forked from zietzm/Helmholtz_Test_Bench
Fixed and extended csv_logging.py
This commit is contained in:
+13
-10
@@ -1314,7 +1314,7 @@ class HardwareConfiguration(Frame):
|
||||
# open file selection dialogue at current path and save path of selected file
|
||||
filename = filedialog.askopenfilename(initialdir=directory, title="Select Config File",
|
||||
filetypes=(("Config File", "*.ini*"), ("All Files", "*.*")))
|
||||
if exists(filename): # does the file exist?
|
||||
if os.path.exists(filename): # does the file exist?
|
||||
config.CONFIG_FILE = filename # set global config file to the new file
|
||||
config.CONFIG_OBJECT = config.get_config_from_file(filename) # load from config file to config object
|
||||
config.check_config(config.CONFIG_OBJECT) # check and display warnings if values are out of bounds
|
||||
@@ -1467,16 +1467,20 @@ class ConfigureLogging(Frame):
|
||||
|
||||
# add general description headline:
|
||||
checkbox_label = Label(self.checkbox_frame, text="Select which data to log:")
|
||||
checkbox_label.grid(row=0, column=0, columnspan=2)
|
||||
checkbox_label.grid(row=0, column=0, columnspan=2, sticky='w')
|
||||
# generate and place all checkboxes:
|
||||
row = 1
|
||||
for key in log.axis_data_dict.keys(): # go through all loggable values
|
||||
row = 0
|
||||
column = 0
|
||||
for key, name in log.logging_selection_options.items(): # go through all loggable values
|
||||
self.checkbox_vars[key] = BooleanVar(value=True) # create variable for checkbox and put it in dictionary
|
||||
checkbox = Checkbutton(self.checkbox_frame, text=key, # generate checkbox
|
||||
checkbox = Checkbutton(self.checkbox_frame, text=name, # generate checkbox
|
||||
variable=self.checkbox_vars[key], onvalue=True, offvalue=False)
|
||||
checkbox.grid(row=row, column=0, sticky=W) # place checkbox in UI
|
||||
checkbox.grid(row=row+1, column=column, padx=(0, 20), sticky=W) # place checkbox in UI
|
||||
self.checkboxes.append(checkbox) # add created checkbox to list of all checkboxes
|
||||
row += 1
|
||||
if row > 8:
|
||||
row = 0
|
||||
column += 1
|
||||
|
||||
# self.controller.bind('<Escape>', self.escape_press) ToDo: implement escape button press event to power down
|
||||
|
||||
@@ -1536,7 +1540,7 @@ class ConfigureLogging(Frame):
|
||||
if try_again == 'yes': # user wants to try again
|
||||
self.write_to_file() # call same function again so user can retry
|
||||
else: # a valid filename was selected
|
||||
log.write_to_file(log.log_data, filepath) # write logged data to the file
|
||||
log.write_to_file(filepath) # write logged data to the file
|
||||
|
||||
def clear_data(self): # called on button press, asks user if he want to save logged data and then deletes it
|
||||
if log.unsaved_data: # there is logged data that has not been written to a file yet
|
||||
@@ -1560,10 +1564,9 @@ class ConfigureLogging(Frame):
|
||||
def update_choices(self): # updates the list storing which checkboxes are currently ticked
|
||||
# (this is passed to logging functions and determines which data is logged)
|
||||
|
||||
self.active_keys = [] # initialize the list
|
||||
self.active_keys = {} # initialize the dict
|
||||
for key in self.checkbox_vars.keys(): # go through all checkboxes
|
||||
if self.checkbox_vars[key].get(): # box is ticked
|
||||
self.active_keys.append(key) # add corresponding item to the list
|
||||
self.active_keys[key] = self.checkbox_vars[key].get() # add corresponding item to the list
|
||||
|
||||
def lock_checkboxes(self): # lock all checkboxes, so they can not be modified while logging
|
||||
# lock all checkboxes:
|
||||
|
||||
Reference in New Issue
Block a user