Main Content

readHistory

Read historical data from nodes on OPC UA server

Description

uaData = readHistory(uaClient,nodeList,startTime,endTime) reads stored historical data from the nodes identified by nodeList, on the server associated with the connected client UaClient,with a source timestamp between startTime (inclusive) and endTime (exclusive).nodeList is a single OPC UA node object or an array of nodes. startTime and endTime can be MATLAB datetime values or date numbers.

uaData = readHistory(uaClient,nodeList,startTime,endTime,returnBounds) allows you to specify that returned data should include bounding values. Bounding values are the values immediately outside the time range requested (the first value just before startTime, or the first value after endTime) when a value does not exist exactly on the specified limit of the time range. Setting returnBounds to true returns bounding values; setting returnBounds to false (the default) returns values strictly within the specified start and end times.

uaData = readHistory(nodeList,startTime,endTime) and uaData = readHistory(nodeList,startTime,endTime,returnBounds) read from the nodes identified by nodeList. All nodes must be of the same connected client.

example

Examples

collapse all

This example shows how to retrieve the history for 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 = readHistory(uaClnt,nodeList,datetime('today'),datetime('now'));

Input Arguments

collapse all

OPC UA client specified as an OPC UA client object. The client must be connected.

List of nodes, specified as an array of node objects or a single node. 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 only from variable type nodes, not object type nodes. If you specify an object node to read, the return value is an empty array, and the quality is set to Bad:AttributeIdInvalid.

Source time span, specified as MATLAB datetime values or date numbers. The source times fall between StartTime (inclusive) and EndTime (exclusive).

Request bounding values, specified as true or false.

Output Arguments

collapse all

Historical data, returned as a vector of OPC UA Data objects. If readHistory fails to retrieve history 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