def _setupReliableMeasWidget(self): gbox_reliablemeas = QGroupBox('Measure Reliability Status', self) gbox_reliablemeas.setStyleSheet(""" .QLabel{min-height:1.29em; max-height:1.29em;} """) lay_reliablemeas = QGridLayout(gbox_reliablemeas) relmeas_count = self._db['ReliableMeasLabels-Cte']['count'] self.relmeas_labels = list() for idx in range(relmeas_count): led = SiriusLedAlert(parent=self, init_channel=self.dcct_prefix.substitute( propty='ReliableMeas-Mon'), bit=idx) lay_reliablemeas.addWidget(led, idx, 0) lbl = QLabel('', self) self.relmeas_labels.append(lbl) lay_reliablemeas.addWidget(lbl, idx, 1) lay_reliablemeas.setColumnStretch(0, 1) lay_reliablemeas.setColumnStretch(1, 10) self.reliablemeas_channel = _PV( self.dcct_prefix.substitute(propty='ReliableMeasLabels-Cte'), callback=self._updateReliableMeasLabels) return gbox_reliablemeas
def _setupStrengthWidget(self): scrollarea = QScrollArea() self.nconfig_data = QWidget() flay_configdata = QFormLayout() psnames = self._get_PSNames() self._map_psnames2wigdets = dict() for ps in psnames: ps = SiriusPVName(ps) if ps in ramp.BoosterRamp.PSNAME_DIPOLES: ps_value = QLabel(str(self.norm_config[ps])+' GeV', self) flay_configdata.addRow(QLabel(ps + ': ', self), ps_value) else: ps_value = QDoubleSpinBoxPlus(self.nconfig_data) ps_value.setDecimals(6) ps_value.setMinimum(-10000) ps_value.setMaximum(10000) ps_value.setValue(self.norm_config[ps]) ps_value.valueChanged.connect(self._handleStrenghtsSet) if ps.dev in {'QD', 'QF', 'QS'}: unit_txt = '1/m' elif ps.dev in {'SD', 'SF'}: unit_txt = '1/m²' else: unit_txt = 'urad' label_unit = QLabel(unit_txt, self) label_unit.setStyleSheet("min-width:2.5em; max-width:2.5em;") hb = QHBoxLayout() hb.addWidget(ps_value) hb.addWidget(label_unit) flay_configdata.addRow(QLabel(ps + ': ', self), hb) ps_value.setObjectName(ps) ps_value.setStyleSheet("min-height:1.29em; max-height:1.29em;") self._map_psnames2wigdets[ps] = ps_value self.nconfig_data.setObjectName('data') self.nconfig_data.setStyleSheet(""" #data{background-color: transparent;}""") self.nconfig_data.setLayout(flay_configdata) scrollarea.setWidget(self.nconfig_data) self.cb_checklims = QCheckBox('Set limits according to energy', self) self.cb_checklims.setChecked(False) self.cb_checklims.stateChanged.connect(self._handleStrengtsLimits) self.bt_graph = QPushButton(qta.icon('mdi.chart-line'), '', self) self.bt_graph.clicked.connect(self._show_kicks_graph) gbox = QGroupBox() gbox.setObjectName('strengths') gbox.setStyleSheet('#strengths{min-width:20em;}') glay = QGridLayout() glay.addWidget(scrollarea, 0, 0, 1, 2) glay.addWidget(self.cb_checklims, 1, 0, alignment=Qt.AlignLeft) glay.addWidget(self.bt_graph, 1, 1, alignment=Qt.AlignRight) gbox.setLayout(glay) return gbox
def _create_groupbox(self, title, widgets, orientation='V'): if not isinstance(widgets, list): widgets = [ widgets, ] gbox = QGroupBox(title, self) gbox.setStyleSheet('QGroupBox{font-size: 12pt; font-weight: bold;}') lay = QVBoxLayout(gbox) if orientation == 'V' else QHBoxLayout(gbox) lay.setAlignment(Qt.AlignCenter) lay.addStretch() for wid in widgets: lay.addWidget(wid) lay.addStretch() return gbox
def _setupUi(self): label = QLabel('<h3>' + self.scrn_prefix + ' Calibration</h3>', self, alignment=Qt.AlignCenter) positioning = QGroupBox('Positioning', self) positioning.setStyleSheet(""" .QLabel{ min-width:16em;\nmax-width:16em; qproperty-alignment: AlignRight;\n}""") positioning.setLayout(self._setupPositionLayout()) LED = QGroupBox('LED Brightness', self) LED.setStyleSheet(""" .QLabel{ min-width:11em;\nmax-width:11em; qproperty-alignment: AlignRight;\n}""") LED.setLayout(self._setupLEDLayout()) Img = QGroupBox('Statistics Unit Conversion (Pixels→mm)', self) Img.setStyleSheet(""" .QLabel{ min-width:12em;\nmax-width:12em; qproperty-alignment: AlignRight;\n}""") Img.setLayout(self._setupImageCalibLayout()) vlay = QVBoxLayout() vlay.addWidget(label) vlay.addItem( QSpacerItem(1, 10, QSzPlcy.Fixed, QSzPlcy.MinimumExpanding)) vlay.addWidget(positioning) vlay.addItem( QSpacerItem(1, 10, QSzPlcy.Fixed, QSzPlcy.MinimumExpanding)) vlay.addWidget(LED) vlay.addItem( QSpacerItem(1, 10, QSzPlcy.Fixed, QSzPlcy.MinimumExpanding)) vlay.addWidget(Img) self.setLayout(vlay)
class SiriusScrnView(QWidget): """ Class to read Sirius screen cameras image data. To allow saving a grid correctly, control calibrationgrid_flag, which indicates if the screen is in calibration grid position. You can control it by using the method/Slot updateCalibrationGridFlag. """ save_files = Signal() def __init__(self, parent=None, prefix=_VACA_PREFIX, device=None): """Initialize object.""" QWidget.__init__(self, parent=parent) self.prefix = prefix self.device = SiriusPVName(device) self.scrn_prefix = self.device.substitute(prefix=prefix) self._receivedData = False self.setObjectName(self.scrn_prefix.sec + 'App') self.screen_type_conn = SiriusConnectionSignal( self.scrn_prefix.substitute(propty='ScrnType-Sts')) self.screen_type_conn.new_value_signal.connect( self.updateCalibrationGridFlag) self._calibrationgrid_flag = self.screen_type_conn.getvalue() self.save_files.connect(self._saveGridLocalFiles) self.ch_ImgROIHeight = SiriusConnectionSignal( self.scrn_prefix.substitute(propty='ImgROIHeight-RB')) self.ch_ImgROIWidth = SiriusConnectionSignal( self.scrn_prefix.substitute(propty='ImgROIWidth-RB')) self.ch_ImgROIOffsetX = SiriusConnectionSignal( self.scrn_prefix.substitute(propty='ImgROIOffsetX-RB')) self.ch_ImgROIOffsetY = SiriusConnectionSignal( self.scrn_prefix.substitute(propty='ImgROIOffsetY-RB')) self._setupUi() self.setFocus(True) self.setFocusPolicy(Qt.StrongFocus) self._loadCalibrationGrid(default=True) @property def calibrationgrid_flag(self): """Indicate if the screen device is in calibration grid position.""" return self._calibrationgrid_flag @Slot(int) def updateCalibrationGridFlag(self, new_state): """Update calibrationgrid_flag property.""" self._calibrationgrid_flag = new_state if new_state == 1: self.pushbutton_savegrid.setEnabled(True) else: self.pushbutton_savegrid.setEnabled(False) def _setupUi(self): self.cameraview_widget = QWidget() self.cameraview_widget.setLayout(self._cameraviewLayout()) self.settings_widget = QWidget(self) self.settings_widget.setLayout(self._settingsLayout()) self.settings_widget.setStyleSheet(""" .QLabel{ min-width: 5em;} QLabel{ qproperty-alignment: AlignCenter;}""") self.calibrationgrid_widget = QWidget(self) self.calibrationgrid_widget.setLayout(self._calibrationgridLayout()) self.calibrationgrid_widget.setSizePolicy(QSzPlcy.Expanding, QSzPlcy.Expanding) self.calibrationgrid_widget.layout().setAlignment(Qt.AlignHCenter) self.tab = QTabWidget(self) self.tab.setStyleSheet(""" QTabWidget::pane { border-left: 2px solid gray; border-bottom: 2px solid gray; border-right: 2px solid gray; }""") self.tab.addTab(self.settings_widget, 'Camera Settings') self.tab.addTab(self.calibrationgrid_widget, 'Calibration') self.statistics_groupBox = QGroupBox('Statistics', self) self.statistics_groupBox.setLayout(self._statisticsLayout()) self.statistics_groupBox.setSizePolicy(QSzPlcy.Expanding, QSzPlcy.Expanding) self.statistics_groupBox.setStyleSheet(""" .QLabel{ min-width:0.28em; max-width:0.28em; min-height:1.29em; max-height:1.29em;} QLabel{ qproperty-alignment: AlignCenter;} PyDMWidget{ min-width:4.84em; max-width:4.84em; min-height:1.29em; max-height:1.29em;}""") self.trigger_groupBox = QGroupBox('Trigger', self) if 'TB' in self.device or 'BO' in self.device: trg_prefix = 'AS-Fam:TI-Scrn-TBBO' elif 'TS' in self.device: trg_prefix = 'TS-Fam:TI-Scrn' hbl = QHBoxLayout(self.trigger_groupBox) hbl.addWidget( HLTriggerSimple(parent=self.trigger_groupBox, device=trg_prefix, prefix=self.prefix)) self.trigger_groupBox.setLayout(hbl) self.trigger_groupBox.setStyleSheet(""" PyDMWidget{ min-width:4.84em; max-width:4.84em; min-height:1.29em; max-height:1.29em;}""") vlay = QVBoxLayout() vlay.addWidget(self.statistics_groupBox) vlay.addWidget(self.trigger_groupBox) vlay.setSpacing(10) lay = QGridLayout(self) lay.setHorizontalSpacing(10) lay.setVerticalSpacing(10) lay.addWidget(self.cameraview_widget, 0, 0, 1, 2) lay.addWidget(self.tab, 1, 0) lay.addLayout(vlay, 1, 1) lay.setRowStretch(0, 15) lay.setRowStretch(1, 7) def _cameraviewLayout(self): label = QLabel(self.device, self) label.setStyleSheet("""font-weight: bold;max-height:1.29em;""") label.setAlignment(Qt.AlignCenter) self.image_view = _SiriusImageView( parent=self, image_channel=self.scrn_prefix.substitute(propty='ImgData-Mon'), width_channel=self.scrn_prefix.substitute(propty='ImgROIWidth-RB'), offsetx_channel=self.scrn_prefix.substitute( propty='ImgROIOffsetX-RB'), offsety_channel=self.scrn_prefix.substitute( propty='ImgROIOffsetY-RB'), maxwidth_channel=self.scrn_prefix.substitute( propty='ImgMaxWidth-Cte'), maxheight_channel=self.scrn_prefix.substitute( propty='ImgMaxHeight-Cte')) self.image_view.setObjectName('ScrnView') self.image_view.normalizeData = True self.image_view.readingOrder = self.image_view.Clike self.image_view.maxRedrawRate = 15 self.image_view.setStyleSheet(""" #ScrnView{min-width:30em; min-height:24em;}""") self.image_view.failToSaveGrid.connect(self._showFailToSaveGridMsg) self.image_view.receivedData.connect(self._setReceivedDataFlag) lay = QGridLayout() lay.setContentsMargins(0, 0, 0, 0) lay.addWidget(label, 0, 1) lay.addItem(QSpacerItem(40, 2, QSzPlcy.Preferred, QSzPlcy.Fixed), 1, 1) lay.addWidget(self.image_view, 2, 1) return lay def _calibrationgridLayout(self): self.checkBox_showgrid = QCheckBox('Show', self) self.checkBox_showgrid.setEnabled(False) self.checkBox_showgrid.setStyleSheet(""" min-width:4em; max-width:4em; min-height:1.29em; max-height:1.29em;""") self.checkBox_showgrid.toggled.connect( self.image_view.showCalibrationGrid) self.pushbutton_savegrid = QPushButton('Save', self) self.pushbutton_savegrid.setEnabled(False) self.pushbutton_savegrid.setStyleSheet(""" min-width:4em; max-width:4em; min-height:1.29em; max-height:1.29em;""") self.pushbutton_savegrid.clicked.connect(self._saveCalibrationGrid) self.pushbutton_loadgrid = QPushButton('Load', self) self.pushbutton_loadgrid.setStyleSheet(""" min-width:4em; max-width:4em; min-height:1.29em; max-height:1.29em;""") self.pushbutton_loadgrid.clicked.connect(self._loadCalibrationGrid) hbox_grid = QHBoxLayout() hbox_grid.addWidget(self.checkBox_showgrid) hbox_grid.addWidget(self.pushbutton_savegrid) hbox_grid.addWidget(self.pushbutton_loadgrid) lb = QLabel('Show levels <') lb.setStyleSheet("min-width:7em;max-width:7em;") self.spinbox_gridfilterfactor = QSpinBoxPlus() self.spinbox_gridfilterfactor.setMaximum(100) self.spinbox_gridfilterfactor.setMinimum(0) self.spinbox_gridfilterfactor.setValue( self.image_view.calibration_grid_filterfactor) self.spinbox_gridfilterfactor.editingFinished.connect( self._setCalibrationGridFilterFactor) self.spinbox_gridfilterfactor.setStyleSheet(""" min-width:4em; max-width:4em;""") hbox_filter = QHBoxLayout() hbox_filter.setSpacing(0) hbox_filter.addWidget(lb) hbox_filter.addWidget(self.spinbox_gridfilterfactor) hbox_filter.addWidget(QLabel(' %')) lb = QLabel('Remove border: ') lb.setStyleSheet("min-width:7em;max-width:7em;") self.spinbox_removeborder = QSpinBoxPlus() self.spinbox_removeborder.setMaximum(512) self.spinbox_removeborder.setMinimum(0) self.spinbox_removeborder.setValue( self.image_view.calibration_grid_removeborder) self.spinbox_removeborder.editingFinished.connect( self._setCalibrationGridBorder2Remove) self.spinbox_removeborder.setStyleSheet(""" min-width:4em; max-width:4em;""") hbox_remove = QHBoxLayout() hbox_remove.setSpacing(0) hbox_remove.addWidget(lb) hbox_remove.addWidget(self.spinbox_removeborder) hbox_remove.addWidget(QLabel(' px')) hbox_EnblLED = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='EnblLED', propty_type='enbldisabl', width=4.68) lay = QFormLayout() lay.addItem(QSpacerItem(1, 10, QSzPlcy.Ignored, QSzPlcy.Preferred)) lay.addRow(' Grid: ', hbox_grid) lay.addItem(QSpacerItem(1, 10, QSzPlcy.Ignored, QSzPlcy.Preferred)) lay.addRow(' ', hbox_filter) lay.addRow(' ', hbox_remove) lay.addItem(QSpacerItem(1, 20, QSzPlcy.Ignored, QSzPlcy.Preferred)) lay.addRow(' LED: ', hbox_EnblLED) lay.addItem(QSpacerItem(1, 10, QSzPlcy.Ignored, QSzPlcy.Preferred)) lay.setLabelAlignment(Qt.AlignRight) lay.setFormAlignment(Qt.AlignCenter) return lay def _settingsLayout(self): label_CamEnbl = QLabel('Enable: ', self) hbox_CamEnbl = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='CamEnbl', propty_type='enbldisabl') label_CamAcqPeriod = QLabel('Acquire\nPeriod [s]:', self) hbox_CamAcqPeriod = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='CamAcqPeriod', propty_type='sprb', width=5.0) label_CamExposureTime = QLabel('Exposure\nTime [us]:', self) hbox_CamExposureTime = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='CamExposureTime', propty_type='sprb', width=5.0) label_CamGain = QLabel('Gain[dB]:', self) hbox_CamGain = _create_propty_layout(parent=self, prefix=self.scrn_prefix, propty='CamGain', width=5.0, propty_type='sprb') label_AutoGain = QLabel('Auto Gain: ', self) self.pb_autogain = PyDMPushButton( label='', icon=qta.icon('mdi.auto-fix'), parent=self, pressValue=1, init_channel=self.scrn_prefix.substitute(propty='CamAutoGain-Cmd')) self.pb_autogain.setObjectName('autog') self.pb_autogain.setStyleSheet( "#autog{min-width:25px; max-width:25px; icon-size:20px;}") cam_prefix = SiriusPVName(self.scrn_prefix).substitute(dev='ScrnCam') label_Reset = QLabel('Reset: ', self) self.pb_dtl = PyDMPushButton( label='', icon=qta.icon('fa5s.sync'), parent=self, pressValue=1, init_channel=cam_prefix.substitute(propty='Rst-Cmd')) self.pb_dtl.setObjectName('reset') self.pb_dtl.setStyleSheet( "#reset{min-width:25px; max-width:25px; icon-size:20px;}") self.pb_details = QPushButton(qta.icon('fa5s.ellipsis-h'), '', self) self.pb_details.setToolTip('More settings') self.pb_details.setObjectName('detail') self.pb_details.setStyleSheet( "#detail{min-width:25px; max-width:25px; icon-size:20px;}") self.pb_details.setSizePolicy(QSzPlcy.Expanding, QSzPlcy.Preferred) util.connect_window(self.pb_details, _ScrnSettingsDetails, parent=self, prefix=self.prefix, device=self.device) hbox_aux = QHBoxLayout() hbox_aux.addWidget(self.pb_dtl, alignment=Qt.AlignLeft) hbox_aux.addWidget(self.pb_details, alignment=Qt.AlignRight) lay = QFormLayout() lay.setFormAlignment(Qt.AlignCenter) lay.addRow(label_CamEnbl, hbox_CamEnbl) lay.addRow(label_CamAcqPeriod, hbox_CamAcqPeriod) lay.addRow(label_CamExposureTime, hbox_CamExposureTime) lay.addRow(label_CamGain, hbox_CamGain) lay.addRow(label_AutoGain, self.pb_autogain) lay.addRow(label_Reset, hbox_aux) return lay def _statisticsLayout(self): # - Method label_Method = QLabel('CalcMethod:', self) label_Method.setStyleSheet("min-width:7em;") self.comboBox_Method = QComboBox(self) self.comboBox_Method.addItem('DimFei', 0) self.comboBox_Method.addItem('NDStats', 1) self.comboBox_Method.setCurrentIndex(0) self.comboBox_Method.setStyleSheet(""" QComboBox::item {height: 1em;} QComboBox{min-width:6em;}""") self.comboBox_Method.currentIndexChanged.connect( self._handleShowStatistics) # - Centroid label_Centroid = QLabel('Centroid [mm]: ', self) label_Centroid.setStyleSheet("min-width:7em;") label_i_Center = QLabel('(', self) self.PyDMLabel_CenterXDimFei = PyDMLabel( parent=self, init_channel=self.scrn_prefix.substitute( propty='CenterXDimFei-Mon')) self.PyDMLabel_CenterXDimFei.setStyleSheet( 'min-width:4em; max-width:4em;') self.PyDMLabel_CenterXNDStats = PyDMLabel( parent=self, init_channel=self.scrn_prefix.substitute( propty='CenterXNDStats-Mon')) self.PyDMLabel_CenterXNDStats.setStyleSheet( 'min-width:4em; max-width:4em;') self.PyDMLabel_CenterXNDStats.setVisible(False) label_m_Center = QLabel(',', self) self.PyDMLabel_CenterYDimFei = PyDMLabel( parent=self, init_channel=self.scrn_prefix.substitute( propty='CenterYDimFei-Mon')) self.PyDMLabel_CenterYDimFei.setStyleSheet( 'min-width:4em; max-width:4em;') self.PyDMLabel_CenterYNDStats = PyDMLabel( parent=self, init_channel=self.scrn_prefix.substitute( propty='CenterYNDStats-Mon')) self.PyDMLabel_CenterYNDStats.setStyleSheet( 'min-width:4em; max-width:4em;') self.PyDMLabel_CenterYNDStats.setVisible(False) label_f_Center = QLabel(')', self) # - Sigma label_Sigma = QLabel('Sigma [mm]: ', self) label_Sigma.setStyleSheet("min-width:7em;") label_i_Sigma = QLabel('(', self) self.PyDMLabel_SigmaXDimFei = PyDMLabel( parent=self, init_channel=self.scrn_prefix.substitute( propty='SigmaXDimFei-Mon')) self.PyDMLabel_SigmaXDimFei.setStyleSheet( 'min-width:4em; max-width:4em;') self.PyDMLabel_SigmaXNDStats = PyDMLabel( parent=self, init_channel=self.scrn_prefix.substitute( propty='SigmaXNDStats-Mon')) self.PyDMLabel_SigmaXNDStats.setStyleSheet( 'min-width:4em; max-width:4em;') self.PyDMLabel_SigmaXNDStats.setVisible(False) label_m_Sigma = QLabel(',', self) self.PyDMLabel_SigmaYDimFei = PyDMLabel( parent=self, init_channel=self.scrn_prefix.substitute( propty='SigmaYDimFei-Mon')) self.PyDMLabel_SigmaYDimFei.setStyleSheet( 'min-width:4em; max-width:4em;') self.PyDMLabel_SigmaYNDStats = PyDMLabel( parent=self, init_channel=self.scrn_prefix.substitute( propty='SigmaYNDStats-Mon')) self.PyDMLabel_SigmaYNDStats.setStyleSheet( 'min-width:4em; max-width:4em;') self.PyDMLabel_SigmaYNDStats.setVisible(False) label_f_Sigma = QLabel(')', self) # - Theta label_Theta = QLabel('Theta [rad]: ') label_Theta.setStyleSheet("min-width:7em;") label_i_Theta = QLabel('(', self) self.PyDMLabel_ThetaDimFei = PyDMLabel( parent=self, init_channel=self.scrn_prefix.substitute(propty='ThetaDimFei-Mon')) self.PyDMLabel_ThetaDimFei.setStyleSheet("max-width:12em;") self.PyDMLabel_ThetaNDStats = PyDMLabel( parent=self, init_channel=self.scrn_prefix.substitute( propty='ThetaNDStats-Mon')) self.PyDMLabel_ThetaNDStats.setStyleSheet("max-width:12em;") self.PyDMLabel_ThetaNDStats.setVisible(False) label_f_Theta = QLabel(')', self) lay = QGridLayout() lay.addWidget(label_Method, 1, 1, 1, 3) lay.addWidget(self.comboBox_Method, 1, 3, 1, 3) lay.addWidget(label_Centroid, 3, 1, alignment=Qt.AlignCenter) lay.addWidget(label_i_Center, 3, 2) lay.addWidget(self.PyDMLabel_CenterXDimFei, 3, 3) lay.addWidget(self.PyDMLabel_CenterXNDStats, 3, 3) lay.addWidget(label_m_Center, 3, 4) lay.addWidget(self.PyDMLabel_CenterYDimFei, 3, 5) lay.addWidget(self.PyDMLabel_CenterYNDStats, 3, 5) lay.addWidget(label_f_Center, 3, 6) lay.addWidget(label_Sigma, 5, 1, alignment=Qt.AlignCenter) lay.addWidget(label_i_Sigma, 5, 2) lay.addWidget(self.PyDMLabel_SigmaXDimFei, 5, 3) lay.addWidget(self.PyDMLabel_SigmaXNDStats, 5, 3) lay.addWidget(label_m_Sigma, 5, 4) lay.addWidget(self.PyDMLabel_SigmaYDimFei, 5, 5) lay.addWidget(self.PyDMLabel_SigmaYNDStats, 5, 5) lay.addWidget(label_f_Sigma, 5, 6) lay.addWidget(label_Theta, 7, 1, alignment=Qt.AlignCenter) lay.addWidget(label_i_Theta, 7, 2) lay.addWidget(self.PyDMLabel_ThetaDimFei, 7, 3, 1, 3) lay.addWidget(self.PyDMLabel_ThetaNDStats, 7, 3, 1, 3) lay.addWidget(label_f_Theta, 7, 6) return lay def _handleShowStatistics(self, visible): self.PyDMLabel_CenterXDimFei.setVisible(not visible) self.PyDMLabel_CenterXNDStats.setVisible(visible) self.PyDMLabel_CenterYDimFei.setVisible(not visible) self.PyDMLabel_CenterYNDStats.setVisible(visible) self.PyDMLabel_ThetaDimFei.setVisible(not visible) self.PyDMLabel_ThetaNDStats.setVisible(visible) self.PyDMLabel_SigmaXDimFei.setVisible(not visible) self.PyDMLabel_SigmaXNDStats.setVisible(visible) self.PyDMLabel_SigmaYDimFei.setVisible(not visible) self.PyDMLabel_SigmaYNDStats.setVisible(visible) def _saveCalibrationGrid(self): t = Thread(target=self._saveCalibrationGrid_thread, daemon=True) t.start() def _saveCalibrationGrid_thread(self): roi_h = float(self.ch_ImgROIHeight.value) roi_w = float(self.ch_ImgROIWidth.value) roi_offsetx = float(self.ch_ImgROIOffsetX.value) roi_offsety = float(self.ch_ImgROIOffsetY.value) cond = roi_h != float(self.image_view.image_maxheight) or \ roi_w != float(self.image_view.image_maxwidth) or \ roi_offsetx != 0 or roi_offsety != 0 if cond: # Disable camera acquisition and wait for disabling self.PyDMStateButton_CamEnbl.send_value_signal[int].emit(0) state = self.SiriusLedState_CamEnbl.state while state == 1: time.sleep(0.1) state = self.SiriusLedState_CamEnbl.state # Change ROI to get entire image self.ch_ImgROIHeight.send_value_signal[float].emit( float(self.image_view.image_maxheight)) self.ch_ImgROIWidth.send_value_signal[float].emit( float(self.image_view.image_maxwidth)) self.ch_ImgROIOffsetX.send_value_signal[float].emit(0) self.ch_ImgROIOffsetY.send_value_signal[float].emit(0) # Enable led and wait for status self.PyDMStateButton_EnblLED.send_value_signal[int].emit(1) while not self.SiriusLedState_EnblLED.state: time.sleep(0.1) # Enable camera acquisition and wait for receiveing first frame self._receivedData = False self.PyDMStateButton_CamEnbl.send_value_signal[int].emit(1) while not self._receivedData: time.sleep(0.1) # Save grid self.image_view.saveCalibrationGrid() if cond: # Disable camera acquisition and wait for disabling self.PyDMStateButton_CamEnbl.send_value_signal[int].emit(0) state = self.SiriusLedState_CamEnbl.state while state == 1: time.sleep(0.1) state = self.SiriusLedState_CamEnbl.state # Change ROI to original size self.ch_ImgROIHeight.send_value_signal[float].emit(roi_h) self.ch_ImgROIWidth.send_value_signal[float].emit(roi_w) self.ch_ImgROIOffsetX.send_value_signal[float].emit(roi_offsetx) self.ch_ImgROIOffsetY.send_value_signal[float].emit(roi_offsety) # Enable camera acquisition self.PyDMStateButton_CamEnbl.send_value_signal[int].emit(1) # Enable showing saved grid time.sleep(0.1) self.checkBox_showgrid.setEnabled(True) self.save_files.emit() def _saveGridLocalFiles(self): home = os.path.expanduser('~') folder_month = datetime.now().strftime('%Y-%m') folder_day = datetime.now().strftime('%Y-%m-%d') path = os.path.join(home, 'mounts', 'screens-iocs', folder_month, folder_day) if not os.path.exists(path): os.makedirs(path) fn, _ = QFileDialog.getSaveFileName( self, 'Save Grid As...', path + '/' + self.device + datetime.now().strftime('_%Y-%m-%d_%Hh%Mmin'), '*.npy') if not fn: return False path_default = os.path.join(home, 'mounts', 'screens-iocs', 'default') if not os.path.exists(path_default): os.makedirs(path_default) fn_default = path_default + '/' + self.device grid = self.image_view.calibrationGrid width = self.image_view.imageWidth data = np.append(width, grid) np.save(fn, data) np.save(fn_default, data) def _loadCalibrationGrid(self, default=False): home = os.path.expanduser('~') if not default: folder_month = datetime.now().strftime('%Y-%m') path = os.path.join(home, 'mounts', 'screens-iocs', folder_month) fn, _ = QFileDialog.getOpenFileName(self, 'Load Grid...', path, '*.npy') if not fn: return if self.device not in fn: ans = QMessageBox.question( self, 'Warning', 'The name of the selected file does not contain the name' + ' of this screen. Are you sure you\'re loading this grid?', QMessageBox.Yes, QMessageBox.Cancel) if ans == QMessageBox.Cancel: return else: path = os.path.join(home, 'mounts', 'screens-iocs', 'default') fn = path + '/' + self.device + '.npy' try: data = np.load(fn) self.image_view.calibrationGrid = data except Exception as e: if not default: QMessageBox.critical( self, 'Error', 'Could not load calibration grid from file ' + fn + '. ' + '\nError message: ' + str(e), QMessageBox.Ok) return # Enable showing saved grid self.checkBox_showgrid.setEnabled(True) def _setReceivedDataFlag(self): self._receivedData = True def _setCalibrationGridFilterFactor(self): self.image_view.set_calibration_grid_filterfactor( self.spinbox_gridfilterfactor.value()) def _setCalibrationGridBorder2Remove(self): self.image_view.set_calibration_grid_border2remove( self.spinbox_removeborder.value()) @Slot() def _showFailToSaveGridMsg(self): QMessageBox.warning(self, 'Warning', 'Could not save calibration grid!', QMessageBox.Ok)
def _setupControlsWidget(self): ld_acqtime = QLabel('Acquisition Time [ms]', self) sb_acqtime = PyDMSpinbox(self, self.dev_pref + ':SB_ACQTIME') sb_acqtime.showStepExponent = False ld_bunid = QLabel('Bunch Number', self) sb_bunid = PyDMSpinbox(self, self.dev_pref + ':SB_BUNCH_ID') sb_bunid.showStepExponent = False ld_acqsmpl = QLabel('Acq Samples', self) lb_acqsmpl = PyDMLabel(self, self.dev_pref + ':SB_ACQ_SAMPLES') ld_currbun = QLabel('Current Bunch', self) lb_currbun = PyDMLabel(self, self.dev_pref + ':SB_RAW_BUNCH_ID') gbox_dtacq = QGroupBox('Data Acquisition', self) lay_dtacq = QGridLayout(gbox_dtacq) lay_dtacq.addWidget(ld_acqtime, 0, 0) lay_dtacq.addWidget(sb_acqtime, 0, 1) lay_dtacq.addWidget(ld_bunid, 1, 0) lay_dtacq.addWidget(sb_bunid, 1, 1) lay_dtacq.addWidget(ld_acqsmpl, 2, 0) lay_dtacq.addWidget(lb_acqsmpl, 2, 1) lay_dtacq.addWidget(ld_currbun, 3, 0) lay_dtacq.addWidget(lb_currbun, 3, 1) ld_trgexten = QLabel('Internal/External', self) cb_trgexten = PyDMEnumComboBox(self, self.dev_pref + ':SB_EXTEN') ld_trginsel = QLabel('Selection', self) cb_trginsel = PyDMEnumComboBox(self, self.dev_pref + ':SB_TRIG_IN_SEL') ld_trgarm = QLabel('Arm', self) cb_trgarm = PyDMStateButton(self, self.dev_pref + ':SB_ARM') lb_armmon = SiriusLedState(self, self.dev_pref + ':SB_ARM_MON') ld_trgbrarm = QLabel('Auto re-arm', self) cb_trgbrarm = PyDMStateButton(self, self.dev_pref + ':SB_BR_ARM') gbox_trig = QGroupBox('Trigger', self) lay_trig = QGridLayout(gbox_trig) lay_trig.addWidget(ld_trgexten, 0, 0) lay_trig.addWidget(cb_trgexten, 0, 1, 1, 2) lay_trig.addWidget(ld_trginsel, 1, 0) lay_trig.addWidget(cb_trginsel, 1, 1, 1, 2) lay_trig.addWidget(ld_trgarm, 2, 0) lay_trig.addWidget(cb_trgarm, 2, 1) lay_trig.addWidget(lb_armmon, 2, 2) lay_trig.addWidget(ld_trgbrarm, 3, 0) lay_trig.addWidget(cb_trgbrarm, 3, 1) ld_phtrkctrl = QLabel('<h4>Controls</h4>', self, alignment=Qt.AlignCenter) ld_bunnr = QLabel('Bunch Number', self) sb_bunnr = PyDMSpinbox(self, self.dev_pref + ':SB_BUNCH_ID') sb_bunnr.showStepExponent = False ld_gain = QLabel('Gain', self) sb_gain = PyDMSpinbox(self, self.dev_pref + ':PHTRK_GAIN') sb_gain.showStepExponent = False ld_sp = QLabel('Setpoint [deg]', self) sb_sp = PyDMSpinbox(self, self.dev_pref + ':PHTRK_SETPT') sb_sp.showStepExponent = False ld_range = QLabel('Range [kHz]', self) sb_range = PyDMSpinbox(self, self.dev_pref + ':PHTRK_RANGE') sb_range.showStepExponent = False ld_dec = QLabel('Decimation', self) sb_dec = PyDMSpinbox(self, self.dev_pref + ':PHTRK_DECIM') sb_dec.showStepExponent = False ld_rate = QLabel('Rate', self) lb_rate = PyDMLabel(self, self.dev_pref + ':PHTRK_RATE') lb_rate.showUnits = True ld_bw = QLabel('Bandwidth', self) lb_bw = PyDMLabel(self, self.dev_pref + ':PHTRK_BANDWIDTH') lb_bw.showUnits = True ld_loopctrl = QLabel('Loop Control', self) cb_loopctrl = PyDMStateButton(self, self.dev_pref + ':PHTRK_LOOPCTRL') ld_drv2 = QLabel('Use Drive 2', self) cb_drv2 = PyDMStateButton(self, self.dev_pref + ':DRIVE2_TRACK') ld_mod = QLabel('Modulation', self) cb_mod = PyDMStateButton(self, self.dev_pref + ':PHTRK_MOD') lay_phtrkctrl = QGridLayout() lay_phtrkctrl.addWidget(ld_phtrkctrl, 0, 0, 1, 2) lay_phtrkctrl.addWidget(ld_bunnr, 1, 0) lay_phtrkctrl.addWidget(sb_bunnr, 1, 1) lay_phtrkctrl.addWidget(ld_gain, 2, 0) lay_phtrkctrl.addWidget(sb_gain, 2, 1) lay_phtrkctrl.addWidget(ld_sp, 3, 0) lay_phtrkctrl.addWidget(sb_sp, 3, 1) lay_phtrkctrl.addWidget(ld_range, 4, 0) lay_phtrkctrl.addWidget(sb_range, 4, 1) lay_phtrkctrl.addWidget(ld_dec, 5, 0) lay_phtrkctrl.addWidget(sb_dec, 5, 1) lay_phtrkctrl.addWidget(ld_rate, 6, 0) lay_phtrkctrl.addWidget(lb_rate, 6, 1) lay_phtrkctrl.addWidget(ld_bw, 7, 0) lay_phtrkctrl.addWidget(lb_bw, 7, 1) lay_phtrkctrl.addWidget(ld_loopctrl, 8, 0) lay_phtrkctrl.addWidget(cb_loopctrl, 8, 1) lay_phtrkctrl.addWidget(ld_drv2, 9, 0) lay_phtrkctrl.addWidget(cb_drv2, 9, 1) lay_phtrkctrl.addWidget(ld_mod, 10, 0) lay_phtrkctrl.addWidget(cb_mod, 10, 1) ld_phtrkdata = QLabel('<h4>Data</h4>', self, alignment=Qt.AlignCenter) ld_mag = QLabel('Magnitude', self) lb_mag = PyDMLabel(self, self.dev_pref + ':PHTRK_MAG') lb_mag.showUnits = True ld_trgain = QLabel('Transfer Gain', self) lb_trgain = PyDMLabel(self, self.dev_pref + ':PHTRK_TFGAIN') lb_trgain.showUnits = True ld_nshift = QLabel('Normalizing Shift', self) lb_nshift = PyDMLabel(self, self.dev_pref + ':PHTRK_SHIFT') ld_phase = QLabel('Phase', self) lb_phase = PyDMLabel(self, self.dev_pref + ':PHTRK_PHASE') lb_phase.showUnits = True ld_error = QLabel('Error', self) lb_error = PyDMLabel(self, self.dev_pref + ':PHTRK_ERROR') lb_error.showUnits = True ld_trfreq = QLabel('Tracking Frequency', self) lb_trfreq = PyDMLabel(self, self.dev_pref + ':PHTRK_FREQ0') lb_trfreq.showUnits = True ld_trtune = QLabel('Tracking Tune', self) lb_trtune = PyDMLabel(self, self.dev_pref + ':PHTRK_TUNE') lay_phtrkdata = QGridLayout() lay_phtrkdata.addWidget(ld_phtrkdata, 0, 0, 1, 2) lay_phtrkdata.addWidget(ld_mag, 1, 0) lay_phtrkdata.addWidget(lb_mag, 1, 1) lay_phtrkdata.addWidget(ld_trgain, 2, 0) lay_phtrkdata.addWidget(lb_trgain, 2, 1) lay_phtrkdata.addWidget(ld_nshift, 3, 0) lay_phtrkdata.addWidget(lb_nshift, 3, 1) lay_phtrkdata.addWidget(ld_phase, 4, 0) lay_phtrkdata.addWidget(lb_phase, 4, 1) lay_phtrkdata.addWidget(ld_error, 5, 0) lay_phtrkdata.addWidget(lb_error, 5, 1) lay_phtrkdata.addWidget(ld_trfreq, 6, 0) lay_phtrkdata.addWidget(lb_trfreq, 6, 1) lay_phtrkdata.addWidget(ld_trtune, 7, 0) lay_phtrkdata.addWidget(lb_trtune, 7, 1) gbox_phtrk = QGroupBox('Phase Tracking', self) lay_phtrk = QGridLayout(gbox_phtrk) lay_phtrk.setHorizontalSpacing(20) lay_phtrk.addLayout(lay_phtrkctrl, 0, 0) lay_phtrk.addLayout(lay_phtrkdata, 1, 0) gbox_phtrk.setStyleSheet(""" PyDMLabel{ min-width: 6em; max-width: 6em; }""") wid = QWidget() lay = QGridLayout(wid) lay.addWidget(gbox_dtacq, 0, 0) lay.addWidget(gbox_trig, 1, 0) lay.addWidget(gbox_phtrk, 2, 0) return wid
def __init__(self, settings: PartSettings): super().__init__() self.settings = settings self.save_translate_dict: typing.Dict[str, SaveBase] = {x.get_short_name(): x for x in save_dict.values()} self.plan = PlanPreview(self) self.save_plan_btn = QPushButton("Save") self.clean_plan_btn = QPushButton("Remove all") self.remove_btn = QPushButton("Remove") self.update_element_chk = QCheckBox("Update element") self.change_root = EnumComboBox(RootType) self.save_choose = QComboBox() self.save_choose.addItem("<none>") self.save_choose.addItems(list(self.save_translate_dict.keys())) self.save_btn = QPushButton("Save") self.segment_profile = SearchableListWidget() self.pipeline_profile = SearchableListWidget() self.segment_stack = QTabWidget() self.segment_stack.addTab(self.segment_profile, "Profile") self.segment_stack.addTab(self.pipeline_profile, "Pipeline") self.generate_mask_btn = QPushButton("Add mask") self.generate_mask_btn.setToolTip("Mask need to have unique name") self.mask_name = QLineEdit() self.mask_operation = EnumComboBox(MaskOperation) self.chanel_num = QSpinBox() self.choose_channel_for_measurements = QComboBox() self.choose_channel_for_measurements.addItems( ["Same as segmentation"] + [str(x + 1) for x in range(MAX_CHANNEL_NUM)] ) self.units_choose = EnumComboBox(Units) self.units_choose.set_value(self.settings.get("units_value", Units.nm)) self.chanel_num.setRange(0, 10) self.expected_node_type = None self.save_constructor = None self.chose_profile_btn = QPushButton("Add Profile") self.get_big_btn = QPushButton("Leave the biggest") self.get_big_btn.hide() self.get_big_btn.setDisabled(True) self.measurements_list = SearchableListWidget(self) self.measurement_name_prefix = QLineEdit(self) self.add_calculation_btn = QPushButton("Add measurement calculation") self.information = QTextEdit() self.information.setReadOnly(True) self.protect = False self.mask_set = set() self.calculation_plan = CalculationPlan() self.plan.set_plan(self.calculation_plan) self.segmentation_mask = MaskWidget(settings) self.file_mask = FileMask() self.change_root.currentIndexChanged.connect(self.change_root_type) self.save_choose.currentTextChanged.connect(self.save_changed) self.measurements_list.currentTextChanged.connect(self.show_measurement) self.segment_profile.currentTextChanged.connect(self.show_segment) self.measurements_list.currentTextChanged.connect(self.show_measurement_info) self.segment_profile.currentTextChanged.connect(self.show_segment_info) self.pipeline_profile.currentTextChanged.connect(self.show_segment_info) self.pipeline_profile.currentTextChanged.connect(self.show_segment) self.mask_name.textChanged.connect(self.mask_name_changed) self.generate_mask_btn.clicked.connect(self.create_mask) self.clean_plan_btn.clicked.connect(self.clean_plan) self.remove_btn.clicked.connect(self.remove_element) self.mask_name.textChanged.connect(self.mask_text_changed) self.chose_profile_btn.clicked.connect(self.add_segmentation) self.get_big_btn.clicked.connect(self.add_leave_biggest) self.add_calculation_btn.clicked.connect(self.add_measurement) self.save_plan_btn.clicked.connect(self.add_calculation_plan) # self.forgot_mask_btn.clicked.connect(self.forgot_mask) # self.cmap_save_btn.clicked.connect(self.save_to_cmap) self.save_btn.clicked.connect(self.add_save_to_project) self.update_element_chk.stateChanged.connect(self.mask_text_changed) self.update_element_chk.stateChanged.connect(self.show_measurement) self.update_element_chk.stateChanged.connect(self.show_segment) self.update_element_chk.stateChanged.connect(self.update_names) self.segment_stack.currentChanged.connect(self.change_segmentation_table) plan_box = QGroupBox("Prepare workflow:") lay = QVBoxLayout() lay.addWidget(self.plan) bt_lay = QGridLayout() bt_lay.setSpacing(1) bt_lay.addWidget(self.save_plan_btn, 0, 0) bt_lay.addWidget(self.clean_plan_btn, 0, 1) bt_lay.addWidget(self.remove_btn, 1, 0) bt_lay.addWidget(self.update_element_chk, 1, 1) lay.addLayout(bt_lay) plan_box.setLayout(lay) plan_box.setStyleSheet(group_sheet) other_box = QGroupBox("Other operations:") other_box.setContentsMargins(0, 0, 0, 0) bt_lay = QVBoxLayout() bt_lay.setSpacing(0) bt_lay.addWidget(QLabel("Root type:")) bt_lay.addWidget(self.change_root) bt_lay.addStretch(1) bt_lay.addWidget(QLabel("Saving:")) bt_lay.addWidget(self.save_choose) bt_lay.addWidget(self.save_btn) other_box.setLayout(bt_lay) other_box.setStyleSheet(group_sheet) mask_box = QGroupBox("Use mask from:") mask_box.setStyleSheet(group_sheet) self.mask_stack = QTabWidget() self.mask_stack.addTab(stretch_widget(self.file_mask), "File") self.mask_stack.addTab(stretch_widget(self.segmentation_mask), "Current ROI") self.mask_stack.addTab(stretch_widget(self.mask_operation), "Operations on masks") self.mask_stack.setTabToolTip(2, "Allows to create mask which is based on masks previously added to plan.") lay = QGridLayout() lay.setSpacing(0) lay.addWidget(self.mask_stack, 0, 0, 1, 2) label = QLabel("Mask name:") label.setToolTip("Needed if you would like to reuse this mask in tab 'Operations on masks'") self.mask_name.setToolTip("Needed if you would like to reuse this mask in tab 'Operations on masks'") lay.addWidget(label, 1, 0) lay.addWidget(self.mask_name, 1, 1) lay.addWidget(self.generate_mask_btn, 2, 0, 1, 2) mask_box.setLayout(lay) segment_box = QGroupBox("ROI extraction:") segment_box.setStyleSheet(group_sheet) lay = QVBoxLayout() lay.setSpacing(0) lay.addWidget(self.segment_stack) lay.addWidget(self.chose_profile_btn) lay.addWidget(self.get_big_btn) segment_box.setLayout(lay) measurement_box = QGroupBox("Set of measurements:") measurement_box.setStyleSheet(group_sheet) lay = QGridLayout() lay.setSpacing(0) lay.addWidget(self.measurements_list, 0, 0, 1, 2) lab = QLabel("Name prefix:") lab.setToolTip("Prefix added before each column name") lay.addWidget(lab, 1, 0) lay.addWidget(self.measurement_name_prefix, 1, 1) lay.addWidget(QLabel("Channel:"), 2, 0) lay.addWidget(self.choose_channel_for_measurements, 2, 1) lay.addWidget(QLabel("Units:"), 3, 0) lay.addWidget(self.units_choose, 3, 1) lay.addWidget(self.add_calculation_btn, 4, 0, 1, 2) measurement_box.setLayout(lay) info_box = QGroupBox("Information") info_box.setStyleSheet(group_sheet) lay = QVBoxLayout() lay.addWidget(self.information) info_box.setLayout(lay) layout = QGridLayout() fst_col = QVBoxLayout() fst_col.addWidget(plan_box, 1) fst_col.addWidget(mask_box) layout.addWidget(plan_box, 0, 0, 5, 1) # layout.addWidget(plan_box, 0, 0, 3, 1) # layout.addWidget(mask_box, 3, 0, 2, 1) # layout.addWidget(segmentation_mask_box, 1, 1) layout.addWidget(mask_box, 0, 2, 1, 2) layout.addWidget(other_box, 0, 1) layout.addWidget(segment_box, 1, 1, 1, 2) layout.addWidget(measurement_box, 1, 3) layout.addWidget(info_box, 3, 1, 1, 3) self.setLayout(layout) self.generate_mask_btn.setDisabled(True) self.chose_profile_btn.setDisabled(True) self.add_calculation_btn.setDisabled(True) self.mask_allow = False self.segment_allow = False self.file_mask_allow = False self.node_type = NodeType.root self.node_name = "" self.plan_node_changed.connect(self.mask_text_changed) self.plan.changed_node.connect(self.node_type_changed) self.plan_node_changed.connect(self.show_segment) self.plan_node_changed.connect(self.show_measurement) self.plan_node_changed.connect(self.mask_stack_change) self.mask_stack.currentChanged.connect(self.mask_stack_change) self.file_mask.value_changed.connect(self.mask_stack_change) self.mask_name.textChanged.connect(self.mask_stack_change) self.node_type_changed()
def setupUI(self): width, height = self.determine_dialog_dimensions() self.setMinimumSize(width, height) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.setWindowTitle("About Mantid Workbench") self.setStyleSheet(f"""QDialog {{ background-color: rgb(190, 230, 190); }} QLabel{{ font: {self.rescale_w(14)}px; }} QPushButton{{ font: {self.rescale_w(14)}px; }} QCommandLinkButton{{ font: {self.rescale_w(22)}px; background-color: rgba(255, 255, 255, 0); border-radius: {self.rescale_w(15)}px; }} QCommandLinkButton:hover {{ background-color: rgba(45, 105, 45, 40); }}""") # version label section at th etop parent_layout = QVBoxLayout() parent_layout.addSpacerItem(QSpacerItem(self.rescale_w(20),self.rescale_h(70),vPolicy=QSizePolicy.Fixed)) self.lbl_version.setText("version ") self.lbl_version.setIndent(self.rescale_w(115)) self.lbl_version.setStyleSheet(f"""color: rgb(215, 215, 215); font: {self.rescale_w(28)}pt; font-weight: bold; font-size: {self.rescale_w(28)}px""") parent_layout.addWidget(self.lbl_version) parent_layout.addSpacerItem(QSpacerItem(self.rescale_w(20),self.rescale_h(40), vPolicy=QSizePolicy.MinimumExpanding)) # split into the two columns two_box_layout = QHBoxLayout() # left side Welcome and Tutorial left_layout = QVBoxLayout() left_layout.setContentsMargins(self.rescale_w(5), 0, self.rescale_w(10), 0) left_layout.setSpacing(0) # welcome label lbl_welcome = QLabel() lbl_welcome.setStyleSheet(f"color: rgb(45, 105, 45); font-size: {self.rescale_w(28)}px;") lbl_welcome.setText("Welcome") left_layout.addWidget(lbl_welcome) # release notes self.setup_command_link_button(self.clb_release_notes, "Release Notes", ':/images/Notepad-Bloc-notes-icon-48x48.png') left_layout.addWidget(self.clb_release_notes) # sample datasets self.setup_command_link_button(self.clb_sample_datasets, "Sample Datasets", ':/images/download-icon-48x48.png') left_layout.addWidget(self.clb_sample_datasets) # Tutorials Label lbl_tutorials = QLabel() lbl_tutorials.setStyleSheet(f"color: rgb(45, 105, 45); font-size: {self.rescale_w(28)}px;") lbl_tutorials.setText("Tutorials") left_layout.addWidget(lbl_tutorials) # Mantid Introduction self.setup_command_link_button(self.clb_mantid_introduction, "Mantid Introduction", ':/images/Misc-Tutorial-icon-48x48.png') left_layout.addWidget(self.clb_mantid_introduction) # Introduction to python self.setup_command_link_button(self.clb_python_introduction, "Introduction to Python", ':/images/Python-icon-48x48.png') left_layout.addWidget(self.clb_python_introduction) # Python in Mantid self.setup_command_link_button(self.clb_python_in_mantid, "Python In Mantid", ':/images/Circle_cog_48x48.png') left_layout.addWidget(self.clb_python_in_mantid) # Extending Mantid with python self.setup_command_link_button(self.clb_extending_mantid, "Extending Mantid with Python", ':/images/Plugin-Python-icon-48x48.png') left_layout.addWidget(self.clb_extending_mantid) # right hand side Setup and facility icons right_layout = QVBoxLayout() right_layout.setSpacing(0) # personal setup grp_personal_setup = QGroupBox() grp_personal_setup.setStyleSheet(f"""QGroupBox {{ border: {self.rescale_w(3)}px solid rgb(38, 128, 20);; border-radius: {self.rescale_w(10)}px; background-color: rgb(240, 240, 240); }} QGroupBox QLabel{{ font: {self.rescale_w(12)}px; color: rgb(121, 121, 121); }} QGroupBox QComboBox{{ font: {self.rescale_w(12)}px; }} font: {self.rescale_w(12)}px; """) grp_personal_setup_layout = QVBoxLayout() grp_personal_setup_layout.setContentsMargins(self.rescale_w(9), self.rescale_h(1), self.rescale_w(9), self.rescale_h(9)) grp_personal_setup_layout.setSpacing(0) grp_personal_setup.setLayout(grp_personal_setup_layout) lbl_personal_setup = QLabel() lbl_personal_setup.setStyleSheet(f"color: rgb(38, 128, 20);\nfont-size: {self.rescale_w(18)}px;") lbl_personal_setup.setText("Personal Setup") lbl_personal_setup.setAlignment(Qt.AlignHCenter) grp_personal_setup_layout.addWidget(lbl_personal_setup) personal_setup_form_layout = QFormLayout() personal_setup_form_layout.setHorizontalSpacing(self.rescale_w(5)) personal_setup_form_layout.setVerticalSpacing(self.rescale_h(5)) personal_setup_form_layout.setLabelAlignment(Qt.AlignRight) # default Facility lbl_default_facilty = QLabel() lbl_default_facilty.setText("Default Facility") personal_setup_form_layout.addRow(lbl_default_facilty, self.cb_facility) # default instrument lbl_default_instrument = QLabel() lbl_default_instrument.setText("Default Instrument") personal_setup_form_layout.addRow(lbl_default_instrument, self.cb_instrument) # Set Data Directories lbl_mud = QLabel() lbl_mud.setText("Set data directories") self.pb_manage_user_directories.setText("Manage User Directories") personal_setup_form_layout.addRow(lbl_mud, self.pb_manage_user_directories) # Usage data lbl_allow_usage_data = QLabel() lbl_allow_usage_data.setText("Report Usage Data") usagelayout = QHBoxLayout() usagelayout.setContentsMargins(0, 0, 0, 0) self.chk_allow_usage_data.setChecked(True) self.chk_allow_usage_data.setStyleSheet(f"padding: {self.rescale_w(4)}px;") usagelayout.addWidget(self.chk_allow_usage_data) usagelayout.addSpacerItem(QSpacerItem(self.rescale_w(40), self.rescale_h(20), hPolicy=QSizePolicy.Expanding)) self.lbl_privacy_policy.setText(r'<html><head/><body><p>' r'<a href="https://www.mantidproject.org/MantidProject:Privacy_policy' r'#Usage_Data_recorded_in_Mantid">' r'<span style=" text-decoration: underline; color:#0000ff;">' r'Privacy Policy</span></a></p></body></html>') self.lbl_privacy_policy.setOpenExternalLinks(False) usagelayout.addWidget(self.lbl_privacy_policy) personal_setup_form_layout.addRow(lbl_allow_usage_data,usagelayout) grp_personal_setup_layout.addLayout(personal_setup_form_layout) right_layout.addWidget(grp_personal_setup) right_layout.addSpacerItem(QSpacerItem(self.rescale_w(20), self.rescale_h(40), vPolicy=QSizePolicy.Expanding)) # facility icons # Row one icon_layout_top = QHBoxLayout() icon_layout_top.setContentsMargins(0, self.rescale_h(10), 0, 0) icon_layout_top.setSpacing(0) icon_layout_top.addWidget(self.create_label_with_image(112, 50, ':/images/ISIS_Logo_Transparent.gif')) icon_layout_top.addSpacerItem(QSpacerItem(self.rescale_w(10), self.rescale_h(20), hPolicy=QSizePolicy.Fixed)) icon_layout_top.addWidget(self.create_label_with_image(94, 50, ':/images/ess_logo_transparent_small.png')) icon_layout_top.addSpacerItem(QSpacerItem(self.rescale_w(40), 20,hPolicy=QSizePolicy.Expanding)) right_layout.addLayout(icon_layout_top) # Row two icon_layout_middle = QHBoxLayout() icon_layout_middle.setContentsMargins(0, self.rescale_h(10), 0, 0) icon_layout_middle.setSpacing(0) icon_layout_middle.addWidget(self.create_label_with_image(200, 30, ':/images/Ornl_hfir_sns_logo_small.png')) icon_layout_middle.addSpacerItem(QSpacerItem(self.rescale_w(40), self.rescale_h(20), hPolicy=QSizePolicy.Expanding)) right_layout.addLayout(icon_layout_middle) # Row three icon_layout_bottom = QHBoxLayout() icon_layout_bottom.setContentsMargins(0, self.rescale_h(10), 0, 0) icon_layout_bottom.setSpacing(0) icon_layout_bottom.addWidget(self.create_label_with_image(110, 40, ':/images/Tessella_Logo_Transparent.gif')) icon_layout_bottom.addSpacerItem(QSpacerItem(self.rescale_w(10), self.rescale_h(20), hPolicy=QSizePolicy.Fixed)) icon_layout_bottom.addWidget(self.create_label_with_image(50, 50, ':/images/ILL_logo.png')) icon_layout_bottom.addSpacerItem(QSpacerItem(self.rescale_w(10), self.rescale_h(20), hPolicy=QSizePolicy.Fixed)) icon_layout_bottom.addWidget(self.create_label_with_image(92, 50, ':/images/CSNS_Logo_Short.png')) icon_layout_bottom.addSpacerItem(QSpacerItem(self.rescale_w(40), self.rescale_h(20), hPolicy=QSizePolicy.Expanding)) right_layout.addLayout(icon_layout_bottom) # end the two box layout two_box_layout.addLayout(left_layout) two_box_layout.addLayout(right_layout) parent_layout.addLayout(two_box_layout) # footer footer_layout = QHBoxLayout() # do not show again do_not_show_layout = QVBoxLayout() do_not_show_layout.setContentsMargins(self.rescale_w(15), 0, 0, 0) do_not_show_layout.setSpacing(self.rescale_w(2)) do_not_show_layout.addSpacerItem(QSpacerItem(1,self.rescale_h(1), vPolicy=QSizePolicy.Expanding)) lbl_update = QLabel() lbl_update.setMinimumSize(self.rescale_w(400),0) lbl_update.setStyleSheet("color: rgb(25,125,25);") lbl_update.setText('You can revisit this dialog by selecting "About" on the Help menu.') lbl_update.setAlignment(Qt.AlignBottom) do_not_show_layout.addWidget(lbl_update) do_not_show_checkbox_layout = QHBoxLayout() self.chk_do_not_show_until_next_release.setChecked(True) do_not_show_checkbox_layout.addWidget(self.chk_do_not_show_until_next_release) do_not_show_checkbox_layout.addSpacerItem(QSpacerItem(self.rescale_w(10), self.rescale_h(2), hPolicy=QSizePolicy.Fixed)) lbl_do_not_show = QLabel() lbl_do_not_show.setStyleSheet("color: rgb(25,125,25);") lbl_do_not_show.setText('Do not show again until next release') do_not_show_checkbox_layout.addWidget(lbl_do_not_show) do_not_show_checkbox_layout.addSpacerItem(QSpacerItem(self.rescale_w(40),10, hPolicy=QSizePolicy.Expanding)) do_not_show_layout.addLayout(do_not_show_checkbox_layout) footer_layout.addLayout(do_not_show_layout) # Close button close_button_layout = QVBoxLayout() close_button_layout.addSpacerItem(QSpacerItem(20,self.rescale_h(15), vPolicy=QSizePolicy.Expanding)) self.pb_close.setText("Close") self.pb_close.setDefault(True) close_button_layout.addWidget(self.pb_close) footer_layout.addLayout(close_button_layout) footer_layout.addSpacerItem(QSpacerItem(self.rescale_w(100), self.rescale_h(20), hPolicy=QSizePolicy.Fixed)) parent_layout.addLayout(footer_layout) self.setLayout(parent_layout) self.setAttribute(Qt.WA_DeleteOnClose, True)
class MainLauncher(SiriusMainWindow): """Main Launcher.""" showMonitor = Signal() showStatus = Signal() showEgun = Signal() def __init__(self, parent=None, prefix=VACA_PREFIX): """Init.""" super().__init__(parent) self._prefix = prefix # window settings self.setObjectName('ASApp') self.setWindowTitle('Sirius Launcher') self.setWindowIcon( qta.icon('mdi.rocket', color=get_appropriate_color('AS'))) screens = QApplication.screens() screen_idx = 3 if len(screens) == 8 else 0 topleft = screens[screen_idx].geometry().topLeft() self.move(topleft.x(), topleft.y() + 20) self.setWindowFlags(Qt.WindowStaysOnTopHint) # menubar menubar = get_object(ismenubar=True) menubar.setNativeMenuBar(False) self.setMenuBar(menubar) self._setupUi() # connect window signals connect_newprocess(self, 'sirius-hla-as-ap-monitor.py', parent=self, signal=self.showMonitor) connect_newprocess(self, 'sirius-hla-si-ap-genstatus.py', parent=self, signal=self.showStatus) connect_newprocess(self, 'sirius-hla-li-eg-control.py', parent=self, signal=self.showEgun) # set focus policy self.setFocus(True) self.setFocusPolicy(Qt.StrongFocus) def _setupUi(self): # Machine Shift self.wid_shift = QGroupBox('Machine Shift') machshift_pvname = SiriusPVName( 'AS-Glob:AP-MachShift:Mode-Sel').substitute(prefix=self._prefix) cbox_shift_mode = SiriusEnumComboBox(self, machshift_pvname) label_shift_mode = MachShiftLabel(self, self._prefix) label_shift_mode.label.setStyleSheet( 'QLabel{max-height: 2em; min-width: 7em;}') lay_shift = QGridLayout(self.wid_shift) lay_shift.setVerticalSpacing(5) lay_shift.setAlignment(Qt.AlignCenter) lay_shift.addWidget(cbox_shift_mode, 1, 0) lay_shift.addWidget(label_shift_mode, 2, 0) # Injection System self.wid_injsys = QGroupBox('Inj.System') wid_injsys = InjSysStbyControlWidget(self, self._prefix, is_summary=True) lay_injsys = QGridLayout(self.wid_injsys) lay_injsys.setAlignment(Qt.AlignCenter) lay_injsys.setContentsMargins(0, 0, 0, 0) lay_injsys.addWidget(wid_injsys) # Egun triggers self.wid_egun = QGroupBox('Egun Trig.') self.wid_egun.setStyleSheet('min-width: 5em;') egun_dev = SiriusPVName('LI-01:EG-TriggerPS').substitute( prefix=self._prefix) but_egun_trigger = PyDMStateButton( self, egun_dev.substitute(propty_name='enable')) led_egun_trigger = SiriusLedState( self, egun_dev.substitute(propty_name='enablereal')) lay_egun = QGridLayout(self.wid_egun) lay_egun.setVerticalSpacing(5) lay_egun.addWidget(but_egun_trigger, 1, 0) lay_egun.addWidget(led_egun_trigger, 2, 0) # injection control injctrl_dev = SiriusPVName('AS-Glob:AP-InjCtrl') injctrl_dev = injctrl_dev.substitute(prefix=self._prefix) self.wid_inject = QGroupBox('Injection') self.ch_injmode = SiriusConnectionSignal( injctrl_dev.substitute(propty='Mode-Sts')) self.ch_injmode.new_value_signal[int].connect( self._handle_injmode_settings_vis) # # Settings label_sett = QLabel('<h4>Sett.</h4>', self, alignment=Qt.AlignCenter) led_sett = InjDiagLed(self) self.wid_injsett = QWidget() lay_injsett = QGridLayout(self.wid_injsett) lay_injsett.setContentsMargins(0, 0, 0, 0) lay_injsett.setAlignment(Qt.AlignTop) lay_injsett.addWidget(label_sett, 0, 0) lay_injsett.addWidget(led_sett, 1, 0) # # Auto Stop self.label_injauto = QLabel('<h4>AutoStop</h4>', self, alignment=Qt.AlignCenter) self.but_injauto = PyDMStateButton( self, injctrl_dev.substitute(propty='AutoStop-Sel')) self.led_injauto = SiriusLedState( self, injctrl_dev.substitute(propty='AutoStop-Sts')) self.wid_injauto = QWidget() self.wid_injauto.setObjectName('wid') self.wid_injauto.setStyleSheet("#wid{min-width: 8em; max-width: 8em;}") lay_injauto = QGridLayout(self.wid_injauto) lay_injauto.setContentsMargins(0, 0, 0, 0) lay_injauto.setAlignment(Qt.AlignTop) lay_injauto.addWidget(self.label_injauto, 0, 0) lay_injauto.addWidget(self.but_injauto, 1, 0) lay_injauto.addWidget(self.led_injauto, 2, 0) # # Top-up status label_tusts = QLabel('<h4>Status</h4>', self, alignment=Qt.AlignCenter) label_tunow = ClockLabel(self) label_tunow.setStyleSheet('max-height:2em;') label_tunxt = SiriusLabel( self, injctrl_dev.substitute(propty='TopUpNextInj-Mon')) label_tunxt.displayFormat = SiriusLabel.DisplayFormat.Time label_tunxt.setAlignment(Qt.AlignCenter) label_tunxt.setStyleSheet('max-height:2em;') but_round = PyDMPushButton( self, '', qta.icon('mdi.tilde'), 1, False, injctrl_dev.substitute(propty='TopUpNextInjRound-Cmd')) but_round.setObjectName('but') but_round.setStyleSheet( '#but{min-width:18px; max-width:18px; icon-size:16px;}') self.wid_tusts = QWidget() self.wid_tusts.setObjectName('wid') self.wid_tusts.setStyleSheet("#wid{min-width: 8em; max-width: 8em;}") lay_tusts = QGridLayout(self.wid_tusts) lay_tusts.setContentsMargins(0, 0, 0, 0) lay_tusts.setAlignment(Qt.AlignTop) lay_tusts.addWidget(label_tusts, 0, 0, 1, 2) lay_tusts.addWidget(QLabel('Now:', self), 1, 0) lay_tusts.addWidget(label_tunow, 1, 1) lay_tusts.addWidget(QLabel('Next:', self), 2, 0) lay_tusts.addWidget(label_tunxt, 2, 1) lay_tusts.addWidget(but_round, 2, 2) self.wid_tusts.setVisible(False) # # Control label_inj = QLabel('<h4>Control</h4>', self, alignment=Qt.AlignCenter) self.but_tiinj = EVGInjectionButton(self, self._prefix) self.but_topup = PyDMStateButton( self, injctrl_dev.substitute(propty='TopUpState-Sel')) self.but_topup.setVisible(False) lay_inject_sel = QGridLayout() lay_inject_sel.setAlignment(Qt.AlignCenter) lay_inject_sel.addWidget(self.but_tiinj, 0, 0) lay_inject_sel.addWidget(self.but_topup, 0, 0) led_injsts = EVGInjectionLed(self, self._prefix) label_injcnt = PyDMLabel(self) label_injcnt.setToolTip( 'Count injection pulses when Egun Trigger is enabled.') label_injcnt.channel = SiriusPVName( 'AS-Glob:AP-CurrInfo:InjCount-Mon').substitute(prefix=self._prefix) label_injcnt.setStyleSheet('QLabel{max-width: 3.5em;}') lay_inject_sts = QHBoxLayout() lay_inject_sts.setContentsMargins(0, 0, 0, 0) lay_inject_sts.setAlignment(Qt.AlignTop) lay_inject_sts.addWidget(led_injsts) lay_inject_sts.addWidget(label_injcnt) self.wid_injctrl = QWidget() lay_injctrl = QGridLayout(self.wid_injctrl) lay_injctrl.setContentsMargins(0, 0, 0, 0) lay_injctrl.setAlignment(Qt.AlignTop) lay_injctrl.addWidget(label_inj, 0, 2, alignment=Qt.AlignCenter) lay_injctrl.addLayout(lay_inject_sel, 1, 2, alignment=Qt.AlignCenter) lay_injctrl.addLayout(lay_inject_sts, 2, 2, alignment=Qt.AlignCenter) # # Injection Auxiliary section self.wid_injlog = QGroupBox('Injection Log') label_injlog = PyDMLogLabel(self, injctrl_dev.substitute(propty='Log-Mon'), replace=[ 'Remaining time', ]) lay_injlog = QGridLayout(self.wid_injlog) lay_injlog.addWidget(label_injlog, 0, 0) self.wid_injlog.setVisible(False) self.wid_mon = MonitorSummaryWidget(self, self._prefix) self.wid_mon.setVisible(False) # # Target Current self._ld_currtgt = QLabel('<h4>Target Curr.</h4>', self, alignment=Qt.AlignCenter) self._sb_currtgt = SiriusSpinbox( self, injctrl_dev.substitute(propty='TargetCurrent-SP')) self._sb_currtgt.showStepExponent = False self._lb_currtgt = PyDMLabel( self, injctrl_dev.substitute(propty='TargetCurrent-RB')) self._lb_currtgt.showUnits = True self._wid_tcurr = QWidget() lay_tcurr = QGridLayout(self._wid_tcurr) lay_tcurr.setContentsMargins(0, 0, 0, 0) lay_tcurr.setAlignment(Qt.AlignTop) lay_tcurr.addWidget(self._ld_currtgt, 0, 0) lay_tcurr.addWidget(self._sb_currtgt, 1, 0) lay_tcurr.addWidget(self._lb_currtgt, 2, 0) # # Bucket List self._bucket_list = BucketList(self, prefix=self._prefix, min_size=15) self.wid_fill = QWidget() lay_fill = QGridLayout(self.wid_fill) lay_fill.setContentsMargins(0, 0, 0, 0) lay_fill.setHorizontalSpacing(9) lay_fill.addWidget(self._wid_tcurr, 0, 0) lay_fill.addWidget(self._bucket_list, 0, 1) self.wid_fill.setVisible(False) pbt_aux = QPushButton('v', self) pbt_aux.setToolTip('Show Injection Auxiliary section.') pbt_aux.clicked.connect(self._toggle_show_injaux) pbt_aux.setStyleSheet('QPushButton{max-width: 0.8em;}') pbt_bl = QPushButton('>', self) pbt_bl.setToolTip('Show bucket list and target current controls.') pbt_bl.clicked.connect(self._toggle_show_bucketlist) pbt_bl.setStyleSheet('QPushButton{max-width: 0.8em;}') lay_inj = QGridLayout(self.wid_inject) lay_inj.setAlignment(Qt.AlignTop) lay_inj.setVerticalSpacing(5) lay_inj.setHorizontalSpacing(12) lay_inj.addWidget(self.wid_injsett, 0, 0, 2, 1) lay_inj.addWidget(self.wid_injauto, 0, 1, 2, 1) lay_inj.addWidget(self.wid_tusts, 0, 1, 2, 1) lay_inj.addWidget(self.wid_injctrl, 0, 2, 2, 1) lay_inj.addWidget(pbt_bl, 0, 3, alignment=Qt.AlignTop) lay_inj.addWidget(pbt_aux, 1, 3, alignment=Qt.AlignBottom) lay_inj.addWidget(self.wid_fill, 0, 4, 2, 1) # Current curr_pvname = SiriusPVName( 'SI-Glob:AP-CurrInfo:Current-Mon').substitute(prefix=self._prefix) self.label_curr = PyDMLabel(self, curr_pvname) self.label_curr.showUnits = True self.label_curr.setStyleSheet(""" QLabel{ font-size: 18pt; qproperty-alignment: AlignCenter; min-width: 6em; max-width: 6em; }""") self.wid_curr = QGroupBox('Current') lay_curr = QHBoxLayout(self.wid_curr) lay_curr.addWidget(self.label_curr) # RF Kill Beam self.wid_rfkill = QGroupBox('RF Kill Beam') self.wid_rfkill.setObjectName('RFKillBeam') rfkill_bt = RFKillBeamButton(self, self._prefix) rfkill_lay = QGridLayout(self.wid_rfkill) rfkill_lay.addWidget(rfkill_bt) # menu buttons self.wid_pbt = QPushButton('v', self) self.wid_pbt.clicked.connect(self._toggle_show_menubutton) self.wid_pbt.setStyleSheet('QPushButton{max-width: 0.8em;}') self._menubutton = get_object(ismenubar=False, parent=self) self._menubutton.layout().setContentsMargins(0, 0, 0, 0) self._menubutton.layout().setSpacing(4) self._menubutton.setVisible(False) hlay1 = QHBoxLayout() hlay1.setContentsMargins(0, 0, 0, 0) hlay1.addWidget(self.wid_shift) hlay1.addWidget(self.wid_injsys) hlay1.addWidget(self.wid_egun) hlay1.addWidget(self.wid_inject) hlay1.addWidget(self.wid_curr) hlay1.addWidget(self.wid_rfkill) hlay2 = QHBoxLayout() hlay2.setContentsMargins(0, 0, 0, 0) hlay2.addWidget(self.wid_injlog) hlay2.addWidget(self.wid_mon) cwid = QWidget(self) lay = QGridLayout(cwid) lay.addLayout(hlay1, 0, 0) lay.addLayout(hlay2, 1, 0) lay.addWidget(self._menubutton, 2, 0, 1, 2) lay.addWidget(self.wid_pbt, 0, 1, 2, 1, alignment=Qt.AlignRight | Qt.AlignBottom) self.setCentralWidget(cwid) def _toggle_show_menubutton(self): self._menubutton.setVisible(self._menubutton.isHidden()) text = 'v' if self._menubutton.isHidden() else '^' self.sender().setText(text) self.centralWidget().adjustSize() self.adjustSize() def _toggle_show_bucketlist(self): show = self.wid_fill.isHidden() self.wid_fill.setVisible(show) text = '<' if show else '>' tooltip = ('Hide' if show else 'Show') + ' bucket list controls.' self.sender().setText(text) self.sender().setToolTip(tooltip) self.sender().parent().adjustSize() self.centralWidget().adjustSize() self.adjustSize() def _toggle_show_injaux(self): show = self.wid_mon.isHidden() self.wid_mon.setVisible(show) self.wid_injlog.setVisible(show) text = '^' if show else 'v' tooltip = ('Hide' if show else 'Show') + ' Injection Auxiliary section.' self.sender().setText(text) self.sender().setToolTip(tooltip) self.sender().parent().adjustSize() self.centralWidget().adjustSize() self.adjustSize() @Slot(int) def _handle_injmode_settings_vis(self, new_mode): is_topup = new_mode == _InjConst.InjMode.TopUp self.label_injauto.setVisible(not is_topup) self.but_injauto.setVisible(not is_topup) self.led_injauto.setVisible(not is_topup) self.wid_tusts.setVisible(is_topup) self.but_tiinj.setVisible(not is_topup) self.but_topup.setVisible(is_topup) def mouseDoubleClickEvent(self, event): """Implement mouseDoubleClickEvent.""" if event.button() == Qt.LeftButton: if self.wid_curr.underMouse(): self.showStatus.emit() elif self.wid_shift.underMouse(): self.showStatus.emit() elif self.wid_egun.underMouse(): self.showEgun.emit() elif self.wid_mon.underMouse(): self.showMonitor.emit() super().mouseDoubleClickEvent(event) def changeEvent(self, event): """Implement changeEvent.""" if event.type() == QEvent.FontChange: fontsize = self.app.font().pointSize() self.label_curr.setStyleSheet( 'QLabel{' ' font-size: ' + str(fontsize + 8) + 'pt;' ' qproperty-alignment: AlignCenter;' ' min-width: 6em; max-width: 6em;' '}') self.ensurePolished()
def _setup_ui(self): # central widget self.central_widget = QWidget() self.setCentralWidget(self.central_widget) # tree gb_tree = QGroupBox('Select power supplies:') self.pwrsupplies_tree = PVNameTree(self._psnames, ('sec', 'mag_group'), tuple(), self) self.pwrsupplies_tree.tree.setHeaderHidden(True) self.pwrsupplies_tree.tree.setColumnCount(1) glay_tree = QVBoxLayout(gb_tree) glay_tree.addWidget(self.pwrsupplies_tree) # commands lb_prep_ti = QLabel('<h4>Prepare Timing</h4>', self, alignment=Qt.AlignCenter) ti_ch = [ PVName(name).substitute(prefix=VACA_PREFIX) for name in self._timing.get_pvnames_by_psnames() ] self.ticonn_led = PyDMLedMultiConn(self, channels=ti_ch) self.save_timing_bt = QPushButton('1. Save Timing Initial State', self) self.save_timing_bt.setToolTip( 'Save timing current state as initial state.') self.save_timing_bt.clicked.connect( _part(self._run_task, 'save_timing')) self.save_timing_bt.clicked.connect(self._set_lastcomm) self.prepare_timing_bt = QPushButton('2. Prepare Timing', self) self.prepare_timing_bt.setToolTip('Prepare EVG, triggers and events') self.prepare_timing_bt.clicked.connect(_part(self._run_task, 'timing')) self.prepare_timing_bt.clicked.connect(self._set_lastcomm) self.prepare_timing_lb = QLabel(self) self.prepare_timing_lb.setPixmap(self._pixmap_not) lb_prep_ps = QLabel('<h4>Prepare PS</h4>', self, alignment=Qt.AlignCenter) self.psconn_led = PyDMLedMultiConn(self) self.set_ps_sofbmode_off_bt = QPushButton('3. Turn off PS SOFBMode', self) self.set_ps_sofbmode_off_bt.setToolTip( 'Turn off power supplies SOFBMode.') self.set_ps_sofbmode_off_bt.clicked.connect( _part(self._run_task, 'ps_sofbmode')) self.set_ps_sofbmode_off_bt.clicked.connect(self._set_lastcomm) self.set_ps_sofbmode_off_lb = QLabel(self) self.set_ps_sofbmode_off_lb.setPixmap(self._pixmap_not) self.set_ps_opmode_slowref_bt = QPushButton( '4. Set PS OpMode to SlowRef', self) self.set_ps_opmode_slowref_bt.setToolTip( 'Set power supplies OpMode to SlowRef.') self.set_ps_opmode_slowref_bt.clicked.connect( _part(self._run_task, 'ps_om_slowref')) self.set_ps_opmode_slowref_bt.clicked.connect(self._set_lastcomm) self.set_ps_opmode_slowref_lb = QLabel(self) self.set_ps_opmode_slowref_lb.setPixmap(self._pixmap_not) self.set_ps_current_zero_bt = QPushButton('5. Set PS current to zero', self) self.set_ps_current_zero_bt.setToolTip( 'Set power supplies current to zero.') self.set_ps_current_zero_bt.clicked.connect( _part(self._run_task, 'ps_current')) self.set_ps_current_zero_bt.clicked.connect(self._set_lastcomm) self.set_ps_current_zero_lb = QLabel(self) self.set_ps_current_zero_lb.setPixmap(self._pixmap_not) self.prepare_ps_params_bt = QPushButton('6. Prepare PS Parameters', self) self.prepare_ps_params_bt.setToolTip( 'Check power supplies OpMode in SlowRef, check\n' 'current is zero and configure cycle parameters.') self.prepare_ps_params_bt.clicked.connect( _part(self._run_task, 'ps_params')) self.prepare_ps_params_bt.clicked.connect(self._set_lastcomm) self.prepare_ps_params_lb = QLabel(self) self.prepare_ps_params_lb.setPixmap(self._pixmap_not) self.prepare_ps_opmode_bt = QPushButton('7. Prepare PS OpMode', self) self.prepare_ps_opmode_bt.setToolTip( 'Set power supplies OpMode to Cycle.') self.prepare_ps_opmode_bt.clicked.connect( _part(self._run_task, 'ps_om_cycle')) self.prepare_ps_opmode_bt.clicked.connect(self._set_lastcomm) self.prepare_ps_opmode_lb = QLabel(self) self.prepare_ps_opmode_lb.setPixmap(self._pixmap_not) lb_cycle = QLabel('<h4>Cycle</h4>', self, alignment=Qt.AlignCenter) self.cycle_trims_bt = QPushButton('8. Cycle Trims', self) self.cycle_trims_bt.setToolTip( 'Cycle trims:\nStep 1) CH, QS and QTrims\nStep 2) CV') self.cycle_trims_bt.clicked.connect(_part(self._run_task, 'trims')) self.cycle_trims_bt.clicked.connect(self._set_lastcomm) self.cycle_trims_bt.setVisible(False) self.cycle_trims_lb = QLabel(self) self.cycle_trims_lb.setPixmap(self._pixmap_check) self.cycle_trims_lb.setVisible(False) self.cycle_bt = QPushButton('8. Cycle', self) self.cycle_bt.setToolTip( 'Check all configurations,\nenable triggers and run cycle.') self.cycle_bt.clicked.connect(_part(self._run_task, 'cycle')) self.cycle_bt.clicked.connect(self._set_lastcomm) self.cycle_bt.setEnabled(False) lb_rest_ti = QLabel('<h4>Restore Timing</h4>', self, alignment=Qt.AlignCenter) self.restore_timing_bt = QPushButton('9. Restore Timing Initial State', self) self.restore_timing_bt.setToolTip('Restore timing initial state.') self.restore_timing_bt.clicked.connect( _part(self._run_task, 'restore_timing')) self.restore_timing_bt.clicked.connect(self._set_lastcomm) self._prepared_labels = { 'timing': self.prepare_timing_lb, 'ps_sofbmode': self.set_ps_sofbmode_off_lb, 'ps_om_slowref': self.set_ps_opmode_slowref_lb, 'ps_current': self.set_ps_current_zero_lb, 'ps_params': self.prepare_ps_params_lb, 'ps_om_cycle': self.prepare_ps_opmode_lb, 'trims': self.cycle_trims_lb } gb_commsts = QGroupBox() gb_commsts.setStyleSheet(""" QPushButton{min-height:1.5em;} QLabel{qproperty-alignment: AlignCenter;}""") lay_commsts = QGridLayout(gb_commsts) lay_commsts.addItem( QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 0, 0, 1, 2) lay_commsts.addWidget(lb_prep_ti, 1, 0) lay_commsts.addWidget(self.ticonn_led, 1, 1) lay_commsts.addWidget(self.save_timing_bt, 2, 0) lay_commsts.addWidget(self.prepare_timing_bt, 3, 0) lay_commsts.addWidget(self.prepare_timing_lb, 3, 1) lay_commsts.addItem( QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 4, 0) lay_commsts.addWidget(lb_prep_ps, 5, 0) lay_commsts.addWidget(self.psconn_led, 5, 1) lay_commsts.addWidget(self.set_ps_sofbmode_off_bt, 6, 0) lay_commsts.addWidget(self.set_ps_sofbmode_off_lb, 6, 1) lay_commsts.addWidget(self.set_ps_opmode_slowref_bt, 7, 0) lay_commsts.addWidget(self.set_ps_opmode_slowref_lb, 7, 1) lay_commsts.addWidget(self.set_ps_current_zero_bt, 8, 0) lay_commsts.addWidget(self.set_ps_current_zero_lb, 8, 1) lay_commsts.addWidget(self.prepare_ps_params_bt, 9, 0) lay_commsts.addWidget(self.prepare_ps_params_lb, 9, 1) lay_commsts.addWidget(self.prepare_ps_opmode_bt, 10, 0) lay_commsts.addWidget(self.prepare_ps_opmode_lb, 10, 1) lay_commsts.addItem( QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 11, 0) lay_commsts.addWidget(lb_cycle, 12, 0) lay_commsts.addWidget(self.cycle_trims_bt, 13, 0) lay_commsts.addWidget(self.cycle_trims_lb, 13, 1) lay_commsts.addWidget(self.cycle_bt, 14, 0) lay_commsts.addItem( QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 15, 0) lay_commsts.addWidget(lb_rest_ti, 16, 0) lay_commsts.addWidget(self.restore_timing_bt, 17, 0) lay_commsts.addItem( QSpacerItem(1, 1, QSzPlcy.Ignored, QSzPlcy.Expanding), 18, 0) lay_commsts.setColumnStretch(0, 10) lay_commsts.setColumnStretch(1, 1) lay_commsts.setVerticalSpacing(12) lay_commsts.setHorizontalSpacing(6) self.label_lastcomm = QLabel('Last Command: ', self) self.clearhist_bt = QPushButton('Clear', self) self.clearhist_bt.clicked.connect(self._clear_lastcomm) lay_lc = QHBoxLayout() lay_lc.setContentsMargins(0, 0, 0, 0) lay_lc.addWidget(self.label_lastcomm, alignment=Qt.AlignLeft) lay_lc.addWidget(self.clearhist_bt, alignment=Qt.AlignRight) lay_lc.setStretch(0, 10) lay_lc.setStretch(1, 1) self.progress_list = QListWidget(self) self.progress_list.setObjectName('progresslist') self.progress_list.setStyleSheet('#progresslist{min-width:20em;}') self.progress_list.itemDoubleClicked.connect(self._open_ps_detail) self.progress_list.setSelectionMode(QAbstractItemView.MultiSelection) self.progress_list.setToolTip( 'Select rows and press Ctrl+C to copy and Esc to deselect.') self.progress_bar = MyProgressBar(self) lay_log = QVBoxLayout() lay_log.addLayout(lay_lc) lay_log.addWidget(self.progress_list) lay_log.addWidget(self.progress_bar) # connect tree signals self.pwrsupplies_tree.tree.doubleClicked.connect(self._open_ps_detail) self.pwrsupplies_tree.tree.itemChanged.connect( self._handle_checked_items_changed) self.pwrsupplies_tree.check_requested_levels(self._checked_accs) # layout layout = QGridLayout() layout.setVerticalSpacing(10) layout.setHorizontalSpacing(10) layout.addWidget( QLabel('<h3>PS Cycle</h3>', self, alignment=Qt.AlignCenter), 0, 0, 1, 3) layout.addWidget(gb_tree, 1, 0) layout.addWidget(gb_commsts, 1, 1) layout.addLayout(lay_log, 1, 2) layout.setRowStretch(0, 1) layout.setRowStretch(1, 15) layout.setColumnStretch(0, 5) layout.setColumnStretch(1, 4) layout.setColumnStretch(2, 8) self.central_widget.setLayout(layout)
def _setupMeasSettingsWidget(self, mode): if mode == 'Normal': prefix = self.dcct_prefix visible = True elif mode == 'Fast': prefix = self.dcct_prefix.substitute(propty_name=mode) visible = False gbox_modesettings = QGroupBox(mode + ' Measurement Mode Settings', self) l_smpcnt = QLabel('Sample Count: ', self) spinbox_SampleCnt = PyDMSpinbox( self, prefix.substitute(propty=prefix.propty_name + 'SampleCnt-SP')) spinbox_SampleCnt.showStepExponent = False label_SampleCnt = PyDMLabel( self, prefix.substitute(propty=prefix.propty_name + 'SampleCnt-RB')) hlay_smpcnt = QHBoxLayout() hlay_smpcnt.addWidget(spinbox_SampleCnt) hlay_smpcnt.addWidget(label_SampleCnt) l_measperiod = QLabel('Period [s]: ', self) spinbox_MeasPeriod = PyDMSpinbox( self, prefix.substitute(propty=prefix.propty_name + 'MeasPeriod-SP')) spinbox_MeasPeriod.showStepExponent = False label_MeasPeriod = PyDMLabel( self, prefix.substitute(propty=prefix.propty_name + 'MeasPeriod-RB')) hlay_measperiod = QHBoxLayout() hlay_measperiod.addWidget(spinbox_MeasPeriod) hlay_measperiod.addWidget(label_MeasPeriod) l_measupdateperiod = QLabel('Measured Period [s]: ', self) label_MeasUpdatePeriod = PyDMLabel( self, self.dcct_prefix.substitute(propty='MeasUpdatePeriod-Mon')) l_imped = QLabel('Impedance: ', self) enumcombobox_Imped = PyDMEnumComboBox( self, prefix.substitute(propty=prefix.propty_name + 'Imped-Sel')) label_Imped = PyDMLabel( self, prefix.substitute(propty=prefix.propty_name + 'Imped-Sts')) hlay_imped = QHBoxLayout() hlay_imped.addWidget(enumcombobox_Imped) hlay_imped.addWidget(label_Imped) l_offset = QLabel('Relative Offset Enable: ', self) statebutton_RelEnbl = PyDMStateButton( self, prefix.substitute(propty=prefix.propty_name + 'RelEnbl-Sel')) statebutton_RelEnbl.shape = 1 statebutton_RelEnbl.setStyleSheet('min-width:6em; max-width:6em;') label_RelEnbl = PyDMLabel( self, prefix.substitute(propty=prefix.propty_name + 'RelEnbl-Sts')) hlay_offset = QHBoxLayout() hlay_offset.addWidget(statebutton_RelEnbl) hlay_offset.addWidget(label_RelEnbl) l_rellvl = QLabel('Relative Offset Level [V]: ', self) spinbox_RelLvl = PyDMSpinbox( self, prefix.substitute(propty=prefix.propty_name + 'RelLvl-SP')) spinbox_RelLvl.showStepExponent = False label_RelLvl = PyDMLabel( self, prefix.substitute(propty=prefix.propty_name + 'RelLvl-RB')) label_RelLvl.precisionFromPV = False label_RelLvl.precision = 9 pushbutton_RelAcq = PyDMPushButton( parent=self, label='Acquire Offset', pressValue=1, init_channel=prefix.substitute(propty=prefix.propty_name + 'RelAcq-Cmd')) pushbutton_RelAcq.setAutoDefault(False) pushbutton_RelAcq.setDefault(False) hlay_rellvl = QHBoxLayout() hlay_rellvl.addWidget(spinbox_RelLvl) hlay_rellvl.addWidget(label_RelLvl) hlay_rellvl.addWidget(pushbutton_RelAcq) flay_modesettings = QFormLayout() flay_modesettings.setLabelAlignment(Qt.AlignRight) flay_modesettings.setFormAlignment(Qt.AlignHCenter) flay_modesettings.addRow(l_smpcnt, hlay_smpcnt) flay_modesettings.addRow(l_measperiod, hlay_measperiod) flay_modesettings.addRow(l_measupdateperiod, label_MeasUpdatePeriod) flay_modesettings.addRow(l_imped, hlay_imped) flay_modesettings.addRow(l_offset, hlay_offset) flay_modesettings.addRow(l_rellvl, hlay_rellvl) if mode == 'Normal': l_linesync = QLabel('Line Synchronization: ', self) statebutton_LineSync = PyDMStateButton( self, prefix.substitute(propty=prefix.propty_name + 'LineSync-Sel')) statebutton_LineSync.shape = 1 statebutton_LineSync.setStyleSheet('min-width:6em; max-width:6em;') label_LineSync = PyDMLabel( self, prefix.substitute(propty=prefix.propty_name + 'LineSync-Sts')) hlay_linesync = QHBoxLayout() hlay_linesync.addWidget(statebutton_LineSync) hlay_linesync.addWidget(label_LineSync) label_avg = QLabel('<h4>Average Filter</h4>', self) l_avgenbl = QLabel('Enable: ', self) statebutton_AvgFilterEnbl = PyDMStateButton( self, prefix.substitute(propty=prefix.propty_name + 'AvgFilterEnbl-Sel')) statebutton_AvgFilterEnbl.shape = 1 label_AvgFilterEnbl = PyDMLabel( self, prefix.substitute(propty=prefix.propty_name + 'AvgFilterEnbl-Sts')) hlay_avgenbl = QHBoxLayout() hlay_avgenbl.addWidget(statebutton_AvgFilterEnbl) hlay_avgenbl.addWidget(label_AvgFilterEnbl) l_avgcnt = QLabel('Samples: ', self) spinbox_AvgFilterCount = PyDMSpinbox( self, prefix.substitute(propty=prefix.propty_name + 'AvgFilterCnt-SP')) spinbox_AvgFilterCount.showStepExponent = False label_AvgFilterCount = PyDMLabel( self, prefix.substitute(propty=prefix.propty_name + 'AvgFilterCnt-RB')) hlay_avgcnt = QHBoxLayout() hlay_avgcnt.addWidget(spinbox_AvgFilterCount) hlay_avgcnt.addWidget(label_AvgFilterCount) l_avgtyp = QLabel('Type: ', self) enumcombobox_AvgFilterTyp = PyDMEnumComboBox( self, self.dcct_prefix.substitute(propty='AvgFilterTyp-Sel')) label_AvgFilterTyp = PyDMLabel( self, self.dcct_prefix.substitute(propty='AvgFilterTyp-Sts')) hlay_avgtyp = QHBoxLayout() hlay_avgtyp.addWidget(enumcombobox_AvgFilterTyp) hlay_avgtyp.addWidget(label_AvgFilterTyp) l_avgwin = QLabel('Noise window size [%]: ', self) spinbox_AvgFilterWind = PyDMSpinbox( self, prefix.substitute(propty=prefix.propty_name + 'AvgFilterWind-SP')) spinbox_AvgFilterWind.showStepExponent = False label_AvgFilterWind = PyDMLabel( self, prefix.substitute(propty=prefix.propty_name + 'AvgFilterWind-RB')) hlay_avgwin = QHBoxLayout() hlay_avgwin.addWidget(spinbox_AvgFilterWind) hlay_avgwin.addWidget(label_AvgFilterWind) flay_modesettings.addRow(l_linesync, hlay_linesync) flay_modesettings.addRow(QLabel('')) flay_modesettings.addRow(label_avg) flay_modesettings.addRow(l_avgenbl, hlay_avgenbl) flay_modesettings.addRow(l_avgcnt, hlay_avgcnt) flay_modesettings.addRow(l_avgtyp, hlay_avgtyp) flay_modesettings.addRow(l_avgwin, hlay_avgwin) gbox_modesettings.setLayout(flay_modesettings) gbox_modesettings.setVisible(visible) gbox_modesettings.setStyleSheet(""" PyDMSpinbox, PyDMLabel{ min-width:6em; max-width:6em; qproperty-alignment: AlignCenter;} PyDMLedMultiChannel, PyDMStateButton, PyDMEnumComboBox{ min-width:6em; max-width:6em;}""") return gbox_modesettings
def _setupUi(self): lay = QVBoxLayout() lay.addWidget( QLabel('<h3>Settings</h3>', self, alignment=Qt.AlignHCenter | Qt.AlignBottom)) lay.setStretch(0, 1) # Measure l_reliablemeas = QLabel('Reliability: ') self.led_ReliableMeas = SiriusLedAlert( self, self.dcct_prefix.substitute(propty='ReliableMeas-Mon')) l_curr = QLabel('Current [mA]: ', self, alignment=Qt.AlignRight) self.label_current = PyDMLabel( self, self.dcct_prefix.substitute(propty='Current-Mon')) self.led_StoredEBeam = SiriusLedState( self, self.dcct_prefix.substitute(propty='StoredEBeam-Mon')) hlay_current = QHBoxLayout() hlay_current.addWidget(self.label_current) hlay_current.addWidget(self.led_StoredEBeam) l_enbl = QLabel('Enable:', self) self.pydmstatebutton_Enbl = PyDMStateButton( self, self.dcct_prefix.substitute(propty='Enbl-Sel')) self.pydmstatebutton_Enbl.shape = 1 self.led_Enbl = SiriusLedState( self, self.dcct_prefix.substitute(propty='Enbl-Sts')) hlay_enbl = QHBoxLayout() hlay_enbl.addWidget(self.pydmstatebutton_Enbl) hlay_enbl.addWidget(self.led_Enbl) l_meastrig = QLabel('Trigger Source:', self) self.pydmenumcombobox_MeasTrg = PyDMEnumComboBox( self, self.dcct_prefix.substitute(propty='MeasTrg-Sel')) self.pydmlabel_MeasTrg = PyDMLabel( self, self.dcct_prefix.substitute(propty='MeasTrg-Sts')) hlay_meastrig = QHBoxLayout() hlay_meastrig.addWidget(self.pydmenumcombobox_MeasTrg) hlay_meastrig.addWidget(self.pydmlabel_MeasTrg) if 'SI' in self.device: l_range = QLabel('Range: ', self) self.pydmenumcombobox_Range = PyDMEnumComboBox( self, self.dcct_prefix.substitute(propty='Range-Sel')) self.pydmlabel_Range = PyDMLabel( self, self.dcct_prefix.substitute(propty='Range-Sts')) hlay_range = QHBoxLayout() hlay_range.addWidget(self.pydmenumcombobox_Range) hlay_range.addWidget(self.pydmlabel_Range) hlay_range.setContentsMargins(0, 0, 0, 0) l_measmode = QLabel('Mode: ', self) self.pydmenumcombobox_MeasMode = PyDMEnumComboBox( self, self.dcct_prefix.substitute(propty='MeasMode-Sel')) self.pydmlabel_MeasMode = PyDMLabel( self, self.dcct_prefix.substitute(propty='MeasMode-Sts')) hlay_measmode = QHBoxLayout() hlay_measmode.addWidget(self.pydmenumcombobox_MeasMode) hlay_measmode.addWidget(self.pydmlabel_MeasMode) hlay_measmode.setContentsMargins(0, 0, 0, 0) glay_mode = QGridLayout() self.normalmode_widget = self._setupMeasSettingsWidget('Normal') self.fastmode_widget = self._setupMeasSettingsWidget('Fast') glay_mode.addWidget(self.normalmode_widget, 0, 0) glay_mode.addWidget(self.fastmode_widget, 0, 0) glay_mode.setContentsMargins(0, 0, 0, 0) self.mode_channel = SiriusConnectionSignal( self.dcct_prefix.substitute(propty='MeasMode-Sel')) self.mode_channel.new_value_signal.connect(self._showMeasModeSettings) # Details self.pb_details = QPushButton(qta.icon('fa5s.ellipsis-h'), '', self) self.pb_details.setToolTip('Open details') self.pb_details.setObjectName('detail') self.pb_details.setStyleSheet( "#detail{min-width:25px; max-width:25px; icon-size:20px;}") detail_window = create_window_from_widget(DCCTSettingsDetails, title=self.device + ' Settings Details') _hlautil.connect_window(self.pb_details, detail_window, self, prefix=self.prefix, device=self.device) gbox_gen = QGroupBox('Measure') glay_gen = QGridLayout(gbox_gen) glay_gen.setAlignment(Qt.AlignVCenter) glay_gen.addWidget(l_curr, 0, 0) glay_gen.addLayout(hlay_current, 0, 1) glay_gen.addWidget(l_reliablemeas, 1, 0) glay_gen.addWidget(self.led_ReliableMeas, 1, 1, alignment=Qt.AlignLeft) glay_gen.addWidget(l_enbl, 2, 0) glay_gen.addLayout(hlay_enbl, 2, 1) glay_gen.addWidget(l_meastrig, 3, 0) glay_gen.addLayout(hlay_meastrig, 3, 1) if 'SI' in self.device: glay_gen.addWidget(l_range, 4, 0) glay_gen.addLayout(hlay_range, 4, 1) glay_gen.addWidget(l_measmode, 5, 0) glay_gen.addLayout(hlay_measmode, 5, 1) glay_gen.addLayout(glay_mode, 6, 0, 1, 2) glay_gen.addWidget(self.pb_details, 7, 0, 1, 2, alignment=Qt.AlignRight) gbox_gen.setStyleSheet(""" .QLabel{ qproperty-alignment: 'AlignVCenter | AlignRight'; min-width: 6em;} PyDMLed{ min-width: 6em;}""") lay.addWidget(gbox_gen) lay.setStretch(1, 7) # Trigger self.trigger_widget = QGroupBox('Trigger') hbl = QHBoxLayout(self.trigger_widget) hbl.addWidget( HLTriggerSimple(self.trigger_widget, device=self.device.substitute(dis='TI'), prefix=self.prefix)) lay.addWidget(self.trigger_widget) lay.setStretch(2, 3) self.setLayout(lay) self.setStyleSheet(""" QSpinBox, QComboBox, QPushButton, PyDMSpinbox, PyDMEnumComboBox, PyDMLabel{ min-width:6em; max-width:6em;} .QLabel{max-height:1.5em;}""")
def _setupUi(self): title = QLabel(self.title, self, alignment=Qt.AlignCenter) title.setStyleSheet("font-weight: bold;") title.setSizePolicy(QSzPlcy.Preferred, QSzPlcy.Maximum) # limit setpoints self._wid_lims = QGroupBox('Select Thresholds: ') lay_lims = QGridLayout(self._wid_lims) lay_lims.setAlignment(Qt.AlignTop) row = 0 if 'sum' in self.metric: text = '\nThresholds must be set in Monit1 rate\n'\ 'counts. Here we make available you \n'\ 'to read Sum-Mon values, in Monit rate\n'\ 'counts, and convert them to Monit1\n'\ 'rate counts using calibration curves.\n'\ 'You can also apply a scale factor to\n'\ 'the values read.\n\n' self._label_help = QLabel(text, self) lay_lims.addWidget(self._label_help, row, 0, 1, 2) row += 1 self._pb_get = QPushButton('Get current Sum-Mon', self) self._pb_get.released.connect(self._get_new_sum) lay_lims.addWidget(self._pb_get, row, 0, 1, 2) row += 1 self._label_getsts = QLabel('\n', self) lay_lims.addWidget(self._label_getsts, row, 0, 1, 2) row += 1 self._label_scl = QLabel('Scale: ', self) lay_lims.addWidget(self._label_scl, row, 0) self._spin_scl = QDoubleSpinBox(self) self._spin_scl.setDecimals(2) self._spin_scl.setValue(1.00) self._spin_scl.setMinimum(-100.00) self._spin_scl.setMaximum(+100.00) lay_lims.addWidget(self._spin_scl, row, 1) else: self._head_value = QLabel('Value', self, alignment=Qt.AlignCenter) lay_lims.addWidget(self._head_value, 0, 1) self._head_send = QLabel('Apply', self, alignment=Qt.AlignCenter) lay_lims.addWidget(self._head_send, 0, 2) self._spins, self._checks = dict(), dict() for lsp in self.lim_sp: row += 1 text = lsp.split('-')[0].split('Lmt')[1] + ' [nm]: ' label = QLabel(text, self, alignment=Qt.AlignRight) lay_lims.addWidget(label, row, 0) spin = QSpinBox(self) self._spins[lsp] = spin spin.setValue(0) spin.setMinimum(-1e9) spin.setMaximum(1e9) lay_lims.addWidget(spin, row, 1) check = QCheckBox(self) self._checks[lsp] = check lay_lims.addWidget(check, row, 2, alignment=Qt.AlignCenter) row += 1 self._label_reforb = QLabel( '\nChoose Ref.Orb. to calculate reference\n' + self.title.lower() + ' around which we\napply the values above:') lay_lims.addWidget(self._label_reforb, row, 0, 1, 3) row += 1 self._cb_reforb = RefOrbComboBox(self) self._cb_reforb.refOrbChanged.connect(self._set_ref_orb) lay_lims.addWidget(self._cb_reforb, row, 0, 1, 3) if 'trans' in self.metric: text = '\n\nBPM calculation consider the translation\n' \ 'estimative:' \ '\n\n(pos@downstream+pos@upstream)/2\n\n' \ 'where the pairs upstream/downstream\nfolow:\n' \ ' - M1/M2\n' \ ' - C1-1/C1-2\n' \ ' - C2/C3-1\n' \ ' - C3-2/C4\n' elif 'ang' in self.metric: text = '\n\nBPM calculation consider the angulation\n' \ 'estimative:' \ '\n\n(pos@downstream - pos@upstream)\n\n' \ 'where the pairs upstream/downstream\nfolow:\n' \ ' - M1/M2\n' \ ' - C1-1/C1-2\n' \ ' - C2/C3-1\n' \ ' - C3-2/C4\n' row += 1 self._label_help = QLabel(text, self) lay_lims.addWidget(self._label_help, row, 0, 1, 3) # BPM selection groupsel = QGroupBox('Select BPMs:') groupsel.setObjectName('groupsel') groupsel.setStyleSheet('#groupsel{min-width: 27em; max-width: 27em;}') self._bpm_sel = _BPMSelectionWidget(self, show_toggle_all_false=False, toggle_all_true_text='Select All', prefix=self.prefix) lay_groupsel = QGridLayout(groupsel) lay_groupsel.addWidget(self._bpm_sel) # connect signals and slots self._bpm_sel.applyChangesClicked.connect(self.send_value) lay = QGridLayout(self) lay.addWidget(title, 0, 0, 1, 2) lay.addWidget(self._wid_lims, 1, 0) lay.addWidget(groupsel, 1, 1)
def _setup_ui(self): # setup central widget self.central_widget = QFrame() self.central_widget.setStyleSheet(""" #OkList { background-color: #eafaea; } #NokList { background-color: #ffebe6; } QLabel{ max-height: 1.29em; } QTabWidget::pane { border-left: 2px solid gray; border-bottom: 2px solid gray; border-right: 2px solid gray; }""") self.setCentralWidget(self.central_widget) self.tab = QTabWidget(self) self.tab.setObjectName('ASTab') # # PS self.ps_wid = QWidget(self) lay_ps = QGridLayout(self.ps_wid) lay_ps.setContentsMargins(0, 9, 0, 0) lay_ps.setHorizontalSpacing(0) # PS selection self.ps_tree = PVNameTree(items=self._get_ps_tree_names(), tree_levels=('sec', 'mag_group'), parent=self) self.ps_tree.tree.setHeaderHidden(True) self.ps_tree.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.ps_tree.tree.setColumnCount(1) self.ps_tree.tree.doubleClicked.connect(self._open_detail) self.ps_tree.tree.itemChanged.connect( self._handle_checked_items_changed) gbox_ps_select = QGroupBox('Select PS: ', self) gbox_ps_select.setObjectName('select') gbox_ps_select.setStyleSheet(""" #select{ border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; }""") lay_ps_select = QVBoxLayout(gbox_ps_select) lay_ps_select.addWidget(self.ps_tree) lay_ps.addWidget(gbox_ps_select, 0, 0) lay_ps.setColumnStretch(0, 1) # PS commands self.checkcomm_ps_bt = QPushButton('Check Communication', self) self.checkcomm_ps_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.checkcomm_ps_bt.clicked.connect(self._check_comm) self.checkcomm_ps_bt.setToolTip( 'Check PS and DCLinks communication status (verify invalid alarms ' 'and, if LI, the value of Connected-Mon PV)') self.checkstatus_ps_bt = QPushButton('Show Status Summary', self) self.checkstatus_ps_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.checkstatus_ps_bt.clicked.connect(_part(self._check_status, 'PS')) self.checkstatus_ps_bt.setToolTip( 'Check PS and DCLinks interlock status and, if powered on, ' 'check if it is following reference') self.dsbltrigger_ps_bt = QPushButton('Disable PS triggers', self) self.dsbltrigger_ps_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.dsbltrigger_ps_bt.clicked.connect( _part(self._set_check_trigger_state, 'PS', 'dsbl')) self.setsofbmode_ps_bt = QPushButton('Turn Off SOFBMode', self) self.setsofbmode_ps_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.setsofbmode_ps_bt.clicked.connect( _part(self._set_check_fbp_sofbmode, 'off')) self.setslowref_ps_bt = QPushButton('Set PS and DCLinks to SlowRef', self) self.setslowref_ps_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.setslowref_ps_bt.clicked.connect(self._set_check_opmode_slowref) self.currzero_ps_bt1 = QPushButton('Set PS Current to zero', self) self.currzero_ps_bt1.clicked.connect(_part(self._set_lastcomm, 'PS')) self.currzero_ps_bt1.clicked.connect(self._set_zero_ps) self.reset_ps_bt = QPushButton('Reset PS and DCLinks', self) self.reset_ps_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.reset_ps_bt.clicked.connect(_part(self._reset_intlk, 'PS')) self.prep_sidclink_bt = QPushButton('Prepare SI Fam DCLinks', self) self.prep_sidclink_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.prep_sidclink_bt.clicked.connect(self._prepare_sidclinks) self.prep_sidclink_bt.setVisible(False) self.init_sips_bt = QPushButton('Initialize SI Fam PS', self) self.init_sips_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.init_sips_bt.clicked.connect(self._set_check_pwrstateinit) self.init_sips_bt.setVisible(False) self.aux_label = QLabel('') self.aux_label.setVisible(False) self.turnon_dcl_bt = QPushButton('Turn DCLinks On', self) self.turnon_dcl_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.turnon_dcl_bt.clicked.connect( _part(self._set_check_pwrstate_dclinks, 'on')) self.checkctrlloop_dcl_bt = QPushButton('Check DCLinks CtrlLoop', self) self.checkctrlloop_dcl_bt.clicked.connect( _part(self._set_lastcomm, 'PS')) self.checkctrlloop_dcl_bt.clicked.connect( _part(self._set_check_ctrlloop, 'dclink')) self.setvolt_dcl_bt = QPushButton('Set DCLinks Voltage', self) self.setvolt_dcl_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.setvolt_dcl_bt.clicked.connect(self._set_check_dclinks_capvolt) self.turnon_ps_bt = QPushButton('Turn PS On', self) self.turnon_ps_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.turnon_ps_bt.clicked.connect( _part(self._set_check_pwrstate, 'PS', 'on', True)) self.setcheckctrlloop_ps_bt = QPushButton('Check PS CtrlLoop', self) self.setcheckctrlloop_ps_bt.clicked.connect( _part(self._set_lastcomm, 'PS')) self.setcheckctrlloop_ps_bt.clicked.connect( _part(self._set_check_ctrlloop, 'pwrsupply')) self.test_ps_bt = QPushButton('Set PS Current to test value', self) self.test_ps_bt.clicked.connect(_part(self._set_lastcomm, 'PS')) self.test_ps_bt.clicked.connect(self._set_test_ps) self.currzero_ps_bt2 = QPushButton('Set PS Current to zero', self) self.currzero_ps_bt2.clicked.connect(_part(self._set_lastcomm, 'PS')) self.currzero_ps_bt2.clicked.connect(self._set_zero_ps) self.restoretrigger_ps_bt = QPushButton('Restore PS triggers', self) self.restoretrigger_ps_bt.clicked.connect( _part(self._set_lastcomm, 'PS')) self.restoretrigger_ps_bt.clicked.connect( _part(self._restore_triggers_state, 'PS')) gbox_ps_comm = QGroupBox('Commands', self) gbox_ps_comm.setObjectName('comm') gbox_ps_comm.setStyleSheet('#comm{border: 0px solid transparent;}') lay_ps_comm = QVBoxLayout(gbox_ps_comm) lay_ps_comm.setContentsMargins(20, 9, 20, 9) lay_ps_comm.addWidget(QLabel('')) lay_ps_comm.addWidget( QLabel('<h4>Check</h4>', self, alignment=Qt.AlignCenter)) lay_ps_comm.addWidget(self.checkcomm_ps_bt) lay_ps_comm.addWidget(self.checkstatus_ps_bt) lay_ps_comm.addWidget(QLabel('')) lay_ps_comm.addWidget( QLabel('<h4>Prepare</h4>', self, alignment=Qt.AlignCenter)) lay_ps_comm.addWidget(self.dsbltrigger_ps_bt) lay_ps_comm.addWidget(self.setsofbmode_ps_bt) lay_ps_comm.addWidget(self.setslowref_ps_bt) lay_ps_comm.addWidget(self.currzero_ps_bt1) lay_ps_comm.addWidget(self.reset_ps_bt) lay_ps_comm.addWidget(QLabel('')) lay_ps_comm.addWidget(self.prep_sidclink_bt) lay_ps_comm.addWidget(self.init_sips_bt) lay_ps_comm.addWidget(self.aux_label) lay_ps_comm.addWidget( QLabel('<h4>Config DCLinks</h4>', self, alignment=Qt.AlignCenter)) lay_ps_comm.addWidget(self.turnon_dcl_bt) lay_ps_comm.addWidget(self.checkctrlloop_dcl_bt) lay_ps_comm.addWidget(self.setvolt_dcl_bt) lay_ps_comm.addWidget(QLabel('')) lay_ps_comm.addWidget( QLabel('<h4>Test</h4>', self, alignment=Qt.AlignCenter)) lay_ps_comm.addWidget(self.turnon_ps_bt) lay_ps_comm.addWidget(self.setcheckctrlloop_ps_bt) lay_ps_comm.addWidget(self.test_ps_bt) lay_ps_comm.addWidget(self.currzero_ps_bt2) lay_ps_comm.addWidget(QLabel('')) lay_ps_comm.addWidget( QLabel('<h4>Restore</h4>', self, alignment=Qt.AlignCenter)) lay_ps_comm.addWidget(self.restoretrigger_ps_bt) lay_ps_comm.addWidget(QLabel('')) lay_ps.addWidget(gbox_ps_comm, 0, 1) lay_ps.setColumnStretch(1, 1) self.tab.addTab(self.ps_wid, 'PS') # # PU self.pu_wid = QWidget(self) lay_pu = QGridLayout(self.pu_wid) lay_pu.setContentsMargins(0, 9, 0, 0) lay_pu.setHorizontalSpacing(0) # PU selection self.pu_tree = PVNameTree(items=self._get_pu_tree_names(), tree_levels=('sec', ), parent=self) self.pu_tree.tree.setHeaderHidden(True) self.pu_tree.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.pu_tree.tree.setColumnCount(1) self.pu_tree.tree.doubleClicked.connect(self._open_detail) gbox_pu_select = QGroupBox('Select PU: ', self) gbox_pu_select.setObjectName('select') gbox_pu_select.setStyleSheet(""" #select{ border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; }""") lay_pu_select = QVBoxLayout(gbox_pu_select) lay_pu_select.addWidget(self.pu_tree) lay_pu.addWidget(gbox_pu_select, 0, 0) lay_pu.setColumnStretch(0, 1) # PU commands self.checkstatus_pu_bt = QPushButton('Show Status Summary', self) self.checkstatus_pu_bt.clicked.connect(_part(self._set_lastcomm, 'PU')) self.checkstatus_pu_bt.clicked.connect(_part(self._check_status, 'PU')) self.checkstatus_pu_bt.setToolTip( 'Check PU interlock status and, if powered on, ' 'check if it is following voltage setpoint') self.voltzero_pu_bt1 = QPushButton('Set PU Voltage to zero', self) self.voltzero_pu_bt1.clicked.connect(_part(self._set_lastcomm, 'PU')) self.voltzero_pu_bt1.clicked.connect(_part(self._set_zero_pu, False)) self.reset_pu_bt = QPushButton('Reset PU', self) self.reset_pu_bt.clicked.connect(_part(self._set_lastcomm, 'PU')) self.reset_pu_bt.clicked.connect(_part(self._reset_intlk, 'PU')) self.turnon_pu_bt = QPushButton('Turn PU On', self) self.turnon_pu_bt.clicked.connect(_part(self._set_lastcomm, 'PU')) self.turnon_pu_bt.clicked.connect( _part(self._set_check_pwrstate, 'PU', 'on', True)) self.enblpulse_pu_bt = QPushButton('Enable PU Pulse', self) self.enblpulse_pu_bt.clicked.connect(_part(self._set_lastcomm, 'PU')) self.enblpulse_pu_bt.clicked.connect(_part(self._set_check_pulse, 'on')) self.enbltrigger_pu_bt = QPushButton('Enable PU triggers', self) self.enbltrigger_pu_bt.clicked.connect(_part(self._set_lastcomm, 'PU')) self.enbltrigger_pu_bt.clicked.connect( _part(self._set_check_trigger_state, 'PU', 'on')) self.test_pu_bt = QPushButton('Set PU Voltage to test value', self) self.test_pu_bt.clicked.connect(_part(self._set_lastcomm, 'PU')) self.test_pu_bt.clicked.connect(self._set_test_pu) self.voltzero_pu_bt2 = QPushButton('Set PU Voltage to zero', self) self.voltzero_pu_bt2.clicked.connect(_part(self._set_lastcomm, 'PU')) self.voltzero_pu_bt2.clicked.connect(_part(self._set_zero_pu, True)) self.restoretrigger_pu_bt = QPushButton('Restore PU triggers', self) self.restoretrigger_pu_bt.clicked.connect( _part(self._set_lastcomm, 'PU')) self.restoretrigger_pu_bt.clicked.connect( _part(self._restore_triggers_state, 'PU')) gbox_pu_comm = QGroupBox('Commands', self) gbox_pu_comm.setObjectName('comm') gbox_pu_comm.setStyleSheet('#comm{border: 0px solid transparent;}') lay_pu_comm = QVBoxLayout(gbox_pu_comm) lay_pu_comm.setContentsMargins(20, 9, 20, 9) lay_pu_comm.addWidget(QLabel('')) lay_pu_comm.addWidget( QLabel('<h4>Check</h4>', self, alignment=Qt.AlignCenter)) lay_pu_comm.addWidget(self.checkstatus_pu_bt) lay_pu_comm.addWidget(QLabel('')) lay_pu_comm.addWidget( QLabel('<h4>Prepare</h4>', self, alignment=Qt.AlignCenter)) lay_pu_comm.addWidget(self.voltzero_pu_bt1) lay_pu_comm.addWidget(self.reset_pu_bt) lay_pu_comm.addWidget(QLabel('')) lay_pu_comm.addWidget( QLabel('<h4>Test</h4>', self, alignment=Qt.AlignCenter)) lay_pu_comm.addWidget(self.turnon_pu_bt) lay_pu_comm.addWidget(self.enblpulse_pu_bt) lay_pu_comm.addWidget(self.enbltrigger_pu_bt) lay_pu_comm.addWidget(self.test_pu_bt) lay_pu_comm.addWidget(self.voltzero_pu_bt2) lay_pu_comm.addWidget(QLabel('')) lay_pu_comm.addWidget( QLabel('<h4>Restore</h4>', self, alignment=Qt.AlignCenter)) lay_pu_comm.addWidget(self.restoretrigger_pu_bt) lay_pu_comm.addWidget(QLabel('')) lay_pu.addWidget(gbox_pu_comm, 0, 1) lay_pu.setColumnStretch(1, 1) self.tab.addTab(self.pu_wid, 'PU') # lists self.label_lastcomm = QLabel('Last Command: ', self) self.ok_ps = QListWidget(self) self.ok_ps.setObjectName('OkList') self.ok_ps.doubleClicked.connect(self._open_detail) self.ok_ps.setSelectionMode(QAbstractItemView.MultiSelection) self.ok_ps.setToolTip( 'Select rows and press Ctrl+C to copy and Esc to deselect.') self.nok_ps = QListWidget(self) self.nok_ps.setObjectName('NokList') self.nok_ps.doubleClicked.connect(self._open_detail) self.nok_ps.setSelectionMode(QAbstractItemView.MultiSelection) self.nok_ps.setToolTip( 'Select rows and press Ctrl+C to copy and Esc to deselect.') self.clearlists_bt = QPushButton('Clear', self) self.clearlists_bt.clicked.connect(self._clear_lastcomm) self.ok_ps_aux_list = list() self.nok_ps_aux_list = list() hbox = QHBoxLayout() hbox.addWidget(self.label_lastcomm) hbox.addWidget(self.clearlists_bt, alignment=Qt.AlignRight) list_layout = QGridLayout() list_layout.setContentsMargins(0, 0, 0, 0) list_layout.setVerticalSpacing(6) list_layout.setHorizontalSpacing(9) list_layout.addLayout(hbox, 0, 0, 1, 2) list_layout.addWidget( QLabel('<h4>Ok</h4>', self, alignment=Qt.AlignCenter), 1, 0) list_layout.addWidget(self.ok_ps, 2, 0) list_layout.addWidget( QLabel('<h4>Failed</h4>', self, alignment=Qt.AlignCenter), 1, 1) list_layout.addWidget(self.nok_ps, 2, 1) # menu self.menu = self.menuBar() self.act_cycle = self.menu.addAction('Open Cycle Window') connect_newprocess(self.act_cycle, 'sirius-hla-as-ps-cycle.py', parent=self) self.aux_comm = self.menu.addMenu('Auxiliary commands') # # auxiliary PS self.ps_menu = self.aux_comm.addMenu('PS') self.act_turnoff_ps = self.ps_menu.addAction('Turn PS Off') self.act_turnoff_ps.triggered.connect(_part(self._set_lastcomm, 'PS')) self.act_turnoff_ps.triggered.connect( _part(self._set_check_pwrstate, 'PS', 'off', True)) self.act_turnoff_dclink = self.ps_menu.addAction('Turn DCLinks Off') self.act_turnoff_dclink.triggered.connect( _part(self._set_lastcomm, 'PS')) self.act_turnoff_dclink.triggered.connect( _part(self._set_check_pwrstate_dclinks, 'off')) self.act_setcurrent_ps = self.ps_menu.addAction('Set PS Current') self.act_setcurrent_ps.triggered.connect( _part(self._set_lastcomm, 'PS')) self.act_setcurrent_ps.triggered.connect(self._set_check_current) self.act_opmode_ps = self.ps_menu.addAction('Set PS OpMode') self.act_opmode_ps.triggered.connect(_part(self._set_lastcomm, 'PS')) self.act_opmode_ps.triggered.connect(self._set_check_opmode) # # auxiliary PU self.pu_menu = self.aux_comm.addMenu('PU') self.act_turnoff_pu = self.pu_menu.addAction('Turn PU Off') self.act_turnoff_pu.triggered.connect(_part(self._set_lastcomm, 'PU')) self.act_turnoff_pu.triggered.connect( _part(self._set_check_pwrstate, 'PU', 'off', True)) self.act_dsblpulse_pu = self.pu_menu.addAction('Disable PU Pulse') self.act_dsblpulse_pu.triggered.connect(_part(self._set_lastcomm, 'PU')) self.act_dsblpulse_pu.triggered.connect( _part(self._set_check_pulse, 'off')) # layout lay = QGridLayout() lay.setHorizontalSpacing(15) lay.setVerticalSpacing(5) lay.addWidget( QLabel('<h3>Power Supplies Test</h3>', self, alignment=Qt.AlignCenter), 0, 0, 1, 3) lay.addWidget(self.tab, 1, 0) lay.addLayout(list_layout, 1, 1) lay.setColumnStretch(0, 2) lay.setColumnStretch(1, 2) lay.setRowStretch(0, 2) lay.setRowStretch(1, 18) self.central_widget.setLayout(lay)
def _make_groupbox(self, sec): status = QGroupBox(sec, self) status_lay = QGridLayout() status_lay.setAlignment(Qt.AlignTop) status.setStyleSheet("QLabel{max-height: 1.4em;}") status.setLayout(status_lay) def update_gridpos(row, col, col_count, offset=0): new_col = offset if col == offset+col_count-1 else col+1 new_row = row+1 if new_col == offset else row return [new_row, new_col] row, col = 0, 0 for label, devices in self.get_label2devices(sec).items(): if not devices: continue grid = QGridLayout() grid.setVerticalSpacing(6) grid.setHorizontalSpacing(6) if sec == 'BO' and label in ['CH', 'CV']: desc = QLabel(label, self, alignment=Qt.AlignRight) grid.addWidget(desc, 0, 0) for i in range(5): lbh = QLabel('{0:02d}'.format(i*2+1), self, alignment=Qt.AlignRight) lbh.setStyleSheet("QLabel{max-width:2em;}") grid.addWidget(lbh, 0, i+1) lbv = QLabel('{0:02d}'.format(i*10), self, alignment=Qt.AlignRight) lbv.setStyleSheet("QLabel{max-width:2em;}") grid.addWidget(lbv, i+1, 0) aux_row, aux_col, offset = 1, 1, 1 if label == 'CV': aux = devices.pop(-1) devices.insert(0, aux) elif sec == 'SI': aux = devices.pop(-1) devices.insert(0, aux) if label == 'Trims': aux = devices.pop(-1) devices.insert(0, aux) if label in ['QS', 'FCV']: for i in range(1, 21): lb = QLabel('{0:02d}'.format(i), self) grid.addWidget(lb, i+1, (0 if label == 'QS' else 5)) if label in ['QS', 'CH', 'CV', 'Trims', 'FCH', 'FCV']: aux_row, aux_col = 2, (1 if label == 'QS' else 0) offset = (1 if label == 'QS' else 0) i = 0 for text in self.get_dev2sub_labels(label): lbh = QLabel(text, self, alignment=Qt.AlignCenter) grid.addWidget(lbh, 1, offset+i) i += 1 else: aux_row, aux_col, offset = 1, 0, 0 grid.addWidget(QLabel(label, self), 0, offset, 1, 4) else: grid.addWidget(QLabel(label, self), 0, 0, 1, 4) aux_row, aux_col, offset = 1, 0, 0 for name in devices: if label == 'Trims' and aux_row in (2, 6, 10, 14, 18) \ and aux_col in (0, 3): grid.addWidget(QLabel(''), aux_row, aux_col) aux_col += 1 led = MyLed(self, SiriusPVName(name).substitute( prefix=self._prefix, propty='DiagStatus-Mon'), name) grid.addWidget(led, aux_row, aux_col) aux_row, aux_col = update_gridpos( aux_row, aux_col, self.get_col2dev_count(sec, label), offset) row, col, rowc, colc = self.get_sec2dev_laypos(sec, label) status_lay.addLayout(grid, row, col, rowc, colc, alignment=Qt.AlignTop) if sec == 'LI': status_lay.setColumnStretch(0, 2) status_lay.setColumnStretch(1, 5) status_lay.setColumnStretch(2, 7) status_lay.setColumnStretch(3, 3) status_lay.setColumnStretch(4, 2) status_lay.setVerticalSpacing(12) status_lay.setHorizontalSpacing(16) elif sec == 'SI': status_lay.setColumnStretch(0, 1) status_lay.setColumnStretch(1, 2) status_lay.setColumnStretch(2, 2) status_lay.setColumnStretch(3, 3) status_lay.setColumnStretch(4, 3) status_lay.setColumnStretch(5, 8) status_lay.setColumnStretch(6, 14) status_lay.setColumnStretch(7, 3) status_lay.setColumnStretch(8, 4) status_lay.setColumnStretch(9, 4) status_lay.setVerticalSpacing(12) status_lay.setHorizontalSpacing(12) else: status_lay.setVerticalSpacing(12) status_lay.setHorizontalSpacing(16) return status
def _setupRawReadings(self): self.label_waveread = QLabel('<h3>Current Raw Readings</h3>', self, alignment=Qt.AlignCenter) self.wavegraph = PyDMWaveformPlot(self) self.wavegraph.setLabels(left='Current [mA]', bottom='Index') channel = 'FAKE:Readings' self.rawreadings_channel = SignalChannel( self.dcct_prefix.substitute(propty='RawReadings-Mon')) self.rawreadings_channel.new_value_signal[np.ndarray].connect( self._updateRawBuffer) self.wavegraph.addChannel(y_channel=channel, name='Current Raw Readings', color='blue', lineWidth=2, lineStyle=Qt.SolidLine) self.wavegraph.autoRangeX = True self.wavegraph.autoRangeY = True self.wavegraph.backgroundColor = QColor(255, 255, 255) self.wavegraph.showLegend = False self.wavegraph.showXGrid = True self.wavegraph.showYGrid = True self.wavegraph.plotItem.showButtons() self.wavecurve = self.wavegraph.curveAtIndex(0) wid = QWidget() lay = QGridLayout(wid) lay.setAlignment(Qt.AlignTop) lay.setRowStretch(0, 1) lay.setRowStretch(1, 9) lay.addWidget(self.label_waveread, 0, 0) lay.addWidget(self.wavegraph, 1, 0) # Smoothing evgname = SiriusPVName(_LLTimeSearch.get_evg_name()) self._evnt_dly = SignalChannel( evgname.substitute(prefix=self.prefix, propty='Dig' + self.device.sec + 'Delay-RB')) self._evnt_dly.new_value_signal[float].connect(self.updateRawXAxis) self._trig_dly = SignalChannel( self.dcct_prefix.substitute(dis='TI', propty='Delay-RB')) self._trig_dly.new_value_signal[float].connect(self.updateRawXAxis) self._smpl_cnt = SignalChannel( self.dcct_prefix.substitute(propty='FastSampleCnt-RB')) self._smpl_cnt.new_value_signal[float].connect(self.updateRawXAxis) self._meas_per = SignalChannel( self.dcct_prefix.substitute(propty='FastMeasPeriod-RB')) self._meas_per.new_value_signal[float].connect(self.updateRawXAxis) self.cb_timeaxis = QCheckBox('Use time axis', self) self.cb_timeaxis.setChecked(True) self.cb_timeaxis.stateChanged.connect(self.updateRawXAxis) self.cb_timeaxis.setLayoutDirection(Qt.RightToLeft) lay.addWidget(self.cb_timeaxis, 2, 0, alignment=Qt.AlignLeft) lay.setRowStretch(2, 1) l_smoothmethod = QLabel('Method: ', self) self.cb_smoothmethod = QComboBox(self) self.cb_smoothmethod.addItems(['Average', 'Median']) self.cb_smoothmethod.currentTextChanged.connect( self.setRawSmoothMethod) l_smoothnracq = QLabel('Nr.Acqs.: ', self) self.sb_smoothnracq = QSpinBoxPlus(self) self.sb_smoothnracq.setValue(1) self.sb_smoothnracq.valueChanged.connect(self.setRawSmoothNrAcq) l_smoothbuff = QLabel('Buffer Size: ', self) l_smoothbuff.setSizePolicy(QSzPly.Minimum, QSzPly.Preferred) self.label_buffsize = QLabel('', self) self.label_buffsize.setStyleSheet('min-width:3em; max-width:3em;') self.pb_resetbuff = QPushButton(qta.icon('mdi.delete-empty'), '', self) self.pb_resetbuff.setToolTip('Reset buffer') self.pb_resetbuff.setObjectName('resetbuff') self.pb_resetbuff.setStyleSheet( "#resetbuff{min-width:25px; max-width:25px; icon-size:20px;}") self.pb_resetbuff.clicked.connect(self.resetRawBuffer) hlay_buff = QHBoxLayout() hlay_buff.addWidget(self.label_buffsize) hlay_buff.addWidget(self.pb_resetbuff) l_down = QLabel('Downsampling: ', self) self.sb_down = QSpinBoxPlus(self) self.sb_down.setValue(1) self.sb_down.valueChanged.connect(self.setRawDownsampling) gbox_smooth = QGroupBox('Smoothing of Readings') glay_smooth = QGridLayout(gbox_smooth) glay_smooth.addWidget(l_smoothmethod, 0, 0) glay_smooth.addWidget(self.cb_smoothmethod, 0, 1) glay_smooth.addWidget(l_smoothnracq, 1, 0) glay_smooth.addWidget(self.sb_smoothnracq, 1, 1) glay_smooth.addWidget(QLabel(''), 0, 2) glay_smooth.addWidget(l_smoothbuff, 0, 3) glay_smooth.addLayout(hlay_buff, 0, 4, 1, 2) glay_smooth.addWidget(l_down, 1, 3) glay_smooth.addWidget(self.sb_down, 1, 4, 1, 2) glay_smooth.setColumnStretch(0, 10) glay_smooth.setColumnStretch(1, 10) glay_smooth.setColumnStretch(2, 2) glay_smooth.setColumnStretch(3, 10) glay_smooth.setColumnStretch(4, 5) glay_smooth.setColumnStretch(5, 5) lay.addWidget(gbox_smooth, 3, 0) lay.setRowStretch(3, 3) gbox_smooth.setStyleSheet(""" .QLabel{ qproperty-alignment: 'AlignVCenter | AlignRight';} QPushButton{ min-width:3em; max-width:3em;}""") return wid