Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dc7a989
ENH: (TUNEFB) Add tune feedback enums, consts and pvs
VitorSouzaLNLS Jul 27, 2026
d275e9c
ENH: (TUNEFB) Add "_inloop" property to TuneCorrApp
VitorSouzaLNLS Jul 27, 2026
9326921
ENH: (TUNEFB) Add SITuneCorrApp
VitorSouzaLNLS Jul 27, 2026
e48fb31
ENH/FIX: (TUNEFB) Fix "tune source" set function
VitorSouzaLNLS Jul 27, 2026
8f7e0a9
Merge branch 'master' into dev/enh/si-tune-fb
VitorSouzaLNLS Jul 27, 2026
66bc723
ENH/FIX: (TUNEFB) Get tunes
VitorSouzaLNLS Jul 27, 2026
2616c50
ENH/FIX: (TUNEFB) Fix tune check (max distortion)
VitorSouzaLNLS Jul 27, 2026
be87379
ENH/FIX: (TUNEFB) Fix "_process_pid" input args
VitorSouzaLNLS Jul 27, 2026
500b340
ENH/LOG: (TUNEFB) Add log when loop closes
VitorSouzaLNLS Jul 27, 2026
7503f84
MNT/ENH: (TUNEFB) Add TuneX and TuneY mon pvs, and replace source -> src
VitorSouzaLNLS Jul 27, 2026
f8a65d0
MNT: (TUNECORR) Update PV initializations
xresende Jul 27, 2026
f365e0c
Merge branch 'master' into dev/enh/si-tune-fb
xresende Jul 27, 2026
84aaeb4
Merge branch 'master' into dev/enh/si-tune-fb
VitorSouzaLNLS Aug 4, 2026
c6a96e0
BUG (TUNEFB): Fix "loop_state"/"inloop" desynchronization on programm…
VitorSouzaLNLS Aug 7, 2026
c8b4f7f
ENH (TUNEFB): Change how the StoredEBeam PV is created and connected,…
VitorSouzaLNLS Aug 7, 2026
4e64a89
MNT (TUNEFB): Open the loop if applying the correction fails
VitorSouzaLNLS Aug 7, 2026
5650cfa
ENH (TUNEFB): Do not update reference when opening the loop
VitorSouzaLNLS Aug 10, 2026
9b5578a
MNT (TUNEFB): Return "True" on "cmd_set_newref" if sucess
VitorSouzaLNLS Aug 13, 2026
8c0d868
REV (OPTICSCORR.TUNEFB): Revert "return True" on "cmd_set_newref" and…
VitorSouzaLNLS Aug 13, 2026
10104dd
Merge branch 'master' into dev/enh/si-tune-fb
VitorSouzaLNLS Aug 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions siriuspy/siriuspy/opticscorr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self, acc):

self._optprm_est = [0.0, 0.0]

self._loop_state = _Const.LoopState.Open # needed for the SI Tune FB
self._apply_corr_cmd_count = 0
self._config_ps_cmd_count = 0

Expand Down Expand Up @@ -248,10 +249,15 @@ def __init__(self, acc):

# Connect to CurrInfo
self._storedebeam_pv = _PV(
_PVName('SI-Glob:AP-CurrInfo:StoredEBeam-Mon').substitute(
prefix=_vaca_prefix),
_PVName(
'SI-Glob:AP-CurrInfo:StoredEBeam-Mon'
).substitute(prefix=_vaca_prefix),
connection_timeout=0.05

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VitorSouzaLNLS , is there not a default connecion_timeout constant from a base class or one in another class you can import and expose more visibly than having a hard-coded constant burried in the code implementation ?

)
self._storedebeam_pv.add_callback(
callback=self._callback_get_storedebeam,
connection_timeout=0.05)
run_now=True
)

# Connect to Tunes
self._tune_x_pv = _PV(
Expand Down Expand Up @@ -320,6 +326,12 @@ def write(self, reason, value):

def cmd_apply_corr(self, value):
"""ApplyCorr command."""
if self._loop_state == _Const.LoopState.Closed:
self.run_callbacks(
'Log-Mon',
'Can\'t apply correction while the feedback is on.'
)
return False
if self._apply_corr():
self._apply_corr_cmd_count += 1
self.run_callbacks('ApplyDelta-Cmd', self._apply_corr_cmd_count)
Expand Down Expand Up @@ -354,6 +366,12 @@ def set_config_name(self, value):

def set_corr_meth(self, value):
"""Set CorrMeth."""
if self._loop_state == _Const.LoopState.Closed:
self.run_callbacks(
'Log-Mon',
'Can\'t change the corr. method while the feedback is on.'
)
return False
if value == self._corr_method:
return False
self._corr_method = value
Expand All @@ -365,6 +383,12 @@ def set_corr_group(self, value):
"""Set CorrGroup."""
if value == self._corr_group:
return False
if self._loop_state == _Const.LoopState.Closed:
self.run_callbacks(
'Log-Mon',
'Can\'t change the corr. group while the feedback is on.'
)
return False
self._corr_group = value
self.run_callbacks('CorrGroup-Sts', self._corr_group)
self._calc_intstrength()
Expand All @@ -378,6 +402,12 @@ def set_sync_corr(self, value):
return False
if value == self._sync_corr:
return False
if self._loop_state == _Const.LoopState.Closed:
self.run_callbacks(
'Log-Mon',
'Can\'t change the synchrozization while the feedback is on.'
)
return False

self._sync_corr = value

Expand Down Expand Up @@ -411,13 +441,25 @@ def set_sync_corr(self, value):

def cmd_config_ps(self, value):
"""ConfigPS command."""
if self._loop_state == _Const.LoopState.Closed:
self.run_callbacks(
'Log-Mon',
'Can\'t configure the Power Supplies while the feedback is on.'
)
return False
if self._config_ps():
self._config_ps_cmd_count += 1
self.run_callbacks('ConfigPS-Cmd', self._config_ps_cmd_count)
return False

def cmd_config_ti(self, value):
"""ConfigTiming command."""
if self._loop_state == _Const.LoopState.Closed:
self.run_callbacks(
'Log-Mon',
'Can\'t configure the Timing while the feedback is on.'
)
return False
if self._config_timing():
self._config_ti_cmd_count += 1
self.run_callbacks('ConfigTiming-Cmd', self._config_ti_cmd_count)
Expand Down Expand Up @@ -605,6 +647,9 @@ def _start_meas_config(self):
if self._sync_corr == _Const.SyncCorr.On:
log_msg = 'ERR: Turn off syncronized correction!'
cont = False
elif self._loop_state == _Const.LoopState.Closed:
log_msg = 'ERR: Can\'t start meas. while the feedback is on!'
cont = False
elif self._meas_config_name == 'UNDEF':
log_msg = 'ERR: Define a conf.name to save the measure!'
cont = False
Expand Down
180 changes: 180 additions & 0 deletions siriuspy/siriuspy/opticscorr/csdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ class ETypes(_csdev.ETypes):
INDIV_2KNOBS = ('Individual', 'TwoKnobs')
MEAS_CMD = ('Reset', 'Start', 'Stop')
MEAS_MON = ('Idle', 'Measuring', 'Completed', 'Aborted')
OPEN_CLOSED = ('Open', 'Closed')
TUNE_SRC = (
'TuneSpec',
'BbB_SRAM_M2',
'BbB_SB_M1',
'BbB_SRAM_M1',
)
TUNE_SRC_PVS = (
('SI-Glob:DI-Tune-H:TuneFrac-Mon',
'SI-Glob:DI-Tune-V:TuneFrac-Mon'),
('SI-Glob:DI-BbBProc-H:SRAM_M2_TUNE',
'SI-Glob:DI-BbBProc-V:SRAM_M2_TUNE'),
('SI-Glob:DI-BbBProc-H:SB_M1_TUNE',
'SI-Glob:DI-BbBProc-V:SB_M1_TUNE'),
('SI-Glob:DI-BbBProc-H:SRAM_M1_TUNE',
'SI-Glob:DI-BbBProc-V:SRAM_M1_TUNE'),
)


_et = ETypes # syntactic sugar
Expand All @@ -26,6 +43,18 @@ class Const(_csdev.Const):
SyncCorr = _csdev.Const.register('SyncCorr', _et.OFF_ON)
MeasCmd = _csdev.Const.register('MeasCmd', _et.MEAS_CMD)
MeasMon = _csdev.Const.register('MeasMon', _et.MEAS_MON)
LoopState = _csdev.Const.register("LoopState", _et.OPEN_CLOSED)
TuneSrc = _csdev.Const.register("TuneSrc", _et.TUNE_SRC)

DEF_LOOPFREQ = 7.0 # [Hz]
DEF_PID_KP = 0.0 # [frac]
DEF_PID_KI = 2.1 # [frac.Hz]
DEF_PID_KD = 0.0 # [frac.s]
DEF_LOOPSTATE = LoopState.Open
DEF_TUNESRC = TuneSrc.TuneSpec
DEF_REF_TUNEX = 0.1614 # [frac] (BbB TuneX 0.16)
DEF_REF_TUNEY = 0.2215 # [frac] (BbB TuneY 0.22)
DEF_MAX_TUNE_ERR = 0.015 # [frac]

BO_SFAMS_CHROMCORR = ('SF', 'SD')
BO_SFAMS_NELM = (25, 10)
Expand Down Expand Up @@ -305,5 +334,156 @@ def get_tune_database(acc):
pvs_database['MeasConfigStatus-Mon'] = {
'type': 'enum', 'enums': _et.MEAS_MON, 'value': _ct.MeasMon.Idle}

# SI Tune FeedBack: Loop settings
pvs_database['LoopState-Sel'] = {
'type': 'enum',
'enums': _ct.LoopState._fields,
'value': _ct.DEF_LOOPSTATE,
}
pvs_database['LoopState-Sts'] = {
'type': 'enum',
'enums': _ct.LoopState._fields,
'value': _ct.DEF_LOOPSTATE,
}
pvs_database['LoopFreq-SP'] = {
'type': 'float',
'value': _ct.DEF_LOOPFREQ,
'unit': 'Hz',
'prec': 3,
'lolim': 1e-3,
'hilim': 12.0,
}
pvs_database['LoopFreq-RB'] = {
'type': 'float',
'value': _ct.DEF_LOOPFREQ,
'unit': 'Hz',
'prec': 3,
'lolim': 1e-3,
'hilim': 12.0,
}
# SI Tune FeedBack: Gotten Tunes
pvs_database['TuneX-Mon'] = {
'type': 'float', 'value': 0.0, 'unit': 'Tune', 'prec': 6,
'lolim': 0.000001, 'hilim': 0.499999}
pvs_database['TuneY-Mon'] = {
'type': 'float', 'value': 0.0, 'unit': 'Tune', 'prec': 6,
'lolim': 0.000001, 'hilim': 0.499999}

# SI Tune FeedBack: Reference Tunes
pvs_database['RefTuneX-SP'] = {
'type': 'float',
'value': _ct.DEF_REF_TUNEX,
'unit': 'Tune',
'prec': 6,
'lolim': 0.0001,
'hilim': 0.4999,
}
pvs_database['RefTuneX-RB'] = {
'type': 'float',
'value': _ct.DEF_REF_TUNEX,
'unit': 'Tune',
'prec': 6,
'lolim': 0.0001,
'hilim': 0.4999,
}
pvs_database['RefTuneY-SP'] = {
'type': 'float',
'value': _ct.DEF_REF_TUNEY,
'unit': 'Tune',
'prec': 6,
'lolim': 0.0001,
'hilim': 0.4999,
}
pvs_database['RefTuneY-RB'] = {
'type': 'float',
'value': _ct.DEF_REF_TUNEY,
'unit': 'Tune',
'prec': 6,
'lolim': 0.0001,
'hilim': 0.4999,
}
pvs_database['MaxTuneErr-SP'] = {
'type': 'float',
'value': _ct.DEF_MAX_TUNE_ERR,
'unit': 'Tune',
'prec': 6,
'lolim': 0.001,
'hilim': 0.4999,
}
pvs_database['MaxTuneErr-RB'] = {
'type': 'float',
'value': _ct.DEF_MAX_TUNE_ERR,
'unit': 'Tune',
'prec': 6,
'lolim': 0.001,
'hilim': 0.4999,
}
# SI Tune FeedBack: PID PVs
pvs_database['LoopPIDKp-SP'] = {
'type': 'float',
'value': _ct.DEF_PID_KP,
'unit': 'frac',
'prec': 4,
'lolim': -100,
'hilim': 100,
}
pvs_database['LoopPIDKp-RB'] = {
'type': 'float',
'value': _ct.DEF_PID_KP,
'unit': 'frac',
'prec': 4,
'lolim': -100,
'hilim': 100,
}
pvs_database['LoopPIDKi-SP'] = {
'type': 'float',
'value': _ct.DEF_PID_KI,
'unit': 'frac.Hz',
'prec': 4,
'lolim': -100,
'hilim': 100,
}
pvs_database['LoopPIDKi-RB'] = {
'type': 'float',
'value': _ct.DEF_PID_KI,
'unit': 'frac.Hz',
'prec': 4,
'lolim': -100,
'hilim': 100,
}
pvs_database['LoopPIDKd-SP'] = {
'type': 'float',
'value': _ct.DEF_PID_KD,
'unit': 'frac.s',
'prec': 4,
'lolim': -100,
'hilim': 100,
}
pvs_database['LoopPIDKd-RB'] = {
'type': 'float',
'value': _ct.DEF_PID_KD,
'unit': 'frac.s',
'prec': 4,
'lolim': -100,
'hilim': 100,
}

# SI Tune FeedBack: Tune measurement PV selection
pvs_database['TuneSrc-Sel'] = {
'type': 'enum',
'enums': _ct.TuneSrc._fields,
'value': _ct.DEF_TUNESRC,
}
pvs_database['TuneSrc-Sts'] = {
'type': 'enum',
'enums': _ct.TuneSrc._fields,
'value': _ct.DEF_TUNESRC,
}
pvs_database['TuneSrcPVList-Mon'] = {
'type': 'string',
'count': 2,
'value': _et.TUNE_SRC_PVS[_ct.DEF_TUNESRC],
}

pvs_database = _csdev.add_pvslist_cte(pvs_database)
return pvs_database
Loading
Loading