def _select_experimental_setup(self): pref = self._prefix if self._place.lower().startswith('li-ene'): prof = pref + ('-' if pref else '') + 'LA-BI:PRF4' self.conv_coefx = PV(prof + ':X:Gauss:Coef') self.conv_coefy = PV(prof + ':Y:Gauss:Coef') self.image_channel = prof + ':RAW:ArrayData' self.width_channel = prof + ':ROI:MaxSizeX_RBV' self.trig_name = 'LI-Fam:TI-Scrn' elif self._place.lower().startswith('li-emit'): prof = pref + ('-' if pref else '') + 'LA-BI:PRF5' self.conv_coefx = PV(prof + ':X:Gauss:Coef') self.conv_coefy = PV(prof + ':Y:Gauss:Coef') self.image_channel = prof + ':RAW:ArrayData' self.width_channel = prof + ':ROI:MaxSizeX_RBV' self.trig_name = 'LI-Fam:TI-Scrn' elif self._place.lower().startswith('tb-emit'): prof = _PVName('TB-02:DI-ScrnCam-2').substitute(prefix=pref) self.conv_coefx = PV(prof.substitute(propty='ImgScaleFactorX-RB')) self.conv_coefy = PV(prof.substitute(propty='ImgScaleFactorY-RB')) prof = _PVName('TB-02:DI-Scrn-2').substitute(prefix=pref) self.image_channel = prof.substitute(propty='ImgData-Mon') self.width_channel = prof.substitute(propty='ImgROIWidth-RB') self.trig_name = 'TB-Fam:TI-Scrn' else: raise Exception('Wrong value for "place".')
def __init__(self, acc, opticsparam, parent=None, prefix=_VACA_PREFIX): """Initialize some widgets.""" super(OpticsCorrWindow, self).__init__(parent) self.prefix = prefix self.acc = acc.upper() self.param = opticsparam self.ioc_prefix = _PVName( self.acc+'-Glob:AP-'+self.param.title()+'Corr') self.ioc_prefix = self.ioc_prefix.substitute(prefix=self.prefix) self.title = self.acc + ' ' + self.param.title() + ' Correction' if self.param == 'tune': self.param_pv = 'DeltaTune{0}-{1}' self.intstrength = 'KL' self.intstrength_calcdesc = 'DeltaKL-Mon' self.intstrength_calcpv = 'DeltaKL{}-Mon' self.fams = list(_Const.SI_QFAMS_TUNECORR) if self.acc == 'SI' \ else list(_Const.BO_QFAMS_TUNECORR) elif self.param == 'chrom': self.param_pv = 'Chrom{0}-{1}' self.intstrength = 'SL' self.intstrength_calcdesc = 'CalcSL-Mon' self.intstrength_calcpv = 'SL{}-Mon' self.fams = list(_Const.SI_SFAMS_CHROMCORR) if self.acc == 'SI' \ else list(_Const.BO_SFAMS_CHROMCORR) self.setWindowTitle(self.title) self.setObjectName(self.acc+'App') self._setupUi() self.setFocus(True) self.setFocusPolicy(Qt.StrongFocus)
def __init__(self, parent, device, orbits, idx, prefix='', acc='SI'): """Initialize the Context Menu.""" super(OrbitRegister, self).__init__(parent) self.idx = idx self.prefix = prefix self.device = _PVName(device) self.devpref = self.device.substitute(prefix=prefix) text = acc.lower() + 'orb' self.setObjectName(text + str(idx)) self.EXT = (f'.{acc.lower()}orb', f'.{acc.lower()}dorb') self.EXT_FLT = f'Sirius Orbit Files (*.{text});;' +\ f'Sirius Delta Orbit Files (*.{acc.lower()}dorb)' self._config_type = acc.lower() + '_orbit' self._client = ConfigDBClient(config_type=self._config_type) self._csorb = SOFBFactory.create(acc.upper()) self.string_status = 'Empty' self.name = 'Register {0:d}'.format(self.idx) self.setup_ui() self._orbits = orbits self.last_dir = self.DEFAULT_DIR self.filename = '' self._orbx = _np.zeros(self._csorb.nr_bpms) self._orby = _np.zeros(self._csorb.nr_bpms) self.new_string_signal.emit(self.string_status)
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
def __init__(self, parent=None, pslist=[], name='', delta=0.0, idxini=0, idxfin=4000, legend=False): super().__init__(parent) self._pvslist = pslist self.name = name self._legend = legend self._idx_ini = idxini self._idx_fin = idxfin self._delta = delta self.curves = [] self.setupui() self.setFocus(True) self.setFocusPolicy(Qt.StrongFocus) self.chans = [ _ConnSig( _PVName(ps).substitute(prefix=_VACA_PREFIX, propty='Wfm-Mon')) for ps in pslist ] for idx, chan in enumerate(self.chans): chan.new_value_signal[_np.ndarray].connect( _part(self._update_curve, idx))
def __init__(self, parent=None, prefix=''): """Init.""" self.dev_type = 'Slits' if 'Slit' in self.DEVICE_PREFIX else 'Scrapers' self.sec = _PVName(self.DEVICE_PREFIX).sec super(DiffCtrlView, self).__init__(parent) self.setObjectName(self.sec + 'App') gbox_h = QGroupBox(self.DEVICE_PREFIX + 'H') self.dev_h = self.DEVICE_CLASS(self, prefix, self.DEVICE_PREFIX + 'H') lay_h = QVBoxLayout() lay_h.addWidget(self.dev_h) gbox_h.setLayout(lay_h) gbox_v = QGroupBox(self.DEVICE_PREFIX + 'V') self.dev_v = self.DEVICE_CLASS(self, prefix, self.DEVICE_PREFIX + 'V') lay_v = QVBoxLayout() lay_v.addWidget(self.dev_v) gbox_v.setLayout(lay_v) lay = QVBoxLayout() lay.setSpacing(20) lay.addWidget( QLabel('<h3>' + self.sec + ' ' + ('Slits' if 'Slit' in self.DEVICE_PREFIX else 'Scrapers') + ' View</h3>', alignment=Qt.AlignCenter)) lay.addWidget(gbox_h) lay.addWidget(gbox_v) self.setLayout(lay)
def __init__(self, parent=None, prefix=''): """Init.""" super().__init__(parent) pvname = _PVName('AS-Glob:AP-MachShift:Mode-Sts') pvname = pvname.substitute(prefix=prefix) self.label = SiriusLabel(self, pvname) self.label.setAlignment(Qt.AlignCenter) color_list = [ SiriusFrame.Yellow, # Users SiriusFrame.MediumBlue, # Commissioning SiriusFrame.DarkCyan, # Conditioning SiriusFrame.LightSalmon, # Injection SiriusFrame.LightBlue, # MachineStudy SiriusFrame.MediumGreen, # Maintenance SiriusFrame.LightGray, # Standby SiriusFrame.DarkGray, # Shutdown ] self.frame = SiriusFrame(self, pvname, color_list=color_list, is_float=False) self.frame.add_widget(self.label) lay = QGridLayout(self) lay.setContentsMargins(0, 0, 0, 0) lay.addWidget(self.frame)
def __init__(self, parent=None, prefix='', device=''): """Initialize.""" super().__init__(parent) self.prefix = prefix self.device = _PVName(device) self.dcct_prefix = device.substitute(prefix=self.prefix) self._setupUi()
def _init(cls): """Initialize the Instance.""" with cls._lock: if cls._hl_triggers: return if not _web.server_online(): raise Exception('Could not connect with Consts Server!!') text1 = _web.high_level_triggers(timeout=_timeout) text2 = _web.high_level_events(timeout=_timeout) temp_dict = _ast.literal_eval(text1) hl_trigs = dict() for k, vs in temp_dict.items(): vs['channels'] = tuple(map(_PVName, vs['channels'])) hl_trigs[_PVName(k)] = vs cls._hl_triggers = hl_trigs cls._hl_events = _ast.literal_eval(text2) hl2ll = dict() for hlt, val in cls._hl_triggers.items(): chans = val['channels'] hl2ll[hlt] = {_LLSearch.get_trigger_name(c) for c in chans} ll2hl = dict() for k, vs in hl2ll.items(): ll2hl.update({v: k for v in vs}) cls._hl2ll_trigs = hl2ll cls._ll2hl_trigs = ll2hl
def __init__(self, parent, device, prefix=''): """.""" super().__init__(parent) self.prefix = prefix self.device = _PVName(device) self.setObjectName(self.device.sec+'App') self._setupui()
def check_hl_triggers_consistency(cls): """Check consitency of Triggers definition. Check if High Level definition of Triggers is consistent with Low Level connections of the timing devices. """ cls._init() twds_evg = _LLSearch.get_connections_twds_evg() from_evg = _LLSearch.get_connections_from_evg() for trig, val in cls._hl_triggers.items(): chans = {_PVName(chan) for chan in val['channels']} for chan in chans: tmp = twds_evg.get(chan) if tmp is None: raise Exception( chan + ' is used in HL trigger ' + trig + ' but not specified in timing connections data.') if not tmp: raise Exception(chan + ' which is used in HL trigger ' + trig + ' maybe were already used somewhere else.') up_dev = tmp.pop() diff_devs = from_evg[up_dev] - chans if diff_devs and not chan.dev.endswith('BPM'): raise Exception( 'Devices: ' + ' '.join(diff_devs) + ' are connected to the same output of ' + up_dev + ' as ' + chan + ' but are not related to the same trigger (' + trig + ').')
def _get_newitem_data(self, updated): pv, value = updated pv = _PVName(pv) if isinstance(value, _np.ndarray): _log.warning('PSDiag window received a numpy array to ' + pv+' ('+str(value)+')!') return if value is None: return if 'conn' in self.sender().objectName(): str_value = 'disconnected' logtype = 'DISCONN' elif pv.propty_name == 'PwrState': str_value = _PSEnums.PWRSTATE_STS[value] logtype = 'ERR' elif pv.propty_name == 'OpMode': str_value = _PSEnums.STATES[value] logtype = 'WARN' else: str_value = str(value) logtype = 'ERR' return {'logtype': logtype, 'psname': pv.device_name, 'propty': '' if logtype == 'DISCONN' else pv.propty_name, 'value': str_value}
def _build_mapping(cls, text): mapping = dict() lines = text.splitlines() for line in lines: line = line.strip() if not line or line[0] == '#': continue # empty line key, pos, timing, *_ = line.split() key = _PVName(key) timing = _PVName(timing) if key in mapping.keys(): raise Exception('BPM {0:s} double entry.'.format(key)) else: mapping[key] = {'position': float(pos), 'timing': timing} cls._mapping = mapping cls._names = sorted(cls._mapping.keys())
def __init__(self, channel, prefix): """Initialize the Low Level object. callback is the callable to be called each time a low level PV changes its value. """ super().__init__() self.channel = _PVName(channel) self.prefix = prefix self._dict_functs_for_write = self._define_dict_for_write() self._dict_functs_for_update = self._define_dict_for_update() self._dict_functs_for_read = self._define_dict_for_read() self._dict_convert_prop2pv = self._define_convertion_prop2pv() self._dict_convert_pv2prop = { val: key for key, val in self._dict_convert_prop2pv.items() } self._config_ok_values = dict() self._base_freq = _RFFREQ / _RFDIV self._writepvs = dict() self._readpvs = dict() self._locked = False evg_name = _LLTimeSearch.get_evg_name() self._base_freq_pv = _PV(LL_PREFIX + evg_name + ':FPGAClk-Cte') self._update_base_freq() self._base_freq_pv.add_callback(self._update_base_freq) _log.info(self.channel + ': Creating PVs.') for prop, pvname in self._dict_convert_prop2pv.items(): pvnamerb = pvnamesp = None if not _PVName.is_write_pv(pvname): pvnamerb = pvname pvnamesp = _PVName.from_rb2sp(pvname) elif _PVName.is_cmd_pv(pvname): # -Cmd is different!! self._writepvs[prop] = _PV(pvname) if pvnamerb is not None: self._readpvs[prop] = _PV(pvnamerb) if pvnamesp != pvnamerb and not prop.endswith('DevEnbl'): self._writepvs[prop] = _PV(pvnamesp) self._writepvs[prop]._initialized = False for prop, pv in self._writepvs.items(): if not pv.wait_for_connection(): _log.info(pv.pvname + ' not connected.') for prop, pv in self._readpvs.items(): if not pv.wait_for_connection(): _log.info(pv.pvname + ' not connected.') for prop, pv in self._writepvs.items(): if _PVName.is_cmd_pv(pv.pvname): continue pv.add_callback(self._on_change_writepv) pv.connection_callbacks.append(self._on_connection_writepv) for prop, pv in self._readpvs.items(): pv.add_callback(self._on_change_readpv) pv.connection_callbacks.append(self._on_connection)
def __init__(self, parent=None, prefix='', bpm='', data_prefix=''): super().__init__(parent) self.prefix = prefix self.bpm = _PVName(bpm) self.setObjectName(self.bpm.sec+'App') self.data_prefix = data_prefix self.bpmdb = _BPMDB self._chans = []
def __init__(self, parent=None, prefix='', tl=None): """Class construc.""" super(PosAngCorr, self).__init__(parent) if not prefix: self._prefix = _VACA_PREFIX else: self._prefix = prefix self._tl = tl.upper() base_name = _PVName('TL-Glob:AP-PosAng') self.posang_prefix = base_name.substitute( prefix=self._prefix, sec=self._tl) self.setObjectName(self._tl+'App') self.setWindowTitle(self._tl + ' Position and Angle Correction Window') if self._tl == 'TS': self._is_chsept = False ch3_pv = _PV(self.posang_prefix.substitute(propty='CH3-Cte'), connection_timeout=1) if not ch3_pv.wait_for_connection(): self._is_chsept = True if tl == 'ts': corr_h = (Const.TS_CORRH_POSANG_CHSEPT if self._is_chsept else Const.TS_CORRH_POSANG_SEPTSEPT) corr_v = Const.TS_CORRV_POSANG elif tl == 'tb': corr_h = Const.TB_CORRH_POSANG corr_v = Const.TB_CORRV_POSANG self.corrs = dict() self.corrs['CH1'] = _PVName(corr_h[0]) self.corrs['CH2'] = _PVName(corr_h[1]) if len(corr_h) == 3: self.corrs['CH3'] = _PVName(corr_h[2]) self.corrs['CV1'] = _PVName(corr_v[0]) self.corrs['CV2'] = _PVName(corr_v[1]) if len(corr_v) == 4: self.corrs['CV3'] = _PVName(corr_v[2]) self.corrs['CV4'] = _PVName(corr_v[3]) self._just_need_update = False self._update_ref_action = False self._my_input_widgets = list() self._setupUi() self.setFocus(True) self.setFocusPolicy(Qt.StrongFocus) self._ask_message = QMessageBox(self) self._ask_message.setWindowTitle('Message') self._ask_message.setText( 'The '+self._tl+' PosAng IOC indicates reference needs to ' 'be updated! Do you want to update the reference?') self._ask_message.setStandardButtons(QMessageBox.No | QMessageBox.Yes) self._ask_message.setDefaultButton(QMessageBox.No) self.app = QApplication.instance() self.app.focusChanged.connect(self._spinbox_onfocus)
def __init__(self, parent=None, prefix=_vaca_prefix, device=''): """Init.""" super().__init__(parent) self._prefix = prefix self._device = _PVName(device) self._beamline = IDSearch.conv_idname_2_beamline(self._device) self.dev_pref = self._device.substitute(prefix=prefix) self._setupUi()
def __init__(self, parent=None, prefix=_vaca_prefix, device=''): """Init.""" super().__init__(parent) set_bbb_color(self, device) self._prefix = prefix self._device = _PVName(device) self.dev_pref = self._device.substitute(prefix=prefix) self._setupUi()
def __init__(self, parent=None, prefix='', device=''): super().__init__(parent) self._prefix = prefix self._device = _PVName(device) self.dev_pref = self._device.substitute(prefix=prefix) self.setObjectName('IDApp') self.setWindowTitle(device + ' Interlock Details') self._setupUi()
def _build_colors(cls): if 'matplotlib' not in _sys.modules: print('Cannot draw network: matplotlib is not installed') return dev_types = set() for dev in cls._all_devices: dev_types.add(_PVName(dev).dev) nr = len(dev_types)+2 color_types = dict() for i, dev_type in enumerate(sorted(dev_types), 1): color_types[dev_type] = _cmap.spectral(i/nr) colors = dict() for dev in cls._all_devices: colors[dev] = color_types[_PVName(dev).dev] cls._colors = colors
def __init__(self, parent, device, prefix=''): super().__init__(parent) self.prefix = prefix self.device = _PVName(device) self.devpref = self.device.substitute(prefix=prefix) self.setObjectName(self.device.sec + 'App') self._chan = _ConnSig( self.devpref.substitute(propty='NrSingValues-Mon')) self.setupui()
def __init__(self, parent, device, csorb, prefix=''): """.""" super().__init__(parent) self.prefix = prefix self.device = _PVName(device) self.devpref = self.device.substitute(prefix=prefix) self.setObjectName(csorb.acc + 'App') self._csorb = csorb self.setupui()
def _setupFamiliesLayout(self): lay = QGridLayout() lb_family = QLabel('<h4>Family</h4>', self, alignment=Qt.AlignCenter) lb_family.setStyleSheet('max-height:1.29em;') lay.addWidget(lb_family, 0, 1) lb_rbdesc = QLabel('<h4>'+self.intstrength+'-RB</h4>', self, alignment=Qt.AlignCenter) lb_rbdesc.setStyleSheet('max-height:1.29em;') lay.addWidget(lb_rbdesc, 0, 2) if self.param == 'tune': lb_refdesc = QLabel('<h4>RefKL-Mon</h4>', self, alignment=Qt.AlignCenter) lb_refdesc.setStyleSheet('max-height:1.29em;') lay.addWidget(lb_refdesc, 0, 3) lb_lastddesc = QLabel('<h4>'+self.intstrength_calcdesc+'</h4>', self, alignment=Qt.AlignCenter) lb_lastddesc.setStyleSheet('max-height:1.29em;') lay.addWidget(lb_lastddesc, 0, 4) row = 1 for fam in self.fams: dev_name = _PVName(self.acc+'-Fam:PS-'+fam) pref_name = dev_name.substitute(prefix=self.prefix) pbt = QPushButton(qta.icon('fa5s.list-ul'), '', self) pbt.setObjectName('pbt') pbt.setStyleSheet(""" #pbt{ min-width:25px; max-width:25px; min-height:25px; max-height:25px; icon-size:20px;}""") _hlautil.connect_window( pbt, _PSDetailWindow, parent=self, psname=dev_name) lay.addWidget(pbt, row, 0) lb_name = QLabel(fam, self, alignment=Qt.AlignCenter) lay.addWidget(lb_name, row, 1) lb_rb = PyDMLabel(self, pref_name.substitute( propty=self.intstrength+'-RB')) lay.addWidget(lb_rb, row, 2) if self.param == 'tune': lb_ref = PyDMLabel(self, self.ioc_prefix.substitute( propty='RefKL'+fam+'-Mon')) lay.addWidget(lb_ref, row, 3) lb_calc = PyDMLabel(self, self.ioc_prefix.substitute( propty=self.intstrength_calcpv.format(fam))) lay.addWidget(lb_calc, row, 4) row += 1 return lay
def __init__(self, parent, device, ctrls, names, is_orb, prefix='', acc='SI'): """.""" super(BaseWidget, self).__init__(parent) self.setObjectName(acc.upper() + 'App') self.EXT = f'.{acc.lower()}dorb' self.EXT_FLT = f'Sirius Delta Orbit Files (*.{acc.lower()}dorb)' self.line_names = names self.prefix = prefix self.device = _PVName(device) self.devpref = self.device.substitute(prefix=prefix) self.controls = ctrls self._csorb = SOFBFactory.create(acc) self.update_rate = 2.1 # Hz self.last_dir = self.DEFAULT_DIR self.is_orb = is_orb self.timer = QTimer() self.thread = QThread() self.updater = [] self.graph = {'x': None, 'y': None} for _ in range(2): upd = UpdateGraph(ctrls, is_orb, acc) upd.moveToThread(self.thread) self.timer.timeout.connect(upd.update_graphic) self.updater.append(upd) self.setupui() self.connect_signals() prefx, prefy = ('BPMX', 'BPMY') if self.is_orb else ('CH', 'CV') self.enbl_pvs = { 'x': _ConnSig(self.devpref.substitute(propty=prefx + 'EnblList-RB')), 'y': _ConnSig(self.devpref.substitute(propty=prefy + 'EnblList-RB')) } for pln, signal in self.enbl_pvs.items(): sig = signal.new_value_signal[_np.ndarray] for upd in self.updater: sig.connect(_part(upd.set_enbl_list, pln)) self.enbl_pvs_set = { 'x': _ConnSig(self.devpref.substitute(propty=prefx + 'EnblList-SP')), 'y': _ConnSig(self.devpref.substitute(propty=prefy + 'EnblList-SP')) } self.thread.start() self.timer.start(1000 / self.update_rate)
def function(self): """Set PS PwrState.""" self._set(method='set_pwrstate', state=self._state) # NOTE: in turn regatrons off, wait for related PS to update readings regatrons_idcs = ['1A', '1B', '2A', '2B', '3A', '3B', '4A', '4B'] if self._state == 'off': if any( [_PVName(dev).idx in regatrons_idcs for dev in self._devices]): _time.sleep(15)
def __init__(self, parent=None, prefix=_vaca_prefix, device='', resume=False): """Init.""" super().__init__(parent) self.setObjectName('SIApp') self._prefix = prefix self._device = _PVName(device) self.dev_pref = self._device.substitute(prefix=prefix) self._is_resumed = resume self._setupUi()
def __init__(self, parent=None, prefix=_vaca_prefix, device=''): """.""" super().__init__(parent) self.prefix = prefix self.device = _PVName(device) self.dev_pref = self.device.substitute(prefix=prefix) self.setWindowTitle(device+' Control Window') self.setObjectName('SIApp') self.setWindowIcon(get_bbb_icon()) self._setupUi()
def __init__(self, parent=None, prefix=VACA_PREFIX, section=''): """Init.""" super().__init__(parent) self.prefix = prefix self.section = section.upper() self.device = _PVName(conv_sec_2_device(self.section)) self.cam_prefix = self.device.substitute(prefix=prefix) self.setObjectName(self.section + 'App') self.setWindowTitle(self.device + ' View') self._setupUi()
def mouseDoubleClickEvent(self, ev): """Trigger open PS detail window.""" idx = self.selectedIndexes() text = self._model.data(self._model.index(idx[0].row(), 3)) text = _PVName(text) if text.dis == 'PS': _run_newprocess(['sirius-hla-as-ps-detail.py', text]) elif text.dis == 'PU': _run_newprocess(['sirius-hla-as-pu-detail.py', text]) super().mouseDoubleClickEvent(ev)
def __init__(self, parent, device, ctrls, prefix='', acc='SI'): """.""" setpoint = dict() readback = dict() basename = _PVName(device).substitute(prefix=prefix) setpoint['x'] = _ConnSig(basename.substitute(propty='OfflineOrbX-SP')) setpoint['y'] = _ConnSig(basename.substitute(propty='OfflineOrbY-SP')) readback['x'] = _ConnSig(basename.substitute(propty='OfflineOrbX-RB')) readback['y'] = _ConnSig(basename.substitute(propty='OfflineOrbY-RB')) super().__init__(parent, ctrls, setpoint, readback, acc)