diff --git a/src/user_interface.py b/src/user_interface.py index 7c3db67..743f29b 100644 --- a/src/user_interface.py +++ b/src/user_interface.py @@ -64,11 +64,11 @@ class HelmholtzGUI(Tk): else: red = 0 global HEADER_FONT, SUB_HEADER_FONT, BIG_BUTTON_FONT, SMALL_BUTTON_FONT, DEFAULT_FONT - HEADER_FONT = (font, points[0+red], "bold") - SUB_HEADER_FONT = (font, points[2+red], "bold") - BIG_BUTTON_FONT = (font, points[1+red], "bold") - SMALL_BUTTON_FONT = (font, points[2+red]) - DEFAULT_FONT = (font, points[2+red]) + HEADER_FONT = (font, points[0 + red], "bold") + SUB_HEADER_FONT = (font, points[2 + red], "bold") + BIG_BUTTON_FONT = (font, points[1 + red], "bold") + SMALL_BUTTON_FONT = (font, points[2 + red]) + DEFAULT_FONT = (font, points[2 + red]) self.option_add("*font", DEFAULT_FONT) self.Menu = TopMenu(self) # display dropdown menu bar at the top (see TopMenu class for details) @@ -89,7 +89,8 @@ class HelmholtzGUI(Tk): main_area = Frame(self, padx=10, pady=10) # create main area Frame where controls of each mode are displayed main_area.pack(side="top", fill="both", expand=True) # pack main area at the top of the window - main_area.grid_rowconfigure(0, weight=5, minsize=800) # configure rows and columns of the Tkinter grid to expand with window + main_area.grid_rowconfigure(0, weight=5, + minsize=800) # configure rows and columns of the Tkinter grid to expand with window main_area.grid_columnconfigure(0, weight=1) # initialize the GUI pages for the different modes and setup switching between them @@ -578,8 +579,6 @@ class CalibrateAmbientField(Frame): self.controller = controller # To center window - #self.columnconfigure(0, weight=1) - #self.rowconfigure(0, weight=1) self.left_column = Frame(self) self.left_column.grid(row=0, column=0, sticky="nsew") self.right_column = Frame(self) @@ -645,7 +644,7 @@ class CalibrateAmbientField(Frame): field_data_axis_units.grid(row=i, column=3, padx=5, pady=3) row_counter += 1 - # Calibration start and save to csv buttons + # Calibration start and reinitialize buttons start_button_frame = Frame(self.left_column) start_button_frame.grid(row=row_counter, column=0, sticky="sw") self.start_ambient_calibration_button = Button(start_button_frame, text="Calibrate Ambient Field", @@ -656,6 +655,11 @@ class CalibrateAmbientField(Frame): command=self.calibration_procedure_coil_constants, pady=5, padx=5, font=SMALL_BUTTON_FONT) self.start_k_calibration_button.grid(row=0, column=1, padx=10, pady=10) + # Reinitialize button + self.reinitialize_button = Button(start_button_frame, text="Update and Reinitialize", + command=self.reinitialize, + pady=5, padx=5, font=SMALL_BUTTON_FONT) + self.reinitialize_button.grid(row=0, column=2, padx=10, pady=10) row_counter += 1 # Calibration progress bar @@ -969,6 +973,15 @@ class CalibrateAmbientField(Frame): self.clipboard_append(self.coil_constant_clipboard) self.update() + def reinitialize(self): # called on "Reinitialize!" button press + # reinitialize all PSUs and the Arduino + g.CAGE_DEVICE.reconnect_hardware_async() + + # log change to the log file if user has selected event logging in the Configure Logging window + logger = self.controller.pages[ConfigureLogging] # get object of logging configurator + if logger.event_logging: # data should be logged when test bench is commanded + logger.log_datapoint() # log data + class CalibrateMagnetometerSimple(Frame): def __init__(self, parent, controller): @@ -1060,11 +1073,18 @@ class CalibrateMagnetometerSimple(Frame): calibration_point_nr_entry.grid(row=1, column=1, pady=5, sticky="nw") # Calibration start buttons start_button_frame = Frame(controls_frame) - start_button_frame.grid(row=2, column=0, columnspan=2) + start_button_frame.grid(row=2, column=0, columnspan=1, sticky="nw") self.start_calibration_button = Button(start_button_frame, text="Start Calibration", command=self.start_calibration_procedure, pady=5, padx=5, font=SMALL_BUTTON_FONT) - self.start_calibration_button.grid(row=0, column=0, padx=10, pady=(30, 10)) + self.start_calibration_button.grid(row=0, column=0, padx=10, pady=(30, 10), sticky="we") + # Reinitialize button + reinitialize_button_frame = Frame(controls_frame) + reinitialize_button_frame.grid(row=2, column=1, columnspan=1) + self.reinitialize_button = Button(reinitialize_button_frame, text="Update and Reinitialize", + command=self.reinitialize, + pady=5, padx=5, font=SMALL_BUTTON_FONT) + self.reinitialize_button.grid(row=0, column=0, padx=10, pady=(30, 10), sticky="we") # Calibration progress bar progress_bar_frame = Frame(controls_frame) progress_bar_frame.grid(row=3, column=0, columnspan=2) @@ -1409,6 +1429,15 @@ class CalibrateMagnetometerSimple(Frame): [DoubleVar(value=0), DoubleVar(value=1), DoubleVar(value=0)], [DoubleVar(value=0), DoubleVar(value=0), DoubleVar(value=1)]] + def reinitialize(self): # called on "Reinitialize!" button press + # reinitialize all PSUs and the Arduino + g.CAGE_DEVICE.reconnect_hardware_async() + + # log change to the log file if user has selected event logging in the Configure Logging window + logger = self.controller.pages[ConfigureLogging] # get object of logging configurator + if logger.event_logging: # data should be logged when test bench is commanded + logger.log_datapoint() # log data + class CalibrateMagnetometerComplete(Frame): def __init__(self, parent, controller): @@ -1512,11 +1541,18 @@ class CalibrateMagnetometerComplete(Frame): calibration_point_nr_entry.grid(row=1, column=1, pady=5, sticky="nw") # Calibration start buttons start_button_frame = Frame(controls_frame) - start_button_frame.grid(row=2, column=0, columnspan=2, sticky="nw") + start_button_frame.grid(row=2, column=0, columnspan=1, sticky="nw") self.start_calibration_button = Button(start_button_frame, text="Start Calibration", command=self.start_calibration_procedure, pady=5, padx=5, font=SMALL_BUTTON_FONT) self.start_calibration_button.grid(row=0, column=0, padx=10, pady=(30, 10), sticky="we") + # Reinitialize button + reinitialize_button_frame = Frame(controls_frame) + reinitialize_button_frame.grid(row=2, column=1, columnspan=1) + self.reinitialize_button = Button(reinitialize_button_frame, text="Update and Reinitialize", + command=self.reinitialize, + pady=5, padx=5, font=SMALL_BUTTON_FONT) + self.reinitialize_button.grid(row=0, column=0, padx=10, pady=(30, 10), sticky="we") # Calibration progress bar progress_bar_frame = Frame(controls_frame) progress_bar_frame.grid(row=3, column=0, columnspan=2) @@ -1934,6 +1970,15 @@ class CalibrateMagnetometerComplete(Frame): [DoubleVar(value=0), DoubleVar(value=1), DoubleVar(value=0)], [DoubleVar(value=0), DoubleVar(value=0), DoubleVar(value=1)]] + def reinitialize(self): # called on "Reinitialize!" button press + # reinitialize all PSUs and the Arduino + g.CAGE_DEVICE.reconnect_hardware_async() + + # log change to the log file if user has selected event logging in the Configure Logging window + logger = self.controller.pages[ConfigureLogging] # get object of logging configurator + if logger.event_logging: # data should be logged when test bench is commanded + logger.log_datapoint() # log data + class HardwareConfiguration(Frame): """Settings window to set program constants"""