Files
motorDriverTests/tests/sinqMotor/turboPmac/reset.py

35 lines
919 B
Python
Executable File

import time
import pytest
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)
time.sleep(2*motor.idlepoll)
if motor.read_field('enable_rbv') == 0:
motor.write_field('enable', 1)
# Wait until the motor is enabled.
now = time.time()
max_enable_time = 10
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 {motor.pv} could not be enabled in {max_enable_time} seconds')
time.sleep(0.1)
motor.move_and_wait(initpos)