Demand Read
The Demand Read action reads a device variable at that point in a trigger's execution, bypassing the initial trigger buffer read at the start of the trigger's 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
Read action forces a read 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 read. 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. |
Output Data Type | The parameter specifies the data
type of the output variable. |
Output Data Count | The value specifies the number of
elements of the output variable. For a single device variable, enter 1. For an array device variable, enter the number of array elements to read. |
Input tab
The Input tab is used to read a device variable. The device name and the variable name must first be passed into the action.
Parameter | Description |
---|---|
Device Name | The name of the device containing the variable whose value you want to read. |
Variable Name | The name of the variable whose value you want to read. |
Output tab
Parameter | Description |
---|---|
Value | The value read from the device
variable. The Logical data type value is set based on the Output Data Type parameter. The Count value is set based on the Output Data Count parameter. |
Demand Read considerations
Device variables are normally "read" when they are the source 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 read directly from the device and not from the previously read internal trigger buffers, the Demand Read 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 Read 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.