def setupui(self): vbl = QVBoxLayout(self) tip = 'Configure ' + ('Acquisition' if self.is_orb else 'Correctors') pv = 'TrigAcqConfig-Cmd' if self.is_orb else 'CorrConfig-Cmd' conf = PyDMPushButton(self, init_channel=self.devpref.substitute(propty=pv), pressValue=1) conf.setToolTip(tip) conf.setIcon(qta.icon('fa5s.sync')) conf.setObjectName('conf') conf.setStyleSheet( '#conf{min-width:25px; max-width:25px; icon-size:20px;}') vbl.addWidget(conf) pv = 'Orb' if self.is_orb else 'Corr' pdm_led = SiriusLedAlert( self, self.devpref.substitute(propty=pv + 'Status-Mon')) hbl = QHBoxLayout() hbl.setSpacing(9) hbl.addWidget(pdm_led) hbl.addWidget(QLabel('Global Status', self)) hbl.addStretch() hbl.addWidget(conf) vbl.addItem(hbl) grpbx = self.creategroupbox() vbl.addWidget(grpbx)
def _get_multturn_acq_grpbx(self): grp_bx = QWidget(self) fbl = QFormLayout(grp_bx) lbl = QLabel('Downsampling', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair(grp_bx, 'MTurnDownSample') fbl.addRow(lbl, wid) lbl = QLabel('Index', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair(grp_bx, 'MTurnIdx') fbl.addRow(lbl, wid) lbl = QLabel('Index Time', grp_bx, alignment=Qt.AlignCenter) wid = QWidget(grp_bx) pdm_lbl = SiriusLabel( wid, self.devpref.substitute(propty='MTurnIdxTime-Mon')) pdm_lbl.showUnits = True pdm_lbl.setAlignment(Qt.AlignCenter) conf = PyDMPushButton( wid, pressValue=1, init_channel=self.devpref.substitute(propty='MTurnAcquire-Cmd')) conf.setToolTip('Update MTurn PVs') conf.setIcon(qta.icon('fa5s.sync')) conf.setObjectName('conf') conf.setStyleSheet( '#conf{min-width:25px; max-width:25px; icon-size:20px;}') hbl = QHBoxLayout(wid) hbl.addWidget(pdm_lbl) hbl.addWidget(conf) fbl.addRow(lbl, wid) lbl = QLabel('TbT Sync', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair_butled(grp_bx, 'MTurnSyncTim') fbl.addRow(lbl, wid) self._set_detailed([lbl, wid]) lbl = QLabel('TbT Mask', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair_butled(grp_bx, 'MTurnUseMask') fbl.addRow(lbl, wid) self._set_detailed([lbl, wid]) lbl = QLabel('Mask Begin', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair(grp_bx, 'MTurnMaskSplBeg') fbl.addRow(lbl, wid) self._set_detailed([lbl, wid]) lbl = QLabel('Mask End', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair(grp_bx, 'MTurnMaskSplEnd') fbl.addRow(lbl, wid) self._set_detailed([lbl, wid]) return grp_bx
def setglobalparameters(self): wid = QWidget(self.centralWidget()) wid.setSizePolicy(QSzPol.Preferred, QSzPol.Maximum) lay = QGridLayout(wid) evg_dev = SiriusPVName(LLTimeSearch.get_evg_name()) evg_pref = evg_dev.substitute(prefix=self.prefix) sp = PyDMPushButton( self, init_channel=evg_pref.substitute(propty='UpdateEvt-Cmd'), pressValue=1) sp.setIcon(qta.icon('fa5s.sync')) sp.setToolTip('Update Events Table') sp.setObjectName('but') sp.setStyleSheet( '#but{min-width:25px; max-width:25px; icon-size:20px;}') rb = PyDMLed( self, init_channel=evg_pref.substitute(propty='EvtSyncStatus-Mon')) rb.setOffColor(rb.Red) rb.setOnColor(rb.LightGreen) lay.addWidget( self._create_prop_widget('<h4>Update Evts</h4>', wid, (sp, rb)), 0, 0) sp = PyDMStateButton( self, init_channel=evg_pref.substitute(propty='ContinuousEvt-Sel')) rb = PyDMLed( self, init_channel=evg_pref.substitute(propty='ContinuousEvt-Sts')) lay.addWidget( self._create_prop_widget('<h4>Continuous</h4>', wid, (sp, rb)), 0, 1) sp = PyDMStateButton( self, init_channel=evg_pref.substitute(propty='InjectionEvt-Sel')) rb = PyDMLed( self, init_channel=evg_pref.substitute(propty='InjectionEvt-Sts')) lay.addWidget( self._create_prop_widget('<h4>Injection</h4>', wid, (sp, rb)), 0, 2) bucketlist_wid = BucketList(self.centralWidget(), evg_dev, self.prefix) bucketlist_wid.setSizePolicy(QSzPol.MinimumExpanding, QSzPol.Preferred) lay.addWidget(bucketlist_wid, 0, 3, 2, 1) hlay = QHBoxLayout() lab = QLabel('Inj Count:', wid) pydmlab = PyDMLabel( wid, init_channel=evg_pref.substitute(propty='InjCount-Mon')) pydmlab.setStyleSheet('min-width:5em;') pydmlab.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) hlay.addStretch() hlay.addWidget(lab) hlay.addWidget(pydmlab) hlay.addStretch() pydmlab = PyDMLabel( wid, init_channel=evg_pref.substitute(propty='STATEMACHINE')) pydmlab.setStyleSheet('min-width:10em;') hlay.addWidget(pydmlab) hlay.addStretch() pydmlab = PyDMLabel( wid, init_channel=evg_pref.substitute(propty='SeqCount-SP')) pydmlab.rules =\ '[{"name": "VisibleRule", "property": "Visible", ' +\ '"expression": "ch[0]==5", "channels": [{"channel": "' +\ evg_pref.substitute(propty_name='STATEMACHINE') +\ '", "trigger": true}]}]' pydmlab.setStyleSheet('min-width:3em;') hlay.addWidget(pydmlab) hlay.addStretch() lay.addItem(hlay, 1, 0, 1, 3) return wid
def get_measurement_widget(self, parent): """.""" meas_wid = QWidget(parent) meas_lay = QVBoxLayout(meas_wid) strt = PyDMPushButton( meas_wid, init_channel=self.devpref.substitute(propty="MeasRespMat-Cmd"), pressValue=ConstTLines.MeasRespMatCmd.Start) strt.setEnabled(True) strt.setToolTip('Start Measurement') strt.setIcon(qta.icon('fa5s.play')) strt.setObjectName('strt') strt.setStyleSheet( '#strt{min-width:25px; max-width:25px; icon-size:20px;}') stop = PyDMPushButton( meas_wid, init_channel=self.devpref.substitute(propty="MeasRespMat-Cmd"), pressValue=ConstTLines.MeasRespMatCmd.Stop) stop.setEnabled(True) stop.setToolTip('Stop Measurement') stop.setIcon(qta.icon('fa5s.stop')) stop.setObjectName('stop') stop.setStyleSheet( '#stop{min-width:25px; max-width:25px; icon-size:20px;}') rst = PyDMPushButton( meas_wid, init_channel=self.devpref.substitute(propty="MeasRespMat-Cmd"), pressValue=ConstTLines.MeasRespMatCmd.Reset) rst.setEnabled(True) rst.setToolTip('Reset Measurement Status') rst.setIcon(qta.icon('fa5s.sync')) rst.setObjectName('conf') rst.setStyleSheet( '#conf{min-width:25px; max-width:25px; icon-size:20px;}') lbl = PyDMLabel( meas_wid, self.devpref.substitute(propty='MeasRespMat-Mon')) lbl.setAlignment(Qt.AlignCenter) hbl = QHBoxLayout() hbl.setSpacing(8) meas_lay.addItem(hbl) hbl.addWidget(strt) hbl.addWidget(stop) hbl.addWidget(rst) hbl.addStretch() hbl.addWidget(lbl) fml = QFormLayout() meas_lay.addSpacing(20) meas_lay.addItem(fml) lbl = QLabel('CH [urad]', meas_wid) wid = self.create_pair(meas_wid, 'MeasRespMatKickCH') fml.addRow(lbl, wid) lbl = QLabel('CV [urad]', meas_wid) wid = self.create_pair(meas_wid, 'MeasRespMatKickCV') fml.addRow(lbl, wid) if self.acc in {'SI', 'BO'}: lbl = QLabel('RF [Hz]', meas_wid) wid = self.create_pair(meas_wid, 'MeasRespMatKickRF') fml.addRow(lbl, wid) lbl = QLabel('Wait [s]', meas_wid) lbl.setToolTip('Time to wait between kicks') wid = self.create_pair(meas_wid, 'MeasRespMatWait') fml.addRow(lbl, wid) return meas_wid
class APUSummaryWidget(APUSummaryBase): """APU Summary Widget.""" def __init__(self, parent=None, prefix=_vaca_prefix, device=''): """Init.""" super().__init__(parent) self._prefix = prefix self._device = _PVName(device) self._beamline = IDSearch.conv_idname_2_beamline(self._device) self.dev_pref = self._device.substitute(prefix=prefix) self._setupUi() def _setupUi(self): self._lb_bl = QLabel('<h4>' + self._beamline + '</h4>', self, alignment=Qt.AlignCenter) self._pb_dev = QPushButton(self._device, self) connect_newprocess( self._pb_dev, ['sirius-hla-si-id-control.py', '-dev', self._device]) self._sb_phs = PyDMSpinbox(self, self.dev_pref.substitute(propty='Phase-SP')) self._sb_phs.showStepExponent = False self._lb_phs = PyDMLabel(self, self.dev_pref.substitute(propty='Phase-Mon')) self._sb_kx = PyDMSpinbox(self, self.dev_pref.substitute(propty='Kx-SP')) self._sb_kx.showStepExponent = False self._lb_kx = PyDMLabel(self, self.dev_pref.substitute(propty='Kx-Mon')) self._sb_phsspd = PyDMSpinbox( self, self.dev_pref.substitute(propty='PhaseSpeed-SP')) self._sb_phsspd.showStepExponent = False self._lb_phsspd = PyDMLabel( self, self.dev_pref.substitute(propty='PhaseSpeed-Mon')) self._pb_start = PyDMPushButton(self, label='', icon=qta.icon('fa5s.play')) self._pb_start.setToolTip( 'Start automatic motion towards previously entered setpoint.') self._pb_start.channel = self.dev_pref.substitute(propty='DevCtrl-Cmd') self._pb_start.pressValue = 3 # Start self._pb_start.setObjectName('Start') self._pb_start.setStyleSheet( '#Start{min-width:30px; max-width:30px; icon-size:25px;}') self._pb_stop = PyDMPushButton(self, label='', icon=qta.icon('fa5s.stop')) self._pb_stop.setToolTip('Stop all motion, lock all brakes.') self._pb_stop.channel = self.dev_pref.substitute(propty='DevCtrl-Cmd') self._pb_stop.pressValue = 1 # Stop self._pb_stop.setObjectName('Stop') self._pb_stop.setStyleSheet( '#Stop{min-width:30px; max-width:30px; icon-size:25px;}') self._led_ismov = SiriusLedState( self, self.dev_pref.substitute(propty='Moving-Mon')) self._led_status = PyDMLedMultiChannel( self, { self.dev_pref.substitute(propty='Alarm-Mon'): 0, self.dev_pref.substitute(propty='IntlkInStop-Mon'): 0, self.dev_pref.substitute(propty='IntlkInEOpnGap-Mon'): 0, self.dev_pref.substitute(propty='IntlkOutPwrEnbld-Mon'): 1, self.dev_pref.substitute(propty='IsOperational-Mon'): 1 }) self._sb_blenbl = PyDMStateButton( self, self.dev_pref.substitute(propty='BeamLineCtrlEnbl-Sel')) self._led_blenbl = SiriusLedState( self, self.dev_pref.substitute(propty='BeamLineCtrlEnbl-Sts')) self._led_blmon = SiriusLedState( self, self.dev_pref.substitute(propty='BeamLineCtrl-Mon')) self.widgets = { 'Beamline': ([ self._lb_bl, ], 'v'), 'Device': ([ self._pb_dev, ], 'v'), 'Alarms': ([ self._led_status, ], 'v'), 'Phase': ([self._sb_phs, self._lb_phs], 'v'), 'Kx': ([self._sb_kx, self._lb_kx], 'v'), 'Phase Speed': ([self._sb_phsspd, self._lb_phsspd], 'v'), 'Start': ([ self._pb_start, ], 'v'), 'Stop': ([ self._pb_stop, ], 'v'), 'Moving': ([ self._led_ismov, ], 'v'), 'BeamLine Enable': ([self._sb_blenbl, self._led_blenbl], 'h'), 'Beamline Control': ([ self._led_blmon, ], 'v'), } layout = QHBoxLayout(self) for name, size in self.widgets_widths: objname = name.replace(' ', '') group = self.widgets[name] items, ori = group widget = QWidget(self) lay = QVBoxLayout() if ori == 'v' else QHBoxLayout() lay.setContentsMargins(0, 0, 0, 0) lay.setAlignment(Qt.AlignCenter) lay.setSpacing(0) widget.setLayout(lay) for item in items: lay.addWidget(item) widget.setObjectName(objname) widget.setStyleSheet( '#' + objname + '{{min-width:{0}em; max-width:{0}em;}}'.format(str(size))) layout.addWidget(widget) def enable_beamline_control(self): """Enable beamline control.""" if self._sb_blenbl.isEnabled(): if not self._sb_blenbl.value: self._sb_blenbl.send_value() def disable_beamline_control(self): """Disable beamline control.""" if self._sb_blenbl.isEnabled(): if self._sb_blenbl.value: self._sb_blenbl.send_value()
class APUControlWindow(SiriusMainWindow): """APU Control Window.""" def __init__(self, parent=None, prefix=_vaca_prefix, device=''): """Init.""" super().__init__(parent) self._prefix = prefix self._device = _PVName(device) self._beamline = IDSearch.conv_idname_2_beamline(self._device) self.dev_pref = self._device.substitute(prefix=prefix) self.setWindowTitle(device + ' Control Window - ' + self._beamline) self.setObjectName('IDApp') self.setWindowIcon(get_id_icon()) self._setupUi() def _setupUi(self): self._label_title = QLabel('<h3>' + self._device + ' Control - ' + self._beamline + '</h3 >', self, alignment=Qt.AlignCenter) self._label_title.setStyleSheet('max-height:1.29em;') self.wid_mainControls = self._mainControlsWidget() self.wid_ctrlMode = self._ctrlModeWidget() self.wid_beamLinesCtrl = self._beamLinesCtrlWidget() self.wid_auxCommands = self._auxCommandsWidget() self.wid_status = self._statusWidget() cw = QWidget() self.setCentralWidget(cw) lay = QGridLayout(cw) lay.addWidget(self._label_title, 0, 0, 1, 3) lay.addWidget(self.wid_mainControls, 1, 0, 2, 1) lay.addWidget(self.wid_ctrlMode, 1, 1) lay.addWidget(self.wid_beamLinesCtrl, 2, 1) lay.addWidget(self.wid_auxCommands, 3, 0) lay.addWidget(self.wid_status, 3, 1) lay.setRowStretch(0, 1) lay.setRowStretch(1, 1) lay.setRowStretch(2, 2) lay.setRowStretch(3, 3) def _mainControlsWidget(self): self._ld_phs = QLabel('Phase [mm]', self) self._sb_phs = PyDMSpinbox(self, self.dev_pref.substitute(propty='Phase-SP')) self._sb_phs.showStepExponent = False self._lb_phs = PyDMLabel(self, self.dev_pref.substitute(propty='Phase-Mon')) self._ld_kx = QLabel('Kx', self) self._sb_kx = PyDMSpinbox(self, self.dev_pref.substitute(propty='Kx-SP')) self._sb_kx.showStepExponent = False self._lb_kx = PyDMLabel(self, self.dev_pref.substitute(propty='Kx-Mon')) self._ld_phsspd = QLabel('Phase Speed\n[mm/s]', self) self._sb_phsspd = PyDMSpinbox( self, self.dev_pref.substitute(propty='PhaseSpeed-SP')) self._sb_phsspd.showStepExponent = False self._lb_phsspd = PyDMLabel( self, self.dev_pref.substitute(propty='PhaseSpeed-Mon')) self._ld_ismov = QLabel('Motion', self) self._pb_start = PyDMPushButton(self, label='', icon=qta.icon('fa5s.play')) self._pb_start.setToolTip( 'Start automatic motion towards previously entered setpoint.') self._pb_start.channel = self.dev_pref.substitute(propty='DevCtrl-Cmd') self._pb_start.pressValue = 3 # Start self._pb_start.setObjectName('Start') self._pb_start.setStyleSheet( '#Start{min-width:30px; max-width:30px; icon-size:25px;}') self._pb_stop = PyDMPushButton(self, label='', icon=qta.icon('fa5s.stop')) self._pb_stop.setToolTip('Stop all motion, lock all brakes.') self._pb_stop.channel = self.dev_pref.substitute(propty='DevCtrl-Cmd') self._pb_stop.pressValue = 1 # Stop self._pb_stop.setObjectName('Stop') self._pb_stop.setStyleSheet( '#Stop{min-width:30px; max-width:30px; icon-size:25px;}') self._led_ismov = SiriusLedState(self, self.dev_pref + ':Moving-Mon') self._led_motenbl = SiriusLedState( self, self.dev_pref.substitute(propty='MotorsEnbld-Mon')) hbox_motion = QHBoxLayout() hbox_motion.setSpacing(15) hbox_motion.addWidget(self._pb_start) hbox_motion.addWidget(self._pb_stop) hbox_motion.addWidget(self._led_ismov) hbox_motion.addWidget(self._led_motenbl) gbox_main = QGroupBox('Main Controls', self) lay_main = QGridLayout(gbox_main) lay_main.addWidget(self._ld_phs, 0, 0) lay_main.addWidget(self._sb_phs, 0, 1) lay_main.addWidget(self._lb_phs, 0, 2) lay_main.addWidget(self._ld_kx, 1, 0) lay_main.addWidget(self._sb_kx, 1, 1) lay_main.addWidget(self._lb_kx, 1, 2) lay_main.addWidget(self._ld_phsspd, 2, 0) lay_main.addWidget(self._sb_phsspd, 2, 1) lay_main.addWidget(self._lb_phsspd, 2, 2) lay_main.addItem(QSpacerItem(1, 10, QSzPlcy.Ignored, QSzPlcy.Fixed), 3, 0) lay_main.addWidget(self._ld_ismov, 4, 0) lay_main.addLayout(hbox_motion, 4, 1, 1, 2) return gbox_main def _statusWidget(self): self._ld_alarm = QLabel('Alarms', self, alignment=Qt.AlignCenter) self._led_alarm = SiriusLedAlert( self, self.dev_pref.substitute(propty='Alarm-Mon')) self._pb_alarmdetail = QPushButton(qta.icon('fa5s.ellipsis-h'), '', self) self._pb_alarmdetail.setObjectName('dtl') self._pb_alarmdetail.setStyleSheet( "#dtl{min-width:25px; max-width:25px; icon-size:20px;}") connect_window(self._pb_alarmdetail, APUAlarmDetails, self, prefix=self._prefix, device=self._device) self._ld_intlk = QLabel('Interlocks', self, alignment=Qt.AlignCenter) self._led_intlkresume = PyDMLedMultiChannel( self, { self.dev_pref.substitute(propty='IntlkInStop-Mon'): 0, self.dev_pref.substitute(propty='IntlkInEOpnGap-Mon'): 0, self.dev_pref.substitute(propty='IntlkOutPwrEnbld-Mon'): 1 }) self._pb_intlkdetail = QPushButton(qta.icon('fa5s.ellipsis-h'), '', self) self._pb_intlkdetail.setObjectName('dtl') self._pb_intlkdetail.setStyleSheet( "#dtl{min-width:25px; max-width:25px; icon-size:20px;}") connect_window(self._pb_intlkdetail, APUInterlockDetails, self, prefix=self._prefix, device=self._device) self._ld_hwsys = QLabel('Hardware\n&LowLevel', self, alignment=Qt.AlignCenter) self._led_hwsysresume = PyDMLedMultiChannel( self, { self.dev_pref.substitute(propty='StateHw-Mon'): { 'value': [0x4C, 0x3C], 'comp': 'in' }, self.dev_pref.substitute(propty='State-Mon'): { 'value': [1, 4], 'comp': 'in' }, self.dev_pref.substitute(propty='IsOperational-Mon'): 1 }) self._led_hwsysresume.offColor = PyDMLed.Yellow self._led_hwsysresume.onColor = PyDMLed.LightGreen self._pb_hwsysdetail = QPushButton(qta.icon('fa5s.ellipsis-h'), '', self) self._pb_hwsysdetail.setObjectName('dtl') self._pb_hwsysdetail.setStyleSheet( "#dtl{min-width:25px; max-width:25px; icon-size:20px;}") connect_window(self._pb_hwsysdetail, APUHardLLDetails, self, prefix=self._prefix, device=self._device) self._ld_reset = QLabel('Reset', self, alignment=Qt.AlignCenter) self._pb_reset = PyDMPushButton(self, label='', icon=qta.icon('fa5s.sync')) self._pb_reset.setToolTip('Reset active alarms.') self._pb_reset.channel = self.dev_pref.substitute(propty='DevCtrl-Cmd') self._pb_reset.pressValue = 2 # Reset self._pb_reset.setObjectName('Reset') self._pb_reset.setStyleSheet( '#Reset{min-width:30px; max-width:30px; icon-size:25px;}') gbox_alrmintlk = QGroupBox('Status') lay_alrmintlk = QGridLayout(gbox_alrmintlk) lay_alrmintlk.addWidget(self._pb_alarmdetail, 0, 0) lay_alrmintlk.addWidget(self._ld_alarm, 0, 1) lay_alrmintlk.addWidget(self._led_alarm, 0, 2) lay_alrmintlk.addWidget(self._pb_intlkdetail, 1, 0) lay_alrmintlk.addWidget(self._ld_intlk, 1, 1) lay_alrmintlk.addWidget(self._led_intlkresume, 1, 2) lay_alrmintlk.addWidget(self._pb_hwsysdetail, 2, 0) lay_alrmintlk.addWidget(self._ld_hwsys, 2, 1) lay_alrmintlk.addWidget(self._led_hwsysresume, 2, 2) lay_alrmintlk.addWidget(self._ld_reset, 3, 1) lay_alrmintlk.addWidget(self._pb_reset, 3, 2) return gbox_alrmintlk def _ctrlModeWidget(self): self._led_ctrlmode = PyDMLed( self, self.dev_pref.substitute(propty='IsRemote-Mon')) self._led_ctrlmode.offColor = PyDMLed.Red self._led_ctrlmode.onColor = PyDMLed.LightGreen self._lb_ctrlmode = PyDMLabel( self, self.dev_pref.substitute(propty='Interface-Mon')) gbox_ctrlmode = QGroupBox('Control Mode') lay_ctrlmode = QHBoxLayout(gbox_ctrlmode) lay_ctrlmode.setAlignment(Qt.AlignCenter) lay_ctrlmode.addWidget(self._led_ctrlmode) lay_ctrlmode.addWidget(self._lb_ctrlmode) return gbox_ctrlmode def _beamLinesCtrlWidget(self): self._ld_blinesenbl = QLabel('Enable', self) self._sb_blinesenbl = PyDMStateButton( self, self.dev_pref.substitute(propty='BeamLineCtrlEnbl-Sel')) self._led_blinesenbl = SiriusLedState( self, self.dev_pref.substitute(propty='BeamLineCtrlEnbl-Sts')) self._ld_blinesmon = QLabel('Status', self) self._led_blinesmon = SiriusLedState( self, self.dev_pref.substitute(propty='BeamLineCtrl-Mon')) gbox_blines = QGroupBox('Beam Lines Control', self) lay_blines = QGridLayout(gbox_blines) lay_blines.addWidget(self._ld_blinesenbl, 0, 0) lay_blines.addWidget(self._sb_blinesenbl, 0, 1) lay_blines.addWidget(self._led_blinesenbl, 0, 2) lay_blines.addWidget(self._ld_blinesmon, 1, 0) lay_blines.addWidget(self._led_blinesmon, 1, 1, 1, 2) return gbox_blines def _auxCommandsWidget(self): self._ld_speedlim = QLabel('Max Phase Speed\n[mm/s]', self) self._sb_speedlim = PyDMSpinbox( self, self.dev_pref.substitute(propty='MaxPhaseSpeed-SP')) self._sb_speedlim.showStepExponent = False self._sb_speedlim.setStyleSheet('max-width:4.5em;') self._lb_speedlim = PyDMLabel( self, self.dev_pref.substitute(propty='MaxPhaseSpeed-RB')) self._ld_homeaxis = QLabel('Do homing', self) self._pb_home = PyDMPushButton(self, label='', icon=qta.icon('mdi.keyboard-return')) self._pb_home.setToolTip('Execute homing for selected axis.') self._pb_home.channel = self.dev_pref.substitute(propty='DevCtrl-Cmd') self._pb_home.pressValue = 10 # Home self._pb_home.setObjectName('Home') self._pb_home.setStyleSheet( '#Home{min-width:30px; max-width:30px; icon-size:25px;}') self._ld_standby = QLabel('Enable Standby Mode', self) self._pb_standby = PyDMPushButton( self, label='', icon=qta.icon('mdi.alpha-a-box-outline')) self._pb_standby.setToolTip( 'Enable standby mode for automatic motion.') self._pb_standby.channel = \ self.dev_pref.substitute(propty='DevCtrl-Cmd') self._pb_standby.pressValue = 5 # Standby self._pb_standby.setObjectName('Standby') self._pb_standby.setStyleSheet( '#Standby{min-width:30px; max-width:30px; icon-size:25px;}') self._ld_lastcomm = QLabel('Last Command', self) self._lb_lastcomm = PyDMLabel( self, self.dev_pref.substitute(propty='LastDevCtrlCmd-Mon')) gbox_auxcmd = QGroupBox('Auxiliary Commands', self) lay_auxcmd = QGridLayout(gbox_auxcmd) lay_auxcmd.addWidget(self._ld_speedlim, 0, 0) lay_auxcmd.addWidget(self._sb_speedlim, 0, 1) lay_auxcmd.addWidget(self._lb_speedlim, 0, 2) lay_auxcmd.addItem(QSpacerItem(1, 10, QSzPlcy.Ignored, QSzPlcy.Fixed), 1, 0) lay_auxcmd.addWidget(self._ld_homeaxis, 2, 0) lay_auxcmd.addWidget(self._pb_home, 2, 1, 1, 2, alignment=Qt.AlignCenter) lay_auxcmd.addWidget(self._ld_standby, 3, 0) lay_auxcmd.addWidget(self._pb_standby, 3, 1, 1, 2, alignment=Qt.AlignCenter) lay_auxcmd.addWidget(self._ld_lastcomm, 4, 0) lay_auxcmd.addWidget(self._lb_lastcomm, 4, 1, 1, 2) return gbox_auxcmd def contextMenuEvent(self, event): point = event.pos() if self._label_corrsH.underMouse(): menu = self.corrsH.contextMenuEvent(event, return_menu=True) menu.popup(self.mapToGlobal(point)) if self._label_corrsV.underMouse(): menu = self.corrsV.contextMenuEvent(event, return_menu=True) menu.popup(self.mapToGlobal(point))
def get_orbit_widget(self, parent): """.""" orb_wid = QWidget(parent) orb_wid.setObjectName('grp') orb_wid.setStyleSheet('#grp{min-height: 11em; max-height: 15em;}') orb_wid.setLayout(QGridLayout()) conf = PyDMPushButton( orb_wid, pressValue=1, init_channel=self.devpref.substitute(propty='TrigAcqConfig-Cmd')) conf.setToolTip('Refresh Configurations') conf.setIcon(qta.icon('fa5s.sync')) conf.setObjectName('conf') conf.setStyleSheet( '#conf{min-width:25px; max-width:25px; icon-size:20px;}') sts = QPushButton('', orb_wid) sts.setIcon(qta.icon('fa5s.list-ul')) sts.setToolTip('Open Detailed Status View') sts.setObjectName('sts') sts.setStyleSheet( '#sts{min-width:25px; max-width:25px; icon-size:20px;}') icon = qta.icon( 'fa5s.hammer', color=_util.get_appropriate_color(self.acc)) window = create_window_from_widget( StatusWidget, title='Orbit Status', icon=icon) _util.connect_window( sts, window, orb_wid, device=self.device, prefix=self.prefix, acc=self.acc, is_orb=True) pdm_led = SiriusLedAlert( orb_wid, self.devpref.substitute(propty='OrbStatus-Mon')) lbl = QLabel('Status:', orb_wid) hbl = QHBoxLayout() hbl.setSpacing(9) hbl.addStretch() hbl.addWidget(lbl) hbl.addWidget(pdm_led) hbl.addWidget(sts) hbl.addWidget(conf) orb_wid.layout().addItem(hbl, 0, 0, 1, 2) lbl = QLabel('SOFB Mode', orb_wid) wid = self.create_pair_sel(orb_wid, 'SOFBMode') orb_wid.layout().addWidget(lbl, 1, 0, alignment=Qt.AlignVCenter) orb_wid.layout().addWidget(wid, 1, 1) lbl = QLabel('RefOrb:', orb_wid) combo = RefControl( self, self.device, self.ctrls, prefix=self.prefix, acc=self.acc) lbl2 = QLabel('', orb_wid) combo.configname.connect(lbl2.setText) vbl_ref = QVBoxLayout() vbl_ref.addWidget(combo) vbl_ref.addWidget(lbl2) orb_wid.layout().addWidget(lbl, 3, 0, alignment=Qt.AlignVCenter) orb_wid.layout().addLayout(vbl_ref, 3, 1) lbl = QLabel('Num. Pts.', orb_wid) stp = SiriusSpinbox( orb_wid, self.devpref.substitute(propty='SmoothNrPts-SP')) stp.showStepExponent = False rdb = PyDMLabel( orb_wid, self.devpref.substitute(propty='SmoothNrPts-RB')) rdb.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) slsh = QLabel('/', orb_wid, alignment=Qt.AlignCenter) slsh.setStyleSheet('min-width:0.7em; max-width:0.7em;') cnt = PyDMLabel( orb_wid, self.devpref.substitute(propty='BufferCount-Mon')) cnt.setAlignment(Qt.AlignRight | Qt.AlignVCenter) cnt.setToolTip('Current Buffer Size') rst = PyDMPushButton( orb_wid, pressValue=1, init_channel=self.devpref.substitute(propty='SmoothReset-Cmd')) rst.setToolTip('Reset Buffer') rst.setIcon(qta.icon('mdi.delete-empty')) rst.setObjectName('rst') rst.setStyleSheet( '#rst{min-width:25px; max-width:25px; icon-size:20px;}') hbl = QHBoxLayout() hbl.addWidget(stp) hbl.addWidget(cnt) hbl.addWidget(slsh) hbl.addWidget(rdb) hbl.addWidget(rst) orb_wid.layout().addWidget(lbl, 4, 0, alignment=Qt.AlignVCenter) orb_wid.layout().addItem(hbl, 4, 1) orb_wid.layout().setColumnStretch(1, 2) return orb_wid
def get_manual_correction_widget(self, parent): """.""" man_wid = QWidget(parent) man_wid.setObjectName('grp') gdl = QGridLayout(man_wid) gdl.setSpacing(9) calc = PyDMPushButton( man_wid, '', pressValue=1, init_channel=self.devpref.substitute(propty='CalcDelta-Cmd')) calc.setIcon(qta.icon('mdi.calculator-variant')) calc.setToolTip('Calculate Kicks') calc.setObjectName('button') calc.setStyleSheet('#button {\ min-height: 45px; min-width: 45px;\ max-height: 45px; max-width: 45px;\ icon-size: 40px;}') rules = ( '[{"name": "EnblRule", "property": "Enable", ' + '"expression": "not ch[0]", "channels": [{"channel": "' + self.devpref.substitute(propty='LoopState-Sts') + '", "trigger": true}]}]') calc.rules = rules if self.acc == 'BO': gdl.addWidget(calc, 1, 1) gdl.setColumnStretch(0, 2) gdl.setColumnStretch(2, 2) gdl.setRowStretch(0, 2) gdl.setRowStretch(2, 2) return man_wid exp = 'ch[0] in (1, 2, 3)' ch = '' if self.isring: exp = 'ch[1] in (1, 2, 3) and not ch[0]' ch = '{"channel": "' + self.devpref.substitute( propty='LoopState-Sts') + '", "trigger": true},' rules = ( '[{"name": "EnblRule", "property": "Enable", ' + '"expression": "'+exp+'", "channels": ['+ch + '{"channel": "'+self.devpref.substitute(propty='SOFBMode-Sts') + '", "trigger": true}]}]') lst = [ ('All', self._csorb.ApplyDelta.All), ('CH', self._csorb.ApplyDelta.CH), ('CV', self._csorb.ApplyDelta.CV)] if self.acc in {'SI', 'BO'}: lst.append(('RF', self._csorb.ApplyDelta.RF)) btns = dict() for itm, val in lst: btn = PyDMPushButton( man_wid, ' '+itm, pressValue=val, init_channel=self.devpref.substitute(propty='ApplyDelta-Cmd')) btn.rules = rules btn.setIcon(qta.icon('fa5s.hammer')) btn.setToolTip('Apply ' + itm) btn.setObjectName('button') btn.setStyleSheet('#button {\ min-height: 25px; min-width: 45px;\ max-height: 25px;\ icon-size: 20px;}') if self.acc == 'BO': btn.setVisible(False) btns[itm] = btn gdl.addWidget(calc, 0, 0, 2, 1) gdl.addWidget(btns['CH'], 0, 1) gdl.addWidget(btns['CV'], 0, 2) if self.acc in {'SI', 'BO'}: gdl.addWidget(btns['RF'], 0, 3) gdl.addWidget(btns['All'], 1, 1, 1, 3) else: gdl.addWidget(btns['All'], 1, 1, 1, 2) gdl.setColumnMinimumWidth(0, 60) grpbx = QWidget(man_wid) grpbx.setObjectName('gbx') if self.acc in {'SI', 'BO'}: planes = ('CH', 'CV', 'RF') gdl.addWidget(grpbx, 2, 0, 1, 4) else: planes = ('CH', 'CV') gdl.addWidget(grpbx, 2, 0, 1, 3) fbl = QFormLayout(grpbx) for pln in planes: lbl = QLabel(pln+' [%] ', grpbx) lbl.setObjectName('lbl') lbl.setStyleSheet('#lbl{min-height:1em;}') wid = self.create_pair(grpbx, 'ManCorrGain'+pln) wid.setObjectName('wid') wid.setStyleSheet('#wid{min-height:1.2em;}') if self.acc == 'BO': lbl.setVisible(False) wid.setVisible(False) fbl.addRow(lbl, wid) vlay = QVBoxLayout() vlay.addStretch() gdl.addLayout(vlay, 3, 0) return man_wid
def _get_acq_commom_params_grpbx(self): grp_bx = QGroupBox('Common Parameters', self) fbl = QFormLayout(grp_bx) lbl = QLabel('Non-linear Corr.', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair_butled(grp_bx, 'PolyCalibration') fbl.addRow(lbl, wid) self._set_detailed([lbl, wid]) lbl = QLabel('Channel Rate', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair_sel(grp_bx, 'TrigAcqChan') fbl.addRow(lbl, wid) lbl = QLabel('Trigger Type', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair_sel(grp_bx, 'TrigAcqTrigger') fbl.addRow(lbl, wid) self._set_detailed([lbl, wid]) lbl = QLabel('Repeat', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair_butled(grp_bx, 'TrigAcqRepeat') fbl.addRow(lbl, wid) self._set_detailed([lbl, wid]) if self.isring: lbl = QLabel('Nr of Shots', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair(grp_bx, 'TrigNrShots') fbl.addRow(lbl, wid) self._set_detailed([lbl, wid]) lbl = QLabel('SamplesPre', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair(grp_bx, 'TrigNrSamplesPre') fbl.addRow(lbl, wid) lbl = QLabel('SamplesPost', grp_bx, alignment=Qt.AlignCenter) wid = self.create_pair(grp_bx, 'TrigNrSamplesPost') fbl.addRow(lbl, wid) lbl = QLabel('Acquisition:', grp_bx, alignment=Qt.AlignCenter) strt = PyDMPushButton( grp_bx, label='', init_channel=self.devpref.substitute(propty='TrigAcqCtrl-Sel'), pressValue=self._csorb.TrigAcqCtrl.Start) strt.setToolTip('Start Acquisition') strt.setIcon(qta.icon('fa5s.play')) strt.setObjectName('strt') strt.setStyleSheet( '#strt{min-width:25px; max-width:25px; icon-size:20px;}') stop = PyDMPushButton( grp_bx, label='', init_channel=self.devpref.substitute(propty='TrigAcqCtrl-Sel'), pressValue=self._csorb.TrigAcqCtrl.Stop) stop.setToolTip('Stop Acquisition') stop.setIcon(qta.icon('fa5s.stop')) stop.setObjectName('stop') stop.setStyleSheet( '#stop{min-width:25px; max-width:25px; icon-size:20px;}') abrt = PyDMPushButton( grp_bx, label='', init_channel=self.devpref.substitute(propty='TrigAcqCtrl-Sel'), pressValue=self._csorb.TrigAcqCtrl.Abort) abrt.setToolTip('Abort Acquisition') abrt.setIcon(qta.icon('fa5s.ban')) abrt.setObjectName('abrt') abrt.setStyleSheet( '#abrt{min-width:25px; max-width:25px; icon-size:20px;}') pdmlbl = PyDMLabel(grp_bx, self.devpref.substitute(propty='TrigAcqCtrl-Sts')) pdmlbl.setObjectName('pdmlbl') pdmlbl.setStyleSheet('#pdmlbl{min-width:6em; max-width:6em;}') pdmlbl.setAlignment(Qt.AlignCenter) hbl = QHBoxLayout() fbl.addRow(hbl) hbl.addStretch() hbl.addWidget(lbl) hbl.addWidget(strt) hbl.addWidget(stop) hbl.addWidget(abrt) hbl.addWidget(pdmlbl) conf = PyDMPushButton( grp_bx, pressValue=1, init_channel=self.devpref.substitute(propty='TrigAcqConfig-Cmd')) conf.setToolTip('Resend Configurations') conf.setIcon(qta.icon('fa5s.sync')) conf.setObjectName('conf') conf.setStyleSheet( '#conf{min-width:25px; max-width:25px; icon-size:20px;}') sts = QPushButton('', grp_bx) sts.setIcon(qta.icon('fa5s.list-ul')) sts.setToolTip('Open Detailed Status View') sts.setObjectName('sts') sts.setStyleSheet( '#sts{min-width:25px; max-width:25px; icon-size:20px;}') Window = create_window_from_widget(StatusWidget, title='Orbit Status') connect_window(sts, Window, grp_bx, device=self.device, prefix=self.prefix, acc=self.acc, is_orb=True) pdm_led = SiriusLedAlert( grp_bx, self.devpref.substitute(propty='OrbStatus-Mon')) lbl = QLabel('Status:', grp_bx) hbl = QHBoxLayout() hbl.setSpacing(9) hbl.addStretch() hbl.addWidget(lbl) hbl.addWidget(pdm_led) hbl.addWidget(sts) hbl.addWidget(conf) fbl.addRow(hbl) return grp_bx
def _get_config_widget(self, parent): gb_pos = QGroupBox('Image Processing ', parent) meth_sp = PyDMEnumComboBox( gb_pos, init_channel=self._dev+':CalcMethod-Sel') meth_lb = SiriusLabel(gb_pos, init_channel=self._dev+':CalcMethod-Sts') meth_ld = QLabel('Method', gb_pos) nrpt_ld = QLabel('Num. Pts.', gb_pos) nrpt_sp = SiriusSpinbox( gb_pos, init_channel=self._dev+':NrAverages-SP') nrpt_sp.showStepExponent = False rdb = PyDMLabel(gb_pos, init_channel=self._dev+':NrAverages-RB') rdb.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) slsh = QLabel('/', gb_pos, alignment=Qt.AlignCenter) slsh.setStyleSheet('min-width:0.7em; max-width:0.7em;') cnt = PyDMLabel(gb_pos, init_channel=self._dev+':BufferSize-Mon') cnt.setAlignment(Qt.AlignRight | Qt.AlignVCenter) cnt.setToolTip('Current Buffer Size') pbt = PyDMPushButton( gb_pos, init_channel=self._dev+':ResetBuffer-Cmd', pressValue=1) pbt.setToolTip('Reset Buffer') pbt.setIcon(qta.icon('mdi.delete-empty')) pbt.setObjectName('rst') pbt.setStyleSheet( '#rst{min-width:25px; max-width:25px; icon-size:20px;}') nrpt_wd = QWidget(gb_pos) hbl = QHBoxLayout(nrpt_wd) hbl.addWidget(pbt) hbl.addStretch() hbl.addWidget(cnt) hbl.addWidget(slsh) hbl.addWidget(rdb) rsx_sp = SiriusSpinbox(gb_pos, init_channel=self._dev+':ROISizeX-SP') rsx_sp.showStepExponent = False rsx_lb = SiriusLabel(gb_pos, init_channel=self._dev+':ROISizeX-RB') rsx_ld = QLabel('ROI Size X', gb_pos) rsy_sp = SiriusSpinbox(gb_pos, init_channel=self._dev+':ROISizeY-SP') rsy_sp.showStepExponent = False rsy_lb = SiriusLabel(gb_pos, init_channel=self._dev+':ROISizeY-RB') rsy_ld = QLabel('ROI Size Y', gb_pos) ra_bt = PyDMStateButton( gb_pos, init_channel=self._dev+':ROIAutoCenter-Sel') ra_lb = SiriusLabel( gb_pos, init_channel=self._dev+':ROIAutoCenter-Sts') ra_ld = QLabel('Auto Center:', gb_pos) rcx_sp = SiriusSpinbox(gb_pos, init_channel=self._dev+':ROICenterX-SP') rcx_sp.showStepExponent = False rcx_lb = SiriusLabel(gb_pos, init_channel=self._dev+':ROICenterX-RB') rcx_ld = QLabel('ROI Center X', gb_pos) rcy_sp = SiriusSpinbox(gb_pos, init_channel=self._dev+':ROICenterY-SP') rcy_sp.showStepExponent = False rcy_lb = SiriusLabel(gb_pos, init_channel=self._dev+':ROICenterY-RB') rcy_ld = QLabel('ROI Center Y', gb_pos) sts_bt = QPushButton(qta.icon('fa5s.ellipsis-h'), '', gb_pos) sts_bt.setToolTip('Open Detailed Configs') sts_bt.setObjectName('sts') sts_bt.setStyleSheet( '#sts{min-width:25px; max-width:25px; icon-size:20px;}') Window = create_window_from_widget( _DetailedWidget, title='Image Processing Detailed Configs') connect_window( sts_bt, Window, gb_pos, device=self._dev, convertion_set=self._conv_set) hlay = QHBoxLayout() hlay.addWidget(sts_bt, alignment=Qt.AlignRight) lay = QGridLayout(gb_pos) if self._ori == 'V': lay.addWidget(meth_ld, 0, 0, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(meth_sp, 0, 1) lay.addWidget(meth_lb, 1, 1) lay.addWidget(nrpt_ld, 2, 0, alignment=Qt.AlignLeft) lay.addWidget(nrpt_sp, 2, 1) lay.addWidget(nrpt_wd, 3, 0, 1, 2) lay.addWidget(rsx_ld, 4+0, 0, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(rsx_sp, 4+0, 1) lay.addWidget(rsx_lb, 4+1, 1) lay.addWidget(rsy_ld, 6+0, 0, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(rsy_sp, 6+0, 1) lay.addWidget(rsy_lb, 6+1, 1) lay.addWidget(sts_bt, 0, 0+4, alignment=Qt.AlignRight) lay.addWidget(ra_ld, 2+0, 0+3, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(ra_bt, 2+0, 1+3) lay.addWidget(ra_lb, 2+1, 1+3, alignment=Qt.AlignLeft) lay.addWidget(rcx_ld, 4+0, 0+3, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(rcx_sp, 4+0, 1+3) lay.addWidget(rcx_lb, 4+1, 1+3) lay.addWidget(rcy_ld, 6+0, 0+3, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(rcy_sp, 6+0, 1+3) lay.addWidget(rcy_lb, 6+1, 1+3) else: lay.addWidget(meth_ld, 0, 0, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(meth_sp, 0, 1) lay.addWidget(meth_lb, 1, 1) lay.addWidget(nrpt_ld, 2, 0, alignment=Qt.AlignLeft) lay.addWidget(nrpt_sp, 2, 1) lay.addWidget(nrpt_wd, 3, 0, 1, 2) lay.addWidget(rsx_ld, 4+0, 0, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(rsx_sp, 4+0, 1) lay.addWidget(rsx_lb, 4+1, 1) lay.addWidget(rsy_ld, 6+0, 0, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(rsy_sp, 6+0, 1) lay.addWidget(rsy_lb, 6+1, 1) lay.addWidget(ra_ld, 8+0, 0, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(ra_bt, 8+0, 1) lay.addWidget(ra_lb, 8+1, 1, alignment=Qt.AlignLeft) lay.addWidget(rcx_ld, 10+0, 0, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(rcx_sp, 10+0, 1) lay.addWidget(rcx_lb, 10+1, 1) lay.addWidget(rcy_ld, 12+0, 0, 2, 1, alignment=Qt.AlignLeft) lay.addWidget(rcy_sp, 12+0, 1) lay.addWidget(rcy_lb, 12+1, 1) lay.addWidget(sts_bt, 14, 0, alignment=Qt.AlignLeft) lay.setRowStretch(15, 5) return gb_pos