From 67bd917e5b964e157e7cbe2e47d9550be0ce88be Mon Sep 17 00:00:00 2001 From: anacso17 Date: Tue, 18 Feb 2020 17:03:26 -0300 Subject: [PATCH 1/3] cycle.MNT: remove BO --- siriuspy/siriuspy/cycle/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/siriuspy/siriuspy/cycle/util.py b/siriuspy/siriuspy/cycle/util.py index fb3f4cab7..8190e04e2 100644 --- a/siriuspy/siriuspy/cycle/util.py +++ b/siriuspy/siriuspy/cycle/util.py @@ -18,7 +18,7 @@ def get_psnames(): """Return psnames.""" - names = _PSSearch.get_psnames({'sec': '(LI|TB|BO|TS)', 'dis': 'PS'}) + names = _PSSearch.get_psnames({'sec': '(LI|TB|TS)', 'dis': 'PS'}) names.extend(_PSSearch.get_psnames( {'sec': 'SI', 'sub': 'Fam', 'dis': 'PS', 'dev': '(B|Q.*|S.*)'})) names.extend(_PSSearch.get_psnames( From 1133e649d3c6303b9a318191735c934838f0daae Mon Sep 17 00:00:00 2001 From: anacso17 Date: Tue, 18 Feb 2020 17:04:35 -0300 Subject: [PATCH 2/3] cycle.FIX: fix order in checking final state --- siriuspy/siriuspy/cycle/conn.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/siriuspy/siriuspy/cycle/conn.py b/siriuspy/siriuspy/cycle/conn.py index 9471fb6dc..b2a5fff0c 100644 --- a/siriuspy/siriuspy/cycle/conn.py +++ b/siriuspy/siriuspy/cycle/conn.py @@ -379,7 +379,6 @@ def check_on(self): def set_current_zero(self): """Set PS current to zero .""" status = _pv_conn_put(self['Current-SP'], 0) - _time.sleep(SLEEP_CAPUT) return status def check_current_zero(self, wait=5): @@ -503,15 +502,15 @@ def check_final_state(self, mode): if not status: return 3 # indicate cycling not finished yet + status = self.check_intlks() + if not status: + return 4 # indicate interlock problems + status = self.set_opmode_slowref() status &= self.check_opmode_slowref() if not status: return 2 # indicate opmode is not in slowref yet - status = self.check_intlks() - if not status: - return 4 # indicate interlock problems - return 0 def __getitem__(self, prop): From dfdb8e3116db040db0aa8bf86775e3b49ffa6e93 Mon Sep 17 00:00:00 2001 From: anacso17 Date: Tue, 18 Feb 2020 17:06:02 -0300 Subject: [PATCH 3/3] cycle.ENH: change CycleController to set all SI PS current to zero in prepare_ps_parameters --- siriuspy/siriuspy/cycle/main.py | 68 +++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/siriuspy/siriuspy/cycle/main.py b/siriuspy/siriuspy/cycle/main.py index 7a05c13d0..6589c5a04 100644 --- a/siriuspy/siriuspy/cycle/main.py +++ b/siriuspy/siriuspy/cycle/main.py @@ -16,6 +16,7 @@ TIMEOUT_SLEEP = 0.1 TIMEOUT_CHECK = 20 TIMEOUT_CONN = 0.5 +TIMEOUT_CHECK_SI_CURRENTS = 41 class CycleController: @@ -65,6 +66,11 @@ def __init__(self, cyclers=dict(), timing=None, self.prepare_ps_size = 2*len(self.psnames)+1 self.prepare_ps_max_duration = 20 + if 'SI' in self._sections: + # set and check currents to zero + self.prepare_ps_size += 3*len(self.psnames) + self.prepare_ps_max_duration += \ + TIMEOUT_CHECK + TIMEOUT_CHECK_SI_CURRENTS self.cycle_size = (len(self.psnames)+3 + # check params len(self.psnames) + # check opmode @@ -72,12 +78,12 @@ def __init__(self, cyclers=dict(), timing=None, len(self.psnames) + # check final len(self.psnames)+2) # reset subsystems self.cycle_max_duration = ( - 2 + # check params - 2 + # check opmode + 5 + # check params + 5 + # check opmode TIMEOUT_CHECK*3 + # wait for timing trigger round(self._cycle_duration) + # cycle - 2 + # check final - 2) # reset subsystems + 5 + # check final + 5) # reset subsystems # logger self._logger = logger @@ -97,6 +103,59 @@ def mode(self): """Mode.""" return self._mode + def set_check_si_pwrsupplies_currents_zero(self): + """Zero currents of all SI power supplies.""" + if 'SI' not in self._sections: + return + + psnames = _PSSearch.get_psnames( + {'sec': 'SI', 'dis': 'PS', 'dev': '(B|Q|S|CH|CV)'}) + + # create cyclers, if needed + cyclers = dict() + for psname in psnames: + if psname in self.cyclers: + cyclers[psname] = self.cyclers[psname] + else: + self._update_log('Connecting to '+psname+'...') + cyclers[psname] = PSCycler(psname) + + # wait for connections + for cycler in cyclers.values(): + cycler.wait_for_connection() + + # set currents to zero + for psname, cycler in cyclers.items(): + self._update_log('Setting '+psname+' current to zero...') + cycler.set_current_zero() + + # check currents zero + need_check = _dcopy(psnames) + self._checks_result = dict() + t = _time.time() + while _time.time() - t < TIMEOUT_CHECK_SI_CURRENTS: + for psname in psnames: + if psname not in need_check: + continue + if cyclers[psname].check_current_zero(): + need_check.remove(psname) + self._checks_result[psname] = True + if not need_check: + break + _time.sleep(TIMEOUT_SLEEP) + for psname in need_check: + self._checks_result[psname] = False + + status = True + for psname in psnames: + self._update_log('Checking '+psname+' currents...') + if self._checks_result[psname]: + self._update_log(done=True) + else: + self._update_log(psname+' current is not zero.', error=True) + status &= False + return status + def config_all_pwrsupplies(self, ppty): """Prepare power supplies to cycle according to mode.""" if ppty == 'opmode': @@ -323,6 +382,7 @@ def prepare_timing(self): def prepare_pwrsupplies_parameters(self): """Prepare to cycle.""" + self.set_check_si_pwrsupplies_currents_zero() self.config_all_pwrsupplies('parameters') if not self.check_all_pwrsupplies('parameters'): self._update_log(