if self.port.State==0: #cant connect, exit thread
self.stop()
wx.PostEvent(self._notify_window, StatusEvent([666])) #signal apl, that communication was disconnected
- wx.PostEvent(self._notify_window, StatusEvent([0,1,"Error cant connect..."]))
+ wx.PostEvent(self._notify_window, StatusEvent([0,1,"Could not connect to device"]))
return None
wx.PostEvent(self._notify_window, StatusEvent([0,1,"Connected"]))
def stop(self):
if self.port != None: #if stop is called before any connection port is not defined (and not connected )
- self.port.close()
+ self.port.close()
wx.PostEvent(self._notify_window, StatusEvent([0,1,"Disconnected"]))
- wx.PostEvent(self._notify_window, StatusEvent([2,1,"----"]))
+ wx.PostEvent(self._notify_window, StatusEvent([2,1,"---"]))
#class producer end
self.dtcmenu.Enable(ID_CLEAR,True)
self.GetDTCButton.Enable(True)
self.ClearDTCButton.Enable(True)
+ self.connectButton.Enable(False)
+ self.disconnectButton.Enable(True)
def sensor_toggle(e):
sel = e.m_itemIndex
self.settingmenu.Enable(ID_RESET,True)
self.GetDTCButton.Enable(False)
self.ClearDTCButton.Enable(False)
+ self.connectButton.Enable(True)
+ self.disconnectButton.Enable(False)
+
#http://pyserial.sourceforge.net/ empty function
#EVT_LIST_ITEM_ACTIVATED(self.sensors,self.sensor_id, lambda : None)
+ def build_status_page(self):
+ HOFFSET_LIST=35 #offset from the top of panel (space for buttons)
+ tID = wx.NewId()
+ self.devpanel = wx.Panel(self.nb, -1)
+ self.connectButton = wx.Button(self.devpanel,-1 ,"Connect" , wx.Point(0,0))
+ self.disconnectButton = wx.Button(self.devpanel,-1,"Disconnect", wx.Point(85,0))
+
+ #bind functions to button click action
+ self.devpanel.Bind(wx.EVT_BUTTON,self.OpenPort,self.connectButton)
+ self.devpanel.Bind(wx.EVT_BUTTON,self.OnDisconnect,self.disconnectButton)
+
+ self.status = self.MyListCtrl(self.devpanel, tID, pos=wx.Point(0,HOFFSET_LIST),
+ style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_HRULES|wx.LC_SINGLE_SEL)
+
+ self.status.InsertColumn(0, "Description",width=100)
+ self.status.InsertColumn(1, "Value")
+ self.status.Append(["Link State","Disconnected"]);
+ self.status.Append(["Protocol","---"]);
+ self.status.Append(["Cable version","---"]);
+ self.status.Append(["Device",self.COMPORT]);
+ ####################################################################
+ # This little bit of magic keeps the list the same size as the frame
+ def OnPSize(e, win = self.devpanel):
+ self.devpanel.SetSize(e.GetSize())
+ self.status.SetSize(e.GetSize())
+ w,h = self.frame.GetClientSizeTuple()
+ self.status.SetDimensions(0, HOFFSET_LIST, w-4, h-HOFFSET_LIST-33)
+
+ self.devpanel.Bind(wx.EVT_SIZE,OnPSize)
+ ####################################################################
+
+ self.nb.AddPage(self.devpanel, "Status")
+
def build_sensor_page(self):
HOFFSET_LIST=0
tID = wx.NewId()
self.sensors.InsertColumn(0, "Supported",width=70)
- self.sensors.InsertColumn(1, "Sensor",format=wx.LIST_FORMAT_RIGHT, width=250)
+ self.sensors.InsertColumn(1, "Sensor (doubleclick a row to enable)",format=wx.LIST_FORMAT_RIGHT, width=250)
self.sensors.InsertColumn(2, "Value")
for i in range(0, len(obd_io.obd_sensors.SENSORS)):
s = obd_io.obd_sensors.SENSORS[i].name
panel.SetSize(e.GetSize())
self.sensors.SetSize(e.GetSize())
w,h = self.frame.GetClientSizeTuple()
- self.sensors.SetDimensions(0,HOFFSET_LIST, w-10 , h - 35 )
+ self.sensors.SetDimensions(0, HOFFSET_LIST, w-4, h-HOFFSET_LIST-33)
panel.Bind(wx.EVT_SIZE,OnPSize)
####################################################################
self.nb.AddPage(panel, "Sensors")
def build_DTC_page(self):
- HOFFSET_LIST=30 #offset from the top of panel (space for buttons)
+ HOFFSET_LIST=35 #offset from the top of panel (space for buttons)
tID = wx.NewId()
self.DTCpanel = wx.Panel(self.nb, -1)
- self.GetDTCButton = wx.Button(self.DTCpanel,-1 ,"Get DTC" , wx.Point(15,0))
- self.ClearDTCButton = wx.Button(self.DTCpanel,-1,"Clear DTC", wx.Point(100,0))
+ self.GetDTCButton = wx.Button(self.DTCpanel,-1 ,"Get DTC" , wx.Point(0,0))
+ self.ClearDTCButton = wx.Button(self.DTCpanel,-1,"Clear DTC", wx.Point(85,0))
#bind functions to button click action
self.DTCpanel.Bind(wx.EVT_BUTTON,self.GetDTC,self.GetDTCButton)
self.DTCpanel.SetSize(e.GetSize())
self.dtc.SetSize(e.GetSize())
w,h = self.frame.GetClientSizeTuple()
- # I have no idea where 70 comes from
- self.dtc.SetDimensions(0,HOFFSET_LIST, w-16 , h - 70 )
+ self.dtc.SetDimensions(0, HOFFSET_LIST, w-4, h-HOFFSET_LIST-33)
self.DTCpanel.Bind(wx.EVT_SIZE,OnPSize)
####################################################################
# Main notebook frames
self.nb = wx.Notebook(frame, -1, style = wx.NB_TOP)
- self.status = self.MyListCtrl(self.nb, tID,style=wx.LC_REPORT|wx.SUNKEN_BORDER)
- self.status.InsertColumn(0, "Description",width=100)
- self.status.InsertColumn(1, "Value")
- self.status.Append(["Link State","Disconnected"]);
- self.status.Append(["Protocol","---"]);
- self.status.Append(["Cable version","---"]);
- self.status.Append(["Device",self.COMPORT]);
-
- self.nb.AddPage(self.status, "Status")
+ self.build_status_page()
self.OBDTests = self.MyListCtrl(self.nb, tID,style=wx.LC_REPORT|wx.SUNKEN_BORDER)
self.OBDTests.InsertColumn(0, "Description",width=200)