Demand Write

The Demand Write action writes a device variable through to the device at that point in a trigger's execution, bypassing the internal trigger buffer used for device variables that is normally written when the trigger ends execution.

When a trigger starts it execution, all variables referenced by the trigger's actions are read into internal buffers. The variables' values are read from or written to this internal buffer when the variables are referenced by any of the trigger's actions. The internal buffer is written to the devices when the trigger completes its execution.
To bypass this internal buffering, the Demand Write action forces a write of a device variable through the device manager and device driver to the device.

Parameter descriptions

Parameter Description
Device Name The device where the variable resides.
The name can be a constant (entered directly in the parameter), or the name can be dynamically specified.
The default value is the substitution variable, $(Device Name). This can be used along the Input tab parameter Device Name, or it can be changed.
The parameter lets you specify the name of a device using a compound string. The following shows an example Device Name parameter and the row that holds its Id variable in the Input tab.

The substitution variable $(Id) is mapped on the Input tab.
Variable Name The variable to write.
The name can be a constant (entered directly in the parameter), or the name can be dynamically specified.
The default value is the substitution variable, $(Variable Name). This can be used along the Input tab parameter Variable Name, or it can be changed.
The parameter lets you specify the name of a device using a compound string. The following shows an example Variable Name parameter and the rows that hold its Type and Number variables in the Input tab.

The substitution variables $(Type) and $(Number) are mapped in the Input tab.
Input Data Type The parameter specifies the data type of the input variable.

Input Data Count The value specifies the number of elements of the input variable.
For a single variable, enter 1.
For an array variable, enter the number of array elements to write.

Input tab

The parameters in the Input tab are based on the substitution variables used in the Device Name and Variable Name parameters.

The default substitution variables are $(Device Name) and $(Variable Name), which results in an Input tab as show below.


Parameter Description
Device Name The name of the device that contains the variable that you want to write to.
Variable Name The name of the variable whose value you want to write.
Value The value to write to the target variable based on the Device Name and Variable Name parameters.

For the example substitution variables $(Id), $(Type) and $(Number), they would result in a Input tab with those parameters to map to input variables.

Demand Write considerations

Device variables are normally "written to" when they are the destination variable in an action. For example, a Set action has a source variable and a destination variable.

When a trigger starts it execution, all variables referenced by the trigger's actions are read into internal buffers. The variables' values are read from or written to this internal buffer when the variables are referenced by any of the trigger's actions. The internal buffer is written to the devices when the trigger completes its execution. This process maximizes performance of the trigger execution.

In cases where the device variable needs to be written directly to the device and not just into the internal trigger buffers, the Demand Write action is used. These cases need to take into account the overall application logic in the triggers and in the devices to understand the dynamic interaction of all parts of the application. The Demand Write action does take additional resources in terms of processing time (compared to for example a Set action), since the trigger engine and device driver must communicate down to the physical device and get a response. This includes the communication across the network to the device.

The internal trigger buffers (for example the destination variable of a Set action) are written to the devices when the trigger completes its execution.