class DiagnosticsFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
                          wx.Size(400, 600))
        wx.Frame.Hide(self)

        self.Bind(wx.EVT_CLOSE, self.on_close)

        self._diagnostics_panel = None
        self._is_stale = True
        self._top_level_state = -1

        self._diagnostics_toplevel_state_sub = rospy.Subscriber(
            'diagnostics_toplevel_state', DiagnosticStatus,
            self.dashboard_callback)
        self._stall_timer = None

    def on_close(self, evt):
        self.Hide()

    def Show(self):
        self._diagnostics_panel = RobotMonitorPanel(self)
        self._diagnostics_panel.SetSize(self.GetClientSize())
        wx.Frame.Show(self)

    def Hide(self):
        wx.Frame.Hide(self)
        if self._diagnostics_panel is not None:
            self._diagnostics_panel.Close()
            self._diagnostics_panel.Destroy()
            self._diagnostics_panel = None

    def dashboard_callback(self, msg):
        self._is_stale = False
        if self._stall_timer is not None:
            self._stall_timer.cancel()
        # timer to mark stalled when not receiving messages for some time
        self._stall_timer = threading.Timer(10, self._stalled)

        self._top_level_state = msg.level

    def _stalled(self, event):
        self._stall_timer = None
        self._is_stale = True

    def get_top_level_state(self):
        if (self._is_stale):
            return 3

        return self._top_level_state
Пример #2
0
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
                          wx.Size(600, 200))

        self.Bind(wx.EVT_CLOSE, self.on_close)

        self._diagnostics_panel = RobotMonitorPanel(self)
Пример #3
0
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, wx.ID_ANY, title)

        self._sizer = wx.BoxSizer(wx.VERTICAL)
        self._panel = RobotMonitorPanel(self)
        self._sizer.Add(self._panel, 1, wx.EXPAND)
        self.SetSizer(self._sizer)

        self._shutdown_timer = wx.Timer()
        self._shutdown_timer.Bind(wx.EVT_TIMER, self._on_shutdown_timer)
        self._shutdown_timer.Start(100)
 def Show(self):
     self._diagnostics_panel = RobotMonitorPanel(self)
     self._diagnostics_panel.SetSize(self.GetClientSize())
     wx.Frame.Show(self)
Пример #5
0
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, wx.ID_ANY, title)

        self.panel = RobotMonitorPanel(self)