Eclipse Milo:方法支持参数数组吗?

huangapple go评论69阅读模式
英文:

Eclipse Milo: Does method support argument array?

问题

OPCUA服务器具有一个带有一个输入参数的方法,例如:

protected Variant[] invoke(InvocationContext invocationContext, Variant[] inputValues) {
        logger.debug("Invoking sqrt() method of objectId={}", invocationContext.getObjectId());

        double x = (double) inputValues[0].getValue();
        double xSqrt = Math.sqrt(x);

        return new Variant[]{new Variant(xSqrt)};
}

在OPCUA客户端,我可以用整数数组调用这个方法吗?例如:[1,4,9,16,25]

CallMethodRequest request = new CallMethodRequest(
            objectId,
            methodId,
            new Variant[]{new Variant(input)}
);

在这里,inputArguments是Variant数组,我可以将其设置为[1,4,9,16,25]并得到[1,2,3,4,5]吗?

英文:

OPCUA server have a method with one input argument
e.g.

protected Variant[] invoke(InvocationContext invocationContext, Variant[] inputValues) {
        logger.debug("Invoking sqrt() method of objectId={}", invocationContext.getObjectId());

        double x = (double) inputValues[0].getValue();
        double xSqrt = Math.sqrt(x);

        return new Variant[]{new Variant(xSqrt)};
}

At the OPCUA client, can I call this method with array int? e.g.[1,4,9,16,25]

CallMethodRequest request = new CallMethodRequest(
            objectId,
            methodId,
            new Variant[]{new Variant(input)}
);

At here, the inputArguments is Variant array, can I set with [1,4,9,16,25] and get [1,2,3,4,5]?

答案1

得分: 0

不,它不是那样工作的。

您可以在一个CallRequest内部发送5个CallMethodRequest

英文:

No, it doesn't work that way.

You can send 5 CallMethodRequests inside one CallRequest, though.

huangapple
  • 本文由 发表于 2020年5月19日 17:23:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/61887587.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定