Index: tests/dg_heat_and_chemical_disinfect_test.py =================================================================== diff -u -r1261e3824e07dc805e6bf3d73c5ee340bb88fc15 -r597b213629a8243dd0d76ee5fe16f7b83e64483f --- tests/dg_heat_and_chemical_disinfect_test.py (.../dg_heat_and_chemical_disinfect_test.py) (revision 1261e3824e07dc805e6bf3d73c5ee340bb88fc15) +++ tests/dg_heat_and_chemical_disinfect_test.py (.../dg_heat_and_chemical_disinfect_test.py) (revision 597b213629a8243dd0d76ee5fe16f7b83e64483f) @@ -8,18 +8,21 @@ from dialin.dg.drain_pump import DrainPumpStates from dialin.dg.thermistors import ThermistorsNames from dialin.dg.temperature_sensors import TemperatureSensorsNames +from dialin.dg.dialysate_generator import DGOperationModes from time import sleep def get_chemical_disinfect_mode_info(): info = ('State, {}, Overall_elapsed_time, {}, State_elapsed_time, {}, Disinfect_elapsed_time, {}, ' - 'Cancellation_mode, {}, R1_level, {:5.3f}, R1_drift, {:5.3f}, R2_level, {:5.3f}, R2_drift, {:5.3f} ' + 'Cancellation_mode, {}, R1_level, {:5.3f}, R1_drift, {:5.3f}, R2_level, {:5.3f}, R2_drift, {:5.3f}, ' + 'Current_rinse_count, {}, Total_rinse_count, {}, ' .format(ChemicalDisinfectStates(dg.chemical_disinfect.chemical_disinfect_state).name, dg.chemical_disinfect.overall_elapsed_time, dg.chemical_disinfect.state_elapsed_time, dg.chemical_disinfect.disinfect_elapsed_time, CancellationModes(dg.chemical_disinfect.cancellation_mode).name, dg.chemical_disinfect.r1_level, (dg.chemical_disinfect.r1_level - dg.load_cells.load_cell_A1), dg.chemical_disinfect.r2_level, - (dg.chemical_disinfect.r2_level - dg.load_cells.load_cell_B1))) + (dg.chemical_disinfect.r2_level - dg.load_cells.load_cell_B1), + dg.chemical_disinfect.current_post_rinse_count, dg.chemical_disinfect.target_post_rinse_count)) return info @@ -41,9 +44,17 @@ return info +def get_dg_run_info(): + + info = ('DG_op_mode, {}, DG_sub_mode, {}, '.format(DGOperationModes(dg.dg_operation_mode).name, + dg.dg_operation_sub_mode)) + return info + + def get_dg_valves_states(): info = ('VPi, {}, VSP, {}, VPd, {}, VBf, {}, VPo, {}, VDr, {}, VRc, {}, VRo, {}, VRd, {}, VRi, {}, VRf, {}, ' + 'VRD1, {}, VRD2, {}, ' .format(dg.valves.valve_states_enum[dg.valves.VALVE_PRESSURE_INLET], dg.valves.valve_states_enum[dg.valves.VALVE_SAMPLING_PORT], dg.valves.valve_states_enum[dg.valves.VALVE_PRODUCTION_DRAIN], @@ -54,15 +65,17 @@ dg.valves.valve_states_enum[dg.valves.VALVE_RESERVOIR_OUTLET], dg.valves.valve_states_enum[dg.valves.VALVE_RESERVOIR_DRAIN], dg.valves.valve_states_enum[dg.valves.VALVE_RESERVOIR_INLET], - dg.valves.valve_states_enum[dg.valves.VALVE_RESERVOIR_FILL])) + dg.valves.valve_states_enum[dg.valves.VALVE_RESERVOIR_FILL], + dg.valves.valve_states_enum[dg.valves.VALVE_RESERVOIR_DRAIN_1], + dg.valves.valve_states_enum[dg.valves.VALVE_RESERVOIR_DRAIN_2])) return info def get_drain_states_info(): - info = ('Drain, {}, DAC, {}, RPM, {}, PRd, {:5.3f}, PDr, {:5.3f}, '. - format(DrainPumpStates(dg.drain_pump.drain_pump_state).name, - dg.drain_pump.dac_value, dg.drain_pump.current_drain_pump_rpm, + info = ('Drain, {}, DAC, {}, Tgt_RPM, {}, Curr_RPM, {}, PRd, {:5.3f}, PDr, {:5.3f}, '. + format(DrainPumpStates(dg.drain_pump.drain_pump_state).name, dg.drain_pump.dac_value, + dg.drain_pump.target_drain_pump_rpm, dg.drain_pump.current_drain_pump_rpm, dg.pressures.drain_pump_inlet_pressure, dg.pressures.drain_pump_outlet_pressure)) return info @@ -131,17 +144,67 @@ return info +def run_dg(): + + counter = 1 + f = open("/home/fw/projects/dialin/tests/run_dg.log", "w") + dg.hd_proxy.cmd_start_stop_dg() + sleep(0.2) + + try: + while True: + + dg_run = get_dg_run_info() + load_cell = get_load_cells_info() + drain = get_drain_states_info() + ro = get_ro_info() + valves = get_dg_valves_states() + + var = dg_run + load_cell + drain + ro + valves + '\r' + + print(var) + f.write(var) + + if DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_RECIRCULATE.name and\ + dg.dg_operation_sub_mode == 2 and counter == 1: + dg.hd_proxy.cmd_switch_reservoirs(reservoirID=1) + sleep(3) + dg.hd_proxy.cmd_drain(tare_load_cell=True) + counter += 1 + sleep(0.15) + + if DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_RECIRCULATE.name and\ + dg.dg_operation_sub_mode == 2 and counter == 2: + dg.hd_proxy.cmd_fill(volume=1200) + counter += 1 + sleep(0.15) + + if DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_RECIRCULATE.name and\ + dg.dg_operation_sub_mode == 2 and counter == 3: + #dg.hd_proxy.cmd_switch_reservoirs(reservoirID=0) + dg.ro_pump.cmd_ro_pump_duty_cycle_pct(0) + sleep(3) + dg.hd_proxy.cmd_drain() + counter += 1 + sleep(0.15) + + sleep(1) + + except KeyboardInterrupt: + dg.hd_proxy.cmd_start_stop_dg(start=False) + f.close() + + def run_heat_disinfect(): complete_counter = 1 f = open("/home/fw/projects/dialin/tests/Heat_disinfect.log", "w") dg.hd_proxy.cmd_start_stop_heat_disinfect() - #dg.hd_proxy.cmd_start_stop_dg() try: while True: - disinfect = get_heat_disinfect_mode_info() + disinfect = get_dg_run_info() drain = get_drain_states_info() load_cell = get_load_cells_info() valves = get_dg_valves_states() @@ -156,7 +219,6 @@ f.write(var) sleep(1) - # If the mode came back to standby or standby solo if dg.dg_operation_mode == 3 or dg.dg_operation_mode == 4: # If it is the first call, stop heat disinfect @@ -171,10 +233,8 @@ complete_counter += 1 - except KeyboardInterrupt: dg.hd_proxy.cmd_start_stop_heat_disinfect(start=False) - #dg.hd_proxy.cmd_start_stop_dg(start=False) f.close() @@ -226,8 +286,10 @@ dg.cmd_log_in_to_dg() sleep(1) - run_heat_disinfect() + #run_heat_disinfect() #run_chemical_disinfect() + run_dg() +