From b29b1e1b369748434a1b0cb9cd08efa5e0f35f1e Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Wed, 17 Nov 2021 13:20:13 +0100 Subject: [PATCH] entangle.AnalogOutput: fix window mechanism fix 2 problems: - in case the window is smaller than the pollinterval, isAtTarget might be False for up to the timeout delay - in case the history is shorter than the window, and the ramp is fast enough to miss any points during ramp, isAtTarget is True before the window time is reached. This happens because the history is reset on write_target + do not wait when target is not changed (by more than precision) tested! Change-Id: Ia4ff4378fe91fa93be50168b2883a20b49ebfb6a Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27159 Reviewed-by: Markus Zolliker Reviewed-by: Enrico Faulhaber Tested-by: Jenkins Automated Tests --- secop_mlz/entangle.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/secop_mlz/entangle.py b/secop_mlz/entangle.py index 02abcd8..51dbd39 100644 --- a/secop_mlz/entangle.py +++ b/secop_mlz/entangle.py @@ -492,8 +492,11 @@ class AnalogOutput(PyTangoDevice, Drivable): hist = self._history[:] window_start = currenttime() - self.window hist_in_window = [v for (t, v) in hist if t >= window_start] + if len(hist) == len(hist_in_window): + return False # no data point before window if not hist_in_window: - return False # no relevant history -> no knowledge + # window is too small -> use last point only + hist_in_window = [self.value] max_in_hist = max(hist_in_window) min_in_hist = min(hist_in_window) @@ -574,7 +577,9 @@ class AnalogOutput(PyTangoDevice, Drivable): if not self.timeout: self._timeout = None self._moving = True - self._history = [] # clear history + # do not clear the history here: + # - if the target is not changed by more than precision, there is no need to wait + # self._history = [] self.read_status() # poll our status to keep it updated return self.read_target()