########################################################################### # # 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_demo.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.dg.dialysate_generator import DG from dialin.hd.hemodialysis_device import HD from dialin.hd.constants import RESET, NO_RESET, BUTTON_PRESSED, BUTTON_RELEASED from dialin.utils.base import find_variables_in_object import time def test_dg_version(): """ Prints the DG version. @return: None """ dg = DG() if dg.cmd_log_in_to_dg(): dg.cmd_ui_request_dg_version() time.sleep(0.5) print(dg.dg_version) print(dg.fpga_version) def test_hd_version(): """ Prints the HD version. @return: None """ hd = HD(log_level="DEBUG") if hd.cmd_log_in_to_hd(): hd.ui.cmd_ui_request_hd_version() time.sleep(0.5) print(f"Current HD version: {hd.ui.hd_version}") print(f"Current HD FPGA version: {hd.ui.fpga_version}") def test_hd_off_button(): """ Simulates pressing the off button @return: None """ hd = HD() if hd.cmd_log_in_to_hd(): # reset previous override hd.buttons.cmd_off_button_override(BUTTON_PRESSED, RESET) # simulate off button pressed hd.buttons.cmd_off_button_override(BUTTON_PRESSED, NO_RESET) def test_hd_blood_flow(ml_per_min=110): """ Sets the HD blood flow rate (mL / min) @return: None """ hd = HD() if hd.cmd_log_in_to_hd(): hd.bloodflow.cmd_blood_flow_set_point_override(0, RESET) hd.bloodflow.cmd_blood_flow_set_point_override(ml_per_min, NO_RESET) while True: print("measured blood flow rate: {0}".format(hd.bloodflow.measured_blood_flow_rate)) time.sleep(0.5) def test_stop_hd_blood_flow(): """ Stops the HD blood flow @return: None """ hd = HD() if hd.cmd_log_in_to_hd(): hd.bloodflow.cmd_blood_flow_set_point_override(0, NO_RESET) def test_dialin_version(): import dialin print(dialin.__version__) def test_valves(): dg = DG() if dg.cmd_log_in_to_dg(): print(dg.valves.get_valve_states()) for valve_id in range(0, 13): dg.valves.cmd_valve_override(False, valve_id, RESET) for valve_id in range(0, 13): if valve_id % 2 == 0: dg.valves.cmd_valve_override(True, valve_id, NO_RESET) else: dg.valves.cmd_valve_override(False, valve_id, RESET) print("Sleeping...") time.sleep(5) print(dg.valves.get_valve_states()) def test_reverse_lookup(): hd = HD() print(find_variables_in_object(hd.ui, 2, "REQUEST_")) if __name__ == '__main__': test_hd_version() # test_dg_version()