Main Content

readProcessed

Read aggregate data from nodes of an OPC UA server

Description

example

UaData = readProcessed(UaClient,NodeList,AggregateFn,AggrInterval,StartTime,EndTime) reads processed historical data from the nodes given by NodeList. NodeList must be an array of OPC UA node objects, which you can create using getNamespace, browseNamespace, or opcuanode. The interval between StartTime and EndTime (which can be datetime variables or date numbers) is split into intervals of AggrInterval, a MATLAB duration variable or a double representing the interval in seconds. 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. A client stores the available Aggregates for a server in the AggregateFunctions property. For a description of Aggregate functions, see OPC UA Aggregate Functions.

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.

OPC UA servers provide 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, and the status for that node is set to Bad:AttributeNotSupported, a warning is issued, and the node is not included in the returned UaData object.

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.

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 datetime or date numbers.

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.

Version History

Introduced in R2015b

See Also

Functions