Main Content

opcuanode

Create OPC UA node objects

Description

nodeList = opcuanode(index,id) creates an OPC UA node object or array of objects from the information in index and id. index is a number or numeric vector. id is a character vector, string, scalar integer, or cell array containing character vectors and scalar integers. Use this syntax to create node objects for known nodes on an OPC UA server. Each node Name property is set to 'Index:Identifier', and other properties of the node are left empty until you use the node to access an OPC UA server. When you successfully use the node object with a client using writeValue or readValue, the Client property of the node is set to the client, and other attributes are read from that client.

example

nodeList = opcuanode(index,id,uaClient) immediately associates the node object with the specified client uaClient. If uaClient is connected at this time, the opcuanode function also retrieves other properties from the server associated with uaClient.

Use opcuanode to create node objects only when you know the index and identifier of nodes you are interested in. For nodes that you need to find from the server, create node objects by browsing the namespace of a connected OPC UA client object with browseNamespace or getNamespace, or browse the Parent and Children properties of existing node objects.

example

Examples

collapse all

Construct a node object from index and identifier values. Use the node to write a value to the server, then note that the node has its properties set from the server.

s = opcuaserverinfo("localhost");
uaClient = opcua(s);
connect(uaClient);
myNode = opcuanode(2,10225); % Not associated with server yet.
writeValue(uaClient,myNode,pi)
myNode
myNode = 
OPC UA Node:
   Node Information:
                      Name: '2:10225'
               Description: ''
            NamespaceIndex: 2
                Identifier: 10225
                  NodeType: 'Variable'

   Hierarchy Information:
                    Parent: ''
                  Children: 0

   Variable Information:
            ServerDataType: 'Float'
        AccessLevelCurrent: 'read/write'
        AccessLevelHistory: 'none'
               Historizing: 0

Create a known node object and use it to browse for other nodes.

uaClient = opcua("localhost",51210);
connect(uaClient);
boilerNode = opcuanode(4,1241,uaClient);
ftxNodes = findNodeByName(boilerNode,'FTX','-partial')
ftxNodes = 
1x2 OPC UA Node array:
    index   Name   NsInd  Identifier  NodeType  Children
    -----  ------  -----  ----------  --------  --------
      1    FTX001  4      1243        Object    1
      2    FTX002  4      1266        Object    1

Input Arguments

collapse all

Node index, specified as a numeric value or array.

Example: 2

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Node ID, specified as a numeric, character, or string value, or an array of these.

Example: 10225

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | char | string

OPC UA client, specified as an opc.ua.Client object. You can create the client using the opcua function.

Example: opcua()

Output Arguments

collapse all

OPC UA nodes, returned as an array of opc.ua.Node objects. An OPC UA node object stores information about a node in an OPC UA server. You can read and write current data, and read historical data using variable nodes. You can browse the name space using object and variable nodes.

A node’s type is described by its NodeType property, which can indicate an 'Object' or 'Method' or 'Variable' type. Variable type nodes can contain data values, while object type nodes cannot contain values. Method nodes can have input and output arguments. Each node type can contain other nodes: object nodes can contain object, method and variable nodes, variable nodes can contain other variable nodes.

Node objects include these properties.

PropertyDescription
Node Information
NameDisplay name for the node.
DescriptionCharacter vector describing the node.
NamespaceIndexNamespace index for the node.
IdentifierUnique identifier with data type as a character vector or integer.
NodeTypeType of node: 'Object', 'Method', or 'Variable'.
Hierarchy Information
ParentParent node of the node.
ChildrenChild nodes of the node.
Variable Information
ServerDataTypeOPC UA data type for node.
AccessLevelCurrentUser access level to current value: 'none', 'read', 'write', 'read/write'.
AccessLevelHistoryUser access level to historical values: 'none', 'read', 'write', 'read/write'.
HistorizingTrue if the server is storing history for the node data.
Method Information
ExecutableTrue if the node is executable.
UserExecutableTrue if the node is executable by the current user.
NumInputsNumber of inputs required by the node.
InputTypesData types of input arguments.
NumOutputsNumber of outputs returned by the node.
OutputTypesData types of output arguments.

Version History

Introduced in R2015b