Setup Pages
X-600M Users Manual
Script:
Type the text for your script into this box. When you click
Add
, the script is checked for correct
syntax. If an error occurs, the first error will be highlighted. You will not be able to add a script with
faulty syntax. To cause the script to run continually, it must contain an all encompassing loop,
otherwise when the X-600M first turns on the script will run to completion and then end. Scripts can
be up to 8K in length.
Lua Documentation
The Lua reference manual can be found at
/x600m/downloads.html. For more
detailed information please see
Appendix G
on Lua Scripts. Several example scripts are shown below:
The following Lua e
xpression
converts a 1-Wire temperature sensor named “owSensor1” from
Fahrenheit °F to Centigrade °C and assigns it to the register named “register1”.
reg.register1 = (io.owSensor1-32)*5/9
The following Lua
expression
changes the raw data from an analog I/O named “analog1” to engineering
units with the linear equation Y=mX+b and places the result in a register named “register1”.
reg.register1 = io.analog1*0.75 + 5
The following Lua script runs continually. This script monitors a counter in several remote ControlByWeb
X-320 modules for activity (counter1 - counter4). If the counters quit advancing or the communications
fail, the script sends an Email warning that a production machine has jammed.
-- wait for X600 to get current values of counters
-- before starting
sleep(10000)
-- initialize previous counter values
prevCount1 = io.counter1
prevCount2 = io.counter2
prevCount3 = io.counter3
prevCount4 = io.counter4
-- warningFlag indicates if an email needs to be sent
warningFlag = 0
-- prevent sending multiple emails. Make flag a register so it can be reset
-- from the dashboard. This register is configured under the register tab and
-- named emailSent
reg.emailSent = false
-- define the email to send
emailDef = {
rcpt = "grp.admin",
subj = [[WARNING!! Production machine has jammed.]],
body = [[Production machine needs attention.]]
}
-- loop forever
while true do
-- wait 10 seconds before checking counters
sleep(10000)
-- check to see if the counters have changed
if prevCount1 ~= io.counter1 then
warningFlag = 1
Page 80
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...