From 365c13aed9c11fc60a27cddaa46dd07aeae6ef65 Mon Sep 17 00:00:00 2001 From: Martin Killenberg <martin.killenberg@desy.de> Date: Wed, 8 Nov 2023 17:57:57 +0100 Subject: [PATCH] fix: mp Events not passed to process --- Python_script/climate-lab-gui.py | 5 +++-- Python_script/prototype.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Python_script/climate-lab-gui.py b/Python_script/climate-lab-gui.py index b9f302b..73a0d9a 100755 --- a/Python_script/climate-lab-gui.py +++ b/Python_script/climate-lab-gui.py @@ -115,7 +115,7 @@ class TestStandMainWindow(QMainWindow): self.stepParameter.value(), self.fixedParameter.value(), self.soakingTime.value(), self.stableReads.value(), self.get_analysis_config(time_string), os.path.join(self.start_dir, self.measurementFile.text()), error_queue, config_data, - ext_sensor_channels)) + ext_sensor_channels, process_sync.stop_measurement)) p.start() while p.is_alive(): @@ -135,7 +135,8 @@ class TestStandMainWindow(QMainWindow): @staticmethod def do_measurement_impl(measurement_type, output_basename, start_parameter, stop_parameter, step_parameter, fixed_parameter, soaking_time, stable_reads, analysis_config, measurement_file, error_queue, - config_data, ext_sensor_channels): + config_data, ext_sensor_channels, stop_measurement_event): + process_sync.stop_measurement = stop_measurement_event meas = None try: diff --git a/Python_script/prototype.py b/Python_script/prototype.py index 675cf36..f5fddd0 100755 --- a/Python_script/prototype.py +++ b/Python_script/prototype.py @@ -178,14 +178,18 @@ 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)) + 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() - def perform_single_measurement_impl(self, output, target_temp, target_hum, soaking_time, n_stable_reads): + def perform_single_measurement_impl(self, output, target_temp, target_hum, soaking_time, n_stable_reads, + stop_measurement): + + with open(output, mode='w', newline='') as csv_file: fieldnames = ['TIMESTAMP', 'TARGET_TEMPERATURE', 'READBACK_TEMPERATURE', 'TARGET_HUMIDITY', 'READBACK_HUMIDITY', 'DUT_IDENTIFIER', 'RUN_ID', 'EQUILIBRIUM_INDICATOR', 'TEMP_HEATER', @@ -215,7 +219,7 @@ class Measurements: dut_signal_queues = [[], []] while True: - if process_sync.stop_measurement.is_set(): + if stop_measurement.is_set(): do_another_measurement = False break @@ -278,7 +282,7 @@ class Measurements: all_measurements_stable = True for i in range(0, n_stable_reads): - if process_sync.stop_measurement.is_set(): + if stop_measurement.is_set(): all_measurements_stable = False #not enough stable reads yet do_another_measurement = False break -- GitLab