--- a/mqtt/client.py Fri Aug 30 11:54:36 2024 +0200
+++ b/mqtt/client.py Fri Aug 30 15:17:03 2024 +0200
@@ -29,7 +29,11 @@
self.Controler.GetCTRoot().logger.write(msg)
def CreateMQTTClient_UI(self, parent):
- return MQTTClientPanel(parent, self.Controler.GetModelData(), self.Log, self.Controler.GetConfig)
+ return MQTTClientPanel(
+ parent,
+ self.Controler.GetModelData(),
+ self.Log,
+ self.Controler.GetTypes)
class MQTTClient(object):
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
@@ -86,6 +90,10 @@
def GetModelData(self):
return self.modeldata
+ def GetTypes(self):
+ datatype_candidates = self.GetCTRoot().GetDataTypes()
+ return datatype_candidates
+
def GetConfig(self):
def cfg(path):
try:
@@ -194,3 +202,9 @@
"location": ".".join([str(i) for i in current_location]) + ".x",
"children": children}
+
+ def CTNGlobalInstances(self):
+ location_str = "_".join(map(str, self.GetCurrentLocation()))
+ return [("MQTT_HAPPY_"+location_str, "DINT", "")]
+
+
--- a/mqtt/mqtt_client_gen.py Fri Aug 30 11:54:36 2024 +0200
+++ b/mqtt/mqtt_client_gen.py Fri Aug 30 15:17:03 2024 +0200
@@ -152,8 +152,16 @@
def ResetData(self):
self.Reset(len(self.data))
+class MQQTTypeChoiceRenderer(dv.DataViewChoiceRenderer):
+ def __init__(self, types_getter):
+ dv.DataViewChoiceRenderer.__init__(self, types_getter())
+ self.types_getter = types_getter
+
+ def GetChoices(self):
+ return self.types_getter()
+
class MQTTTopicListPanel(wx.Panel):
- def __init__(self, parent, log, model, direction):
+ def __init__(self, parent, log, model, direction, types_getter):
self.log = log
wx.Panel.__init__(self, parent, -1)
@@ -171,7 +179,12 @@
dsc = lstcoldsc[direction]
for idx,(colname,width) in enumerate(zip(dsc.lstcolnames,dsc.lstcolwidths)):
- self.dvc.AppendTextColumn(colname, idx, width=width, mode=dv.DATAVIEW_CELL_EDITABLE)
+ if colname == "Type":
+ choice_DV_render = MQQTTypeChoiceRenderer(types_getter)
+ choice_DV_col = dv.DataViewColumn(colname, choice_DV_render, idx, width=width)
+ self.dvc.AppendColumn(choice_DV_col)
+ else:
+ self.dvc.AppendTextColumn(colname, idx, width=width, mode=dv.DATAVIEW_CELL_EDITABLE)
self.Sizer = wx.BoxSizer(wx.VERTICAL)
@@ -206,18 +219,16 @@
class MQTTClientPanel(wx.SplitterWindow):
- def __init__(self, parent, modeldata, log, config_getter):
+ def __init__(self, parent, modeldata, log, types_getter):
self.log = log
wx.SplitterWindow.__init__(self, parent, style=wx.SUNKEN_BORDER | wx.SP_3D)
- self.config_getter = config_getter
-
self.selected_datas = modeldata
self.selected_models = { direction:MQTTTopicListModel(
self.selected_datas[direction], log, direction) for direction in directions }
self.selected_lists = { direction:MQTTTopicListPanel(
self, log,
- self.selected_models[direction], direction)
+ self.selected_models[direction], direction, types_getter)
for direction in directions }
self.SplitHorizontally(*[self.selected_lists[direction] for direction in directions]+[300])