MethodNode QML Type

Calls a method on the server. 更多...

import 语句: import QtOpcUa
Since: QtOpcUa 5.12
继承: Node

特性

方法

详细描述

This QML element supports calling method nodes on a server. The target object node ID has to be specified by the objectNodeId 特性。

import QtOpcUa as QtOpcUa
QtOpcUa.MethodNode {
    nodeId : QtOpcUa.NodeId {
        identifier: "s=Example.Method"
        ns: "Example Namespace"
    }
    objectNodeId : QtOpcUa.NodeId {
        identifier: "s=Example.Object"
        ns: "Example Namespace"
    }
    connection: myConnection
 }
					

The actual function call can be triggered by a signal.

Button {
      text: "Start"
      onClicked: myNode.callMethod
}
					

or by JavaScript

myNode.callMethod()
					

特性文档编制

inputArguments : list < MethodArgument >

Arguments to be used when calling the method on the server.

This example shows how to call a method with two double arguments.

QtOpcUa.MethodNode {
    ...
    inputArguments: [
        QtOpcUa.MethodArgument {
            value: 3
            type: QtOpcUa.Constants.Double
        },
        QtOpcUa.MethodArgument {
            value: 4
            type: QtOpcUa.Constants.Double
        }
    ]
}
						

另请参阅 callMethod .


objectNodeId : OpcUaNode

Determines the actual node on which the method is called. It can be a relative or absolute node Id.


[read-only] outputArguments : list < var >

Returns values from the method call. Depending on the output arguments, this list may contain zero or more values. The resultStatus has to be checked separately. In case the method call failed, the list will be empty.

if (node.status.isGood) {
    // print two arguments
    console.log("Number of return values:", node.outputArguments.length)
    console.log("Return value #1:", node.outputArguments[0])
    console.log("Return value #2:", node.outputArguments[1])
}
								

另请参阅 callMethod and resultStatus .


[read-only] resultStatus : Status

Status of the last method call. This property has to be checked to determine if the method call was successful.

另请参阅 Status .


type : QOpcUa::Types

Sets the type of the argument that is expected by the server. The value variant is converted to that type when calling the method. The type has to match the method on the server exactly, otherwise the method call will fail.

另请参阅 MethodNode::callMethod .


方法文档编制

callMethod ()

Calls the method on the connected server.