User guide

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()
local o_data_u
local o_data
if result() == 2 then
return "READ_ERROR"
end
local data = readResult():cornerCoordinates()
local x1_y1 = field(data,1,":")
local x2_y2 = field(data,2,":")
local x3_y3 = field(data,3,":")
local x4_y4 = field(data,4,":")
local x1 = tonumber(field(x1_y1,1,"/"))
local y1 = tonumber(field(x1_y1,2,"/"))
local x2 = tonumber(field(x2_y2,1,"/"))
local y2 = tonumber(field(x2_y2,2,"/"))
local x3 = tonumber(field(x3_y3,1,"/"))
local y3 = tonumber(field(x3_y3,2,"/"))
local x4 = tonumber(field(x4_y4,1,"/"))
local y4 = tonumber(field(x4_y4,2,"/"))
if (x3 - x2) == 0 then
if (y3 - y2) > 0 then
o_data_u = 0
else
o_data_u = 180
end
elseif (y3 - y2) == 0 then
if (x3 - x2) > 0 then
o_data_u = -90
else
o_data_u = 90
end
else
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)
if (x3 > x2) then
o_data_u = -90 + o_data_u
else
o_data_u = 90 + o_data_u
end
end
o_data = o_data_u.."[deg]_"..readResult():readData()
return (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