(VTSDriver Library)
Description: Used by a tag to create a request for a single read of a given driver address. (This is in contrast to the polled read request of the AddRead function).
Returns: Object value of underlying read module.
Usage: Script
Format: …\Driver\Read(Address, N, PtrDataDest[, OriginalAddr])
Parameters: Address { text } { required } { no default: }
The starting address of the data to be read.
N { numeric } { required } { no default: }
The number of elements to read.
PtrDataDest { pointer } { required } { no default: }
A pointer to destination for the data. May be a pointer to a variable, an array or the object value of a module. Will be set to Invalid if the read fails.
OriginalAddr { text } { optional } { no default: }
The original address string from an I/O tag. May be different from the address for a DriverMUX. If provided, this will become the first parameter to a NewData call.
Comments: Allows the reading of a specific address on demand. The resulting data will be sent only to the requesting machine. This will also be the case when the function is run in a client-of-a-client configuration.
The object value of the underlying read module is returned from the function. When the read finishes, the returned object’s value will go to Invalid, signaling the end of read.
Example:
If 1 WaitForReadToEnd;
[
Obj = ModDrv1\Driver\Read(40001, 5, &Val);
]
WaitForReadToEnd [
If !Valid(Obj);
[
{ … process data from read … }
{ When Obj is Invalid, read operation is complete and Val }
{ will be an array of 5 values. }
{ If the read did not succeed, such as in the case of server }
{ failover, Val would be an array of 5 Invalid elements. }
]
]
This example reads from addresses 40001 to 40005 of a Modbus driver tag named ModDrv1 and returns the result as an array in the variable Val.
See Also: AddRead