########################################################################### # # Copyright (c) 2021-2024 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file test_ui_proxy.py # # @author (last) Peter Lucia # @date (last) 21-May-2021 # @author (original) Peter Lucia # @date (original) 29-Apr-2021 # ############################################################################ import sys sys.path.append("../../") from dialin.hd.hemodialysis_device import HD from time import sleep from dialin.utils.base import AbstractObserver IP_ADDRESS = "192.168.10.77" class Observer(AbstractObserver): def __init__(self): self.valid = False def update(self, message): print(message) self.valid = message.get("treatment_parameters_valid", False) def test_create_treatment(): hd = HD(log_level="DEBUG") hd.cmd_hd_software_reset_request() observer = Observer() hd.ui.attach(observer) sleep(1) if hd.cmd_log_in_to_hd(): sleep(10) print("Logged in") hd.ui.cmd_ui_start_treatment_request(0) sleep(4) hd.ui.cmd_set_treatment_parameters(100, 100, 120, 0, 0, 0, 100, 1, 0, 1, 36, -200, -170, -100, 100, 30, 75) while not observer.valid: sleep(0.1) hd.ui.cmd_ui_confirm_treatment_parameters() sleep(4) hd.ui.cmd_ui_start_treatment_request(2) sleep(4) def test_reset_hd(): hd = HD(log_level="DEBUG") hd.cmd_hd_software_reset_request() def test_get_hd_operation_mode(): hd = HD(log_level="DEBUG") observer = Observer() hd.ui.attach(observer) if hd.cmd_log_in_to_hd(): sleep(5) print(hd.get_operation_mode()) def test_clear_all_alarms(): hd = HD(log_level="DEBUG") hd.alarms.cmd_clear_all_alarms() if __name__ == '__main__': # test_reset_hd() # test_create_treatment() test_clear_all_alarms() # test_get_hd_operation_mode()