From b36932b6e0afcd20b25aeb3d17452909f217264d Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Thu, 15 Feb 2024 14:58:21 -0500 Subject: [PATCH 1/2] Add two new kwargs to ADTriggerStatus __init__, to allow for using different signals than default AD --- ophyd/areadetector/trigger_mixins.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ophyd/areadetector/trigger_mixins.py b/ophyd/areadetector/trigger_mixins.py index a695b0904..36ab8b2fb 100644 --- a/ophyd/areadetector/trigger_mixins.py +++ b/ophyd/areadetector/trigger_mixins.py @@ -27,18 +27,29 @@ class ADTriggerStatus(DeviceStatus): based on comparing device.cam.array_counter to device.cam.num_images. """ - def __init__(self, *args, **kwargs): + def __init__(self, *args, counter_signal = None, target_signal = None, **kwargs): super().__init__(*args, **kwargs) self.start_ts = ttime.time() + # Provide option to override which signals are watched to specify a "done" condition + self.counter_signal = counter_signal + self.target_signal = target_signal + + # If not specified, just use the default array counter and num images signals. + if counter_signal is None: + self.counter_signal = self.device.cam.array_counter + + if target_signal is None: + self.target_signal = self.device.cam.num_images + # Notify watchers (things like progress bars) of new values # at the device's natural update rate. if not self.done: - self.device.cam.array_counter.subscribe(self._notify_watchers) + self.counter_signal.subscribe(self._notify_watchers) # some state needed only by self._notify_watchers self._name = self.device.name - self._initial_count = self.device.cam.array_counter.get() - self._target_count = self.device.cam.num_images.get() + self._initial_count = self.counter_signal.get() + self._target_count = self.target_signal.get() def watch(self, func): self._watchers.append(func) @@ -46,7 +57,7 @@ def watch(self, func): def _notify_watchers(self, value, *args, **kwargs): # *args and **kwargs catch extra inputs from pyepics, not needed here if self.done: - self.device.cam.array_counter.clear_sub(self._notify_watchers) + self.counter_signal.clear_sub(self._notify_watchers) if not self._watchers: return # Always start progress bar at 0 regardless of starting value of From 7e5e723594dff93027bd8ac7cc22e7bb41c774ea Mon Sep 17 00:00:00 2001 From: Jakub Wlodek Date: Fri, 22 Mar 2024 10:11:50 -0400 Subject: [PATCH 2/2] Update docstring for ADTriggerStatus --- ophyd/areadetector/trigger_mixins.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ophyd/areadetector/trigger_mixins.py b/ophyd/areadetector/trigger_mixins.py index 36ab8b2fb..8138eb0b1 100644 --- a/ophyd/areadetector/trigger_mixins.py +++ b/ophyd/areadetector/trigger_mixins.py @@ -24,7 +24,12 @@ class ADTriggerStatus(DeviceStatus): A Status for AreaDetector triggers A special status object that notifies watches (progress bars) - based on comparing device.cam.array_counter to device.cam.num_images. + based on comparing the two signal values counter_signal and + target_signal passed to the object instance at __init__. Once the + value of counter_signal reaches target_signal, the operation is considered done. + If these two signals are passed in as None or not passed in at all (default), + then the standard device.cam.array_counter signal is used as the + progress indicator, and device.cam.num_images is used as the target. """ def __init__(self, *args, counter_signal = None, target_signal = None, **kwargs):