Main Content

readProcessed

Read server-aggregated data from an OPC HDA server

Syntax

DObj = readProcessed(HdaObj,ItmList,AggregateType,AggregateInterval,StartTime,EndTime)
[ItmID,Value,Quality,TimeStamp] = readProcessed(HdaObj,ItmList,AggregateType,AggregateInterval,StartTime,EndTime,'DataType')
S = readProcessed(HdaObj,ItmList,AggregateType,AggregateInterval,StartTime,EndTime,'struct')

Description

DObj = readProcessed(HdaObj,ItmList,AggregateType,AggregateInterval,StartTime,EndTime) reads processed data from the OPC HDA Server associated with client object HdaObj, returning the processed data in opc.hda.Data object DObj. HdaObj must be a scalar OPC HDA client that is already connected to the server.

ItmList is a string array or cell array of item IDs to read from. AggregateType is the requested aggregate type, obtained from the client’s Aggregates property. AggregateInterval is the time interval in seconds that the server must aggregate data over. StartTime and EndTime are MATLAB date numbers representing the start and end times of the period over which data must be aggregated.

[ItmID,Value,Quality,TimeStamp] = readProcessed(HdaObj,ItmList,AggregateType,AggregateInterval,StartTime,EndTime,'DataType') returns the processed data as separate arrays. 'DataType' is one of the built-in MATLAB numeric arrays ('double', 'single', etc.) or 'cell'. ItmID is returned as a 1-by-N cell array of character vectors. Value is an array of M-by-N values. Quality is an array of M-by-N quality IDs, and TimeStamp is a M-by-1 array of time stamps as MATLAB date numbers.

S = readProcessed(HdaObj,ItmList,AggregateType,AggregateInterval,StartTime,EndTime,'struct') returns the processed data as a structure containing fields ItemID, Value, Quality and TimeStamp.

Examples

Create an OPC HDA Client and connect the client to the server:

hdaObj = opchda('localhost','Matrikon.OPC.Simulation');
connect(hdaObj);

Read the one minute average values of two items for the last hour:

aggregates = hdaObj.Aggregates
DObj = readProcessed(hdaObj,{'Random.Real8','Random.Real4'}, ...
         aggregates.TIMEAVERAGE,60,now-1/24,now);

Version History

Introduced in R2011a