Skip to content

Commit

Permalink
Merge pull request #852 from lnls-sirius/update-fofb
Browse files Browse the repository at this point in the history
Update FOFB IOC
  • Loading branch information
anacso17 authored Oct 17, 2022
2 parents 847f66d + df9474d commit 23be762
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 105 deletions.
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.55.0
2.56.0
38 changes: 33 additions & 5 deletions siriuspy/siriuspy/devices/fofb.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def refy(self, value):
var[NR_BPM:] = _np.array(value, dtype=int)
self.ref = var

def set_ref(self, value):
"""Set RefOrb."""
self.ref = value
return True

def set_refx(self, value):
"""Set RefOrb X."""
self.refx = value
Expand All @@ -91,12 +96,18 @@ def set_refy(self, value):
self.refy = value
return True

def check_ref(self, value):
"""Check whether RefOrb is equal to value."""
if not _np.all(self.ref == value):
return False
return True

def check_refx(self, value):
"""Check if first half of RefOrb is equal to value."""
"""Check whether first half of RefOrb is equal to value."""
return self._check_reforbit('x', value)

def check_refy(self, value):
"""Check if second half of RefOrb is equal to value."""
"""Check whether second half of RefOrb is equal to value."""
return self._check_reforbit('y', value)

def _check_reforbit(self, plane, value):
Expand Down Expand Up @@ -228,7 +239,7 @@ class FamFOFBControllers(_Devices):
"""Family of FOFBCtrl and related BPM devices."""

DEF_TIMEOUT = 10 # [s]
DEF_DCC_TIMEFRAMELEN = 6000
DEF_DCC_TIMEFRAMELEN = 5000
DEF_BPMTRIG_RCVSRC = 0
DEF_BPMTRIG_RCVIN = 5
BPM_TRIGS_IDS = [1, 2, 20]
Expand All @@ -251,8 +262,7 @@ def __init__(self):
self._ctl_dccs[ctl + ':' + dcc] = FOFBCtrlDCC(ctl, dcc)
# BPM DCCs and triggers
bpmnames = _BPMSearch.get_names({'sec': 'SI', 'dev': 'BPM'})
bpmids = _np.roll(
_np.array([i-1 if i % 2 == 1 else i for i in range(NR_BPM)]), -1)
bpmids = [((i + 1) // 2) * 2 % 160 for i in range(NR_BPM)]
self._bpm_dccs, self._bpm_trgs, self._bpm_ids = dict(), dict(), dict()
for idx, bpm in enumerate(bpmnames):
self._bpm_ids[bpm] = bpmids[idx]
Expand All @@ -272,6 +282,12 @@ def __init__(self):

super().__init__('SI-Glob:BS-FOFB', devices)

def set_reforb(self, value):
"""Set RefOrb for all FOFB controllers."""
for ctrl in self._ctl_refs.values():
ctrl.set_ref(value)
return True

def set_reforbx(self, value):
"""Set RefOrbX for all FOFB controllers."""
return self._set_reforb('x', value)
Expand All @@ -286,6 +302,15 @@ def _set_reforb(self, plane, value):
fun(value)
return True

def check_reforb(self, value):
"""Check whether RefOrb is equal to value."""
if not self.connected:
return False
for ctrl in self._ctl_refs.values():
if not ctrl.check_ref(value):
return False
return True

def check_reforbx(self, value):
"""Check whether RefOrbX is equal to value."""
return self._check_reforb('x', value)
Expand Down Expand Up @@ -723,6 +748,9 @@ def check_fofbacc_freeze(
if not self.connected:
return False
devs = self._get_devices(psnames, psindices)
if isinstance(values, (int, float, bool)):
values = len(devs) * [values]
values = list(values)
return self._wait_devices_propty(
devs, 'FOFBAccFreeze-Sts', values, timeout=timeout)

Expand Down
41 changes: 29 additions & 12 deletions siriuspy/siriuspy/fofb/csdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,28 @@ def get_hlfofb_database(self):
'LoopState-Sts': {
'type': 'enum', 'enums': _et.OPEN_CLOSED,
'value': self.LoopState.Open},
'LoopGain-SP': {
'LoopGainH-SP': {
'type': 'float', 'value': 1, 'prec': 4,
'lolim': -2**3, 'hilim': 2**3-1,
'unit': 'Global FOFB pre-accumulator gain.'},
'LoopGain-RB': {
'unit': 'FOFB pre-accumulator gain.'},
'LoopGainH-RB': {
'type': 'float', 'value': 1, 'prec': 4,
'lolim': -2**3, 'hilim': 2**3-1,
'unit': 'Global FOFB pre-accumulator gain.'},
'LoopGain-Mon': {
'unit': 'FOFB pre-accumulator gain.'},
'LoopGainH-Mon': {
'type': 'float', 'value': 0, 'prec': 4,
'unit': 'Global FOFB pre-accumulator gain.'},
'unit': 'FOFB pre-accumulator gain.'},
'LoopGainV-SP': {
'type': 'float', 'value': 1, 'prec': 4,
'lolim': -2**3, 'hilim': 2**3-1,
'unit': 'FOFB pre-accumulator gain.'},
'LoopGainV-RB': {
'type': 'float', 'value': 1, 'prec': 4,
'lolim': -2**3, 'hilim': 2**3-1,
'unit': 'FOFB pre-accumulator gain.'},
'LoopGainV-Mon': {
'type': 'float', 'value': 0, 'prec': 4,
'unit': 'FOFB pre-accumulator gain.'},

# Correctors
'CHPosS-Cte': {
Expand All @@ -148,18 +159,24 @@ def get_hlfofb_database(self):
'CorrSetAccFreezeEnbl-Cmd': {'type': 'int', 'value': 0},
'CorrSetAccClear-Cmd': {'type': 'int', 'value': 0},
'CorrSetCurrZero-Cmd': {'type': 'int', 'value': 0},
'CorrAccSatMax-SP': {
'CHAccSatMax-SP': {
'type': 'float', 'prec': 6, 'value': 0.95, 'unit': 'A',
'lolim': 0, 'hilim': 0.95},
'CHAccSatMax-RB': {
'type': 'float', 'prec': 6, 'value': 0.95, 'unit': 'A',
'lolim': 0, 'hilim': 0.95},
'CVAccSatMax-SP': {
'type': 'float', 'prec': 6, 'value': 0.95, 'unit': 'A',
'lolim': 0, 'hilim': 0.95},
'CorrAccSatMax-RB': {
'CVAccSatMax-RB': {
'type': 'float', 'prec': 6, 'value': 0.95, 'unit': 'A',
'lolim': 0, 'hilim': 0.95},

# FOFB Controllers
'TimeFrameLen-SP': {
'type': 'int', 'value': 5000, 'lolim': 3000, 'hilim': 7500,},
'type': 'int', 'value': 5000, 'lolim': 3000, 'hilim': 7500},
'TimeFrameLen-RB': {
'type': 'int', 'value': 5000, 'lolim': 3000, 'hilim': 7500,},
'type': 'int', 'value': 5000, 'lolim': 3000, 'hilim': 7500},
'FOFBCtrlStatus-Mon': {'type': 'int', 'value': 0b1111111},
'FOFBCtrlStatusLabels-Cte': {
'type': 'string', 'count': len(_et.STS_LBLS_FOFBCTRL),
Expand All @@ -169,7 +186,7 @@ def get_hlfofb_database(self):
'FOFBCtrlConfTFrameLen-Cmd': {'type': 'int', 'value': 0},
'FOFBCtrlConfBPMLogTrg-Cmd': {'type': 'int', 'value': 0},

# Kicks and Kick buffer configuration:
# Kicks and Kick buffer configuration
'KickBufferSize-SP': {
'type': 'float', 'value': self.DEF_KICK_BUFFER_SIZE, 'prec': 0,
'lolim': 1, 'hilim': 1000,
Expand All @@ -185,7 +202,7 @@ def get_hlfofb_database(self):
'type': 'float', 'unit': 'urad', 'count': self.nr_cv,
'value': self.nr_cv*[0]},

# Reference Orbit (same order os SOFB)
# Reference Orbit (same order of SOFB)
'RefOrbX-SP': {
'type': 'float', 'unit': 'um', 'count': self.nr_bpms,
'value': self.nr_bpms*[0]},
Expand Down
Loading

0 comments on commit 23be762

Please sign in to comment.