def test_create_struct_sync_client(client): idx = 4 new_struct(client, idx, "MyMyStruct", [ new_struct_field("MyBool", ua.VariantType.Boolean), new_struct_field("MyUInt32", ua.VariantType.UInt32, array=True), ]) client.load_data_type_definitions() mystruct = ua.MyMyStruct() mystruct.MyUInt32 = [78, 79] var = client.nodes.objects.add_variable(idx, "my_struct", mystruct) val = var.read_value() assert val.MyUInt32 == [78, 79]
async def test_custom_struct_(opc): idx = 4 await new_struct(opc.opc, idx, "MyMyStruct", [ 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.MyMyStruct() mystruct.MyUInt32 = [78, 79] var = await opc.opc.nodes.objects.add_variable(idx, "my_struct", ua.Variant(mystruct, ua.VariantType.ExtensionObject)) val = await var.read_value() assert val.MyUInt32 == [78, 79]