Example #1
0
    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)
Example #2
0
    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
Example #3
0
class InjSysStbyControlWidget(QWidget):
    """Injection System Control Widget."""

    expand = Signal()

    def __init__(self,
                 parent=None,
                 prefix=VACA_PREFIX,
                 is_summary=False,
                 handler=None):
        """Init."""
        super().__init__(parent)
        self.prefix = prefix
        self._inj_prefix = SiriusPVName('AS-Glob:AP-InjCtrl').substitute(
            prefix=prefix)
        self._is_summary = is_summary
        self._last_comm = None

        self._handler = handler or InjSysStandbyHandler()
        self._icon_off = qta.icon('mdi.power-off')
        self._icon_on = qta.icon('mdi.power-on')
        self._icon_check = qta.icon('fa5s.check')
        self._pixmap_check = self._icon_check.pixmap(
            self._icon_check.actualSize(QSize(16, 16)))
        self._icon_not = qta.icon('fa5s.times')
        self._pixmap_not = self._icon_not.pixmap(
            self._icon_not.actualSize(QSize(16, 16)))

        self.menu = QMenu(self)
        self.rstord_act = self.menu.addAction('Reset Commands')
        self.rstord_act.triggered.connect(self._reset_commands_order)

        if is_summary:
            self._setupSummary()
        else:
            self._setupFull()

        self._ch_cmdsts = SiriusConnectionSignal(
            self._inj_prefix.substitute(propty='InjSysCmdSts-Mon'))

        self._ch_off_order_sp = SiriusConnectionSignal(
            self._inj_prefix.substitute(propty='InjSysTurnOffOrder-SP'))
        self._ch_off_order_rb = SiriusConnectionSignal(
            self._inj_prefix.substitute(propty='InjSysTurnOffOrder-RB'))
        self._ch_on_order_sp = SiriusConnectionSignal(
            self._inj_prefix.substitute(propty='InjSysTurnOnOrder-SP'))
        self._ch_on_order_rb = SiriusConnectionSignal(
            self._inj_prefix.substitute(propty='InjSysTurnOnOrder-RB'))
        if not is_summary:
            self._ch_cmdone = SiriusConnectionSignal(
                self._inj_prefix.substitute(propty='InjSysCmdDone-Mon'))

        self._ch_cmdsts.new_value_signal[int].connect(
            self._handle_cmdsts_buttons_enbl)
        self._ch_off_order_rb.new_value_signal[str].connect(
            self._handle_buttons_color)
        self._ch_on_order_rb.new_value_signal[str].connect(
            self._handle_buttons_color)
        self._ch_off_order_rb.new_value_signal[str].connect(
            self._handle_actions_state)
        self._ch_on_order_rb.new_value_signal[str].connect(
            self._handle_actions_state)
        if not is_summary:
            self._ch_cmdone.new_value_signal[str].connect(
                self._handle_cmdone_labels)
            self._ch_cmdsts.new_value_signal[int].connect(
                self._handle_cmdsts_labels)

    def _setupSummary(self):
        self._pb_off = PyDMPushButton(self,
                                      label='',
                                      icon=self._icon_off,
                                      init_channel=self._inj_prefix.substitute(
                                          propty='InjSysTurnOff-Cmd'),
                                      pressValue=0)
        self._pb_off.setObjectName('bt')
        self._pb_off.setStyleSheet(
            '#bt{min-width:25px; max-width:25px; icon-size:20px;}')
        self._pb_on = PyDMPushButton(self,
                                     label='',
                                     icon=self._icon_on,
                                     init_channel=self._inj_prefix.substitute(
                                         propty='InjSysTurnOn-Cmd'),
                                     pressValue=0)
        self._pb_on.setObjectName('bt')
        self._pb_on.setStyleSheet(
            '#bt{min-width:25px; max-width:25px; icon-size:20px;}')

        self._led_sts = InjSysStbyLed(self)
        self._led_sts.setStyleSheet(
            'QLed{min-width:1.29em; max-width:1.29em;}')

        lay = QGridLayout(self)
        lay.setAlignment(Qt.AlignCenter)
        lay.addWidget(self._pb_off, 0, 0)
        lay.addWidget(self._pb_on, 0, 1)
        lay.addWidget(self._led_sts, 1, 0, 1, 2, alignment=Qt.AlignCenter)

        # menu
        for cmmtype in ['on', 'off']:
            order = getattr(self._handler, cmmtype + '_order')
            menu = QMenu('Select Turn ' + cmmtype.upper() + ' Commands', self)
            setattr(self, cmmtype + '_menu', menu)
            self.menu.addMenu(menu)
            for cmm in order:
                act = menu.addAction(self._handler.HANDLER_DESC[cmm])
                act.setObjectName(cmm)
                act.setCheckable(True)

    def _setupFull(self):
        lay = QGridLayout(self)

        lay.addWidget(QLabel('Off', self, alignment=Qt.AlignCenter), 0, 1)
        lay.addWidget(QLabel('On', self, alignment=Qt.AlignCenter), 0, 2)
        lay.addWidget(QLabel('Status', self, alignment=Qt.AlignCenter), 0, 3)

        self._checkbox_off = dict()
        self._checkbox_on = dict()
        self._labels_sts = dict()
        for idx, name in enumerate(self._handler.DEF_ON_ORDER):
            cb_off = QCheckBox(self)
            cb_off.setObjectName(name)
            self._checkbox_off[name] = cb_off
            cb_on = QCheckBox(self)
            cb_on.setObjectName(name)
            self._checkbox_on[name] = cb_on
            desc = self._handler.HANDLER_DESC[name]
            splitd = desc.split('(')
            lbl_txt = splitd[0]
            tip = ''
            if len(splitd) > 1:
                lbl_txt, tip = splitd
            lb_dsc = QLabel(lbl_txt, self, alignment=Qt.AlignLeft)
            if tip:
                lb_dsc.setToolTip(tip[:-1])
            lb_sts = QLabel('', self, alignment=Qt.AlignCenter)
            lb_sts.setObjectName(name)
            self._labels_sts[name] = lb_sts
            lay.addWidget(lb_dsc, idx + 1, 0)
            lay.addWidget(cb_off, idx + 1, 1, alignment=Qt.AlignCenter)
            lay.addWidget(cb_on, idx + 1, 2, alignment=Qt.AlignCenter)
            lay.addWidget(lb_sts, idx + 1, 3)

        self._pb_off = PyDMPushButton(self,
                                      label='',
                                      icon=self._icon_off,
                                      init_channel=self._inj_prefix.substitute(
                                          propty='InjSysTurnOff-Cmd'),
                                      pressValue=0)
        self._pb_off.setObjectName('bt')
        self._pb_off.setStyleSheet(
            '#bt{min-width:25px; max-width:25px; icon-size:20px;}')
        self._pb_on = PyDMPushButton(self,
                                     label='',
                                     icon=self._icon_on,
                                     init_channel=self._inj_prefix.substitute(
                                         propty='InjSysTurnOn-Cmd'),
                                     pressValue=0)
        self._pb_on.setObjectName('bt')
        self._pb_on.setStyleSheet(
            '#bt{min-width:25px; max-width:25px; icon-size:20px;}')

        self._led_sts = InjSysStbyLed(self)

        lay.addWidget(self._pb_off, 6, 1)
        lay.addWidget(self._pb_on, 6, 2)
        lay.addWidget(self._led_sts, 6, 3)

    @Slot(int)
    def _handle_cmdsts_buttons_enbl(self, new_sts):
        if new_sts == _Const.InjSysCmdSts.On:
            self._pb_on.setEnabled(False)
            self._pb_on.setIcon(
                qta.icon('fa5s.spinner', animation=qta.Spin(self._pb_on)))
            self._pb_off.setEnabled(False)
        elif new_sts == _Const.InjSysCmdSts.Off:
            self._pb_on.setEnabled(False)
            self._pb_off.setEnabled(False)
            self._pb_off.setIcon(
                qta.icon('fa5s.spinner', animation=qta.Spin(self._pb_off)))
        else:
            if not self._pb_on.isEnabled():
                self._pb_on.setEnabled(True)
                self._pb_off.setEnabled(True)
                self._pb_on.setIcon(self._icon_on)
                self._pb_off.setIcon(self._icon_off)

    @Slot(str)
    def _handle_cmdone_labels(self, new_done):
        for name in self._handler.DEF_ON_ORDER:
            lbl = self._labels_sts[name]
            if name in new_done:
                lbl.setPixmap(self._pixmap_check)
            elif self._ch_cmdsts.value == _Const.InjSysCmdSts.Idle:
                lbl.setPixmap(self._pixmap_not)

    @Slot(int)
    def _handle_cmdsts_labels(self, new_sts):
        if new_sts == _Const.InjSysCmdSts.On:
            self._last_comm = new_sts
            for name in self._handler.DEF_ON_ORDER:
                if self._ch_on_order_rb.value is None:
                    break
                lbl = self._labels_sts[name]
                if name in self._ch_on_order_rb.value:
                    icon = qta.icon('fa5s.spinner')
                    pixmap = icon.pixmap(icon.actualSize(QSize(16, 16)))
                    lbl.setPixmap(pixmap)
                else:
                    lbl.setPixmap(QPixmap())
        elif new_sts == _Const.InjSysCmdSts.Off:
            self._last_comm = new_sts
            for name in self._handler.DEF_OFF_ORDER:
                if self._ch_off_order_rb.value is None:
                    break
                lbl = self._labels_sts[name]
                if name in self._ch_off_order_rb.value:
                    icon = qta.icon('fa5s.spinner')
                    pixmap = icon.pixmap(icon.actualSize(QSize(16, 16)))
                    lbl.setPixmap(pixmap)
                else:
                    lbl.setPixmap(QPixmap())
        else:
            done = self._ch_cmdone.value
            for name in self._handler.DEF_ON_ORDER:
                if done is None or name in done:
                    continue
                lbl = self._labels_sts[name]
                if self._last_comm == _Const.InjSysCmdSts.On and \
                        name in self._ch_on_order_rb.value:
                    lbl.setPixmap(self._pixmap_not)
                elif self._last_comm == _Const.InjSysCmdSts.Off and \
                        name in self._ch_off_order_rb.value:
                    lbl.setPixmap(self._pixmap_not)
            self._last_comm = None

    @Slot()
    def _set_commands_order(self):
        if self._is_summary:
            if self.sender() in self.on_menu.actions():
                on_order = [
                    a.objectName() for a in self.on_menu.actions()
                    if a.isChecked()
                ]
                self._ch_on_order_sp.send_value_signal[str].emit(
                    ','.join(on_order))
            elif self.sender() in self.off_menu.actions():
                off_order = [
                    a.objectName() for a in self.off_menu.actions()
                    if a.isChecked()
                ]
                self._ch_off_order_sp.send_value_signal[str].emit(
                    ','.join(off_order))
        else:
            if self.sender() in self._checkbox_on.values():
                checked = [
                    w.objectName() for w in self._checkbox_on.values()
                    if w.isChecked()
                ]
                on_order = [
                    h for h in self._handler.DEF_ON_ORDER if h in checked
                ]
                self._ch_on_order_sp.send_value_signal[str].emit(
                    ','.join(on_order))
            elif self.sender() in self._checkbox_off.values():
                checked = [
                    w.objectName() for w in self._checkbox_off.values()
                    if w.isChecked()
                ]
                off_order = [
                    h for h in self._handler.DEF_OFF_ORDER if h in checked
                ]
                self._ch_off_order_sp.send_value_signal[str].emit(
                    ','.join(off_order))

    @Slot()
    def _reset_commands_order(self):
        self._ch_off_order_sp.send_value_signal[str].emit(','.join(
            self._handler.DEF_OFF_ORDER))
        self._ch_on_order_sp.send_value_signal[str].emit(','.join(
            self._handler.DEF_ON_ORDER))
        if self._is_summary:
            for menu in [self.off_menu, self.on_menu]:
                for act in menu.actions():
                    act.toggled.disconnect()
                    act.setChecked(True)
                    act.toggled.connect(self._set_commands_order)
        else:
            for group in [self._checkbox_off, self._checkbox_on]:
                for wid in group.values():
                    wid.toggled.disconnect()
                    wid.setChecked(True)
                    wid.toggled.connect(self._set_commands_order)

    @Slot()
    def _handle_buttons_color(self):
        off_color = 'yellow' if self._ch_off_order_rb.value != \
            ','.join(self._handler.DEF_OFF_ORDER) else 'white'
        self._pb_off.setStyleSheet(
            '#bt{min-width:25px; max-width:25px; icon-size:20px;'
            'background-color: ' + off_color + ';}')
        on_color = 'yellow' if self._ch_on_order_rb.value != \
            ','.join(self._handler.DEF_ON_ORDER) else 'white'
        self._pb_on.setStyleSheet(
            '#bt{min-width:25px; max-width:25px; icon-size:20px;'
            'background-color: ' + on_color + ';}')

    @Slot(str)
    def _handle_actions_state(self, sts):
        state = 'on' if 'On' in self.sender().address else 'off'
        channel = getattr(self, '_ch_' + state + '_order_rb')
        if channel.value is None:
            return

        if self._is_summary:
            group = getattr(self, state + '_menu').actions()
        else:
            group = getattr(self, '_checkbox_' + state).values()
        for obj in group:
            obj.disconnect()
            ost = obj.objectName() in sts
            obj.setChecked(ost)
            obj.toggled.connect(self._set_commands_order)

    def contextMenuEvent(self, event):
        """Show a custom context menu."""
        self.menu.popup(self.mapToGlobal(event.pos()))
Example #4
0
    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
Example #5
0
class PUDetailWidget(QWidget):
    """Detailed widget for controlling a pulsed magnet."""
    def __init__(self, devname, parent=None):
        """Receive a parent and a pulsed mangnet name."""
        super().__init__(parent)
        self._devname = _PVName(devname)
        self._section = self._devname.sec
        self._prefix = _VACA_PREFIX
        self._pdev = self._devname.substitute(prefix=self._prefix)
        self.setObjectName(self._section + 'App')
        self.setWindowIcon(
            qta.icon('mdi.current-ac',
                     color=util.get_appropriate_color(self._section)))

        self._create_pvs()
        self._setup_ui()
        self.setStyleSheet("""
            #pulses_box,
            #pwrstate_box {
                max-width: 8em;
            }
        """)
        self.setFocusPolicy(Qt.StrongFocus)

    def _create_pvs(self):
        """Create variables with pvs that'll be used."""
        self._voltage_sp_pv = self._pdev.substitute(propty='Voltage-SP')
        self._voltage_rb_pv = self._pdev.substitute(propty='Voltage-RB')
        self._voltage_mon_pv = self._pdev.substitute(propty='Voltage-Mon')
        self._kick_sp_pv = self._pdev.substitute(propty='Kick-SP')
        self._kick_rb_pv = self._pdev.substitute(propty='Kick-RB')
        self._kick_mon_pv = self._pdev.substitute(propty='Kick-Mon')
        self._pwrstate_sel_pv = self._pdev.substitute(propty='PwrState-Sel')
        self._pwrstate_sts_pv = self._pdev.substitute(propty='PwrState-Sts')
        self._enablepulses_sel_pv = self._pdev.substitute(propty='Pulse-Sel')
        self._enablepulses_sts_pv = self._pdev.substitute(propty='Pulse-Sts')
        self._reset_cmd_pv = self._pdev.substitute(propty='Reset-Cmd')
        self._intlk1_mon_pv = self._pdev.substitute(propty='Intlk1-Mon')
        self._intlk2_mon_pv = self._pdev.substitute(propty='Intlk2-Mon')
        self._intlk3_mon_pv = self._pdev.substitute(propty='Intlk3-Mon')
        self._intlk4_mon_pv = self._pdev.substitute(propty='Intlk4-Mon')
        self._intlk5_mon_pv = self._pdev.substitute(propty='Intlk5-Mon')
        self._intlk6_mon_pv = self._pdev.substitute(propty='Intlk6-Mon')
        self._intlk7_mon_pv = self._pdev.substitute(propty='Intlk7-Mon')
        self._intlk1_lbcte_pv = self._pdev.substitute(propty='Intlk1Label-Cte')
        self._intlk2_lbcte_pv = self._pdev.substitute(propty='Intlk2Label-Cte')
        self._intlk3_lbcte_pv = self._pdev.substitute(propty='Intlk3Label-Cte')
        self._intlk4_lbcte_pv = self._pdev.substitute(propty='Intlk4Label-Cte')
        self._intlk5_lbcte_pv = self._pdev.substitute(propty='Intlk5Label-Cte')
        self._intlk6_lbcte_pv = self._pdev.substitute(propty='Intlk6Label-Cte')
        self._intlk7_lbcte_pv = self._pdev.substitute(propty='Intlk7Label-Cte')
        if 'Sept' not in self._devname:
            self._intlk8_mon_pv = self._pdev.substitute(propty='Intlk8-Mon')
            self._intlk8_lbcte_pv = \
                self._pdev.substitute(propty='Intlk8Label-Cte')
        self._ctrlmode_pv = self._pdev.substitute(propty='CtrlMode-Mon')

        self._trigname = self._devname.substitute(dis='TI')

    def _setup_ui(self):
        self.header_label = QLabel("<h1>" + self._devname + "</h1>")
        self.header_label.setObjectName("header_label")
        interlock_box = QGroupBox(parent=self, title="Interlock")
        interlock_box.setObjectName("interlock_box")
        interlock_box.setLayout(self._interlock_layout())
        pwrstate_box = QGroupBox(parent=self, title="Power")
        pwrstate_box.setObjectName("pwrstate_box")
        pwrstate_box.setLayout(self._pwrstate_layout())
        pulses_box = QGroupBox(parent=self, title="Pulses")
        pulses_box.setObjectName("pulses_box")
        pulses_box.setLayout(self._pulses_layout())
        voltage_box = QGroupBox(parent=self, title="Voltage")
        voltage_box.setObjectName("voltage_box")
        voltage_box.setLayout(self._voltage_layout())
        kick_box = QGroupBox(parent=self, title="Kick")
        kick_box.setObjectName("kick_box")
        kick_box.setLayout(self._kick_layout())
        timing_box = QGroupBox(parent=self, title='Trigger')
        timing_box.setObjectName('timing_box')
        hbl = QHBoxLayout(timing_box)
        hbl.addWidget(HLTriggerSimple(timing_box, self._trigname,
                                      self._prefix))

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.header_label, 0, 0, 1, 3)
        self.layout.addWidget(interlock_box, 1, 0, 3, 1)
        vbl1 = QVBoxLayout()
        vbl1.addWidget(pwrstate_box)
        vbl1.addWidget(pulses_box)
        self.layout.addLayout(vbl1, 1, 1, 2, 1)
        vbl2 = QVBoxLayout()
        vbl2.addWidget(voltage_box)
        vbl2.addWidget(kick_box)
        self.layout.addLayout(vbl2, 1, 2, 2, 1)
        self.layout.addWidget(timing_box, 3, 1, 1, 3)
        self.layout.addLayout(self._ctrlmode_layout(), 4, 1, 1, 3)

    def _interlock_layout(self):
        interlock_layout = QGridLayout()

        intlk_cnt = 8 if 'Sept' not in self._devname else 7
        for i in range(intlk_cnt):
            label = PyDMLabel(
                self, getattr(self, '_intlk' + str(i + 1) + '_lbcte_pv'))
            led = PyDMLed(self, getattr(self,
                                        '_intlk' + str(i + 1) + '_mon_pv'))
            led.onColor = led.LightGreen
            led.offColor = led.Red
            interlock_layout.addWidget(led, i, 0)
            interlock_layout.addWidget(label, i, 1)

        self.reset_bt = PyDMPushButton(parent=self,
                                       init_channel=self._reset_cmd_pv,
                                       pressValue=1)
        self.reset_bt.setIcon(qta.icon('fa5s.sync'))
        self.reset_bt.setObjectName('reset_bt')
        self.reset_bt.setStyleSheet(
            '#reset_bt{min-width:25px; max-width:25px; icon-size:20px;}')
        interlock_layout.addWidget(self.reset_bt,
                                   i + 1,
                                   0,
                                   1,
                                   2,
                                   alignment=Qt.AlignHCenter)

        return interlock_layout

    def _pwrstate_layout(self):
        pwrstate_layout = QHBoxLayout()

        self.state_button = PyDMStateButton(parent=self,
                                            init_channel=self._pwrstate_sel_pv)
        self.state_led = SiriusLedState(self, self._pwrstate_sts_pv)

        pwrstate_layout.addWidget(self.state_button)
        pwrstate_layout.addWidget(self.state_led)

        return pwrstate_layout

    def _pulses_layout(self):
        pulses_layout = QHBoxLayout()

        self.pulses_state_button = PyDMStateButton(
            parent=self, init_channel=self._enablepulses_sel_pv)
        self.pulses_state_led = SiriusLedState(
            parent=self, init_channel=self._enablepulses_sts_pv)

        pulses_layout.addWidget(self.pulses_state_button)
        pulses_layout.addWidget(self.pulses_state_led)

        return pulses_layout

    def _voltage_layout(self):
        voltage_layout = QVBoxLayout()

        self.voltage_sp_widget = PyDMSpinboxScrollbar(self,
                                                      self._voltage_sp_pv)
        self.voltage_rb_label = PyDMLabel(self, self._voltage_rb_pv)
        self.voltage_rb_label.showUnits = True
        self.voltage_rb_label.precisionFromPV = True
        self.voltage_mon_label = PyDMLabel(self, self._voltage_mon_pv)
        self.voltage_mon_label.showUnits = True
        self.voltage_mon_label.precisionFromPV = True

        voltage_layout = QFormLayout()
        voltage_layout.setLabelAlignment(Qt.AlignRight)
        voltage_layout.setFormAlignment(Qt.AlignHCenter)
        voltage_layout.addRow('SP:', self.voltage_sp_widget)
        voltage_layout.addRow('RB:', self.voltage_rb_label)
        voltage_layout.addRow('Mon:', self.voltage_mon_label)

        return voltage_layout

    def _kick_layout(self):
        self.kick_sp_widget = PyDMSpinboxScrollbar(self, self._kick_sp_pv)
        self.kick_rb_label = PyDMLabel(self, self._kick_rb_pv)
        self.kick_rb_label.showUnits = True
        self.kick_rb_label.precisionFromPV = True
        self.kick_mon_label = PyDMLabel(self, self._kick_mon_pv)
        self.kick_mon_label.showUnits = True
        self.kick_mon_label.precisionFromPV = True

        kick_layout = QFormLayout()
        kick_layout.setLabelAlignment(Qt.AlignRight)
        kick_layout.setFormAlignment(Qt.AlignHCenter)
        kick_layout.addRow('SP:', self.kick_sp_widget)
        kick_layout.addRow('RB:', self.kick_rb_label)
        kick_layout.addRow('Mon:', self.kick_mon_label)

        return kick_layout

    def _ctrlmode_layout(self):
        ctrlmode_layout = QHBoxLayout()

        self.ctrlmode_led = SiriusLedAlert(parent=self,
                                           init_channel=self._ctrlmode_pv)
        self.ctrlmode_label = PyDMLabel(parent=self,
                                        init_channel=self._ctrlmode_pv)

        ctrlmode_layout.addStretch()
        ctrlmode_layout.addWidget(self.ctrlmode_led)
        ctrlmode_layout.addWidget(self.ctrlmode_label)

        return ctrlmode_layout
Example #6
0
class SummaryWidget(QWidget):
    """General widget for controlling a power supply."""
    def __init__(self, name, visible_props, parent=None):
        """Build UI with dclink name."""
        super().__init__(parent)
        self._name = PVName(name)
        self._psmodel = PSSearch.conv_psname_2_psmodel(name)
        self._pstype = PSSearch.conv_psname_2_pstype(name)
        self.visible_props = sort_propties(visible_props)
        self.filled_widgets = set()
        self._prefixed_name = self._name.substitute(prefix=VACA_PREFIX)

        self._analog_name = get_analog_name(self._name)
        self._strength_name = get_strength_name(self._name)
        self._is_pulsed = IsPulsed.match(self._name)
        self._is_linac = IsLinac.match(self._name)
        self._li_has_not_strength = LIQuadHasNotStrength.match(self._name)
        self._is_fofb = FastCorrector.match(self._name)
        self._is_dclink = IsDCLink.match(self._name)
        self._is_regatron = self._psmodel == 'REGATRON_DCLink'
        self._is_reg_slave = self._pstype == 'as-dclink-regatron-slave'

        self._bbb_name = ''
        self._udc_name = ''
        if not self._is_pulsed and not self._is_linac and \
                not self._is_regatron and not self._is_fofb:
            self._bbb_name = PSSearch.conv_psname_2_bbbname(self._name)
            self._udc_name = PSSearch.conv_psname_2_udc(self._name)
        self._has_opmode = not self._is_linac and not self._is_pulsed\
            and not self._is_fofb
        self._has_ctrlmode = not self._is_regatron and not self._is_linac\
            and not self._is_fofb
        self._has_pwrstate = not self._is_reg_slave
        self._has_reset = not self._is_linac and not self._is_fofb\
            and not self._is_reg_slave
        self._has_ctrlloop = not self._is_linac and not self._is_pulsed\
            and not self._is_regatron
        self._has_parmupdt = not self._is_linac and not self._is_regatron\
            and not self._is_fofb
        self._has_wfmupdt = self._has_parmupdt and not self._is_dclink
        self._has_analsp = not self._is_reg_slave
        self._has_analrb = not self._is_regatron
        self._has_analmon = not self._is_fofb
        self._has_strength = bool(self._strength_name
                                  and not self._li_has_not_strength)
        self._has_strength_mon = self._has_strength and not self._is_fofb
        self._has_trim = HasTrim.match(self._name)

        self._create_pvs()
        self._setup_ui()

    @property
    def devname(self):
        """PS name."""
        return self._name

    @property
    def bbbname(self):
        """BBB name."""
        return self._bbb_name

    @property
    def udcname(self):
        """UDC name."""
        return self._udc_name

    def _setup_ui(self):
        """Setups widget UI."""
        lay = QHBoxLayout()
        lay.setContentsMargins(0, 0, 0, 0)
        lay.setSpacing(10)
        self._widgets_dict = dict()

        self.detail_wid = self._build_widget(name='detail', orientation='v')
        self._widgets_dict['detail'] = self.detail_wid
        lay.addWidget(self.detail_wid)

        if self._bbb_name:
            self.bbb_wid = self._build_widget(name='bbb', orientation='v')
            self._widgets_dict['bbb'] = self.bbb_wid
            lay.addWidget(self.bbb_wid)

        if self._udc_name:
            self.udc_wid = self._build_widget(name='udc', orientation='v')
            self._widgets_dict['udc'] = self.udc_wid
            lay.addWidget(self.udc_wid)

        if self._has_opmode:
            self.opmode_wid = self._build_widget(name='opmode',
                                                 orientation='v')
            self._widgets_dict['opmode'] = self.opmode_wid
            lay.addWidget(self.opmode_wid)

        if self._has_ctrlmode:
            self.ctrlmode_wid = self._build_widget(name='ctrlmode',
                                                   orientation='v')
            self._widgets_dict['ctrlmode'] = self.ctrlmode_wid
            lay.addWidget(self.ctrlmode_wid)

        self.state_wid = self._build_widget(name='state')
        self._widgets_dict['state'] = self.state_wid
        lay.addWidget(self.state_wid)

        if self._is_pulsed:
            self.pulse_wid = self._build_widget(name='pulse')
            self._widgets_dict['pulse'] = self.pulse_wid
            lay.addWidget(self.pulse_wid)

        self.intlk_wid = self._build_widget(name='intlk')
        self._widgets_dict['intlk'] = self.intlk_wid
        lay.addWidget(self.intlk_wid)

        if self._is_linac:
            self.conn_wid = self._build_widget(name='conn')
            self._widgets_dict['conn'] = self.conn_wid
            lay.addWidget(self.conn_wid)

        if self._has_reset:
            self.reset_wid = self._build_widget(name='reset')
            self._widgets_dict['reset'] = self.reset_wid
            lay.addWidget(self.reset_wid)

        if self._has_ctrlloop:
            self.ctrlloop_wid = self._build_widget(name='ctrlloop')
            self._widgets_dict['ctrlloop'] = self.ctrlloop_wid
            lay.addWidget(self.ctrlloop_wid)

        if self._has_wfmupdt:
            self.wfmupdate_wid = self._build_widget(name='wfmupdate')
            self._widgets_dict['wfmupdate'] = self.wfmupdate_wid
            lay.addWidget(self.wfmupdate_wid)

        if self._has_parmupdt:
            self.updparms_wid = self._build_widget(name='updparms')
            self._widgets_dict['updparms'] = self.updparms_wid
            lay.addWidget(self.updparms_wid)

        self.setpoint_wid = self._build_widget(name='setpoint',
                                               orientation='v')
        self._widgets_dict['setpoint'] = self.setpoint_wid
        lay.addWidget(self.setpoint_wid)

        if self._has_analrb:
            self.readback_wid = self._build_widget(name='readback',
                                                   orientation='v')
            self._widgets_dict['readback'] = self.readback_wid
            lay.addWidget(self.readback_wid)

        if self._has_analmon:
            self.monitor_wid = self._build_widget(name='monitor',
                                                  orientation='v')
            self._widgets_dict['monitor'] = self.monitor_wid
            lay.addWidget(self.monitor_wid)

        if self._has_strength:
            self.strength_sp_wid = self._build_widget(name='strength_sp',
                                                      orientation='v')
            self._widgets_dict['strength_sp'] = self.strength_sp_wid
            lay.addWidget(self.strength_sp_wid)

            self.strength_rb_wid = self._build_widget(name='strength_rb',
                                                      orientation='v')
            self._widgets_dict['strength_rb'] = self.strength_rb_wid
            lay.addWidget(self.strength_rb_wid)

        if self._has_strength_mon:
            self.strength_mon_wid = self._build_widget(name='strength_mon',
                                                       orientation='v')
            self._widgets_dict['strength_mon'] = self.strength_mon_wid
            lay.addWidget(self.strength_mon_wid)

        if self._has_trim:
            self.trim_wid = self._build_widget(name='trim', orientation='v')
            self._widgets_dict['trim'] = self.trim_wid
            lay.addWidget(self.trim_wid)

        _widths = get_prop2width(self._name)
        for name, widget in self._widgets_dict.items():
            width = _widths[name]
            widget.setStyleSheet('#' + name + '{min-width:' + str(width) +
                                 'em;'
                                 'max-width:' + str(width) + 'em;}')
            widget.setSizePolicy(QSzPlcy.Fixed, QSzPlcy.Fixed)
            widget.setVisible(name in self.visible_props)

        self.setStyleSheet("""
            PyDMStateButton{
                min-width: 2.5em; max-width: 2.5em;
                min-height: 1.5em; max-height: 1.5em;
            }
            QLed{
                min-width: 1.5em; max-width: 1.5em;
                min-height: 1.5em; max-height: 1.5em;
            }
            QLabel{
                min-height: 1.5em; max-height: 1.5em;
                qproperty-alignment: AlignCenter;
            }
        """)

        lay.addStretch()
        self.setLayout(lay)

        for prop in self.visible_props:
            self.fillWidget(prop)

    def _create_pvs(self):
        if self._has_opmode:
            if self._is_reg_slave:
                self._opmode_sts = self._prefixed_name.substitute(
                    propty='ModState-Mon')
            elif self._is_regatron:
                self._opmode_sts = self._prefixed_name.substitute(
                    propty='OpMode-Sts')
            else:
                self._opmode_sel = self._prefixed_name.substitute(
                    propty='OpMode-Sel')
                self._opmode_sts = self._prefixed_name.substitute(
                    propty='OpMode-Sts')

        if self._has_ctrlmode:
            self._ctrlmode_sts = self._prefixed_name.substitute(
                propty='CtrlMode-Mon')

        if self._has_pwrstate:
            self._pwrstate_sel = self._prefixed_name.substitute(
                propty='PwrState-Sel')
            self._pwrstate_sts = self._prefixed_name.substitute(
                propty='PwrState-Sts')

        if self._is_pulsed:
            self._pulse_sel = self._prefixed_name.substitute(
                propty='Pulse-Sel')
            self._pulse_sts = self._prefixed_name.substitute(
                propty='Pulse-Sts')

        # interlock
        if self._is_pulsed:
            self._intlk = list()
            for i in range(1, 8):
                self._intlk.append(
                    self._prefixed_name.substitute(propty='Intlk' + str(i) +
                                                   '-Mon'))
            if 'Sept' not in self._name.dev:
                self._intlk.append(
                    self._prefixed_name.substitute(propty='Intlk8-Mon'))
        elif self._is_linac:
            self._intlk = self._prefixed_name.substitute(
                propty='StatusIntlk-Mon')
        elif self._is_regatron:
            if not self._is_reg_slave:
                self._generr = self._prefixed_name.substitute(
                    propty='GenIntlk-Mon')
                self._genwrn = self._prefixed_name.substitute(
                    propty='GenWarn-Mon')
        elif self._is_fofb:
            self._intlk = [
                self._prefixed_name.substitute(
                    propty='PSAmpOverCurrFlagL-Sts'),
                self._prefixed_name.substitute(
                    propty='PSAmpOverCurrFlagR-Sts'),
                self._prefixed_name.substitute(
                    propty='PSAmpOverTempFlagL-Sts'),
                self._prefixed_name.substitute(
                    propty='PSAmpOverTempFlagR-Sts'),
            ]
        else:
            self._soft_intlk = self._prefixed_name.substitute(
                propty='IntlkSoft-Mon')
            self._hard_intlk = self._prefixed_name.substitute(
                propty='IntlkHard-Mon')

        if self._is_linac:
            self._conn = self._prefixed_name.substitute(propty='Connected-Mon')

        if self._has_reset:
            self._reset_intlk = self._prefixed_name.substitute(
                propty='Reset-Cmd')

        if self._has_ctrlloop:
            self._ctrlloop_sel = self._prefixed_name.substitute(
                propty='CtrlLoop-Sel')
            self._ctrlloop_sts = self._prefixed_name.substitute(
                propty='CtrlLoop-Sts')

        if self._has_wfmupdt:
            self._wfmupdate_sel = self._prefixed_name.substitute(
                propty='WfmUpdateAuto-Sel')
            self._wfmupdate_sts = self._prefixed_name.substitute(
                propty='WfmUpdateAuto-Sts')

        if self._has_parmupdt:
            self._updparms_cmd = self._prefixed_name.substitute(
                propty='ParamUpdate-Cmd')

        # analog control
        sp = self._analog_name
        if self._has_analsp:
            self._analog_sp = self._prefixed_name.substitute(
                propty='{}-SP'.format(sp))
        if self._has_analrb:
            self._analog_rb = self._prefixed_name.substitute(
                propty='{}-RB'.format(sp))
        if self._has_analmon:
            if self._is_reg_slave:
                self._analog_mon = self._prefixed_name.substitute(
                    propty='ModOutVolt-Mon')
            else:
                self._analog_mon = self._prefixed_name.substitute(
                    propty='{}-Mon'.format(sp))

        # strength
        if self._has_strength:
            st = self._strength_name
            self._strength_sp = self._prefixed_name.substitute(
                propty='{}-SP'.format(st))
            self._strength_rb = self._prefixed_name.substitute(
                propty='{}-RB'.format(st))
        if self._has_strength_mon:
            self._strength_mon = self._prefixed_name.substitute(
                propty='{}-Mon'.format(st))

    def _build_widget(self, name='', orientation='h'):
        widget = QWidget(self)
        widget.setObjectName(name)
        if orientation == 'h':
            lay = QHBoxLayout(widget)
        else:
            lay = QVBoxLayout(widget)
        lay.setSpacing(0)
        lay.setContentsMargins(0, 3, 0, 3)
        return widget

    def fillWidget(self, name):
        if name in self.filled_widgets:
            return
        if name == 'detail':
            self.detail_bt = QPushButton(self)
            if self._name.dev == 'DCLink':
                self.detail_bt.setIcon(qta.icon('fa5s.list-ul'))
                self.detail_bt.setToolTip(self._name)
            else:
                self.detail_bt.setText(self._name)
            self.detail_wid.layout().addWidget(self.detail_bt)
        elif name == 'bbb' and self._bbb_name:
            self.bbb_lb = QLabel(self._bbb_name, self)
            self.bbb_wid.layout().addWidget(self.bbb_lb)
        elif name == 'udc' and self._udc_name:
            self.udc_lb = QLabel(self._udc_name, self)
            self.udc_wid.layout().addWidget(self.udc_lb)
        elif name == 'opmode' and self._has_opmode:
            opmode_list = list()
            if 'Voltage' not in self._analog_name:
                self.opmode_cb = SiriusEnumComboBox(self, self._opmode_sel)
                opmode_list.append(self.opmode_cb)
            self.opmode_lb = PyDMLabel(self, self._opmode_sts)
            opmode_list.append(self.opmode_lb)
            for wid in opmode_list:
                self.opmode_wid.layout().addWidget(wid)
        elif name == 'ctrlmode' and self._has_ctrlmode:
            self.ctrlmode_lb = PyDMLabel(self, self._ctrlmode_sts)
            self.ctrlmode_wid.layout().addWidget(self.ctrlmode_lb)
        elif name == 'state' and self._has_pwrstate:
            self.state_bt = PyDMStateButton(self, self._pwrstate_sel)
            self.state_led = SiriusLedState(self, self._pwrstate_sts)
            self.state_wid.layout().addWidget(self.state_bt)
            self.state_wid.layout().addWidget(self.state_led)
        elif name == 'pulse' and self._is_pulsed:
            self.pulse_bt = PyDMStateButton(self, self._pulse_sel)
            self.pulse_led = SiriusLedState(self, self._pulse_sts)
            self.pulse_wid.layout().addWidget(self.pulse_bt)
            self.pulse_wid.layout().addWidget(self.pulse_led)
        elif name == 'intlk':
            if self._is_pulsed:
                self.intlk_led = PyDMLedMultiChannel(
                    self, channels2values={ch: 1
                                           for ch in self._intlk})
                self.intlk_wid.layout().addWidget(self.intlk_led)
            elif self._is_linac:
                if IsLinacSpect.match(self.devname):
                    self.intlk_led = LISpectIntlkLed(self)
                else:
                    self.intlk_led = PyDMLedMultiChannel(self,
                                                         channels2values={
                                                             self._intlk: {
                                                                 'value':
                                                                 _PS_LI_INTLK,
                                                                 'comp': 'lt'
                                                             }
                                                         })
                self.intlk_wid.layout().addWidget(self.intlk_led)
            elif self._is_regatron:
                if not self._is_reg_slave:
                    self.generr_led = SiriusLedAlert(self, self._generr)
                    self.genwrn_led = SiriusLedAlert(self, self._genwrn)
                    self.intlk_wid.layout().addWidget(self.generr_led)
                    self.intlk_wid.layout().addWidget(self.genwrn_led)
            elif self._is_fofb:
                self.intlk_led = PyDMLedMultiChannel(
                    self, channels2values={ch: 1
                                           for ch in self._intlk})
                self.intlk_wid.layout().addWidget(self.intlk_led)
            else:
                self.soft_intlk_led = SiriusLedAlert(self, self._soft_intlk)
                self.hard_intlk_led = SiriusLedAlert(self, self._hard_intlk)
                self.intlk_wid.layout().addWidget(self.soft_intlk_led)
                self.intlk_wid.layout().addWidget(self.hard_intlk_led)
        elif name == 'conn' and self._is_linac:
            self.conn_led = PyDMLedMultiChannel(
                self, channels2values={self._conn: 0})
            self.conn_wid.layout().addWidget(self.conn_led)
        elif name == 'reset' and self._has_reset:
            self.reset_bt = PyDMPushButton(parent=self,
                                           init_channel=self._reset_intlk,
                                           pressValue=1)
            self.reset_bt.setIcon(qta.icon('fa5s.sync'))
            self.reset_bt.setObjectName('reset_bt')
            self.reset_bt.setStyleSheet(
                '#reset_bt{min-width:25px; max-width:25px; icon-size:20px;}')
            self.reset_wid.layout().addWidget(self.reset_bt)
        elif name == 'ctrlloop' and self._has_ctrlloop:
            if self._is_fofb:
                self.ctrlloop_bt = PyDMStateButton(self, self._ctrlloop_sel)
            else:
                self.ctrlloop_bt = PyDMStateButton(self,
                                                   self._ctrlloop_sel,
                                                   invert=True)
            self.ctrlloop_lb = PyDMLabel(self, self._ctrlloop_sts)
            self.ctrlloop_wid.layout().addWidget(self.ctrlloop_bt)
            self.ctrlloop_wid.layout().addWidget(self.ctrlloop_lb)
        elif name == 'wfmupdate' and self._has_wfmupdt:
            self.wfmupdate_bt = PyDMStateButton(self, self._wfmupdate_sel)
            self.wfmupdate_led = SiriusLedState(self, self._wfmupdate_sts)
            self.wfmupdate_wid.layout().addWidget(self.wfmupdate_bt)
            self.wfmupdate_wid.layout().addWidget(self.wfmupdate_led)
        elif name == 'updparms' and self._has_parmupdt:
            self.updparms_bt = PyDMPushButton(parent=self,
                                              init_channel=self._updparms_cmd,
                                              pressValue=1)
            self.updparms_bt.setIcon(qta.icon('fa5s.redo-alt'))
            self.updparms_bt.setObjectName('updparms_bt')
            self.updparms_bt.setStyleSheet(
                '#updparms_bt{min-width:25px;max-width:25px;icon-size:20px;}')
            self.updparms_wid.layout().addWidget(self.updparms_bt)
        elif name == 'setpoint' and self._has_analsp:
            self.setpoint = PyDMSpinboxScrollbar(self, self._analog_sp)
            if self._is_fofb:
                self.setpoint.spinbox.precisionFromPV = False
                self.setpoint.spinbox.precision = 6
            self.setpoint_wid.layout().addWidget(self.setpoint)
        elif name == 'readback' and self._has_analrb:
            self.readback = PyDMLabel(self, self._analog_rb)
            if self._is_fofb:
                self.readback.precisionFromPV = False
                self.readback.precision = 6
            self.readback_wid.layout().addWidget(self.readback)
        elif name == 'monitor' and self._has_analmon:
            self.monitor = PyDMLabel(self, self._analog_mon)
            self.monitor_wid.layout().addWidget(self.monitor)
        elif name == 'strength_sp' and self._has_strength:
            self.strength_sp_le = PyDMSpinboxScrollbar(self, self._strength_sp)
            self.strength_sp_wid.layout().addWidget(self.strength_sp_le)
        elif name == 'strength_rb' and self._has_strength:
            self.strength_rb_lb = PyDMLabel(parent=self,
                                            init_channel=self._strength_rb)
            self.strength_rb_lb.showUnits = True
            self.strength_rb_wid.layout().addWidget(self.strength_rb_lb)
        elif name == 'strength_mon' and self._has_strength_mon:
            self.strength_mon_lb = PyDMLabel(parent=self,
                                             init_channel=self._strength_mon)
            self.strength_mon_lb.showUnits = True
            self.strength_mon_wid.layout().addWidget(self.strength_mon_lb)
        elif name == 'trim' and self._has_trim:
            self.trim_bt = QPushButton(qta.icon('fa5s.angle-right'), '', self)
            self.trim_wid.layout().addWidget(self.trim_bt)
        self.filled_widgets.add(name)

    def get_detail_button(self):
        """Return psname button."""
        return self.detail_bt

    def get_trim_button(self):
        """Return trim button."""
        if self._has_trim:
            return self.trim_bt
        return None

    def set_opmode_slowref(self):
        """Set power supply OpMode to SlowRef."""
        if hasattr(self, 'opmode_cb'):
            if self.opmode_cb.isEnabled():
                index = self.opmode_cb.findText('SlowRef')
                self.opmode_cb.internal_combo_box_activated_int(index)

    def turn_on(self):
        """Turn power supply on."""
        if hasattr(self, 'state_bt'):
            if self.state_bt.isEnabled():
                if not self.state_bt.value:
                    self.state_bt.send_value()

    def turn_off(self):
        """Turn power supply off."""
        if hasattr(self, 'state_bt'):
            if self.state_bt.isEnabled():
                if self.state_bt.value:
                    self.state_bt.send_value()

    def ctrlloop_close(self):
        """Close control loop."""
        if hasattr(self, 'ctrlloop_bt'):
            if self.ctrlloop_bt.isEnabled():
                if not self.ctrlloop_bt.value:
                    self.ctrlloop_bt.send_value()

    def ctrlloop_open(self):
        """Open control loop."""
        if hasattr(self, 'ctrlloop_bt'):
            if self.ctrlloop_bt.isEnabled():
                if self.ctrlloop_bt.value:
                    self.ctrlloop_bt.send_value()

    def pulse_on(self):
        """Turn power supply on."""
        if hasattr(self, 'pulse_bt'):
            if self.pulse_bt.isEnabled():
                if not self.pulse_bt.value:
                    self.pulse_bt.send_value()

    def pulse_off(self):
        """Turn power supply off."""
        if hasattr(self, 'pulse_bt'):
            if self.pulse_bt.isEnabled():
                if self.pulse_bt.value:
                    self.pulse_bt.send_value()

    def wfmupdate_on(self):
        """Enable WfmUpdateAuto."""
        if hasattr(self, 'wfmupdate_bt'):
            if self.wfmupdate_bt.isEnabled():
                if not self.wfmupdate_bt.value:
                    self.wfmupdate_bt.send_value()

    def wfmupdate_off(self):
        """Disable WfmUpdateAuto."""
        if hasattr(self, 'wfmupdate_bt'):
            if self.wfmupdate_bt.isEnabled():
                if self.wfmupdate_bt.value:
                    self.wfmupdate_bt.send_value()

    def reset(self):
        """Reset power supply."""
        if hasattr(self, 'reset_bt'):
            if self.reset_bt.isEnabled():
                self.reset_bt.sendValue()

    def update_params(self):
        """Update power supply parameters."""
        if hasattr(self, 'updparms_bt'):
            if self.updparms_bt.isEnabled():
                self.updparms_bt.sendValue()
Example #7
0
    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
Example #8
0
class BPMOrbIntlkDetailWindow(BaseObject, SiriusMainWindow):
    """Individual BPM Orbit Interlock Window."""
    def __init__(self, parent=None, prefix=_vaca_prefix, device=''):
        """Init."""
        BaseObject.__init__(self, prefix)
        SiriusMainWindow.__init__(self, parent)

        self.prefix = prefix
        self.device = SiriusPVName(device)
        self.devpref = self.device.substitute(prefix=prefix)

        self.setObjectName('SIApp')
        self.setWindowTitle(device + ' Orbit Interlock Control Window')

        self._setupUi()

        self.setFocusPolicy(Qt.StrongFocus)

    def _setupUi(self):
        wid = QWidget(self)
        self.setCentralWidget(wid)

        title = QLabel('<h3>' + self.device + ' Orbit Interlock Control</h3>',
                       self,
                       alignment=Qt.AlignCenter)
        title.setStyleSheet("font-weight: bold;")

        # General Interlock
        self._gb_gen = QGroupBox('General Interlock')
        lay_gen = self._setupIntlkGenLayout()
        self._gb_gen.setLayout(lay_gen)

        # Translation Interlock
        self._gb_trans = QGroupBox('Translation Interlock')
        lay_trans = self._setupIntlkTypeLayout('Trans')
        self._gb_trans.setLayout(lay_trans)

        # Angulation Interlock
        self._gb_ang = QGroupBox('Angulation Interlock')
        lay_ang = self._setupIntlkTypeLayout('Ang')
        self._gb_ang.setLayout(lay_ang)

        lay = QGridLayout(wid)
        lay.addWidget(title, 0, 0, 1, 2)
        lay.addWidget(self._gb_gen, 1, 0, 1, 2)
        lay.addWidget(self._gb_trans, 2, 0)
        lay.addWidget(self._gb_ang, 2, 1)

    def _setupIntlkGenLayout(self):
        self._ld_genenbl = QLabel('Enable: ',
                                  self,
                                  alignment=Qt.AlignRight | Qt.AlignBottom)
        self._sb_genenbl = PyDMStateButton(
            self, self.devpref.substitute(propty='IntlkEn-Sel'))
        self._led_genenbl = SiriusLedState(
            self, self.devpref.substitute(propty='IntlkEn-Sts'))

        self._ld_genclr = QLabel('Reset: ',
                                 self,
                                 alignment=Qt.AlignRight | Qt.AlignBottom)
        self._bt_genclr = PyDMPushButton(
            self,
            init_channel=self.devpref.substitute(propty='IntlkClr-Sel'),
            pressValue=1)
        self._bt_genclr.setIcon(qta.icon('fa5s.sync'))
        self._bt_genclr.setObjectName('clr')
        self._bt_genclr.setStyleSheet(
            '#clr{min-width:25px; max-width:25px; icon-size:20px;}')

        self._ld_intlkinst = QLabel('Intantaneous Interlock: ',
                                    self,
                                    alignment=Qt.AlignRight | Qt.AlignBottom)
        self._led_intlkinst = SiriusLedAlert(
            self, self.devpref.substitute(propty='Intlk-Mon'))

        self._ld_intlkltc = QLabel('Latch Interlock: ',
                                   self,
                                   alignment=Qt.AlignRight | Qt.AlignBottom)
        self._led_intlkltc = SiriusLedAlert(
            self, self.devpref.substitute(propty='IntlkLtc-Mon'))

        self._ld_minsumenbl = QLabel('Min.Sum.Thres. Enable: ',
                                     self,
                                     alignment=Qt.AlignRight | Qt.AlignBottom)
        self._ld_minsumenbl.setToolTip(
            'If enabled, enable interlock only if minimum sum'
            ' threshold is exceeded.')
        self._sb_minsumenbl = PyDMStateButton(
            self, self.devpref.substitute(propty='IntlkMinSumEn-Sel'))
        self._led_minsumenbl = SiriusLedState(
            self, self.devpref.substitute(propty='IntlkMinSumEn-Sts'))

        self._ld_minsumlim = QLabel('Min.Sum.Thres.[sum count]: ',
                                    self,
                                    alignment=Qt.AlignRight | Qt.AlignVCenter)
        self._sb_minsumlim = SiriusSpinbox(
            self, self.devpref.substitute(propty='IntlkLmtMinSum-SP'))
        self._sb_minsumlim.showStepExponent = False
        self._sb_minsumlim.limitsFromChannel = False
        self._sb_minsumlim.setMinimum(-1e12)
        self._sb_minsumlim.setMaximum(+1e12)
        self._lb_minsumlim = PyDMLabel(
            self, self.devpref.substitute(propty='IntlkLmtMinSum-RB'))

        lay = QGridLayout()
        lay.setAlignment(Qt.AlignCenter)
        lay.addWidget(self._ld_genenbl, 0, 0)
        lay.addWidget(self._sb_genenbl, 0, 1)
        lay.addWidget(self._led_genenbl, 0, 2)
        lay.addWidget(self._ld_genclr, 1, 0)
        lay.addWidget(self._bt_genclr, 1, 1, alignment=Qt.AlignCenter)
        lay.addWidget(self._ld_intlkinst, 2, 0)
        lay.addWidget(self._led_intlkinst, 2, 1)
        lay.addWidget(self._ld_intlkltc, 3, 0)
        lay.addWidget(self._led_intlkltc, 3, 1)
        lay.addItem(QSpacerItem(1, 15, QSzPlc.Ignored, QSzPlc.Fixed), 4, 0)
        lay.addWidget(self._ld_minsumenbl, 5, 0)
        lay.addWidget(self._sb_minsumenbl, 5, 1)
        lay.addWidget(self._led_minsumenbl, 5, 2)
        lay.addWidget(self._ld_minsumlim, 6, 0)
        lay.addWidget(self._sb_minsumlim, 6, 1)
        lay.addWidget(self._lb_minsumlim, 6, 2)
        return lay

    def _setupIntlkTypeLayout(self, intlk):
        unit = 'nm'

        ld_enbl = QLabel('Enable: ',
                         self,
                         alignment=Qt.AlignRight | Qt.AlignBottom)
        sb_enbl = PyDMStateButton(
            self, self.devpref.substitute(propty='Intlk' + intlk + 'En-Sel'))
        led_enbl = SiriusLedState(
            self, self.devpref.substitute(propty='Intlk' + intlk + 'En-Sts'))

        ld_clr = QLabel('Reset: ',
                        self,
                        alignment=Qt.AlignRight | Qt.AlignBottom)
        bt_clr = PyDMPushButton(self,
                                init_channel=self.devpref.substitute(
                                    propty='Intlk' + intlk + 'Clr-Sel'),
                                pressValue=1)
        bt_clr.setIcon(qta.icon('fa5s.sync'))
        bt_clr.setObjectName('clr')
        bt_clr.setStyleSheet(
            '#clr{min-width:25px; max-width:25px; icon-size:20px;}')

        ld_minx = QLabel('Min.X Thres.[' + unit + ']: ',
                         self,
                         alignment=Qt.AlignRight | Qt.AlignVCenter)
        sb_minx = SiriusSpinbox(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MinX-SP'))
        sb_minx.showStepExponent = False
        sb_minx.limitsFromChannel = False
        sb_minx.setMinimum(-1e9)
        sb_minx.setMaximum(+1e9)
        lb_minx = PyDMLabel(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MinX-RB'))

        ld_maxx = QLabel('Max.X Thres.[' + unit + ']: ',
                         self,
                         alignment=Qt.AlignRight | Qt.AlignVCenter)
        sb_maxx = SiriusSpinbox(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MaxX-SP'))
        sb_maxx.showStepExponent = False
        sb_maxx.limitsFromChannel = False
        sb_maxx.setMinimum(-1e9)
        sb_maxx.setMaximum(+1e9)
        lb_maxx = PyDMLabel(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MaxX-RB'))

        ld_miny = QLabel('Min.Y Thres.[' + unit + ']: ',
                         self,
                         alignment=Qt.AlignRight | Qt.AlignVCenter)
        sb_miny = SiriusSpinbox(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MinY-SP'))
        sb_miny.showStepExponent = False
        sb_miny.limitsFromChannel = False
        sb_miny.setMinimum(-1e9)
        sb_miny.setMaximum(+1e9)
        lb_miny = PyDMLabel(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MinY-RB'))

        ld_maxy = QLabel('Max.Y Thres.[' + unit + ']: ',
                         self,
                         alignment=Qt.AlignRight | Qt.AlignVCenter)
        sb_maxy = SiriusSpinbox(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MaxY-SP'))
        sb_maxy.showStepExponent = False
        sb_maxy.limitsFromChannel = False
        sb_maxy.setMinimum(-1e9)
        sb_maxy.setMaximum(+1e9)
        lb_maxy = PyDMLabel(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MaxY-RB'))

        ld_leglow = QLabel('Smaller', self, alignment=Qt.AlignCenter)
        ld_leghigh = QLabel('Bigger', self, alignment=Qt.AlignCenter)

        ld_legmask = QLabel('<h4>Masked By Enable</h4>',
                            self,
                            alignment=Qt.AlignCenter)
        ld_legmask_any = QLabel('X or Y',
                                self,
                                alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_mask_anylow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'Smaller-Mon'))
        led_mask_anyhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'Bigger-Mon'))

        ld_leginst = QLabel('<h4>Instantaneous</h4>',
                            self,
                            alignment=Qt.AlignCenter)
        ld_leginst_any = QLabel('X or Y',
                                self,
                                alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_inst_anylow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'SmallerAny-Mon'))
        led_inst_anyhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerAny-Mon'))
        ld_leginst_x = QLabel('X',
                              self,
                              alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_inst_xlow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'SmallerX-Mon'))
        led_inst_xhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerX-Mon'))
        ld_leginst_y = QLabel('Y',
                              self,
                              alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_inst_ylow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'SmallerY-Mon'))
        led_inst_yhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerY-Mon'))

        ld_legltc = QLabel('<h4>Latch</h4>', self, alignment=Qt.AlignCenter)
        ld_legltc_any = QLabel('X or Y',
                               self,
                               alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_ltc_anylow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'SmallerLtc-Mon'))
        led_ltc_anyhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerLtc-Mon'))
        ld_legltc_x = QLabel('X',
                             self,
                             alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_ltc_xlow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk +
                                    'SmallerLtcX-Mon'))
        led_ltc_xhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerLtcX-Mon'))
        ld_legltc_y = QLabel('Y',
                             self,
                             alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_ltc_ylow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk +
                                    'SmallerLtcY-Mon'))
        led_ltc_yhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerLtcY-Mon'))

        lay_mon = QGridLayout()
        lay_mon.setAlignment(Qt.AlignCenter)
        lay_mon.addWidget(ld_leglow, 0, 1)
        lay_mon.addWidget(ld_leghigh, 0, 2)
        lay_mon.addWidget(ld_legmask, 1, 0)
        lay_mon.addWidget(ld_legmask_any, 2, 0)
        lay_mon.addWidget(led_mask_anylow, 2, 1)
        lay_mon.addWidget(led_mask_anyhigh, 2, 2)
        lay_mon.addWidget(ld_leginst, 3, 0)
        lay_mon.addWidget(ld_leginst_any, 4, 0)
        lay_mon.addWidget(led_inst_anylow, 4, 1)
        lay_mon.addWidget(led_inst_anyhigh, 4, 2)
        lay_mon.addWidget(ld_leginst_x, 5, 0)
        lay_mon.addWidget(led_inst_xlow, 5, 1)
        lay_mon.addWidget(led_inst_xhigh, 5, 2)
        lay_mon.addWidget(ld_leginst_y, 6, 0)
        lay_mon.addWidget(led_inst_ylow, 6, 1)
        lay_mon.addWidget(led_inst_yhigh, 6, 2)
        lay_mon.addWidget(ld_legltc, 7, 0)
        lay_mon.addWidget(ld_legltc_any, 8, 0)
        lay_mon.addWidget(led_ltc_anylow, 8, 1)
        lay_mon.addWidget(led_ltc_anyhigh, 8, 2)
        lay_mon.addWidget(ld_legltc_x, 9, 0)
        lay_mon.addWidget(led_ltc_xlow, 9, 1)
        lay_mon.addWidget(led_ltc_xhigh, 9, 2)
        lay_mon.addWidget(ld_legltc_y, 10, 0)
        lay_mon.addWidget(led_ltc_ylow, 10, 1)
        lay_mon.addWidget(led_ltc_yhigh, 10, 2)

        lay = QGridLayout()
        lay.setAlignment(Qt.AlignTop)
        lay.addWidget(ld_enbl, 0, 0)
        lay.addWidget(sb_enbl, 0, 1)
        lay.addWidget(led_enbl, 0, 2)
        lay.addWidget(ld_clr, 1, 0)
        lay.addWidget(bt_clr, 1, 1, alignment=Qt.AlignCenter)
        lay.addWidget(ld_minx, 2, 0)
        lay.addWidget(sb_minx, 2, 1)
        lay.addWidget(lb_minx, 2, 2)
        lay.addWidget(ld_maxx, 3, 0)
        lay.addWidget(sb_maxx, 3, 1)
        lay.addWidget(lb_maxx, 3, 2)
        lay.addWidget(ld_miny, 4, 0)
        lay.addWidget(sb_miny, 4, 1)
        lay.addWidget(lb_miny, 4, 2)
        lay.addWidget(ld_maxy, 5, 0)
        lay.addWidget(sb_maxy, 5, 1)
        lay.addWidget(lb_maxy, 5, 2)
        lay.addItem(QSpacerItem(1, 15, QSzPlc.Ignored, QSzPlc.Fixed), 6, 0)
        lay.addLayout(lay_mon, 7, 0, 1, 3)
        return lay
Example #9
0
    def _setupIntlkTypeLayout(self, intlk):
        unit = 'nm'

        ld_enbl = QLabel('Enable: ',
                         self,
                         alignment=Qt.AlignRight | Qt.AlignBottom)
        sb_enbl = PyDMStateButton(
            self, self.devpref.substitute(propty='Intlk' + intlk + 'En-Sel'))
        led_enbl = SiriusLedState(
            self, self.devpref.substitute(propty='Intlk' + intlk + 'En-Sts'))

        ld_clr = QLabel('Reset: ',
                        self,
                        alignment=Qt.AlignRight | Qt.AlignBottom)
        bt_clr = PyDMPushButton(self,
                                init_channel=self.devpref.substitute(
                                    propty='Intlk' + intlk + 'Clr-Sel'),
                                pressValue=1)
        bt_clr.setIcon(qta.icon('fa5s.sync'))
        bt_clr.setObjectName('clr')
        bt_clr.setStyleSheet(
            '#clr{min-width:25px; max-width:25px; icon-size:20px;}')

        ld_minx = QLabel('Min.X Thres.[' + unit + ']: ',
                         self,
                         alignment=Qt.AlignRight | Qt.AlignVCenter)
        sb_minx = SiriusSpinbox(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MinX-SP'))
        sb_minx.showStepExponent = False
        sb_minx.limitsFromChannel = False
        sb_minx.setMinimum(-1e9)
        sb_minx.setMaximum(+1e9)
        lb_minx = PyDMLabel(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MinX-RB'))

        ld_maxx = QLabel('Max.X Thres.[' + unit + ']: ',
                         self,
                         alignment=Qt.AlignRight | Qt.AlignVCenter)
        sb_maxx = SiriusSpinbox(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MaxX-SP'))
        sb_maxx.showStepExponent = False
        sb_maxx.limitsFromChannel = False
        sb_maxx.setMinimum(-1e9)
        sb_maxx.setMaximum(+1e9)
        lb_maxx = PyDMLabel(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MaxX-RB'))

        ld_miny = QLabel('Min.Y Thres.[' + unit + ']: ',
                         self,
                         alignment=Qt.AlignRight | Qt.AlignVCenter)
        sb_miny = SiriusSpinbox(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MinY-SP'))
        sb_miny.showStepExponent = False
        sb_miny.limitsFromChannel = False
        sb_miny.setMinimum(-1e9)
        sb_miny.setMaximum(+1e9)
        lb_miny = PyDMLabel(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MinY-RB'))

        ld_maxy = QLabel('Max.Y Thres.[' + unit + ']: ',
                         self,
                         alignment=Qt.AlignRight | Qt.AlignVCenter)
        sb_maxy = SiriusSpinbox(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MaxY-SP'))
        sb_maxy.showStepExponent = False
        sb_maxy.limitsFromChannel = False
        sb_maxy.setMinimum(-1e9)
        sb_maxy.setMaximum(+1e9)
        lb_maxy = PyDMLabel(
            self,
            self.devpref.substitute(propty='IntlkLmt' + intlk + 'MaxY-RB'))

        ld_leglow = QLabel('Smaller', self, alignment=Qt.AlignCenter)
        ld_leghigh = QLabel('Bigger', self, alignment=Qt.AlignCenter)

        ld_legmask = QLabel('<h4>Masked By Enable</h4>',
                            self,
                            alignment=Qt.AlignCenter)
        ld_legmask_any = QLabel('X or Y',
                                self,
                                alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_mask_anylow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'Smaller-Mon'))
        led_mask_anyhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'Bigger-Mon'))

        ld_leginst = QLabel('<h4>Instantaneous</h4>',
                            self,
                            alignment=Qt.AlignCenter)
        ld_leginst_any = QLabel('X or Y',
                                self,
                                alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_inst_anylow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'SmallerAny-Mon'))
        led_inst_anyhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerAny-Mon'))
        ld_leginst_x = QLabel('X',
                              self,
                              alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_inst_xlow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'SmallerX-Mon'))
        led_inst_xhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerX-Mon'))
        ld_leginst_y = QLabel('Y',
                              self,
                              alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_inst_ylow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'SmallerY-Mon'))
        led_inst_yhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerY-Mon'))

        ld_legltc = QLabel('<h4>Latch</h4>', self, alignment=Qt.AlignCenter)
        ld_legltc_any = QLabel('X or Y',
                               self,
                               alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_ltc_anylow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'SmallerLtc-Mon'))
        led_ltc_anyhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerLtc-Mon'))
        ld_legltc_x = QLabel('X',
                             self,
                             alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_ltc_xlow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk +
                                    'SmallerLtcX-Mon'))
        led_ltc_xhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerLtcX-Mon'))
        ld_legltc_y = QLabel('Y',
                             self,
                             alignment=Qt.AlignRight | Qt.AlignVCenter)
        led_ltc_ylow = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk +
                                    'SmallerLtcY-Mon'))
        led_ltc_yhigh = SiriusLedAlert(
            self,
            self.devpref.substitute(propty='Intlk' + intlk + 'BiggerLtcY-Mon'))

        lay_mon = QGridLayout()
        lay_mon.setAlignment(Qt.AlignCenter)
        lay_mon.addWidget(ld_leglow, 0, 1)
        lay_mon.addWidget(ld_leghigh, 0, 2)
        lay_mon.addWidget(ld_legmask, 1, 0)
        lay_mon.addWidget(ld_legmask_any, 2, 0)
        lay_mon.addWidget(led_mask_anylow, 2, 1)
        lay_mon.addWidget(led_mask_anyhigh, 2, 2)
        lay_mon.addWidget(ld_leginst, 3, 0)
        lay_mon.addWidget(ld_leginst_any, 4, 0)
        lay_mon.addWidget(led_inst_anylow, 4, 1)
        lay_mon.addWidget(led_inst_anyhigh, 4, 2)
        lay_mon.addWidget(ld_leginst_x, 5, 0)
        lay_mon.addWidget(led_inst_xlow, 5, 1)
        lay_mon.addWidget(led_inst_xhigh, 5, 2)
        lay_mon.addWidget(ld_leginst_y, 6, 0)
        lay_mon.addWidget(led_inst_ylow, 6, 1)
        lay_mon.addWidget(led_inst_yhigh, 6, 2)
        lay_mon.addWidget(ld_legltc, 7, 0)
        lay_mon.addWidget(ld_legltc_any, 8, 0)
        lay_mon.addWidget(led_ltc_anylow, 8, 1)
        lay_mon.addWidget(led_ltc_anyhigh, 8, 2)
        lay_mon.addWidget(ld_legltc_x, 9, 0)
        lay_mon.addWidget(led_ltc_xlow, 9, 1)
        lay_mon.addWidget(led_ltc_xhigh, 9, 2)
        lay_mon.addWidget(ld_legltc_y, 10, 0)
        lay_mon.addWidget(led_ltc_ylow, 10, 1)
        lay_mon.addWidget(led_ltc_yhigh, 10, 2)

        lay = QGridLayout()
        lay.setAlignment(Qt.AlignTop)
        lay.addWidget(ld_enbl, 0, 0)
        lay.addWidget(sb_enbl, 0, 1)
        lay.addWidget(led_enbl, 0, 2)
        lay.addWidget(ld_clr, 1, 0)
        lay.addWidget(bt_clr, 1, 1, alignment=Qt.AlignCenter)
        lay.addWidget(ld_minx, 2, 0)
        lay.addWidget(sb_minx, 2, 1)
        lay.addWidget(lb_minx, 2, 2)
        lay.addWidget(ld_maxx, 3, 0)
        lay.addWidget(sb_maxx, 3, 1)
        lay.addWidget(lb_maxx, 3, 2)
        lay.addWidget(ld_miny, 4, 0)
        lay.addWidget(sb_miny, 4, 1)
        lay.addWidget(lb_miny, 4, 2)
        lay.addWidget(ld_maxy, 5, 0)
        lay.addWidget(sb_maxy, 5, 1)
        lay.addWidget(lb_maxy, 5, 2)
        lay.addItem(QSpacerItem(1, 15, QSzPlc.Ignored, QSzPlc.Fixed), 6, 0)
        lay.addLayout(lay_mon, 7, 0, 1, 3)
        return lay
Example #10
0
    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
Example #11
0
    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
Example #12
0
    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
Example #13
0
    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