MQTT+IDE: Allow user to associate IEC structure datatype to a topic.
authorEdouard Tisserant <edouard@beremiz.fr>
Fri, 30 Aug 2024 11:54:36 +0200
changeset 4009 51272fe96999
parent 4008 f30573e98600
child 4010 3779356cca8f
MQTT+IDE: Allow user to associate IEC structure datatype to a topic.
dialogs/BrowseLocationsDialog.py
mqtt/client.py
--- a/dialogs/BrowseLocationsDialog.py	Fri Aug 30 11:50:23 2024 +0200
+++ b/dialogs/BrowseLocationsDialog.py	Fri Aug 30 11:54:36 2024 +0200
@@ -134,7 +134,7 @@
         self.Controller = controller
         self.VarType = var_type
         self.BaseVarType = self.Controller.GetBaseType(self.VarType)
-        self.VarTypeSize = LOCATION_SIZES[self.BaseVarType]
+        self.VarTypeSize = LOCATION_SIZES[self.BaseVarType] if self.BaseVarType else None
         self.Locations = self.Controller.GetVariableLocationTree()
 
         # Define Tree item icon list
@@ -180,7 +180,7 @@
         if self.TypeFilter == 0:
             return True
 
-        if location_size != self.VarTypeSize:
+        if self.VarTypeSize is not None and location_size != self.VarTypeSize:
             return False
 
         if self.TypeFilter == 1:
--- a/mqtt/client.py	Fri Aug 30 11:50:23 2024 +0200
+++ b/mqtt/client.py	Fri Aug 30 11:54:36 2024 +0200
@@ -177,12 +177,12 @@
             entries.append((Topic, QoS, iec_type, iec_number, "I", LOCATION_VAR_INPUT))
 
         for Topic, QoS, iec_type, iec_number, iec_dir_prefix, loc_type in entries:
-            C_type, iec_size_prefix = MQTT_IEC_types[iec_type]
+            _C_type, iec_size_prefix = MQTT_IEC_types.get(iec_type,(None,""))
             c_loc_name = "__" + iec_dir_prefix + iec_size_prefix + locstr + "_" + str(iec_number)
             children.append({
                 "name": Topic,
                 "type": loc_type,
-                "size": {"X":1, "B":8, "W":16, "D":32, "L":64}[iec_size_prefix],
+                "size": {"X":1, "B":8, "W":16, "D":32, "L":64, "":None}[iec_size_prefix],
                 "IEC_type": iec_type,
                 "var_name": c_loc_name,
                 "location": "%" + iec_dir_prefix + iec_size_prefix + ".".join([str(i) for i in current_location]) + "." + str(iec_number),