diff --git a/BmsApp.py b/BmsApp.py index fdd1966..b49cff6 100644 --- a/BmsApp.py +++ b/BmsApp.py @@ -51,8 +51,10 @@ def findCategory (imsg, isignal): return "moduledata" else: + print("undefined category ", hex(imsg)) return "undefined" +cat_propgrid = ["bmsprofile", "packprofile", "packdata", "packalarms",] class BmsMonitorView(BmsMonitorFrame): def __init__(self, *args, **kwds): @@ -60,28 +62,43 @@ class BmsMonitorView(BmsMonitorFrame): self.property_grid_page_info = self.property_grid_1.AddPage("Info") - for cat_name in ["bmsprofile", "packprofile", "packdata"]: + for cat_name in cat_propgrid: cat = wx.propgrid.PropertyCategory(label=cat_name) self.property_grid_page_info.Append(cat) # bms_model = wx.propgrid.StringProperty(label="Model", name="bms_model", value="B3DWER32EW") # self.property_grid_page_info.AppendIn("packdata", bms_model) + tohex = "{:#04X}-".format for msg in db.messages: tag, id, type = parse_can_id(msg.frame_id) - for signal in msg.signals: - if signal.is_float: - prop = wx.propgrid.FloatProperty(label=signal.name) - else: - prop = wx.propgrid.IntProperty(label=signal.name) - prop.SetHelpString(signal.comment) + if id == 0x02: - if tag == 0x14180 and id == 0x2 and 0x00 <= type <= 0x06: # BMS Profile + if findCategory(msg.frame_id, 0) == "bmsprofile": + prop = wx.propgrid.StringProperty(label=msg.name) self.property_grid_page_info.AppendIn("bmsprofile", prop) - if tag == 0x14180 and id == 0x2 and 0x10 <= type <= 0x20: # Pack Profile and Data - self.property_grid_page_info.AppendIn("packdata", prop) + for isig, signal in enumerate(msg.signals): + plabel = tohex(type)+signal.name + if signal.is_float: + prop = wx.propgrid.FloatProperty(label=plabel) + else: + prop = wx.propgrid.IntProperty(label=plabel) + prop.SetHelpString(signal.comment) + + cat = findCategory(msg.frame_id, isig) + + if cat in cat_propgrid: + self.property_grid_page_info.AppendIn(cat, prop) + + ''' + if tag == 0x14180 and id == 0x2 and 0x00 <= type <= 0x06: # BMS Profile + self.property_grid_page_info.AppendIn("bmsprofile", prop) + + if tag == 0x14180 and id == 0x2 and 0x10 <= type <= 0x20: # Pack Profile and Data + self.property_grid_page_info.AppendIn("packdata", prop) + ''' # end of class BmsMonitorFrame diff --git a/BmsView.py b/BmsView.py index d529e43..5a333de 100644 --- a/BmsView.py +++ b/BmsView.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 -*- # -# generated by wxGlade 0.9.5 on Wed Feb 19 19:23:19 2020 +# generated by wxGlade 0.9.5 on Fri Feb 21 16:44:13 2020 # import wx @@ -21,12 +21,14 @@ class BmsMonitorFrame(wx.Frame): # begin wxGlade: BmsMonitorFrame.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) - self.SetSize((798, 638)) + self.SetSize((831, 774)) self.choice_2 = wx.Choice(self, wx.ID_ANY, choices=[_("choice 1")]) self.choice_1 = wx.Choice(self, wx.ID_ANY, choices=[_("0x02"), _("0x03"), _("0x04"), _("0x05"), _("0x06"), _("0x07"), _("0x08"), _("0x09")]) - self.property_grid_1 = wx.propgrid.PropertyGridManager(self, wx.ID_ANY, style=wx.propgrid.PG_DESCRIPTION | wx.propgrid.PG_TOOLBAR) - self.tree_ctrl_1 = wx.TreeCtrl(self, wx.ID_ANY, style=wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT) + self.property_grid_1 = wx.propgrid.PropertyGridManager(self, wx.ID_ANY, style=wx.propgrid.PG_AUTO_SORT | wx.propgrid.PG_DESCRIPTION | wx.propgrid.PG_TOOLBAR) + self.spin_ctrl_1 = wx.SpinCtrl(self, wx.ID_ANY, "0", min=0, max=27) + self.combo_box_1 = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN) self.grid_1 = wx.grid.Grid(self, wx.ID_ANY, size=(1, 1)) + self.grid_2 = wx.grid.Grid(self, wx.ID_ANY, size=(1, 1)) self.__set_properties() self.__do_layout() @@ -53,12 +55,17 @@ class BmsMonitorFrame(wx.Frame): self.grid_1.SetRowLabelValue(9, _("Cell 10")) self.grid_1.SetRowLabelValue(10, _("Cell 11")) self.grid_1.SetRowLabelValue(11, _("Cell 12")) + self.grid_2.CreateGrid(16, 3) + self.grid_2.SetColLabelValue(0, _("Warning1")) + self.grid_2.SetColLabelValue(1, _("Warning2")) + self.grid_2.SetColLabelValue(2, _("Fault")) # end wxGlade def __do_layout(self): # begin wxGlade: BmsMonitorFrame.__do_layout sizer_1 = wx.BoxSizer(wx.HORIZONTAL) sizer_4 = wx.BoxSizer(wx.VERTICAL) + sizer_5 = wx.BoxSizer(wx.HORIZONTAL) sizer_3 = wx.BoxSizer(wx.VERTICAL) sizer_2 = wx.BoxSizer(wx.HORIZONTAL) label_1 = wx.StaticText(self, wx.ID_ANY, _("CAN Device")) @@ -73,8 +80,15 @@ class BmsMonitorFrame(wx.Frame): sizer_3.Add(sizer_2, 0, wx.EXPAND, 0) sizer_3.Add(self.property_grid_1, 1, wx.EXPAND, 0) sizer_1.Add(sizer_3, 1, wx.EXPAND, 0) - sizer_4.Add(self.tree_ctrl_1, 1, wx.EXPAND, 0) + label_3 = wx.StaticText(self, wx.ID_ANY, _("Module Number: ")) + sizer_5.Add(label_3, 0, 0, 0) + sizer_5.Add(self.spin_ctrl_1, 0, 0, 0) + sizer_5.Add(self.combo_box_1, 0, 0, 0) + sizer_4.Add(sizer_5, 0, wx.EXPAND, 0) sizer_4.Add(self.grid_1, 1, wx.EXPAND, 0) + static_line_1 = wx.StaticLine(self, wx.ID_ANY) + sizer_4.Add(static_line_1, 0, wx.EXPAND, 0) + sizer_4.Add(self.grid_2, 1, wx.EXPAND, 0) sizer_1.Add(sizer_4, 1, wx.EXPAND, 0) self.SetSizer(sizer_1) self.Layout() diff --git a/BmsView.wxg b/BmsView.wxg index 4c0821a..b2939e6 100644 --- a/BmsView.wxg +++ b/BmsView.wxg @@ -1,9 +1,9 @@ - + - 798, 638 + 831, 774 frame @@ -92,7 +92,7 @@ 0 wxEXPAND - + @@ -104,11 +104,37 @@ wxVERTICAL - + 0 wxEXPAND - - + + wxHORIZONTAL + + + 0 + + + + + + + 0 + + + 0, 27 + 0 + + + + + 0 + + + -1 + + + + @@ -144,6 +170,34 @@ wxGrid.wxGridSelectCells + + + 0 + wxEXPAND + + + + + + + 0 + wxEXPAND + + 1 + + Warning1 + Warning2 + Fault + + 16 + 1 + 1 + 1 + 1 + 1 + wxGrid.wxGridSelectCells + +