...
Create a task definition to use the LUA function
What is still missing the usage of the LUA function. In order to trigger a LUA function whenever a data point changes its value, a Task can be used. To define a Task, open the "Task Definitions" within the "Extensions" menu of the NETx BMS Studio and create a definition. The column "Source Item ID" specified the item which shall trigger the LUA function. This means whenever the value of the item that is specified here is written, the task is trigger. The value of this item can be retrieved within LUA using the function nxa.SourceValue() – the item ID with the function nxa.SourceItemID(). The next column specified an optional destination item. The selected Item can be accessed within LUA using nxa.WriteDestinationValue(value) and nxa.DestinationItemID(). The next three columns are used to define when the task shall be trigger:
- On receive: the task is triggered when a value is received from the field bus (e.g. from KNX or BACnet).
- On sent: the task is triggered when a value is sent to the field bus (e.g. to KNX or BACnet)
- On set: the task is triggered when the value is updated by the server (e.g. due to setting a value within the visualization or by receiving a value from the field bus).
Info |
---|
Normally, all three columns are set to "T" (true) since a task shall always be triggered when a value is changed. Setting one of them to false is only used in special use cases. |
The next column can be used to specify an optional delay. The column "Command" defines the action that shall be triggered by the task. To execute a LUA function "SCRIPT" has to be used. The last column "Parameter" finally defines the LUA function that shall be invoked when "SCRIPT" is used as command type. Here, the LUA function including the parameters have to be entered. In following screenshot shows how our LUA function LimitValue
can be used to monitor the item NETx\VAR\Numeric\Item1
. As destination item, NETx\VAR\Numeric\Item2
is used. 50 is used as lower limit and 100 as upper limit. The e mail address that shall be used is defined as third parameter. The second definition shows how the function can be used without using the e mail functionality.
After having defined the your task, save the definition. Since the Task Definitions are live ones, they are automatically reloaded – a server restart is not necessary. Now test the new tasks. For the given example, set NETx\VAR\Numeric\Item1
to 70. Since it is between 50 and 100, the value 70 is also written to NETx\VAR\Numeric\Item2
. If NETx\VAR\Numeric\Item1
is set to 40, an e mail is sent since the value is below the specified limit.
Related articles
Filter by label (Content by label) | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...