Reputation: 330
In my company i've a QR reader made by Keyence with which we read codes in our production line.
The images acquired by the sensor are saved on an FTP server, and for business needs, the name of the images must be in the format: yyyymmdd_qrcodecontent.jpg
.
On the sensor we already have a script in .lua
that saves the images with the naming qrcodecontent.jpg
.
I don't know the lua language, and from the documentation I could not find info on how to add date information
Do you have any suggestions or advice?
function nameformatEvent()
local read_data
read_data = readResult():readData()
return(read_data)
end
Upvotes: 1
Views: 371
Reputation: 38
You can probably use some os
functions.
For the date formatting on the filename, you could write a quick function like this:
function GenerateFilename()
return os.date("%d%m%y") .. "_qrcodecontent"
end
You can probably configure a filename somewhere. I don't know what the code for readResult and :readData is, but check the content of those functions.
Just add .jpg/.jpeg to the end if it doesn't generate the file extension (change _qrcodecontent
to _qrcodecontent.jpg
).
Upvotes: 0
Reputation: 28994
Lua provides date and time through its os
library.
https://www.lua.org/manual/5.4/manual.html#pdf-os
You can get a formatted date string through os.date
.
Search the Keyence scripting manual for date
and time
. Run a script with print(os)
. If it prints nil
that library is not available. At least it is not listed in the manual while some other standard libraries are.
If Keyence's scripting API does not provide the os library and no other means to get the current date and time you cannot access that information.
I'm not aware that the Keyence readers have a realtime clock on-board, so that information is probably not available on the sensor.
Get in touch with the Keyence support. That's what they're getting payed for.
Upvotes: 1