This set of functions are used in combination with tasks. Some functions provide helper functionality that are only invokable within LUA functions that are executed by task (cf. Section 4.5.2). Furthermore, there are functions included that can be used to add and delete task definitions directly within LUA scripts. Using them provides the opportunity to dynamically create task that are not listed within the task definition file. Note that adding and deleting of task can only be done during server start up (e.g. within the callback "OnInitEvent").
Description
Signature
string nxa.SourceItemID | nxa.SourceVar ()
This function can be used to query the ID of the source item that triggered the corresponding task. This function can only be used within LUA functions that are invoked by tasks.
Parameters
None.
Return
Type | Description |
---|---|
string | itemID of the source item that triggered the task |
Description
Signature
string nxa.DestinationItemID ()
This function can be used to query the ID of the destination item that is configured within the corresponding task. This function can only be used within LUA functions that are invoked by tasks.
Parameters
None.
Return
Type | Description |
---|---|
string | itemID of the destination item that is configured within the task |
Description
Signature
nxa.SetDestinationValue (variant)
This function can be used to set a new value for the destination item that is configured within the corresponding task. This function can only be used within LUA functions that are invoked by tasks. Note that the new value will only be set within the server - it will not be forwarded to the field device.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
variant | M | new value of the destination item |
Return
None.
Description
Signature
nxa.WriteDestinationValue (variant)
This function can be used to write a new value to the destination item that is configured within the corresponding task. Compared to setting a value, a value write will also propagate the value change to the field device. This function can only be used within LUA functions that are invoked by tasks.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
variant | M | new value of the destination item |
Return
None.
Description
Signature
variant nxa.ReadDestinationValue ()
This function can be used to read the current value of the destination item that is configured within the corresponding task. This function can only be used within LUA functions that are invoked by tasks.
Parameters
None.
Return
Type | Description |
---|---|
variant | current value of the destination item |
Description
Signature
variant nxa.InputValue | nxa.SourceValue ()
This function can be used to query the value of the source item that triggered the corresponding task. This function can only be used within LUA functions that are invoked by tasks.
Parameters
None.
Return
Type | Description |
---|---|
variant | current value of the source item |
Description
Signature
nxa.ExecuteDelayedScript (string, number)
This function executes a LUA script that is specified as String parameter. The execution can optionally be delayed.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
string | M | name of the LUA script | |
number | O | delay in milliseconds (optional) |
Return
None.
Description
Signature
nxa.AddWriteTask (string, string, bool, bool, bool, number, variant)
This function adds a new "WRITE" task definition during runtime.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
string | M | itemID of the source Server Item that triggers the task | |
string | M | itemID of the destination Server Item that is changed by the task | |
bool | M | corresponds to the "OnReceive" parameter of the task definition (cf. Section 4.5.2) | |
bool | M | corresponds to the "OnSend" parameter of the task definition (cf. Section 4.5.2) | |
bool | M | corresponds to the "OnSet" parameter of the task definition (cf. Section 4.5.2) | |
number | M | time interval in milliseconds that the task will be delayed when triggered | |
variant | O | if used, this value will be used instead of the value of the source item (optional) |
Return
None.
Description
Signature
nxa.AddReadTask (string, string, bool, bool, bool, number)
This function adds a new "READ" task definition during runtime.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
string | M | itemID of the source Server Item that triggers the task | |
string | M | itemID of the Server Item that has to be read | |
bool | M | corresponds to the "OnReceive" parameter of the task definition (cf. Section 4.5.2) | |
bool | M | corresponds to the "OnSend" parameter of the task definition (cf. Section 4.5.2) | |
bool | M | corresponds to the "OnSet" parameter of the task definition (cf. Section 4.5.2) | |
number | M | time interval in milliseconds that the task will be delayed when triggered |
Return
None.
Description
Signature
nxa.AddSetTask (string, string, bool, bool, bool, number, variant)
This function adds a new "SET" task definition during runtime.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
string | M | itemID of the source Server Item that triggers the task | |
string | M | itemID of the destination Server Item that is changed by the task | |
bool | M | corresponds to the "OnReceive" parameter of the task definition (cf. Section 4.5.2) | |
bool | M | corresponds to the "OnSend" parameter of the task definition (cf. Section 4.5.2) | |
bool | M | corresponds to the "OnSet" parameter of the task definition (cf. Section 4.5.2) | |
number | M | time interval in milliseconds that the task will be delayed when triggered | |
variant | O | if used, this value will be used instead of the value of the source item (optional) |
Return
None.
Description
Signature
nxa.AddScriptTask (string, string, bool, bool, bool, number, string, number)
This function adds a new "SCRIPT" task definition during runtime.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
string | M | sourceItemID | |
string | M | destinationItemID | |
bool | M | corresponds to the "OnReceive" parameter of the task definition (cf. Section 4.5.2) | |
bool | M | corresponds to the "OnSend" parameter of the task definition (cf. Section 4.5.2) | |
bool | M | corresponds to the "OnSet" parameter of the task definition (cf. Section 4.5.2) | |
number | M | time interval in milliseconds that the task will be delayed when triggered | |
string | M | LUA script name that will be executed when the task is triggered | |
number | M | (optional) ModuleID. Needs to be > 5000. Can be referenced in the nxa.RemoveScriptTask function. |
Return
None.
Description
Signature
bool nxa.AddVarTask (string, string, number)
This function can be used to add a task that is triggered if a variable changes its value.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
string | M | name of the variable that shall be the trigger for the task. | |
string | M | name of the LUA function that shall be invoked. | |
number | M | (optional) delay for executing the function. |
Return
Type | Description |
---|---|
bool | true on success, false otherwise |
Description
Signature
nxa.RemoveScriptTask (string, number)
Removes all "SCRIPT" tasks matching the provided parameters from the runtime system, even if defined in the definition file.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
string | M | sourceItemID | |
number | M | (optional) ModuleID as set in the nxa.AddScriptTask function. |
Return
None.
Description - INTERNAL DOCUMENTATION
Signature
nxa.ExecuteXCommandValue (string)
This function is used to execute an XLogic command within LUA. This version takes a single string as parameter which includes all parameters.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
string | M | XCommand including all parameters as string |
Return
None.
Description - INTERNAL DOCUMENTATION
Signature
nxa.ExecuteXCommand (string, string, ...)
This function is used to execute an XLogic command within LUA. This version takes a single string as parameter which includes all parameters.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
string | M | Namd of XCommand. The variable scope is encoded as "'"'. If no scope is needed only the XCommand name shall be given. | |
string | M | Inputs, Parameters and Outputs | |
... |
Return
None.
Description - INTERNAL DOCUMENTATION
Signature
number nxa.GetFreeTransactionID ()
This function returns the next free transaction IDs which can be used to identify a task. The transaction ID is never reused. The transaction ID can be used as last parameter for the functions nxa.SetValue, nxa.WriteValue, nxa.ReadValue, nxa.SetDestinationValue, nxa.WriteDestinationValue, nxa.ReadDestinationValue, nxa.ExecuteDelayedScript
Parameters
None.
Return
Type | Description |
---|---|
number | transaction ID |
Description - INTERNAL DOCUMENTATION
Signature
nxa.CancelTransaction (number)
Aborts a currently running task using its transaction ID.
Parameters
Name | Type | Mandatory/Optional | Description |
---|---|---|---|
number | M | transaction ID of the task that shall be canceled. |
Return
None.