From cf42119f8507995c4fbaf3410544b91a6f73d65c Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Fri, 17 Jun 2022 08:22:58 +0200 Subject: [PATCH] fix handling of persistent_field parameter 'persistent_field' parameter should be updated as long as the switch is turning off Change-Id: I76b592077ceb0a2a20beb8e6390487c620764650 --- secop_psi/magfield.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/secop_psi/magfield.py b/secop_psi/magfield.py index 2a97cb7..5a71ff4 100644 --- a/secop_psi/magfield.py +++ b/secop_psi/magfield.py @@ -114,7 +114,8 @@ class Magfield(HasLimits, Drivable): def write_target(self, target): self.check_limits(target) self.target = target - if not self._state.is_active: # as long as the state machine is still running, it takes care of changing targets + if not self._state.is_active: + # as long as the state machine is still running, it takes care of changing targets self._state.start(self.start_field_change) self.doPoll() return Done @@ -230,8 +231,6 @@ class Magfield(HasLimits, Drivable): if state.init: self.status = Status.STABILIZING, 'stabilizing field' return Retry() - if abs(self.value - state.set_point) < self.tolerance: - self.persistent_field = state.set_point return self.check_switch_off def check_switch_off(self, state): @@ -258,6 +257,7 @@ class Magfield(HasLimits, Drivable): return self.start_switch_on if self.mode == Mode.DRIVEN: return self.start_switch_on + self.persistent_field = self.value if state.now - self.switch_time < self.wait_switch_off: return Retry() return self.start_ramp_to_zero