Products & Services Solutions Academia Support User Community Company

Learn more about OPC Toolbox   

Understanding OPC Data: Value, Quality, and TimeStamp

Introduction

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.

This section describes the OPC Value, Quality, and TimeStamp properties, and how they should be used together to assess the information provided by an OPC server.

The Relationship Between Value, Quality, and TimeStamp

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:

OPC Toolbox software provides access to the Value, Quality, and TimeStamp properties of a server item through properties of the daitem object associated with that server item.

How Value, Quality, and TimeStamp Are Obtained

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

You initiate a synchronous read operation by using the read function. When you read from a dagroup object, all items in that group are read in one instruction.

You can specify the source of a synchronous read operation as 'cache' or 'device'. 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 updates the daitem object's Value, Quality, and TimeStamp properties with the values read from the server.

OPC Data Returned in Asynchronous Read Operations

You initiate an asynchronous read operation by using the readasync function. 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 EventLog property of the client. The event structure is also passed to the callback function defined in the ReadAsyncFcn property of the 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 the Value, Quality, and TimeStamp properties of the associated daitem object.

OPC Data Returned from a Data Change Event

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 UpdateRate property 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 refresh function.

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 daitem objects by setting their Active property. You control the subscribed status of a dagroup object by setting the Subscription property of the dagroup object.

The following points describe how an OPC server generates a data change event:

When the OPC server generates a data change event, OPC Toolbox software performs the following tasks:

  1. The daitem object Value, Quality, and TimeStamp properties are updated for each item that is included in the data change event.

  2. The callback function defined by the DataChangeFcn property of the dagroup object is called. For more information on callbacks, see Creating and Executing Callback Functions.

  3. If the group is logging data, the data change event is stored in memory and/or on disk. For more information on logging, see Logging OPC Server Data.

  4. If the group is logging, and the number of records acquired is a multiple of the RecordsAcquiredFcnCount property of the dagroup object, then the callback function defined by the RecordsAcquiredFcn property of the dagroup object is called. For more information on callbacks, see Creating and Executing 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.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS