Пример #1
0
    def __init__(self,
                 vehicle_event_dispatcher,
                 ui_event_dispatcher,
                 parent=None):
        super(MotorCommandController, self).__init__(parent)
        BasePanelController.__init__(self)
        self.ui = MotorCommandPanel()
        self.ui.setupUi(self)
        self.ui.sendButton.setEnabled(False)
        self.ui.clearButton.setEnabled(False)

        self.started = False

        # Connect GUI slots and signals
        self.ui.sendButton.clicked.connect(self.sendCommand)
        self.ui.clearButton.clicked.connect(self.clearCommand)
    def __init__(self, vehicle_event_dispatcher, ui_event_dispatcher, parent=None):
        super(MotorCommandController, self).__init__(parent)
        BasePanelController.__init__(self)
        self.ui = MotorCommandPanel()
        self.ui.setupUi(self)
        self.ui.sendButton.setEnabled(False)
        self.ui.clearButton.setEnabled(False)
       
        self.started = False


        # Connect GUI slots and signals
        self.ui.sendButton.clicked.connect(self.sendCommand)
        self.ui.clearButton.clicked.connect(self.clearCommand)
    def __init__(self, vehicle_model, message_sender, parent=None):
        super(MotorCommandController, self).__init__(parent)
        BasePanelController.__init__(self)
        
        self.vehicle_model = vehicle_model
        self.message_sender = message_sender
        
        self.started = False

        self.ui = MotorCommandPanel()
        self.ui.setupUi(self)
        self.ui.sendButton.setEnabled(False)
        self.ui.clearButton.setEnabled(False)

        # Connect GUI slots and signals
        self.ui.sendButton.clicked.connect(self.sendCommand)
        self.ui.clearButton.clicked.connect(self.clearCommand)
class MotorCommandController(QtGui.QWidget, BasePanelController):
    
    def __init__(self, vehicle_model, message_sender, parent=None):
        super(MotorCommandController, self).__init__(parent)
        BasePanelController.__init__(self)
        
        self.vehicle_model = vehicle_model
        self.message_sender = message_sender
        
        self.started = False

        self.ui = MotorCommandPanel()
        self.ui.setupUi(self)
        self.ui.sendButton.setEnabled(False)
        self.ui.clearButton.setEnabled(False)

        # Connect GUI slots and signals
        self.ui.sendButton.clicked.connect(self.sendCommand)
        self.ui.clearButton.clicked.connect(self.clearCommand)

    def start(self, xmlSubPanel, boardConfiguration):
        '''This method starts a timer used for any long running loops in a subpanel'''
        self.xmlSubPanel     = xmlSubPanel
        self.validateCommand = self.xml.find(self.xmlSubPanel + 'ValidateCommand').text
        self.command_motor   = self.xml.find(self.xmlSubPanel + 'CommandMotor').text
        self.boardConfiguration = boardConfiguration

        if self.comm.isConnected() == True:
            self.ui.sendButton.setEnabled(True)
            self.ui.clearButton.setEnabled(True)

            if not self.started:
                motor_count  = int(self.boardConfiguration['Motors'])
                motor_layout = self.ui.motor_slider_widget.layout()

                self.ui.motor_sliders = [MotorSlider(motor_number=(i + 1)) for i in xrange(motor_count)]
                for motor in self.ui.motor_sliders:
                    motor_layout.addWidget(motor)

                self.started = True

            self.timer = QtCore.QTimer()
            self.timer.timeout.connect(self.readContinuousData)
            self.timer.start(50)

    def sendCommand(self):
        serial_string   = self.validateCommand + ';' + ';'.join([
            str(float(motor_slider.slider.value()))
            for motor_slider in self.ui.motor_sliders
        ])
        self.comm.write(self.command_motor)
        self.comm.write(serial_string)
        sleep(0.150)

    def readContinuousData(self):
        isConnected = self.comm.isConnected()
        self.ui.sendButton.setEnabled(isConnected)
        self.ui.clearButton.setEnabled(isConnected)

    def clearCommand(self):
        serial_string   = self.validateCommand + ';' + ';'.join([
            '1000.0' for motor_slider in self.ui.motor_sliders
        ])
        self.comm.write(self.command_motor)
        self.comm.write(serial_string)
        for motor_slider in self.ui.motor_sliders:
            motor_slider.slider.setValue(1000)
        sleep(0.150)
Пример #5
0
class MotorCommandController(QtGui.QWidget, BasePanelController):
    def __init__(self,
                 vehicle_event_dispatcher,
                 ui_event_dispatcher,
                 parent=None):
        super(MotorCommandController, self).__init__(parent)
        BasePanelController.__init__(self)
        self.ui = MotorCommandPanel()
        self.ui.setupUi(self)
        self.ui.sendButton.setEnabled(False)
        self.ui.clearButton.setEnabled(False)

        self.started = False

        # Connect GUI slots and signals
        self.ui.sendButton.clicked.connect(self.sendCommand)
        self.ui.clearButton.clicked.connect(self.clearCommand)

    def start(self):
        '''This method starts a timer used for any long running loops in a subpanel'''
#        self.xmlSubPanel     = xmlSubPanel
#        self.validateCommand = self.xml.find(self.xmlSubPanel + 'ValidateCommand').text
#        self.command_motor   = self.xml.find(self.xmlSubPanel + 'CommandMotor').text
#        self.boardConfiguration = boardConfiguration
#
#        if self._communicator.isConnected() == True:
#            self.ui.sendButton.setEnabled(True)
#            self.ui.clearButton.setEnabled(True)
#
#            if not self.started:
#                motor_count  = int(self.boardConfiguration['Motors'])
#                motor_layout = self.ui.motor_slider_widget.layout()
#
#                self.ui.motor_sliders = [MotorSlider(motor_number=(i + 1)) for i in xrange(motor_count)]
#                for motor in self.ui.motor_sliders:
#                    motor_layout.addWidget(motor)
#
#                self.started = True
#
#            self.timer = QtCore.QTimer()
#            self.timer.timeout.connect(self.readContinuousData)
#            self.timer.start(50)

    def sendCommand(self):
        serial_string = self.validateCommand + ';' + ';'.join([
            str(float(motor_slider.slider.value()))
            for motor_slider in self.ui.motor_sliders
        ])
        self._communicator.write(self.command_motor)
        self._communicator.write(serial_string)
        sleep(0.150)

    def readContinuousData(self):
        isConnected = self._communicator.isConnected()
        self.ui.sendButton.setEnabled(isConnected)
        self.ui.clearButton.setEnabled(isConnected)

    def clearCommand(self):
        serial_string = self.validateCommand + ';' + ';'.join(
            ['1000.0' for motor_slider in self.ui.motor_sliders])
        self._communicator.write(self.command_motor)
        self._communicator.write(serial_string)
        for motor_slider in self.ui.motor_sliders:
            motor_slider.slider.setValue(1000)
        sleep(0.150)