Exemplo n.º 1
0
 def __set_properties(self):
     # begin wxGlade: Controller.__set_properties
     self.SetTitle(_("TCP-Controller"))
     _icon = wx.NullIcon
     _icon.CopyFromBitmap(icons8_connected_50.GetBitmap())
     self.SetIcon(_icon)
     self.button_device_connect.SetBackgroundColour(wx.Colour(
         102, 255, 102))
     self.button_device_connect.SetForegroundColour(wx.BLACK)
     self.button_device_connect.SetFont(
         wx.Font(
             12,
             wx.FONTFAMILY_DEFAULT,
             wx.FONTSTYLE_NORMAL,
             wx.FONTWEIGHT_NORMAL,
             0,
             "Segoe UI",
         ))
     self.button_device_connect.SetToolTip(
         _("Force connection/disconnection from the device."))
     self.button_device_connect.SetBitmap(
         icons8_disconnected_50.GetBitmap(use_theme=False))
     self.text_status.SetToolTip(_("Connection status"))
     self.text_ip_host.SetToolTip(_("IP/Host if the server computer"))
     self.text_port.SetToolTip(
         _("Port for tcp connection on the server computer"))
     self.text_buffer_length.SetMinSize((165, 23))
     self.text_buffer_length.SetToolTip(
         _("Current number of bytes in the write buffer."))
     self.text_buffer_max.SetMinSize((165, 23))
     self.text_buffer_max.SetToolTip(
         _("Current number of bytes in the write buffer."))
Exemplo n.º 2
0
 def __init__(self, *args, **kwds):
     super().__init__(499, 170, *args, **kwds)
     self.panel = BalorControllerPanel(self,
                                       wx.ID_ANY,
                                       context=self.context)
     self.add_module_delegate(self.panel)
     self.SetTitle(_("Balor-Controller"))
     _icon = wx.NullIcon
     _icon.CopyFromBitmap(icons8_connected_50.GetBitmap())
     self.SetIcon(_icon)
     self.Layout()
Exemplo n.º 3
0
    def __init__(self, *args, **kwds):
        super().__init__(499, 357, *args, **kwds)
        self.service = self.context.device
        self.SetTitle("SerialController")
        _icon = wx.NullIcon
        _icon.CopyFromBitmap(icons8_connected_50.GetBitmap())
        self.SetIcon(_icon)

        self.serial_panel = SerialControllerPanel(self,
                                                  wx.ID_ANY,
                                                  context=self.service)
        self.Layout()
Exemplo n.º 4
0
 def on_connection_state_change(self, origin, state):
     if state == "STATE_CONNECTION_FAILED" or state == "STATE_DRIVER_NO_BACKEND":
         self.button_device_connect.SetBackgroundColour("#dfdf00")
         origin, usb_status = self.context.last_signal("pipe;usb_status")
         if usb_status is not None:
             self.button_device_connect.SetLabel(str(usb_status[0]))
         self.button_device_connect.SetBitmap(
             icons8_disconnected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Enable()
     elif state == "STATE_UNINITIALIZED" or state == "STATE_USB_DISCONNECTED":
         self.button_device_connect.SetBackgroundColour("#ffff00")
         self.button_device_connect.SetLabel(_("Connect"))
         self.button_device_connect.SetBitmap(
             icons8_connected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Enable()
     elif state == "STATE_USB_SET_DISCONNECTING":
         self.button_device_connect.SetBackgroundColour("#ffff00")
         self.button_device_connect.SetLabel(_("Disconnecting..."))
         self.button_device_connect.SetBitmap(
             icons8_disconnected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Disable()
     elif state == "STATE_USB_CONNECTED" or state == "STATE_CONNECTED":
         self.button_device_connect.SetBackgroundColour("#00ff00")
         self.button_device_connect.SetLabel(_("Disconnect"))
         self.button_device_connect.SetBitmap(
             icons8_connected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Enable()
     elif state == "STATE_CONNECTING":
         self.button_device_connect.SetBackgroundColour("#ffff00")
         self.button_device_connect.SetLabel(_("Connecting..."))
         self.button_device_connect.SetBitmap(
             icons8_connected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Disable()
Exemplo n.º 5
0
 def on_serial_status(self, origin, state):
     self.state = state
     if state == "uninitialized" or state == "disconnected":
         self.button_device_connect.SetBackgroundColour("#ffff00")
         self.button_device_connect.SetLabel(_("Connect"))
         self.button_device_connect.SetBitmap(
             icons8_disconnected_50.GetBitmap(use_theme=False))
         self.button_device_connect.Enable()
     elif state == "connected":
         self.button_device_connect.SetBackgroundColour("#00ff00")
         self.button_device_connect.SetLabel(_("Disconnect"))
         self.button_device_connect.SetBitmap(
             icons8_connected_50.GetBitmap(use_theme=False))
         self.button_device_connect.Enable()
Exemplo n.º 6
0
    def __init__(self, *args, context=None, **kwds):
        # begin wxGlade: SerialControllerPanel.__init__
        self.service = context
        kwds["style"] = kwds.get("style", 0)
        wx.Panel.__init__(self, *args, **kwds)
        sizer_1 = wx.BoxSizer(wx.VERTICAL)

        self.state = None
        self.button_device_connect = wx.Button(self, wx.ID_ANY, "Connection")
        self.button_device_connect.SetBackgroundColour(wx.Colour(
            102, 255, 102))
        self.button_device_connect.SetFont(
            wx.Font(
                12,
                wx.FONTFAMILY_DEFAULT,
                wx.FONTSTYLE_NORMAL,
                wx.FONTWEIGHT_NORMAL,
                0,
                "Segoe UI",
            ))
        self.button_device_connect.SetToolTip(
            "Force connection/disconnection from the device.")
        self.button_device_connect.SetBitmap(
            icons8_connected_50.GetBitmap(use_theme=False))
        sizer_1.Add(self.button_device_connect, 0, wx.EXPAND, 0)

        static_line_2 = wx.StaticLine(self, wx.ID_ANY)
        static_line_2.SetMinSize((483, 5))
        sizer_1.Add(static_line_2, 0, wx.EXPAND, 0)

        self.data_exchange = wx.TextCtrl(self,
                                         wx.ID_ANY,
                                         "",
                                         style=wx.TE_MULTILINE)
        sizer_1.Add(self.data_exchange, 1, wx.EXPAND, 0)

        self.gcode_text = wx.TextCtrl(self,
                                      wx.ID_ANY,
                                      "",
                                      style=wx.TE_PROCESS_ENTER)
        self.gcode_text.SetFocus()
        sizer_1.Add(self.gcode_text, 0, wx.EXPAND, 0)

        self.SetSizer(sizer_1)

        self.Layout()

        self.Bind(wx.EVT_BUTTON, self.on_button_start_connection,
                  self.button_device_connect)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_gcode_enter, self.gcode_text)
Exemplo n.º 7
0
    def __init__(self, *args, **kwds):
        super().__init__(_advanced_width, _default_height, *args, **kwds)

        # ==========
        # MENU BAR
        # ==========
        from platform import system as _sys

        if _sys() != "Darwin":
            self.MoshiController_menubar = wx.MenuBar()
            self.create_menu(self.MoshiController_menubar.Append)
            self.SetMenuBar(self.MoshiController_menubar)
        # ==========
        # MENUBAR END
        # ==========

        self.panel = MoshiControllerPanel(self, wx.ID_ANY, context=self.context)
        self.add_module_delegate(self.panel)
        _icon = wx.NullIcon
        _icon.CopyFromBitmap(icons8_connected_50.GetBitmap())
        self.SetIcon(_icon)
        self.SetTitle(_("Moshiboard-Controller"))
Exemplo n.º 8
0
 def on_connection_state_change(self, origin, state):
     if origin != self.context._path:
         return
     if state == "STATE_CONNECTION_FAILED":
         self.button_device_connect.SetBackgroundColour("#dfdf00")
         origin, usb_status = self.context.last_signal("pipe;usb_status")
         self.button_device_connect.SetLabel(_("Connect Failed"))
         self.button_device_connect.SetBitmap(
             icons8_disconnected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Enable()
     elif state == "STATE_FAILED_RETRYING":
         self.button_device_connect.SetBackgroundColour("#df0000")
         origin, usb_status = self.context.last_signal("pipe;usb_status")
         self.button_device_connect.SetLabel(_("Retrying..."))
         self.button_device_connect.SetBitmap(
             icons8_disconnected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Enable()
     elif state == "STATE_FAILED_SUSPENDED":
         self.button_device_connect.SetBackgroundColour("#0000df")
         origin, usb_status = self.context.last_signal("pipe;usb_status")
         self.button_device_connect.SetLabel(_("Suspended Retrying"))
         self.button_device_connect.SetBitmap(
             icons8_disconnected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Enable()
     elif state == "STATE_DRIVER_NO_BACKEND":
         self.button_device_connect.SetBackgroundColour("#dfdf00")
         origin, usb_status = self.context.last_signal("pipe;usb_status")
         self.button_device_connect.SetLabel(_("No Backend"))
         self.button_device_connect.SetBitmap(
             icons8_disconnected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Enable()
     elif state == "STATE_UNINITIALIZED" or state == "STATE_USB_DISCONNECTED":
         self.button_device_connect.SetBackgroundColour("#ffff00")
         self.button_device_connect.SetLabel(_("Connect"))
         self.button_device_connect.SetBitmap(
             icons8_connected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Enable()
     elif state == "STATE_USB_SET_DISCONNECTING":
         self.button_device_connect.SetBackgroundColour("#ffff00")
         self.button_device_connect.SetLabel(_("Disconnecting..."))
         self.button_device_connect.SetBitmap(
             icons8_disconnected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Disable()
     elif state == "STATE_USB_CONNECTED" or state == "STATE_CONNECTED":
         self.button_device_connect.SetBackgroundColour("#00ff00")
         self.button_device_connect.SetLabel(_("Disconnect"))
         self.button_device_connect.SetBitmap(
             icons8_connected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Enable()
     elif state == "STATE_CONNECTING":
         self.button_device_connect.SetBackgroundColour("#ffff00")
         self.button_device_connect.SetLabel(_("Connecting..."))
         self.button_device_connect.SetBitmap(
             icons8_connected_50.GetBitmap(use_theme=False)
         )
         self.button_device_connect.Disable()
Exemplo n.º 9
0
    def __init__(self,
                 *args,
                 context=None,
                 gui=None,
                 index: int = 0,
                 pane=False,
                 **kwds):
        kwds["style"] = kwds.get("style", 0) | wx.TAB_TRAVERSAL
        wx.Panel.__init__(self, *args, **kwds)
        self.gui = gui
        self.context = context
        self.index = index
        self.pane = pane

        if pane:
            job_name = "CamPane%d" % self.index
        else:
            job_name = "Camera%d" % self.index
        Job.__init__(self, job_name=job_name)
        self.process = self.update_camera_frame
        self.run_main = True

        self.context("camera%d\n" %
                     self.index)  # command activates Camera service
        self.camera = self.context.get_context(f"camera/{self.index}")
        # camera service location.
        self.last_frame_index = -1

        if not pane:
            self.button_update = wx.BitmapButton(self, wx.ID_ANY,
                                                 icons8_camera_50.GetBitmap())
            self.button_export = wx.BitmapButton(
                self, wx.ID_ANY,
                icons8_picture_in_picture_alternative_50.GetBitmap())
            self.button_reconnect = wx.BitmapButton(
                self, wx.ID_ANY, icons8_connected_50.GetBitmap())
            self.check_fisheye = wx.CheckBox(self, wx.ID_ANY,
                                             _("Correct Fisheye"))
            self.check_perspective = wx.CheckBox(self, wx.ID_ANY,
                                                 _("Correct Perspective"))
            self.slider_fps = wx.Slider(
                self,
                wx.ID_ANY,
                24,
                0,
                60,
                style=wx.SL_AUTOTICKS | wx.SL_HORIZONTAL | wx.SL_LABELS,
            )
            self.button_detect = wx.BitmapButton(
                self, wx.ID_ANY, icons8_detective_50.GetBitmap())
            scene_name = "Camera%s" % self.index
        else:
            scene_name = "CamPaneScene%s" % self.index

        self.display_camera = ScenePanel(
            self.camera,
            self,
            scene_name=scene_name,
            style=wx.EXPAND | wx.WANTS_CHARS,
        )
        self.widget_scene = self.display_camera.scene

        # end wxGlade
        sizer_main = wx.BoxSizer(wx.VERTICAL)
        if not pane:
            self.button_update.SetToolTip(_("Update Image"))
            self.button_update.SetSize(self.button_update.GetBestSize())
            self.button_export.SetToolTip(_("Export Snapshot"))
            self.button_export.SetSize(self.button_export.GetBestSize())
            self.button_reconnect.SetToolTip(_("Reconnect Camera"))
            self.button_reconnect.SetSize(self.button_reconnect.GetBestSize())
            self.button_detect.SetToolTip(_("Detect Distortions/Calibration"))
            self.button_detect.SetSize(self.button_detect.GetBestSize())
            sizer_controls = wx.BoxSizer(wx.HORIZONTAL)
            sizer_checkboxes = wx.BoxSizer(wx.VERTICAL)
            sizer_controls.Add(self.button_update, 0, 0, 0)
            sizer_controls.Add(self.button_export, 0, 0, 0)
            sizer_controls.Add(self.button_reconnect, 0, 0, 0)
            sizer_checkboxes.Add(self.check_fisheye, 0, 0, 0)
            sizer_checkboxes.Add(self.check_perspective, 0, 0, 0)
            sizer_controls.Add(sizer_checkboxes, 1, wx.EXPAND, 0)
            sizer_controls.Add(self.slider_fps, 1, wx.EXPAND, 0)
            sizer_controls.Add(self.button_detect, 0, 0, 0)
            sizer_main.Add(sizer_controls, 1, wx.EXPAND, 0)
            self.Bind(wx.EVT_BUTTON, self.on_button_update, self.button_update)
            self.Bind(wx.EVT_BUTTON, self.on_button_export, self.button_export)
            self.Bind(wx.EVT_BUTTON, self.on_button_reconnect,
                      self.button_reconnect)
            self.Bind(wx.EVT_CHECKBOX, self.on_check_fisheye,
                      self.check_fisheye)
            self.Bind(wx.EVT_CHECKBOX, self.on_check_perspective,
                      self.check_perspective)
            self.Bind(wx.EVT_SLIDER, self.on_slider_fps, self.slider_fps)
            self.Bind(wx.EVT_BUTTON, self.on_button_detect, self.button_detect)
        sizer_main.Add(self.display_camera, 10, wx.EXPAND, 0)
        self.SetSizer(sizer_main)
        self.Layout()

        self.image_width = -1
        self.image_height = -1
        self.frame_bitmap = None

        self.SetDoubleBuffered(True)
        # end wxGlade

        if not pane:
            self.check_fisheye.SetValue(self.camera.correction_fisheye)
            self.check_perspective.SetValue(self.camera.correction_perspective)
            self.slider_fps.SetValue(self.camera.fps)

        self.on_fps_change(None)

        self.widget_scene.widget_root.set_aspect(self.camera.aspect)

        self.widget_scene.background_brush = wx.Brush(wx.WHITE)
        self.widget_scene.add_scenewidget(
            CamSceneWidget(self.widget_scene, self))
        self.widget_scene.add_scenewidget(
            CamImageWidget(self.widget_scene, self))
        self.widget_scene.add_interfacewidget(
            CamInterfaceWidget(self.widget_scene, self))
Exemplo n.º 10
0
 def set_button_connected(self):
     self.button_device_connect.SetBackgroundColour("#00ff00")
     self.button_device_connect.SetBitmap(
         icons8_connected_50.GetBitmap(use_theme=False))
     self.button_device_connect.Enable()