Index: HD/HD_TestScript.py =================================================================== diff -u -r0da0106eca868b9144298c60911710b3414a5837 -rc652777ecb913a96a3bd61ca0bb0c062091f45e3 --- HD/HD_TestScript.py (.../HD_TestScript.py) (revision 0da0106eca868b9144298c60911710b3414a5837) +++ HD/HD_TestScript.py (.../HD_TestScript.py) (revision c652777ecb913a96a3bd61ca0bb0c062091f45e3) @@ -13,49 +13,59 @@ # @brief This is an example test script for the HD. # ############################################################################ -# TODO: Use .format or f" {varname}" instead of casting to string. -# TODO: Break while loops on some condition, shouldn't rely on Ctrl-C. - +from utils import RESET, NO_RESET from HemodialysisDevice import HD from time import sleep if __name__ == "__main__": - hd = HD(can_interface_name="vcan0") + hd = HD() sleep(2) if hd.basics.cmd_log_in_to_hd() == 0: exit(1) - hd.bloodflow.cmd_blood_flow_broadcast_interval_override(hd.RESET, 0) + hd.bloodflow.cmd_blood_flow_broadcast_interval_override(RESET, 0) sleep(2) - print("Blood Flow Target = " + str(hd.bloodflow.TargetBloodFlowRate)) - print("Blood Pump Current= " + str(hd.bloodflow.MeasuredBloodPumpMCCurrent)) + print("Blood Flow Target = {}".format(hd.bloodflow.target_blood_flow_rate)) + print("Blood Pump Current = {}".format(hd.bloodflow.measured_blood_pump_mc_current)) sleep(5) - print("Blood Pump Current= " + str(hd.bloodflow.MeasuredBloodPumpMCCurrent)) + print("Blood Pump Current = {}".format(hd.bloodflow.measured_blood_pump_mc_current)) - hd.bloodflow.cmd_blood_pump_measured_current_override(hd.NO_RESET, 140) + hd.bloodflow.cmd_blood_pump_measured_current_override(NO_RESET, 140) sleep(1) - print("Blood Pump Current= " + str(hd.bloodflow.MeasuredBloodPumpMCCurrent)) + print("Blood Pump Current= {}".format(hd.bloodflow.measured_blood_pump_mc_current)) sleep(5) - hd.bloodflow.cmd_blood_pump_measured_current_override(hd.RESET, 0) + hd.bloodflow.cmd_blood_pump_measured_current_override(RESET, 0) + i = 0 while True: sleep(0.5) - print("Measured Flow = " + str(hd.bloodflow.MeasuredBloodFlowRate) + " mL/min") + print("Measured Flow = {} mL/min".format(hd.bloodflow.measured_blood_flow_rate)) + if i > 0 and i % 60 == 0: + resp = input("Press 'Enter' to continue or 'q' to quit: ") + if resp.lower() == "q": + break + i += 1 tgtRate = 0 - hd.BloodFlow.cmd_blood_flow_broadcast_interval_override(hd.NO_RESET, 2000) + hd.bloodflow.cmd_blood_flow_broadcast_interval_override(NO_RESET, 2000) + i = 0 while True: - if hd.BloodFlow.TargetBloodFlowRate == 0: + if hd.bloodflow.target_blood_flow_rate == 0: if tgtRate != 0: - hd.BloodFlow.cmd_blood_flow_broadcast_interval_override(hd.NO_RESET, 2000) + hd.bloodflow.cmd_blood_flow_broadcast_interval_override(NO_RESET, 2000) tgtRate = 0 else: if tgtRate == 0: - hd.BloodFlow.cmd_blood_flow_broadcast_interval_override(hd.NO_RESET, 200) - tgtRate = hd.BloodFlow.TargetBloodFlowRate + hd.bloodflow.cmd_blood_flow_broadcast_interval_override(NO_RESET, 200) + tgtRate = hd.bloodflow.target_blood_flow_rate + if i > 0 and i % 60 == 0: + resp = input("Press 'Enter' to continue or 'q' to quit: ") + if resp.lower() == "q": + break + i += 1 -# hd.bloodflow.cmd_blood_flow_broadcast_interval_override(hd.RESET,0) +# hd.bloodflow.cmd_blood_flow_broadcast_interval_override(RESET,0)