From e20475c7de35bb98286a347147fa81e15967a333 Mon Sep 17 00:00:00 2001 From: Ana Clara Oliveira Date: Mon, 18 Apr 2022 18:10:29 -0300 Subject: [PATCH 1/8] cycle.ENH: add fast correctors control --- siriuspy/siriuspy/cycle/__init__.py | 3 +- siriuspy/siriuspy/cycle/conn.py | 146 ++++++++++++++++++ siriuspy/siriuspy/cycle/fc_cycle_data.py | 187 +++++++++++++++++++++++ siriuspy/siriuspy/cycle/main.py | 71 +++++---- siriuspy/siriuspy/cycle/util.py | 4 +- 5 files changed, 380 insertions(+), 31 deletions(-) create mode 100644 siriuspy/siriuspy/cycle/fc_cycle_data.py diff --git a/siriuspy/siriuspy/cycle/__init__.py b/siriuspy/siriuspy/cycle/__init__.py index 06affc30b..2417d540b 100644 --- a/siriuspy/siriuspy/cycle/__init__.py +++ b/siriuspy/siriuspy/cycle/__init__.py @@ -1,5 +1,5 @@ from .main import CycleController -from .conn import Timing, PSCycler, LinacPSCycler, PSCyclerFBP +from .conn import Timing, PSCycler, LinacPSCycler, PSCyclerFBP, FOFBPSCycler from .util import get_psnames, get_sections, get_trigger_by_psname, \ TRIGGER_NAMES from .bo_cycle_data import \ @@ -7,3 +7,4 @@ DEFAULT_RAMP_TOTDURATION, BASE_RAMP_CURVE_ORIG, \ bo_get_default_waveform, bo_generate_base_waveform from .li_cycle_data import li_get_default_waveform +from .fc_cycle_data import fc_get_default_waveform diff --git a/siriuspy/siriuspy/cycle/conn.py b/siriuspy/siriuspy/cycle/conn.py index 638f1ed95..65a39033a 100644 --- a/siriuspy/siriuspy/cycle/conn.py +++ b/siriuspy/siriuspy/cycle/conn.py @@ -21,6 +21,7 @@ from .bo_cycle_data import DEFAULT_RAMP_NRCYCLES, DEFAULT_RAMP_TOTDURATION, \ bo_get_default_waveform as _bo_get_default_waveform from .li_cycle_data import li_get_default_waveform as _li_get_default_waveform +from .fc_cycle_data import fc_get_default_waveform as _fc_get_default_waveform TIMEOUT_SLEEP = 0.1 @@ -753,3 +754,148 @@ def _get_duration_and_waveform(self): def __getitem__(self, prop): """Return item.""" return self._pvs[prop] + + +class FOFBPSCycler: + """Handle FOFB power supply properties to cycle.""" + + # NOTE: this could be a class derived from one of the Device classes. + + properties = [ + 'Current-SP', 'Current-RB', 'PwrState-Sts', + 'PSAmpOverCurrFlagL-Sts', 'PSAmpOverTempFlagL-Sts', + 'PSAmpOverCurrFlagR-Sts', 'PSAmpOverTempFlagR-Sts', + 'TestOpenLoopTriang-Sel', 'TestOpenLoopTriang-Sts', + 'TestOpenLoopSquare-Sel', 'TestOpenLoopSquare-Sts', + 'TestClosedLoopSquare-Sel', 'TestClosedLoopSquare-Sts', + ] + + def __init__(self, psname): + """Constructor.""" + self._psname = _PVName(psname) + self._waveform = None + self._cycle_duration = None + self._times = None + self._pvs = dict() + for prop in FOFBPSCycler.properties: + if prop not in self._pvs.keys(): + self._pvs[prop] = _PV( + self._psname.substitute(prefix=VACA_PREFIX, propty=prop), + connection_timeout=TIMEOUT_CONNECTION) + + @property + def psname(self): + """Power supply name.""" + return self._psname + + @property + def connected(self): + """Return connected state.""" + for prop in FOFBPSCycler.properties: + if not self[prop].connected: + return False + return True + + def wait_for_connection(self, timeout=0.5): + """Wait for connection.""" + for pvobj in self._pvs.values(): + if not pvobj.wait_for_connection(timeout): + return False + return True + + @property + def waveform(self): + """Return waveform.""" + if self._waveform is None: + self._get_duration_and_waveform() + return self._waveform + + def cycle_duration(self, _): + """Return the duration of the cycling in seconds.""" + if self._cycle_duration is None: + self._get_duration_and_waveform() + return self._cycle_duration + + def check_intlks(self, wait=2): + """Check interlocks.""" + if not self.connected: + return False + status = (self._pvs['PSAmpOverCurrFlagL-Sts'].value == 1) + status &= (self._pvs['PSAmpOverTempFlagL-Sts'].value == 1) + status &= (self._pvs['PSAmpOverCurrFlagR-Sts'].value == 1) + status &= (self._pvs['PSAmpOverTempFlagR-Sts'].value == 1) + return status + + def check_on(self): + """Return whether power supply PS is on.""" + return _pv_timed_get(self['PwrState-Sts'], 1) + + def set_current_zero(self): + """Set PS current to zero .""" + return _pv_conn_put(self['Current-SP'], 0) + + def check_current_zero(self, wait=5): + """Return whether power supply PS current is zero.""" + return _pv_timed_get(self['Current-RB'], 0, abs_tol=0.01, wait=wait) + + def prepare(self, _): + """Config power supply to cycling mode.""" + status = True + if not self.check_current_zero(wait=0.5): + status &= self.set_current_zero() + return status + + def is_prepared(self, _, wait=5): + """Return whether power supply is ready.""" + status = self.check_current_zero(wait) + return status + + def set_opmode_slowref(self): + """Set OpMode to SlowRef, if needed.""" + if self.check_opmode_slowref(wait=1): + return True + sts = _pv_conn_put( + self['TestOpenLoopTriang-Sel'], _PSConst.DsblEnbl.Dsbl) + sts &= _pv_conn_put( + self['TestOpenLoopSquare-Sel'], _PSConst.DsblEnbl.Dsbl) + sts &= _pv_conn_put( + self['TestClosedLoopSquare-Sel'], _PSConst.DsblEnbl.Dsbl) + _time.sleep(TIMEOUT_SLEEP) + return sts + + def check_opmode_slowref(self, wait=10): + """Check if OpMode is SlowRef.""" + _wt = wait/3 + sts = _pv_timed_get( + self['TestOpenLoopTriang-Sts'], _PSConst.DsblEnbl.Dsbl, wait=_wt) + sts &= _pv_timed_get( + self['TestOpenLoopSquare-Sts'], _PSConst.DsblEnbl.Dsbl, wait=_wt) + sts &= _pv_timed_get( + self['TestClosedLoopSquare-Sts'], _PSConst.DsblEnbl.Dsbl, wait=_wt) + return sts + + def cycle(self): + """Cycle. This function may run in a thread.""" + for i in range(len(self._waveform)-1): + self['Current-SP'].value = self._waveform[i] + _time.sleep(self._times[i+1] - self._times[i]) + self['Current-SP'].value = self._waveform[-1] + + def check_final_state(self, _): + """Check state after Cycle.""" + status = self.check_on() + status &= self.check_intlks() + if not status: + return _Const.CycleEndStatus.Interlock + return _Const.CycleEndStatus.Ok + + def _get_duration_and_waveform(self): + """Get duration and waveform.""" + time, wfm = _fc_get_default_waveform(psname=self.psname) + self._times = time + self._cycle_duration = max(time) + self._waveform = wfm + + def __getitem__(self, prop): + """Return item.""" + return self._pvs[prop] diff --git a/siriuspy/siriuspy/cycle/fc_cycle_data.py b/siriuspy/siriuspy/cycle/fc_cycle_data.py new file mode 100644 index 000000000..28a5d469f --- /dev/null +++ b/siriuspy/siriuspy/cycle/fc_cycle_data.py @@ -0,0 +1,187 @@ +"""SI fast correctors cycle data.""" + +import numpy as _np + + +PARMS = { + # psname dt[s], max_amp[A], period[s], nrcycles, tau[s], sin**2 + 'SI-01M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-01M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-01M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-01M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-01C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-01C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-01C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-01C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-02M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-02M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-02M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-02M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-02C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-02C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-02C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-02C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-03M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-03M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-03M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-03M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-03C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-03C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-03C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-03C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-04M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-04M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-04M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-04M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-04C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-04C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-04C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-04C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-05M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-05M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-05M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-05M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-05C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-05C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-05C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-05C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-06M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-06M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-06M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-06M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-06C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-06C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-06C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-06C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-07M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-07M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-07M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-07M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-07C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-07C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-07C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-07C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-08M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-08M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-08M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-08M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-08C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-08C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-08C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-08C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-09M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-09M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-09M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-09M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-09C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-09C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-09C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-09C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-10M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-10M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-10M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-10M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-10C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-10C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-10C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-10C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-11M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-11M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-11M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-11M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-11C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-11C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-11C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-11C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-12M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-12M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-12M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-12M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-12C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-12C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-12C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-12C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-13M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-13M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-13M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-13M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-13C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-13C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-13C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-13C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-14M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-14M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-14M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-14M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-14C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-14C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-14C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-14C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-15M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-15M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-15M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-15M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-15C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-15C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-15C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-15C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-16M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-16M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-16M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-16M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-16C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-16C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-16C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-16C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-17M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-17M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-17M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-17M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-17C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-17C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-17C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-17C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-18M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-18M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-18M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-18M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-18C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-18C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-18C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-18C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-19M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-19M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-19M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-19M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-19C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-19C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-19C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-19C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-20M1:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-20M1:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-20M2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-20M2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-20C2:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-20C2:PS-FCV': [0.5, 0.95, 24, 8, 48, False], + 'SI-20C3:PS-FCH': [0.5, 0.95, 24, 8, 48, False], + 'SI-20C3:PS-FCV': [0.5, 0.95, 24, 8, 48, False], +} + + +def fc_get_default_waveform(psname): + """Return cycle waveform.""" + [dtime, ampl, period, nr_periods, tau, square] = PARMS[psname] + wfm = 2*_np.pi/period + nrpts = nr_periods * int(period / dtime) + vec = list(range(0, nrpts)) + time = dtime * _np.array(vec) + nexp = 2 if square else 1 + time0 = _np.arctan(2*_np.pi*tau*nexp)/wfm + sin = _np.sin(2*_np.pi*time/period) + exp = _np.exp(- (time - time0)/tau) + amp = ampl/(_np.sin(wfm*time0))**nexp + func = amp * exp * sin**nexp + time = _np.append(time, time[-1] + dtime) + func = _np.append(func, 0.0) + func *= ampl/max(func) # makes sure max point is 'ampl' + return time, func diff --git a/siriuspy/siriuspy/cycle/main.py b/siriuspy/siriuspy/cycle/main.py index 6c90b7885..f8f41c226 100644 --- a/siriuspy/siriuspy/cycle/main.py +++ b/siriuspy/siriuspy/cycle/main.py @@ -10,7 +10,7 @@ from ..namesys import Filter as _Filter, SiriusPVName as _PVName from ..search import PSSearch as _PSSearch -from .conn import Timing, PSCycler, PSCyclerFBP, LinacPSCycler +from .conn import Timing, PSCycler, PSCyclerFBP, LinacPSCycler, FOFBPSCycler from .bo_cycle_data import DEFAULT_RAMP_DURATION from .util import get_sections as _get_sections, Const as _Const, \ get_trigger_by_psname as _get_trigger_by_psname @@ -30,7 +30,7 @@ def __init__(self, cyclers=None, timing=None, # initialize auxiliar variables self._mode = None self._sections = list() - self._only_linac = None + self._not_ctrl_ti = None self._cycle_duration = 0 self._aux_cyclers = dict() self._cycle_trims_duration = 0 @@ -88,6 +88,8 @@ def cyclers(self, new_cyclers): for name in psnames: if 'LI' in name: new_cyclers[name] = LinacPSCycler(name) + elif _PSSearch.conv_psname_2_psmodel(name) == 'FOFB_PS': + new_cyclers[name] = FOFBPSCycler(name) elif _PSSearch.conv_psname_2_psmodel(name) == 'FBP': new_cyclers[name] = PSCyclerFBP(name, self._ramp_config) else: @@ -97,8 +99,11 @@ def cyclers(self, new_cyclers): # define section self._sections = _get_sections(self._cyclers.keys()) - # define only_linac variable - self._only_linac = self._sections == ['LI', ] + # define not_ctrl_ti variable + ps_no_ti = _PSSearch.get_psnames({'sec': 'LI', 'dis': 'PS'}) + ps_no_ti.extend( + _PSSearch.get_psnames({'sec': 'SI', 'dis': 'PS', 'dev': 'FC.*'})) + self._not_ctrl_ti = not bool(set(self._cyclers.keys()) - set(ps_no_ti)) # define triggers self._triggers = _get_trigger_by_psname(self._cyclers.keys()) @@ -136,7 +141,7 @@ def cyclers(self, new_cyclers): self._cycle_duration = duration # egun pv - if 'LI-01:PS-Spect' in self.psnames: + if 'LI-01:PS-Spect' in self._cyclers.keys(): self._pv_egun = _PV('LI-01:EG-TriggerPS:enablereal', connection_timeout=0.05) @@ -372,9 +377,11 @@ def restore_timing_max_duration(self): def config_pwrsupplies(self, ppty, psnames): """Prepare power supplies to cycle according to mode.""" if ppty == 'opmode': - if self._only_linac: - return True - psnames = {ps for ps in psnames if 'LI' not in ps} + psnames = { + p for p in psnames if 'LI' not in p and + not _PSSearch.conv_psname_2_psmodel(p) == 'FOFB_PS'} + if not psnames: + return True self._update_log('Preparing power supplies '+ppty+'...') with ThreadPoolExecutor(max_workers=100) as executor: @@ -392,7 +399,7 @@ def config_pwrsupplies(self, ppty, psnames): def config_timing(self): """Prepare timing to cycle according to mode.""" - if self._only_linac: + if self._not_ctrl_ti: return self._timing.turnoff(self._triggers) self._update_log('Preparing Timing...') @@ -402,9 +409,11 @@ def config_timing(self): def check_pwrsupplies(self, ppty, psnames, timeout=TIMEOUT_CHECK): """Check all power supplies according to mode.""" if ppty == 'opmode': - if self._only_linac: - return True - psnames = {ps for ps in psnames if 'LI' not in ps} + psnames = { + p for p in psnames if 'LI' not in p and + not _PSSearch.conv_psname_2_psmodel(p) == 'FOFB_PS'} + if not psnames: + return True self._update_log('Checking power supplies '+ppty+'...') self._checks_result = {psn: False for psn in psnames} @@ -443,7 +452,7 @@ def check_pwrsupplies(self, ppty, psnames, timeout=TIMEOUT_CHECK): def check_timing(self): """Check timing preparation.""" - if self._only_linac: + if self._not_ctrl_ti: return True self._update_log('Checking Timing...') @@ -472,7 +481,7 @@ def check_egun_off(self): def set_triggers_state(self, triggers, state): """Set triggers state.""" - if self._only_linac: + if self._not_ctrl_ti: return True label = 'enabl' if state == 'enbl' else 'disabl' @@ -485,7 +494,7 @@ def set_triggers_state(self, triggers, state): def trigger_timing(self): """Trigger timing according to mode.""" - if self._only_linac: + if self._not_ctrl_ti: return self._update_log('Triggering timing...') self._timing.trigger(self.mode) @@ -563,12 +572,14 @@ def init(self): # initialize dict to check which ps is cycling self._is_cycling_dict = {ps: True for ps in self.psnames} - self._li_threads = list() - psnames_li = [psn for psn in self.psnames if 'LI' in psn] - for psname in psnames_li: + self._aux_threads = list() + psn2thr = [ + p for p in self.psnames if _PVName(p).sec == 'LI' or + _PVName(p).dev in ['FCH', 'FCV']] + for psname in psn2thr: cycler = self._get_cycler(psname) thread = _thread.Thread(target=cycler.cycle, daemon=True) - self._li_threads.append(thread) + self._aux_threads.append(thread) thread.start() # trigger @@ -596,6 +607,8 @@ def wait(self): for psname in self.psnames: if _PVName(psname).sec == 'LI': continue + if _PVName(psname).dev in ['FCH', 'FCV']: + continue cycler = self._get_cycler(psname) if not cycler.get_cycle_enable(): self._update_log( @@ -650,10 +663,10 @@ def check_pwrsupplies_finalsts(self, psnames): def set_pwrsupplies_sofbmode(self, psnames): """Set power supplies SOFBMode.""" - if self._only_linac: + psnames = { + p for p in psnames if _PSSearch.conv_psname_2_psmodel(p) == 'FBP'} + if not psnames: return True - psnames = {ps for ps in psnames - if _PSSearch.conv_psname_2_psmodel(ps) == 'FBP'} self._update_log('Turning off power supplies SOFBMode...') for idx, psname in enumerate(psnames): @@ -666,10 +679,10 @@ def set_pwrsupplies_sofbmode(self, psnames): def check_pwrsupplies_sofbmode(self, psnames, timeout=TIMEOUT_CHECK): """Check power supplies SOFBMode.""" - if self._only_linac: + psnames = { + p for p in psnames if _PSSearch.conv_psname_2_psmodel(p) == 'FBP'} + if not psnames: return True - psnames = {ps for ps in psnames - if _PSSearch.conv_psname_2_psmodel(ps) == 'FBP'} self._update_log('Checking power supplies SOFBMode...') self._checks_result = {psn: False for psn in psnames} @@ -704,9 +717,9 @@ def check_pwrsupplies_sofbmode(self, psnames, timeout=TIMEOUT_CHECK): def set_pwrsupplies_slowref(self, psnames): """Set power supplies OpMode to SlowRef.""" - if self._only_linac: + psnames = {p for p in psnames if 'LI' not in p} + if not psnames: return True - psnames = {ps for ps in psnames if 'LI' not in ps} self._update_log('Setting power supplies to SlowRef...') with ThreadPoolExecutor(max_workers=100) as executor: @@ -721,9 +734,9 @@ def set_pwrsupplies_slowref(self, psnames): def check_pwrsupplies_slowref(self, psnames, timeout=TIMEOUT_CHECK): """Check power supplies OpMode.""" - if self._only_linac: + psnames = {p for p in psnames if 'LI' not in p} + if not psnames: return True - psnames = {ps for ps in psnames if 'LI' not in ps} self._update_log('Checking power supplies opmode...') self._checks_result = {psn: False for psn in psnames} diff --git a/siriuspy/siriuspy/cycle/util.py b/siriuspy/siriuspy/cycle/util.py index 3502a2399..a2af39d72 100644 --- a/siriuspy/siriuspy/cycle/util.py +++ b/siriuspy/siriuspy/cycle/util.py @@ -31,9 +31,11 @@ def get_psnames(isadv=False): names.extend(_PSSearch.get_psnames( {'sec': 'SI', 'sub': '[0-2][0-9]C2', 'dis': 'PS', 'dev': 'QS'})) + names.extend(_PSSearch.get_psnames( + {'sec': 'SI', 'dis': 'PS', 'dev': 'FC.*'})) else: names.extend(_PSSearch.get_psnames( - {'sec': 'SI', 'dis': 'PS', 'dev': '(B|Q.*|S.*|C.*)'})) + {'sec': 'SI', 'dis': 'PS', 'dev': '(B|Q.*|S.*|C.*|FC.*)'})) to_remove = _PSSearch.get_psnames({'sec': 'TS', 'idx': '(0|1E2)'}) for name in to_remove: From c0b975020e04d030e07f254516f008a37e6dd333 Mon Sep 17 00:00:00 2001 From: Ana Clara Oliveira Date: Tue, 19 Apr 2022 12:11:58 -0300 Subject: [PATCH 2/8] psdiag.ENH: add fast corrector monitoring --- siriuspy/siriuspy/diagsys/psdiag/csdev.py | 11 +++++++++++ siriuspy/siriuspy/diagsys/psdiag/main.py | 21 +++++++++++++++++++-- siriuspy/siriuspy/diagsys/psdiag/pvs.py | 23 +++++++++++++++++++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/siriuspy/siriuspy/diagsys/psdiag/csdev.py b/siriuspy/siriuspy/diagsys/psdiag/csdev.py index 4ed94d658..147f2c93c 100644 --- a/siriuspy/siriuspy/diagsys/psdiag/csdev.py +++ b/siriuspy/siriuspy/diagsys/psdiag/csdev.py @@ -26,6 +26,15 @@ class ETypes(_csdev.ETypes): 'Reserved', 'Reserved') + DIAG_STATUS_LABELS_FC = ( + 'PS Disconnected', + 'PwrState-Sts Off', + 'Current-(SP|RB) are different', + 'Alarms', + 'Reserved', + 'Reserved', + 'Reserved') + DIAG_STATUS_LABELS_BO = ( 'PS Disconnected/Comm. Broken', 'PwrState-Sts Off', @@ -42,6 +51,8 @@ class ETypes(_csdev.ETypes): def get_ps_diag_status_labels(psname): """Return Diag Status Labels enum.""" psname = _PVName(psname) + if psname.dev in ['FCH', 'FCV']: + return _et.DIAG_STATUS_LABELS_FC if psname.sec == 'BO': return _et.DIAG_STATUS_LABELS_BO if psname.sec == 'LI': diff --git a/siriuspy/siriuspy/diagsys/psdiag/main.py b/siriuspy/siriuspy/diagsys/psdiag/main.py index 2af015947..11918ec97 100644 --- a/siriuspy/siriuspy/diagsys/psdiag/main.py +++ b/siriuspy/siriuspy/diagsys/psdiag/main.py @@ -21,7 +21,10 @@ def _create_computed_pvs(self, psnames): # DiagCurrentDiff-Mon pvs = [None, None] pvs[_PSDiffPV.CURRT_SP] = devname + ':Current-SP' - pvs[_PSDiffPV.CURRT_MON] = devname + ':Current-Mon' + if devname.dev in ['FCH', 'FCV']: + pvs[_PSDiffPV.CURRT_MON] = devname + ':Current-RB' + else: + pvs[_PSDiffPV.CURRT_MON] = devname + ':Current-Mon' pvo = _ComputedPV( psname + ':DiagCurrentDiff-Mon', _PSDiffPV(), self._queue, pvs, monitor=False) @@ -29,7 +32,21 @@ def _create_computed_pvs(self, psnames): # DiagStatus-Mon computer = _PSStatusPV() - if devname.sec != 'LI': + if devname.dev in ['FCH', 'FCV']: + pvs = [None]*6 + pvs[_PSStatusPV.PWRSTE_STS] = devname + ':PwrState-Sts' + pvs[_PSStatusPV.CURRT_DIFF] = devname + ':DiagCurrentDiff-Mon' + + alarm_list = [ + ':PSAmpOverCurrFlagL-Sts', ':PSAmpOverCurrFlagR-Sts', + ':PSAmpOverTempFlagL-Sts', ':PSAmpOverTempFlagR-Sts', + ] + computer.ALARM_PVS = list() + for idx, alarm in enumerate(alarm_list): + pvidx = idx + computer.CURRT_DIFF + 1 + computer.ALARM_PVS.append(pvidx) + pvs[pvidx] = devname + alarm + elif devname.sec != 'LI': intlks = _get_ps_interlocks(psname=psname) intlk_list = [':' + ppt for ppt in intlks if 'Intlk' in ppt] alarm_list = [':' + ppt for ppt in intlks if 'Alarm' in ppt] diff --git a/siriuspy/siriuspy/diagsys/psdiag/pvs.py b/siriuspy/siriuspy/diagsys/psdiag/pvs.py index a27ebb409..8cfcb7655 100644 --- a/siriuspy/siriuspy/diagsys/psdiag/pvs.py +++ b/siriuspy/siriuspy/diagsys/psdiag/pvs.py @@ -62,7 +62,13 @@ def compute_update(self, computed_pv, updated_pv_name, value): psname = _PVName(computed_pv.pvs[0].pvname).device_name value = 0 # ps connected? - if psname.sec != 'LI': + if psname.dev in ['FCH', 'FCV']: + disconnected = \ + not computed_pv.pvs[PSStatusPV.PWRSTE_STS].connected or \ + not computed_pv.pvs[PSStatusPV.CURRT_DIFF].connected + for alrm in self.ALARM_PVS: + disconnected |= not computed_pv.pvs[alrm].connected + elif psname.sec != 'LI': disconnected = \ not computed_pv.pvs[PSStatusPV.PWRSTE_STS].connected or \ not computed_pv.pvs[PSStatusPV.CURRT_DIFF].connected or \ @@ -102,7 +108,20 @@ def compute_update(self, computed_pv, updated_pv_name, value): if pwrsts != _PSConst.PwrStateSts.On or pwrsts is None: value |= PSStatusPV.BIT_PWRSTATON - if psname.sec != 'LI': + if psname.dev in ['FCH', 'FCV']: + # current-diff? + severity = computed_pv.pvs[PSStatusPV.CURRT_DIFF].severity + if severity != 0: + value |= PSStatusPV.BIT_CURRTDIFF + + # alarms? + for alarm in self.ALARM_PVS: + alarmval = computed_pv.pvs[alarm].value + if alarmval != 1 or alarmval is None: + value |= PSStatusPV.BIT_ALARMSSET + break + + elif psname.sec != 'LI': # opmode? sel = computed_pv.pvs[PSStatusPV.OPMODE_SEL].value sts = computed_pv.pvs[PSStatusPV.OPMODE_STS].value From c48757b033c5899e6cd8ddaade396a8db5f7fa14 Mon Sep 17 00:00:00 2001 From: Ana Clara Oliveira Date: Thu, 12 May 2022 15:49:51 -0300 Subject: [PATCH 3/8] clientconfigdb.ENH: add first version of si_fofb configuration type --- .../siriuspy/clientconfigdb/types/si_fofb.py | 199 ++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 siriuspy/siriuspy/clientconfigdb/types/si_fofb.py diff --git a/siriuspy/siriuspy/clientconfigdb/types/si_fofb.py b/siriuspy/siriuspy/clientconfigdb/types/si_fofb.py new file mode 100644 index 000000000..b617a480f --- /dev/null +++ b/siriuspy/siriuspy/clientconfigdb/types/si_fofb.py @@ -0,0 +1,199 @@ +"""SI fast orbit feedback system configuration.""" +from copy import deepcopy as _dcopy + + +def get_dict(): + """Return configuration type dictionary.""" + module_name = __name__.split('.')[-1] + _dict = { + 'config_type_name': module_name, + 'value': _dcopy(_template_dict), + 'check': False, + } + return _dict + + +# When using this type of configuration to set the machine, +# the list of PVs should be processed in the same order they are stored +# in the configuration. The second numeric parameter in the pair is the +# delay [s] the client should wait before setting the next PV. + +_corrs = [ + 'SI-01M1:PS-FCH', + 'SI-01M1:PS-FCV', + 'SI-01M2:PS-FCH', + 'SI-01M2:PS-FCV', + 'SI-01C2:PS-FCH', + 'SI-01C2:PS-FCV', + 'SI-01C3:PS-FCH', + 'SI-01C3:PS-FCV', + 'SI-02M1:PS-FCH', + 'SI-02M1:PS-FCV', + 'SI-02M2:PS-FCH', + 'SI-02M2:PS-FCV', + 'SI-02C2:PS-FCH', + 'SI-02C2:PS-FCV', + 'SI-02C3:PS-FCH', + 'SI-02C3:PS-FCV', + 'SI-03M1:PS-FCH', + 'SI-03M1:PS-FCV', + 'SI-03M2:PS-FCH', + 'SI-03M2:PS-FCV', + 'SI-03C2:PS-FCH', + 'SI-03C2:PS-FCV', + 'SI-03C3:PS-FCH', + 'SI-03C3:PS-FCV', + 'SI-04M1:PS-FCH', + 'SI-04M1:PS-FCV', + 'SI-04M2:PS-FCH', + 'SI-04M2:PS-FCV', + 'SI-04C2:PS-FCH', + 'SI-04C2:PS-FCV', + 'SI-04C3:PS-FCH', + 'SI-04C3:PS-FCV', + 'SI-05M1:PS-FCH', + 'SI-05M1:PS-FCV', + 'SI-05M2:PS-FCH', + 'SI-05M2:PS-FCV', + 'SI-05C2:PS-FCH', + 'SI-05C2:PS-FCV', + 'SI-05C3:PS-FCH', + 'SI-05C3:PS-FCV', + 'SI-06M1:PS-FCH', + 'SI-06M1:PS-FCV', + 'SI-06M2:PS-FCH', + 'SI-06M2:PS-FCV', + 'SI-06C2:PS-FCH', + 'SI-06C2:PS-FCV', + 'SI-06C3:PS-FCH', + 'SI-06C3:PS-FCV', + 'SI-07M1:PS-FCH', + 'SI-07M1:PS-FCV', + 'SI-07M2:PS-FCH', + 'SI-07M2:PS-FCV', + 'SI-07C2:PS-FCH', + 'SI-07C2:PS-FCV', + 'SI-07C3:PS-FCH', + 'SI-07C3:PS-FCV', + 'SI-08M1:PS-FCH', + 'SI-08M1:PS-FCV', + 'SI-08M2:PS-FCH', + 'SI-08M2:PS-FCV', + 'SI-08C2:PS-FCH', + 'SI-08C2:PS-FCV', + 'SI-08C3:PS-FCH', + 'SI-08C3:PS-FCV', + 'SI-09M1:PS-FCH', + 'SI-09M1:PS-FCV', + 'SI-09M2:PS-FCH', + 'SI-09M2:PS-FCV', + 'SI-09C2:PS-FCH', + 'SI-09C2:PS-FCV', + 'SI-09C3:PS-FCH', + 'SI-09C3:PS-FCV', + 'SI-10M1:PS-FCH', + 'SI-10M1:PS-FCV', + 'SI-10M2:PS-FCH', + 'SI-10M2:PS-FCV', + 'SI-10C2:PS-FCH', + 'SI-10C2:PS-FCV', + 'SI-10C3:PS-FCH', + 'SI-10C3:PS-FCV', + 'SI-11M1:PS-FCH', + 'SI-11M1:PS-FCV', + 'SI-11M2:PS-FCH', + 'SI-11M2:PS-FCV', + 'SI-11C2:PS-FCH', + 'SI-11C2:PS-FCV', + 'SI-11C3:PS-FCH', + 'SI-11C3:PS-FCV', + 'SI-12M1:PS-FCH', + 'SI-12M1:PS-FCV', + 'SI-12M2:PS-FCH', + 'SI-12M2:PS-FCV', + 'SI-12C2:PS-FCH', + 'SI-12C2:PS-FCV', + 'SI-12C3:PS-FCH', + 'SI-12C3:PS-FCV', + 'SI-13M1:PS-FCH', + 'SI-13M1:PS-FCV', + 'SI-13M2:PS-FCH', + 'SI-13M2:PS-FCV', + 'SI-13C2:PS-FCH', + 'SI-13C2:PS-FCV', + 'SI-13C3:PS-FCH', + 'SI-13C3:PS-FCV', + 'SI-14M1:PS-FCH', + 'SI-14M1:PS-FCV', + 'SI-14M2:PS-FCH', + 'SI-14M2:PS-FCV', + 'SI-14C2:PS-FCH', + 'SI-14C2:PS-FCV', + 'SI-14C3:PS-FCH', + 'SI-14C3:PS-FCV', + 'SI-15M1:PS-FCH', + 'SI-15M1:PS-FCV', + 'SI-15M2:PS-FCH', + 'SI-15M2:PS-FCV', + 'SI-15C2:PS-FCH', + 'SI-15C2:PS-FCV', + 'SI-15C3:PS-FCH', + 'SI-15C3:PS-FCV', + 'SI-16M1:PS-FCH', + 'SI-16M1:PS-FCV', + 'SI-16M2:PS-FCH', + 'SI-16M2:PS-FCV', + 'SI-16C2:PS-FCH', + 'SI-16C2:PS-FCV', + 'SI-16C3:PS-FCH', + 'SI-16C3:PS-FCV', + 'SI-17M1:PS-FCH', + 'SI-17M1:PS-FCV', + 'SI-17M2:PS-FCH', + 'SI-17M2:PS-FCV', + 'SI-17C2:PS-FCH', + 'SI-17C2:PS-FCV', + 'SI-17C3:PS-FCH', + 'SI-17C3:PS-FCV', + 'SI-18M1:PS-FCH', + 'SI-18M1:PS-FCV', + 'SI-18M2:PS-FCH', + 'SI-18M2:PS-FCV', + 'SI-18C2:PS-FCH', + 'SI-18C2:PS-FCV', + 'SI-18C3:PS-FCH', + 'SI-18C3:PS-FCV', + 'SI-19M1:PS-FCH', + 'SI-19M1:PS-FCV', + 'SI-19M2:PS-FCH', + 'SI-19M2:PS-FCV', + 'SI-19C2:PS-FCH', + 'SI-19C2:PS-FCV', + 'SI-19C3:PS-FCH', + 'SI-19C3:PS-FCV', + 'SI-20M1:PS-FCH', + 'SI-20M1:PS-FCV', + 'SI-20M2:PS-FCH', + 'SI-20M2:PS-FCV', + 'SI-20C2:PS-FCH', + 'SI-20C2:PS-FCV', + 'SI-20C3:PS-FCH', + 'SI-20C3:PS-FCV', + ] +_corr_propts = [ + [':CtrlLoopKp-SP', 5000000, 0.0], # PI Kp parameter + [':CtrlLoopTi-SP', 300, 0.0], # PI Ti parameter + [':CurrGain-SP', 6.25e-5, 0.0], # current gain + [':CurrOffset-SP', 0, 0.0], # current offset + [':VoltGain-SP', 1.12916762036e-4, 0.0], # voltage gain + [':VoltOffset-SP', 0, 0.0], # voltage offset +] +_pvs_corrs = list() +for dev in _corrs: + for ppt, val, dly in _corr_propts: + _pvs_corrs.append([dev+ppt, val, dly]) + +_template_dict = { + 'pvs': + _pvs_corrs + } From d21497924460ba3ba385206e8aa2b6beb660bdde Mon Sep 17 00:00:00 2001 From: Ana Clara Oliveira Date: Thu, 12 May 2022 18:38:42 -0300 Subject: [PATCH 4/8] pwrsupply.ENH: add FOFB corrector database --- siriuspy/siriuspy/pwrsupply/csdev.py | 80 ++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/siriuspy/siriuspy/pwrsupply/csdev.py b/siriuspy/siriuspy/pwrsupply/csdev.py index 5625c3743..47614f0ce 100644 --- a/siriuspy/siriuspy/pwrsupply/csdev.py +++ b/siriuspy/siriuspy/pwrsupply/csdev.py @@ -1329,6 +1329,82 @@ def _get_ps_LINAC_propty_database(): return propty_db +def _get_ps_FOFB_propty_database(): + """This is not a primary source database. + + Primary sources can be found in Fast Orbit Feedback EPICS Support: + https://github.com/lnls-dig/fofb-epics-ioc/. + """ + dbase = { + # PwsState + 'PwrState-Sel': { + 'type': 'enum', 'enums': _et.OFF_ON, + 'value': Const.OffOn.Off, 'unit': 'pwrstate'}, + 'PwrState-Sts': { + 'type': 'enum', 'enums': _et.OFF_ON, + 'value': Const.OffOn.Off, 'unit': 'pwrstate'}, + # Ctrl Loop + 'CtrlLoop-Sel': { + 'type': 'enum', 'enums': _et.OFF_ON, + 'value': Const.OffOn.Off, 'unit': 'ctrlloop'}, + 'CtrlLoop-Sts': { + 'type': 'enum', 'enums': _et.OFF_ON, + 'value': Const.OffOn.Off, 'unit': 'ctrlloop'}, + # Tests (opmode) + 'TestOpenLoopTriang-Sel': { + 'type': 'enum', 'enums': _et.OFF_ON, + 'value': Const.OffOn.Off, 'unit': 'state'}, + 'TestOpenLoopTriang-Sts': { + 'type': 'enum', 'enums': _et.OFF_ON, + 'value': Const.OffOn.Off, 'unit': 'state'}, + 'TestOpenLoopSquare-Sel': { + 'type': 'enum', 'enums': _et.OFF_ON, + 'value': Const.OffOn.Off, 'unit': 'state'}, + 'TestOpenLoopSquare-Sts': { + 'type': 'enum', 'enums': _et.OFF_ON, + 'value': Const.OffOn.Off, 'unit': 'state'}, + 'TestClosedLoopSquare-Sel': { + 'type': 'enum', 'enums': _et.OFF_ON, + 'value': Const.OffOn.Off, 'unit': 'state'}, + 'TestClosedLoopSquare-Sts': { + 'type': 'enum', 'enums': _et.OFF_ON, + 'value': Const.OffOn.Off, 'unit': 'state'}, + # Alarms + 'PSAmpOverCurrFlagL-Sts': {'type': 'int', 'value': 0.0}, + 'PSAmpOverCurrFlagR-Sts': {'type': 'int', 'value': 0.0}, + 'PSAmpOverTempFlagL-Sts': {'type': 'int', 'value': 0.0}, + 'PSAmpOverTempFlagR-Sts': {'type': 'int', 'value': 0.0}, + # PI params + 'CtrlLoopKp-SP': {'type': 'int', 'value': 0.0}, + 'CtrlLoopKp-RB': {'type': 'int', 'value': 0.0}, + 'CtrlLoopTi-SP': {'type': 'int', 'value': 0.0}, + 'CtrlLoopTi-RB': {'type': 'int', 'value': 0.0}, + # Calibration params + 'CurrGain-SP': {'type': 'float', 'prec': 15, 'value': 0.0}, + 'CurrGain-RB': {'type': 'float', 'prec': 15, 'value': 0.0}, + 'CurrOffset-SP': {'type': 'int', 'value': 0.0}, + 'CurrOffset-RB': {'type': 'int', 'value': 0.0}, + 'VoltGain-SP': {'type': 'float', 'prec': 15, 'value': 0.0}, + 'VoltGain-RB': {'type': 'float', 'prec': 15, 'value': 0.0}, + 'VoltOffset-SP': {'type': 'int', 'value': 0.0}, + 'VoltOffset-RB': {'type': 'int', 'value': 0.0}, + # Current + 'CurrentRaw-SP': { + 'type': 'int', 'value': 0.0, 'unit': 'count'}, + 'CurrentRaw-RB': { + 'type': 'int', 'value': 0.0, 'unit': 'count'}, + 'Current-SP': { + 'type': 'float', 'prec': 15, 'value': 0.0, 'unit': 'A', + 'lolo': -0.95, 'low': -0.95, 'lolim': -0.95, + 'hilim': 0.95, 'high': 0.95, 'hihi': 0.95}, + 'Current-RB': { + 'type': 'float', 'prec': 15, 'value': 0.0, 'unit': 'A', + 'lolo': -0.95, 'low': -0.95, 'lolim': -0.95, + 'hilim': 0.95, 'high': 0.95, 'hihi': 0.95}, + } + dbase = _csdev.add_pvslist_cte(dbase) + return dbase + # --- FBP --- def _get_ps_FBP_propty_database(): @@ -2710,6 +2786,7 @@ def _get_model_db(psmodel): 'FP_KCKR': _get_pu_FP_KCKR_propty_database, 'FP_PINGER': _get_pu_FP_PINGER_propty_database, 'LINAC_PS': _get_ps_LINAC_propty_database, + 'FOFB_PS': _get_ps_FOFB_propty_database, 'APU': _get_id_apu_propty_database, 'REGATRON_DCLink': _get_ps_REGATRON_DCLink_database, } @@ -2807,5 +2884,8 @@ def _insert_strengths(database, pstype): del database['KLRef-Mon'] if 'SLRef-Mon' in database: del database['SLRef-Mon'] + if pstype in ('si-corrector-fch', 'si-corrector-fcv'): + del database['KickRef-Mon'] + del database['Kick-Mon'] return database From 9a3da34982e329d67fe1e573b42a2915e150a9df Mon Sep 17 00:00:00 2001 From: Ana Clara Oliveira Date: Thu, 12 May 2022 18:38:50 -0300 Subject: [PATCH 5/8] Update version to 2.47.0 --- siriuspy/siriuspy/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/siriuspy/siriuspy/VERSION b/siriuspy/siriuspy/VERSION index cc8758303..bb13a7e35 100644 --- a/siriuspy/siriuspy/VERSION +++ b/siriuspy/siriuspy/VERSION @@ -1 +1 @@ -2.46.0 +2.47.0 From be240b52619b1ad65fb2da139b9691152ec2bb75 Mon Sep 17 00:00:00 2001 From: Ana Clara Oliveira Date: Thu, 12 May 2022 19:44:51 -0300 Subject: [PATCH 6/8] TST: fix powersupply tests --- siriuspy/siriuspy/pwrsupply/csdev.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/siriuspy/siriuspy/pwrsupply/csdev.py b/siriuspy/siriuspy/pwrsupply/csdev.py index 47614f0ce..39c02a64b 100644 --- a/siriuspy/siriuspy/pwrsupply/csdev.py +++ b/siriuspy/siriuspy/pwrsupply/csdev.py @@ -2885,7 +2885,8 @@ def _insert_strengths(database, pstype): if 'SLRef-Mon' in database: del database['SLRef-Mon'] if pstype in ('si-corrector-fch', 'si-corrector-fcv'): - del database['KickRef-Mon'] - del database['Kick-Mon'] + if 'KickRef-Mon' in database: + del database['KickRef-Mon'] + del database['Kick-Mon'] return database From 3e3eadbe23b2fba7e9e69ead582d60250d6d5dfb Mon Sep 17 00:00:00 2001 From: Ana Clara Oliveira Date: Fri, 13 May 2022 10:45:04 -0300 Subject: [PATCH 7/8] cycle.MNT: code cleanup --- siriuspy/siriuspy/cycle/conn.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/siriuspy/siriuspy/cycle/conn.py b/siriuspy/siriuspy/cycle/conn.py index 65a39033a..e06e75574 100644 --- a/siriuspy/siriuspy/cycle/conn.py +++ b/siriuspy/siriuspy/cycle/conn.py @@ -445,8 +445,7 @@ def check_on(self): def set_current_zero(self): """Set PS current to zero .""" - status = _pv_conn_put(self['Current-SP'], 0) - return status + return _pv_conn_put(self['Current-SP'], 0) def check_current_zero(self, wait=5): """Return whether power supply PS current is zero.""" @@ -726,8 +725,7 @@ def prepare(self, _): def is_prepared(self, mode, wait=5): """Return whether power supply is ready.""" - status = self.check_current_zero(wait) - return status + return self.check_current_zero(wait) def cycle(self): """Cycle. This function may run in a thread.""" @@ -847,8 +845,7 @@ def prepare(self, _): def is_prepared(self, _, wait=5): """Return whether power supply is ready.""" - status = self.check_current_zero(wait) - return status + return self.check_current_zero(wait) def set_opmode_slowref(self): """Set OpMode to SlowRef, if needed.""" From 961be2a26a4fef60eb108a98794f14bebbede48a Mon Sep 17 00:00:00 2001 From: Ana Clara Oliveira Date: Fri, 13 May 2022 11:09:10 -0300 Subject: [PATCH 8/8] pwrsupply.MNT: simplify pstype comparison --- siriuspy/siriuspy/pwrsupply/csdev.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/siriuspy/siriuspy/pwrsupply/csdev.py b/siriuspy/siriuspy/pwrsupply/csdev.py index 39c02a64b..c2e5a7eb3 100644 --- a/siriuspy/siriuspy/pwrsupply/csdev.py +++ b/siriuspy/siriuspy/pwrsupply/csdev.py @@ -2884,7 +2884,7 @@ def _insert_strengths(database, pstype): del database['KLRef-Mon'] if 'SLRef-Mon' in database: del database['SLRef-Mon'] - if pstype in ('si-corrector-fch', 'si-corrector-fcv'): + if pstype.startswith('si-corrector-fc'): if 'KickRef-Mon' in database: del database['KickRef-Mon'] del database['Kick-Mon']