Main Content

invoke

Execute method node on OPC UA server

Since R2024a

    Description

    [value,timestamp,quality] = invoke(uaNode) executes the method node identified by uaNode and returns the output value, timestamp, and quality ID. A client must be connected to the server containing the node.

    [value,timestamp,quality] = invoke(uaClient,uaNode) executes the method node available on the server connected to the client specified in uaClient.

    [value,timestamp,quality] = invoke(uaNode,arg1,arg2,...,argN) executes the method node identified by uaNode. The input arguments for the node are specified by arg1,arg2,…,argN.

    [value,timestamp,quality] = invoke(uaClient,uaNode,arg1,arg2,...,argN) executes the method node whose input arguments are specified by arg1,arg2,…,argN.

    example

    Examples

    collapse all

    Create an OPC UA client and connect it to the server.

    uaClient = opcua("localhost",53530); 
    connect(uaClient);

    Call the browseNamespace function, and select the StartMachine method node from the Browse Namespace dialog box.

    methodNode = browseNamespace(uaClient)

    Add Method Node

    Verify the number of input arguments associated with the node and their data types by using the NumInputs and InputTypes properties of the method node object.

    methodNode 
    methodNode = 
    OPC UA Node:
    
       Node Information:
                  Name: 'StartMachine'
           Description: ''
        NamespaceIndex: 1
            Identifier: 62541
              NodeType: 'Method'
    
       Hierarchy Information:
                Parent: 'ControlSystem'
              Children: 2
    
       Method Information:
            Executable: 1
        UserExecutable: 1
             NumInputs: 1
            InputTypes: {'String'}
            NumOutputs: 1
           OutputTypes: {'String'}
    

    Execute the selected method node with the Compressor input argument.

    [value,time,quality] = invoke(uaClient,methodNode,"Compressor")
    value = 'Started Compressor'
    
    time = 
       01-Jan-2024 05:53:28
    
    quality = 
    OPC UA Quality ID:
    	Good
    

    Input Arguments

    collapse all

    Connected OPC UA client, specified as an OPC UA client object. You can create the client object with the opcua function.

    Example: uaClient=opcua(_)

    Data Types: object

    OPC UA method node, specified as an OPC UA method node object. You can use the browseNamespace function to select the method nodes from the list of nodes associated with a connected client. You can execute only one method node at a time.

    Example: uaNode=browseNamespace(uaClient)

    Data Types: object

    Argument name(s), specified as a comma-separated list of input arguments. You can pass the appropriate input arguments by checking the NumInputs and InputTypes properties of the method node object. For more information on supported data types for input arguments, see OPC UA Server Data Types.

    Example: invoke(clientObj,methodNode,"hello",true,5)

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

    Output Arguments

    collapse all

    Output of method node execution, returned as a cell array. The NumOutputs and OutputTypes properties of the method node object specify the number of elements in the cell array and their corresponding data types. For more information on supported data types for Value, see OPC UA Server Data Types.

    Time at which the source provides data to the server, returned as a MATLAB datetime value.

    Node data quality, returned as a quality ID of Good, Bad, or Uncertain. For details on the quality format, see OPC UA Quality.

    Limitations

    • This function does not support method nodes created using opcuanode.

    Version History

    Introduced in R2024a