Пример #1
0
class MotorConfigPanel(TaurusWidget):

    """Widget for motor"""

    def __init__(self, parent=None):
        TaurusWidget.__init__(self, parent)
        self._setup_ui()

    def _setup_ui(self):

        self.gridLayout = QtGui.QGridLayout(self)
        self.taurusForm = TaurusForm(self)
        self.taurusForm.setWithButtons(False)

        self.gridLayout.addWidget(self.taurusForm, 0, 0, 1, 2)

    def setModel(self, mot):

        attributes = [mot+"/Status",
                      mot+"/State",
                      mot+"/Step_per_unit",
                      mot+"/Offset",
                      mot+"/Sign",
                      mot+"/Position",
                      mot+"/DialPosition",
                      ]

        self.taurusForm.setModel(attributes)
Пример #2
0
class AttributesPreview(Qt.QFrame):
    def __init__(self, model='', parent=None, source=None):
        Qt.QWidget.__init__(self, parent)
        self.model = model
        self.source = source
        self.test = panic.current()._eval
        self.test._trace = True
        self.initStyle()
        self.updateAttributes(self.model)

    def initStyle(self):
        print 'In AttributesPreview.initStyle()'
        try:
            self.setLayout(Qt.QGridLayout())
            self.redobt = Qt.QPushButton()
            self.redobt.setIcon(getThemeIcon('view-refresh'))
            self.redobt.setToolTip('Update result')
            self.taurusForm = TaurusForm()
            self.taurusForm.setWithButtons(False)
            self.taurusForm.setWindowTitle('Preview')
            self.layout().addWidget(self.redobt, 0, 6, 1, 1)
            self.layout().addWidget(
                Qt.QLabel('Values of attributes used in the Alarm formula:'),
                0, 0, 1, 1)
            self.layout().addWidget(self.taurusForm, 1, 0, 1, 7)
            self.connect(self.redobt, Qt.SIGNAL('pressed()'),
                         self.updateAttributes)
        except:
            print traceback.format_exc()

    @Catched
    def updateAttributes(self, model=None):
        print('AttributesPreview.updateAttributes(%s)' % model)
        if not model and self.source:
            try:
                if hasattr(self.source, 'formula'): model = self.source.formula
                elif hasattr(self.source, '__call__'): model = self.source()
                else: model = str(self.source or '')
            except:
                print(traceback.format_exc())

        if not fandango.isSequence(model):
            ms, model = self.test.parse_variables(model or ''), set()
            for var in ms:
                dev, attr = var[0], var[1]
                if ':' in dev and not dev.startswith('tango://'):
                    dev = 'tango://' + dev
                model.add(dev + '/' + attr)

        self.model = sorted(model)
        print('In AttributesPreview.updateAttributes(%s)' % model)
        self.taurusForm.setModel(model)
        [
            tvalue.setLabelConfig("<attr_fullname>")
            for tvalue in self.taurusForm.getItems()
        ]
Пример #3
0
class IORConfigPanel(TaurusWidget):

    """Widget to configure the IOR"""

    config_trigger = QtCore.pyqtSignal()

    def __init__(self, userwidget, parent=None):
        self.userwidget = userwidget
        TaurusWidget.__init__(self, parent)
        self._setup_ui()
        self.oldvalue =  {}

    def updateBoxes(self):
        self.userwidget.updateBoxes(True)

    def _setup_ui(self):
        self.gridLayout = QtGui.QGridLayout(self)
        self.taurusForm = TaurusForm(self)
        self.taurusForm.setWithButtons(False)
        self.gridLayout.addWidget(self.taurusForm, 0, 0, 1, 2)

    def setModel(self, ior):

        attributes = [ior+"/Labels",
                      ior+"/Calibration",
                      ]
        self.taurusForm.setModel(attributes)

        #Need listeners on these attributes to update user widget
        #for a in attributes:
        #    taurus.Attribute(a).addListener(self.configListener)
        #self.config_trigger.connect(self.updateBoxes)

    def configListener(self, src, evt_type, attr_val):

        #is this going to emit every 3 seconds irrespective of whether attribute actually changes?
        if isinstance(src,taurus.core.tango.tangoattribute.TangoAttribute):
            if src not in  self.oldvalue:
                self.oldvalue[src] = attr_val.value
            else:
                if self.oldvalue[src] != attr_val.value:
                    self.oldvalue[src] = attr_val.value
                    self.config_trigger.emit()
Пример #4
0
def configure_form(dev, form=None):
    """ Creates a TauForm and configures its Status fields 
    """
    if form is None:
        form = FORM_CLASS()
    elif hasattr(form, 'setModel'):
        form.setModel([])
    ##Configuring the TauForm:
    form.setWithButtons(False)
    form.setWindowTitle(dev)
    form.setModel('%s/%s' % (dev, a) for a in get_dev_attrs(dev))
    ##Adapting the status widget to show properly an status
    status = form.getItemByModel(
        dev +
        '/status')  #A TauValue object (containing label and value widgets)
    sw = status.readWidget()  #A TauStatusLabel object
    sw.setAlignment(Qt.Qt.AlignLeft)
    sw.setMinimumHeight(STATUS_HEIGHT)
    #sw.setShowQuality(False) #It didn't work as expected
    return form
class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        self._Form = Form
        self.font = QtGui.QFont()
        self.font.setBold(True)
        self.gridLayout_2 = QtGui.QGridLayout(Form)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.gridLayout = QtGui.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")

        self.chooseLabel = Qt.QLabel()
        self.chooseLabel.setObjectName("chooseLabel")
        self.chooseLabel.setFont(self.font)
        self.chooseLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.gridLayout.addWidget(self.chooseLabel, 0, 0, 1, 1)

        self.tac = attributeChooser()
        self.tac.setObjectName("taurusAttributeChooser")
        self.gridLayout.addWidget(self.tac, 1, 0, 6, 1)

        self.selectedLabel = Qt.QLabel()
        self.selectedLabel.setObjectName("selectedLabel")
        self.selectedLabel.setFont(self.font)
        self.selectedLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.selectedLabel.hide()
        self.gridLayout.addWidget(self.selectedLabel, 0, 1, 1, 6)

        self.tf = TaurusForm()
        self.tf.setWithButtons(False)
        self.tf.setObjectName("taurusForm")
        self.tf.hide()
        self.gridLayout.addWidget(self.tf, 1, 1, 1, 6)
        self.label = Qt.QLabel()
        self.label.setObjectName("label")
        self.label.setFont(self.font)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.gridLayout.addWidget(self.label, 1, 1, 1, 6)

        spacerItem = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Minimum,
                                       QtGui.QSizePolicy.Expanding)
        self.gridLayout.addItem(spacerItem, 1, 1, 1, 1)

        self.modepLabel = QtGui.QLabel(Form)
        self.modepLabel.setObjectName("modepLabel")
        self.modepLabel.setText('Period [s]:')
        self.gridLayout.addWidget(self.modepLabel, 2, 1, 1, 1)
        self.modepLineEdit = QtGui.QLineEdit(Form)
        self.modepLineEdit.setObjectName("modepLineEdit")
        self.modepLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form))
        self.modepLineEdit.setMaxLength(7)
        self.modepLineEdit.setMaximumWidth(60)
        self.modepLineEdit.setText('60.0')
        self.gridLayout.addWidget(self.modepLineEdit, 2, 2, 1, 1)

        self.modeaLabel = QtGui.QLabel(Form)
        self.modeaLabel.setObjectName("modeaLabel")
        self.modeaLabel.setText('Absolute Period [s]:')
        self.gridLayout.addWidget(self.modeaLabel, 3, 1, 1, 1)
        self.modeaLineEdit = QtGui.QLineEdit(Form)
        self.modeaLineEdit.setObjectName("modeaLineEdit")
        self.modeaLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form))
        self.modeaLineEdit.setMaxLength(7)
        self.modeaLineEdit.setMaximumWidth(60)
        self.modeaLineEdit.setText('15.0')
        self.gridLayout.addWidget(self.modeaLineEdit, 3, 2, 1, 1)
        self.modeaLowerLimitLabel = QtGui.QLabel(Form)
        self.modeaLowerLimitLabel.setObjectName("modeaLowerLimitLabel")
        self.modeaLowerLimitLabel.setText('Lower Limit (decr.):')
        self.gridLayout.addWidget(self.modeaLowerLimitLabel, 3, 3, 1, 1)
        self.modeaLowerLimitLineEdit = QtGui.QLineEdit(Form)
        self.modeaLowerLimitLineEdit.setObjectName("modeaLowerLimitLineEdit")
        self.modeaLowerLimitLineEdit.setValidator(
            Qt.QDoubleValidator(1, 14400, 2, Form))
        self.modeaLowerLimitLineEdit.setMaxLength(7)
        self.modeaLowerLimitLineEdit.setMaximumWidth(60)
        self.gridLayout.addWidget(self.modeaLowerLimitLineEdit, 3, 4, 1, 1)
        self.modeaUpperLimitLabel = QtGui.QLabel(Form)
        self.modeaUpperLimitLabel.setObjectName("modeaUpperLimitLabel")
        self.modeaUpperLimitLabel.setText('Upper Limit (incr.):')
        self.gridLayout.addWidget(self.modeaUpperLimitLabel, 3, 5, 1, 1)
        self.modeaUpperLimitLineEdit = QtGui.QLineEdit(Form)
        self.modeaUpperLimitLineEdit.setObjectName("modeaUpperLimitLineEdit")
        self.modeaUpperLimitLineEdit.setValidator(
            Qt.QDoubleValidator(1, 14400, 2, Form))
        self.modeaUpperLimitLineEdit.setMaxLength(7)
        self.modeaUpperLimitLineEdit.setMaximumWidth(60)
        self.gridLayout.addWidget(self.modeaUpperLimitLineEdit, 3, 6, 1, 1)

        self.moderLabel = QtGui.QLabel(Form)
        self.moderLabel.setObjectName("moderLabel")
        self.moderLabel.setText('Relative Period [s]:')
        self.gridLayout.addWidget(self.moderLabel, 4, 1, 1, 1)
        self.moderLineEdit = QtGui.QLineEdit(Form)
        self.moderLineEdit.setObjectName("moderLineEdit")
        self.moderLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form))
        self.moderLineEdit.setMaxLength(7)
        self.moderLineEdit.setMaximumWidth(60)
        self.moderLineEdit.setText('15.0')
        self.gridLayout.addWidget(self.moderLineEdit, 4, 2, 1, 1)
        self.moderLowerLimitPercentLabel = QtGui.QLabel(Form)
        self.moderLowerLimitPercentLabel.setObjectName(
            "moderLowerLimitPercentLabel")
        self.moderLowerLimitPercentLabel.setText('Lower % Limit (decr.):')
        self.gridLayout.addWidget(self.moderLowerLimitPercentLabel, 4, 3, 1, 1)
        self.moderLowerLimitPercentLineEdit = QtGui.QLineEdit(Form)
        self.moderLowerLimitPercentLineEdit.setObjectName(
            "moderLowerLimitPercentLineEdit")
        self.moderLowerLimitPercentLineEdit.setValidator(
            QtGui.QDoubleValidator(0, 1, 2, Form))
        self.moderLowerLimitPercentLineEdit.setMaxLength(7)
        self.moderLowerLimitPercentLineEdit.setMaximumWidth(60)
        self.gridLayout.addWidget(self.moderLowerLimitPercentLineEdit, 4, 4, 1,
                                  1)
        self.moderUpperLimitPercentLabel = QtGui.QLabel(Form)
        self.moderUpperLimitPercentLabel.setObjectName(
            "moderUpperLimitPercentLabel")
        self.moderUpperLimitPercentLabel.setText('Upper % Limit (incr.):')
        self.gridLayout.addWidget(self.moderUpperLimitPercentLabel, 4, 5, 1, 1)
        self.moderUpperLimitPercentLineEdit = QtGui.QLineEdit(Form)
        self.moderUpperLimitPercentLineEdit.setObjectName(
            "moderUpperLimitPercentLineEdit")
        self.moderUpperLimitPercentLineEdit.setValidator(
            Qt.QDoubleValidator(0, 1, 2, Form))
        self.moderUpperLimitPercentLineEdit.setMaxLength(7)
        self.moderUpperLimitPercentLineEdit.setMaximumWidth(60)
        self.gridLayout.addWidget(self.moderUpperLimitPercentLineEdit, 4, 6, 1,
                                  1)

        self.gridButtonLayout = QtGui.QGridLayout()
        self.gridButtonLayout.setObjectName("gridButtonLayout")
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Minimum)
        self.gridButtonLayout.addItem(spacerItem, 0, 1, 1, 1)
        self.pushButtonStart = QtGui.QPushButton(Form)
        self.pushButtonStart.setObjectName("pushButtonStart")
        self.pushButtonStart.setEnabled(False)
        self.gridButtonLayout.addWidget(self.pushButtonStart, 0, 2, 1, 1)
        self.pushButtonStop = QtGui.QPushButton(Form)
        self.pushButtonStop.setObjectName("pushButtonStop")
        self.pushButtonStop.setEnabled(False)
        self.gridButtonLayout.addWidget(self.pushButtonStop, 0, 3, 1, 1)
        self.pushButtonCancel = QtGui.QPushButton(Form)
        self.pushButtonCancel.setObjectName("pushButtonCancel")
        self.gridButtonLayout.addWidget(self.pushButtonCancel, 0, 4, 1, 1)
        self.gridLayout.addLayout(self.gridButtonLayout, 5, 1, 1, 6)
        self.gridLayout_2.addLayout(self.gridLayout, 1, 0, 1, 1)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        Form.setWindowTitle(
            QtGui.QApplication.translate("Form", "Archiving Widget", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.pushButtonStart.setText(
            QtGui.QApplication.translate("Form", "Start Archiving", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.pushButtonStop.setText(
            QtGui.QApplication.translate("Form", "Stop", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.pushButtonCancel.setText(
            QtGui.QApplication.translate("Form", "Close", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.label.setText(
            QtGui.QApplication.translate("Form", "Nothing to display", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.selectedLabel.setText(
            QtGui.QApplication.translate(
                "Form", "Press start to start archiving selected attributes:",
                None, QtGui.QApplication.UnicodeUTF8))
        self.chooseLabel.setText(
            QtGui.QApplication.translate(
                "Form",
                "Choose attributes to archive and hit apply to move attributes to selection",
                None, QtGui.QApplication.UnicodeUTF8))
        self.tf.connect(self.tac, Qt.SIGNAL("UpdateAttrs"), self.onUpdate)
        QtCore.QObject.connect(self.pushButtonStart, Qt.SIGNAL("clicked()"),
                               self.onStart)
        QtCore.QObject.connect(self.pushButtonStop, Qt.SIGNAL("clicked()"),
                               self.onStop)
        QtCore.QObject.connect(self.pushButtonCancel, Qt.SIGNAL("clicked()"),
                               self.onCancel)
        QtCore.QObject.connect(self.modepLineEdit,
                               Qt.SIGNAL('textChanged(const QString &)'),
                               self.modepTextChanged)
        QtCore.QObject.connect(self.modeaLineEdit,
                               Qt.SIGNAL('textChanged(const QString &)'),
                               self.modeaTextChanged)
        QtCore.QObject.connect(self.moderLineEdit,
                               Qt.SIGNAL('textChanged(const QString &)'),
                               self.moderTextChanged)
        #QtCore.QObject.connect(self.moderUpperLimitPercentLineEdit, Qt.SIGNAL('editingFinished()'), self.moderUpperLimitPercentTextChanged)
        #QtCore.QObject.connect(self.moderLowerLimitPercentLineEdit, Qt.SIGNAL('editingFinished()'), self.moderLowerLimitPercentTextChanged)
        #QtCore.QObject.connect(self.modeaUpperLimitLineEdit, Qt.SIGNAL('editingFinished()'), self.modeaUpperLimitTextChanged)
        #QtCore.QObject.connect(self.modeaLowerLimitLineEdit, Qt.SIGNAL('editingFinished()'), self.modeaLowerLimitTextChanged)

    def modepTextChanged(self):
        if self.modepLineEdit.text():
            if (float(self.modepLineEdit.text()) < 1
                    or float(self.modepLineEdit.text()) > 14400):
                Qt.QMessageBox.critical(self._Form, 'Error',
                                        'Value ranges between 1 and 14400',
                                        QtGui.QMessageBox.AcceptRole,
                                        QtGui.QMessageBox.AcceptRole)
                if float(self.modepLineEdit.text()) > 14400:
                    self.modepLineEdit.setText('14400')
                else:
                    self.modepLineEdit.setText('1')
        else:
            Qt.QMessageBox.critical(self._Form, 'Error',
                                    'Value ranges between 1 and 14400',
                                    QtGui.QMessageBox.AcceptRole,
                                    QtGui.QMessageBox.AcceptRole)
            self.modepLineEdit.setText('1')

    def modeaTextChanged(self):
        if self.modeaLineEdit.text():
            if (float(self.modeaLineEdit.text()) > float(
                    self.modepLineEdit.text())):
                Qt.QMessageBox.critical(
                    self._Form, 'Error',
                    'Value cannot be higher than ' + self.modepLineEdit.text(),
                    QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole)
                self.modeaLineEdit.setText('0')

    def moderTextChanged(self):
        if self.moderLineEdit.text():
            if (float(self.moderLineEdit.text()) > float(
                    self.modepLineEdit.text())):
                Qt.QMessageBox.critical(
                    self._Form, 'Error',
                    'Value cannot be higher than ' + self.modepLineEdit.text(),
                    QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole)
                self.moderLineEdit.setText('0')

    def validate(self, modep, modea, moder):
        if (modep < modea or modep < moder):
            Qt.QMessageBox.critical(
                self._Form, 'Error',
                'Period value has to be higher than the others',
                QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole)
            self.modepLineEdit.setText(
                str(10 * max(int(self.moderLineEdit.text()),
                             int(self.modeaLineEdit.text()))))
            return False
        return True

    def floatValidation(self, line):
        val = line.text()
        try:
            float(val)
            return True
        except:
            Qt.QMessageBox.critical(self._Form,
                                    'Error in ' + str(line.objectName()),
                                    'Wrong value !\nSetting value to 0!',
                                    QtGui.QMessageBox.AcceptRole,
                                    QtGui.QMessageBox.AcceptRole)
            line.setText('0')
            return False

    def onStart(self):

        self.floatValidation(self.moderUpperLimitPercentLineEdit)
        self.floatValidation(self.moderLowerLimitPercentLineEdit)
        self.floatValidation(self.modeaUpperLimitLineEdit)
        self.floatValidation(self.modeaLowerLimitLineEdit)
        try:
            self.modep = int(1000 * self.modepLineEdit.text())
            self.modea = (int(1000 * self.modeaLineEdit.text())
                          if self.modeaLineEdit.text() else None)
            self.modeaLowerLimit = (float(self.modeaLowerLimitLineEdit.text())
                                    if self.modeaLowerLimitLineEdit.text() else
                                    None)
            self.modeaUpperLimit = (float(self.modeaUpperLimitLineEdit.text())
                                    if self.modeaUpperLimitLineEdit.text() else
                                    None)
            self.moder = (int(1000 * self.moderLineEdit.text())
                          if self.moderLineEdit.text() else None)
            self.moderLowerLimit = (
                float(self.moderLowerLimitPercentLineEdit.text())
                if self.moderLowerLimitPercentLineEdit.text() else None)
            self.moderUpperLimit = (
                float(self.moderUpperLimitPercentLineEdit.text())
                if self.moderUpperLimitPercentLineEdit.text() else None)
            if self.validate(self.modep, self.modea, self.moder):
                reply = Qt.QMessageBox.question(
                    self._Form, "Warning",
                    "Do you want to start archiving selected attributes?",
                    QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
                    QtGui.QMessageBox.Yes)
                if reply == QtGui.QMessageBox.Yes:
                    command = {'MODE_P': [self.modep]}
                    if (self.modea and self.modeaUpperLimit
                            and self.modeaLowerLimit):
                        command['MODE_A'] = [
                            self.modea, self.modeaUpperLimit,
                            self.modeaLowerLimit
                        ]
                    if (self.moder and self.moderUpperLimit
                            and self.moderLowerLimit):
                        command['MODE_R'] = [
                            self.moder, self.moderUpperLimit,
                            self.moderLowerLimit
                        ]
                    attrs = [a for a in self.tf.getModel()]
                    cmd = self.tac.tdb.check_modes('tdb', command)
                    toStop = [a for a in attrs if a in self.tac.beingArchived]
                    try:
                        if toStop:
                            self.tac.tdb.api.start_archiving(attrs,
                                                             cmd,
                                                             kill=True)
                        else:
                            self.tac.tdb.api.start_archiving(attrs, cmd)
                    except:
                        Qt.QMessageBox.critical(
                            self._Form, "Error",
                            'Cannot start archiving process.\nCheck the state of archiving managers.',
                            QtGui.QMessageBox.AcceptRole,
                            QtGui.QMessageBox.AcceptRole)
                        print(traceback.format_exc())

                    self.tac.beingArchived = [
                        a.lower() for a in self.tac.tdb
                        if self.tac.tdb.is_attribute_archived(a.lower())
                    ]  #update archived list
                    self.onUpdate(attrs)
                    self.tac.setNewDevName()
        except:
            print(traceback.format_exc())

    def onStop(self):
        toStop = [
            att.lower() for att in self.tf.getModel()
            if att.lower() in self.tac.beingArchived
        ]
        reply = Qt.QMessageBox.question(
            self._Form, "Warning", "Do you want to stop archiving " +
            str(len(toStop)) + " attributes?",
            QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
            QtGui.QMessageBox.Yes)
        if reply == QtGui.QMessageBox.Yes:
            self.tac.tdb.api.stop_archiving(toStop)
            self.tac.beingArchived = [
                a.lower() for a in self.tac.tdb
                if self.tac.tdb.is_attribute_archived(a.lower())
            ]  #update archived list
            self.pushButtonStop.setEnabled(False)
            self.pushButtonStop.setText('Stop')
            self.tac.setNewDevName()
            self.clearParams()

    def onUpdate(self, attrs):
        self.clearParams()
        if not attrs:
            self.tf.hide()
            self.label.show()
            self.selectedLabel.hide()
            self.pushButtonStart.setEnabled(False)
            self.pushButtonStop.setEnabled(False)
            self.pushButtonStop.setText('Stop')
        else:
            self.label.hide()
            self.selectedLabel.show()
            self.tf.show()
            self.tf.setModel(attrs)

            for i in range(len(attrs)):
                item = self.tf.getItemByIndex(i)
                if item.getModel().lower() in self.tac.beingArchived:
                    item.setExtraWidgetClass(historyButton)
                    historyButton().setModel(item.getModel())

            self.pushButtonStart.setEnabled(True)
            toStop = [
                att.lower() for att in attrs
                if att.lower() in self.tac.beingArchived
            ]
            if toStop:
                self.pushButtonStop.setEnabled(True)
                self.pushButtonStop.setText('Stop (' + str(len(toStop)) + ')')
                modes = self.tac.tdb.get(toStop[0]).modes
                if 'MODE_P' in modes.keys():
                    self.modepLineEdit.setText(
                        str(int(modes['MODE_P'][0] / 1000)))
                if 'MODE_R' in modes.keys():
                    if len(modes['MODE_R']) == 3:
                        self.moderLineEdit.setText(
                            str(int(modes['MODE_R'][0] / 1000)))
                        self.moderLowerLimitPercentLineEdit.setText(
                            str(float(modes['MODE_R'][1])))
                        self.moderUpperLimitPercentLineEdit.setText(
                            str(float(modes['MODE_R'][2])))
                if 'MODE_A' in modes.keys():
                    if len(modes['MODE_A']) == 3:
                        self.modeaLineEdit.setText(
                            str(int(modes['MODE_A'][0] / 1000)))
                        self.modeaLowerLimitLineEdit.setText(
                            str(int(modes['MODE_A'][1])))
                        self.modeaUpperLimitLineEdit.setText(
                            str(int(modes['MODE_A'][2])))
            else:
                self.pushButtonStop.setEnabled(False)
                self.pushButtonStop.setText('Stop')

    def clearParams(self):
        self.modepLineEdit.setText('60')
        self.moderLineEdit.setText('')
        self.moderLowerLimitPercentLineEdit.setText('')
        self.moderUpperLimitPercentLineEdit.setText('')
        self.modeaLineEdit.setText('')
        self.modeaLowerLimitLineEdit.setText('')
        self.modeaUpperLimitLineEdit.setText('')

    def onCancel(self):
        self._Form.close()
Пример #6
0
class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        self._Form=Form
        self.font=QtGui.QFont()
        self.font.setBold(True)
        self.gridLayout_2 = QtGui.QGridLayout(Form)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.gridLayout = QtGui.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")

        self.chooseLabel=Qt.QLabel()
        self.chooseLabel.setObjectName("chooseLabel")
        self.chooseLabel.setFont(self.font)
        self.chooseLabel.setAlignment(QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.chooseLabel, 0, 0, 1, 1)

        self.tac=attributeChooser()
        self.tac.setObjectName("taurusAttributeChooser")
        self.gridLayout.addWidget(self.tac, 1, 0, 6, 1)
        
        self.selectedLabel=Qt.QLabel()
        self.selectedLabel.setObjectName("selectedLabel")
        self.selectedLabel.setFont(self.font)
        self.selectedLabel.setAlignment(QtCore.Qt.AlignCenter);
        self.selectedLabel.hide()
        self.gridLayout.addWidget(self.selectedLabel, 0, 1, 1, 6)

        self.tf=TaurusForm()
        self.tf.setWithButtons(False)
        self.tf.setObjectName("taurusForm")
        self.tf.hide()
        self.gridLayout.addWidget(self.tf, 1, 1, 1, 6)        
        self.label=Qt.QLabel()
        self.label.setObjectName("label")
        self.label.setFont(self.font)
        self.label.setAlignment(QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.label, 1, 1, 1, 6)
                
        spacerItem = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.gridLayout.addItem(spacerItem, 1, 1, 1, 1)
        
        self.modepLabel = QtGui.QLabel(Form)
        self.modepLabel.setObjectName("modepLabel")
        self.modepLabel.setText('Period [s]:')
        self.gridLayout.addWidget(self.modepLabel, 2, 1, 1, 1)        
        self.modepLineEdit = QtGui.QLineEdit(Form)
        self.modepLineEdit.setObjectName("modepLineEdit")
        self.modepLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form))
        self.modepLineEdit.setMaxLength(7)
        self.modepLineEdit.setMaximumWidth(60)
        self.modepLineEdit.setText('60.0')
        self.gridLayout.addWidget(self.modepLineEdit, 2, 2, 1, 1)                
        
        self.modeaLabel = QtGui.QLabel(Form)
        self.modeaLabel.setObjectName("modeaLabel")
        self.modeaLabel.setText('Absolute Period [s]:')
        self.gridLayout.addWidget(self.modeaLabel, 3, 1, 1, 1)
        self.modeaLineEdit = QtGui.QLineEdit(Form)
        self.modeaLineEdit.setObjectName("modeaLineEdit")
        self.modeaLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form))
        self.modeaLineEdit.setMaxLength(7)        
        self.modeaLineEdit.setMaximumWidth(60)
        self.modeaLineEdit.setText('15.0')        
        self.gridLayout.addWidget(self.modeaLineEdit, 3, 2, 1, 1)        
        self.modeaLowerLimitLabel = QtGui.QLabel(Form)
        self.modeaLowerLimitLabel.setObjectName("modeaLowerLimitLabel")
        self.modeaLowerLimitLabel.setText('Lower Limit (decr.):')
        self.gridLayout.addWidget(self.modeaLowerLimitLabel, 3, 3, 1, 1)                
        self.modeaLowerLimitLineEdit = QtGui.QLineEdit(Form)
        self.modeaLowerLimitLineEdit.setObjectName("modeaLowerLimitLineEdit")
        self.modeaLowerLimitLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 2, Form))
        self.modeaLowerLimitLineEdit.setMaxLength(7)        
        self.modeaLowerLimitLineEdit.setMaximumWidth(60)
        self.gridLayout.addWidget(self.modeaLowerLimitLineEdit, 3, 4, 1, 1)                
        self.modeaUpperLimitLabel = QtGui.QLabel(Form)
        self.modeaUpperLimitLabel.setObjectName("modeaUpperLimitLabel")
        self.modeaUpperLimitLabel.setText('Upper Limit (incr.):')
        self.gridLayout.addWidget(self.modeaUpperLimitLabel, 3, 5, 1, 1)                
        self.modeaUpperLimitLineEdit = QtGui.QLineEdit(Form)
        self.modeaUpperLimitLineEdit.setObjectName("modeaUpperLimitLineEdit")
        self.modeaUpperLimitLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 2, Form))
        self.modeaUpperLimitLineEdit.setMaxLength(7)        
        self.modeaUpperLimitLineEdit.setMaximumWidth(60)
        self.gridLayout.addWidget(self.modeaUpperLimitLineEdit, 3, 6, 1, 1)        
        
        self.moderLabel = QtGui.QLabel(Form)
        self.moderLabel.setObjectName("moderLabel")
        self.moderLabel.setText('Relative Period [s]:')
        self.gridLayout.addWidget(self.moderLabel, 4, 1, 1, 1)                        
        self.moderLineEdit = QtGui.QLineEdit(Form)
        self.moderLineEdit.setObjectName("moderLineEdit")
        self.moderLineEdit.setValidator(Qt.QDoubleValidator(1, 14400, 1, Form))
        self.moderLineEdit.setMaxLength(7)
        self.moderLineEdit.setMaximumWidth(60)
        self.moderLineEdit.setText('15.0')        
        self.gridLayout.addWidget(self.moderLineEdit, 4, 2, 1, 1)        
        self.moderLowerLimitPercentLabel = QtGui.QLabel(Form)
        self.moderLowerLimitPercentLabel.setObjectName("moderLowerLimitPercentLabel")
        self.moderLowerLimitPercentLabel.setText('Lower % Limit (decr.):')
        self.gridLayout.addWidget(self.moderLowerLimitPercentLabel, 4, 3, 1, 1)                        
        self.moderLowerLimitPercentLineEdit = QtGui.QLineEdit(Form)
        self.moderLowerLimitPercentLineEdit.setObjectName("moderLowerLimitPercentLineEdit")
        self.moderLowerLimitPercentLineEdit.setValidator(QtGui.QDoubleValidator(0, 1, 2, Form))
        self.moderLowerLimitPercentLineEdit.setMaxLength(7)
        self.moderLowerLimitPercentLineEdit.setMaximumWidth(60)
        self.gridLayout.addWidget(self.moderLowerLimitPercentLineEdit, 4, 4, 1, 1)     
        self.moderUpperLimitPercentLabel = QtGui.QLabel(Form)
        self.moderUpperLimitPercentLabel.setObjectName("moderUpperLimitPercentLabel")
        self.moderUpperLimitPercentLabel.setText('Upper % Limit (incr.):')
        self.gridLayout.addWidget(self.moderUpperLimitPercentLabel, 4, 5, 1, 1)                        
        self.moderUpperLimitPercentLineEdit = QtGui.QLineEdit(Form)
        self.moderUpperLimitPercentLineEdit.setObjectName("moderUpperLimitPercentLineEdit")
        self.moderUpperLimitPercentLineEdit.setValidator(Qt.QDoubleValidator(0, 1, 2, Form))
        self.moderUpperLimitPercentLineEdit.setMaxLength(7)
        self.moderUpperLimitPercentLineEdit.setMaximumWidth(60)
        self.gridLayout.addWidget(self.moderUpperLimitPercentLineEdit, 4, 6, 1, 1)             

        self.gridButtonLayout = QtGui.QGridLayout()
        self.gridButtonLayout.setObjectName("gridButtonLayout")               
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.gridButtonLayout.addItem(spacerItem, 0, 1, 1, 1)
        self.pushButtonStart = QtGui.QPushButton(Form)
        self.pushButtonStart.setObjectName("pushButtonStart")
        self.pushButtonStart.setEnabled(False)
        self.gridButtonLayout.addWidget(self.pushButtonStart, 0, 2, 1, 1)
        self.pushButtonStop = QtGui.QPushButton(Form)
        self.pushButtonStop.setObjectName("pushButtonStop")
        self.pushButtonStop.setEnabled(False)
        self.gridButtonLayout.addWidget(self.pushButtonStop, 0, 3, 1, 1)
        self.pushButtonCancel = QtGui.QPushButton(Form)
        self.pushButtonCancel.setObjectName("pushButtonCancel")
        self.gridButtonLayout.addWidget(self.pushButtonCancel, 0, 4, 1, 1)
        self.gridLayout.addLayout(self.gridButtonLayout, 5, 1, 1, 6)
        self.gridLayout_2.addLayout(self.gridLayout, 1, 0, 1, 1)
        
        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        Form.setWindowTitle(QtGui.QApplication.translate("Form", "Archiving Widget", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButtonStart.setText(QtGui.QApplication.translate("Form", "Start Archiving", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButtonStop.setText(QtGui.QApplication.translate("Form", "Stop", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButtonCancel.setText(QtGui.QApplication.translate("Form", "Close", None, QtGui.QApplication.UnicodeUTF8))
        self.label.setText(QtGui.QApplication.translate("Form", "Nothing to display", None, QtGui.QApplication.UnicodeUTF8))
        self.selectedLabel.setText(QtGui.QApplication.translate("Form", "Press start to start archiving selected attributes:", None, QtGui.QApplication.UnicodeUTF8))
        self.chooseLabel.setText(QtGui.QApplication.translate("Form", "Choose attributes to archive and hit apply to move attributes to selection", None, QtGui.QApplication.UnicodeUTF8))
        self.tf.connect(self.tac, Qt.SIGNAL("UpdateAttrs"), self.onUpdate)
        QtCore.QObject.connect(self.pushButtonStart, Qt.SIGNAL("clicked()"), self.onStart)
        QtCore.QObject.connect(self.pushButtonStop, Qt.SIGNAL("clicked()"), self.onStop)
        QtCore.QObject.connect(self.pushButtonCancel, Qt.SIGNAL("clicked()"), self.onCancel)
        QtCore.QObject.connect(self.modepLineEdit, Qt.SIGNAL('textChanged(const QString &)'), self.modepTextChanged)
        QtCore.QObject.connect(self.modeaLineEdit, Qt.SIGNAL('textChanged(const QString &)'), self.modeaTextChanged)
        QtCore.QObject.connect(self.moderLineEdit, Qt.SIGNAL('textChanged(const QString &)'), self.moderTextChanged)
        #QtCore.QObject.connect(self.moderUpperLimitPercentLineEdit, Qt.SIGNAL('editingFinished()'), self.moderUpperLimitPercentTextChanged)        
        #QtCore.QObject.connect(self.moderLowerLimitPercentLineEdit, Qt.SIGNAL('editingFinished()'), self.moderLowerLimitPercentTextChanged)                
        #QtCore.QObject.connect(self.modeaUpperLimitLineEdit, Qt.SIGNAL('editingFinished()'), self.modeaUpperLimitTextChanged)        
        #QtCore.QObject.connect(self.modeaLowerLimitLineEdit, Qt.SIGNAL('editingFinished()'), self.modeaLowerLimitTextChanged)                

    def modepTextChanged(self):
        if self.modepLineEdit.text():
            if (float(self.modepLineEdit.text()) < 1 or float(self.modepLineEdit.text()) > 14400):
                Qt.QMessageBox.critical(self._Form,'Error','Value ranges between 1 and 14400', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole)
                if float(self.modepLineEdit.text()) > 14400: self.modepLineEdit.setText('14400') 
                else: self.modepLineEdit.setText('1') 
        else:
            Qt.QMessageBox.critical(self._Form,'Error','Value ranges between 1 and 14400', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole)
            self.modepLineEdit.setText('1')
              
    def modeaTextChanged(self):
        if self.modeaLineEdit.text():
            if (float(self.modeaLineEdit.text()) > float(self.modepLineEdit.text())):
                Qt.QMessageBox.critical(self._Form,'Error','Value cannot be higher than '+self.modepLineEdit.text(), QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole)
                self.modeaLineEdit.setText('0') 

    def moderTextChanged(self):
        if self.moderLineEdit.text():
            if (float(self.moderLineEdit.text()) > float(self.modepLineEdit.text())):
                Qt.QMessageBox.critical(self._Form,'Error','Value cannot be higher than '+self.modepLineEdit.text(), QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole)
                self.moderLineEdit.setText('0') 
       
    def validate(self, modep, modea, moder):
        if (modep < modea or modep < moder):
            Qt.QMessageBox.critical(self._Form,'Error','Period value has to be higher than the others', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole)
            self.modepLineEdit.setText(str(10*max(int(self.moderLineEdit.text()), int(self.modeaLineEdit.text())))) 
            return False
        return True

    def floatValidation(self, line):
        val = line.text()
        try:
            float(val)
            return True
        except:
            Qt.QMessageBox.critical(self._Form,'Error in '+str(line.objectName()),'Wrong value !\nSetting value to 0!', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole)
            line.setText('0') 
            return False        

    def onStart(self):

        self.floatValidation(self.moderUpperLimitPercentLineEdit)
        self.floatValidation(self.moderLowerLimitPercentLineEdit)
        self.floatValidation(self.modeaUpperLimitLineEdit)
        self.floatValidation(self.modeaLowerLimitLineEdit)
        try:
            self.modep=int(1000*self.modepLineEdit.text())
            self.modea=(int(1000*self.modeaLineEdit.text()) if self.modeaLineEdit.text() else None)
            self.modeaLowerLimit=(float(self.modeaLowerLimitLineEdit.text()) if self.modeaLowerLimitLineEdit.text() else None)
            self.modeaUpperLimit=(float(self.modeaUpperLimitLineEdit.text()) if self.modeaUpperLimitLineEdit.text() else None)
            self.moder=(int(1000*self.moderLineEdit.text()) if self.moderLineEdit.text() else None)
            self.moderLowerLimit=(float(self.moderLowerLimitPercentLineEdit.text()) if self.moderLowerLimitPercentLineEdit.text() else None)
            self.moderUpperLimit=(float(self.moderUpperLimitPercentLineEdit.text()) if self.moderUpperLimitPercentLineEdit.text() else None)
            if self.validate(self.modep, self.modea, self.moder):
                reply=Qt.QMessageBox.question(self._Form,"Warning","Do you want to start archiving selected attributes?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes)
                if reply == QtGui.QMessageBox.Yes:
                    command={'MODE_P':[self.modep]}                    
                    if (self.modea and self.modeaUpperLimit and self.modeaLowerLimit): command['MODE_A']=[self.modea, self.modeaUpperLimit, self.modeaLowerLimit]
                    if (self.moder and self.moderUpperLimit and self.moderLowerLimit): command['MODE_R']=[self.moder, self.moderUpperLimit, self.moderLowerLimit]
                    attrs=[a for a in self.tf.getModel()]                    
                    cmd=self.tac.tdb.check_modes('tdb', command)
                    toStop=[a for a in attrs if a in self.tac.beingArchived]
                    try:
                        if toStop: self.tac.tdb.api.start_archiving(attrs, cmd, kill=True)
                        else: self.tac.tdb.api.start_archiving(attrs, cmd)
                    except:
                        Qt.QMessageBox.critical(self._Form,"Error",'Cannot start archiving process.\nCheck the state of archiving managers.', QtGui.QMessageBox.AcceptRole, QtGui.QMessageBox.AcceptRole)
                        print(traceback.format_exc())

                    self.tac.beingArchived=[a.lower() for a in self.tac.tdb if self.tac.tdb.is_attribute_archived(a.lower())] #update archived list
                    self.onUpdate(attrs)
                    self.tac.setNewDevName()
        except:
            print(traceback.format_exc())

    def onStop(self):
        toStop=[att.lower() for att in self.tf.getModel() if att.lower() in self.tac.beingArchived]
        reply=Qt.QMessageBox.question(self._Form,"Warning","Do you want to stop archiving "+str(len(toStop))+" attributes?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes)
        if reply == QtGui.QMessageBox.Yes:
            self.tac.tdb.api.stop_archiving(toStop)
            self.tac.beingArchived=[a.lower() for a in self.tac.tdb if self.tac.tdb.is_attribute_archived(a.lower())] #update archived list
            self.pushButtonStop.setEnabled(False)
            self.pushButtonStop.setText('Stop')
            self.tac.setNewDevName()
            self.clearParams()

    def onUpdate(self, attrs):
        self.clearParams()
        if not attrs:
            self.tf.hide()
            self.label.show()
            self.selectedLabel.hide()
            self.pushButtonStart.setEnabled(False)
            self.pushButtonStop.setEnabled(False)
            self.pushButtonStop.setText('Stop')
        else: 
            self.label.hide()
            self.selectedLabel.show()
            self.tf.show()
            self.tf.setModel(attrs)
            
            for i in range(len(attrs)):
                item=self.tf.getItemByIndex(i)
                if item.getModel().lower() in self.tac.beingArchived:
                    item.setExtraWidgetClass(historyButton)
                    historyButton().setModel(item.getModel())

            self.pushButtonStart.setEnabled(True)
            toStop=[att.lower() for att in attrs if att.lower() in self.tac.beingArchived]
            if toStop: 
                self.pushButtonStop.setEnabled(True)
                self.pushButtonStop.setText('Stop ('+str(len(toStop))+')')
                modes=self.tac.tdb.get(toStop[0]).modes
                if 'MODE_P' in modes.keys():
                    self.modepLineEdit.setText(str(int(modes['MODE_P'][0]/1000)))
                if 'MODE_R' in modes.keys():
                    if len(modes['MODE_R']) == 3: 
                        self.moderLineEdit.setText(str(int(modes['MODE_R'][0]/1000)))
                        self.moderLowerLimitPercentLineEdit.setText(str(float(modes['MODE_R'][1])))
                        self.moderUpperLimitPercentLineEdit.setText(str(float(modes['MODE_R'][2])))
                if 'MODE_A' in modes.keys(): 
                    if len(modes['MODE_A']) == 3: 
                        self.modeaLineEdit.setText(str(int(modes['MODE_A'][0]/1000)))
                        self.modeaLowerLimitLineEdit.setText(str(int(modes['MODE_A'][1])))
                        self.modeaUpperLimitLineEdit.setText(str(int(modes['MODE_A'][2])))
            else:
                self.pushButtonStop.setEnabled(False)
                self.pushButtonStop.setText('Stop')

    def clearParams(self):
        self.modepLineEdit.setText('60')
        self.moderLineEdit.setText('')
        self.moderLowerLimitPercentLineEdit.setText('')
        self.moderUpperLimitPercentLineEdit.setText('')
        self.modeaLineEdit.setText('')
        self.modeaLowerLimitLineEdit.setText('')
        self.modeaUpperLimitLineEdit.setText('')

    def onCancel(self):
        self._Form.close()
Пример #7
0
class IORUserPanel(TaurusWidget):

    """Widget to use the IOR"""

    def __init__(self, parent=None):
        TaurusWidget.__init__(self, parent)
        self._setup_ui()
        self.ior_model = None
        self.mot_model = None
        self.options = []
        self.dict =  {}

    def updateBoxes(self,arg):
        """ If receive signal to update the options, adjust the model"""
        if self.ior_model is not None and self.mot_model is not None : #only do it once initialised
            self.setModel(self.ior_model, self.mot_model,firstcall=False,updateIOR=True)

    def _setup_ui(self):

        self.gridLayout = QtGui.QGridLayout(self)
        self.taurusForm = TaurusForm(self)


        #form for the standard IOR widget
        self.taurusForm.setWithButtons(False)
        self.gridLayout.addWidget(self.taurusForm, 0, 0, 1, 2)

        #form for the standard motor widget
        self.taurusForm2 = TaurusForm(self)
        self.taurusForm2.setWithButtons(False)
        self.gridLayout.addWidget(self.taurusForm2, 1, 0, 1, 2)

        #form with a custom combo box - can replace the standard IOR widget
        #self.comboBox = TaurusValueComboBox(self)
        #self.comboBox.setAutoApply(True)
        #self.gridLayout.addWidget(self.comboBox, 2, 0, 1, 2)

        #self.label = TaurusLabel(self)
        #self.gridLayout.addWidget(self.label, 0, 1, 1, 1)

    def setModel(self, ior, mot, firstcall=False,updateIOR=False):

        self.ior_model = ior
        self.mot_model = mot
        self.updateIOR = updateIOR
        self.firstcall = firstcall

        #If we triggered a change, have the labels really changed, if so set model
        updated = False
        if self.firstcall or self.updateIOR:

            options = [(option.split(":")[0], option.split(":")[1])
                       for option in (taurus.Attribute(ior+"/Labels").read().value).split()]

            if options != self.options:
                updated = True
                self.options = options
                for opt in self.options:
                    self.dict[opt[0]] = opt[1]
                    #self.comboBox.setValueNames(self.options)

            #set the IOR widget
            try:
                self.taurusForm.setCustomWidgetMap(getattr(tauruscustomsettings,'T_FORM_CUSTOM_WIDGET_MAP',{}))
            except NameError:
                self.taurusForm.setCustomWidgetMap(getattr(TaurusCustomSettings,'T_FORM_CUSTOM_WIDGET_MAP',{}))
            self.taurusForm.setModel([self.ior_model])

            #set the motor widget
            try:
                self.taurusForm2.setCustomWidgetMap(getattr(tauruscustomsettings,'T_FORM_CUSTOM_WIDGET_MAP',{}))
            except NameError:
                self.taurusForm2.setCustomWidgetMap(getattr(TaurusCustomSettings,'T_FORM_CUSTOM_WIDGET_MAP',{}))
            self.taurusForm2.setModel([self.mot_model])

            if self.firstcall:

                #make ior widget auto apply settings
                for widget in self.taurusForm:
                    widget.writeWidget().setAutoApply(True)

                #connect combo box changes to method below
                #self.connect(self.comboBox, QtCore.SIGNAL('currentIndexChanged(const int &)'), self.indexChanged)

                #fill label
                #self.label.setModel(taurus.Attribute(ior+"/Value"))
                #get taurus attribute which is value and also motor pos
                self.position_ior = taurus.Attribute(ior+"/Value")