11:03, EET
January 27, 2012
Hi,
I was wondering if there is a way to use an own enum implementation, which extends Enumeration, as DataType for input argument of a method.
What I want to achieve is a way to allow e.g. “OK”, “NOK” as values for an input argument.
WIth DataType Boolean I only get a checkbox for setting the input value using UaExpert. What I want to see is a select box with my two defined options.
Is this possible? If yes, how to define this in Argument array?
Thanks.
Best regards
7:52, EET
December 21, 2011
Hi,
Yes, using a custom Enumeration as argument for a method is possible. SampleConsoleServer.createMyEnumNode() has a sample of adding your own Enumeration type. Then use the NodeId of your custom enumeration as the DataType of the argument (example of creating a custom method can be found in SampleConsoleServer.createMethodNode()). Using the latest version of UaExpert, you should see a drop-down of the possible values as input argument.
Best regards,
– Otso
9:03, EET
January 27, 2012
Hi Otso,
Thanks for your answer. I have the latest version. However, I can’t find method createMyEnumNode() in the SampleConsoleServer code!
I already created an enum which works and I also think I found my error. I tried to use the “public enum …” in setDataType(..) method instead of creating this enum as a DataType/Subtype of enumeration too.
However, also when I use my own EnumType I do not get Dropdown in UaExpert. Could you provide a short code snippet on how to do that?
That’s what I have done:
Argument[] inputs = new Argument[1];
inputs[0] = new Argument();
inputs[0].setName(“Input1”);
inputs[0].setDataType(myOwnEnumType.getNodeId());
inputs[0].setValueRank(ValueRanks.Scalar);
inputs[0].setArrayDimensions(null);
inputs[0].setDescription(new LocalizedText(“Value for Input1”, Locale.ENGLISH));
setMyMethod.setInputArguments(inputs);
where myOwnEnumType is defined as a UaDataTypeNode.
Best regards,
Fred
13:28, EET
December 21, 2011
The problems seems to be in the example type definition, if you followed the blog post sample.
The EnumStrings property must be defined as
PlainProperty enumStringsProperty = new PlainProperty( myNodeManager, myEnumStringsId, new QualifiedName("EnumStrings"), new LocalizedText("EnumStrings", LocalizedText.NO_LOCALE));
in order to define the BrowseName in namespace 0. The “default” constructor defines the BrowseName in the same namespace with the NodeId.
// WRONG PlainProperty enumStringsProperty = new PlainProperty( myNodeManager, myEnumStringsId, "EnumStrings", LocalizedText.NO_LOCALE);
Since EnumStrings is a standard property, the BrowseName must be defined in the standard namespace.
SampleConsoleServer.createMyEnumNode() is not yet in the released SDK sample code (version 1.4.2).
Most Users Ever Online: 1919
Currently Online:
13 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 738
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
mickey21654, donnyredmond08, keesha4235, cheribruce, candacekolb4, Garmcrypto7Zof, calebhardison, susannahdingle7, inilarythikibia, rickykennionModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1