import time import math from setup.classes 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.put_pv('dialhighlimit', high_limit+10) motor.put_pv('diallowlimit', low_limit-10) # Wait two idle poll periods time.sleep(2 * motor.idlepoll) # Values should have been reread assert math.isclose(motor.get_pv('highlimit'), high_limit, rel_tol=1e-9, abs_tol=0.001) assert math.isclose(motor.get_pv('lowlimit'), low_limit, rel_tol=1e-9, abs_tol=0.001) assert math.isclose(motor.get_pv('dialhighlimit'), high_limit, rel_tol=1e-9, abs_tol=0.001) assert math.isclose(motor.get_pv('diallowlimit'), low_limit, rel_tol=1e-9, abs_tol=0.001)