Main Content

readAtTime

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

Description

uaData = readAtTime(uaClient,nodeList,timeVector) reads stored historical data from the nodes given by nodeList, at the specified times in timeVector.

uaData = readAtTime(nodeList,timeVector) reads from the nodes identified by nodeList. All nodes must be of the same connected client.

example

Examples

collapse all

Create an OPC UA Client and connect the client to an OPC UA server

uaClnt = opcua("localhost",62550);
connect(uaClnt);

Retrieve the 10 minute sampled history for the current day from a local server.

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);

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 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.

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

Output Arguments

collapse all

OPC UA data, 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. For more information on OPC UA data object, see OPC UA Data.

Version History

Introduced in R2015b