Skip to content

Commit

Permalink
Merge pull request #874 from lnls-sirius/fix-sofb
Browse files Browse the repository at this point in the history
Fix SOFB and FOFB bugs
  • Loading branch information
anacso17 authored Nov 22, 2022
2 parents 927bce9 + d185f03 commit 3f868fa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
16 changes: 14 additions & 2 deletions siriuspy/siriuspy/devices/fofb.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,9 @@ class BPMDCC(_DCCDevice):

def __init__(self, devname):
"""Init."""
if not _BPMSearch.is_valid_devname(devname):
raise NotImplementedError(devname)
# Temporarily remove this check to control new 10SB BPMs
# if not _BPMSearch.is_valid_devname(devname):
# raise NotImplementedError(devname)
super().__init__(devname, 'DCCP2P')


Expand Down Expand Up @@ -320,6 +321,10 @@ def __init__(self):
for trig in self.BPM_TRIGS_IDS:
trigname = bpm + ':TRIGGER' + str(trig)
self._bpm_trgs[trigname] = BPMLogicalTrigger(bpm, trig)
bpm2dsbl = ['SI-10SB:DI-BPM-1', 'SI-10SB:DI-BPM-2']
self._bpmdcc2dsbl = dict()
for bpm in bpm2dsbl:
self._bpmdcc2dsbl[bpm] = BPMDCC(bpm)
# fofb event
self._evt_fofb = Event('FOFBS')

Expand Down Expand Up @@ -594,6 +599,13 @@ def cmd_sync_net(self, bpms=None, timeout=DEF_TIMEOUT):
for bpm in bpms:
enbdccs.append(self._bpm_dccs[bpm])

# temporary solution: disable BPM DCCs that are not in FOFB network
dcc2dsbl = list(self._bpmdcc2dsbl.values())
self._set_devices_propty(dcc2dsbl, 'CCEnable-SP', 0)
if not self._wait_devices_propty(
dcc2dsbl, 'CCEnable-RB', 0, timeout=timeout/2):
return False

self._set_devices_propty(alldccs, 'CCEnable-SP', 0)
if not self._wait_devices_propty(
alldccs, 'CCEnable-RB', 0, timeout=timeout/2):
Expand Down
17 changes: 13 additions & 4 deletions siriuspy/siriuspy/sofb/correctors.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def refvalue(self):
class RFCtrl(Corrector):
"""RF control class."""

TINY_VAR = 0.01 # [Hz]
LARGE_VAR = 10000 # [Hz]
MAX_DELTA = 200 # [Hz]

def __init__(self, acc):
"""Init method."""
super().__init__(acc)
Expand All @@ -139,14 +143,13 @@ def value(self):
@value.setter
def value(self, freq):
"""."""
delta_max = 200 # Hz
freq0 = self.value
if freq0 is None or freq is None:
return
delta = abs(freq-freq0)
if delta < 0.1 or delta > 10000:
if delta < self.TINY_VAR or delta > self.LARGE_VAR:
return
npoints = int(delta//delta_max) + 2
npoints = int(delta//self.MAX_DELTA) + 2
freq_span = _np.linspace(freq0, freq, npoints)[1:]
for i, freq in enumerate(freq_span, 1):
self._sp.put(freq, wait=False)
Expand Down Expand Up @@ -866,7 +869,13 @@ def _timed_out(self, values, mode='ready'):
okg[i] = True
continue
val = corr.value if mode == 'ready' else corr.refvalue
okg[i] = val is not None and _compare_kicks(values[i], val)
if val is None:
continue
if isinstance(corr, RFCtrl):
okg[i] = _compare_kicks(
values[i], val, atol=RFCtrl.TINY_VAR)
else:
okg[i] = _compare_kicks(values[i], val)
if all(okg):
return False
_time.sleep(self.TINY_INTERVAL)
Expand Down

0 comments on commit 3f868fa

Please sign in to comment.