Esempio n. 1
0
    def __init__(self, parent, psnames):
        super().__init__(parent)

        self._psnames = psnames

        self._choose_sec = ['TB', 'BO', 'TS', 'SI']

        self._choose_sub = ['All', ]
        self._choose_sub.extend(['{0:02d}.*'.format(i+1) for i in range(20)])
        self._choose_sub.extend(['.*M1', '.*M2',
                                 '.*C1', '.*C2', '.*C3', '.*C4',
                                 '.*SA', '.*SB', '.*SP'])

        self._choose_dev = {
            sec: ['CH', 'CV', 'C(H|V)'] for sec in self._choose_sec}
        self._choose_dev['SI'].extend(
            ['QS', 'QFA', 'QFB', 'QFP', 'QF.*',
             'QDA', 'QDB1', 'QDB2', 'QDP1', 'QDP2', 'QD.*',
             'Q1', 'Q2', 'Q3', 'Q4', 'Q[1-4]',
             'Q(D|F).*', 'Q(F|D|[1-4]).*',
             'FCH', 'FCV', 'FC(H|V)'])

        self.magfunc = _PSSearch.conv_psname_2_magfunc(self._psnames[0])
        self.pytype = _PSSearch.conv_psname_2_pstype(self._psnames[0])

        self._setupUi()
Esempio n. 2
0
 def function(self):
     for dev in self._devices:
         self.currentItem.emit(dev)
         if dev not in BaseTask._testers:
             devname = _PVName(dev)
             if devname.sec == 'LI':
                 t = TesterPSLinac(dev)
             elif _PSSearch.conv_psname_2_psmodel(dev) == 'FOFB_PS':
                 t = TesterPSFOFB(dev)
             elif _PSSearch.conv_psname_2_psmodel(dev) == 'FBP_DCLink':
                 t = TesterDCLinkFBP(dev)
             elif 'bo-dclink' in _PSSearch.conv_psname_2_pstype(dev):
                 t = TesterDCLink(dev)
             elif _PSSearch.conv_psname_2_psmodel(dev) == 'REGATRON_DCLink':
                 t = TesterDCLinkRegatron(dev)
             elif _PSSearch.conv_psname_2_psmodel(dev) == 'FBP':
                 t = TesterPSFBP(dev)
             elif devname.dis == 'PS':
                 t = TesterPS(dev)
             elif devname.dis == 'PU' and 'Kckr' in devname.dev:
                 t = TesterPUKckr(dev)
             elif devname.dis == 'PU' and 'Sept' in devname.dev:
                 t = TesterPUSept(dev)
             else:
                 raise NotImplementedError(
                     'There is no Tester defined to ' + dev + '.')
             BaseTask._testers[dev] = t
         self.itemDone.emit(dev, True)
         if self._quit_task:
             break
Esempio n. 3
0
 def test_conv_psname_2_pstypes(self):
     """Test conv_psname_2_pstype."""
     for psname, pstype in TestPSSearch.sample.items():
         self.assertEqual(PSSearch.conv_psname_2_pstype(psname), pstype)
     # exceptions
     self.assertRaises(KeyError,
                       PSSearch.conv_psname_2_pstype,
                       psname='dummy')
Esempio n. 4
0
 def __init__(self, parent=None, prefix=_vaca_prefix, filters=''):
     super().__init__(parent)
     self.setWindowTitle('Power Supplies Graph Monitor')
     self._prefix = prefix
     self._filters = filters
     if not filters:
         self.setObjectName('ASApp')
         filters = {'sec': 'SI', 'dis': 'PS', 'dev': 'CH'}
     else:
         self.setObjectName(filters['sec']+'App')
     self._psnames = _PSSearch.get_psnames(filters)
     self._magfunc = _PSSearch.conv_psname_2_magfunc(self._psnames[0])
     self._pstype = _PSSearch.conv_psname_2_pstype(self._psnames[0])
     self._setupUi()
Esempio n. 5
0
    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()
Esempio n. 6
0
    def _set_psnames(self):
        sec = self.cb_sec.currentText()
        if sec == 'SI':
            sub = self.cb_sub.currentText()
            sub = sub if sub != 'All' else '.*'
        else:
            sub = '.*'
        dev = self.cb_dev[sec].currentText()

        self._psnames = _PSSearch.get_psnames(
            {'sec': sec, 'sub': '(?!Fam)'+sub, 'dis': 'PS', 'dev': dev})

        if self._psnames and self.sender() == self.cb_dev[sec]:
            self.magfunc = _PSSearch.conv_psname_2_magfunc(self._psnames[0])
            self.pytype = _PSSearch.conv_psname_2_pstype(self._psnames[0])
            self.matype_changed.emit(self.magfunc, self.pytype)

        self.psnames_changed.emit(self._psnames)
Esempio n. 7
0
 def _get_related_dclinks(self, psnames, include_regatrons=False):
     if isinstance(psnames, str):
         psnames = [
             psnames,
         ]
     alldclinks = set()
     for name in psnames:
         if 'LI' in name:
             continue
         dclinks = PSSearch.conv_psname_2_dclink(name)
         if dclinks:
             dclink_model = PSSearch.conv_psname_2_psmodel(dclinks[0])
             if dclink_model != 'REGATRON_DCLink':
                 alldclinks.update(dclinks)
             elif include_regatrons:
                 for dcl in dclinks:
                     dcl_typ = PSSearch.conv_psname_2_pstype(dcl)
                     if dcl_typ == 'as-dclink-regatron-master':
                         alldclinks.add(dcl)
     alldclinks = [PVName(dev) for dev in alldclinks]
     return alldclinks
Esempio n. 8
0
def get_analog_name(psname):
    """."""
    psname = PVName(psname)
    psmodel = PSSearch.conv_psname_2_psmodel(psname)
    pstype = PSSearch.conv_psname_2_pstype(psname)

    if 'dclink' in pstype:
        if psmodel == 'FBP_DCLink':
            return 'Voltage'
        elif psmodel in {'FAC_ACDC', 'FAC_2S_ACDC', 'FAC_2P4S_ACDC'}:
            return 'CapacitorBankVoltage'
        elif psmodel == 'REGATRON_DCLink':
            return 'Voltage'
        else:
            raise RuntimeError(
                'Undefined PS model {} setpoint PV name'.format(psmodel))
    else:
        if psname.dis == 'PS':
            return 'Current'
        elif psname.dis == 'PU':
            return 'Voltage'
        else:
            raise RuntimeError(
                'Undefined PS model {} setpoint PV name'.format(psmodel))
Esempio n. 9
0
 def __init__(self, psname, parent=None):
     """Init UI."""
     super(PSDetailWindow, self).__init__(parent)
     if isinstance(psname, str):
         self._psname = [
             _PVName(psname),
         ]
     else:
         self._psname = [_PVName(psn) for psn in psname]
     name = self._psname[0]
     self._is_dclink = 'dclink' in PSSearch.conv_psname_2_pstype(name)
     secs = {'AS', 'LI', 'TB', 'BO', 'TS', 'SI', 'IT'}
     if name.sub.endswith(('SA', 'SB', 'SP', 'ID')):
         sec = 'ID'
     elif name.sec in secs:
         sec = name.sec
     elif name.idx[:2] in secs:
         sec = name.idx[:2]
     else:
         sec = 'AS'
     self.setObjectName(sec + 'App')
     icon = qta.icon('mdi.car-battery', color=get_appropriate_color(sec))
     self.setWindowIcon(icon)
     self._setup_ui()