Main Content

readProcessed

Read server-aggregated data from OPC HDA server

Description

dObj = readProcessed(hdaClient,itmList,aggregateType,aggregateInterval,startTime,endTime) reads data processed by the OPC HDA Server associated with client specified in hdaClient and returns the processed data in data object dObj.

[itmList,value,quality,timeStamp] = readProcessed(hdaClient,itmList,aggregateType,aggregateInterval,startTime,endTime,dataType) returns the processed data as separate arrays in the specified dataType along with the corresponding item ID, quality ID and timestamp.

hdaDataStruct = readProcessed(hdaClient,itmList,aggregateType,aggregateInterval,startTime,endTime,'struct') returns the processed data as a structure containing fields ItemID, Value, Quality and TimeStamp.

example

Examples

collapse all

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,datetime("now")-hours(1),datetime("now"));

Input Arguments

collapse all

OPC HDA client, specified as an OPC HDA client object. You can specify only one OPC HDA client, and the client must be connected to the server.

Example: hdaClient = opchda(_)

IDs of HDA items IDs, specified as a character vector, string, or supporting array of either.

Example: {'Random.Real8','Random.Real4'}

Data Types: char | string | cell

Aggregate type, obtained from the client’s Aggregates property and specified as opc.hda.AggregateTypes.

Example: aggregates.TIMEAVERAGE

Aggregate time interval, specified in seconds. The server aggregates data over this interval.

Example: 60

Time boundaries, specified as datetime values returned by datetime function.

Example: datetime(2018,11,30)

Data Types: datetime

Type of data in Value, specified as one of these:

  • 'single'

  • 'double'

  • 'int8'

  • 'int16'

  • 'int32'

  • 'int64'

  • 'uint8'

  • 'uint16'

  • 'uint32'

  • 'uint64'

  • 'logical'

Output Arguments

collapse all

Raw OPC HDA data, returned as an OPC HDA data object or an array of OPC HDA data objects. Each item in the itemList corresponds to a data object in the array. All elements in the dObj have the same timestamp.

HDA item IDs, returned as a 1-by-N cell array of character vectors.

HDA data, returned as a M-by-N array, where each element is of the same data type as specified in dataType.

HDA data quality, returned as an M-by-N array of quality IDs.

Timestamp of data read from server, returned as an M-by-1 vector of timestamps.

Version History

Introduced in R2011a