--- a/mqtt/mqtt_client_gen.py Fri Sep 13 14:26:55 2024 +0200
+++ b/mqtt/mqtt_client_gen.py Fri Sep 13 14:28:07 2024 +0200
@@ -488,143 +488,3 @@
return Ccode
-if __name__ == "__main__":
-
- import wx.lib.mixins.inspection as wit
- import sys,os
-
- app = wit.InspectableApp()
-
- frame = wx.Frame(None, -1, "MQTT Client Test App", size=(800,600))
-
- argc = len(sys.argv)
-
- config={}
- config["URI"] = sys.argv[1] if argc>1 else "tcp://localhost:1883"
- config["clientID"] = sys.argv[2] if argc>2 else ""
- config["AuthType"] = None
- config["UseMQTT5"] = True
-
- if argc > 3:
- AuthType = sys.argv[3]
- config["AuthType"] = AuthType
- for (name, default), value in zip_longest(authParams[AuthType], sys.argv[4:]):
- if value is None:
- if default is None:
- raise Exception(name+" param expected")
- value = default
- config[name] = value
-
- test_panel = wx.Panel(frame)
- test_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
- test_sizer.AddGrowableCol(0)
- test_sizer.AddGrowableRow(0)
-
- modeldata = MQTTClientModel(print)
-
- mqtttestpanel = MQTTClientPanel(test_panel, modeldata, print, lambda:config)
-
- def OnGenerate(evt):
- dlg = wx.FileDialog(
- frame, message="Generate file as ...", defaultDir=os.getcwd(),
- defaultFile="",
- wildcard="C (*.c)|*.c", style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT
- )
-
- if dlg.ShowModal() == wx.ID_OK:
- path = dlg.GetPath()
- Ccode = """
-/*
-In case open62541 was built just aside beremiz, you can build this test with:
-gcc %s -o %s \\
- -I ../../open62541/plugins/include/ \\
- -I ../../open62541/build/src_generated/ \\
- -I ../../open62541/include/ \\
- -I ../../open62541/arch/ ../../open62541/build/bin/libopen62541.a
-*/
-
-"""%(path, path[:-2]) + modeldata.GenerateC(path, "test", config) + """
-
-int LogMessage(uint8_t level, char* buf, uint32_t size){
- printf("log level:%d message:'%.*s'\\n", level, size, buf);
-};
-
-int main(int argc, char *argv[]) {
-
- __init_test(arc,argv);
-
- __retrieve_test();
-
- __publish_test();
-
- __cleanup_test();
-
- return EXIT_SUCCESS;
-}
-"""
-
- with open(path, 'w') as Cfile:
- Cfile.write(Ccode)
-
-
- dlg.Destroy()
-
- def OnLoad(evt):
- dlg = wx.FileDialog(
- frame, message="Choose a file",
- defaultDir=os.getcwd(),
- defaultFile="",
- wildcard="CSV (*.csv)|*.csv",
- style=wx.FD_OPEN | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST )
-
- if dlg.ShowModal() == wx.ID_OK:
- path = dlg.GetPath()
- modeldata.LoadCSV(path)
- mqtttestpanel.Reset()
-
- dlg.Destroy()
-
- def OnSave(evt):
- dlg = wx.FileDialog(
- frame, message="Save file as ...", defaultDir=os.getcwd(),
- defaultFile="",
- wildcard="CSV (*.csv)|*.csv", style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT
- )
-
- if dlg.ShowModal() == wx.ID_OK:
- path = dlg.GetPath()
- modeldata.SaveCSV(path)
-
- dlg.Destroy()
-
- test_sizer.Add(mqtttestpanel, flag=wx.GROW|wx.EXPAND)
-
- testbt_sizer = wx.BoxSizer(wx.HORIZONTAL)
-
- loadbt = wx.Button(test_panel, label="Load")
- test_panel.Bind(wx.EVT_BUTTON, OnLoad, loadbt)
-
- savebt = wx.Button(test_panel, label="Save")
- test_panel.Bind(wx.EVT_BUTTON, OnSave, savebt)
-
- genbt = wx.Button(test_panel, label="Generate")
- test_panel.Bind(wx.EVT_BUTTON, OnGenerate, genbt)
-
- testbt_sizer.Add(loadbt, 0, wx.LEFT|wx.RIGHT, 5)
- testbt_sizer.Add(savebt, 0, wx.LEFT|wx.RIGHT, 5)
- testbt_sizer.Add(genbt, 0, wx.LEFT|wx.RIGHT, 5)
-
- test_sizer.Add(testbt_sizer, flag=wx.GROW)
- test_sizer.Layout()
- test_panel.SetAutoLayout(True)
- test_panel.SetSizer(test_sizer)
-
- def OnClose(evt):
- mqtttestpanel.OnClose()
- evt.Skip()
-
- frame.Bind(wx.EVT_CLOSE, OnClose)
-
- frame.Show()
-
- app.MainLoop()