Skip to content

Commit

Permalink
Merge pull request #1080 from lnls-sirius/fix-orbintlk
Browse files Browse the repository at this point in the history
Fix bugs in OrbIntlk IOC
  • Loading branch information
anacso17 authored May 3, 2024
2 parents 9659274 + ac35904 commit bc2235e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.87.0
2.87.1
31 changes: 17 additions & 14 deletions siriuspy/siriuspy/orbintlk/csdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class Const(_csdev.Const):
('Src-Sel', 0),
('State-Sel', 1),
('Polarity-Sel', 0),
('Log-Sel', 0))),
('Log-Sel', 1))),
('SI-14C4:TI-DCCT-PsMtm', (
('Src-Sel', 0),
('State-Sel', 1),
('Polarity-Sel', 0),
('Log-Sel', 0))),
('Log-Sel', 1))),
]
FOUTSFIXED_RXENBL = {
'CA-RaTim:TI-Fout-2': 0b01000001,
Expand Down Expand Up @@ -139,23 +139,25 @@ def EVG_CONFIGS(cls):
if cls.__EVG_CONFIGS is not None:
return cls.__EVG_CONFIGS

hltg_enbl = [
'SI-Fam:TI-BPM-OrbIntlk',
'SI-Fam:TI-OrbIntlkRedundancy',
]
lltg_enbl = []
for hltg in hltg_enbl:
lltg_enbl.extend(_HLTimeSearch.get_ll_trigger_names(hltg))
lltg_enbl = set(lltg_enbl)

fouts = set()
evgchans = set()
evgrxenbl = list()
for ch in _LLTimeSearch.get_connections_twds_evg():
if ch.dev != 'BPM':
continue
if ch.sec != 'SI':
continue
if ch.dev == 'BPM' and ch.sub.endswith(('SA', 'SB', 'SP')):
continue
fch = _LLTimeSearch.get_fout_channel(ch)
evgrxenbl = set()
for lltg in lltg_enbl:
fch = _LLTimeSearch.get_fout_channel(lltg)
fouts.add(fch.device_name)
evgch = _LLTimeSearch.get_evg_channel(fch)
if evgch in evgchans:
continue
evgchans.add(evgch)
evgrxenbl.append(int(evgch.propty[3:]))
evgrxenbl.add(int(evgch.propty[3:]))
evgrxenbl = sorted(evgrxenbl)

hlevts = _HLTimeSearch.get_hl_events()
evtin0 = int(hlevts['Intlk'].strip('Evt'))
Expand Down Expand Up @@ -213,6 +215,7 @@ def __init__(self):
if NR_BPM != len(self.bpm_names):
raise ValueError('Inconsistent NR_BPM parameter!')
self.bpm_nicknames = _BPMSearch.get_nicknames(self.bpm_names)
self.bpm_idcs = {b: idx for idx, b in enumerate(self.bpm_names)}

# bpm position along the ring
self.bpm_pos = _BPMSearch.get_positions(self.bpm_names)
Expand Down
18 changes: 15 additions & 3 deletions siriuspy/siriuspy/orbintlk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ def __init__(self, tests=False):
pvo.add_callback(self._callback_evg_rxlock)

# # Fouts
foutnames = list(self._const.FOUTS_2_MON) + \
list(self._const.FOUTSFIXED_RXENBL.keys())
foutnames = list(
self._const.FOUTS_2_MON |
self._const.FOUTSFIXED_RXENBL.keys()
)
self._thread_cbfout = {fout: None for fout in foutnames}
self._fout_devs = {
devname: _Device(
Expand Down Expand Up @@ -1358,13 +1360,23 @@ def _callback_bpm_intlk(self, pvname, value, **kws):
if not value:
return
# launch thread to log interlock details
bpmname = _PVName(pvname).device_name
_CAThread(
target=self._log_bpm_intlk,
args=(_PVName(pvname).device_name, ),
args=(bpmname, ),
daemon=True).start()
# launch thread to send interlock to RF as a backup
if self._thread_cbbpm and self._thread_cbbpm.is_alive():
return

# NOTE: the next lines help to avoid killing beam in case one BPM that
# is not enabled raises a false positive interlock signal.
idx = self._const.bpm_idcs[bpmname]
enbl = self._enable_lists['pos'][idx] or self._enable_lists['ang'][idx]
if not enbl:
self._update_log(f'WARN:{bpmname} false positive')
return

self._thread_cbbpm = _CAThread(
target=self._do_callback_bpm_intlk, daemon=True)
self._thread_cbbpm.start()
Expand Down

0 comments on commit bc2235e

Please sign in to comment.