Updating canvas slows down loop. only increment it if new field is set

Takes ca 50-100ms
This commit is contained in:
2023-02-24 11:45:33 +01:00
parent c0fb152efa
commit a49f98ba63
+11 -9
View File
@@ -95,15 +95,6 @@ class ExecCSVThread(Thread):
t = time.time() - t_zero # get time relative to start of run
target_t = array[i, 0] # Target execution time of data point
# Update figure
try:
for j in range(4):
avx_lines[j].set_data([t, t], [0, 1])
#print("The next line might crash the programm, outcomment if necessary")
parent.plot_canvas.draw() # equivalent to matplotlib.show()
except DeviceAccessError as e:
ui_print("Failed to update figure: ", e)
if t >= target_t: # time for this row has come
field_vec = array[i, 1:4] # extract desired field vector
ui_print("[{:5.3f}s] B=[{:.1f}, {:.1f}, {:.1f}]\u03BCT for t={:.2f}s".format(t,
@@ -119,11 +110,22 @@ class ExecCSVThread(Thread):
logger = controller.pages[ui.ConfigureLogging] # get object of logging configurator
if logger.event_logging: # data should be logged when test bench is commanded
logger.log_datapoint() # log data
# Update figure
try:
for j in range(4):
avx_lines[j].set_data([t, t], [0, 1])
# print("The next line might crash the programm, outcomment if necessary")
parent.plot_canvas.draw() # equivalent to matplotlib.show()
except DeviceAccessError as e:
ui_print("Failed to update figure: ", e)
i = i + 1 # next row
elif t <= target_t - delay - 0.02: # is there enough time to sleep before the next row?
time.sleep(delay) # sleep to give other threads time to run
ui_print("Sequence executed, powering down channels.")