opcuanode (opcua)

Create OPC UA node objects

Description

example

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.

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.
myNode = 
OPC UA Node object:
                      Name: 2:10225
               Description: 
            NamespaceIndex: 2
                Identifier: 10225
                  NodeType: Unknown
writeValue(UaClient,myNode,pi)
myNode3
myNode3 = 
OPC UA Node object:
                      Name: 2:10225
               Description: 
            NamespaceIndex: 2
                Identifier: 10225
                  NodeType: Variable

                  Children: 0 nodes.

            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 'Variable' type. Variable type nodes can contain data values, while object type nodes cannot contain values. Each node type can contain other nodes: object nodes can contain object and variable nodes, variable nodes can contain other variable nodes.

Node objects include the following properties.

PropertyDescription
Identity properties
NameDisplay name for the node.
NodeTypeType of node: 'Object' or 'Variable'.
NamespaceIndexNamespace index for this node.
IdentifierTypeType of identifier: 'string', 'numeric', or 'GUID'.
IdentifierUnique identifier. A character vector or integer, depending on the IdentifierType.
Relationship properties
ParentParent node of this node.
ChildrenChild nodes of this node.
ClientReference to OPC UA client associated with the node.
FullyQualifiedIdCharacter vector that uniquely describes this node.
Essential attributes
DescriptionCharacter vector describing the node.
MinimumSamplingIntervalMinimum rate at which node value can change.
HistorizingTrue if the server is storing history for the node.
ServerDataTypeOPC UA data type for node.
Informative attributes
AccessLevelCurrentUser access level to current value: 'none', 'read', 'write', 'read/write'.
AccessLevelHistoryUser access level to historical values: 'none', 'read', 'write', 'read/write'.
ServerValueRankSize restrictions on the server value: 'unrestricted', 'scalar', 'vector', or 'array'.
ServerArrayDimensionsArray dimensions of the server value. Might be empty, as this property is optional for servers.

Introduced in R2015b