IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

MethodNode QML Type

Calls a method on the server.

This type was introduced in QtOpcUa 5.12.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

MethodNode QML Type

  • Import Statement: import QtOpcUa

  • Since:: QtOpcUa 5.12

  • Inherits:: Node

Detailed Description

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

 
Sélectionnez
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.

 
Sélectionnez
Button {
      text: "Start"
      onClicked: myNode.callMethod
}

or by JavaScript

 
Sélectionnez
myNode.callMethod()

Property Documentation

 

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.

 
Sélectionnez
QtOpcUa.MethodNode {
    ...
    inputArguments: [
        QtOpcUa.MethodArgument {
            value: 3
            type: QtOpcUa.Constants.Double
        },
        QtOpcUa.MethodArgument {
            value: 4
            type: QtOpcUa.Constants.Double
        }
    ]
}
See Also

See also 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.

 
Sélectionnez
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])
}
See Also

[read-only] resultStatus : Status

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

See Also

See also 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.

See Also

Method Documentation

 

callMethod()

Calls the method on the connected server.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+