Files
motorDriverTests/tests/sinqMotor/limits.py

30 lines
1.0 KiB
Python
Executable File

import time
import math
from test_helpers import read_config
def reread_limits_from_hw(motor):
"""
sinqMotor drivers usually read their limits from the hardware at each poll,
hence any values manually written to DHLM or DLLM should be overwritten
after the next poll at latest
"""
(high_limit, low_limit) = motor.limits()
motor.write_field('dialhighlimit', high_limit+10)
motor.write_field('diallowlimit', low_limit-10)
# Wait two idle poll periods
time.sleep(2 * motor.idlepoll)
# Values should have been reread
assert math.isclose(motor.read_field('highlimit'),
high_limit, rel_tol=1e-9, abs_tol=0.001)
assert math.isclose(motor.read_field('lowlimit'),
low_limit, rel_tol=1e-9, abs_tol=0.001)
assert math.isclose(motor.read_field('dialhighlimit'),
high_limit, rel_tol=1e-9, abs_tol=0.001)
assert math.isclose(motor.read_field('diallowlimit'),
low_limit, rel_tol=1e-9, abs_tol=0.001)