Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add settle time as property of Signal to be referenced in set method #1074

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ophyd/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand All @@ -105,6 +108,7 @@ def __init__(
metadata=None,
cl=None,
attr_name="",
settle_time=None,
):

super().__init__(
Expand All @@ -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.
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -326,6 +337,8 @@ def set(self, value, *, timeout=None, settle_time=None, **kwargs):
kwargs,
)

settle_time = settle_time or self.settle_time
maffettone marked this conversation as resolved.
Show resolved Hide resolved

def set_thread():
try:
self._set_and_wait(value, timeout, **kwargs)
Expand Down