Execution_signal example
The execution_signal
parameter returns information about the specific signal that triggered execution. If there are multiple possible source signals, it identifies the one that actually initiated the execution. In this example, Modbus RTU protocol is used. Configuration of devices:
Execution_signal
should always be "signal" when execution_signal is used. PORT2 is used to connect IOMod 8DI8DO to WCC Lite via RS485. IOMod signals configuration in this case:
In this case IOMod's input signals are used, but also other signals can be used depending on needs. Map the signals as shown below:
First lua signal is executing first input signal, while second lua signal is executing second input signal. Results signal is used to store information about executed signal.
A Lua script can be written in various ways using the execution_signal
parameter. However, in this example, a simple Lua script is used to retrieve the signal_alias
of the executing signal by accessing execution_signal.tag.signal_alias
:
local DI = execution_signal.tag.signal_alias if DI == "DI1_lua" then publish(signals.results, 1) elseif DI == "DI2_lua" then publish(signals.results, 2) end
This is just one example of execution_signal
usage. It can retrieve different information about executing signal using:
execution_signal.tag.device_alias
- retrieves device_aliasexecution_signal.tag.signal_alias
- retrieves signal_aliasexecution_signal.value.value
- retrieves value of executing signal (for example, 1 or 0)execution_signal.value.time
- retrieves system time in milliseconds (UNIX timestamp)execution_signal.value.attributes
- retrieves attributes (for example, iv, nt, sb)
Upload the configuration to WCC Lite (it should upload without any errors):
Upload Lua script to script runner and press start. After this, Status should show Running and script process number will appear.
After activating first input, in the WCC Lite web's imported signals tab, results should display 1:
After activating second input, in the WCC Lite web's imported signals tab, results should display 2:
Configuration --> Download
Lua script --> Download