Exemplo n.º 1
0
class PvPushButton(QtWidgets.QPushButton):

    valueSet = QtCore.pyqtSignal('QString', name='valueSet')

    def __init__(self, pvname, label):
        super(PvPushButton, self).__init__(label)
        self.setMaximumWidth(25)  # Revisit

        self.clicked.connect(self.buttonClicked)

        self.pv = Pv(pvname, self.update)

    def update(self, err):
        pass

    def buttonClicked(self):
        self.pv.put(1)  # Value is immaterial
Exemplo n.º 2
0
class PvEditCmb(PvComboDisplay):
    def __init__(self, pvname, choices):
        super(PvEditCmb, self).__init__(choices)
        self.connect_signal()
        self.currentIndexChanged.connect(self.setValue)

        self.pv = Pv(pvname, self.update)

    def setValue(self):
        value = self.currentIndex()
        self.pv.put(value)

    def update(self, err):
        q = self.pv.get()
        if err is None:
            self.setCurrentIndex(q)
            self.valueSet.emit(q)
        else:
            print(err)
Exemplo n.º 3
0
class PvCheckBox(CheckBox):
    def __init__(self, pvname, label):
        super(PvCheckBox, self).__init__(label)
        self.connect_signal()
        self.clicked.connect(self.pvClicked)

        self.pv = Pv(pvname)
        self.pv.monitor(self.update)

    def pvClicked(self):
        q = self.isChecked()
        self.pv.put(q)
        #print "PvCheckBox.clicked: pv %s q %x" % (self.pv.name, q)

    def update(self, err):
        #print "PvCheckBox.update:  pv %s, i %s, v %x, err %s" % (self.pv.name, self.text(), self.pv.get(), err)
        q = self.pv.get() != 0
        if err is None:
            if q != self.isChecked(): self.valueSet.emit(q)
        else:
            print(err)
Exemplo n.º 4
0
class PvDstTab(QtWidgets.QWidget):
    def __init__(self, pvname):
        super(PvDstTab, self).__init__()

        self.pv = Pv(pvname)

        self.chkBox = []
        layout = QtWidgets.QGridLayout()
        for i in range(ndestn):
            layout.addWidget(QtWidgets.QLabel('D%d' % i), i / 4, 2 * (i % 4))
            chkB = QtWidgets.QCheckBox()
            layout.addWidget(chkB, i / 4, 2 * (i % 4) + 1)
            chkB.clicked.connect(self.update)
            self.chkBox.append(chkB)
        self.setLayout(layout)

    def update(self):
        v = 0
        for i in range(ndestn):
            if self.chkBox[i].isChecked():
                v |= (1 << i)
        self.pv.put(v)
Exemplo n.º 5
0
class PvEditCmb(PvComboDisplay):
    def __init__(self, pvname, choices):
        super(PvEditCmb, self).__init__(choices)
        self.connect_signal()
        self.currentIndexChanged.connect(self.setValue)

        self.pv = Pv(pvname, self.update)

    def setValue(self):
        value = self.currentIndex()
        if self.pv.get() != value:
            self.pv.put(value)
        else:
            logger.debug(
                "Skipping updating PV for edit combobox as the value of the pv %s is the same as the current value",
                self.pv.pvname)

    def update(self, err):
        q = self.pv.get()
        if err is None:
            self.setCurrentIndex(q)
            self.valueSet.emit(str(q))
        else:
            print(err)