コード例 #1
0
    def initView(self, Big):
        self.BigSize = Big
        self.coloroff = QtGui.QColor(225, 255, 200)
        self.colorerror = QtGui.QColor(255, 179, 179)
        self.colorok = QtGui.QColor(223, 223, 237)
        self.colorwarning = QtGui.QColor(255, 255, 0)
        self.colorconfig = QtGui.QColor(255, 206, 162)
        #self.colorconf = QtGui.QColor(0,255,255)
        if Big:
            self.ui = Ui_IcePapDriverWidget()
            self.ui.setupUi(self)
            self.setPaletteColor(self.ui.lcdCurrent, self.coloroff,
                                 QtGui.QColor(Qt.Qt.white))
        else:
            self.ui = Ui_IcePapDriverWidgetSmall()
            self.ui.setupUi(self)

        self.ui.ledStatus.changeColor(Led.YELLOW)
        self.ui.ledLimitPos.changeColor(Led.ORANGE)
        self.ui.ledLimitNeg.changeColor(Led.GREEN)
        self._manager = MainManager()

        self.setAutoFillBackground(True)

        QtCore.QObject.connect(self.ui.pushButton,
                               QtCore.SIGNAL("clicked(bool)"),
                               self.btnEnDis_on_click)
コード例 #2
0
 def __init__(self, parent, driver):
     QtGui.QDialog.__init__(self, parent)
     self.ui = Ui_DialogDriverConflict()
     self.modal = True
     self.ui.setupUi(self)
     font = QtGui.QFont()
     font.setPointSize(7.5)
     self.setFont(font)
     pathname = os.path.dirname(sys.argv[0])
     path = os.path.abspath(pathname)
     self.config_template = path+'/../share/icepapcms/templates/driverparameters.xml'
     self._driver = driver
     self._manager = MainManager()
     self.ui.tableWidget.horizontalHeader().setResizeMode(0, Qt.QHeaderView.Stretch)
     self.ui.tableWidget.horizontalHeader().setResizeMode(1, Qt.QHeaderView.Stretch)
     self.ui.tableWidget.horizontalHeader().setResizeMode(2, Qt.QHeaderView.Stretch)
     self._fillTable()
     QtCore.QObject.connect(self.ui.btnStored, QtCore.SIGNAL("clicked()"),self.btnStored_on_click)
     QtCore.QObject.connect(self.ui.btnIcepap, QtCore.SIGNAL("clicked()"),self.btnIcepap_on_click)
コード例 #3
0
 def __init__(self, parent, driver):
     QtGui.QDialog.__init__(self, parent)
     pathname = os.path.dirname(sys.argv[0])
     path = os.path.abspath(pathname)
     self.config_template = path + '/../share/icepapcms/templates/driverparameters.xml'
     self.ui = Ui_DialogHistoricCfg()
     self.modal = True
     self.ui.setupUi(self)
     self._driver = driver
     self.setObjectName("DialogTemplate")
     self.setWindowTitle(self.tr("Driver templates"))
     headerItem = QtGui.QTableWidgetItem()
     headerItem.setText(self.tr("Description"))
     self.ui.tableWidget.setHorizontalHeaderItem(1, headerItem)
     self.ui.tableWidget.horizontalHeader().setStretchLastSection(True)
     self._manager = MainManager()
     self._templateList = self._manager.getDriverTemplateList()
     self.ui.tableWidgetCfg.horizontalHeader().setResizeMode(
         0, Qt.QHeaderView.Stretch)
     self.ui.tableWidgetCfg.horizontalHeader().setResizeMode(
         1, Qt.QHeaderView.Stretch)
     self._createTableCfgView()
     self._fillTable()
     self._fillTableCfg(self._driver.currentCfg)
     self.ui.saveButton.setEnabled(True)
     self.ui.loadButton.setEnabled(False)
     self.ui.deleteButton.setEnabled(False)
     QtCore.QObject.connect(self.ui.loadButton, QtCore.SIGNAL("clicked()"),
                            self.loadButton_on_click)
     QtCore.QObject.connect(self.ui.saveButton, QtCore.SIGNAL("clicked()"),
                            self.saveButton_on_click)
     QtCore.QObject.connect(self.ui.deleteButton,
                            QtCore.SIGNAL("clicked()"),
                            self.deleteButton_on_click)
     QtCore.QObject.connect(self.ui.tableWidget,
                            QtCore.SIGNAL("cellClicked(int,int)"),
                            self.tableCell_on_click)
コード例 #4
0
class DialogTemplate(QtGui.QDialog):
    def __init__(self, parent, driver):
        QtGui.QDialog.__init__(self, parent)
        pathname = os.path.dirname(sys.argv[0])
        path = os.path.abspath(pathname)
        self.config_template = path + '/../share/icepapcms/templates/driverparameters.xml'
        self.ui = Ui_DialogHistoricCfg()
        self.modal = True
        self.ui.setupUi(self)
        self._driver = driver
        self.setObjectName("DialogTemplate")
        self.setWindowTitle(self.tr("Driver templates"))
        headerItem = QtGui.QTableWidgetItem()
        headerItem.setText(self.tr("Description"))
        self.ui.tableWidget.setHorizontalHeaderItem(1, headerItem)
        self.ui.tableWidget.horizontalHeader().setStretchLastSection(True)
        self._manager = MainManager()
        self._templateList = self._manager.getDriverTemplateList()
        self.ui.tableWidgetCfg.horizontalHeader().setResizeMode(
            0, Qt.QHeaderView.Stretch)
        self.ui.tableWidgetCfg.horizontalHeader().setResizeMode(
            1, Qt.QHeaderView.Stretch)
        self._createTableCfgView()
        self._fillTable()
        self._fillTableCfg(self._driver.currentCfg)
        self.ui.saveButton.setEnabled(True)
        self.ui.loadButton.setEnabled(False)
        self.ui.deleteButton.setEnabled(False)
        QtCore.QObject.connect(self.ui.loadButton, QtCore.SIGNAL("clicked()"),
                               self.loadButton_on_click)
        QtCore.QObject.connect(self.ui.saveButton, QtCore.SIGNAL("clicked()"),
                               self.saveButton_on_click)
        QtCore.QObject.connect(self.ui.deleteButton,
                               QtCore.SIGNAL("clicked()"),
                               self.deleteButton_on_click)
        QtCore.QObject.connect(self.ui.tableWidget,
                               QtCore.SIGNAL("cellClicked(int,int)"),
                               self.tableCell_on_click)

    def _createTableCfgView(self):
        doc = minidom.parse(self.config_template)
        root = doc.documentElement
        row = 0
        for section in root.getElementsByTagName("section"):
            for pars in section.getElementsByTagName("par"):
                if pars.nodeType == Node.ELEMENT_NODE:
                    self.ui.tableWidgetCfg.insertRow(row)
                    parname = pars.attributes.get('name').value
                    parname = parname.strip()
                    self._addItemToTable(self.ui.tableWidgetCfg, row, 0,
                                         parname, False)
                    row += 1

    def tableCell_on_click(self, row, col):
        self.templatename = str(self.ui.tableWidget.item(row, 0).text())
        template = self._templateList[self.templatename]
        self.ui.txtName.setText(template.name)
        self.ui.txtDescription.clear()
        self.ui.txtDescription.insertPlainText(template.description)
        self.ui.saveButton.setEnabled(False)
        self.ui.txtName.setEnabled(False)
        self.ui.txtDescription.setEnabled(False)
        self.ui.loadButton.setEnabled(True)
        self.ui.deleteButton.setEnabled(True)
        self._fillTableCfg(template.cfg)

    def loadButton_on_click(self):
        template = self._templateList[self.templatename]
        self.loadcfg = template.cfg
        self.accept()

    def deleteButton_on_click(self):
        if MessageDialogs.showYesNoMessage(self, "Historic configuration",
                                           "Delete selected configuration ?"):
            self._manager.deleteDriverTemplate(self.templatename)
        self.ui.txtName.setText("")
        self.ui.txtDescription.clear()
        self._fillTable()
        self.selecteddate = ""
        for row in range(self.ui.tableWidgetCfg.rowCount()):
            self.ui.tableWidgetCfg.item(row, 1).setText("")
        self.ui.loadButton.setEnabled(False)
        self.ui.deleteButton.setEnabled(False)

    def saveButton_on_click(self):
        name = str(self.ui.txtName.text())
        desc = str(self.ui.txtDescription.toPlainText())
        if name == "":
            MessageDialogs.showWarningMessage(self, "Driver template",
                                              "Fill all required data.")
        else:
            if self._templateList.has_key(name):
                MessageDialogs.showWarningMessage(
                    self, "Driver template", "Choose another template name.")
            elif MessageDialogs.showYesNoMessage(
                    self, "Store template configuration",
                    "Save current configuration ?"):
                self._manager.saveDriverTemplate(name, desc,
                                                 self._driver.currentCfg)
                self.close()

    def _fillTableCfg(self, cfg):
        for row in range(self.ui.tableWidgetCfg.rowCount()):
            name = str(self.ui.tableWidgetCfg.item(row, 0).text())
            if self._driver.currentCfg.parList.has_key(name):
                stored_value = cfg.parList[name]
            else:
                stored_value = ""
            self._addItemToTable(self.ui.tableWidgetCfg, row, 1, stored_value,
                                 False)

    def _fillTable(self):
        self.ui.tableWidget.setRowCount(0)
        row = 0
        for name, template in self._templateList.items():
            self.ui.tableWidget.insertRow(row)
            self._addItemToTable(self.ui.tableWidget, row, 0, name, False)
            self._addItemToTable(self.ui.tableWidget, row, 1,
                                 template.description, False)
            row += 1

    def _addItemToTable(self, table, row, column, text, editable):
        item = QtGui.QTableWidgetItem()
        item.setText(text)
        if not editable:
            item.setFlags(Qt.Qt.ItemIsSelectable)
        else:
            item.setTextColor(QtGui.QColor(Qt.Qt.red))
        table.setItem(row, column, item)
コード例 #5
0
 def buildLocationCombo(self, location):
     for location_name in MainManager().locationList.keys():
         self.ui.cbLocation.addItem(location_name)
     self.ui.cbLocation.setCurrentIndex(
         self.ui.cbLocation.findText(location, QtCore.Qt.MatchFixedString))
コード例 #6
0
class DialogDriverConflict(QtGui.QDialog):
    def __init__(self, parent, driver):
        QtGui.QDialog.__init__(self, parent)
        self.ui = Ui_DialogDriverConflict()
        self.modal = True
        self.ui.setupUi(self)
        font = QtGui.QFont()
        font.setPointSize(7.5)
        self.setFont(font)
        pathname = os.path.dirname(sys.argv[0])
        path = os.path.abspath(pathname)
        self.config_template = path+'/../share/icepapcms/templates/driverparameters.xml'
        self._driver = driver
        self._manager = MainManager()
        self.ui.tableWidget.horizontalHeader().setResizeMode(0, Qt.QHeaderView.Stretch)
        self.ui.tableWidget.horizontalHeader().setResizeMode(1, Qt.QHeaderView.Stretch)
        self.ui.tableWidget.horizontalHeader().setResizeMode(2, Qt.QHeaderView.Stretch)
        self._fillTable()
        QtCore.QObject.connect(self.ui.btnStored, QtCore.SIGNAL("clicked()"),self.btnStored_on_click)
        QtCore.QObject.connect(self.ui.btnIcepap, QtCore.SIGNAL("clicked()"),self.btnIcepap_on_click)
        
        
    def _createTableView(self):
        self.var_dict = {}
        doc = minidom.parse(self.config_template)
        root  = doc.documentElement
        row = 0
        for section in root.getElementsByTagName("section"):
            if section.nodeType == Node.ELEMENT_NODE:
                    section_name =  section.attributes.get('name').value
            inTestSection = (section_name == "test")
            if inTestSection:
                return
            for pars in section.getElementsByTagName("par"):
                if pars.nodeType == Node.ELEMENT_NODE:
                    self.ui.tableWidget.insertRow(row)
                    parname =  pars.attributes.get('name').value
                    parname = parname.strip()
                    self.var_dict[parname] = row
                    self._addItemToTable(row, 0, parname, False)
                    row = row + 1

    
    def _fillTable(self):
        self._createTableView()
        self.icepap_values = self._manager.getDriverConfiguration(self._driver.icepapsystem_name, self._driver.addr)
        row = 0
        current = False

        for row in range(self.ui.tableWidget.rowCount()):
            name = unicode(self.ui.tableWidget.item(row,0).text())

            if name == "NAME":
                name = unicode("IPAPNAME")

            stored_value = self._driver.current_cfg.getParameter(name, True)
            if stored_value is None:
                stored_value = ""
            
            icepap_value = self.icepap_values.getParameter(name, True)
            if icepap_value is None:
                icepap_value = ""
            color = stored_value != icepap_value
                               
            self._addItemToTable(row, 1, stored_value, color)
            self._addItemToTable(row, 2, icepap_value, color)
        

        if current:
            MessageDialogs.showWarningMessage(self, "Driver conflict", "Warning!!\nCurrent values (IN, IB, II) have changed!!\n")
    
    def btnIcepap_on_click(self):
        db = StormManager()
        db.store(self.icepap_values)
        # bug sqlite
        self._driver.addConfiguration(self.icepap_values)
        self.accept()
    
    def btnStored_on_click(self):
        del self.icepap_values
        self._manager.saveValuesInIcepap(self._driver, self._driver.current_cfg.toList())
        self.accept()
           
    def _addItemToTable(self, row, column, text, colored):
        item = QtGui.QTableWidgetItem()
        item.setText(text)
        item.setFlags(Qt.Qt.ItemIsSelectable)
        if colored:
            item.setTextColor(QtGui.QColor(Qt.Qt.red))
        self.ui.tableWidget.setItem(row, column, item)
コード例 #7
0
class IcePapDriverWidget(QtGui.QWidget):
    def __init__(self, parent=None, BigSize=True):
        QtGui.QWidget.__init__(self, parent)
        self.initView(BigSize)
        self.MaxCurrent = 7
        self._driver = None
        self.setMouseTracking(True)
        self.status = -1
        self.ready = -1
        self.power = -1
        self.mode = -1

    def initView(self, Big):
        self.BigSize = Big
        self.coloroff = QtGui.QColor(225, 255, 200)
        self.colorerror = QtGui.QColor(255, 179, 179)
        self.colorok = QtGui.QColor(223, 223, 237)
        self.colorwarning = QtGui.QColor(255, 255, 0)
        self.colorconfig = QtGui.QColor(255, 206, 162)
        #self.colorconf = QtGui.QColor(0,255,255)
        if Big:
            self.ui = Ui_IcePapDriverWidget()
            self.ui.setupUi(self)
            self.setPaletteColor(self.ui.lcdCurrent, self.coloroff,
                                 QtGui.QColor(Qt.Qt.white))
        else:
            self.ui = Ui_IcePapDriverWidgetSmall()
            self.ui.setupUi(self)

        self.ui.ledStatus.changeColor(Led.YELLOW)
        self.ui.ledLimitPos.changeColor(Led.ORANGE)
        self.ui.ledLimitNeg.changeColor(Led.GREEN)
        self._manager = MainManager()

        self.setAutoFillBackground(True)

        QtCore.QObject.connect(self.ui.pushButton,
                               QtCore.SIGNAL("clicked(bool)"),
                               self.btnEnDis_on_click)

    def mouseDoubleClickEvent(self, event):
        self.emit(QtCore.SIGNAL("icepapDoubleClicked(PyQt_PyObject)"),
                  self._driver)
        event.accept()

    def mousePressEvent(self, event):
        tooltip = str(self._driver.current_cfg)
        QtGui.QToolTip.showText(event.globalPos(), tooltip)
        event.accept()

    def mouseMoveEvent(self, event):
        tooltip = str(self._driver.current_cfg)
        #self.setToolTip(tooltip)
        event.accept()

    def btnEnDis_on_click(self, bool):
        if bool:
            self.ui.pushButton.setText("power OFF")
            self._manager.enableDriver(self._driver.icepapsystem_name,
                                       self._driver.addr)
        else:
            self.ui.pushButton.setText("power ON")
            self._manager.disableDriver(self._driver.icepapsystem_name,
                                        self._driver.addr)

    def getDriver(self):
        return self._driver

    def fillData(self, driver):
        self._driver = driver
        if driver is None:
            self.ui.lblName.setText("")
            self.ui.frame.setEnabled(False)
            return False
        else:
            return self.fillStatus()

    def refresh(self):
        if not self._driver is None:
            return self.fillStatus()
        else:
            return True

    def fillStatus(self):
        if self._driver.getName() == None:
            self.ui.lblName.setText("- %d -" % self._driver.addr)
        elif self._driver.getName() <> "":
            self.ui.lblName.setText(
                "%d- %s" % (self._driver.addr, self._driver.getName()))
        else:
            self.ui.lblName.setText("- %d -" % self._driver.addr)

        if self._driver.conflict == Conflict.DRIVER_NOT_PRESENT:
            self.setPaletteColor(self.ui.frame, self.colorerror, Qt.Qt.black)
        elif self._driver.conflict == Conflict.DRIVER_CHANGED:
            self.setPaletteColor(self.ui.frame, self.colorwarning, Qt.Qt.black)
        elif self._driver.mode == IcepapMode.CONFIG:
            self.setPaletteColor(self.ui.frame, self.colorconfig, Qt.Qt.black)
        else:
            self.setPaletteColor(self.ui.frame, self.colorok, Qt.Qt.black)

        (status, power, current) = self._manager.getDriverStatus(
            self._driver.icepapsystem_name, self._driver.addr)
        if status == -1:
            self.ui.pushButton.setEnabled(False)
            self.ui.ledStatus.changeColor(Led.RED)
            self.ui.ledStatus.on()
            return

        disabled = IcepapStatus.isDisabled(status)
        ready = IcepapStatus.isReady(status)
        mode = IcepapStatus.getMode(status)
        if self.status <> disabled or self.mode <> mode or self.power <> power or self.ready <> ready:
            if disabled == 0:
                if power:
                    self.ui.ledStatus.changeColor(Led.GREEN)
                    self.ui.ledStatus.on()
                    self.ui.pushButton.setText("power OFF")
                    self.ui.pushButton.setChecked(True)
                    self.ui.pushButton.setEnabled(True)
                    self.mode = mode
                else:
                    self.ui.pushButton.setEnabled(True)
                    self.ui.pushButton.setText("power ON")
                    self.ui.pushButton.setChecked(False)
                    self.ui.ledStatus.changeColor(Led.RED)
                    self.ui.ledStatus.on()
            elif disabled == 1:
                # driver is not active disable motion and enable
                self.ui.pushButton.setEnabled(False)
                self.ui.ledStatus.changeColor(Led.RED)
                self.ui.ledStatus.on()
            else:
                self.ui.pushButton.setEnabled(True)
                self.ui.pushButton.setText("power ON")
                self.ui.pushButton.setChecked(False)
                self.ui.ledStatus.changeColor(Led.RED)
                self.ui.ledStatus.on()

        if status == -1:
            self.ui.pushButton.setEnabled(False)
            self.ui.ledStatus.changeColor(Led.RED)
            self.ui.ledStatus.on()

        self.status = disabled
        self.ready = ready
        self.power = power

        lower = IcepapStatus.getLimitNegative(status)
        upper = IcepapStatus.getLimitPositive(status)
        if lower:
            self.ui.ledLimitNeg.on()
        else:
            self.ui.ledLimitNeg.off()

        if upper:
            self.ui.ledLimitPos.on()
        else:
            self.ui.ledLimitPos.off()

        if self.BigSize:
            self.setCurrent(current)
        return True

    def setCurrent(self, current):
        self.ui.lcdCurrent.display(current)
        color = QtGui.QColor()
        if current < 0 or current > 7:
            color = self.coloroff
        else:
            percentage = ((self.MaxCurrent) - current) / self.MaxCurrent

            S = 255 - abs(int(128 * percentage))
            H = abs(int(180 * percentage))
            V = 255 - abs(int(60 * percentage))
            color.setHsv(H, S, V)
        self.setPaletteColor(self.ui.lcdCurrent, color,
                             QtGui.QColor(Qt.Qt.black))

    def setPaletteColor(self, widget, backcolor, forecolor):
        palette = widget.palette()
        widget.setAutoFillBackground(True)
        palette.setColor(QtGui.QPalette.Base, backcolor)
        palette.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, forecolor)
        widget.setPalette(palette)
        widget.show()