Index: tests/test_alarms.py =================================================================== diff -u -r39cffcc77c7c0ce645325cf50cad65874b2bb096 -rc864e886bc1b52d3a43f03c507425248c44a913f --- tests/test_alarms.py (.../test_alarms.py) (revision 39cffcc77c7c0ce645325cf50cad65874b2bb096) +++ tests/test_alarms.py (.../test_alarms.py) (revision c864e886bc1b52d3a43f03c507425248c44a913f) @@ -17,7 +17,9 @@ sys.path.append("..") from dialin.hd.hemodialysis_device import HD from dialin.utils.base import AbstractObserver -import time +from dialin.ui.hd_simulator import HDSimulator +from dialin.common.alarm_defs import AlarmList +from time import time, sleep class Observer(AbstractObserver): @@ -33,6 +35,7 @@ def check_something(self): pass + def test_disable_all_hd_alarms(): """ Disables all hd alarms @@ -42,12 +45,13 @@ if hd.cmd_log_in_to_hd(): hd.ui.cmd_ui_request_hd_version() - time.sleep(0.5) + sleep(0.5) print(f"Current HD version: {hd.ui.hd_version}") for desc, val in hd.alarms.ids.items(): hd.alarms.cmd_alarm_state_override(0, val) - time.sleep(0.5) + sleep(0.5) + def test_hd_alarms(): """ Simulates all HD alarms @@ -86,23 +90,44 @@ if hd.cmd_log_in_to_hd(): hd.ui.cmd_ui_request_hd_version() - time.sleep(0.5) + sleep(0.5) print(f"Current HD version: {hd.ui.hd_version}") for desc, val in hd.alarms.ids.items(): if desc in alarm_faults: print("Skipping {0}".format(desc)) continue print("Testing {0} = {1}".format(val.name, val.value)) success = hd.alarms.cmd_alarm_state_override(1, val.value) - time.sleep(3) + sleep(3) if not success: raise ValueError("Failed to activate alarm {0} = {1}".format(desc, val)) success = hd.alarms.cmd_alarm_state_override(0, val.value) if not success: raise ValueError("Failed to deactivate alarm {0} = {1}".format(desc, val)) - time.sleep(2) + sleep(2) +def test_clear_alarms(): + hd_sim = HDSimulator() + hd_sim.alarms_simulator.cmd_send_clear_alarms() + sleep(3) + hd_sim.alarms_simulator.cmd_activate_alarm(alarm=AlarmList.ALARM_ID_BLOOD_PUMP_MOTOR_SPEED_CHECK) + sleep(3) + hd_sim.alarms_simulator.cmd_send_clear_alarms() + sleep(1) + + +def test_repeated_alarm(): + hd_sim = HDSimulator(log_level="DEBUG") + hd_sim.alarms_simulator.cmd_send_clear_alarms() + sleep(2) + flags = hd_sim.alarms_simulator.cmd_make_alarm_flags(alarms_silenced=0, + user_acknowledge=0) + hd_sim.alarms_simulator.set_flags(flags) + hd_sim.alarms_simulator.cmd_repeat_broadcast_alarm(alarm=AlarmList.ALARM_ID_BLOOD_PUMP_MOTOR_SPEED_CHECK, + state=1, + timeout=20) + + if __name__ == '__main__': - # test_disable_all_hd_alarms() - test_hd_alarms() + test_repeated_alarm()