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.

opcuanode (opcua)

Construct OPC UA node objects

Syntax

NodeList = opcuanode(Index,Id)
NodeList = opcuanode(Index,Id,UaClient)

Description

NodeList = opcuanode(Index,Id) constructs 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 construct node objects for known nodes on an OPC UA server. The 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.

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.

You should construct node objects only when you know the index and identifier of nodes you are interested in. For nodes you need to find from the server, you can construct 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

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

Construct 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

Introduced in R2015b

Was this topic helpful?