Skip to content
Snippets Groups Projects
Commit eb183d35 authored by Martin Killenberg's avatar Martin Killenberg
Browse files

feat: make sleeps interruptible and process plot window events while waiting for data

parent ccff7384
No related branches found
No related tags found
No related merge requests found
......@@ -174,6 +174,13 @@ class MeasurementPlot:
window_close_callback = self.fig.canvas.mpl_connect('close_event', MeasurementPlot.window_closed)
while True:
if self.data_queue.empty():
time.sleep(0.1)
if not stop_measurement_event.is_set():
#the canvas might have gone and set stop_measurement_event when closing
self.fig.canvas.flush_events()
continue
data_frame, pdf_name, stop_drawing = self.data_queue.get()
if stop_drawing:
self.fig.canvas.mpl_disconnect(window_close_callback)
......
......@@ -280,7 +280,7 @@ class Measurements:
for i in range(0, n_stable_reads):
if process_sync.stop_measurement.is_set():
all_measurements_stable = False #not enough stable reads yet
do_another_measurement = False
do_another_measurement = False
break
# create the main data set for the first measurement set
......@@ -328,8 +328,14 @@ class Measurements:
def sleep_until(self, wakeup_time):
remaining_sleep_time = wakeup_time - self.clock.time()
if remaining_sleep_time > 0:
self.clock.sleep(remaining_sleep_time)
while remaining_sleep_time > 0:
if remaining_sleep_time > 1:
self.clock.sleep(1)
if process_sync.stop_measurement.is_set():
return
else:
self.clock.sleep(remaining_sleep_time)
remaining_sleep_time -= 1
def read_data(self, measurement_set_name):
[temp, hum, mode, alarms] = self.chamber.read_monitor().split(',')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment