Appendix G: Lua Scripts
X-600M Users Manual
-- loop forever
while true do
–- check for received bytes
rc = serGetRXByteCount(“io.serialPort1”)
-– if no bytes received sleep for 50 ms else echo the received bytes
if rc <= 0 then
sleep(50)
else
data = serRead(“io.serialPort1”)
rc = serWrite(“io.serialPort”, “Received: “)
rc = serWrite(“io.serialPort1”, data)
end
End
getLastAccessUser(ioName)
This function will return the Full Name of the user who last accessed the io specified by ioName.
getLastAccessTime(ioName)
This function will return the date and time that corresponds to user who last accessed the io
specified by ioName.
getDesc(ioName)
This function will return the description of the io specified by ioName.
The previous 3 functions are useful for generating content for email messages. The following
example shows how they can be used when creating an action to send an email.
Assume an action has been created that will be executed whenever an relay is turned on to send an
email. The relay description has been configured as “First Level Lights” and a user has been
configured whose full name has been configured as “Jon Doe”. The body of the email has been
configured as:
[getDesc("io.relay1")] changed states. The last user to access the
[getDesc("io.relay1")] was [getLastAccessUser("io.relay1")] at
[getLastAccessTime("io.relay1")].
When the user Jon Doe turns the relay on, the following email will be sent:
“First Level Lights changed states. The last user to access the First Level Lights was Jon Doe at
Thu Jun 4 11:26:56 2015.”
Notice that in this instance (action type send email), the body of the email is not a Lua script but
rather plain text. To evaluate Lua code and insert the result into the email body, square brackets are
used to surround the Lua code. When using these function from a Lua script, the square brackets
are omitted.
Page 136
Xytronix Research & Design, Inc.
Содержание X-600M
Страница 1: ...X 600MTitle Page Goes Here...
Страница 6: ...X 600M Users Manual Page 4 Xytronix Research Design Inc...
Страница 99: ...X 600M Users Manual Setup Pages Xytronix Research Design Inc Page 97...
Страница 116: ...Appendix B Installing New Firmware X 600M Users Manual Page 114 Xytronix Research Design Inc...