def getMotorDriver(self):
        #self.comboBox_driver.currentIndexChanged.disconnect()
        dat = self.main.serialGet("drvtype!\n")
        self.comboBox_driver.clear()
        self.drvIds, self.drvClasses = classlistToIds(dat)
        id = self.main.serialGet("drvtype?\n")
        if (id == None):
            self.main.log("Error getting driver")
            return
        self.drvId = int(id)
        for c in self.drvClasses:
            self.comboBox_driver.addItem(c[1])

        if (self.drvId in self.drvIds and self.comboBox_driver.currentIndex()
                != self.drvIds[self.drvId][0]):
            self.comboBox_driver.setCurrentIndex(self.drvIds[self.drvId][0])
        # else:
        #     self.comboBox_driver.setCurrentIndex(0)
        #self.comboBox_driver.currentIndexChanged.connect(self.driverChanged)
        # TMC

        if (self.drvId == 1):
            if not self.main.hasTab("TMC4671"):
                tmc = tmc4671_ui.TMC4671Ui(self.main)
                if (tmc.initUi()):
                    tabId = self.main.addTab(tmc, "TMC4671")
                    if (int(self.main.serialGet("mtype\n")) == 0):
                        self.main.selectTab(tabId)
                        msg = QMessageBox(
                            QMessageBox.Information, "TMC4671",
                            "Please setup the motor driver first!")
                        msg.exec_()
Exemple #2
0
        def drvtypecb(dat):
            l, i = dat
            self.drvIds, self.drvClasses = classlistToIds(l)
            self.drvId = int(i)

            if (i == None):
                self.main.log("Error getting driver")
                return

            updateClassComboBox(self.comboBox_driver, self.drvIds,
                                self.drvClasses, self.drvId)

            self.updateSliders()
 def updateMains(dat):
     self.comboBox_main.clear()
     self.classIds,self.classes = classlistToIds(dat)
     
     if(self.mainID == None):
         #self.main.resetPort()
         self.groupBox_system.setEnabled(False)
         return
     self.groupBox_system.setEnabled(True)
     for c in self.classes:
         self.comboBox_main.addItem(c[1])
     self.comboBox_main.setCurrentIndex(self.classIds[self.mainID][0])
     self.main.log("Detected mode: "+self.comboBox_main.currentText())
     self.main.updateTabs()
        def updateMains(dat):
            self.comboBox_main.clear()
            self.classIds, self.classes = classlistToIds(dat)

            if (self.mainID == None):
                #self.main.resetPort()
                self.groupBox_system.setEnabled(False)
                return
            self.groupBox_system.setEnabled(True)

            updateClassComboBox(self.comboBox_main, self.classIds,
                                self.classes, self.mainID)

            self.main.log("Detected mode: " + self.comboBox_main.currentText())
            self.main.updateTabs()
        def drvtypecb(dat):
            l, i = dat
            self.comboBox_driver.clear()
            self.drvIds, self.drvClasses = classlistToIds(l)
            if (i == None):
                self.main.log("Error getting driver")
                return
            self.drvId = int(i)
            for c in self.drvClasses:
                self.comboBox_driver.addItem(c[1])

            if (self.drvId in self.drvIds
                    and self.comboBox_driver.currentIndex() !=
                    self.drvIds[self.drvId][0]):
                self.comboBox_driver.setCurrentIndex(
                    self.drvIds[self.drvId][0])
Exemple #6
0
        def f(dat):
            self.comboBox_encoder.clear()
            self.encWidgets.clear()

            self.encIds, self.encClasses = classlistToIds(dat)
            for c in self.encClasses:
                self.comboBox_encoder.addItem(c[1], c[0])
                id = c[0]
                creatable = c[2]
                self.comboBox_encoder.model().item(
                    self.encIds[c[0]][0]).setEnabled(creatable)

                if (id not in self.encWidgets
                        or self.stackedWidget_encoder.indexOf(
                            self.encWidgets[id]) == -1):
                    self.encWidgets[id] = EncoderOptions(self.main, id)
                    self.stackedWidget_encoder.addWidget(self.encWidgets[id])
    def getMainClasses(self):
        dat = self.main.serialGet("lsmain\n")
        self.comboBox_main.clear()
        self.classIds, self.classes = classlistToIds(dat)
        id = self.main.serialGet("id?\n")
        if (id == None):
            #self.main.resetPort()
            self.setEnabled(False)
            return

        self.setEnabled(True)
        id = int(id)

        for c in self.classes:
            self.comboBox_main.addItem(c[1])
        self.comboBox_main.setCurrentIndex(self.classIds[id][0])
        self.main.log("Detected mode: " + self.comboBox_main.currentText())
        self.main.chooseMain(id)
Exemple #8
0
        def cb_axisSources(dat):
            btns = dat[0]
            types = int(dat[1])

            self.axisIds, self.axisClasses = classlistToIds(btns)
            if (types == None):
                self.main.log("Error getting buttons")
                return
            types = int(types)
            layout = QGridLayout()
            #clear
            for b in self.axisconfbuttons:
                del b
            for b in self.axisbtns.buttons():
                self.axisbtns.removeButton(b)
                del b
            #add buttons
            row = 0
            for c in self.axisClasses:
                creatable = c[2]
                btn = QCheckBox(str(c[1]), self.groupBox_buttons)
                self.axisbtns.addButton(btn, c[0])
                layout.addWidget(btn, row, 0)
                enabled = types & (1 << c[0]) != 0
                btn.setChecked(enabled)

                confbutton = QToolButton(self)
                confbutton.setText(">")
                layout.addWidget(confbutton, row, 1)
                self.axisconfbuttons.append(
                    (confbutton,
                     analogconf_ui.AnalogOptionsDialog(str(c[1]), c[0],
                                                       self.main)))
                confbutton.clicked.connect(self.axisconfbuttons[row][1].exec)
                confbutton.setEnabled(enabled)
                self.axisbtns.button(c[0]).stateChanged.connect(
                    confbutton.setEnabled)
                row += 1

                confbutton.setEnabled(creatable or enabled)
                btn.setEnabled(creatable or enabled)

            self.groupBox_analogaxes.setLayout(layout)
    def getButtonSources(self):
        dat = self.main.serialGet("lsbtn\n")

        self.btnIds, self.btnClasses = classlistToIds(dat)
        types = self.main.serialGet("btntypes?\n")
        if (types == None):
            self.main.log("Error getting buttons")
            return
        types = int(types)
        layout = QGridLayout()
        #clear
        for b in self.buttonconfbuttons:
            del b
        for b in self.buttonbtns.buttons():
            self.buttonbtns.removeButton(b)
            del b
        #add buttons
        row = 0
        for c in self.btnClasses:
            btn = QCheckBox(str(c[1]), self.groupBox_buttons)
            self.buttonbtns.addButton(btn, c[0])
            layout.addWidget(btn, row, 0)
            enabled = types & (1 << c[0]) != 0
            btn.setChecked(enabled)

            confbutton = QToolButton(self)
            confbutton.setText(">")
            #confbutton.setPopupMode(QToolButton.InstantPopup)
            layout.addWidget(confbutton, row, 1)
            self.buttonconfbuttons.append(
                (confbutton,
                 buttonconf_ui.ButtonOptionsDialog(str(c[1]), c[0],
                                                   self.main)))
            confbutton.clicked.connect(self.buttonconfbuttons[row][1].exec)
            confbutton.setEnabled(enabled)
            self.buttonbtns.button(c[0]).stateChanged.connect(
                confbutton.setEnabled)
            row += 1

        self.groupBox_buttons.setLayout(layout)
    def getEncoder(self):
        #self.comboBox_encoder.currentIndexChanged.disconnect()
        self.spinBox_ppr.setEnabled(True)

        dat = self.main.serialGet("enctype!\n")
        self.comboBox_encoder.clear()
        self.encIds, self.encClasses = classlistToIds(dat)
        id = self.main.serialGet("enctype?\n")
        if (id == None):
            self.main.log("Error getting encoder")
            return
        self.encId = int(id)
        for c in self.encClasses:
            self.comboBox_encoder.addItem(c[1])

        idx = self.encIds[self.encId][0] if self.encId in self.encIds else 0
        self.comboBox_encoder.setCurrentIndex(idx)

        ppr = self.main.serialGet("ppr?\n")
        self.spinBox_ppr.setValue(int(ppr))

        if (self.encId == 1):
            self.spinBox_ppr.setEnabled(False)
 def f(dat):
     self.comboBox_encoder.clear()
     self.encIds, self.encClasses = classlistToIds(dat)
     for c in self.encClasses:
         self.comboBox_encoder.addItem(c[1])