mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2025-07-10 18:51:53 +02:00
fix: adapt SimPositioner, make tolerance changeable signal
This commit is contained in:
@ -372,7 +372,6 @@ class SimPositioner(Device, PositionerBase):
|
|||||||
delay (int) : If 0, execution of move will be instant. If 1, exectution will depend on motor velocity. Default is 1.
|
delay (int) : If 0, execution of move will be instant. If 1, exectution will depend on motor velocity. Default is 1.
|
||||||
update_frequency (int) : Frequency in Hz of the update of the simulated state during a move. Default is 2 Hz.
|
update_frequency (int) : Frequency in Hz of the update of the simulated state during a move. Default is 2 Hz.
|
||||||
precision (integer) : Precision of the readback in digits, written to .describe(). Default is 3 digits.
|
precision (integer) : Precision of the readback in digits, written to .describe(). Default is 3 digits.
|
||||||
tolerance (float) : Tolerance of the positioner to accept reaching target positions. Default is 0.5.
|
|
||||||
limits (tuple) : Tuple of the low and high limits of the positioner. Overrides low/high_limit_travel is specified. Default is None.
|
limits (tuple) : Tuple of the low and high limits of the positioner. Overrides low/high_limit_travel is specified. Default is None.
|
||||||
parent : Parent device, optional, is used internally if this signal/device is part of a larger device.
|
parent : Parent device, optional, is used internally if this signal/device is part of a larger device.
|
||||||
kind : A member the Kind IntEnum (or equivalent integer), optional. Default is Kind.normal. See Kind for options.
|
kind : A member the Kind IntEnum (or equivalent integer), optional. Default is Kind.normal. See Kind for options.
|
||||||
@ -394,6 +393,7 @@ class SimPositioner(Device, PositionerBase):
|
|||||||
# Config signals
|
# Config signals
|
||||||
velocity = Cpt(SetableSignal, value=100, kind=Kind.config)
|
velocity = Cpt(SetableSignal, value=100, kind=Kind.config)
|
||||||
acceleration = Cpt(SetableSignal, value=1, kind=Kind.config)
|
acceleration = Cpt(SetableSignal, value=1, kind=Kind.config)
|
||||||
|
tolerance = Cpt(SetableSignal, value=0.5, kind=Kind.config)
|
||||||
|
|
||||||
# Ommitted signals
|
# Ommitted signals
|
||||||
high_limit_travel = Cpt(SetableSignal, value=0, kind=Kind.omitted)
|
high_limit_travel = Cpt(SetableSignal, value=0, kind=Kind.omitted)
|
||||||
@ -411,7 +411,6 @@ class SimPositioner(Device, PositionerBase):
|
|||||||
delay: int = 1,
|
delay: int = 1,
|
||||||
update_frequency=2,
|
update_frequency=2,
|
||||||
precision=3,
|
precision=3,
|
||||||
tolerance: float = 0.5,
|
|
||||||
limits=None,
|
limits=None,
|
||||||
parent=None,
|
parent=None,
|
||||||
kind=None,
|
kind=None,
|
||||||
@ -422,7 +421,6 @@ class SimPositioner(Device, PositionerBase):
|
|||||||
self.delay = delay
|
self.delay = delay
|
||||||
self.device_manager = device_manager
|
self.device_manager = device_manager
|
||||||
self.precision = precision
|
self.precision = precision
|
||||||
self.tolerance = tolerance
|
|
||||||
self.init_sim_params = sim_init
|
self.init_sim_params = sim_init
|
||||||
self._registered_proxies = {}
|
self._registered_proxies = {}
|
||||||
|
|
||||||
@ -517,7 +515,7 @@ class SimPositioner(Device, PositionerBase):
|
|||||||
try:
|
try:
|
||||||
move_val = self._get_sim_state(
|
move_val = self._get_sim_state(
|
||||||
self.setpoint.name
|
self.setpoint.name
|
||||||
) + self.tolerance * np.random.uniform(-1, 1)
|
) + self.tolerance.get() * np.random.uniform(-1, 1)
|
||||||
|
|
||||||
updates = np.ceil(
|
updates = np.ceil(
|
||||||
np.abs(old_setpoint - move_val)
|
np.abs(old_setpoint - move_val)
|
||||||
|
@ -185,9 +185,13 @@ def test_camera_readback(camera, amplitude, noise_multiplier):
|
|||||||
def test_positioner_move(positioner):
|
def test_positioner_move(positioner):
|
||||||
"""Test the move method of SimPositioner."""
|
"""Test the move method of SimPositioner."""
|
||||||
positioner.move(0).wait()
|
positioner.move(0).wait()
|
||||||
assert np.isclose(positioner.read()[positioner.name]["value"], 0, atol=positioner.tolerance)
|
assert np.isclose(
|
||||||
|
positioner.read()[positioner.name]["value"], 0, atol=positioner.tolerance.get()
|
||||||
|
)
|
||||||
positioner.move(10).wait()
|
positioner.move(10).wait()
|
||||||
assert np.isclose(positioner.read()[positioner.name]["value"], 10, atol=positioner.tolerance)
|
assert np.isclose(
|
||||||
|
positioner.read()[positioner.name]["value"], 10, atol=positioner.tolerance.get()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("proxy_active", [True, False])
|
@pytest.mark.parametrize("proxy_active", [True, False])
|
||||||
|
Reference in New Issue
Block a user