Initial Commit - Monitoring Cell V, T
This commit is contained in:
commit
5e407e52e0
12 changed files with 4667 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/venv/
|
||||||
2
.idea/.gitignore
generated
vendored
Normal file
2
.idea/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Default ignored files
|
||||||
|
/workspace.xml
|
||||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (wxGladeTest)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/wxGladeTest.iml" filepath="$PROJECT_DIR$/.idea/wxGladeTest.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
10
.idea/wxGladeTest.iml
generated
Normal file
10
.idea/wxGladeTest.iml
generated
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
BIN
PCANBasic.dll
Normal file
BIN
PCANBasic.dll
Normal file
Binary file not shown.
4
can.ini
Normal file
4
can.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[default]
|
||||||
|
interface = pcan
|
||||||
|
channel = PCAN_USBBUS1
|
||||||
|
bitrate = 250000
|
||||||
6
cantools-ebus.py
Normal file
6
cantools-ebus.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import cantools
|
||||||
|
from pprint import pprint
|
||||||
|
db = cantools.database.load_file('res/EBUS_Host.dbc')
|
||||||
|
pprint(db.messages)
|
||||||
|
# example_message = db.get_message_by_name('ExampleMessage')
|
||||||
|
# pprint(example_message.signals)
|
||||||
128
hello.py
Normal file
128
hello.py
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
#
|
||||||
|
# generated by wxGlade 0.9.5 on Mon Feb 3 15:18:49 2020
|
||||||
|
#
|
||||||
|
|
||||||
|
import wx
|
||||||
|
import wx.propgrid
|
||||||
|
|
||||||
|
# begin wxGlade: dependencies
|
||||||
|
import gettext
|
||||||
|
# end wxGlade
|
||||||
|
|
||||||
|
import can
|
||||||
|
import cantools
|
||||||
|
|
||||||
|
# begin wxGlade: extracode
|
||||||
|
# end wxGlade
|
||||||
|
|
||||||
|
|
||||||
|
class MyFrame(wx.Frame):
|
||||||
|
def __init__(self, *args, **kwds):
|
||||||
|
# begin wxGlade: MyFrame.__init__
|
||||||
|
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
|
||||||
|
wx.Frame.__init__(self, *args, **kwds)
|
||||||
|
self.SetSize((400, 300))
|
||||||
|
|
||||||
|
self.counter = 0
|
||||||
|
self.timer = wx.Timer(self)
|
||||||
|
self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
|
||||||
|
|
||||||
|
self.property_grid_1 = wx.propgrid.PropertyGrid(self, wx.ID_ANY)
|
||||||
|
#cat1 = wx.propgrid.PropertyCategory("Message 1")
|
||||||
|
#self.property_grid_1.Append(cat1)
|
||||||
|
#self.property_grid_1.AppendIn(wx.propgrid.PGPropArgCls(cat1), wx.propgrid.StringProperty(label="sp1", name="test_string", value="some string value"))
|
||||||
|
self.property_grid_1.Append(wx.propgrid.StringProperty(label="sp1", value="some string value"))
|
||||||
|
|
||||||
|
self.button_1 = wx.ToggleButton(self, wx.ID_ANY, _("Start"))
|
||||||
|
|
||||||
|
self.__set_properties()
|
||||||
|
self.__do_layout()
|
||||||
|
|
||||||
|
self.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleCAN, self.button_1)
|
||||||
|
# end wxGlade
|
||||||
|
|
||||||
|
self.candb = cantools.database.load_file('res/EBUS_Host.dbc')
|
||||||
|
|
||||||
|
self.battery_module_state = [{} for i in range(18)]
|
||||||
|
|
||||||
|
|
||||||
|
def __set_properties(self):
|
||||||
|
# begin wxGlade: MyFrame.__set_properties
|
||||||
|
self.SetTitle(_("frame"))
|
||||||
|
# end wxGlade
|
||||||
|
|
||||||
|
def __do_layout(self):
|
||||||
|
# begin wxGlade: MyFrame.__do_layout
|
||||||
|
sizer_1 = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
sizer_1.Add(self.property_grid_1, 1, wx.EXPAND, 0)
|
||||||
|
sizer_1.Add(self.button_1, 0, 0, 0)
|
||||||
|
self.SetSizer(sizer_1)
|
||||||
|
self.Layout()
|
||||||
|
# end wxGlade
|
||||||
|
|
||||||
|
def ToggleCAN(self, event): # wxGlade: MyFrame.<event_handler>
|
||||||
|
btnLabel = self.button_1.GetLabel()
|
||||||
|
if self.button_1.Value:
|
||||||
|
print ("starting timer...")
|
||||||
|
self.bus = can.Bus()
|
||||||
|
|
||||||
|
self.timer.Start(10)
|
||||||
|
self.button_1.SetLabel("Stop")
|
||||||
|
else:
|
||||||
|
print ( "timer stopped!" )
|
||||||
|
self.bus.shutdown()
|
||||||
|
self.bus = None
|
||||||
|
|
||||||
|
self.timer.Stop()
|
||||||
|
self.button_1.SetLabel("Start")
|
||||||
|
|
||||||
|
event.Skip()
|
||||||
|
|
||||||
|
def OnTimer(self, event): # wxGlade: MyFrame.<event_handler>
|
||||||
|
# print("Read CAN Message!")
|
||||||
|
msg = self.bus.recv(timeout=1.)
|
||||||
|
islave = (msg.arbitration_id & (~0xfffff0ff))
|
||||||
|
mtag = (msg.arbitration_id & 0xfffff000) >> 12
|
||||||
|
mid = (msg.arbitration_id & 0xf00) >> 8
|
||||||
|
mtype = msg.arbitration_id & 0xff
|
||||||
|
if 0x07 <= mtype <= 0x0b:
|
||||||
|
try:
|
||||||
|
dmsg = self.candb.decode_message(msg.arbitration_id, msg.data)
|
||||||
|
except KeyError as key:
|
||||||
|
print(key, " does not exist")
|
||||||
|
else:
|
||||||
|
print(hex(msg.arbitration_id), hex(mtag), hex(mid), hex(mtype), dmsg)
|
||||||
|
self.__update_bm_state(dmsg)
|
||||||
|
|
||||||
|
for k in self.battery_module_state[0]:
|
||||||
|
if self.property_grid_1.GetProperty(k):
|
||||||
|
self.property_grid_1.SetPropertyValue(k, self.battery_module_state[0][k])
|
||||||
|
else:
|
||||||
|
self.property_grid_1.Append(wx.propgrid.StringProperty(label=k, value=str(self.battery_module_state[0][k])))
|
||||||
|
event.Skip()
|
||||||
|
|
||||||
|
|
||||||
|
def __update_bm_state(self, dmsg):
|
||||||
|
imodule = dmsg['BatS_Cell_ModuleNo']
|
||||||
|
for k in dmsg:
|
||||||
|
self.battery_module_state[imodule][k] = dmsg[k]
|
||||||
|
|
||||||
|
|
||||||
|
# end of class MyFrame
|
||||||
|
|
||||||
|
class MyApp(wx.App):
|
||||||
|
def OnInit(self):
|
||||||
|
self.frame = MyFrame(None, wx.ID_ANY, "")
|
||||||
|
self.SetTopWindow(self.frame)
|
||||||
|
self.frame.Show()
|
||||||
|
return True
|
||||||
|
|
||||||
|
# end of class MyApp
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
gettext.install("app") # replace with the appropriate catalog name
|
||||||
|
|
||||||
|
app = MyApp(0)
|
||||||
|
app.MainLoop()
|
||||||
4492
res/EBUS_Host.dbc
Normal file
4492
res/EBUS_Host.dbc
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue