Skip to content

Commit

Permalink
DOC: write a docstring for _get_timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ZLLentz committed Sep 8, 2023
1 parent 6a8f35c commit 6552cb3
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion typhos/positioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,44 @@ def _start_status_thread(self, status, timeout):
thread.start()

def _get_timeout(self, set_position: float, settle_time: float, rescale: float = 1) -> float | None:
"""Use positioner's configuration to select a timeout."""
"""
Use positioner's configuration to select a timeout.
This will estimate the amount of time it will take to get to the
set_position. The calculation is simplified and is intended to be
slightly greater than the true expected move duration:
move_time ~= distance/velocity + accel_time + deccel_time
*(note: we assume accel_time = deccel_time)
Which is just the trapezoidal move curve, but a little bit longer.
The timeout will be:
timeout = settle_time + rescale * move_time
A return value of ``None`` will be used if we cannot determine the
velocity, which is interpreted by ophyd as "never times out".
If we can't determine the acceleration time, we will assume it is
zero.
Parameters
----------
set_position : float
The position we'd like to move to.
settle_time : float
How long to wait on top of the calculated move time.
Note that this does not get ``rescale`` applied on top of it.
rescale : float
A scaling factor, multiplied onto the calculated move time.
This can be used to give some extra margin proportional to
the expected move time, e.g. for long moves.
Returns
-------
timeout : float or None
The timeout to use for this move, or None if a timeout could
not be calculated.
"""
pos_sig = getattr(self.device, self._readback_attr, None)
vel_sig = getattr(self.device, self._velocity_attr, None)
acc_sig = getattr(self.device, self._acceleration_attr, None)
Expand Down

0 comments on commit 6552cb3

Please sign in to comment.