36 PKG =
'pr2_power_board' 39 roslib.load_manifest(PKG)
49 if wxversion.checkInstalled(WXVER):
50 wxversion.select(WXVER)
52 print(
'This application requires wxPython version %s' % (WXVER), file=sys.stderr)
58 import threading, time
62 wx.Panel.__init__(self, parent, wx.ID_ANY)
66 xrc_path = roslib.packages.get_pkg_dir(PKG) +
'/ui/pr2_power_board_panel.xrc' 68 self.
_xrc = xrc.XmlResource(xrc_path)
69 self.
_real_panel = self._xrc.LoadPanel(self,
'PowerBoardPanel')
71 serialBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
72 self.
myList = wx.ComboBox(self, -1, size=(150,30), style=wx.CB_READONLY)
73 self.Bind(wx.EVT_COMBOBOX,
lambda e: self.
chooseBoard(self.myList.GetValue()))
74 serialBoxSizer.Add( wx.StaticText( self, -1,
"Board ") )
75 serialBoxSizer.Add( self.
myList )
76 serialBoxSizer.Add( wx.StaticText( self, -1,
"Serial ") )
78 self.serialText.SetEditable(
False)
82 sizer = wx.BoxSizer(wx.VERTICAL)
83 sizer.Add( serialBoxSizer, 0, wx.TOP)
87 self._real_panel.Bind(wx.EVT_BUTTON, self.
EnableCB0, id=xrc.XRCID(
'm_button1'))
88 self._real_panel.Bind(wx.EVT_BUTTON, self.
EnableCB1, id=xrc.XRCID(
'm_button11'))
89 self._real_panel.Bind(wx.EVT_BUTTON, self.
EnableCB2, id=xrc.XRCID(
'm_button12'))
91 self._real_panel.Bind(wx.EVT_BUTTON, self.
StandbyCB0, id=xrc.XRCID(
'm_button2'))
92 self._real_panel.Bind(wx.EVT_BUTTON, self.
StandbyCB1, id=xrc.XRCID(
'm_button21'))
93 self._real_panel.Bind(wx.EVT_BUTTON, self.
StandbyCB2, id=xrc.XRCID(
'm_button22'))
95 self._real_panel.Bind(wx.EVT_BUTTON, self.
ResetCB0, id=xrc.XRCID(
'm_button3'))
96 self._real_panel.Bind(wx.EVT_BUTTON, self.
ResetCB1, id=xrc.XRCID(
'm_button31'))
97 self._real_panel.Bind(wx.EVT_BUTTON, self.
ResetCB2, id=xrc.XRCID(
'm_button32'))
99 self._real_panel.Bind(wx.EVT_BUTTON, self.
DisableCB0, id=xrc.XRCID(
'cb0_disable'))
100 self._real_panel.Bind(wx.EVT_BUTTON, self.
DisableCB1, id=xrc.XRCID(
'cb1_disable'))
101 self._real_panel.Bind(wx.EVT_BUTTON, self.
DisableCB2, id=xrc.XRCID(
'cb2_disable'))
103 self._real_panel.Bind(wx.EVT_BUTTON, self.
ResetCurrent, id=xrc.XRCID(
'button_reset_current'))
104 self._real_panel.Bind(wx.EVT_BUTTON, self.
ResetTransitions, id=xrc.XRCID(
'button_reset_transitions'))
107 self.
power_control = rospy.ServiceProxy(
'power_board/control', PowerBoardCommand)
122 self.breaker0_status.SetEditable(
False)
123 self.breaker1_status.SetEditable(
False)
124 self.breaker2_status.SetEditable(
False)
125 self.estop_status.SetEditable(
False)
127 self.breaker0_status.SetEditable(
False)
128 self.breaker1_status.SetEditable(
False)
129 self.breaker2_status.SetEditable(
False)
130 self.estop_status.SetEditable(
False)
134 self.myList.SetValue(
"none")
140 self.serialText.Clear()
144 name = str(status.name)
146 for strvals
in status.values:
147 if (strvals.key ==
"Serial Number"):
148 serial = int(strvals.value)
149 rospy.logerr(
"Adding: %s serial=%d" %(name,serial))
150 self.myList.Append(name);
153 if self.myList.Count == 1:
154 self.myList.SetSelection(0)
159 self._mutex.acquire()
162 self._messages.append(message)
163 self._mutex.release()
170 self._mutex.acquire()
175 for status
in message.status:
176 if( (status.name.startswith(
"Power board") & (self.myList.FindString( status.name ) == wx.NOT_FOUND)) ):
181 if( status.level == 0 ):
182 self._real_panel.SetBackgroundColour(
"LIGHT_GREY")
183 self._real_panel.Enable(
True)
184 elif (status.level == 0):
185 self._real_panel.SetBackgroundColour(
"Orange")
187 self._real_panel.SetBackgroundColour(
"RED")
190 for value
in status.values:
191 if (value.key ==
"Breaker 0 Voltage"):
193 if (value.key ==
"Breaker 1 Voltage"):
195 if (value.key ==
"Breaker 2 Voltage"):
197 if (value.key ==
"RunStop Button Status"):
199 if (value.key ==
"RunStop Status"):
202 for strvals
in status.values:
203 if (re.match(
'Breaker 0',strvals.key,re.IGNORECASE)):
205 if (re.match(
'Breaker 1',strvals.key,re.IGNORECASE)):
207 if (re.match(
'Breaker 2',strvals.key,re.IGNORECASE)):
219 self.breaker0_status.SetBackgroundColour(
"Orange")
221 self.breaker0_status.SetBackgroundColour(
"Light Green")
223 self.breaker0_status.SetBackgroundColour(
"Red")
226 self.breaker1_status.SetBackgroundColour(
"Orange")
228 self.breaker1_status.SetBackgroundColour(
"Light Green")
230 self.breaker1_status.SetBackgroundColour(
"Red")
233 self.breaker2_status.SetBackgroundColour(
"Orange")
235 self.breaker2_status.SetBackgroundColour(
"Light Green")
237 self.breaker2_status.SetBackgroundColour(
"Red")
240 estop_status_temp =
"Stop" 241 self.estop_status.SetBackgroundColour(
"Red")
243 estop_status_temp =
"Run" 244 self.estop_status.SetBackgroundColour(
"Light Green")
251 self._mutex.release()
260 except rospy.ServiceException
as e:
261 rospy.logerr(
"Service Call Failed: %s"%e)
266 except rospy.ServiceException
as e:
267 rospy.logerr(
"Service Call Failed: %s"%e)
272 except rospy.ServiceException
as e:
273 rospy.logerr(
"Service Call Failed: %s"%e)
279 except rospy.ServiceException
as e:
280 rospy.logerr(
"Service Call Failed: %s"%e)
285 except rospy.ServiceException
as e:
286 rospy.logerr(
"Service Call Failed: %s"%e)
291 except rospy.ServiceException
as e:
292 rospy.logerr(
"Service Call Failed: %s"%e)
298 except rospy.ServiceException
as e:
299 rospy.logerr(
"Service Call Failed: %s"%e)
304 except rospy.ServiceException
as e:
305 rospy.logerr(
"Service Call Failed: %s"%e)
310 except rospy.ServiceException
as e:
311 rospy.logerr(
"Service Call Failed: %s"%e)
317 except rospy.ServiceException
as e:
318 rospy.logerr(
"Service Call Failed: %s"%e)
323 except rospy.ServiceException
as e:
324 rospy.logerr(
"Service Call Failed: %s"%e)
329 except rospy.ServiceException
as e:
330 rospy.logerr(
"Service Call Failed: %s"%e)
336 except rospy.ServiceException
as e:
337 rospy.logerr(
"Service Call Failed: %s"%e)
341 except rospy.ServiceException
as e:
342 rospy.logerr(
"Service Call Failed: %s"%e)
def __init__(self, parent)
def ResetCurrent(self, event)
def EnableCB0(self, event)
def chooseBoard(self, board)
def diagnostics_callback(self, message)
def DisableCB2(self, event)
def StandbyCB2(self, event)
def ResetCB0(self, event)
def ResetTransitions(self, event)
def ResetCB1(self, event)
def DisableCB0(self, event)
def EnableCB1(self, event)
def EnableCB2(self, event)
def StandbyCB1(self, event)
def ResetCB2(self, event)
def StandbyCB0(self, event)
def DisableCB1(self, event)
def addBoard(self, status)