diff --git a/Python_script/MeasurementPlot.py b/Python_script/MeasurementPlot.py index a1db17670863bf1458a9e6ae170acc740f0344e0..0ca1467c2d76538e3cc3fe0558f0665accae9ca7 100644 --- a/Python_script/MeasurementPlot.py +++ b/Python_script/MeasurementPlot.py @@ -161,17 +161,19 @@ class MeasurementPlot: except queue.Full: pass - def drawing_loop(self): + def drawing_loop(self, stop_measurement_event): + # turn interactive plotting (back) on (is deactivated by starting the process) + plt.ion() while True: data_frame, pdf_name, stop_drawing = self.data_queue.get() if stop_drawing: return try: - if not process_sync.stop_measurement.is_set(): + if not stop_measurement_event.is_set(): self.draw_in_this_thread(data_frame, pdf_name='') except Exception as e: # Don't exit here. Always drain the data queue so the program can terminate correctly - process_sync.stop_measurement.set() + stop_measurement_event.set() def draw_in_this_thread(self, data_frame, pdf_name=''): timestamps = data_frame.TIMESTAMP diff --git a/Python_script/prototype.py b/Python_script/prototype.py index f5fddd0b1a254101b4298526d8e985e72a1acc20..d821439d3c47737cd75401763d3e4b85e533a60e 100755 --- a/Python_script/prototype.py +++ b/Python_script/prototype.py @@ -177,17 +177,13 @@ class Measurements: """ process_sync.stop_measurement.clear() ctx = mp.get_context('spawn') - measurement_process = ctx.Process(target=self.perform_single_measurement_impl, - args=(output, target_temp, target_hum, soaking_time, n_stable_reads, - process_sync.stop_measurement)) - measurement_process.start() - # turn interactive plotting (back) on (is deactivated by starting the process) - plt.ion() - self.measurement_plot.drawing_loop() - measurement_process.join() + plot_process = ctx.Process(target=self.measurement_plot.drawing_loop, + args=(process_sync.stop_measurement,)) + plot_process.start() + self.perform_single_measurement_impl(output, target_temp, target_hum, soaking_time, n_stable_reads) + plot_process.join() - def perform_single_measurement_impl(self, output, target_temp, target_hum, soaking_time, n_stable_reads, - stop_measurement): + def perform_single_measurement_impl(self, output, target_temp, target_hum, soaking_time, n_stable_reads): with open(output, mode='w', newline='') as csv_file: @@ -219,7 +215,7 @@ class Measurements: dut_signal_queues = [[], []] while True: - if stop_measurement.is_set(): + if process_sync.stop_measurement.is_set(): do_another_measurement = False break @@ -282,7 +278,7 @@ class Measurements: all_measurements_stable = True for i in range(0, n_stable_reads): - if stop_measurement.is_set(): + if process_sync.stop_measurement.is_set(): all_measurements_stable = False #not enough stable reads yet do_another_measurement = False break