diff --git a/ophyd/signal.py b/ophyd/signal.py index 755c4c08a..a06acbda5 100644 --- a/ophyd/signal.py +++ b/ophyd/signal.py @@ -79,6 +79,9 @@ class Signal(OphydObject): Control Layer. Must provide 'get_pv' and 'thread_class' attr_name : str, optional The parent Device attribute name that corresponds to this Signal + settle_time : float, optional + The amount of time to wait after setting the signal to report status + completion. Attributes ---------- @@ -105,6 +108,7 @@ def __init__( metadata=None, cl=None, attr_name="", + settle_time=None, ): super().__init__( @@ -127,6 +131,7 @@ def __init__( self._tolerance = tolerance # self.tolerance is a property self.rtolerance = rtolerance + self._settle_time = settle_time # Signal defaults to being connected, with full read/write access. # Subclasses are expected to clear these on init, if applicable. @@ -183,6 +188,12 @@ def tolerance(self): def tolerance(self, tolerance): self._tolerance = tolerance + @property + def settle_time(self): + """The amount of time to wait after setting the signal to report status + completion.""" + return self._settle_time + def _repr_info(self): "Yields pairs of (key, value) to generate the Signal repr" yield from super()._repr_info() @@ -326,6 +337,8 @@ def set(self, value, *, timeout=None, settle_time=None, **kwargs): kwargs, ) + settle_time = settle_time if settle_time is not None else self.settle_time + def set_thread(): try: self._set_and_wait(value, timeout, **kwargs) diff --git a/ophyd/tests/test_signal.py b/ophyd/tests/test_signal.py index f56e9d4cf..96dd6a58d 100644 --- a/ophyd/tests/test_signal.py +++ b/ophyd/tests/test_signal.py @@ -413,6 +413,18 @@ def test_set_method(): assert sig.get() == 28 +def test_settle_time(): + sig = Signal(name="sig", settle_time=0.5) + start = time.monotonic() + st = sig.set(34) + wait(st) + finish = time.monotonic() + assert finish - start > 0.5 + assert st.done + assert st.success + assert sig.get() == 34 + + def test_soft_derived(): timestamp = 1.0 value = "q"