Added disable delay to test

This commit is contained in:
2025-07-24 09:04:49 +02:00
parent 40fc5b7ca1
commit 10bf2cc5d3

View File

@@ -1,10 +1,22 @@
import time import time
import pytest import pytest
def stop_reset_enable_move_sequence(motor, target): def stop_reset_enable_move_sequence(motor, target):
motor.write_field('stop', 1) motor.write_field('stop', 1)
motor.write_field('reseterrorpv', 1) motor.write_field('reseterrorpv', 1)
# Wait until the motor is disabled.
now = time.time()
max_enable_time = 10
while motor.read_field('enable_rbv') == 1:
# Wait a maximum of max_enable_time seconds until enabling
if time.time() > now + max_enable_time:
pytest.fail(
f'Motor {motor.pv} could not be stopped and resetted in {max_enable_time} seconds')
time.sleep(0.1)
motor.write_field('enable', 1) motor.write_field('enable', 1)
# Wait until the motor is enabled. # Wait until the motor is enabled.
@@ -13,9 +25,10 @@ def stop_reset_enable_move_sequence(motor, target):
while motor.read_field('enable_rbv') == 0: while motor.read_field('enable_rbv') == 0:
# Wait a maximum of max_enable_time seconds until enabling # Wait a maximum of max_enable_time seconds until enabling
if time.time() > now + max_enable_time: if time.time() > now + max_enable_time:
pytest.fail(f'Motor {self.pv} could not be enabled in {max_enable_time} seconds') pytest.fail(
f'Motor {motor.pv} could not be enabled in {max_enable_time} seconds')
time.sleep(0.1) time.sleep(0.1)
motor.move_and_wait(target) motor.move_and_wait(target)
assert motor.at_target(target) assert motor.at_target(target)
assert not motor.has_error() assert not motor.has_error()