Index: tests/dg_heat_and_chemical_disinfect_test.py =================================================================== diff -u -rf8d379027a25b5497de67aabfb1e11b5e4fd6cbc -rd9310e1930f9237650263dcad07f676439468b50 --- tests/dg_heat_and_chemical_disinfect_test.py (.../dg_heat_and_chemical_disinfect_test.py) (revision f8d379027a25b5497de67aabfb1e11b5e4fd6cbc) +++ tests/dg_heat_and_chemical_disinfect_test.py (.../dg_heat_and_chemical_disinfect_test.py) (revision d9310e1930f9237650263dcad07f676439468b50) @@ -178,6 +178,13 @@ 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") @@ -335,7 +342,7 @@ sleep_time = 1 run_number = 1 recirc_delay = 1 - ro_dc = 10 + ro_dc = 20 ro_dc_step = 5 f = open("/home/fw/projects/dialin/tests/run_ro_pump.log", "w") @@ -352,11 +359,12 @@ 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 + fans + valves + '\r' + temperature + heaters + load_cell + drain + ro + uv_reactors + fans + valves + '\r' print(var) f.write(var) @@ -528,10 +536,4 @@ #cmd_test_heaters() - #dg.concentrate_pumps.cmd_concentrate_pump_state_change_request(0, 0) - #sleep(0.1) - #dg.concentrate_pumps.cmd_concentrate_pump_state_change_request(1, 0) - #dg.valves.cmd_valve_override(4, 0) - - Index: tests/flow_sensor_data_processor.py =================================================================== diff -u --- tests/flow_sensor_data_processor.py (revision 0) +++ tests/flow_sensor_data_processor.py (revision d9310e1930f9237650263dcad07f676439468b50) @@ -0,0 +1,93 @@ + +import math +import os + +log_files_address = '/home/fw/Desktop/Users/DaraN/Flow Sensor Data' + +write_file = '/home/fw/Desktop/Users/DaraN/Flow Sensor Data/flow_results.csv' +# Check if the report file exists. If it does, remove it first +if os.path.exists(write_file): + os.remove(write_file) + +# Create the CSV file +w = open(write_file, 'w') + +# Search through the log files of the provided folder +for root, dirs, log_files in os.walk(log_files_address): + for log_file in log_files: + # Get all the .log files + if log_file.endswith('.log'): + # Open the file as read mode + r = open(os.path.join(root, log_file), 'r') + + is_it_fill_time = False + flow_running_sum = 0.0 + initial_fill_load_cell = 0.0 + initial_fill_time = 0 + initial_fill_flow = 0.0 + initial_fill_delay = 0 + counter = 0 + + # Get the log file address without the extension + file_name = os.path.splitext(log_file)[0] + # Remove all the addresses before the file name (i.e. home/folder/run_pump will be run_pump) + file_name = file_name.split('/')[-1] + + # Add the header to the run + w.write(file_name + '\r') + w.write('Duty Cycle (%), Start Measured Flow (mL/min), End Measured Flow (mL/min), ' + 'Avg. Measured Flow (mL/min), Calculated Flow (mL/min), Error (%)' + '\r') + + for data in r: + + counter += 1 + # Parse the values the are of interest. Split from the title of the data and then split from the comma + # after the data + # i.e. Flow, 0.89, -> first get rid of Flow, -> 0.89, then get rid of , after the data -> 0.89 + # If the data is a string, use strip() to remove all the whitespaces + operation_mode = data.split('DG_op_mode,', 1)[1].split(',')[0].strip() + vpo_status = data.split('VPo,', 1)[1].split(',')[0].strip() + flow = float(data.split('Flow,', 1)[1].split(',')[0]) * 1000 + load_cell = float(data.split('B1,', 1)[1].split(',')[0]) + + # Check if the operation mode is fill and the VPo valve is set to fill + if operation_mode == 'DG_OP_MODE_FILL' and vpo_status == 'VALVE_STATE_FILL_C_TO_NC': + # Wait for the first 3 seconds of the data in the fill. This is to wait for the measured flow + # to settle since the RO controller is still trying to stabilize itself + initial_fill_delay += 1 + # If the first 3 seconds have elapsed and the fill time has started + if initial_fill_delay > 2 and is_it_fill_time is False: + # Get the value of the load cell and timer (as a counter) and the flow + initial_fill_load_cell = load_cell + initial_fill_time = counter + is_it_fill_time = True + initial_fill_flow = flow + # If it is the fill time, keep adding the parsed flow to be averaged later as the average measured + # flow of the fill + if is_it_fill_time is True: + flow_running_sum += flow + + # Check if the operation mode is back to recirculate and the fill time flag is still true. This means + # fill just ended and it is back to recirculate so the calculations can be done now + elif operation_mode == 'DG_OP_MODE_RECIRCULATE' and is_it_fill_time is True: + # Calculate the average measured flow + avg_measured_flow = flow_running_sum / (counter - initial_fill_time) + # Calculate the load cell flow by calculating the slope x 60 seconds to convert it to mL/min + load_cell_flow = ((load_cell - initial_fill_load_cell) / (counter - initial_fill_time)) * 60 + # Get the duty cycle first as the float then convert it to integer + duty_cycle = float(data.split('PWM,', 1)[1].split(',')[0]) + duty_cycle = int(math.floor(duty_cycle)) + # Calculate the error from load cell to the average measured flow in percent + error = ((load_cell_flow - avg_measured_flow) / load_cell_flow) * 100 + + info = ('{}, {:5.3f}, {:5.3f}, {:5.3f}, {:5.3f}, {:5.3f} '.format(duty_cycle, initial_fill_flow, + flow, avg_measured_flow, + load_cell_flow, error)) + w.write(info + '\r') + print(info) + # Done with this calculations, reset all the variables for the next fill + initial_fill_time = 0 + initial_fill_load_cell = 0 + is_it_fill_time = False + flow_running_sum = 0 + initial_fill_delay = 0 Index: tests/test_flush.py =================================================================== diff -u -rf8d379027a25b5497de67aabfb1e11b5e4fd6cbc -rd9310e1930f9237650263dcad07f676439468b50 --- tests/test_flush.py (.../test_flush.py) (revision f8d379027a25b5497de67aabfb1e11b5e4fd6cbc) +++ tests/test_flush.py (.../test_flush.py) (revision d9310e1930f9237650263dcad07f676439468b50) @@ -75,6 +75,13 @@ 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 @@ -87,9 +94,10 @@ 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)