I am able to create a custom datatype using python-opcua examples. I want to create an array for the custom data type. Example: I want to create : ARRAY[0..1] OF type_def_Struct
I tried by creating a list, like we do in python and define custom variable in it. is this the right way to create it?
#Custom Variable
custom_var_1 = "custom_var_1"
dict_builder = DataTypeDictionaryBuilder(server, idx, OPCUA_NAMESPACE, "My_Dict")
custom_var_1_name = dict_builder.create_data_type(custom_var_1)
custom_var_1_name.add_field("id", ua.VariantType.Int32)
custom_var_1_name.add_field("name", ua.VariantType.String)
# dev is just another object
my_obj = server.nodes.objects.add_object(idx, "Device-001", dev)
# Array for custom variable
basic_struct_1= [my_obj.add_variable(idx, "type_def_Struct_1", ua.Variant(None, ua.VariantType.Null),
custom_var_1_name.data_type),
my_obj.add_variable(idx, "type_def_Struct_2",
ua.Variant(None, ua.VariantType.Null),
custom_var_1_name.data_type)]
basic_struct_1[0].set_writable(True)
basic_msg_1 = get_ua_class(custom_var_1)()
basic_msg_1.id = 1
basic_msg_1.name = "abc"
basic_struct_1[0].set_value(basic_msg_1)
basic_struct_1[1].set_writable(True)
basic_msg_1 = get_ua_class(custom_var_1)()
basic_msg_1.id = 2
basic_msg_1.name = "cdf"
basic_struct_1[1].set_value(basic_msg_1)