Ejemplo n.º 1
0
def get_event_database(evt_num=0, prefix=None):
    """Return event_database."""
    def_prefix = 'Evt{0:02d}'.format(evt_num)
    prefix = def_prefix if prefix is None else prefix

    dbase = dict()
    dic_ = {
        'type': 'int',
        'value': 0,
        'lolo': 0,
        'low': 0,
        'lolim': 0,
        'hilim': 2**31 - 1,
        'high': 2**31 - 1,
        'hihi': 2**31 - 1
    }
    dbase[prefix + 'Delay-SP'] = _dcopy(dic_)
    dbase[prefix + 'Delay-RB'] = dic_
    dic_ = {'type': 'enum', 'enums': _et.EVT_MODES, 'value': 1}
    dbase[prefix + 'Mode-Sel'] = _dcopy(dic_)
    dbase[prefix + 'Mode-Sts'] = dic_
    dic_ = {'type': 'enum', 'enums': _et.FIXED_INCR, 'value': 1}
    dbase[prefix + 'DelayType-Sel'] = _dcopy(dic_)
    dbase[prefix + 'DelayType-Sts'] = dic_
    dic_ = {'type': 'string', 'value': ''}
    dbase[prefix + 'Desc-SP'] = _dcopy(dic_)
    dbase[prefix + 'Desc-RB'] = dic_
    dbase[prefix + 'ExtTrig-Cmd'] = {'type': 'int', 'value': 0}
    return dbase
Ejemplo n.º 2
0
def get_eve_database(eve_num=1, prefix=None):
    """Return eve_database."""
    prefix = prefix or ''
    dbase = dict()

    dic_ = {'type': 'enum', 'value': 0, 'enums': _et.DSBL_ENBL}
    dbase[prefix + 'DevEnbl-Sts'] = dic_
    dbase[prefix + 'DevEnbl-Sel'] = _dcopy(dic_)

    dic_ = {'type': 'enum', 'value': 0, 'enums': _et.RFOUT}
    dbase[prefix + 'RFOut-Sts'] = dic_
    dbase[prefix + 'RFOut-Sel'] = _dcopy(dic_)

    dbase[prefix + 'Alive-Mon'] = {
        'type': 'int',
        'value': 0,
        'unit': '',
        'lolo': 0,
        'low': 0,
        'lolim': 0,
        'hilim': 2**31 - 1,
        'high': 2**31 - 1,
        'hihi': 2**31 - 1
    }

    dbase[prefix + 'Network-Mon'] = {
        'type': 'enum',
        'value': 1,
        'enums': _et.DISCONN_CONN
    }

    dbase[prefix + 'LinkStatus-Mon'] = {
        'type': 'enum',
        'value': 1,
        'enums': _et.UNLINK_LINK
    }

    dbase[prefix + 'IntlkStatus-Mon'] = {
        'type': 'enum',
        'value': 0,
        'enums': _et.DSBL_ENBL
    }

    dbase[prefix + 'IntlkEnbl-Mon'] = {
        'type': 'enum',
        'value': 0,
        'enums': _et.DSBL_ENBL
    }

    for i in range(24):
        db2 = get_otp_database(otp_num=i)
        for k, v in db2.items():
            dbase[prefix + k] = v

    for i in range(8):
        db2 = get_out_database(out_num=i, equip='EVE')
        for k, v in db2.items():
            dbase[prefix + k] = v

    return dbase
Ejemplo n.º 3
0
    def __init__(self, parent=None, prefix='', ramp_config=None,
                 norm_config=None, time=None, energy=None,
                 magnets=dict(), conn_sofb=None,
                 tunecorr_configname=None, chromcorr_configname=None):
        """Initialize object."""
        super().__init__(parent)
        self.setWindowTitle('Edit Normalized Configuration')
        self.setObjectName('BOApp')
        self.prefix = prefix
        self.ramp_config = ramp_config
        self.norm_config = _dcopy(norm_config)
        self.time = time
        self.energy = energy

        self._aux_magnets = magnets
        self._conn_sofb = conn_sofb
        self._tunecorr = BOTuneCorr(tunecorr_configname)
        self._chromcorr = BOChromCorr(chromcorr_configname)

        self._reference = _dcopy(norm_config)
        self._currChrom = self._estimateChrom(use_ref=True)
        self._deltas = {
            'kicks': dict(),
            'factorH': 0.0,
            'factorV': 0.0,
            'tuneX': 0.0,
            'tuneY': 0.0,
            'chromX': self._currChrom[0],
            'chromY': self._currChrom[1],
        }
        self._setupUi()
        self._setupMenu()
        self.verifySync()
Ejemplo n.º 4
0
def get_litbts_currinfo_database(acc):
    """Return LI, TB, TS, CurrentInfo Soft IOC database."""
    pref = acc + '-Glob:AP-CurrInfo:'
    pvs_db = {pref + 'Version-Cte': {'type': 'string', 'value': 'UNDEF'}}

    devices = {
        'LI': ('LI-01:DI-ICT-1:', 'LI-01:DI-ICT-2:'),
        'TB': ('TB-02:DI-ICT:', 'TB-04:DI-ICT:'),
        'TS': ('TS-01:DI-ICT:', 'TS-04:DI-ICT:')
    }
    def_db = {'type': 'float', 'value': 0.0, 'unit': 'nC', 'prec': 3}
    pvs = [
        'Charge-Mon', 'ChargeAvg-Mon', 'ChargeMin-Mon', 'ChargeMax-Mon',
        'ChargeStd-Mon'
    ]

    for device in devices[acc]:
        pvs_db.update({device + pv: _dcopy(def_db) for pv in pvs})
        pvs_db[device + 'PulseCount-Mon'] = {'type': 'int', 'value': 0}

    def_db = {'type': 'float', 'value': 0.0, 'unit': '%', 'prec': 3}
    pvs_db[pref + 'TranspEff-Mon'] = _dcopy(def_db)
    pvs_db[pref + 'TranspEffAvg-Mon'] = _dcopy(def_db)
    pvs_db = _csdev.add_pvslist_cte(pvs_db, prefix=pref)
    return pvs_db
Ejemplo n.º 5
0
    def __init__(self, parent=None, channels2values=dict(), color_list=None):
        """Init."""
        QLed.__init__(self, parent)
        PyDMWidget.__init__(self)
        self.stateColors = _dcopy(color_list) or self.default_colorlist
        self._connected = False

        self._operations_dict = {
            'eq': self._eq,
            'cl': self._cl,
            'ne': self._ne,
            'gt': self._gt,
            'lt': self._lt,
            'ge': self._ge,
            'le': self._le,
            'in': self._in,
            'wt': self._wt
        }

        self._address2values = dict()
        self._address2channel = dict()
        self._address2conn = dict()
        self._address2status = dict()
        self._address2currvals = dict()
        self.set_channels2values(_dcopy(channels2values))
Ejemplo n.º 6
0
def get_out_database(out_num=0, equip='EVR', prefix=None):
    """Return out_database."""
    def_prefix = 'OUT{0:d}'.format(out_num)
    prefix = def_prefix if prefix is None else prefix
    dbase = dict()

    dic_ = {'type': 'enum', 'value': 0, 'enums': _et.TRIG_SRC_LL}
    dbase[prefix + 'Src-Sts'] = dic_
    dbase[prefix + 'Src-Sel'] = _dcopy(dic_)

    dic_ = {'type': 'enum', 'value': 0, 'enums': _et.DLYTYP}
    dbase[prefix + 'RFDelayType-Sts'] = dic_
    dbase[prefix + 'RFDelayType-Sel'] = _dcopy(dic_)

    max_trig = 23 if equip == 'EVR' else 15
    num_trig = out_num + 12 if equip == 'EVR' else out_num
    dic_ = {
        'type': 'int',
        'value': num_trig,
        'unit': '',
        'lolo': 0,
        'low': 0,
        'lolim': 0,
        'hilim': max_trig,
        'high': max_trig,
        'hihi': max_trig
    }
    dbase[prefix + 'SrcTrig-SP'] = dic_
    dbase[prefix + 'SrcTrig-RB'] = _dcopy(dic_)

    dic_ = {
        'type': 'int',
        'value': 0,
        'unit': '',
        'lolo': 0,
        'low': 0,
        'lolim': 0,
        'hilim': 30,
        'high': 30,
        'hihi': 30
    }
    dbase[prefix + 'RFDelay-SP'] = dic_
    dbase[prefix + 'RFDelay-RB'] = _dcopy(dic_)

    dic_ = {
        'type': 'int',
        'value': 1,
        'unit': '',
        'lolo': 0,
        'low': 0,
        'lolim': 0,
        'hilim': 200,
        'high': 200,
        'hihi': 200
    }
    dbase[prefix + 'FineDelay-SP'] = dic_
    dbase[prefix + 'FineDelay-RB'] = _dcopy(dic_)

    return dbase
Ejemplo n.º 7
0
 def get_statistic_database(prefix=''):
     """Get the PV database of the STAT plugin."""
     acq_data_stat_db = {
         'type': 'float', 'value': 0.0, 'low': -1e12, 'high': 1e12}
     dbase = dict()
     dbase['_STATSMaxValue_RBV'] = _dcopy(acq_data_stat_db)
     dbase['_STATSMeanValue_RBV'] = _dcopy(acq_data_stat_db)
     dbase['_STATSMinValue_RBV'] = _dcopy(acq_data_stat_db)
     dbase['_STATSSigma_RBV'] = _dcopy(acq_data_stat_db)
     return {prefix + k: v for k, v in dbase.items()}
Ejemplo n.º 8
0
 def _receiveNewNormConfigs(self, norm_configs):
     old_norm_configs = _dcopy(
         self.config_parameters.mult_ramp.normalized_configs)
     self.ramp_config.ps_normalized_configs_set(norm_configs)
     self.loadSignal.emit(self.ramp_config)
     self._verifySync()
     new_norm_configs = _dcopy(
         self.config_parameters.mult_ramp.normalized_configs)
     self.config_parameters.mult_ramp.stackUndoMultipoleTableCommand(
         description='reconstruct normalized configs from waveforms',
         old=old_norm_configs, new=new_norm_configs)
Ejemplo n.º 9
0
 def set_psnames(self, psnames):
     """Set psnames."""
     self._psnames = _dcopy(psnames)
     if SiriusPVName(self._psnames[0]).dev in ('FCH', 'FCV'):
         self._propsymb_2_defval = _PVHandler.PROPSYMB_2_DEFVAL_FCS
     else:
         self._propsymb_2_defval = _PVHandler.PROPSYMB_2_DEFVAL_DEF
Ejemplo n.º 10
0
def shrink_descriptors(code, masterTableVersionNumber='latest', depth=99):
    """Shrink descriptor(s)

    :code: A single integer or list of integers
    :depth: Shrink depth
    :masterTableVersionNumber: WMO master table version Number
    :return: A list of shrinked descriptors
    """
    seq = get_sequence_def(masterTableVersionNumber)
    # WARNING: order of sequence by length is important!
    if not isinstance(code, list):
        code = [code]
    code = _dcopy(code)
    for _ in range(depth):
        shrink_element = {}
        for k, v in seq.items():
            j = list(_knuth_morris_pratt_(code, v))
            for i in j:
                shrink_element[i] = [k, len(v)]
        if len(shrink_element) == 0:
            break
        elements = [n for k, v in shrink_element.items()
                    for n in list(range(k + 1, k + v[1]))]
        for k, v in shrink_element.items():
            code[k] = v[0]
        shrinked = []
        for l, val in enumerate(code):
            if l not in elements:
                shrinked.append(val)
        code = shrinked
    return(code)
Ejemplo n.º 11
0
 def _do_acquire_spass_bg(self):
     """."""
     self.run_callbacks('SPassBgSts-Mon', self._csorb.SPassBgSts.Acquiring)
     self._spass_bgs = [dict() for _ in range(len(self.bpms))]
     ants = {'A': [], 'B': [], 'C': [], 'D': []}
     bgs = [_dcopy(ants) for _ in range(len(self.bpms))]
     # Acquire the samples
     for _ in range(self._smooth_npts):
         for i, bpm in enumerate(self.bpms):
             bgs[i]['A'].append(bpm.arraya)
             bgs[i]['B'].append(bpm.arrayb)
             bgs[i]['C'].append(bpm.arrayc)
             bgs[i]['D'].append(bpm.arrayd)
         _time.sleep(1 / self._acqrate)
     # Make the smoothing
     try:
         for i, bpm in enumerate(self.bpms):
             for k, val in bgs[i].items():
                 if self._smooth_meth == self._csorb.SmoothMeth.Average:
                     bgs[i][k] = _np.mean(val, axis=0)
                 else:
                     bgs[i][k] = _np.median(val, axis=0)
                 if not _np.all(_np.isfinite(bgs[i][k])):
                     raise ValueError('there was some nans or infs.')
         self._spass_bgs = bgs
         self.run_callbacks('SPassBgSts-Mon',
                            self._csorb.SPassBgSts.Acquired)
     except (ValueError, TypeError) as err:
         msg = 'ERR: SPassBg Acq ' + str(err)
         self._update_log(msg)
         _log.error(msg[5:])
         self.run_callbacks('SPassBgSts-Mon', self._csorb.SPassBgSts.Empty)
Ejemplo n.º 12
0
    def check_pwrsupplies_slowref(self, psnames):
        """Check power supplies OpMode."""
        if self._only_linac:
            return True
        psnames = {ps for ps in psnames if 'LI' not in ps}
        need_check = _dcopy(psnames)

        self._checks_result = dict()
        time = _time.time()
        while _time.time() - time < TIMEOUT_CHECK:
            for psname in psnames:
                if psname not in need_check:
                    continue
                cycler = self._get_cycler(psname)
                if cycler.check_opmode_slowref():
                    need_check.remove(psname)
                    self._checks_result[psname] = True
            if not need_check:
                break
            _time.sleep(TIMEOUT_SLEEP)
        for psname in need_check:
            self._checks_result[psname] = False

        status = True
        for psname in psnames:
            self._update_log('Checking ' + psname + ' OpMode...')
            if self._checks_result[psname]:
                self._update_log(done=True)
            else:
                self._update_log(psname + ' is not in SlowRef.', error=True)
                status &= False
        return status
Ejemplo n.º 13
0
    def check_pwrsupplies(self, ppty, psnames):
        """Check all power supplies according to mode."""
        need_check = _dcopy(psnames)

        self._checks_result = dict()
        time = _time.time()
        while _time.time() - time < 2 * TIMEOUT_CHECK:
            for psname in psnames:
                if psname not in need_check:
                    continue
                cycler = self._get_cycler(psname)
                if ppty == 'parameters':
                    ret = cycler.is_prepared(self.mode)
                elif ppty == 'opmode':
                    ret = cycler.check_opmode_cycle(self.mode)
                if ret:
                    need_check.remove(psname)
                    self._checks_result[psname] = True
            if not need_check:
                break
            _time.sleep(TIMEOUT_SLEEP)
        for psname in need_check:
            self._checks_result[psname] = False

        status = True
        for psname in psnames:
            self._update_log('Checking ' + psname + ' ' + ppty + '...')
            if self._checks_result[psname]:
                self._update_log(done=True)
            else:
                self._update_log(psname + ' is not ready.', error=True)
                status &= False
        return status
Ejemplo n.º 14
0
 def get_hl_trigger_predef_db(cls, hl_trigger):
     """Return the default database of the high level trigger."""
     cls._init()
     dic_ = _dcopy(cls._hl_triggers[hl_trigger]['database'])
     dic_['Src']['enums'] = ('Dsbl', ) + dic_['Src']['enums']
     dic_['Src']['value'] += 1
     return dic_
Ejemplo n.º 15
0
    def __init__(self, acc, prefix='', callback=None):
        """Initialize the instance."""
        super().__init__(acc, prefix=prefix, callback=callback)
        self.select_items = {
            'bpmx': _np.ones(self._csorb.nr_bpms, dtype=bool),
            'bpmy': _np.ones(self._csorb.nr_bpms, dtype=bool),
            'ch': _np.ones(self._csorb.nr_ch, dtype=bool),
            'cv': _np.ones(self._csorb.nr_cv, dtype=bool),
            }
        self.selection_pv_names = {
            'ch': 'CHEnblList-RB',
            'cv': 'CVEnblList-RB',
            'bpmx': 'BPMXEnblList-RB',
            'bpmy': 'BPMYEnblList-RB',
            }
        if self.acc == 'SI':
            self.select_items['rf'] = _np.zeros(1, dtype=bool)
            self.selection_pv_names['rf'] = 'RFEnbl-Sts'
        self.min_sing_val = self._csorb.MIN_SING_VAL
        self.tikhonov_reg_const = self._csorb.TIKHONOV_REG_CONST
        self.respmat = _np.zeros(
            [2*self._csorb.nr_bpms, self._csorb.nr_corrs], dtype=float)
        self.inv_respmat = self.respmat.copy().T

        self.ring_extension = 1
        self.respmat_extended = self.respmat.copy()
        self.select_items_extended = _dcopy(self.select_items)
        self._load_respmat()
Ejemplo n.º 16
0
def get_dict():
    """Return configuration type dictionary."""
    module_name = __name__.split('.')[-1]
    _dict = {
        'config_type_name': module_name,
        'value': _dcopy(_template_dict)
    }
    return _dict
Ejemplo n.º 17
0
 def _set_item(self, time, value):
     """Set configuration item."""
     str_time = '{:.3f}'.format(time)
     if value == self._value['ps_normalized_configs*'][str_time]:
         return
     self._value['ps_normalized_configs*'][str_time] = _dcopy(value)
     self.verify_synchronized()
     self._invalidate_ps_waveforms()
Ejemplo n.º 18
0
 def get_amplitudes_database(prefix=''):
     """."""
     data_db = {'type': 'float', 'value': 0.0, 'low': -1e12, 'high': 1e12}
     dbase = {
         'PosX-Mon': _dcopy(data_db), 'PosY-Mon': _dcopy(data_db),
         'Sum-Mon': _dcopy(data_db), 'PosQ-Mon': _dcopy(data_db),
         'AmplA-Mon': _dcopy(data_db), 'AmplB-Mon': _dcopy(data_db),
         'AmplC-Mon': _dcopy(data_db), 'AmplD-Mon': _dcopy(data_db),
         }
     return {prefix + k: v for k, v in dbase.items()}
Ejemplo n.º 19
0
 def get_gain_database(prefix=''):
     """."""
     data_db = {'type': 'float', 'value': 0.0, 'low': -1e12, 'high': 1e12}
     dbase = {
         'PosKq-SP': _dcopy(data_db), 'PosKq-RB': _dcopy(data_db),
         'PosKsum-SP': _dcopy(data_db), 'PosKsum-RB': _dcopy(data_db),
         'PosKx-SP': _dcopy(data_db), 'PosKx-RB': _dcopy(data_db),
         'PosKy-SP': _dcopy(data_db), 'PosKy-RB': _dcopy(data_db),
         }
     return {prefix + k: v for k, v in dbase.items()}
Ejemplo n.º 20
0
	def __parse_datatable(self, matrix_content, footer=False):
		theader = _ParagraphStyle("body")
		_setattribs(theader, [('alignment',_TA_CENTER),('fontName','Helvetica-Bold'),('fontSize',10),('textColor','white'),('wordWrap','RTL'),('splitLongWords',1)])
		tfooter = _dcopy(theader)
		_setattribs(tfooter, [('alignment',_TA_RIGHT),('wordWrap','RTL'),('textColor','black')])
		tbody = _ParagraphStyle("body")
		_setattribs(tbody, [('alignment',_TA_JUSTIFY),('fontName','Helvetica'),('fontSize',8),('wordWrap','RTL'),('splitLongWords',1)])
		parse_head = lambda text, ft_flag=False: _Paragraph(u"{}".format(text), theader) if not ft_flag else _Paragraph(u"{}".format(text), tfooter)
		parse_cell = lambda ctx, idx, jdx=-1: parse_head(ctx) if idx==0 else parse_head(ctx, True) if (idx==len(matrix_content)-1 and footer==True) else _Paragraph(ctx, tbody)
		return [[parse_cell(u"{}".format(cell), i, j) for j,cell in enumerate(row)] for i,row in enumerate(matrix_content)]
Ejemplo n.º 21
0
def get_dict():
    """Return a dict with ramp settings."""
    module_name = __name__.split('.')[-1]
    _dict = {
        'config_type_name': module_name,
        'value': _dcopy(_template_dict),
        'check': False,
    }

    return _dict
Ejemplo n.º 22
0
def get_clock_database(clock_num=0, prefix=None):
    """Return clock_database."""
    def_prefix = 'Clk{0:d}'.format(clock_num)
    prefix = def_prefix if prefix is None else prefix
    dbase = dict()

    dic_ = {
        'type': 'int',
        'value': 124948114,
        'lolo': 2,
        'low': 2,
        'lolim': 2,
        'hilim': 2**31 - 1,
        'high': 2**31 - 1,
        'hihi': 2**31 - 1
    }
    dbase[prefix + 'MuxDiv-SP'] = _dcopy(dic_)
    dbase[prefix + 'MuxDiv-RB'] = dic_
    dic_ = {'type': 'enum', 'enums': _et.DSBL_ENBL, 'value': 0}
    dbase[prefix + 'MuxEnbl-Sel'] = _dcopy(dic_)
    dbase[prefix + 'MuxEnbl-Sts'] = dic_
    return dbase
Ejemplo n.º 23
0
    def read_parameters(self, device_ids, parameter_id=None):
        """Return power supply parameters."""
        # process device_ids
        if isinstance(device_ids, int):
            dev_ids = (device_ids, )
        else:
            dev_ids = device_ids

        # builds dict of requested values
        values = dict()
        for dev_id in dev_ids:
            if parameter_id is None:
                values[dev_id] = self._psupplies[dev_id].parameters
            else:
                values[dev_id] = \
                    self._psupplies[dev_id].get_parameter(parameter_id)

        # make copy
        with self._lock:
            if isinstance(device_ids, int):
                return _dcopy(values[device_ids])
            return _dcopy(values)
Ejemplo n.º 24
0
def get_fout_database(prefix=None):
    """Return fout_database."""
    prefix = prefix or ''
    dbase = dict()

    dic_ = {'type': 'enum', 'value': 0, 'enums': _et.DSBL_ENBL}
    dbase[prefix + 'DevEnbl-Sts'] = dic_
    dbase[prefix + 'DevEnbl-Sel'] = _dcopy(dic_)

    dbase[prefix + 'Los-Mon'] = {
        'type': 'int',
        'value': 0,
        'unit': '',
        'lolo': 0,
        'low': 0,
        'lolim': 0,
        'hilim': 255,
        'high': 255,
        'hihi': 255
    }

    dbase[prefix + 'Alive-Mon'] = {
        'type': 'int',
        'value': 0,
        'unit': '',
        'lolo': 0,
        'low': 0,
        'lolim': 0,
        'hilim': 2**31 - 1,
        'high': 2**31 - 1,
        'hihi': 2**31 - 1
    }

    dbase[prefix + 'Network-Mon'] = {
        'type': 'enum',
        'value': 1,
        'enums': _et.DISCONN_CONN
    }

    dbase[prefix + 'Link-Mon'] = {
        'type': 'enum',
        'value': 1,
        'enums': _et.UNLINK_LINK
    }

    dbase[prefix + 'Intlk-Mon'] = {
        'type': 'enum',
        'value': 0,
        'enums': _et.DSBL_ENBL
    }
    return dbase
Ejemplo n.º 25
0
    def __init__(self, ethbridgeclnt_class, bbbnames=None, mproc=None):
        """."""
        # check arguments
        if mproc is not None and \
                (not isinstance(mproc, dict) or
                 set(mproc.keys()) != {'rbref', 'ref', 'fret'}):
            raise ValueError('Invalid mproc dictionary!')

        self._acc = 'SI'
        self._pru = None
        self._udc = None
        self.bbbnames = bbbnames or _dcopy(PSSOFB.BBBNAMES)
        self.bbb2devs = dict()

        self._sofb_psnames = \
            PSNamesSOFB.get_psnames_ch(self._acc) + \
            PSNamesSOFB.get_psnames_cv(self._acc)

        # snapshot of sofb current values
        ncorrs = len(self._sofb_psnames)
        arr = _np.zeros(ncorrs, dtype=float)
        self._sofb_current_rb = arr.copy()
        self._sofb_current_mon = arr.copy()

        if mproc:
            self._sofb_current_readback_ref = mproc['rbref']
            self._sofb_current_refmon = mproc['ref']
            self._sofb_func_return = mproc['fret']
        else:
            self._sofb_current_readback_ref = arr.copy()
            self._sofb_current_refmon = arr.copy()
            self._sofb_func_return = _np.zeros(ncorrs, dtype=int)

        # create sofb and bsmp indices
        self.indcs_bsmp, self.indcs_sofb = self._create_indices()

        # initialize connector objects for bsmp communications.
        self._pru, self._udc = self._init_connectors(ethbridgeclnt_class)

        # dictionaries with comm. ack, state snapshot of all correctors
        # states and threads
        self._dev_ack, self._dev_state, self._threads = \
            self._init_threads_dev_state()

        # power supply status objects
        self._pscstatus = [_PSCStatus() for _ in self._sofb_psnames]

        # strength to current converters
        self._strengths_dipole = 3.0  # [GeV]
        if mproc is None:
            self.converter = UnitConverter(self._sofb_psnames)
Ejemplo n.º 26
0
 def send_value(self):
     """
     Method invoked to send the current value on the QDoubleSpinBox to
     the channel using the `send_value_signal`.
     """
     value = QDoubleSpinBox.value(self)
     val = _dcopy(self.value)
     if isinstance(val, _np.ndarray):
         val[self._index] = value
         if not self.valueBeingSet:
             self.send_value_signal[_np.ndarray].emit(val)
     else:
         if not self.valueBeingSet:
             self.send_value_signal[float].emit(value)
Ejemplo n.º 27
0
    def read_variables(self, device_ids, variable_id=None):
        """
        Return device variables.

        Parameters
        ----------
        device_ids : int, tuple or list
            The BSMP device ids.
        variable_id : int or None, optional.
            The BSMP variable id selected. If not passed all device variables
            will be returned.

        Returns
        -------
        Selected BSMP device variable values.

        """
        # process device_ids
        if isinstance(device_ids, int):
            dev_ids = (device_ids, )
        else:
            dev_ids = device_ids

        # builds dict of requested values
        values = dict()
        for dev_id in dev_ids:
            if variable_id is None:
                values[dev_id] = self._psupplies[dev_id].variables
            else:
                values[dev_id] = \
                    self._psupplies[dev_id].get_variable(variable_id)

        # make copy
        with self._lock:
            if isinstance(device_ids, int):
                return _dcopy(values[device_ids])
            return _dcopy(values)
Ejemplo n.º 28
0
 def get_offsets_database(prefix=''):
     """."""
     data_db = {'type': 'float', 'value': 0.0, 'low': -1e12, 'high': 1e12}
     dbase = {
         'PosQOffset-SP': _dcopy(data_db), 'PosQOffset-RB': _dcopy(data_db),
         'PosXOffset-SP': _dcopy(data_db), 'PosXOffset-RB': _dcopy(data_db),
         'PosYOffset-SP': _dcopy(data_db), 'PosYOffset-RB': _dcopy(data_db),
         }
     return {prefix + k: v for k, v in dbase.items()}
Ejemplo n.º 29
0
def get_afc_out_database(out_num=0, out_tp='FMC', prefix=None):
    """Return afc_database."""
    def_prefix = (out_tp + '{0:d}'.format(out_num))
    if out_tp == 'FMC':
        fmc = (out_num // 5) + 1
        ch = (out_num % 5) + 1
        def_prefix = (out_tp + '{0:d}CH{1:d}'.format(fmc, ch))

    prefix = def_prefix if prefix is None else prefix
    dbase = get_otp_database(prefix=prefix)
    dic_ = {'type': 'enum', 'value': 0, 'enums': _et.TRIG_SRC_LL}
    dbase[prefix + 'Src-Sts'] = dic_
    dbase[prefix + 'Src-Sel'] = _dcopy(dic_)

    return dbase
Ejemplo n.º 30
0
 def get_orbit_database(self, prefix=''):
     """Return Orbit database."""
     nbpm = self.nr_bpms
     pvs_ring = ['SlowOrbX-Mon', 'SlowOrbY-Mon']
     db_ring = dict()
     prop = {
         'type': 'float',
         'unit': 'um',
         'count': self.MAX_RINGSZ * nbpm,
         'value': nbpm * [0]
     }
     for k in pvs_ring:
         db_ring[k] = _dcopy(prop)
     dbase = super().get_orbit_database(prefix=prefix)
     dbase.update(self._add_prefix(db_ring, prefix))
     return dbase
Ejemplo n.º 31
0
 def get_fft_database(prefix=''):
     """Get the PV database of the FFT plugin."""
     data_db = {
         'type': 'float', 'value': _np.array(100000*[0.0]), 'count': 100000}
     acq_int_db = {'type': 'int', 'value': 1, 'low': 0, 'high': 100000}
     dbase = dict()
     dbase['FFTFreq-Mon'] = _dcopy(data_db)
     dbase['FFTData.SPAN'] = _dcopy(acq_int_db)
     dbase['FFTData.AMP'] = _dcopy(data_db)
     dbase['FFTData.PHA'] = _dcopy(data_db)
     dbase['FFTData.SIN'] = _dcopy(data_db)
     dbase['FFTData.COS'] = _dcopy(data_db)
     dbase['FFTData.WAVN'] = _dcopy(data_db)
     dbase['FFTData.INDX'] = _dcopy(acq_int_db)
     dbase['FFTData.MXIX'] = _dcopy(acq_int_db)
     dbase['FFTData.WIND'] = {
         'type': 'enum', 'enums': Const.FFTWindowTyp._fields, 'value': 0}
     dbase['FFTData.CDIR'] = {
         'type': 'enum', 'enums': Const.FFTConvDirection._fields,
         'value': 0}
     dbase['FFTData.ASUB'] = {
         'type': 'enum', 'enums': Const.FFTAvgSubtract._fields, 'value': 0}
     return {prefix + k: v for k, v in dbase.items()}