From 3262d30b9a3262a22b7d083371f422c387ddbe3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Teichr=C3=B6b?= Date: Wed, 25 Jan 2023 17:27:55 +0100 Subject: [PATCH 1/2] Possible mistake with getter of tkinter/numpy Error was get() not possible for float values --- src/calibration.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibration.py b/src/calibration.py index 06d660f..4b12d84 100644 --- a/src/calibration.py +++ b/src/calibration.py @@ -531,7 +531,8 @@ class MagnetometerCalibrationComplete(Thread): matrix_trans_mgm_to_hh_np = np.zeros((3, 3)) for row in range(3): for col in range(3): - matrix_trans_mgm_to_hh_np[row][col] = matrix_trans_mgm_to_hh_tk[row][col].get() + #matrix_trans_mgm_to_hh_np[row][col] = matrix_trans_mgm_to_hh_tk[row][col].get() + matrix_trans_mgm_to_hh_np[row][col] = matrix_trans_mgm_to_hh_tk[row][col] # matrix_trans_mgm_to_hh_np = [[-1, 0, 0], [0, 1, 0], [0, 0, -1]] # hardcoded for MGM 1 / 3 # matrix_trans_mgm_to_hh_np = [[0, 1, 0], [-1, 0, 0], [0, 0, 1]] # hardcoded for MGM 0 / 2 ui_print("Applying transformation matrix to data. h_{set,mgm} = mgm_T_hh * h_{set,hh}") From f13389c06de4b04a34237117f3f9f5fac3a2c749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Teichr=C3=B6b?= Date: Thu, 26 Jan 2023 11:43:23 +0100 Subject: [PATCH 2/2] Added Reinitialize buttons to all frames --- src/user_interface.py | 72 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 12 deletions(-) diff --git a/src/user_interface.py b/src/user_interface.py index 25c7ec1..c4033b6 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 @@ -579,7 +580,7 @@ class CalibrateAmbientField(Frame): # To center window # self.columnconfigure(0, weight=1) - self.rowconfigure(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 +646,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 +657,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 +975,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 +1075,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 +1431,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 +1543,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) @@ -1827,7 +1865,8 @@ class CalibrateMagnetometerComplete(Frame): # Execute calibration function and display results sensor_parameters, mag_x_set, mag_y_set, mag_z_set, mag_x_m, mag_y_m, mag_z_m, cal_x, cal_y, cal_z, mag_amp_avg_set = MagnetometerCalibrationComplete.solve_system( raw_data, self.mgm_to_helmholtz_cos_trans) - MagnetometerCalibrationComplete.plot_magnetometer_calibration(self.right_column, mag_x_set, mag_y_set, mag_z_set, + MagnetometerCalibrationComplete.plot_magnetometer_calibration(self.right_column, mag_x_set, mag_y_set, + mag_z_set, mag_x_m, mag_y_m, mag_z_m, cal_x, cal_y, cal_z, mag_amp_avg_set) @@ -1931,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"""