32 lines
916 B
Python
32 lines
916 B
Python
import time
|
|
|
|
def reset(motor, initpos=0):
|
|
"""
|
|
Reset the motor for the next test. This means the following things:
|
|
1) Stopping the motor
|
|
2) Resetting all errors
|
|
3) Enabling the motor
|
|
4) Moving to zero
|
|
"""
|
|
|
|
# motor.write_field('stop', 1)
|
|
|
|
# Reset any errors
|
|
motor.write_field('reseterrorpv', 1)
|
|
|
|
# The reset may take some time -> Wait a bit
|
|
time.sleep(1)
|
|
|
|
if motor.read_field('enable_rbv') == 0:
|
|
motor.write_field('enable', 1)
|
|
|
|
# Wait until the motor is enabled.
|
|
now = time.time()
|
|
max_enable_time = 5
|
|
while motor.read_field('enable_rbv') == 0:
|
|
# Wait a maximum of max_enable_time seconds until enabling
|
|
if time.time() > now + max_enable_time:
|
|
pytest.fail(f'Motor {self.pv} could not be enabled in {max_enable_time} seconds')
|
|
time.sleep(0.1)
|
|
|
|
motor.move_and_wait(initpos) |