英文:
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 CallMethodRequest
s inside one CallRequest
, though.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论