Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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"). <file name="nxa.SourceItemID | nxa.SourceVar">
<h1>Description</h1>
<h1>Signature</h1>

Description

Signature

string nxa.SourceItemID | nxa.SourceVar () <p>This

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.</p>
<h1>Parameters</h1>

Parameters

None. <h1>Return</h1>

Return

...

TypeDescription
stringitemID of the source item that triggered the

...

task

Description

Signature

string nxa.DestinationItemID () <p>This

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.</p>
<h1>Parameters</h1>

Parameters

None. <h1>Return</h1>

Return

...

TypeDescription
stringitemID 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.</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>variant</td><td>M</td><td>new value of the destination item</td></tr>
</tbody>
</table>
<h1>Return</h1> None.
</file>
<file name="nxa.WriteDestinationValue">
<h1>Description</h1>
<h1>Signature</h1>

Parameters

NameTypeMandatory/OptionalDescription
 variantMnew value of the destination item

Return

None.

Description

Signature

nxa.WriteDestinationValue (variant) <p>This

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.</p> <h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>variant</td><td>M</td><td>new value of the destination item</td></tr>
</tbody>
</table>
<h1>Return</h1> None.
</file>
<file name="nxa.ReadDestinationValue">
<h1>Description</h1>
<h1>Signature</h1>

Parameters

NameTypeMandatory/OptionalDescription
 variantMnew value of the destination item

Return

None.

Description

Signature

variant nxa.ReadDestinationValue () <p>This

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.</p>
<h1>Parameters</h1>

Parameters

None. <h1>Return</h1>

Return

...

TypeDescription
variantcurrent value of the destination

...

item

Description

Signature

variant nxa.InputValue | nxa.SourceValue () <p>This

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.</p>
<h1>Parameters</h1>

Parameters

None. <h1>Return</h1>

Return

...

TypeDescription
variantcurrent value of the source

...

item

Description

Signature

nxa.ExecuteDelayedScript (string, number) <p>This

This function executes a LUA script that is specified as String parameter. The execution can optionally be delayed.</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>string</td><td>M</td><td>name of the LUA script</td></tr>
<tr><td></td><td>number</td><td>O</td><td>delay

Parameters

NameTypeMandatory/OptionalDescription
 stringMname of the LUA script
 numberOdelay in milliseconds (optional)

...

Return

None. </file>
<file name="nxa.AddWriteTask">
<h1>Description</h1>
<h1>Signature</h1>

Description

Signature

nxa.AddWriteTask (string, string, bool, bool, bool, number, variant) <p>This

This function adds a new "WRITE" task definition during runtime.</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th> <th>Description</th>
</tr>
<tr><td></td><td>string</td><td>M</td><td>itemID

Parameters

NameTypeMandatory/OptionalDescription
 stringMitemID of the source Server Item that triggers the

...

task
 stringMitemID of the destination Server Item that is changed by the

...

task
 boolMcorresponds to the "OnReceive" parameter of the task definition (cf. Section 4.5.2)

...

 boolMcorresponds to the "OnSend" parameter of the task definition (cf. Section 4.5.2)

...

 boolMcorresponds to the "OnSet" parameter of the

...

task definition (cf. Section 4.5.2)

...

 numberMtime interval in milliseconds that the task will be delayed when

...

triggered
 variantOif used, this value will be used instead of the value of the source item (optional)

...

Return

None. </file>
<file name="nxa.AddReadTask">
<h1>Description</h1>
<h1>Signature</h1>

Description

Signature

nxa.AddReadTask (string, string, bool, bool, bool, number) <p>This

This function adds a new "READ" task definition during runtime.</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>string</td><td>M</td><td>itemID

Parameters

NameTypeMandatory/OptionalDescription
 stringMitemID of the source Server Item that triggers the

...

task
 stringMitemID of the Server Item that has to be

...

read
 boolMcorresponds to the "OnReceive" parameter of the task definition (cf. Section 4.5.2)

...

 boolMcorresponds to the "OnSend" parameter of the task definition (cf. Section 4.5.2)

...

 boolMcorresponds to the "OnSet" parameter of the task definition (cf. Section 4.5.2)

...

 numberMtime interval in milliseconds that the task will be delayed when

...

triggered

Return

None. </file>
<file name="nxa.AddSetTask">
<h1>Description</h1>
<h1>Signature</h1>

Description

Signature

nxa.AddSetTask (string, string, bool, bool, bool, number, variant) <p>This

This function adds a new "SET" task definition during runtime.</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>string</td><td>M</td><td>itemID

Parameters

NameTypeMandatory/OptionalDescription
 stringMitemID of the source Server Item that triggers the

...

task
 stringMitemID of the destination Server Item that is changed by the

...

task
 boolMcorresponds to the "OnReceive" parameter of the task definition (cf. Section 4.5.2)

...

 boolMcorresponds to the "OnSend" parameter of the task definition (cf. Section 4.5.2)

...

 boolMcorresponds to the "OnSet" parameter of the task definition (cf. Section 4.5.2)

...

 numberMtime interval in milliseconds that the task will be delayed when

...

triggered
 variantOif used, this value will be used instead of the value of the source item (optional)

...

Return

None. </file>
<file name="nxa.AddScriptTask">
<h1>Description</h1>
<h1>Signature</h1>

Description

Signature

nxa.AddScriptTask (string, string, bool, bool, bool, number, string, number) <p>This

This function adds a new "SCRIPT" task definition during runtime.</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th> <th>Description</th>
</tr>
<tr><td></td><td>string</td><td>M</td><td>sourceItemID</td></tr>
<tr><td></td><td>string</td><td>M</td><td>destinationItemID</td></tr>
<tr><td></td><td>bool</td><td>M</td><td>corresponds

Parameters

NameTypeMandatory/OptionalDescription
 stringMsourceItemID
 stringMdestinationItemID
 boolMcorresponds to the "OnReceive" parameter of the task definition (cf. Section 4.5.2)

...

 boolMcorresponds to the "OnSend" parameter of the task definition (cf. Section 4.5.2)

...

 boolMcorresponds to the "OnSet" parameter of the task definition (cf. Section 4.5.2)

...

 numberMtime interval in milliseconds that the task will be delayed when

...

triggered
 stringMLUA script name that will be executed when the task is

...

triggered
 numberM(optional) ModuleID. Needs to be > 5000.

...

Can be referenced in the nxa.RemoveScriptTask function.

...

Return

None. </file>
<file name="nxa.AddVarTask">
<h1>Description</h1>
<h1>Signature</h1>

Description

Signature

bool nxa.AddVarTask (string, string, number) <p>This

This function can be used to add a task that is triggered if a variable changes its value.</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>string</td><td>M</td><td>name

Parameters

NameTypeMandatory/OptionalDescription
 stringMname of the variable that shall be the trigger for the task.

...

 stringMname of the LUA function that shall be invoked.

...

 numberM(optional) delay for executing the function.

...

Return

TypeDescription
booltrue on success, false

...

otherwise

Description

Signature

nxa.RemoveScriptTask (string, number) <p>Removes

Removes all "SCRIPT" tasks matching the provided parameters from the runtime system, even if defined in the definition file.</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>string</td><td>M</td><td>sourceItemID</td></tr>
<tr><td></td><td>number</td><td>M</td><td>

Parameters

NameTypeMandatory/OptionalDescription
 stringMsourceItemID
 numberM(optional) ModuleID as set in the nxa.AddScriptTask function.

...

Return

None.

Description - INTERNAL DOCUMENTATION

Signature

nxa.ExecuteXCommandValue (string) <p>This

This function is used to execute an XLogic command within LUA. This version takes a single string as parameter which includes all parameters.</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>string</td><td>M</td><td>XCommand including all parameters as string</td></tr>
</tbody>
</table>
<h1>Return</h1> None.
</file>
<file name="nxa.ExecuteXCommand">
<h1>Description - INTERNAL DOCUMENTATION</h1>
<h1>Signature</h1>

Parameters

NameTypeMandatory/OptionalDescription
 stringMXCommand including all parameters as string

Return

None.

Description - INTERNAL DOCUMENTATION

Signature

nxa.ExecuteXCommand (string, string, ...) <p>This

This function is used to execute an XLogic command within LUA. This version takes a single string as parameter which includes all parameters.</p>
<h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>string</td><td>M</td><td>Namd

Parameters

NameTypeMandatory/OptionalDescription
 stringMNamd of XCommand. The variable scope is encoded as "'

...

"'. If no scope is needed only the XCommand name shall be given.

...

 stringMInputs, Parameters and Outputs
 ...

Return

None.

Description - INTERNAL DOCUMENTATION

Signature

number nxa.GetFreeTransactionID () <p>This

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</p>
<h1>Parameters</h1> ExecuteDelayedScript

Parameters

None. <h1>Return</h1>

Return

...

TypeDescription
numbertransaction ID

Description - INTERNAL DOCUMENTATION

Signature

nxa.CancelTransaction (number) <p>Aborts

Aborts a currently running task using its transaction
ID.</p> <h1>Parameters</h1>
<table>
<colgroup> <col/> <col/> <col/> <col/> </colgroup>
<tbody>
<tr>
<th>Name</th>
<th>Type</th>
<th>Mandatory/Optional</th>
<th>Description</th>
</tr>
<tr><td></td><td>number</td><td>M</td><td>transaction

Parameters

NameTypeMandatory/OptionalDescription
 numberMtransaction ID of the task that shall be canceled.

...

Return

None.