beautypg.com

Sr* *sr, 6 editing read image file names – KEYENCE SR-700 Series User Manual

Page 17

background image

17

E SR SCRIPT RM

5-2

Obtaining angular degrees of a tilted barcode

Angular degrees when a workpiece is read from the front are obtained.
* If it is read from angles other than the front, correct angular degrees cannot be

obtained.

* Set the "partition mark" for SR to ":" (colon).

function readformatEvent()

o_data_u
o_data

result() == 2

"READ_ERROR"

data = readResult():cornerCoordinates()
x1_y1 = field(data,1,":")
x2_y2 = field(data,2,":")
x3_y3 = field(data,3,":")
x4_y4 = field(data,4,":")
x1 = tonumber(field(x1_y1,1,"/"))
y1 = tonumber(field(x1_y1,2,"/"))
x2 = tonumber(field(x2_y2,1,"/"))
y2 = tonumber(field(x2_y2,2,"/"))
x3 = tonumber(field(x3_y3,1,"/"))
y3 = tonumber(field(x3_y3,2,"/"))
x4 = tonumber(field(x4_y4,1,"/"))
y4 = tonumber(field(x4_y4,2,"/"))

(x3 - x2) == 0

(y3 - y2) > 0

o_data_u = 0

o_data_u = 180

(y3 - y2) == 0 then

(x3 - x2) > 0 then

o_data_u = -90

o_data_u = 90

o_data_u = (y3 - y2)/(x3-x2)
o_data_u = math.atan(o_data_u)
o_data_u = math.deg(o_data_u)
o_data_u = math.floor(o_data_u)

(x3 > x2)

o_data_u = -90 + o_data_u

o_data_u = 90 + o_data_u

o_data = o_data_u.."[deg]_"..readResult():readData()

(o_data)

end

--Output data

--Displays the message at read

error.

-- Obtains the coordinates at 4 positions of code.
--x1/y1:x2/y2:x3/y3:x4/y4

--Converts it to numerical values

and assigns the value to the
variable.

--Appends read data to output.

Execution result

Read Data

:

Execution result

: 30[deg]_SR

0[deg]_SR

*SR* *SR*

6 Editing read image file names

6-1

Appending read data to the read image file name

* The read data is specified as the image file name. If a code with exactly the same

data contents is read, the same image file name is adopted. In this case, the old
file is overwritten.

6-2

Appending date and time to the read image file name

* When setting the time on the SR-D100 Series, synchronize the time when setting

with the AutoID Network Navigator.

* When setting the time on the SR-1000/750 Series, prepare the SNTP server on

the same network and enable the synchronization with the SNTP.

6-3

Appending date and time and read data to the read image file name

* When setting the time on the SR-D100 Series, synchronize the time when setting

with the AutoID Network Navigator.

* When setting the time on the SR-1000/750 Series, prepare the SNTP server on

the same network and enable the synchronization with the SNTP.

function nameformatEvent()

local

read_data

read_data = readResult():readData()

return

(read_data)

end

-- Obtains the code reading result.

Execution result

Read data

: keyence

Execution result

: keyence.bmp

function nameformatEvent()

return

(time())

end

-- Obtains date information.

Execution result

Read data

: keyence

Execution result

: 20121222120001.bmp

function nameformatEvent()

local

read_data

read_data = readResult():readData()
read_data = time().."_"..read_data

return

(read_data)

end

-- Obtains the code reading result.
-- Appends date information.

Execution result

Read data

: keyence

Execution result

: 20121222120001_keyence.bmp

This manual is related to the following products: