Enum in Custom Structure #1229
Answered
by
schroeder-
MatthewBoss96
asked this question in
Q&A
-
Hi! Is it possible to get an enumerate in a custom structure? async def EnumStructTest(self, server, idx:int, name:str) -> Struct:
await new_struct(server, idx, name, [
new_struct_field("Enum", ua.VariantType.ExtensionObject, description="Emum test"),
new_struct_field("String", ua.VariantType.String, description="String test"),
])
await self.EnumStructTest(self.server, self.idx, "EnumStructTest")
await self.server.load_data_type_definitions()
self.enumStructTest = await self.add_variable(self.Test, self.idx, "my_custom_enum", "Custom Enum Struct Test", ua.Variant([ua.EnumStructTest(ua.EnumerateTest.UNDEFINED, "")], ua.VariantType.ExtensionObject)) or async def EnumStructTest(self, server, idx:int, name:str) -> Struct:
await new_enum(server, idx, name,
[
"TEST1",
"TEST2",
"TEST3"
])
await new_struct(server, idx, name, [
new_struct_field("String", ua.VariantType.String, description="String test"),
]) But this does not work out the way I am expecting. Can you guys give me some directions? |
Beta Was this translation helpful? Give feedback.
Answered by
schroeder-
Feb 23, 2023
Replies: 1 comment 1 reply
-
This should work (untested): enum_nid = await new_enum(server, idx, name,
[
"TEST1",
"TEST2",
"TEST3"
])
struct_nid = dawait new_struct(server, idx, name, [
new_struct_field("Enum", enum_nid, description="Emum test"),
new_struct_field("String", ua.VariantType.String, description="String test"),
])
await self.server.load_data_type_definitions()
self.enumStructTest = await self.add_variable(self.Test, self.idx, "my_custom_enum", "Custom Enum Struct Test", ua.Variant([ua.EnumStructTest(ua.EnumerateTest.UNDEFINED, "")], struct_nid )) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
MatthewBoss96
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should work (untested):