Files
motorDriverTests/tests/sinqMotor/limits.py

27 lines
1015 B
Python

import time
import math
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)
# After two seconds, at least one poll has been done
time.sleep(2)
# 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)