Main Content

OPC HDA Objects

Industrial Communication Toolbox™ uses OPC HDA client objects to connect to OPC HDA servers. After connecting to the client, use the OPC HDA client object to access server details, retrieve namespaces, and read data. By default, the client reads data from the historian and returns it as OPC HDA data objects. These data objects provide a structured mechanism for storing OPC HDA data. Using data objects, you can visualize and manipulate historical data for processing in MATLAB®.

OPC HDA Client Object

You can construct the OPC HDA client object using opchda function and connect to the HDA server using connect. Before creating and connecting an OPC HDA client object to an OPC HDA server, you must locate the server on a particular host. For more information, see Find and Connect to OPC HDA Server.

OPC HDA Data Object

You can store all data returned by the OPC HDA servers in MATLAB as an OPC HDA data object. The HDA data object allows for convenient data storage, manipulation, and visualization. Each data element is represented by one or more values, qualities, and timestamps, all associated with a specific item ID.

When you perform read operations on OPC HDA servers, you request data for one or more item IDs on that server over a specified time range. For each item, the OPC server returns zero or more data object elements stored as triplets of Value (the sensor reading or item value), Quality (the quality of the value stored), and Timestamp (the time the data was logged by the server). The Value, Quality, and Timestamp properties are always M-by-1 vectors. The data type of the Value property depends on what the server returns to MATLAB. See Comparison of MATLAB and COM Variant Data Types.

Each read operation thus returns an array of OPC HDA data objects, one object for each item requested. All data objects in the object array do not have the same number of Value, Quality, and Timestamp triples always, because the server sometimes does not log data at the same time for all items requested. For more information, see Acquire Data from OPC Historical Data Access Server.