Arendt
Arendt

Reputation: 61

How to properly call methods with no input arguments

The Qt Documentation provides the method

bool QOpcUaNode::callMethod(const QString &methodNodeId, const QVector<QOpcUa::TypedVariant> &args = QVector<QOpcUa::TypedVariant>())

for calling methods on the Opc Ua Server. Regarding this Method I have 2 Questions:

  1. What exactly is methodNodeId ? I imagine it is the Id of the Node I want to call, but if this is the case, why would the function not be static instead ?

  2. How to call methods with 0 input arguments? trying to call myNode->callMethod(methodNodeId) without specifiying further arguments still returns BadTooManyArguments, but there is really not other way I could see it being used.

Upvotes: 0

Views: 321

Answers (1)

Camille G.
Camille G.

Reputation: 3246

  1. An OPC UA Call Service Request need to contain an Array of CallMethodRequest A CallMethod Request is defined as following in the OPC UA Specification:

    • objectId (NodeId) - The NodeId shall be that of the Object or ObjectType on which the Method is invoked. -> I guess this is your QOpcUaNode
    • methodId (NodedId) - The NodeId of the Method to invoke.
    • inputArguments[] (BaseDataType) - List of input argument values.
  2. You will have to check your Method definition and maybe your server. Your call of callMethod(methodId) without arguments is fine. Depending of the Method you are calling, this call might succeed or not.

Anyway your OPC UA Server might also have an issue sending Bad_TooManyArguments instead of Bad_ArgumentsMissing if it was waiting for some inputArguments you did not provide.

Upvotes: 1

Related Questions