Skip to content

Commit

Permalink
Use PV FOFBAccFilterNumBiquads-Cte
Browse files Browse the repository at this point in the history
  • Loading branch information
juliacscarvalho committed May 7, 2024
1 parent 8deed37 commit f4f0324
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
12 changes: 12 additions & 0 deletions siriuspy/siriuspy/devices/fofb.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class FOFBCtrlRef(_Device, FOFBCtrlBase):
'LoopIntlk-Mon', 'LoopIntlkReset-Cmd',
'SYSIDPRBSFOFBAccEn-Sel', 'SYSIDPRBSFOFBAccEn-Sts',
'SYSIDPRBSBPMPosEn-Sel', 'SYSIDPRBSBPMPosEn-Sts',
'FOFBAccFilterNumBiquads-Cte',
)

def __init__(self, devname, props2init='all'):
Expand Down Expand Up @@ -141,6 +142,10 @@ def cmd_reset(self):
self['LoopIntlkReset-Cmd'] = 1
return True

@property
def fofbacc_filter_num_biquads(self):
"""FOFB accumulator filter number of biquads."""
return self['FOFBAccFilterNumBiquads-Cte']

# ---------------- DCC devices ----------------

Expand Down Expand Up @@ -690,6 +695,13 @@ def cmd_dsbl_sysid_exc(self, timeout=DEF_TIMEOUT):
self._evt_fofb.cmd_external_trigger()
return True

@property
def fofbacc_filter_num_biquads(self):
"""FOFB accumulator filter number of biquads."""
ctl = self._ctl_refs[FOFBCtrlBase.DEVICES.SI01]
return ctl.fofbacc_filter_num_biquads



class FamFastCorrs(_DeviceSet):
"""Family of FOFB fast correctors."""
Expand Down
1 change: 1 addition & 0 deletions siriuspy/siriuspy/devices/pwrsupply.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ def fofbacc_filter(self):
@fofbacc_filter.setter
def fofbacc_filter(self, value):
self['FOFBAccFilter-SP'] = value


class PowerSupplyFBP(PowerSupply):
"""FBP Power Supply Device."""
Expand Down
12 changes: 11 additions & 1 deletion siriuspy/siriuspy/fofb/csdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ class HLFOFBConst(_csdev.Const):
MeasRespMatMon = _csdev.Const.register('MeasRespMatMon', _et.MEAS_RMAT_MON)
DecOpt = _csdev.Const.register('DecOpt', _et.DEC_OPT)
FilterOpt = _csdev.Const.register('FilterOpt', _et.FILTER_OPT)


# FOFB Switching filter coefficientes
_b4 = [9.10339395e-01, -1.11484423e-16, 9.10339395e-01] # freq FOFB/4
_a4 = [-1.11484423e-16, 8.20678791e-01] # freq FOFB/4
_b2 = [0.83408931895964943947774372645654, 0.83408931895964943947774372645654, 0.0] # freq FOFB/2
_a2 = [0.66817863791929887895548745291308, 0.0] # freq FOFB/2

FILTER_UNIT = [1.0, 0.0, 0.0, 0.0, 0.0]
FILTER_SW_4 = _b4 + _a4
FILTER_SW_2 = _b2 + _a2

def __init__(self):
"""Class constructor."""

Expand Down
24 changes: 9 additions & 15 deletions siriuspy/siriuspy/fofb/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,31 +708,25 @@ def set_corr_accdec(self, option, value):

return True


def set_corr_accfilter(self, option, value):
"""Set corrector accumulator filter."""

num_biquads = self._llfofb_dev.fofbacc_filter_num_biquads
unit = self._const.FILTER_UNIT
sw2 = self._const.FILTER_SW_2
sw4 = self._const.FILTER_SW_4

if self._corr_accfilter_enm != self._const.FilterOpt.Custom and \
option == 'value':
return False

if option == 'enum':
if value == self._const.FilterOpt.Unit:
filter = 20*[0.0]
filter[0] = 1
filter[5] = 1
filter[10] = 1
filter[15] = 1
filter = num_biquads * unit

elif value == self._const.FilterOpt.Switching:
b4 = [9.10339395e-01, -1.11484423e-16, 9.10339395e-01] # freq FOFB/4
a4 = [-1.11484423e-16, 8.20678791e-01] # freq FOFB/4
b2 = [0.83408931895964943947774372645654, 0.83408931895964943947774372645654, 0.0] # freq FOFB/2
a2 = [0.66817863791929887895548745291308, 0.0] # freq FOFB/2
filter = 20*[0.0]
filter[0:3] = b4
filter[3:5] = a4
filter[5:8] = b2
filter[8:10] = a2
filter = sw2 + sw4 + (num_biquads - 2) * unit

else:
filter = self._corr_accfilter_val
self._corr_accdfilter_enm = value
Expand Down

0 comments on commit f4f0324

Please sign in to comment.