Download ip.buffer User Manual
Transcript
Scannex ip.buffer User Manual © UK 2007-2015 Scannex Electronics Ltd. All rights reserved worldwide. 15.3. Example scripts Scannex have a set of example scripts: http://www.scannex.com/scripts More information on programming in Lua is available from: http://www.lua.org/ http://www.lua.org/pil/ and from the book “Programming in Lua, 2nd Edition”. 15.3.1. Simple prefix This simple script demonstrates how to perform simple filtering and changes to the incoming record stream. In this example, we assume that channel 4 is being filtered and we need a simple date and time prefix to each record, in the form “MM/DD HH:MM”. function datetimeprefix(rec, chnl, tag) local t,s t = i.now s = string.sub(t,6,7)..“/”..string.sub(t,9,10)..“ ”..string.sub(t,12,13)..“:”..string.sub(t,15,16)..“ ” mem.write(chnl,s..rec) end x.chnl[4].src.onrecord = datetimeprefix The function “datetimeprefix” simply takes the global value “i.now” and splits it into the month, day, hour and minute values. It then writes the prefix and original record to the memory channel specified (you could also use a hard-coded channel number, e.g. “mem.write(4,s..rec)”. The last line “glues” the function to the event for channel 4, so that when a record arrives the ip.buffer will call the Lua function rather than storing. This functionality is easier to do with the Protocol Time Stamp field of “%m/ %d %H:%M ” (without the quotes) Page 121