This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Package: opc.hda

Read server-aggregated data from an OPC HDA server


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')


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 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.


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

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

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

aggregates = hdaObj.Aggregates
DObj = readProcessed(hdaObj,{'Random.Real8','Random.Real4'}, ...

Introduced in R2011a

Was this topic helpful?