コード例 #1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.ui = Ui_Dialog_encoder()
        self.ui.setupUi(self)

        try:
            self.linkbot = linkbot.CLinkbot('locl')
        except:
            QtGui.QMessageBox.warning(
                self, "Error",
                "Could not connect to Linkbot. Please make sure the Linkbot is "
                "plugged into the computer with a working Micro-USB cable.")
            raise

        for slider in (
                self.ui.verticalSlider_1,
                self.ui.verticalSlider_2,
                self.ui.verticalSlider_3,
        ):
            slider.setMaximum(360)

        # Connect button
        self.ui.pushButton.clicked.connect(self.close)

        # Connect encoder callbacks
        self.linkbot.enableEncoderEvents(self.encoderEvent)
        self.encoderSignal.connect(self.processEncoderEvent)
コード例 #2
0
class EncoderDialog(QtGui.QDialog):
    encoderSignal = QtCore.pyqtSignal(int, float, int)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.ui = Ui_Dialog_encoder()
        self.ui.setupUi(self)

        try:
            self.linkbot = linkbot.CLinkbot('locl')
        except:
            QtGui.QMessageBox.warning(
                self, "Error",
                "Could not connect to Linkbot. Please make sure the Linkbot is "
                "plugged into the computer with a working Micro-USB cable.")
            raise

        for slider in (
                self.ui.verticalSlider_1,
                self.ui.verticalSlider_2,
                self.ui.verticalSlider_3,
        ):
            slider.setMaximum(360)

        # Connect button
        self.ui.pushButton.clicked.connect(self.close)

        # Connect encoder callbacks
        self.linkbot.enableEncoderEvents(self.encoderEvent)
        self.encoderSignal.connect(self.processEncoderEvent)

    def __del__(self):
        self.linkbot.disableEncoderEvents()

    def encoderEvent(self, n, angle, timestamp):
        self.encoderSignal.emit(n, angle, timestamp)

    def processEncoderEvent(self, n, angle, timestamp):
        def normalizeAngle(theta):
            while theta > 360:
                theta -= 360
            while theta < 0:
                theta += 360
            return theta

        angle_ = angle
        angle = normalizeAngle(angle)
        if n == 0:
            self.ui.verticalSlider_1.setValue(angle)
            self.ui.label_1.setText('{0:.2f}'.format(angle_))
        elif n == 1:
            self.ui.verticalSlider_2.setValue(angle)
            self.ui.label_2.setText('{0:.2f}'.format(angle_))
        elif n == 2:
            self.ui.verticalSlider_3.setValue(angle)
            self.ui.label_3.setText('{0:.2f}'.format(angle_))

    def close(self):
        self.done(0)
コード例 #3
0
class EncoderDialog(QtGui.QDialog):
    encoderSignal = QtCore.pyqtSignal(int, float, int)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.ui = Ui_Dialog_encoder()
        self.ui.setupUi(self)
    
        try:
            self.linkbot = linkbot.CLinkbot('locl')
        except:
            QtGui.QMessageBox.warning(self, "Error",
                "Could not connect to Linkbot. Please make sure the Linkbot is "
                "plugged into the computer with a working Micro-USB cable." )
            raise 

        for slider in ( self.ui.verticalSlider_1,
                        self.ui.verticalSlider_2,
                        self.ui.verticalSlider_3, ):
            slider.setMaximum(360)

        # Connect button
        self.ui.pushButton.clicked.connect(self.close)

        # Connect encoder callbacks
        self.linkbot.enableEncoderEvents(self.encoderEvent)
        self.encoderSignal.connect(self.processEncoderEvent)

    def __del__(self):
        self.linkbot.disableEncoderEvents()

    def encoderEvent(self, n, angle, timestamp):
        self.encoderSignal.emit(n, angle, timestamp)

    def processEncoderEvent(self, n, angle, timestamp):
        def normalizeAngle(theta):
            while theta > 360:
                theta -= 360
            while theta < 0:
                theta += 360
            return theta
        angle_ = angle
        angle = normalizeAngle(angle)
        if n == 0:
            self.ui.verticalSlider_1.setValue(angle)
            self.ui.label_1.setText('{0:.2f}'.format(angle_))
        elif n == 1:
            self.ui.verticalSlider_2.setValue(angle)
            self.ui.label_2.setText('{0:.2f}'.format(angle_))
        elif n == 2:
            self.ui.verticalSlider_3.setValue(angle)
            self.ui.label_3.setText('{0:.2f}'.format(angle_))

    def close(self):
        self.done(0)
コード例 #4
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.ui = Ui_Dialog_encoder()
        self.ui.setupUi(self)
    
        try:
            self.linkbot = linkbot.CLinkbot('locl')
        except:
            QtGui.QMessageBox.warning(self, "Error",
                "Could not connect to Linkbot. Please make sure the Linkbot is "
                "plugged into the computer with a working Micro-USB cable." )
            raise 

        for slider in ( self.ui.verticalSlider_1,
                        self.ui.verticalSlider_2,
                        self.ui.verticalSlider_3, ):
            slider.setMaximum(360)

        # Connect button
        self.ui.pushButton.clicked.connect(self.close)

        # Connect encoder callbacks
        self.linkbot.enableEncoderEvents(self.encoderEvent)
        self.encoderSignal.connect(self.processEncoderEvent)