From 99a0876421ff2df5e69d84eb7f7dfb37ded0ce52 Mon Sep 17 00:00:00 2001 From: Mathias Sander Date: Sun, 30 Jun 2024 23:10:53 +0200 Subject: [PATCH] am --- eco/acquisition/scan.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/eco/acquisition/scan.py b/eco/acquisition/scan.py index 1c1ffc8..200e6ae 100755 --- a/eco/acquisition/scan.py +++ b/eco/acquisition/scan.py @@ -11,7 +11,7 @@ from IPython import get_ipython from .daq_client import Daq from eco.elements.assembly import Assembly from rich.progress import Progress - +import inputimeout inval_chars = [" ", "/"] ScanNameError = Exception( @@ -37,8 +37,7 @@ class RunList(Assembly): super().__init__(name=name) self.scan_info_dir = scan_info_dir - def get_run_list(self): - ... + def get_run_list(self): ... class Scan: @@ -126,7 +125,7 @@ class Scan: for caller in callbacks_start_scan: caller(self, **self.callbacks_kwargs) for ctr in self.counterCallers: - if hasattr(ctr,'callbacks_start_scan') and ctr.callbacks_start_scan: + if hasattr(ctr, "callbacks_start_scan") and ctr.callbacks_start_scan: for tcb in ctr.callbacks_start_scan: tcb() @@ -296,11 +295,34 @@ class Scan: print("Changing back to value(s) before scan.") for ch in chs: ch.wait() + elif self.return_at_end == "timeout": + timeout = 10 + try: + o = inputimeout.inputimeout( + prompt=f"Change back to initial values? (y/n) Changing back in {timeout} seconds.", + timeout=timeout, + ) + except inputimeout.TimeoutOccurred: + chs = self.changeToInitialValues() + print("Changing back to value(s) before scan.") + for ch in chs: + ch.wait() + except KeyboardInterrupt: + raise Exception("User-requested cancelling!") + else: + if o == "y": + chs = self.changeToInitialValues() + print("Changing back to value(s) before scan.") + for ch in chs: + ch.wait() + if o == "n": + print("Staying at final scan value(s)!") elif self.return_at_end: chs = self.changeToInitialValues() print("Changing back to value(s) before scan.") for ch in chs: ch.wait() + else: print("Staying at final scan value(s)!")