########################################################################### # # Copyright (c) 2020-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_uf.py # # @author (last) Sean Nash # @date (last) 24-Sep-2022 # @author (original) Peter Lucia # @date (original) 14-Jul-2020 # ############################################################################ import sys sys.path.append("..") from time import sleep from leahi_dialin.td.treatment_delivery import TD #from leahi_dialin.dd.dialysate_delivery import DD #from leahi_dialin.fp.reverse_osmosis import RO from leahi_dialin.td.modules.valves import ValvesEnum if __name__ == "__main__": # create an TD object called td td = TD(log_level="DEBUG") # create a DD object called dd # dd = DD(log_level="DEBUG") # create a RO object called fp # fp = RO(log_level="DEBUG") sleep(2) # log in to TD, DD and RO as tester if td.cmd_log_in_to_td() == 0: exit(1) # if dd.cmd_log_in_to_dd() == 0: # exit(1) # if fp.cmd_log_in_to_ro() == 0: # exit(1) # sleep(1) # send command to show round-trip communication w/ firmware is working td.blood_flow.cmd_blood_flow_set_speed_rate_request(1000) # create log file with open("TD_test.log", "w") as f: # collect data and display/log it while True: sleep(1) modes = "TD.m, " + '{:2d}'.format(td.td_operation_mode) + \ ", TD.s, " + '{:2d}'.format(td.td_operation_sub_mode) # ", DD.m, " + '{:2d}'.format(dd.dd_operation_mode) + \ # ", DD.s, " + '{:2d}'.format(dd.dd_operation_sub_mode) pumpSetPts = ", BP.sf, " + '{:4d}'.format(td.blood_flow.set_blood_flow_rate) + \ ", BP.ss, " + '{:9.2f}'.format(td.blood_flow.set_rpm) # ", ROP.s, " + '{:9.2f}'.format(fp.ro_pump.TBD) pumpMeasSpds = ", BP.m, " + '{:7.1f}'.format(td.blood_flow.measured_blood_pump_speed) # ", BP.r, " + '{:6.1f}'.format(td.blood_flow.measured_blood_pump_rotor_speed) + \ # ", BP.f, " + '{:7.1f}'.format(td.blood_flow.measured_blood_flow_rate) press = ", PBA, " + '{:9.2f}'.format(td.pressure_sensors.arterial_pressure) + \ ", PBV, " + '{:9.2f}'.format(td.pressure_sensors.venous_pressure) # valves = ", VBA, " + td.valves.valves_status[ValvesEnum.VBA.name]["PosID"] + \ # ", VBV, " + td.valves.valves_status[ValvesEnum.VBV.name]["PosID"] # air = ", ADV, " + '{:1d}'.format(td.bubbles.air_bubbles_status) + \ # ", ULBl, " + '{:1d}'.format(td.air_trap.lower_level) + \ # ", ULBu, " + '{:1d}'.format(td.air_trap.upper_level) + \ # ", AP, " + '{:1d}'.format(td.air_pump.air_pump_state) + \ # ", VBT, " + '{:1d}'.format(td.air_trap.valve_state) # alarms = ", AL.s, " + '{:1d}'.format(td.alarms.get_current_alarms_state()) + \ # ", AL.t, " + '{:4d}'.format(td.alarms.alarm_top) # log data f.write(modes) f.write(pumpSetPts) f.write(pumpMeasSpds) f.write(press) # f.write(valves) # f.write(air) # f.write(alarms) f.write("\n") # print to console print(" Modes: "+modes) print("Pump Set Pts: "+pumpSetPts) print(" Pump Speeds: "+pumpMeasSpds) print(" Pressures: "+press) # print(" Valves: "+valves) # print(" Air: "+air) # print(" Alarms: "+alarms)