Replies: 3 comments 6 replies
|
Depends how much you know about the type ahead of time and whether you've code generated or hand coded types or not. If it's totally dynamic then it's a bit of work: UaMethod method = ... // get UaMethod instance from UaObjectNode etc...
NodeId dataTypeId = ... // get from method input arguments or browse
DataType dataType = client.getDataTypeTree().getDataType(dataTypeId);
DynamicStructType struct = DynamicStructType.newInstance(dataType);
// have to add values for all members here
struct.getMembers().put("Foo", 42);
struct.getMembers().put("Bar", "Hello, World!");
Variant[] inputs = new Variant[]{Variant.ofStruct(struct)};
method.call(inputs);Something along these lines... |
|
Thank you for your fast response. It worked right ahead. |
|
Hi @kevinherron, I just tried your solution, but I am getting following error during encoding: org.eclipse.milo.opcua.stack.core.UaSerializationException: no codec registered for encodingId=ns=2;i=5054 I tried without early encoding as well but still getting same error I am using Eclipse Milo version 1.1.0 |
Uh oh!
There was an error while loading. Please reload this page.
In this discussion someone asked how to pass structs as parameter on opcua-methods.
#882
Now a few years later as the library-api has evolved, I want to ask again what's the correct way to construct struct-types and pass them as method-parameters. I am also communicating with a S7-1500 plc, if that's somehow relevant.
All reactions