diff --git a/siriuspy/siriuspy/VERSION b/siriuspy/siriuspy/VERSION index 22f0bcedd..616b45fd9 100644 --- a/siriuspy/siriuspy/VERSION +++ b/siriuspy/siriuspy/VERSION @@ -1 +1 @@ -2.91.0 +2.92.0 diff --git a/siriuspy/siriuspy/devices/rf.py b/siriuspy/siriuspy/devices/rf.py index 529f1c484..d5a009f03 100644 --- a/siriuspy/siriuspy/devices/rf.py +++ b/siriuspy/siriuspy/devices/rf.py @@ -1335,53 +1335,29 @@ def set_frequency(self, value, timeout=10, tol=0.05): return self.dev_rfgen.set_frequency(value, tol=tol, timeout=timeout) -class RFKillBeam(_SILLRF): +class RFKillBeam(_DeviceSet): """RF Kill Beam Button.""" - TIMEOUT_WAIT = 20.0 # [s] - INCRATE_VALUE = ASLLRF.VoltIncRates.vel_50p0 # [mV/s] - REFMIN_VALUE = 60 # Minimum Amplitude Reference [mV] + TIMEOUT_WAIT = 10 # [s] def __init__(self): """Init.""" - super().__init__(ASLLRF.DEVICES.SIA) + props2init = ASLLRF.PROPERTIES_INTERLOCK + si_a = ASLLRF(devname=ASLLRF.DEVICES.SIA, props2init=props2init) + si_b = ASLLRF(devname=ASLLRF.DEVICES.SIB, props2init=props2init) + devs = [si_a, si_b] + super().__init__(devices=devs, devname='SI-Glob:RF-KillBeam') def cmd_kill_beam(self): """Kill beam.""" if not self.wait_for_connection(self.TIMEOUT_WAIT): return [False, 'Could not read RF PVs.'] - # get initial values - amp_incrate_init = self.voltage_incrate - amp_init = self.voltage - - # set Amplitude Increase Rate to 50 mV/s and wait - self.voltage_incrate = self.INCRATE_VALUE - if not self._wait( - 'AmpIncRate-RB', self.INCRATE_VALUE, - timeout=self.TIMEOUT_WAIT): - return [False, 'Could not set RF Amplitude Increase Rate.'] - - # set Amplitude Reference to 60mV and wait - self.voltage = self.REFMIN_VALUE - if not self._wait_float( - 'SLInpAmp-Mon', self.REFMIN_VALUE, abs_tol=1, - timeout=self.TIMEOUT_WAIT): - return [False, 'Could not set RF Voltage to low value.'] - - # set Amplitude Reference to initial value - self.voltage = amp_init - if not self._wait_float( - 'SLInpAmp-Mon', amp_init, - abs_tol=1, timeout=self.TIMEOUT_WAIT): - return [False, 'Could not set RF Voltage back to original value.'] - - # set Amplitude Increase Rate to initial value - self.voltage_incrate = amp_incrate_init - if not self._wait( - 'AmpIncRate-RB', self.INCRATE_VALUE, - timeout=self.TIMEOUT_WAIT): - return [False, 'Could not set RF Amplitude Increase Rate back.'] + for llrf in self.devices: + llrf.interlock_manual = 1 + _time.sleep(1) + for llrf in self.devices: + llrf.interlock_manual = 0 return [True, ''] diff --git a/siriuspy/siriuspy/injctrl/main.py b/siriuspy/siriuspy/injctrl/main.py index 641714470..04619bca8 100644 --- a/siriuspy/siriuspy/injctrl/main.py +++ b/siriuspy/siriuspy/injctrl/main.py @@ -88,6 +88,7 @@ def __init__(self): self._topup_nrpulses = 1 self._topup_job = None self._accum_job = None + self._stop_topup_job = None self._abort = False self._setting_mode = False @@ -192,6 +193,9 @@ def __init__(self): curr_pvo = self.currinfo_dev.pv_object('Current-Mon') curr_pvo.add_callback(self._callback_autostop) curr_pvo.connection_callbacks.append(self._callback_conn_autostop) + self.currinfo_dev.set_auto_monitor('StoredEBeam-Mon', True) + stored_pvo = self.currinfo_dev.pv_object('StoredEBeam-Mon') + stored_pvo.add_callback(self._callback_havebeam) self._pu_names, self._pu_devs = list(), list() self._pu_refvolt = list() @@ -1174,6 +1178,21 @@ def _thread_is_injecting(self): _time.sleep(self._isinj_duration/1000) self.run_callbacks('IsInjecting-Mon', _Const.IdleInjecting.Idle) + def _callback_havebeam(self, value, **kws): + if value: + return + if self._mode != _Const.InjMode.TopUp: + return + if self._stop_topup_job is not None and \ + self._stop_topup_job.is_alive(): + return + if self._topup_state_sts != _Const.TopUpSts.Off: + self._update_log('FATAL:We do not have stored beam!') + self._update_log('FATAL:Opening TopUp loop...') + self._stop_topup_job = _epics.ca.CAThread( + target=self.set_topup_state, args=[_Const.OffOn.Off, ], daemon=True) + self._stop_topup_job.start() + # --- auxiliary injection methods --- def _check_allok_2_inject(self, show_warn=True):