WIP(Cnt'd)

This commit is contained in:
Yeongdo Park 2020-03-25 13:02:25 -07:00
parent ec41b6912b
commit ef70a3d592
3 changed files with 106 additions and 21 deletions

View file

@ -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

View file

@ -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()

View file

@ -1,9 +1,9 @@
<?xml version="1.0"?>
<!-- generated by wxGlade 0.9.5 on Wed Feb 19 19:23:18 2020 -->
<!-- generated by wxGlade 0.9.5 on Fri Feb 21 16:44:12 2020 -->
<application class="BmsApp" encoding="UTF-8" for_version="3.0" header_extension=".h" indent_amount="4" indent_symbol="space" is_template="0" language="python" mark_blocks="1" name="app" option="0" overwrite="1" path="./BmsView.py" source_extension=".cpp" top_window="frame" use_gettext="1" use_new_namespace="1">
<object class="BmsMonitorFrame" name="frame" base="EditFrame">
<size>798, 638</size>
<size>831, 774</size>
<title>frame</title>
<style>wxDEFAULT_FRAME_STYLE</style>
<object class="wxBoxSizer" name="sizer_1" base="EditBoxSizer">
@ -92,7 +92,7 @@
<border>0</border>
<flag>wxEXPAND</flag>
<object class="wxPropertyGridManager" name="property_grid_1" base="EditPropertyGridManager">
<style>wxPG_TOOLBAR|wxPG_DESCRIPTION</style>
<style>wxPG_AUTO_SORT|wxPG_TOOLBAR|wxPG_DESCRIPTION</style>
</object>
</object>
</object>
@ -104,11 +104,37 @@
<object class="wxBoxSizer" name="sizer_4" base="EditBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<option>1</option>
<option>0</option>
<border>0</border>
<flag>wxEXPAND</flag>
<object class="wxTreeCtrl" name="tree_ctrl_1" base="EditTreeCtrl">
<style>wxTR_HAS_BUTTONS|wxTR_HIDE_ROOT</style>
<object class="wxBoxSizer" name="sizer_5" base="EditBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<option>0</option>
<border>0</border>
<object class="wxStaticText" name="label_3" base="EditStaticText">
<label>Module Number: </label>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<border>0</border>
<object class="wxSpinCtrl" name="spin_ctrl_1" base="EditSpinCtrl">
<style>wxSP_ARROW_KEYS</style>
<range>0, 27</range>
<value>0</value>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<border>0</border>
<object class="wxComboBox" name="combo_box_1" base="EditComboBox">
<style>wxCB_DROPDOWN</style>
<selection>-1</selection>
<choices>
</choices>
</object>
</object>
</object>
</object>
<object class="sizeritem">
@ -144,6 +170,34 @@
<selection_mode>wxGrid.wxGridSelectCells</selection_mode>
</object>
</object>
<object class="sizeritem">
<option>0</option>
<border>0</border>
<flag>wxEXPAND</flag>
<object class="wxStaticLine" name="static_line_1" base="EditStaticLine">
<style>wxLI_HORIZONTAL</style>
</object>
</object>
<object class="sizeritem">
<option>1</option>
<border>0</border>
<flag>wxEXPAND</flag>
<object class="wxGrid" name="grid_2" base="EditGrid">
<create_grid>1</create_grid>
<columns>
<column size="-1">Warning1</column>
<column size="-1">Warning2</column>
<column size="-1">Fault</column>
</columns>
<rows_number>16</rows_number>
<enable_editing>1</enable_editing>
<enable_grid_lines>1</enable_grid_lines>
<enable_col_resize>1</enable_col_resize>
<enable_row_resize>1</enable_row_resize>
<enable_grid_resize>1</enable_grid_resize>
<selection_mode>wxGrid.wxGridSelectCells</selection_mode>
</object>
</object>
</object>
</object>
</object>