Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

readHistory (opcua)

Read historical data from nodes on OPC UA server

Syntax

UaData = readHistory(UaClient,NodeList,StartTime,EndTime)
UaData = readHistory(UaClient,NodeList,StartTime,EndTime,ReturnBounds)
UaData = readHistory(NodeList,StartTime,EndTime)
UaData = readHistory(NodeList,StartTime,EndTime,ReturnBounds)

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.

example

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.

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, type:

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

Introduced in R2015b

Was this topic helpful?