Index: tests/dg_heat_and_chemical_disinfect_test.py =================================================================== diff -u -r21a53e63bedeb01f5eb2a85130e6b6fc454f2f88 -rfd723e785f01249340045b3447771854155a1829 --- tests/dg_heat_and_chemical_disinfect_test.py (.../dg_heat_and_chemical_disinfect_test.py) (revision 21a53e63bedeb01f5eb2a85130e6b6fc454f2f88) +++ tests/dg_heat_and_chemical_disinfect_test.py (.../dg_heat_and_chemical_disinfect_test.py) (revision fd723e785f01249340045b3447771854155a1829) @@ -1,35 +1,58 @@ +########################################################################### +# +# Copyright (c) 2019-2021 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 dg_heat_and_chemical_disinfect_test.py +# +# @author (last) Dara Navaei +# @date (last) 12-Nov-2021 +# @author (original) Dara Navaei +# @date (original) 02-May-2021 +# +############################################################################ -import sys -sys.path.append("..") from dialin.dg.dialysate_generator import DG -from dialin.dg.heat_disinfect import HeatDisinfectStates, HeatCancellationModes, HeatDisinfectUIStates -from dialin.dg.chemical_disinfect import ChemicalDisinfectStates, ChemCancellationModes, ChemDisinfectUIStates +from dialin.hd.hemodialysis_device import HD +from dialin.common.dg_defs import DGHeatDisinfectStates, DGHeatDisinfectUIStates +from dialin.dg.heat_disinfect import HeatCancellationModes +from dialin.common.dg_defs import DGChemicalDisinfectStates, DGChemDisinfectUIStates +from dialin.dg.chemical_disinfect import ChemCancellationModes 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 dialin.hd.hemodialysis_device import HD +from dialin.hd.temperatures import HDTemperaturesNames +from dialin.common.hd_defs import HDOpModes, HDOpSubModes +from dialin.common.dg_defs import DGEventList +from dialin.common.hd_defs import HDEventList +from dialin.hd.reservoirs import HDReservoirStates +from dialin.dg.reservoirs import DGReservoirsNames from time import sleep +from datetime import datetime +import sys +sys.path.append("..") -def get_chemical_disinfect_mode_info(): +def get_chemical_disinfect_mode_info(): info = ('State, {}, Overall_elapsed_time, {}, State_elapsed_time, {}, Disinfect_elapsed_time, {}, ' 'Cancellation_mode, {}, R1_level, {:5.3f}, R2_level, {:5.3f}, Current_rinse_count, {}, ' 'Total_rinse_count, {}, UI_state, {}, ' - .format(ChemicalDisinfectStates(dg.chemical_disinfect.chemical_disinfect_state).name, + .format(DGChemicalDisinfectStates(dg.chemical_disinfect.chemical_disinfect_state).name, dg.chemical_disinfect.overall_elapsed_time, dg.chemical_disinfect.state_elapsed_time, dg.chemical_disinfect.chemical_disinfect_elapsed_time, ChemCancellationModes(dg.chemical_disinfect.cancellation_mode).name, dg.chemical_disinfect.r1_level, dg.chemical_disinfect.r2_level, dg.chemical_disinfect.current_post_rinse_count, dg.chemical_disinfect.target_post_rinse_count, - ChemDisinfectUIStates(dg.chemical_disinfect.chemical_disinfect_ui_state).name)) + DGChemDisinfectUIStates(dg.chemical_disinfect.chemical_disinfect_ui_state).name)) return info def get_concentrate_pumps_info(): - info = ('Bicarb_tgt_speed, {:5.3f}, Bicarb_speed, {:5.3f}, CPo, {:5.3f}, CD1, {:5.3f}, CD2, {:5.3f}, ' .format(dg.concentrate_pumps.concentrate_pump_cp2_current_set_speed, dg.concentrate_pumps.concentrate_pump_cp2_measured_speed, @@ -39,26 +62,49 @@ def get_heat_disinfect_mode_info(): - info = ('State, {}, Overall_elapsed_time, {}, State_elapsed_time, {}, Disinfect_elapsed_time, {}, ' - 'Cancellation_mode, {}, R1_level, {:5.3f}, R2_level, {:5.3f}, UI_state, {}, ' - .format(HeatDisinfectStates(dg.heat_disinfect.heat_disinfect_state).name, + 'R1_level, {:5.3f}, R2_level, {:5.3f}, Top_alarm, {}, UI_state, {} ' + .format(DGHeatDisinfectStates(dg.heat_disinfect.heat_disinfect_state).name, dg.heat_disinfect.overall_elapsed_time, dg.heat_disinfect.state_elapsed_time, - dg.heat_disinfect.heat_disinfect_elapsed_time, - HeatCancellationModes(dg.heat_disinfect.cancellation_mode).name, dg.heat_disinfect.r1_level, - dg.heat_disinfect.r2_level, HeatDisinfectUIStates(dg.heat_disinfect.heat_disinfect_ui_state).name)) + dg.heat_disinfect.heat_disinfect_count_down_time, dg.heat_disinfect.r1_level, + dg.heat_disinfect.r2_level, hd.alarms.alarm_top, + DGHeatDisinfectUIStates(dg.chemical_disinfect.chemical_disinfect_ui_state).name)) return info +def get_hd_run_info(): + info = ('HD_op_mode, {}, HD_sub_mode, {}, Top_alarm, {}, Target_UF_ml, {:5.3f}, Meas_UF_ml, {:5.3f}, ' + .format(HDOpModes(hd.hd_operation_mode).name, hd.hd_operation_sub_mode, hd.alarms.alarm_top, + hd.dialysate_outlet_flow.reference_dialysate_outlet_uf_volume, + hd.dialysate_outlet_flow.measured_dialysate_outlet_uf_volume)) + return info + + +def get_hd_reservoirs_info(): + info = ('HD_rsrvr_state, {}, Active_rsrvr, {}, Active_rsrvr_uf, {:5.3f}, Active_rsrvr_vol_spent, {:5.3f}, ' + 'Dilution_level_pct, {:5.3f}, Recirc_level_pct, {:5.3f}, Time_depletion, {}, Time_wait_to_fill, {}, ' + 'Target_fill_flow, {:5.3f}, ' + .format(HDReservoirStates(hd.hd_reservoirs.reservoir_state).name, + DGReservoirsNames(dg.reservoirs.active_reservoir).name, hd.hd_reservoirs.active_reservoir_uf_ml, + hd.hd_reservoirs.active_reservoir_spent_vol_ml, hd.hd_reservoirs.dilution_level_pct, + hd.hd_reservoirs.recirculation_level_pct, hd.hd_reservoirs.time_depletion, + hd.hd_reservoirs.time_wait_to_fill, hd.hd_reservoirs.temp_remove_fill_flow)) + return info + + def get_dg_run_info(): + # info = ('DG_op_mode, {}, DG_sub_mode, {}, Op, {}, Sub, {}, '.format(DGOperationModes(dg.dg_operation_mode).name, + # dg.dg_operation_sub_mode, + # dg.events.get_dg_events(DGEventList(1).value, 3), + # dg.events.get_dg_events(DGEventList(2).value, 3))) - info = ('DG_op_mode, {}, DG_sub_mode, {}, '.format(DGOperationModes(dg.dg_operation_mode).name, - dg.dg_operation_sub_mode)) + info = ('DG_op_mode, {}, DG_op_mode_num, {}, DG_sub_mode, {}, '.format(DGOperationModes(dg.dg_operation_mode).name, + dg.dg_operation_mode, + 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], @@ -78,7 +124,6 @@ def get_drain_states_info(): - 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, @@ -88,44 +133,40 @@ def get_load_cells_info(): - info = ('A1, {:5.3f}, A2, {:5.3f}, B1, {:5.3f}, B2, {:5.3f}, '. format(dg.load_cells.load_cell_A1, dg.load_cells.load_cell_A2, dg.load_cells.load_cell_B1, dg.load_cells.load_cell_B2)) return info def get_ro_info(): - - info = ('RO, {}, PPi, {:5.3f}, PPo, {:5.3f}, PWM, {:5.3f}, Flow, {:5.3f}, Tgt_flow, {:5.3f}, ' + info = ('RO, {}, PPi, {:5.3f}, PPo, {:5.3f}, PWM, {:5.3f}, Flow, {:5.3f}, Tgt_flow, {:5.3f}, Dia_flow, {:5.3f}, ' .format(dg.ro_pump.ro_pump_state, dg.pressures.ro_pump_inlet_pressure, dg.pressures.ro_pump_outlet_pressure, dg.ro_pump.pwm_duty_cycle_pct, - dg.ro_pump.measured_flow_rate_lpm, dg.ro_pump.target_flow_lpm)) + dg.ro_pump.measured_flow_rate_lpm, dg.ro_pump.target_flow_lpm, dg.dialysate_flow_sensor.flow_rate)) return info -def get_heaters_info(): - - info = ('Pri_main_DC, {:5.3f}, Pri_small_DC, {:5.3f}, Pri_int_temp, {:5.3f}, Prim_CJ_temp, {:5.3f}, ' - 'Prim_TC_temp, {:5.3f}, Trimmer_DC, {:5.3f}, Trim_int_temp, {:5.3f}, Trim_CJ_temp, {:5.3f}, ' - 'Trim_TC_temp, {:5.3f}, Prim_TC_raw, {:5.3f}, Prim_CJ_raw, {:5.3f}, Trimmer_TC_raw, {:5.3f}, ' - 'Trimmer_CJ_raw, {:5.3f}, Primary_target_temp, {:5.3f}, Trimmer_target_temp, {:5.3f}, '. +def get_heaters_with_no_temp_info(): + info = ('Pri_main_DC, {:5.3f}, Pri_small_DC, {:5.3f}, Pri_state, {}, 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.temperature_sensors.temperature_sensors[TemperatureSensorsNames.PRIMARY_HEATER_INTERNAL.name], - dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.PRIMARY_HEATER_COLD_JUNCTION.name], - dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.PRIMARY_HEATER_THERMOCOUPLE.name], - dg.heaters.trimmer_heater_duty_cycle, - dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.TRIMMER_HEATER_INTERNAL.name], - dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.TRIMMER_HEATER_COLD_JUNCTION.name], - dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.TRIMMER_HEATER_THERMOCOUPLE.name], - dg.temperature_sensors.primary_raw_thermo_couple, dg.temperature_sensors.primary_raw_cold_junc, - dg.temperature_sensors.trimmer_raw_thermo_couple, dg.temperature_sensors.trimmer_raw_cold_junc, + dg.heaters.primary_heater_state, dg.heaters.trimmer_heater_duty_cycle, dg.heaters.primary_heaters_target_temperature, dg.heaters.trimmer_heater_target_temperature)) return info -def get_temperature_sensors_info(): +def get_heaters_info(): + info = ('Pri_main_DC, {:5.3f}, Pri_small_DC, {:5.3f}, Pri_state, {}, Trimmer_DC, {:5.3f}, ' + 'Primary_target_temp, {:5.3f}, Trimmer_target_temp, {:5.3f}, Primary_eff, {:5.3f}, '. + format(dg.heaters.main_primary_heater_duty_cycle, dg.heaters.small_primary_heater_duty_cycle, + dg.heaters.primary_heater_state, dg.heaters.trimmer_heater_duty_cycle, + dg.heaters.primary_heaters_target_temperature, dg.heaters.trimmer_heater_target_temperature, + dg.heaters.primary_efficiency)) + return info + +def get_temperature_sensors_info(): info = ('TPi, {:5.3f}, TPo, {:5.3f}, TD1, {:5.3f}, TD2, {:5.3f}, TRo, {:5.3f}, TDi, {:5.3f}, ' .format(dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.INLET_PRIMARY_HEATER.name], dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.OUTLET_PRIMARY_HEATER.name], @@ -136,106 +177,316 @@ return info -def get_fans_info(): - - info = ('Target_fans_DC, {:5.3f}, Inlet1_RPM, {:5.3f}, Outlet1_RPM, {:5.3f}, ' - 'Inlet2_RPM, {:5.3f}, Outlet2_RPM, {:5.3f}, Inlet3_RPM, {:5.3f}, Outlet3_RPM, {:5.3f}, Board_temp, {:5.3f},' - ' FPGA_temp, {:5.3f}, Load_cell_A1_B1, {:5.3f}, Load_cell_A2_B2, {:5.3f}, ' - .format(dg.fans.target_duty_cycle, dg.fans.inlet_1_rpm, dg.fans.inlet_2_rpm, dg.fans.inlet_2_rpm, +def get_dg_fans_info(): + info = ('Target_fans_DC, {:5.3f}, Inlet1_RPM, {:5.3f}, Outlet1_RPM, {:5.3f}, Inlet2_RPM, {:5.3f}, ' + 'Outlet2_RPM, {:5.3f}, Inlet3_RPM, {:5.3f}, Outlet3_RPM, {:5.3f}, Board_temp, {:5.3f}, ' + 'Power_supply_1, {:5.3f}, Power_supply_2, {:5.3f}, FPGA_temp, {:5.3f}, Load_cell_A1_B1, {:5.3f}, ' + 'Load_cell_A2_B2, {:5.3f}, ' + .format(dg.fans.dg_fans_duty_cycle, dg.fans.inlet_1_rpm, dg.fans.inlet_2_rpm, dg.fans.inlet_2_rpm, dg.fans.outlet_2_rpm, dg.fans.inlet_3_rpm, dg.fans.outlet_3_rpm, dg.thermistors.thermistors[ThermistorsNames.THERMISTOR_ONBOARD_NTC.name], + dg.thermistors.thermistors[ThermistorsNames.THERMISTOR_POWER_SUPPLY_1.name], + dg.thermistors.thermistors[ThermistorsNames.THERMISTOR_POWER_SUPPLY_2.name], dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.FPGA_BOARD_SENSOR.name], dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.LOAD_CELL_A1_B1.name], dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.LOAD_CELL_A2_B2.name])) return info -def run_dg(): +def get_hd_fans_info(): + info = ('HD_Fan_DC, {:5.3f}, Target_HD_RPM, {:5.3f}, Inlet1_RPM, {:5.3f}, HD_Board_temp, {:5.3f}, ' + 'HD_Power_supply, {:5.3f}, HD_FPGA_temp, {:5.3f}, PBA_ADC_temp, {:5.3f}, Venous_temp, {:5.3f}, ' + .format(hd.fans.duty_cycle, hd.fans.target_rpm, hd.fans.inlet_1_rpm, + hd.temperatures.hd_temperatures[HDTemperaturesNames.THERMISTOR_ONBOARD_NTC.name], + hd.temperatures.hd_temperatures[HDTemperaturesNames.THERMISTOR_POWER_SUPPLY_1.name], + hd.temperatures.hd_temperatures[HDTemperaturesNames.TEMPSENSOR_FPGA_BOARD.name], + hd.temperatures.hd_temperatures[HDTemperaturesNames.TEMPSENSOR_PBA_ADC_SENSOR.name], + hd.temperatures.hd_temperatures[HDTemperaturesNames.TEMPSENSOR_VENOUS_PRESS_TEMP.name])) + return info + +def get_uv_reactors_info(): + info = ('Inlet_status, {}, Outlet_status, {}, ' + .format(dg.uv_reactors.inlet_uv_reactor_state, dg.uv_reactors.outlet_uv_reactor_state)) + return info + + +def cmd_test_heaters(): + f = open("/home/fw/projects/dialin/tests/test_heaters.log", "w") + + dg.hd_proxy.cmd_start_stop_dg() + sleep(0.1) + + try: + while True: + """ + command = input() + + # s for stop the heaters + if command == 's': + dg.hd_proxy.cmd_stop_primary_heater() + # e for exit the run and close everything + elif command == 'e': + dg.hd_proxy.cmd_start_stop_dg(start=False) + f.close() + # c for change the flow rate and keep going + elif command == 'c': + pass + #TODO figure out the right command for this + """ + + dg_run = get_dg_run_info() + temperature = get_temperature_sensors_info() + heaters = get_heaters_info() + ro = get_ro_info() + + var = dg_run + temperature + heaters + ro + '\r' + + print(var) + f.write(var) + sleep(1) + + except KeyboardInterrupt: + dg.hd_proxy.cmd_start_stop_dg(start=False) + f.close() + + +def run_heaters(): counter = 1 timer = 1 sleep_time = 1 run_number = 1 - f = open("/home/fw/projects/dialin/tests/run_dg.log", "w") + f = open("/home/fw/projects/dialin/tests/run_heaters.log", "w") - """ - Set the broadcast to the fastest for studying a phenomenon - dg.valves.cmd_valve_broadcast_interval_override(50) - sleep(0.25) - dg.pressures.cmd_pressure_broadcast_interval_override(50) - sleep(0.25) - dg.drain_pump.cmd_drain_pump_data_broadcast_interval_override(50) - sleep(0.25) - dg.ro_pump.cmd_ro_pump_data_broadcast_interval_override(50) - sleep(0.25) - """ - dg.hd_proxy.cmd_start_stop_dg() sleep(0.1) try: while True: + try: + dg_run = get_dg_run_info() + temperature = get_temperature_sensors_info() + heaters = get_heaters_info() + ro = get_ro_info() + var = str(run_number) + ', ' + str(timer) + ', ' + dg_run + temperature + heaters + ro + '\r' + + print(var) + f.write(var) + sleep(sleep_time) + + except KeyboardInterrupt: + dg.hd_proxy.cmd_stop_primary_heater() + + except KeyboardInterrupt: + dg.hd_proxy.cmd_start_stop_dg(start=False) + f.close() + + +def run_dg(): + counter = 1 + timer = 0.1 + sleep_time = 1 + run_number = 1 + recirc_delay = 1 + f = open("/home/fw/projects/dialin/tests/run_dg.log", "w") + + dg.hd_proxy.cmd_start_stop_dg() + sleep(0.1) + + try: + while True: dg_run = get_dg_run_info() temperature = get_temperature_sensors_info() - heaters = get_heaters_info() + heaters = get_heaters_with_no_temp_info() load_cell = get_load_cells_info() drain = get_drain_states_info() ro = get_ro_info() + fans = get_dg_fans_info() valves = get_dg_valves_states() - var = str(run_number) + ', ' + str(timer) + ', ' + dg_run + temperature + heaters + load_cell + drain + \ - ro + valves + '\r' + var = str(datetime.now()) + ', ' + str(run_number) + ', ' + str(recirc_delay) + ', ' + dg_run + \ + temperature + heaters + load_cell + drain + ro + fans + valves + '\r' print(var) f.write(var) - tpo = dg.temperature_sensors.temperature_sensors[TemperatureSensorsNames.OUTLET_PRIMARY_HEATER.name] - - if run_number > 3 and dg.dg_operation_sub_mode == 2: + if run_number > 7 and dg.dg_operation_sub_mode == 2: dg.hd_proxy.cmd_start_stop_dg(start=False) f.close() break - elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_RECIRCULATE.name and\ - dg.dg_operation_sub_mode == 2 and counter == 1: + elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_GEN_IDLE.name and \ + dg.dg_operation_sub_mode == 2 and counter == 1: - if timer == 1: - dg.hd_proxy.cmd_switch_reservoirs(reservoirID=1) - timer += 1 + if recirc_delay < 5: + recirc_delay += 1 + else: + if timer == 1: + dg.hd_proxy.cmd_switch_reservoirs(reservoirID=1) + timer += 1 - if timer > ((1/sleep_time) * 1): - timer = 1 + if timer > ((1 / sleep_time) * 1): + timer = 1 + recirc_delay = 1 + counter += 1 + + elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_GEN_IDLE.name and \ + dg.dg_operation_sub_mode == 2 and counter == 2: + dg.hd_proxy.cmd_drain(tare_load_cell=True) + counter += 1 + timer = 1 + + elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_GEN_IDLE.name and \ + dg.dg_operation_sub_mode == 2 and counter == 3: + + timer += 1 + if timer > 4: + dg.hd_proxy.cmd_fill(volume=1700) counter += 1 - elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_RECIRCULATE.name and\ - dg.dg_operation_sub_mode == 2 and counter == 2: + elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_GEN_IDLE.name and \ + dg.dg_operation_sub_mode == 2 and counter == 4: + counter = 1 + run_number += 1 + + sleep(sleep_time) + + except KeyboardInterrupt: + dg.hd_proxy.cmd_start_stop_dg(start=False) + f.close() + pass + + +def run_ro_pump_duty_cycles(): + counter = 1 + timer = 0.1 + sleep_time = 1 + run_number = 1 + recirc_delay = 1 + ro_dc = 20 + ro_dc_step = 5 + f = open("/home/fw/projects/dialin/tests/run_ro_pump.log", "w") + + dg.hd_proxy.cmd_start_stop_dg() + sleep(0.1) + dg.ro_pump.cmd_ro_pump_duty_cycle_pct(ro_dc) + sleep(0.1) + + try: + while True: + dg_run = get_dg_run_info() + temperature = get_temperature_sensors_info() + heaters = get_heaters_with_no_temp_info() + load_cell = get_load_cells_info() + drain = get_drain_states_info() + ro = get_ro_info() + uv_reactors = get_uv_reactors_info() + fans = get_dg_fans_info() + valves = get_dg_valves_states() + + var = str(datetime.now()) + ', ' + str(run_number) + ', ' + str(ro_dc) + ', ' + dg_run + \ + temperature + heaters + load_cell + drain + ro + uv_reactors + fans + valves + '\r' + + print(var) + f.write(var) + + if ro_dc > 95 and dg.dg_operation_sub_mode == 2: + dg.hd_proxy.cmd_start_stop_dg(start=False) + f.close() + break + + elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_RECIRCULATE.name and \ + dg.dg_operation_sub_mode == 2 and counter == 1: + + if recirc_delay < 1: + recirc_delay += 1 + else: + if timer == 1: + dg.hd_proxy.cmd_switch_reservoirs(reservoirID=1) + + timer += 1 + + if timer > ((1 / sleep_time) * 1): + timer = 1 + recirc_delay = 1 + counter += 1 + + elif 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_drain(tare_load_cell=True) counter += 1 timer = 1 - elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_RECIRCULATE.name and\ - dg.dg_operation_sub_mode == 2 and counter == 3: #and tpo > 39.0: + elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_RECIRCULATE.name and \ + dg.dg_operation_sub_mode == 2 and counter == 3: timer += 1 if timer > 4: dg.hd_proxy.cmd_fill(volume=1700) counter += 1 - elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_RECIRCULATE.name and\ - dg.dg_operation_sub_mode == 2 and counter == 4: + elif DGOperationModes(dg.dg_operation_mode).name == DGOperationModes.DG_OP_MODE_RECIRCULATE.name and \ + dg.dg_operation_sub_mode == 2 and counter == 4: counter = 1 run_number += 1 + ro_dc += ro_dc_step + dg.ro_pump.cmd_ro_pump_duty_cycle_pct(ro_dc) sleep(sleep_time) except KeyboardInterrupt: dg.hd_proxy.cmd_start_stop_dg(start=False) f.close() + pass -def run_heat_disinfect(): +def collect_treatment_data(): + f = open("/home/fw/projects/dialin/tests/treatment_run.log", "w") + #dg.cmd_dg_software_reset_request() + + try: + while True: + hd_run = get_hd_run_info() + hd_rsrvrs = get_hd_reservoirs_info() + dg_run = get_dg_run_info() + drain = get_drain_states_info() + load_cell = get_load_cells_info() + valves = get_dg_valves_states() + ro = get_ro_info() + temp = get_temperature_sensors_info() + heaters = get_heaters_info() + dg_fans = get_dg_fans_info() + + var = str(datetime.now()) + ', ' + hd_run + dg_run + hd_rsrvrs + load_cell + drain + ro + temp + heaters + \ + dg_fans + valves + '\r' + + print(var) + f.write(var) + sleep(1) + except KeyboardInterrupt: + dg.hd_proxy.cmd_start_stop_dg(start=False) + f.close() + + +def collect_hd_treatment(): + f = open("/home/fw/projects/dialin/tests/treatment_run_hd.log", "w") + + hd.cmd_hd_software_reset_request() + + try: + while True: + + sleep(1) + except KeyboardInterrupt: + events = hd.hd_events.get_hd_events(2, 0) + for event in events: + print(event) + 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() @@ -250,9 +501,10 @@ ro = get_ro_info() temp = get_temperature_sensors_info() heaters = get_heaters_info() - fans = get_fans_info() + dg_fans = get_dg_fans_info() + hd_fans = get_hd_fans_info() - var = disinfect + load_cell + drain + ro + temp + heaters + fans + valves + '\r' + var = disinfect + load_cell + drain + ro + temp + heaters + dg_fans + hd_fans + valves + '\r' print(var) f.write(var) @@ -263,10 +515,10 @@ # If it is the first call, stop heat disinfect if complete_counter == 1: dg.hd_proxy.cmd_start_stop_heat_disinfect(start=False) - + # Write a few more complete states to make sure the complete state items are recorded elif complete_counter == 3: - #pass + # pass f.close() break @@ -278,7 +530,6 @@ def run_chemical_disinfect(): - complete_counter = 1 f = open("/home/fw/projects/dialin/tests/chemical_disinfect.log", "w") dg.hd_proxy.cmd_start_stop_dg_chemical_disinfect() @@ -294,7 +545,7 @@ ro = get_ro_info() temp = get_temperature_sensors_info() heaters = get_heaters_info() - fans = get_fans_info() + fans = get_dg_fans_info() var = disinfect + load_cell + conc + drain + ro + temp + heaters + fans + valves + '\r' @@ -307,7 +558,7 @@ # Write a few more complete states to make sure the complete state items are recorded if complete_counter == 3: - #pass + # pass f.close() break @@ -319,7 +570,6 @@ def cmd_set_disinfect_ui_screen(): - hd = HD() sleep(0.5) hd.ui.cmd_ui_set_standby_submode_to_disinfect() @@ -330,18 +580,30 @@ if __name__ == "__main__": - dg = DG(log_level='DEBUG') dg.cmd_log_in_to_dg() sleep(1) + hd = HD(log_level='DEBUG') + hd.cmd_log_in_to_hd() + sleep(1) - run_heat_disinfect() + # run_heat_disinfect() - #run_chemical_disinfect() + # run_chemical_disinfect() - #run_dg() + # run_dg() - #cmd_set_disinfect_ui_screen() + # run_ro_pump_duty_cycles() + # cmd_set_disinfect_ui_screen() + # cmd_test_heaters() + collect_treatment_data() + + #collect_hd_treatment() + + + + +