Index: tests/test_flush.py =================================================================== diff -u -r8474f8e345f165187d4dde17840575ee4e98a9b4 -r33155246625e9e2f69db4a70069095fe1e342b15 --- tests/test_flush.py (.../test_flush.py) (revision 8474f8e345f165187d4dde17840575ee4e98a9b4) +++ tests/test_flush.py (.../test_flush.py) (revision 33155246625e9e2f69db4a70069095fe1e342b15) @@ -17,22 +17,36 @@ import sys sys.path.append("..") from dialin.dg.dialysate_generator import DG +from dialin.hd.hemodialysis_device import HD from dialin.dg.drain_pump import DrainPumpStates from time import sleep def get_flush_mode_info(): - info = ('State, {}, Overall_elapsed_time, {}, State_elapsed_time, {}, Drain_vol, {:5.3f}, ' + """ + info = ('State, {}, Overall_elapsed_time, {}, State_elapsed_time, {}, Drain_vol, {:5.3f}, Top_alarm, {}, Op, {}, ' + 'Sub, {}, History, {}, ' .format(dg.flush.flush_state, dg.flush.overall_elapsed_time, dg.flush.state_elapsed_time, - dg.flush.flush_drain_line_volume_l)) + dg.flush.flush_drain_line_volume_l, hd.alarms.alarm_top, dg.events.get_dg_events(1, 0), + dg.events.get_dg_nth_event(2), dg.events.get_dg_events(2, 70))) + """ + + info = ('State, {}, Overall_elapsed_time, {}, State_elapsed_time, {}, Drain_vol, {:5.3f}, Top_alarm, {}, ' + .format(dg.flush.flush_state, dg.flush.overall_elapsed_time, dg.flush.state_elapsed_time, + dg.flush.flush_drain_line_volume_l, hd.alarms.alarm_top)) + 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}, ' + info = ('Bicarb_tgt_speed, {:5.3f}, Bicarb_speed, {:5.3f}, Acid_tgt_speed, {:5.3f}, Acid_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, + dg.concentrate_pumps.concentrate_pump_cp1_current_set_speed, + dg.concentrate_pumps.concentrate_pump_cp1_measured_speed, dg.conductivity_sensors.conductivity_sensor_cpo, dg.conductivity_sensors.conductivity_sensor_cd1, dg.conductivity_sensors.conductivity_sensor_cd2)) return info @@ -78,28 +92,38 @@ def get_ro_info(): - info = ('RO, {}, PPi, {:5.3f}, PPo, {:5.3f}, PWM, {:5.3f}, Flow, {:5.3f}, ' + info = ('RO, {}, PPi, {:5.3f}, PPo, {:5.3f}, PWM, {:5.3f}, Flow, {:5.3f}, Feedback_PWM, {: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.measured_flow_rate_lpm, dg.ro_pump.feedback_duty_cycle_pct)) 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 run_flush_mode(): complete_counter = 1 f = open("/home/fw/projects/dialin/tests/flush_mode.log", "w") - dg.hd_proxy.cmd_start_stop_dg_flush() + #dg.hd_proxy.cmd_start_stop_dg_flush() + dg.cmd_dg_software_reset_request() + try: while True: flush = get_flush_mode_info() load_cell = get_load_cells_info() drain = get_drain_states_info() ro = get_ro_info() conc = get_concentrate_pumps_info() + uv_reactors = get_uv_reactors_info() valves = get_dg_valves_states() - var = flush + load_cell + drain + ro + conc + valves + '\r' + var = flush + load_cell + drain + ro + conc + uv_reactors + valves + '\r' print(var) f.write(var) @@ -108,22 +132,33 @@ # If the mode came back to standby or standby solo if dg.dg_operation_mode == 3 or dg.dg_operation_mode == 4: + if complete_counter == 1: + dg.hd_proxy.cmd_start_stop_dg_flush() # Write a few more complete states to make sure the complete state items are recorded if complete_counter == 3: f.close() + #events = dg.events.get_dg_events(2, 60) + #for event in events: + # print(event) break complete_counter += 1 except KeyboardInterrupt: dg.hd_proxy.cmd_start_stop_dg_flush(start=False) f.close() + events = dg.events.get_dg_events(2, 50) + for event in events: + print(event) if __name__ == "__main__": dg = DG(log_level='DEBUG') + hd = HD(log_level='DEBUG') dg.cmd_log_in_to_dg() sleep(1) + hd.cmd_log_in_to_hd() + sleep(1) run_flush_mode()