DAQ: tidy up my_motor.p
This commit is contained in:
@@ -4,6 +4,7 @@ from epics import Motor
|
||||
|
||||
|
||||
class MyMotor(Motor):
|
||||
"""Wrapper for the EPICS motor PV."""
|
||||
def __init__(self, name, timeout=5.0):
|
||||
super().__init__(name.upper(), timeout=timeout)
|
||||
|
||||
@@ -99,34 +100,3 @@ class MyMotor(Motor):
|
||||
await asyncio.sleep(poll_rate)
|
||||
if time.time() - start_time > timeout:
|
||||
raise RuntimeError(f"Timeout waiting for motor {self.name} to stop")
|
||||
|
||||
# def pv_wait(pv: Union[PV, Motor], target: Union[str, int, float], timeout: float = 30.0,
|
||||
# polling: float = 0.1, tolerance: float | None = None):
|
||||
# """
|
||||
# Unified wait function for Motors and PVs (Strings, Enums, Floats).
|
||||
# """
|
||||
# start_time = time.monotonic()
|
||||
# end_time = start_time + timeout
|
||||
#
|
||||
# # Handle Motors
|
||||
# if isinstance(pv, Motor):
|
||||
# if tolerance is None:
|
||||
# # Try to get the motor resolution/deadband
|
||||
# tolerance = pv.get("RDBD") or 0.01
|
||||
#
|
||||
# while time.monotonic() < end_time:
|
||||
# if pv.done_moving and abs(pv.readback - target) <= tolerance:
|
||||
# return
|
||||
#
|
||||
# raise ValueWaitTimeout(
|
||||
# f"Motor {pv.name} timeout. Target: {target}, Current: {pv.readback}, Done: {pv.done_moving}"
|
||||
# )
|
||||
#
|
||||
# def wait_for_movement_to_finish(*motors: Motor, timeout: float = 60.0):
|
||||
# """Wait for a group of motors to stop moving."""
|
||||
# start_time = time.time()
|
||||
# while not all(m.done_moving for m in motors):
|
||||
# if time.time() - start_time > timeout:
|
||||
# moving = [m.name for m in motors if not m.done_moving]
|
||||
# raise TimeoutError(f"Timeout waiting for motors: {', '.join(moving)}")
|
||||
# poll(0.1)
|
||||
Reference in New Issue
Block a user