Main Content

readAtTime

Read historical data from nodes of OPC UA server at specific times

Syntax

UaData = readAtTime(UaClient,NodeList,TimeVector)
UaData = readAtTime(NodeList,TimeVector)

Description

UaData = readAtTime(UaClient,NodeList,TimeVector) reads stored historical data from the nodes given by NodeList, at the specified times in TimeVector. NodeList is an array of OPC UA node objects, which you can create using getNamespace, browseNamespace, or opcuanode. TimeVector is an array of MATLAB datetimes or date numbers.

UaData is returned as a vector of OPC UA data objects. The server interpolates or extrapolates data if it is not stored at the times specified in TimeVector. Data Quality is set appropriately for interpolated data. If readHistory fails to retrieve history 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 = readAtTime(NodeList,TimeVector) 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, the status for that node is set to Bad:AttributeNotSupported, and the node is not included in the returned UaData object.

Examples

Retrieve the 10 minute sampled 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);
TimeVector = datetime('today'):minutes(10):datetime('now');
dataObj = readAtTime(uaClnt,nodeList,TimeVector);

Version History

Introduced in R2015b