Main Content

readProcessed

Read aggregate data from nodes of an OPC UA server

Description

uaData = readProcessed(uaClient,nodeList,aggregateFn,aggrInterval,startTime,endTime) reads processed historical data from the nodes given by nodeList, at a specified time between StartTime and EndTime at intervals of AggrInterval. For each interval of time, the server calculates a processed value based on the AggregateFn requested. AggregateFn can be specified as a character vector or as an AggregateFnId object

UaData is returned as a vector of OPC UA data objects. If readProcessed fails to retrieve historical data for a given node, that node is not included in the returned OPC UA data object, and a warning is issued. If all requested nodes fail, an error is generated.

uaData = readProcessed(nodeList,aggregateFn,aggrInterval,startTime,endTime) reads from the nodes identified by NodeList. All nodes must be of the same connected client.

example

Examples

collapse all

Retrieve the average value for each 10 minute interval of the current day from a local server.

uaClnt = opcua("localhost",62550);
connect(uaClnt);
nodeId = "1:Quickstarts.HistoricalAccessServer.Data.Dynamic.Double.txt";
nodeList = opcuanode(2,nodeId,uaClnt);
dataObj = readProcessed(uaClnt,nodeList,'Average',minutes(10),datetime('today'),datetime('now'));

Input Arguments

collapse all

OPC UA client, specified as an opc.ua.Client object. Create a client object with the opcua function. The client must be connected.

Example: opcua()

OPC UA nodes, specified as a opc.ua.Node object, or array of objects. You can create node objects using getNamespace, browseNamespace, or opcuanode. For information on node object functions and properties, see OPC UA Node.

You can read historical data only from nodes of type Variable. If you attempt to read values from an Object node, no data is returned for that node, the status for that node is set to Bad:AttributeNotSupported, and the node is not included in the returned UaData object.

Example: opcuanode()

Aggregate function, specified as a character vector or as an AggregateFnId object. A client stores the available aggregates for a server in its AggregateFunctions property.

For a description of the standard aggregate functions defined by the OPC Foundation, see OPC UA Aggregate Functions.

Example: 'Average'

Aggregation interval segment, specified as a MATLAB duration or a double indicating seconds.

Example: minutes(10)

Data Types: double | duration

Aggregation interval boundaries, specified as an array of MATLAB® datetime values returned by datetime function.

Example: datetime('today'),datetime('now')

Data Types: double | datetime

Output Arguments

collapse all

OPC UA data, returned as a vector of opc.ua.Data objects. If readProcessed fails to retrieve data for a given node, that node is not returned in the opc.ua.Data object and a warning is issued. If all requested nodes fail, an error is generated. For more information on OPC UA data object, see OPC UA Data.

Version History

Introduced in R2015b

See Also

Functions