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 __init__(self, pvname, label): super(PvPushButton, self).__init__(label) self.setMaximumWidth(25) # Revisit self.clicked.connect(self.buttonClicked) self.pv = Pv(pvname, self.update)
class PvLabel: def __init__(self, parent, pvbase, name, dName=None, isInt=False): layout = QtWidgets.QHBoxLayout() label = QtWidgets.QLabel(name) label.setMinimumWidth(100) layout.addWidget(label) #layout.addStretch() self.__display = PvDisplay() self.__display.connect_signal() layout.addWidget(self.__display) parent.addLayout(layout) pvname = pvbase + name print(pvname) self.pv = Pv(pvname, self.update) if dName is not None: dPvName = pvbase + dName self.dPv = Pv(dPvName, self.update) else: self.dPv = None self.isInt = isInt def update(self, err): q = self.pv.get() if self.dPv is not None: dq = self.dPv.get() else: dq = None if err is None: s = QString('fail') try: if self.isInt: s = QString("%s (0x%s)") % (QString( int(q)), QString(format(int(q), 'x'))) if dq is not None: s = s + QString(" [%s (0x%s)]") % (QString( int(dq)), QString(format(int(dq), 'x'))) else: s = QString(q) if dq is not None: s = s + QString(" [%s]") % (QString(dq)) except: v = '' for i in range(len(q)): #v = v + ' %f'%q[i] v = v + ' ' + QString(q[i]) if dq is not None: v = v + QString(" [%s]") % (QString(dq[i])) #v = v + ' [' + '%f'%dq[i] + ']' if ((i % 8) == 7): v = v + '\n' s = QString(v) self.__display.valueSet.emit(s) else: print(err)
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)
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
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)
def __init__(self, parent, pvbase, name, dName=None, isInt=False): layout = QtWidgets.QHBoxLayout() label = QtWidgets.QLabel(name) label.setMinimumWidth(100) layout.addWidget(label) #layout.addStretch() self.__display = PvDisplay() self.__display.connect_signal() layout.addWidget(self.__display) parent.addLayout(layout) pvname = pvbase + name print(pvname) self.pv = Pv(pvname, self.update) if dName is not None: dPvName = pvbase + dName self.dPv = Pv(dPvName, self.update) else: self.dPv = None self.isInt = isInt
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)
class PvDblArray: def __init__(self, pv, widgets): self.widgets = widgets self.pv = Pv(pv, self.update) def update(self, err): q = self.pv.get() if err is None: for i in range(len(q)): self.widgets[i].valueSet.emit(QString(format(q[i], '4f'))) else: print(err)
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)
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)
class PvTxt(PvTextDisplay): def __init__(self, pv, label): super(PvTxt, self).__init__(label) self.connect_signal() self.pv = Pv(pv, self.update) def update(self, err): print('Update ' + pv) q = self.pv.get() if err is None: s = QString(q) self.valueSet.emit(s) else: print(err) def setPv(self): pass
def setupUi(self, MainWindow, base, partn, shelf): MainWindow.setObjectName("MainWindow") self.centralWidget = QtWidgets.QWidget(MainWindow) self.centralWidget.setObjectName("centralWidget") pvbase = base + ':XPM:' + shelf + ':' ppvbase = pvbase + 'PART:' + partn + ':' print('pvbase : ' + pvbase) print('ppvbase: ' + ppvbase) grid = QtWidgets.QGridLayout() textWidgets = [] for i in range(32): textWidgets.append(PvDblArrayW()) # Need to wait for pv.get() time.sleep(2) for i in range(14): pv = Pv(pvbase + 'LinkLabel%d' % i) grid.addWidget(QtWidgets.QLabel(pv.get()), i, 0) grid.addWidget(textWidgets[i], i, 1) for j in range(16, 21): i = j - 16 pv = Pv(pvbase + 'LinkLabel%d' % j) grid.addWidget(QtWidgets.QLabel(pv.get()), i, 2) grid.addWidget(textWidgets[j], i, 3) for j in range(28, 32): i = j - 22 grid.addWidget(QtWidgets.QLabel('INH-%d' % (j - 28)), i, 2) grid.addWidget(textWidgets[j], i, 3) self.deadflnk = PvDblArray(ppvbase + 'DeadFLnk', textWidgets) self.centralWidget.setLayout(grid) self.centralWidget.resize(240, 340) title = 'XPM:' + shelf + '\tPART:' + partn MainWindow.setWindowTitle(title) MainWindow.resize(240, 340) MainWindow.setCentralWidget(self.centralWidget)
def __init__(self, pv): super(PvEditTxt, self).__init__() self.connect_signal() self.editingFinished.connect(self.setPv) self.pv = Pv(pv, self.update)
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 __init__(self, pv, label): super(PvTxt, self).__init__(label) self.connect_signal() self.pv = Pv(pv, self.update)
def __init__(self, pv, widgets): self.widgets = widgets self.pv = Pv(pv, self.update)