def test_match_condition_success_no_stop(RE, mot_and_sig): logger.debug("test_match_condition_success_no_stop") mot, sig = mot_and_sig mot.delay = 0 # Delay has no purpose if we aren't going to stop def condition(x): if 5 < x < 7: return True elif 10 < x < 16: return True return False RE(run_wrapper(match_condition(sig, condition, mot, 20, has_stop=False))) assert 12 < mot.position < 14 # Motor should end in the middle of the largest True region mot.move(0, wait=True) def condition(x): return 10 < x < 16 RE(run_wrapper(match_condition(sig, condition, mot, 20, has_stop=False))) assert 12 < mot.position < 14 mot.move(0, wait=True) def condition(x): return x > 10 RE(run_wrapper(match_condition(sig, condition, mot, 20, has_stop=False))) assert 14 < mot.position < 16
def test_match_condition_fail_no_stop(RE, mot_and_sig): logger.debug("test_match_condition_fail_no_stop") mot, sig = mot_and_sig mot.delay = 0 RE(run_wrapper(match_condition(sig, lambda x: x > 50, mot, 40, has_stop=False))) assert mot.position == 40
def test_match_condition_success(RE, mot_and_sig): logger.debug("test_match_condition_success") mot, sig = mot_and_sig RE(run_wrapper(match_condition(sig, lambda x: x > 10, mot, 20))) assert mot.position < 11
def test_match_condition_timeout(RE, mot_and_sig): logger.debug("test_match_condition_timeout") mot, sig = mot_and_sig RE(run_wrapper(match_condition(sig, lambda x: x > 9, mot, 5, timeout=0.3))) assert mot.position < 5
def test_match_condition_fail(RE, mot_and_sig): logger.debug("test_match_condition_fail") mot, sig = mot_and_sig RE(run_wrapper(match_condition(sig, lambda x: x > 50, mot, 40))) assert mot.position == 40