forked from zietzm/Helmholtz_Test_Bench
enabled and added callable status display updates
This commit is contained in:
+7
-4
@@ -6,19 +6,20 @@ import globals as g
|
||||
|
||||
|
||||
class ExecCSVThread(Thread):
|
||||
def __init__(self, threadID, array, parent):
|
||||
def __init__(self, threadID, array, parent, controller):
|
||||
# ToDo: comments
|
||||
Thread.__init__(self)
|
||||
|
||||
self.threadID = threadID
|
||||
self.array = array # numpy array containing data from csv to be executed
|
||||
self.parent = parent
|
||||
self.controller = controller # object on which mainloop() is running, usually main window
|
||||
|
||||
def run(self):
|
||||
func.ui_print("Starting Sequence Execution...")
|
||||
# g.threadLock.acquire() # Get lock to synchronize threads
|
||||
# ToDo: add locking/synchronization? Works without so far but might be more robust
|
||||
execute_sequence(self.array, 0.1)
|
||||
execute_sequence(self.array, 0.1, self.controller)
|
||||
self.parent.running = False
|
||||
# reset buttons:
|
||||
self.parent.select_file_button["state"] = "normal"
|
||||
@@ -26,7 +27,7 @@ class ExecCSVThread(Thread):
|
||||
self.parent.stop_button["state"] = "disabled"
|
||||
|
||||
|
||||
def execute_sequence(array, delay): # runs through array containing times and desired field vectors
|
||||
def execute_sequence(array, delay, controller): # runs through array containing times and desired field vectors
|
||||
# array format: [time (s), xField (T), yField (T), zField (T)]
|
||||
# decimal commas
|
||||
# all times in seconds
|
||||
@@ -41,8 +42,10 @@ def execute_sequence(array, delay): # runs through array containing times and d
|
||||
% (time.time()-t_zero, array[i, 0]), field_vec*1e6, "\u03BCT")
|
||||
func.set_field_simple(field_vec) # send field vector to test stand # ToDo!: reset to set_field()
|
||||
func.ui_print(time.time()-t_zero)
|
||||
controller.StatusDisplay.update_labels() # update status display after change
|
||||
i = i + 1 # next row
|
||||
elif t >= array[i, 0] - delay - 0.02: # not enough time to sleep
|
||||
|
||||
elif t >= array[i, 0] - delay - 0.02: # next change time is close, not enough time to sleep
|
||||
pass
|
||||
else: # sleep to give other threads time to run
|
||||
time.sleep(delay)
|
||||
|
||||
Reference in New Issue
Block a user