Пример #1
0
 def buttonConnectRealOnButtonClick(self, event):
     serialname = self.comboSerialPorts.GetValue()
     if self.buttonConnectReal.GetLabel() == "connect":
         FanbotConfig.setSerialport(serialname)
         try:
             factory = ParserFactory()  # Parser factory can create a parser object
             self.serial = FanbotSerial(factory)
             self.serial.open(serialname, FanbotConfig.baudrate)
             self.remote.setTransport(self.serial)
             self.buttonConnectReal.SetLabel("disconnect")
             FanbotConfig.setSerialport(serialname)
         except SerialException as e:
             print "Unable to open serial port ...error:", e.message
             dlg = wx.MessageDialog(
                 self,
                 e.message + " Select another port. or exit program with <Cancel>!",
                 "Unable to open serial port %s" % serialname,
                 wx.OK | wx.CANCEL | wx.ICON_QUESTION,
             )
             result = dlg.ShowModal()
             dlg.Destroy()
             if wx.ID_OK != result:
                 exit(1)
     else:
         self.serial.close()
         self.serial = None
         self.remote.setTransport(None)
         self.buttonConnectReal.SetLabel("connect")
         print "now disconnected"
Пример #2
0
    def buttonSaveOnButtonClick(self, event):
        host = self.textSimulation.GetValue()
        FanbotConfig.setSimulationIP(host)

        port = self.textPort.GetValue()
        FanbotConfig.setSimulationIPPort(port)

        proxy = self.textProxyPort.GetValue()
        FanbotConfig.setProxyPort(proxy)

        serialname = self.comboSerialPorts.GetValue()
        FanbotConfig.setSerialport(serialname)
        FanbotConfig.save()