Ejemplo n.º 1
0
    def buttonConnectSimulOnButtonClick(self, event):
        host = self.textSimulation.GetValue()
        FanbotConfig.setSimulationIP(host)
        port = self.textPort.GetValue()
        FanbotConfig.setSimulationIPPort(port)

        if self.buttonConnectSimul.GetLabel() == "connect":
            try:
                factory = ParserFactory()  # Parser factory can create a parser object
                self.socket = FanbotSocket(factory)
                self.socket.openSocket(host, int(port))
                self.remote.setTransport(self.socket)
                self.buttonConnectSimul.SetLabel("disconnect")
                print "now connected"
            except Exception as e:
                dlg = wx.MessageDialog(
                    self,
                    "Select another port. or exit program with <Cancel>!",
                    "Unable to open connection to simulator at %s:%s" % (host, port),
                    wx.OK | wx.CANCEL | wx.ICON_QUESTION,
                )

                result = dlg.ShowModal()
                dlg.Destroy()
                if wx.ID_OK != result:
                    exit(1)

        else:
            self.socket.closeSocket()
            self.socket = None
            self.remote.setTransport(None)
            self.buttonConnectSimul.SetLabel("connect")
            print "now disconnected"
Ejemplo n.º 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()