Eclipse Milo: How to call method which takes a customDataType as argument?
up vote
0
down vote
favorite
The CustomDataType the method requires:
<UADataType NodeId="ns=1;i=3010" BrowseName="1:ScanSettings">
<DisplayName>ScanSettings</DisplayName>
<References>
<Reference ReferenceType="HasEncoding">ns=1;i=5015</Reference>
<Reference ReferenceType="HasEncoding">ns=1;i=5016</Reference>
<Reference ReferenceType="HasSubtype" IsForward="false">i=22</Reference>
</References>
<Definition Name="1:ScanSettings">
<Field DataType="Duration" Name="Duration"/>
<Field DataType="Int32" Name="Cycles"/>
<Field DataType="Boolean" Name="DataAvailable"/>
<Field IsOptional="true" DataType="LocationTypeEnumeration" Name="LocationType"/>
</Definition>
</UADataType>
MethodCall:
CallMethodRequest tCallMethodRequest = new CallMethodRequest(tObjectId, tMethodId, new Variant{});
CallMethodResult tCallMethodResult = pOpcUaClient.call(tCallMethodRequest).get();
System.out.println(tCallMethodResult.getStatusCode());
How to call a method which requires ScanSettings?
Do I need to pass the Variant-array with three Variants containing Duration, Cycles and DataAvailable?
Or
do i need to do something like this ?
EDIT:
Tried it with a ScanSettings-class and got the error:
10:08:52.655 [ua-shared-pool-2] WARN org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamEncoder - Not a built-in type: class ScanSettings
My ScanSettings-class:
public class ScanSettings {
private final String duration;
private final UInteger cycles;
private final boolean dataAvailable;
public ScanSettings() {
this("1000", uint(10), true);
}
public ScanSettings(String pDuration, UInteger pCycles, boolean pDataAvailable) {
duration = pDuration;
cycles = pCycles;
dataAvailable = pDataAvailable;
}
public String getDuration() {
return duration;
}
public UInteger getCycles() {
return cycles;
}
public boolean isDataAvailable() {
return dataAvailable;
}
@Override
public int hashCode() {
return Objects.hashCode(duration);
}
@Override
public boolean equals(final Object obj) {
return super.equals(obj);
}
@Override
public String toString() {
return duration + " " + cycles + " " + dataAvailable;
}
public static class Codec extends GenericDataTypeCodec<ScanSettings> {
@Override
public Class<ScanSettings> getType() {
return ScanSettings.class;
}
@Override
public ScanSettings decode(final SerializationContext context, final UaDecoder reader) throws UaSerializationException {
String tDuration = reader.readString("Duration");
UInteger tCycle = reader.readUInt32("Cycle");
boolean tDataAvalible = reader.readBoolean("DataAvailable");
return new ScanSettings(tDuration, tCycle, tDataAvalible);
}
@Override
public void encode(final SerializationContext context, final ScanSettings pScanSettings, final UaEncoder writer) throws UaSerializationException {
writer.writeString("Duration", pScanSettings.duration);
writer.writeUInt32("Cycle", pScanSettings.cycles);
writer.writeBoolean("DataAvailable", pScanSettings.dataAvailable);
}
}
}
Registrating it with:
OpcUaBinaryDataTypeDictionary tOpcUaBinaryDataTypeDictionary = new OpcUaBinaryDataTypeDictionary("urn:ScanSettings");
NodeId binaryEncodingId = new NodeId(2, "DataType.ScanSettings.BinaryEncoding");
tOpcUaBinaryDataTypeDictionary.registerStructCodec(new ScanSettings.Codec().asBinaryCodec(), "ScanSettings", binaryEncodingId);
OpcUaDataTypeManager.getInstance().registerTypeDictionary(tOpcUaBinaryDataTypeDictionary);
java opc-ua milo
add a comment |
up vote
0
down vote
favorite
The CustomDataType the method requires:
<UADataType NodeId="ns=1;i=3010" BrowseName="1:ScanSettings">
<DisplayName>ScanSettings</DisplayName>
<References>
<Reference ReferenceType="HasEncoding">ns=1;i=5015</Reference>
<Reference ReferenceType="HasEncoding">ns=1;i=5016</Reference>
<Reference ReferenceType="HasSubtype" IsForward="false">i=22</Reference>
</References>
<Definition Name="1:ScanSettings">
<Field DataType="Duration" Name="Duration"/>
<Field DataType="Int32" Name="Cycles"/>
<Field DataType="Boolean" Name="DataAvailable"/>
<Field IsOptional="true" DataType="LocationTypeEnumeration" Name="LocationType"/>
</Definition>
</UADataType>
MethodCall:
CallMethodRequest tCallMethodRequest = new CallMethodRequest(tObjectId, tMethodId, new Variant{});
CallMethodResult tCallMethodResult = pOpcUaClient.call(tCallMethodRequest).get();
System.out.println(tCallMethodResult.getStatusCode());
How to call a method which requires ScanSettings?
Do I need to pass the Variant-array with three Variants containing Duration, Cycles and DataAvailable?
Or
do i need to do something like this ?
EDIT:
Tried it with a ScanSettings-class and got the error:
10:08:52.655 [ua-shared-pool-2] WARN org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamEncoder - Not a built-in type: class ScanSettings
My ScanSettings-class:
public class ScanSettings {
private final String duration;
private final UInteger cycles;
private final boolean dataAvailable;
public ScanSettings() {
this("1000", uint(10), true);
}
public ScanSettings(String pDuration, UInteger pCycles, boolean pDataAvailable) {
duration = pDuration;
cycles = pCycles;
dataAvailable = pDataAvailable;
}
public String getDuration() {
return duration;
}
public UInteger getCycles() {
return cycles;
}
public boolean isDataAvailable() {
return dataAvailable;
}
@Override
public int hashCode() {
return Objects.hashCode(duration);
}
@Override
public boolean equals(final Object obj) {
return super.equals(obj);
}
@Override
public String toString() {
return duration + " " + cycles + " " + dataAvailable;
}
public static class Codec extends GenericDataTypeCodec<ScanSettings> {
@Override
public Class<ScanSettings> getType() {
return ScanSettings.class;
}
@Override
public ScanSettings decode(final SerializationContext context, final UaDecoder reader) throws UaSerializationException {
String tDuration = reader.readString("Duration");
UInteger tCycle = reader.readUInt32("Cycle");
boolean tDataAvalible = reader.readBoolean("DataAvailable");
return new ScanSettings(tDuration, tCycle, tDataAvalible);
}
@Override
public void encode(final SerializationContext context, final ScanSettings pScanSettings, final UaEncoder writer) throws UaSerializationException {
writer.writeString("Duration", pScanSettings.duration);
writer.writeUInt32("Cycle", pScanSettings.cycles);
writer.writeBoolean("DataAvailable", pScanSettings.dataAvailable);
}
}
}
Registrating it with:
OpcUaBinaryDataTypeDictionary tOpcUaBinaryDataTypeDictionary = new OpcUaBinaryDataTypeDictionary("urn:ScanSettings");
NodeId binaryEncodingId = new NodeId(2, "DataType.ScanSettings.BinaryEncoding");
tOpcUaBinaryDataTypeDictionary.registerStructCodec(new ScanSettings.Codec().asBinaryCodec(), "ScanSettings", binaryEncodingId);
OpcUaDataTypeManager.getInstance().registerTypeDictionary(tOpcUaBinaryDataTypeDictionary);
java opc-ua milo
UPDATE: After a little bit of work I just get a TimeOut when I call the methode with a ScanSettings Object as Argument. Is there any way to identify the problem? How to know if my ScanSettings-Class is right or the NodeId I use is wrong?
– Bashdi
yesterday
*How to know if my ScanSettings-Class is right or the NodeId I use for encoding is wrong?
– Bashdi
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The CustomDataType the method requires:
<UADataType NodeId="ns=1;i=3010" BrowseName="1:ScanSettings">
<DisplayName>ScanSettings</DisplayName>
<References>
<Reference ReferenceType="HasEncoding">ns=1;i=5015</Reference>
<Reference ReferenceType="HasEncoding">ns=1;i=5016</Reference>
<Reference ReferenceType="HasSubtype" IsForward="false">i=22</Reference>
</References>
<Definition Name="1:ScanSettings">
<Field DataType="Duration" Name="Duration"/>
<Field DataType="Int32" Name="Cycles"/>
<Field DataType="Boolean" Name="DataAvailable"/>
<Field IsOptional="true" DataType="LocationTypeEnumeration" Name="LocationType"/>
</Definition>
</UADataType>
MethodCall:
CallMethodRequest tCallMethodRequest = new CallMethodRequest(tObjectId, tMethodId, new Variant{});
CallMethodResult tCallMethodResult = pOpcUaClient.call(tCallMethodRequest).get();
System.out.println(tCallMethodResult.getStatusCode());
How to call a method which requires ScanSettings?
Do I need to pass the Variant-array with three Variants containing Duration, Cycles and DataAvailable?
Or
do i need to do something like this ?
EDIT:
Tried it with a ScanSettings-class and got the error:
10:08:52.655 [ua-shared-pool-2] WARN org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamEncoder - Not a built-in type: class ScanSettings
My ScanSettings-class:
public class ScanSettings {
private final String duration;
private final UInteger cycles;
private final boolean dataAvailable;
public ScanSettings() {
this("1000", uint(10), true);
}
public ScanSettings(String pDuration, UInteger pCycles, boolean pDataAvailable) {
duration = pDuration;
cycles = pCycles;
dataAvailable = pDataAvailable;
}
public String getDuration() {
return duration;
}
public UInteger getCycles() {
return cycles;
}
public boolean isDataAvailable() {
return dataAvailable;
}
@Override
public int hashCode() {
return Objects.hashCode(duration);
}
@Override
public boolean equals(final Object obj) {
return super.equals(obj);
}
@Override
public String toString() {
return duration + " " + cycles + " " + dataAvailable;
}
public static class Codec extends GenericDataTypeCodec<ScanSettings> {
@Override
public Class<ScanSettings> getType() {
return ScanSettings.class;
}
@Override
public ScanSettings decode(final SerializationContext context, final UaDecoder reader) throws UaSerializationException {
String tDuration = reader.readString("Duration");
UInteger tCycle = reader.readUInt32("Cycle");
boolean tDataAvalible = reader.readBoolean("DataAvailable");
return new ScanSettings(tDuration, tCycle, tDataAvalible);
}
@Override
public void encode(final SerializationContext context, final ScanSettings pScanSettings, final UaEncoder writer) throws UaSerializationException {
writer.writeString("Duration", pScanSettings.duration);
writer.writeUInt32("Cycle", pScanSettings.cycles);
writer.writeBoolean("DataAvailable", pScanSettings.dataAvailable);
}
}
}
Registrating it with:
OpcUaBinaryDataTypeDictionary tOpcUaBinaryDataTypeDictionary = new OpcUaBinaryDataTypeDictionary("urn:ScanSettings");
NodeId binaryEncodingId = new NodeId(2, "DataType.ScanSettings.BinaryEncoding");
tOpcUaBinaryDataTypeDictionary.registerStructCodec(new ScanSettings.Codec().asBinaryCodec(), "ScanSettings", binaryEncodingId);
OpcUaDataTypeManager.getInstance().registerTypeDictionary(tOpcUaBinaryDataTypeDictionary);
java opc-ua milo
The CustomDataType the method requires:
<UADataType NodeId="ns=1;i=3010" BrowseName="1:ScanSettings">
<DisplayName>ScanSettings</DisplayName>
<References>
<Reference ReferenceType="HasEncoding">ns=1;i=5015</Reference>
<Reference ReferenceType="HasEncoding">ns=1;i=5016</Reference>
<Reference ReferenceType="HasSubtype" IsForward="false">i=22</Reference>
</References>
<Definition Name="1:ScanSettings">
<Field DataType="Duration" Name="Duration"/>
<Field DataType="Int32" Name="Cycles"/>
<Field DataType="Boolean" Name="DataAvailable"/>
<Field IsOptional="true" DataType="LocationTypeEnumeration" Name="LocationType"/>
</Definition>
</UADataType>
MethodCall:
CallMethodRequest tCallMethodRequest = new CallMethodRequest(tObjectId, tMethodId, new Variant{});
CallMethodResult tCallMethodResult = pOpcUaClient.call(tCallMethodRequest).get();
System.out.println(tCallMethodResult.getStatusCode());
How to call a method which requires ScanSettings?
Do I need to pass the Variant-array with three Variants containing Duration, Cycles and DataAvailable?
Or
do i need to do something like this ?
EDIT:
Tried it with a ScanSettings-class and got the error:
10:08:52.655 [ua-shared-pool-2] WARN org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamEncoder - Not a built-in type: class ScanSettings
My ScanSettings-class:
public class ScanSettings {
private final String duration;
private final UInteger cycles;
private final boolean dataAvailable;
public ScanSettings() {
this("1000", uint(10), true);
}
public ScanSettings(String pDuration, UInteger pCycles, boolean pDataAvailable) {
duration = pDuration;
cycles = pCycles;
dataAvailable = pDataAvailable;
}
public String getDuration() {
return duration;
}
public UInteger getCycles() {
return cycles;
}
public boolean isDataAvailable() {
return dataAvailable;
}
@Override
public int hashCode() {
return Objects.hashCode(duration);
}
@Override
public boolean equals(final Object obj) {
return super.equals(obj);
}
@Override
public String toString() {
return duration + " " + cycles + " " + dataAvailable;
}
public static class Codec extends GenericDataTypeCodec<ScanSettings> {
@Override
public Class<ScanSettings> getType() {
return ScanSettings.class;
}
@Override
public ScanSettings decode(final SerializationContext context, final UaDecoder reader) throws UaSerializationException {
String tDuration = reader.readString("Duration");
UInteger tCycle = reader.readUInt32("Cycle");
boolean tDataAvalible = reader.readBoolean("DataAvailable");
return new ScanSettings(tDuration, tCycle, tDataAvalible);
}
@Override
public void encode(final SerializationContext context, final ScanSettings pScanSettings, final UaEncoder writer) throws UaSerializationException {
writer.writeString("Duration", pScanSettings.duration);
writer.writeUInt32("Cycle", pScanSettings.cycles);
writer.writeBoolean("DataAvailable", pScanSettings.dataAvailable);
}
}
}
Registrating it with:
OpcUaBinaryDataTypeDictionary tOpcUaBinaryDataTypeDictionary = new OpcUaBinaryDataTypeDictionary("urn:ScanSettings");
NodeId binaryEncodingId = new NodeId(2, "DataType.ScanSettings.BinaryEncoding");
tOpcUaBinaryDataTypeDictionary.registerStructCodec(new ScanSettings.Codec().asBinaryCodec(), "ScanSettings", binaryEncodingId);
OpcUaDataTypeManager.getInstance().registerTypeDictionary(tOpcUaBinaryDataTypeDictionary);
java opc-ua milo
java opc-ua milo
edited Nov 21 at 9:18
asked Nov 20 at 8:38
Bashdi
12
12
UPDATE: After a little bit of work I just get a TimeOut when I call the methode with a ScanSettings Object as Argument. Is there any way to identify the problem? How to know if my ScanSettings-Class is right or the NodeId I use is wrong?
– Bashdi
yesterday
*How to know if my ScanSettings-Class is right or the NodeId I use for encoding is wrong?
– Bashdi
yesterday
add a comment |
UPDATE: After a little bit of work I just get a TimeOut when I call the methode with a ScanSettings Object as Argument. Is there any way to identify the problem? How to know if my ScanSettings-Class is right or the NodeId I use is wrong?
– Bashdi
yesterday
*How to know if my ScanSettings-Class is right or the NodeId I use for encoding is wrong?
– Bashdi
yesterday
UPDATE: After a little bit of work I just get a TimeOut when I call the methode with a ScanSettings Object as Argument. Is there any way to identify the problem? How to know if my ScanSettings-Class is right or the NodeId I use is wrong?
– Bashdi
yesterday
UPDATE: After a little bit of work I just get a TimeOut when I call the methode with a ScanSettings Object as Argument. Is there any way to identify the problem? How to know if my ScanSettings-Class is right or the NodeId I use is wrong?
– Bashdi
yesterday
*How to know if my ScanSettings-Class is right or the NodeId I use for encoding is wrong?
– Bashdi
yesterday
*How to know if my ScanSettings-Class is right or the NodeId I use for encoding is wrong?
– Bashdi
yesterday
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389075%2feclipse-milo-how-to-call-method-which-takes-a-customdatatype-as-argument%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389075%2feclipse-milo-how-to-call-method-which-takes-a-customdatatype-as-argument%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
UPDATE: After a little bit of work I just get a TimeOut when I call the methode with a ScanSettings Object as Argument. Is there any way to identify the problem? How to know if my ScanSettings-Class is right or the NodeId I use is wrong?
– Bashdi
yesterday
*How to know if my ScanSettings-Class is right or the NodeId I use for encoding is wrong?
– Bashdi
yesterday