Skip to content

Commit

Permalink
Add two new kwargs to ADTriggerStatus __init__, to allow for using di…
Browse files Browse the repository at this point in the history
…fferent signals than default AD
  • Loading branch information
jwlodek authored and tacaswell committed Apr 16, 2024
1 parent 5c03c3f commit b36932b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions ophyd/areadetector/trigger_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,37 @@ 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)

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
Expand Down

0 comments on commit b36932b

Please sign in to comment.