Commit 0b866d06 authored by oroulet's avatar oroulet Committed by oroulet

use single code for struct generation

parent 1c94c659
......@@ -62,11 +62,11 @@ async def new_struct(
simple way to create a new structure
return the created data type node and the list of encoding nodes
"""
type_name = server.nodes.base_structure_type
if is_union:
type_name = server.nodes.base_union_type
dtype = await create_data_type(type_name, idx, name)
if isinstance(idx, ua.NodeId):
......@@ -176,7 +176,7 @@ class {struct_name}{base_class}:
{struct_name} structure autogenerated from StructureDefinition object
'''
data_type = ua.NodeId.from_string("{data_type.to_string()}")
data_type = ua.NodeId.from_string('{data_type.to_string()}')
"""
......
......@@ -1575,3 +1575,18 @@ async def test_alias(opc):
v.MyStringType = '1234'
await var.write_value(v)
val = await var.read_value()
async def test_custom_struct_with_strange_chars(opc):
idx = 4
await new_struct(opc.opc, ua.StringNodeId('Toto"æ', 99), ua.QualifiedName("Siemens", 99), [
new_struct_field("MyBool", ua.VariantType.Boolean),
new_struct_field("MyUInt32", ua.VariantType.UInt32, array=True),
])
await opc.opc.load_data_type_definitions()
mystruct = ua.Siemens()
mystruct.MyUInt32 = [78, 79]
var = await opc.opc.nodes.objects.add_variable(idx, "my_siemens_struct", ua.Variant(mystruct, ua.VariantType.ExtensionObject))
val = await var.read_value()
assert val.MyUInt32 == [78, 79]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment