OPC servers provide access to many server items. To reduce network traffic between the server and the "device" associated with each server item (a field instrument, or a memory location in a PLC, SCADA, or DCS system) the OPC server stores information about each server item in the server's "cache," updating that information only as frequently as required to satisfy the requests of all clients connected to that server. Because this process results in data in the cache that may not reflect the actual value of the device, the OPC server provides the client with additional information about that value.
Every server item on an OPC server has three properties that describe the status of the device or memory location associated with that server item:
Value — The
the server item is the last value that the OPC server stored for that
particular item. The value in the cache is updated whenever the server
reads from the device. The server reads values from the device at
the update rate specified by the
and only when the item and group are both active. You control the
active status of an item or group using that object's
In addition, for analog type data (data with the additional
OPC Foundation Recommended Properties
'High EU' and
EU') the percentage change between the cached value and
the device value must exceed the
specified for that item in order for the cached value to be updated.
Quality — The
the server item is a character vector that represents information
about how well the cache value matches the device value. The
Quality is made up of two parts: a major
quality, which can be
'Uncertain', and a minor quality, which describes
the reason for the major quality. For more information on
see OPC Quality.
Quality of the server item can change
Value changing. For instance, if the
OPC server attempts to obtain a
Value from the
device but that operation fails, the
be set to
'Bad'. Also, when you change the client's
Active property, the
You must always examine the
Quality of an
item before using the
Value property of that item.
TimeStamp — The
a server item represents the most recent time that the server assessed
that the device set the
of that server item. The
TimeStamp can change without
Value changing. For example, if the OPC server
obtains a value from the device that is the same as the current
TimeStamp property will still be updated, even
Value property is not.
OPC Toolbox™ software provides access to the
TimeStamp properties of a server item through
properties of the
daitem object associated with
that server item.
OPC Toolbox software provides all three OPC Data Access Standard mechanisms for reading data from an OPC server. The toolbox uses these three mechanisms in various ways to return data from those functions, to provide event information, to update properties of toolbox objects, and to log data to memory and disk.
The way OPC Toolbox software uses the three OPC Data Access mechanisms is described in the following sections:
OPC Data Returned from Synchronous Read Operations describes
the synchronous read mechanism used by the
OPC Data Returned in Asynchronous Read Operations describes
the asynchronous read mechanism used by the
OPC Data Returned from a Data Change Event describes the data change event notification mechanism used with subscribed, active groups, with the refresh function, and by the toolbox logging process.
You initiate a synchronous read operation by using the
read function. When you read from a
all items in that group are read in one instruction.
You can specify the source of a synchronous read operation as
If you read from the cache, the server simply returns the value in
the cache. If you read from the device, the server will get the value
from the device and update the cache before sending the Value, Quality,
and TimeStamp information back as part of the read operation.
OPC Toolbox software returns the data in the output structure from the read operation. Each element of the structure array contains information about one of the items read.
Whenever you read values using the read function, the toolbox
TimeStamp properties with the values read from
You initiate an asynchronous read operation by using the
When you read from a
dagroup object, all items
in that group are read in one instruction.
Asynchronous read operations always use the device as the source of the read. Whenever you send an asynchronous read request, the server will read values from the devices connected to the items. The server will then update that server item's Value, Quality, and TimeStamp in the cache before sending an asynchronous read event back to the toolbox.
OPC Toolbox software returns information from an asynchronous
read operation via the read async event structure. This event structure
is stored in the
opcda client object's event log,
which you can access using the
of the client. The event structure is also passed to the callback
function defined in the
ReadAsyncFcn property of
dagroup object that initiated the asynchronous
read operation. For more information on the format of the event structures,
see Event Structures.
When an asynchronous read operation succeeds, in addition to
returning data via the event structures, the toolbox also updates
of the associated
The third mechanism for getting data from an OPC server involves
the data change event. The OPC server generates a data change event
for a group at the period specified by the
when the Value or Quality of an item in the group changes. You do
not have to specifically request a data change event, because the
OPC server will automatically generate a data change event. However,
you can force a data change event at any time using the
An OPC server will generate a data change event only for an
active, subscribed group containing active items. You control the
active status of
dagroup objects and
by setting their
Active property. You control the
subscribed status of a
dagroup object by setting
Subscription property of the
The following points describe how an OPC server generates a data change event:
When you configure a group, you define the rate at
which the server must scan items in that group. This rate is controlled
UpdateRate property for a
The server updates the Value, Quality, and TimeStamp values in the
cache for the items in that group at the required update rate. Note
that if a device cannot provide a value in that time, the server may
reduce the rate at which it updates the value in the server cache
for that item.
If you set an item's
'off', the server will stop scanning that item.
You must set the
Active property to
the server to scan the item again.
If you set the Active property of a
'off', the server will stop scanning all items
in that group. You can still perform asynchronous read operations,
and synchronous read operations from the
but no operations involving the server cache can be performed. You
must set the
Active property to
enable operations involving the server cache.
Subscription property for
dagroup object is set to
then every time the server updates cache values for the items in that
group, the server will send a data change event for that group, to
the client object. The data change event contains information about
every item whose Value, Quality, or TimeStamp updated.
If you set the
'off', then the OPC server will not generate
data change events. However, as long as the group is still active,
the OPC server will continue to scan all active items for that group,
at the rate specified by the
When the OPC server generates a data change event, OPC Toolbox software performs the following tasks:
TimeStamp properties are updated for each item
that is included in the data change event.
The callback function defined by the
dagroup object is called. For more information
on callbacks, see Create and Execute Callback Functions.
If the group is logging data, the data change event is stored in memory and/or on disk. For more information on logging, see Log OPC Server Data.
If the group is logging, and the number
of records acquired is a multiple of the
dagroup object, then the callback function
defined by the
RecordsAcquiredFcn property of the
is called. For more information on callbacks, see Create and Execute Callback Functions.
For more information on the structure of a data change event, see Data Fields for Cancel Async, Data Change, Error, Read Async, and Write Async Events.