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.

readValue (opcua)

Read values from nodes on OPC UA server

Syntax

[Values,Timestamps,Qualities] = readValue(UaClient,NodeList)
[Values,Timestamps,Qualities] = readValue(NodeList)

Description

example

[Values,Timestamps,Qualities] = readValue(UaClient,NodeList) reads the value, quality, and timestamp from the nodes identified by NodeList, on the server associated with the connected client UaClient.NodeList can be a single OPC UA node object or an array of nodes.

[Values,Timestamps,Qualities] = readValue(NodeList) reads from the nodes identified by NodeList. All nodes must be of the same connected client.

Examples

collapse all

This example shows how to read the value from a node identified by its Index and Identifier.

s = opcuaserverinfo('localhost');
UaClient = opcua(s(1));
connect(UaClient);
node = opcuanode(2,10226,UaClient);
[val,tstamp,qual] = readValue(UaClient,node)
val =
    3.1416

tstamp = 
   05-Jun-2015 15:16:15

qual = 
OPC UA Quality ID:
	Good

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.

Output Arguments

collapse all

Node values, returned as node data type, or a cell array of values. For information about how MATLAB interprets these formats, type:

help opc.ua.DataTypeId

Time of node data source, returned as a vector of MATLAB datetime objects. Timestamps represent the time that the source provided the data to the server.

Node data quality, returned as an array of OPC UA qualities. For information on OPC UA qualities, type:

 help opc.ua.QualityId

Introduced in R2015b

Was this topic helpful?