Read data synchronously from OPC DA groups or items
S = read(
data for all the items contained in the
GObj, or for the vector of
IObj. The data is read from the OPC server’s cache, and
assigned to the structure
You can synchronously read from the cache only if the
property is set to
'on' for both the item and the group that
contains the item. A warning is issued if any of the objects passed to
read are inactive. An inactive item is still returned in
S, but the
Quality is set to
'BAD: Out of Service'.
S = read(
read data from the source specified by
S = read(
Src can be
'device', data is returned directly from the device. If
'cache', data is returned from the
OPC server's cache, which contains a copy of the device data. Note that the
Active property is ignored when reading from
'device'. Note also, that reading data from the device can be
Read Data from a Group
This example reads from a device and cache.
Configure a client, group, and item for the Matrikon™ Simulation Server. Set the update rate for this group to prevent frequent cache updates.
da = opcda('localhost','Matrikon.OPC.Simulation'); connect(da); grp = addgroup(da,'ExRead'); grp.UpdateRate = 20; itm = additem(grp,'Random.Real8');
Read twice from the cache, noting that the values are the same each time.
v1 = read(grp) v2 = read(grp)
Now read twice from the device, noting that the value updates each time.
v3 = read(grp,'device') v4 = read(grp,'device')
GObj — OPC DA group
OPC DC group, specified as a
GObj = addgroup()
IObj — OPC DA item
OPC DA items, specified as an array of opcda item objects.
IObj = additem()
Src — Data source to read
Data source to read, specified as
S — Read data
Read data, returned as a structure containing data for each item in the following fields:
Fully qualified item name
double, character vector
Quality of the value
The time that the value and quality was obtained by the device (if this is available), or the time the server updated or validated the value and quality in its cache
Introduced before R2006a