Esempio n. 1
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. 2
0
    def _set_check_dclinks_capvolt(self):
        self.ok_ps.clear()
        self.nok_ps.clear()
        pwrsupplies = self._get_selected_ps()
        if not pwrsupplies:
            return
        devices = self._get_related_dclinks(pwrsupplies,
                                            include_regatrons=True)
        dev_exc_regatrons = {
            dev
            for dev in devices
            if PSSearch.conv_psname_2_psmodel(dev) != 'REGATRON_DCLink'
        }
        if not devices:
            return

        task0 = CreateTesters(devices, parent=self)
        task1 = SetCapBankVolt(dev_exc_regatrons, parent=self)
        task2 = CheckCapBankVolt(devices, parent=self)
        task2.itemDone.connect(self._log)
        labels = [
            'Connecting to devices...', 'Setting capacitor bank voltage...',
            'Checking capacitor bank voltage...'
        ]
        tasks = [task0, task1, task2]
        dlg = ProgressDialog(labels, tasks, self)
        dlg.exec_()
Esempio n. 3
0
 def _connect_buttons(self, widget):
     w = widget.findChild(QPushButton, 'dclink_button')
     if w:
         psname = self._psname[0]
         dclinks = PSSearch.conv_psname_2_dclink(psname)
         if dclinks:
             dclink_type = PSSearch.conv_psname_2_psmodel(dclinks[0])
             if dclink_type != 'REGATRON_DCLink':
                 connect_window(w, PSDetailWindow, self, psname=dclinks)
             else:
                 if len(dclinks) > 1:
                     menu = QMenu(w)
                     for dcl in dclinks:
                         act = QAction(dcl, menu)
                         connect_newprocess(act, [
                             'sirius-hla-as-ps-regatron-individual', '-dev',
                             dcl
                         ],
                                            parent=self,
                                            is_pydm=True)
                         menu.addAction(act)
                     w.setMenu(menu)
                 else:
                     connect_newprocess(w, [
                         'sirius-hla-as-ps-regatron-individual', '-dev',
                         dclinks[0]
                     ],
                                        parent=self,
                                        is_pydm=True)
         else:
             w.setHidden(True)
Esempio n. 4
0
 def function(self):
     """Create cyclers."""
     for psname in self._psnames:
         self.currentItem.emit(psname)
         if psname not in BaseTask._cyclers:
             if PVName(psname).sec == 'LI':
                 c = LinacPSCycler(psname)
             elif PSSearch.conv_psname_2_psmodel(psname) == 'FOFB_PS':
                 c = FOFBPSCycler(psname)
             elif PSSearch.conv_psname_2_psmodel(psname) == 'FBP':
                 c = PSCyclerFBP(psname)
             else:
                 c = PSCycler(psname)
             BaseTask._cyclers[psname] = c
         self.itemDone.emit(psname, True)
         if self._quit_task:
             self._interrupted = True
             break
Esempio n. 5
0
 def _item(psname, parent=None):
     if 'DCLink' in psname:
         model = PSSearch.conv_psname_2_psmodel(psname)
         if model == 'FBP_DCLink':
             return FBPDCLinkDetailWidget(psname, parent)
         elif model in ('FAC_ACDC', 'FAC_2S_ACDC', 'FAC_2P4S_ACDC'):
             return FACDCLinkDetailWidget(psname, parent)
         else:
             raise ValueError('Undefined PS model: {}'.format(model))
     elif 'LI' in psname:
         return LIPSDetailWidget(psname, parent)
     elif 'FCH' in psname or 'FCV' in psname:
         return FastCorrPSDetailWidget(psname, parent)
     else:
         return PSDetailWidget(psname, parent)
Esempio n. 6
0
def create_udc(bbbname=BBBNAME, udc_index=None):
    """Create UDC."""
    pru = PRU(bbbname=bbbname)
    if udc_index is not None:
        udc_list = PSSearch.conv_bbbname_2_udc(bbbname)
        udcname = udc_list[udc_index]
        bsmps = PSSearch.conv_udc_2_bsmps(udcname)
    else:
        bsmps = PSSearch.conv_bbbname_2_bsmps(bbbname)
    psnames, device_ids = zip(*bsmps)
    for psname, dev_id in bsmps:
        print('psname: {:<15}   dev_id: {}'.format(psname, dev_id))
    psmodel = PSSearch.conv_psname_2_psmodel(psnames[0])
    udc = UDC(pru=pru, psmodel=psmodel, device_ids=device_ids)
    return udc
Esempio n. 7
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. 8
0
def get_prop2label(psname):
    psmodel = PSSearch.conv_psname_2_psmodel(psname)

    analog = get_analog_name(psname)
    if 'CapacitorBank' in analog:
        analog = 'Voltage'
    dic = {
        'detail': 'Detail',
        'state': 'PwrState',
        'intlk': 'Interlocks',
        'setpoint': analog + '-SP',
    }
    if psmodel != 'REGATRON_DCLink':
        dic.update({'readback': analog + '-RB'})
    if psmodel != 'FOFB_PS':
        dic.update({'monitor': analog + '-Mon'})
    else:
        dic.update({'ctrlloop': 'Control Loop'})
    if psname.sec == 'LI':
        dic['conn'] = 'Connected'
    elif psmodel != 'FOFB_PS':
        dic.update({
            'opmode': 'OpMode',
            'reset': 'Reset',
        })
        if psmodel != 'REGATRON_DCLink':
            dic.update({
                'bbb': 'Beagle Bone',
                'udc': 'UDC',
                'ctrlmode': 'Control Mode',
                'ctrlloop': 'Control Loop',
                'wfmupdate': 'Wfm Update',
                'updparms': 'Upd.Params',
            })
    strength = get_strength_name(psname)
    if strength:
        dic.update({
            'strength_sp': strength + '-SP',
            'strength_rb': strength + '-RB'
        })
        if psmodel != 'FOFB_PS':
            dic.update({'strength_mon': strength + '-Mon'})
    if psname.dis == 'PU':
        dic.update({'pulse': 'Pulse'})
    if HasTrim.match(psname):
        dic.update({'trim': 'Trim'})
    return sort_propties(dic)
Esempio n. 9
0
    def _connect_buttons(self, widget):
        for w in widget.get_summary_widgets():
            detail_bt = w.get_detail_button()
            psname = detail_bt.text()
            if not psname:
                psname = detail_bt.toolTip()
            psname = _PVName(psname)
            if PSSearch.conv_psname_2_psmodel(psname) == 'REGATRON_DCLink':
                connect_newprocess(
                    w,
                    ['sirius-hla-as-ps-regatron-individual', '-dev', psname],
                    parent=self,
                    is_pydm=True)
            else:
                connect_window(detail_bt, PSDetailWindow, self, psname=psname)

            trim_bt = w.get_trim_button()
            if trim_bt is not None:
                connect_window(trim_bt, PSTrimWindow, self, device=psname)
Esempio n. 10
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. 11
0
def get_prop2width(psname):
    psmodel = PSSearch.conv_psname_2_psmodel(psname)
    detail_wid = '8.5' if psname.dev != 'DCLink' else '3'
    dic = {
        'detail': detail_wid,
        'state': '6',
        'intlk': '5',
        'setpoint': '6',
    }
    if psmodel != 'REGATRON_DCLink':
        dic.update({'readback': '6'})
    if psmodel != 'FOFB_PS':
        dic.update({'monitor': '6'})
    else:
        dic.update({'ctrlloop': '8'})
    if psname.sec == 'LI':
        dic['conn'] = '5'
    elif psmodel != 'FOFB_PS':
        dic.update({
            'opmode': '8',
            'reset': '4',
        })
        if psmodel != 'REGATRON_DCLink':
            dic.update({
                'bbb': 10,
                'udc': 10,
                'ctrlmode': '6',
                'ctrlloop': '8',
                'wfmupdate': '8',
                'updparms': '6',
            })
    if get_strength_name(psname):
        dic.update({'strength_sp': '6', 'strength_rb': '6'})
        if psmodel != 'FOFB_PS':
            dic.update({'strength_mon': '8'})
    if psname.dis == 'PU':
        dic.update({'pulse': '8'})
    if HasTrim.match(psname):
        dic.update({'trim': '2'})
    return sort_propties(dic)
def create_tree():
    """."""
    dev2ip = get_device_2_ioc_ip()
    bbbnames = PSSearch.get_bbbnames()
    tree = ['BeagleBones', []]
    for bbbname in bbbnames:
        # PSSearch.con
        bbbip = dev2ip[bbbname] if bbbname in dev2ip else ''
        bbblist = (bbbname + '  [' + bbbip + ']', [])
        udcnames = PSSearch.conv_bbbname_2_udc(bbbname)
        for udcname in udcnames:
            udclist = [udcname, []]
            devices = PSSearch.conv_udc_2_bsmps(udcname)
            for device in devices:
                psname, bsmp_id = device
                psmodel = PSSearch.conv_psname_2_psmodel(psname)
                if device == devices[0]:
                    udclist[0] += '  (' + psmodel + ')'
                pslist = [psname + '  (' + str(bsmp_id) + ')', []]

                try:
                    dclinks = PSSearch.conv_psname_2_dclink(psname)
                except KeyError:
                    dclinks = []
                if dclinks is None:
                    dclinks = []
                if len(dclinks) > 0:
                    for dclink in dclinks:
                        dclinklist = [dclink, []]
                        pslist[-1].append(dclinklist)

                # print(dclinks)
                udclist[-1].append(pslist)
                # print(psname, bsmp_id)
            bbblist[-1].append(udclist)
        tree[-1].append(bbblist)
    return tree
Esempio n. 13
0
    def __init__(self, widget, parent=None):
        super().__init__(parent)
        self._widget = widget
        self.name = widget.devname
        self.bbbname = widget.bbbname
        self.udcname = widget.udcname

        self.dclinks = list()
        self.dclinks_type = ''
        self.dclink_widgets = list()
        self.dclinksbbbname = set()
        self.dclinksudcname = set()
        dclinks = PSSearch.conv_psname_2_dclink(self.name)
        if dclinks:
            self.dclinks = dclinks
            self.dclinks_type = PSSearch.conv_psname_2_psmodel(dclinks[0])
            if self.dclinks_type != 'REGATRON_DCLink':
                for dc in dclinks:
                    self.dclinksbbbname.add(PSSearch.conv_psname_2_bbbname(dc))
                    self.dclinksudcname.add(PSSearch.conv_psname_2_udc(dc))
            self.all_props = get_prop2label(PVName(dclinks[0]))

        self.visible_props = sort_propties(
            ['detail', 'state', 'intlk', 'setpoint', 'monitor'])
        self._setup_ui()
        self._create_actions()
        self._enable_actions()
        self.setStyleSheet("""
            #HideButton {
                min-width: 10px;
                max-width: 10px;
            }
            #DCLinkContainer {
                background-color: lightgrey;
            }
        """)
Esempio n. 14
0
    def __init__(self, device):
        """Init."""
        super().__init__(device)

        self.properties = [
            'Reset-Cmd',
            'OpMode-Sel', 'OpMode-Sts',
            'PwrState-Sel', 'PwrState-Sts',
            'CtrlLoop-Sel', 'CtrlLoop-Sts',
            'Current-SP', 'CurrentRef-Mon', 'Current-Mon']
        self._intlk_pvs = get_ps_interlocks(psname=self.device)
        self.properties.extend(self._intlk_pvs)

        if PSSearch.conv_psname_2_psmodel(self.device) == 'FBP':
            self.properties.extend(['SOFBMode-Sel', 'SOFBMode-Sts'])

        for ppty in self.properties:
            self._pvs[ppty] = _PV(
                _PVName(device).substitute(prefix=VACA_PREFIX, propty=ppty),
                connection_timeout=TIMEOUT_CONN)

        splims = PSSearch.conv_psname_2_splims(device)
        self.test_current = splims['TSTV']
        self.test_tol = splims['TSTR']
Esempio n. 15
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. 16
0
    def _set_check_fbp_sofbmode(self, state):
        self.ok_ps.clear()
        self.nok_ps.clear()
        devices = self._get_selected_ps()
        devices = [
            dev for dev in devices
            if PSSearch.conv_psname_2_psmodel(dev) == 'FBP'
        ]
        if not devices:
            return

        task0 = CreateTesters(devices, parent=self)
        task1 = SetSOFBMode(devices, state=state, parent=self)
        task2 = CheckSOFBMode(devices, state=state, parent=self)
        task2.itemDone.connect(self._log)
        tasks = [task0, task1, task2]

        labels = [
            'Connecting to devices...', 'Turning PS SOFBMode ' + state + '...',
            'Checking PS SOFBMode ' + state + '...'
        ]

        dlg = ProgressDialog(labels, tasks, self)
        dlg.exec_()
Esempio n. 17
0
 def test_conv_psname_2_psmodel(self):
     """Test conv_psname_2_psmodel."""
     for ps, pstype in TestPSSearch.sample.items():
         model = PSSearch.conv_psname_2_psmodel(psname=ps)
         self.assertIsInstance(model, str)
Esempio n. 18
0
#!/usr/bin/env python-sirius

"""PS detailed window."""

import sys
import argparse as _argparse
from siriuspy.search import PSSearch
from siriushla.sirius_application import SiriusApplication
from siriushla.as_ps_control import PSDetailWindow
from siriushla.util import run_newprocess


parser = _argparse.ArgumentParser(
    description="Run Power Supply Detailed Control Interface.")
parser.add_argument("psname", type=str, help="PS name.")
args = parser.parse_args()

if PSSearch.conv_psname_2_psmodel(args.psname) == 'REGATRON_DCLink':
    run_newprocess(
        ['sirius-hla-as-ps-regatron-individual', '-dev', args.psname],
        is_pydm=True)
else:
    app = SiriusApplication()
    app.open_window(PSDetailWindow, parent=None, psname=args.psname)
    sys.exit(app.exec_())