AddRead

(VTSDriver Module)

Description: Add a read request.
Returns: Nothing
Usage: Script Only.
Function Groups: Memory I/O
Related to: DelRead
Format: VTSDriver\AddRead(Address, N, Value, Rate[, OriginalAddr, DisablePolling, DeadbandValue])
Parameters:  
Address
Required. Any expression for the address from which to get the data.
N
Required. Any expression for the number of elements to retrieve.
Value
Required. A pointer to the destination for the read data.
Rate
Required. Any numeric expression for the update rate, measured in seconds.
OriginalAddr
For use only by the Driver Multiplexer. Set Invalid in all other instances. The original address string specified in the I/O tag before being parsed into an value that is fit for the Address parameter of AddRead. For example, the original address may be {40001}{42001}, but the address given to the subordinate driver would be 40001.
DisablePolling
Primarily for use by the Driver Multiplexer. In general, should be set to Invalid for other drivers. Any numeric expression, setting a rate value for which Polling will be disabled. Polls will then only be performed by a call to Driver\PollAll() or by setting the Read module’s Trigger.
DeadbandValue

Optional numeric, applying to analog values only. Sets a minimum amount by which the unscaled values must change before a new value is reported to NewData.

Comments:

This module is called by a tag to add a request to read a specific range of memory and set the resulting read data into the variable pointed to by the third parameter.

 

If using this function in custom code, note that the AddRead must run on the current I/O server in order to retrieve data. An AddRead executing only on a client workstation will subscribe to the data but not cause a read.

 

The pointer (3rd parameter) may be a simple variable for one element read or an object reference.

Use of an object for the Value parameter allows a synchronous way of reporting new data. The object must be a module with a subroutine named NewData. NewData will have the following parameters:

Address
Required. The original address that AddRead was called with. Should be an array if Data is an array.
TimeStamp
Required. The timestamp of the data, in UTC. Should be an array if Data is an array.
Data
Required. The data value(s). May be an array of arbitrary size.
Attribute
Optional. Auxiliary data value - rarely used.
ServiceSync
Optional Boolean. TRUE when NewData is being called because the service is synchronizing, rather than when the driver reported new data.
Comments The NewData callback may only be called if RefreshData resulted in a value change (affected by PropagateOnlyOnDataChange). If Data is an array, and only element [i] changed, then the TimeStamp array is used to indicate changes. A valid TimeStamp[i] means that Value[i] and Attribute[i] are valid. Invalid TimeStamp[i] means that Value[i] and Attribute[i] will be invalid since they have not changed.

Example:

For an in-context example, refer to Template.SRC, provided in the Examples folder of your VTScada installation.

{ SetDefaultSetpoints } ( ) [ Var; ] Init [ If \PumpStationSimulator.Ready Main; [ \PumpStationSimulator.Driver.Addread(40001, 1, &Var, 1); ] ] Main [ If Watch(1, Var); [ ... ]