Skip to main content

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 initiated the execution. In this example, the Modbus RTU protocol is used. Configuration of devices:

image-1740645086014.png

Execution_signal should always be "signal" when execution_signal is used. PORT2 is used to connect IOMod 8DI8DO to WCC Lite via RS-485. IOMod signals configuration in this case:

image-1740645367520.png

In this case, IOMod's input signals are used, but other signals can be used depending on needs. Map the signals as shown below:

image-1740646177825.png

The first Lua signal is executing the first input signal, while the second Lua signal is executing the second input signal. The results signal is used to store information about the 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 a signal using:

  • execution_signal.tag.device_alias - retrieves device_alias
  • execution_signal.tag.signal_alias - retrieves signal_alias
  • execution_signal.value.value - retrieves the value of the 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):

image-1740649584122.png

Upload the Lua script to the script runner and press start. After this, Status should show Running, and the script process number will appear.

image-1740649663116.png

After activating the first input, in the WCC Lite web's imported signals tab, results should display 1:

image-1740650410927.png

After activating the second input, in the WCC Lite web's imported signals tab, results should display 2:

image-1740650545463.png

Configuration --> Download

Lua script --> Download