Index: tests/test_uf.py =================================================================== diff -u -rb93016ee67204223658152cb2952e8ab16af1b94 -r0f08c28544b557b2bbd8c04b10cff284f41e4fb9 --- tests/test_uf.py (.../test_uf.py) (revision b93016ee67204223658152cb2952e8ab16af1b94) +++ tests/test_uf.py (.../test_uf.py) (revision 0f08c28544b557b2bbd8c04b10cff284f41e4fb9) @@ -22,11 +22,19 @@ from dialin.dg.temperatures import DGTemperaturesNames 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 HD object called hd - hd = HD(log_level="DEBUG") - # create a DG object called dg - dg = DG(log_level="DEBUG") + # 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) # hd.ui.cmd_ui_start_treatment_request() @@ -35,7 +43,7 @@ # log in to HD and DG as tester # if hd.cmd_log_in_to_hd() == 0: # exit(1) -# if dg.cmd_log_in_to_dg() == 0: +# if fp.cmd_log_in_to_ro() == 0: # exit(1) # sleep(1) @@ -48,75 +56,27 @@ # collect UF related data from HD and DG while True: sleep(1) - modes = "HD.m, " + '{:2d}'.format(hd.hd_operation_mode) + \ - ", HD.s, " + '{:2d}'.format(hd.hd_operation_sub_mode) + \ - ", DG.m, " + '{:2d}'.format(dg.dg_operation_mode) + \ - ", DG.s, " + '{:2d}'.format(dg.dg_operation_sub_mode) - loadCells = ", A1, " + '{:8.1f}'.format(dg.load_cells.load_cell_A1) + \ - ", B1, " + '{:8.1f}'.format(dg.load_cells.load_cell_B1) + \ - ", A2, " + '{:8.1f}'.format(dg.load_cells.load_cell_A2) + \ - ", B2, " + '{:8.1f}'.format(dg.load_cells.load_cell_B2) - ultraFilt = ", RfUF, " + '{:9.2f}'.format(hd.dialysate_outlet_flow.reference_dialysate_outlet_uf_volume) + \ - ", MsUF, " + '{:9.2f}'.format(hd.dialysate_outlet_flow.measured_dialysate_outlet_uf_volume) + \ - ", Act.Res, " + '{:1d}'.format(dg.reservoirs.active_reservoir) - valves = ", DGVlvs, " + '{:4X}'.format(dg.valves.valve_states_all) + \ - ", VBA, " + hd.valves.valves_status[ValvesEnum.VBA.name]["PosID"] + \ - ", VBV, " + hd.valves.valves_status[ValvesEnum.VBV.name]["PosID"] + \ - ", VDi, " + hd.valves.valves_status[ValvesEnum.VDI.name]["PosID"] + \ - ", VDo, " + hd.valves.valves_status[ValvesEnum.VDO.name]["PosID"] + \ - ", VBT, " + '{:1d}'.format(hd.valves.hd_air_trap_status) - air = ", ADV, " + '{:1d}'.format(hd.air_bubbles.air_bubbles_status[0]) + \ - ", ULBl, " + '{:1d}'.format(hd.air_trap.lower_level) + \ - ", ULBu, " + '{:1d}'.format(hd.air_trap.upper_level) - pumpSetPts = ", BP.s, " + '{:4d}'.format(hd.bloodflow.target_blood_flow_rate) + \ - ", DPi.s, " + '{:4d}'.format(hd.dialysate_inlet_flow.target_dialysate_inlet_flow_rate) + \ - ", ROP.s, " + '{:9.2f}'.format(dg.ro_pump.target_pressure_psi) + \ - ", DRP.s, " + '{:9.2f}'.format(dg.drain_pump.target_drain_pump_rpm) - pumpMeasSpds = ", BP.m, " + '{:7.1f}'.format(hd.bloodflow.measured_blood_pump_speed) + \ - ", BP.m2, " + '{:7.1f}'.format(hd.bloodflow.get_measured_blood_pump_motor_controller_speed()) + \ - ", BP.r, " + '{:6.1f}'.format(hd.bloodflow.measured_blood_pump_rotor_speed) + \ - ", BP.f, " + '{:7.1f}'.format(hd.bloodflow.measured_blood_flow_rate) + \ - ", DPi.m, " + '{:7.1f}'.format(hd.dialysate_inlet_flow.measured_dialysate_inlet_pump_speed) + \ - ", DPi.m2, " + '{:7.1f}'.format(hd.dialysate_inlet_flow.get_measured_dialysate_inlet_pump_motor_controller_speed()) + \ - ", DPi.r, " + '{:7.1f}'.format(hd.dialysate_inlet_flow.measured_dialysate_inlet_pump_rotor_speed) + \ - ", DPi.f, " + '{:7.1f}'.format(hd.dialysate_inlet_flow.measured_dialysate_inlet_flow_rate) + \ - ", DPo.m, " + '{:7.1f}'.format(hd.dialysate_outlet_flow.measured_dialysate_outlet_pump_speed) + \ - ", DPo.m2, " + '{:7.1f}'.format(hd.dialysate_outlet_flow.get_measured_dialysate_outlet_pump_motor_controller_speed()) + \ - ", DPo.r, " + '{:6.1f}'.format(hd.dialysate_outlet_flow.measured_dialysate_outlet_pump_rotor_speed) + \ - ", FMD.f, " + '{:7.4f}'.format(dg.dialysate_flow_sensor.get_flow_rate()) + \ - ", ROP.f, " + '{:9.3f}'.format(dg.ro_pump.measured_flow_rate_lpm) - pumpPWMs = ", BP.w, "+'{:6.1f}'.format(hd.bloodflow.pwm_duty_cycle_pct) + \ - ", DPi.w, " + '{:6.1f}'.format(hd.dialysate_inlet_flow.pwm_duty_cycle_pct) + \ - ", DPo.w, " + '{:6.1f}'.format(hd.dialysate_outlet_flow.pwm_duty_cycle_pct) + \ - ", ROP.w, " + '{:6.1f}'.format(dg.ro_pump.pwm_duty_cycle_pct) + \ - ", DRP.w, " + '{:4d}'.format(dg.drain_pump.dac_value) - dgPress = ", PPi, " + '{:9.2f}'.format(dg.pressures.ro_pump_inlet_pressure) + \ - ", PPo, " + '{:9.2f}'.format(dg.pressures.ro_pump_outlet_pressure) + \ - ", PRd, " + '{:9.2f}'.format(dg.pressures.drain_pump_inlet_pressure) + \ - ", PDr, " + '{:9.2f}'.format(dg.pressures.drain_pump_outlet_pressure) - hdPress = ", PBA, " + '{:9.2f}'.format(hd.pressure_occlusion.arterial_pressure) + \ - ", PBV, " + '{:9.2f}'.format(hd.pressure_occlusion.venous_pressure) + \ - ", OB, " + '{:7d}'.format(hd.pressure_occlusion.blood_pump_occlusion) - Temps = ", TPi, " + '{:9.2f}'.format(dg.temperatures.temperatures[DGTemperaturesNames.INLET_PRIMARY_HEATER.name]) + \ - ", TPo, " + '{:9.2f}'.format(dg.temperatures.temperatures[DGTemperaturesNames.OUTLET_PRIMARY_HEATER.name]) + \ - ", TRo, " + '{:9.2f}'.format(dg.temperatures.temperatures[DGTemperaturesNames.INLET_DIALYSATE.name]) + \ - ", TDi, " + '{:9.2f}'.format(dg.temperatures.temperatures[DGTemperaturesNames.OUTLET_DIALYSATE_REDUNDANT.name]) + "," - alarms = ", AL.s, " + '{:1d}'.format(hd.alarms.get_current_alarms_state()) + \ - ", AL.t, " + '{:4d}'.format(hd.alarms.alarm_top) - accels = ", AC.x, " + '{:9.4f}'.format(hd.accel.get_accel_vector().x) + \ - ", AC.y, " + '{:9.4f}'.format(hd.accel.get_accel_vector().y) + \ - ", AC.z, " + '{:9.4f}'.format(hd.accel.get_accel_vector().z) + \ - ", ACm.x, " + '{:9.4f}'.format(hd.accel.get_accel_max_vector().x) + \ - ", ACm.y, " + '{:9.4f}'.format(hd.accel.get_accel_max_vector().y) + \ - ", ACm.z, " + '{:9.4f}'.format(hd.accel.get_accel_max_vector().z) + \ - ", ACt.x, " + '{:9.4f}'.format(hd.accel.get_accel_tilts().x) + \ - ", ACt.y, " + '{:9.4f}'.format(hd.accel.get_accel_tilts().y) + \ - ", ACt.z, " + '{:9.4f}'.format(hd.accel.get_accel_tilts().z) - htrs = (', Pri_main_DC, {:5.3f}, Pri_small_DC, {:5.3f}, Trimmer_DC, {:5.3f}, ' - 'Primary_target_temp, {:5.3f}, Trimmer_target_temp, {:5.3f}, '. - format(dg.heaters.main_primary_heater_duty_cycle, dg.heaters.small_primary_heater_duty_cycle, - dg.heaters.trimmer_heater_duty_cycle, - dg.heaters.primary_heaters_target_temperature, dg.heaters.trimmer_heater_target_temperature)) + 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)