Index: tests/test_ro.py =================================================================== diff -u --- tests/test_ro.py (revision 0) +++ tests/test_ro.py (revision 75e45186be1231371bf2ab6f9dfdbf3ca9b50bdb) @@ -0,0 +1,98 @@ +########################################################################### +# +# 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.ro.reverse_osmosis import RO + +from leahi_dialin.ro.modules.valves import ROValveStates +from leahi_dialin.ro.modules.valves import ROValveNames + +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 ro + ro = RO(log_level="DEBUG") + sleep(2) + + # log in to TD, DD and RO as tester + if ro.cmd_log_in_to_ro() == 0: + exit(1) +# if dd.cmd_log_in_to_dd() == 0: +# exit(1) +# if ro.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("RO_test.log", "w") as f: + + # collect data and display/log it + while True: + sleep(1) + modes = "RO.m, " + '{:2d}'.format(ro.ro_operation_mode) + \ + ", RO.s, " + '{:2d}'.format(ro.ro_operation_sub_mode) + # ", DD.m, " + '{:2d}'.format(dd.dd_operation_mode) + \ + # ", DD.s, " + '{:2d}'.format(dd.dd_operation_sub_mode) + pumpSetPts = ", RO.st, " + '{:4d}'.format(ro.pumps.ro_pump_state) + \ + ", RO.dc, " + '{:9.2f}'.format(ro.pumps.ro_pump_duty_cycle) + # ", ROP.s, " + '{:9.2f}'.format(ro.ro_pump.TBD) + pumpMeasSpds = ", RO.m, " + '{:7.1f}'.format(ro.pumps.ro_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 = ", PRi, " + '{:9.2f}'.format(ro.pressures.pressure_sensor_water_inlet_pre_reg) + \ + ", PRo, " + '{:9.2f}'.format(ro.pressures.pressure_sensor_water_inlet_post_reg) + \ + ", PC2o, " + '{:9.2f}'.format(ro.pressures.pressure_sensor_water_inlet_pre_cond) + \ + ", PPo, " + '{:9.2f}'.format(ro.pressures.pressure_sensor_pre_ro_filter) + \ + ", PMp, " + '{:9.2f}'.format(ro.pressures.pressure_sensor_post_ro_filter) + # 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) + Index: tests/test_td.py =================================================================== diff -u --- tests/test_td.py (revision 0) +++ tests/test_td.py (revision 75e45186be1231371bf2ab6f9dfdbf3ca9b50bdb) @@ -0,0 +1,94 @@ +########################################################################### +# +# 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.ro.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 ro +# ro = 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 ro.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(ro.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) +