forked from zietzm/Helmholtz_Test_Bench
8d1870956f
file is now only written when explicitly wanted, e.g. on button press. global config stored instead as config object
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from User_Interface import HelmholtzGUI
|
|
import cage_func as func
|
|
import traceback
|
|
import globals as g
|
|
from os.path import exists
|
|
|
|
try: # start normal operations
|
|
|
|
g.CONFIG_FILE = 'config.ini'
|
|
# ToDo: remember what the last config file was
|
|
if not exists(g.CONFIG_FILE):
|
|
print("Config file not found, creating new from defaults.")
|
|
func.reset_config_to_default(g.CONFIG_FILE)
|
|
func.write_config_to_file(g.CONFIG_OBJECT)
|
|
|
|
g.CONFIG_OBJECT = func.get_config_from_file(g.CONFIG_FILE)
|
|
print(g.CONFIG_OBJECT)
|
|
|
|
print("Starting setup...")
|
|
func.setup_all() # initiate communication, set handles
|
|
|
|
print("\nOpening User Interface...")
|
|
|
|
g.app = HelmholtzGUI()
|
|
func.ui_print("Program Initialized")
|
|
func.check_config(g.CONFIG_OBJECT) # check config file for values exceeding limits
|
|
|
|
func.ui_print("\nStarting setup...") # do it again, so it is printed in the UI console ToDo: do it only once
|
|
func.setup_all() # initiate communication, set handles
|
|
g.app.mainloop()
|
|
g.app = None # reset to None so nothing tries to print in the UI output
|
|
|
|
|
|
except BaseException as e: # if there is an error, print what happened
|
|
print("\nAn error occurred, Shutting down.")
|
|
print(e)
|
|
print(traceback.print_exc())
|
|
|
|
finally: # safely shut everything down at the end
|
|
func.shut_down_all()
|