Esempio n. 1
0
    def __init__(self, parent, title, controller, server_name, rpc_port, camera_port):
        self.controller = controller
        self._server_name = server_name
        self._rpc_port = rpc_port
        self._camera_port = camera_port
        
        wx.Frame.__init__(self, parent, title=title, size=(1024, 800))
        
        #build ui
        self.panel = wx.Panel(self)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer_view = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer_control = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.sizer_view, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 4)
        self.sizer.Add(self.sizer_control, 1, wx.EXPAND | wx.ALL, 4)
            
        # map frame
        self.map_frame = MapPanel(self.panel, controller)
        self.sizer_view.Add(self.map_frame, 3, wx.EXPAND | wx.RIGHT, 4)
        
        # camera frame
        cam_enabled = self.controller.model.capture_img_enabled
        self.camera_frame = CameraPanel(self.panel, server_name, camera_port, cam_enabled)
        self.sizer_view.Add(self.camera_frame, 1, wx.EXPAND)
        self.camera_update_count = 0
        
        # waypoint frame
        self.waypoint_frame = WayPointPanel(self.panel)
        self.sizer_control.Add(self.waypoint_frame, 1, wx.EXPAND | wx.RIGHT, 4)
            
        # display frame
        self.display_frame = DisplayPanel(self.panel, controller)
        self.sizer_control.Add(self.display_frame, 1, wx.EXPAND | wx.RIGHT, 4)
            
        # auto pilot frame
        self.autopilot_frame = AutoPilotPanel(self.panel, controller)
        self.sizer_control.Add(self.autopilot_frame, 1, wx.EXPAND | wx.RIGHT, 4)
            
        # manual pilot frame
        self.manualpilot_frame = ManualPilotPanel(self.panel, controller)
        self.sizer_control.Add(self.manualpilot_frame, 1, wx.EXPAND)
            
        self.CreateStatusBar()

        self.panel.SetSizerAndFit(self.sizer)
    
        # bind events
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        # setup callback timer
        interval_time = 250
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.timer.Start(interval_time, False)
    def __init__(self, parent, title, server, rpc_port, camera_port):
        self._server = server
        self._rpc_port = rpc_port
        self._camera_port = camera_port
        self.rpc_client = None
        
        wx.Frame.__init__(self, parent, title=title, size=(1024, 800))
        
        #build ui
        self.panel = wx.Panel(self)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer_view = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer_control = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.sizer_view, 0, wx.EXPAND)
        self.sizer.Add(self.sizer_control, 0, wx.EXPAND)
            
        # map frame
        self.map_frame = MapPanel(self.panel)
        self.sizer_view.Add(self.map_frame, 3, wx.EXPAND)
        
        # camera frame
        self.camera_frame = CameraPanel(self.panel, server, camera_port, True)
        self.sizer_view.Add(self.camera_frame, 1, wx.EXPAND)
        
        # waypoint frame
        self.waypoint_frame = WayPointPanel(self.panel)
        self.sizer_control.Add(self.waypoint_frame, 1, wx.EXPAND)
            
        # display frame
        self.display_frame = DisplayPanel(self.panel, self)
        self.sizer_control.Add(self.display_frame, 1, wx.EXPAND)
            
        # auto pilot frame
        self.autopilot_frame = AutoPilotPanel(self.panel, self)
        self.sizer_control.Add(self.autopilot_frame, 1, wx.EXPAND)
            
        # manual pilot frame
        self.manualpilot_frame = ManualPilotPanel(self.panel)
        self.sizer_control.Add(self.manualpilot_frame, 1, wx.EXPAND)
            
        self.CreateStatusBar()

        self.panel.SetSizerAndFit(self.sizer)
        #self.Fit()
    
        # bind events
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        # setup callback timer
        interval_time = 250
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.timer.Start(interval_time, False)
class MainWindow(wx.Frame):

    def __init__(self, parent, title, server, rpc_port, camera_port):
        self._server = server
        self._rpc_port = rpc_port
        self._camera_port = camera_port
        self.rpc_client = None
        
        wx.Frame.__init__(self, parent, title=title, size=(1024, 800))
        
        #build ui
        self.panel = wx.Panel(self)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer_view = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer_control = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.sizer_view, 0, wx.EXPAND)
        self.sizer.Add(self.sizer_control, 0, wx.EXPAND)
            
        # map frame
        self.map_frame = MapPanel(self.panel)
        self.sizer_view.Add(self.map_frame, 3, wx.EXPAND)
        
        # camera frame
        self.camera_frame = CameraPanel(self.panel, server, camera_port, True)
        self.sizer_view.Add(self.camera_frame, 1, wx.EXPAND)
        
        # waypoint frame
        self.waypoint_frame = WayPointPanel(self.panel)
        self.sizer_control.Add(self.waypoint_frame, 1, wx.EXPAND)
            
        # display frame
        self.display_frame = DisplayPanel(self.panel, self)
        self.sizer_control.Add(self.display_frame, 1, wx.EXPAND)
            
        # auto pilot frame
        self.autopilot_frame = AutoPilotPanel(self.panel, self)
        self.sizer_control.Add(self.autopilot_frame, 1, wx.EXPAND)
            
        # manual pilot frame
        self.manualpilot_frame = ManualPilotPanel(self.panel)
        self.sizer_control.Add(self.manualpilot_frame, 1, wx.EXPAND)
            
        self.CreateStatusBar()

        self.panel.SetSizerAndFit(self.sizer)
        #self.Fit()
    
        # bind events
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        # setup callback timer
        interval_time = 250
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.timer.Start(interval_time, False)

    def on_timer(self, event):
        self.update()
    
    def OnClose(self, event):
        logging.debug("UI:\tMain window closing.")
        if self.rpc_client:
            self.rpc_client.close_connection()

    def update(self):
        self.display_frame.update()
        self.camera_frame.update()

    @property
    def server(self):
        """ Server address for remote device. """
        return self._server
    
    @property
    def rpc_port(self):
        """ Port for RPC. """
        return self._rpc_port
    
    @property
    def camera_port(self):
        """ Port for camera stream. """
        return self._camera_port
Esempio n. 4
0
class MainWindow(wx.Frame):

    def __init__(self, parent, title, controller, server_name, rpc_port, camera_port):
        self.controller = controller
        self._server_name = server_name
        self._rpc_port = rpc_port
        self._camera_port = camera_port
        
        wx.Frame.__init__(self, parent, title=title, size=(1024, 800))
        
        #build ui
        self.panel = wx.Panel(self)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer_view = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer_control = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.sizer_view, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 4)
        self.sizer.Add(self.sizer_control, 1, wx.EXPAND | wx.ALL, 4)
            
        # map frame
        self.map_frame = MapPanel(self.panel, controller)
        self.sizer_view.Add(self.map_frame, 3, wx.EXPAND | wx.RIGHT, 4)
        
        # camera frame
        cam_enabled = self.controller.model.capture_img_enabled
        self.camera_frame = CameraPanel(self.panel, server_name, camera_port, cam_enabled)
        self.sizer_view.Add(self.camera_frame, 1, wx.EXPAND)
        self.camera_update_count = 0
        
        # waypoint frame
        self.waypoint_frame = WayPointPanel(self.panel)
        self.sizer_control.Add(self.waypoint_frame, 1, wx.EXPAND | wx.RIGHT, 4)
            
        # display frame
        self.display_frame = DisplayPanel(self.panel, controller)
        self.sizer_control.Add(self.display_frame, 1, wx.EXPAND | wx.RIGHT, 4)
            
        # auto pilot frame
        self.autopilot_frame = AutoPilotPanel(self.panel, controller)
        self.sizer_control.Add(self.autopilot_frame, 1, wx.EXPAND | wx.RIGHT, 4)
            
        # manual pilot frame
        self.manualpilot_frame = ManualPilotPanel(self.panel, controller)
        self.sizer_control.Add(self.manualpilot_frame, 1, wx.EXPAND)
            
        self.CreateStatusBar()

        self.panel.SetSizerAndFit(self.sizer)
    
        # bind events
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        # setup callback timer
        interval_time = 250
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.timer.Start(interval_time, False)

    def on_timer(self, event):
        self.update()
    
    def OnClose(self, event):
        logging.debug("UI:\tMain window closing.")
        if self.controller:
            self.controller.close_connection()
        #self.Close(True)

    def update(self):
        """ Callback to perform updates etc. """
        logging.debug("UI:\tIn update...")
        # update controller
        self.controller.update()
        # update screens
        self.display_frame.update()
        # update camera less frequently
        if self.camera_update_count > 200:
            self.camera_frame.update()
            self.camera_update_count = 0
        else:
            self.camera_update_count += 1

    @property
    def server(self):
        """ Server address for remote device. """
        return self._server
    
    @property
    def rpc_port(self):
        """ Port for RPC. """
        return self._rpc_port
    
    @property
    def camera_port(self):
        """ Port for camera stream. """
        return self._camera_port