forked from zietzm/Helmholtz_Test_Bench
moved error messages and program end message to messagebox
This commit is contained in:
+2
-1
@@ -649,7 +649,8 @@ class StatusDisplay(Frame):
|
||||
|
||||
def continuous_label_update(self, controller, interval): # update display values in regular intervals
|
||||
self.update_labels()
|
||||
controller.after(interval, lambda: self.continuous_label_update(controller, interval))
|
||||
if g.app is not None:
|
||||
controller.after(interval, lambda: self.continuous_label_update(controller, interval))
|
||||
|
||||
def update_labels(self):
|
||||
g.ARDUINO.update_status_info()
|
||||
|
||||
+20
-6
@@ -1,6 +1,7 @@
|
||||
import numpy as np
|
||||
import serial
|
||||
import traceback
|
||||
from tkinter import messagebox
|
||||
|
||||
from User_Interface import ui_print
|
||||
from pyps2000b import PS2000B
|
||||
@@ -279,42 +280,55 @@ def power_down_all(): # temporary, set all outputs to 0 but keep connections en
|
||||
def shut_down_all(): # shutdown at program end or on error, set outputs to 0 and disable connections
|
||||
# ToDo: remove checks if connected or make them only for printing
|
||||
ui_print("\nAttempting to safely shut down all devices. Check equipment to confirm.")
|
||||
message = "Tried to safely shut down all devices. Check equipment to confirm."
|
||||
if g.XY_DEVICE is not None:
|
||||
try:
|
||||
set_to_zero(g.XY_DEVICE)
|
||||
g.XY_DEVICE.disable_all()
|
||||
except BaseException as e:
|
||||
ui_print("Error while deactivating XY PSU:", e)
|
||||
message += "\nError while deactivating XY PSU: %s" % e
|
||||
else:
|
||||
ui_print("XY PSU deactivated.")
|
||||
message += "\nXY PSU deactivated."
|
||||
else:
|
||||
ui_print("XY PSU not connected, can't deactivate.")
|
||||
message += "\nXY PSU not connected, can't deactivate."
|
||||
if g.Z_DEVICE is not None:
|
||||
try:
|
||||
set_to_zero(g.Z_DEVICE)
|
||||
g.Z_DEVICE.disable_all()
|
||||
except BaseException as e:
|
||||
ui_print("Error while deactivating Z PSU:", e)
|
||||
message += "\nError while deactivating Z PSU: %s" % e
|
||||
else:
|
||||
ui_print("Z PSU deactivated.")
|
||||
message += "\nZ PSU deactivated."
|
||||
else:
|
||||
ui_print("Z PSU not connected, can't deactivate.")
|
||||
message += "\nZ PSU not connected, can't deactivate."
|
||||
|
||||
try:
|
||||
g.ARDUINO.safe()
|
||||
except BaseException as e:
|
||||
ui_print("Arduino safing unsuccessful:", e)
|
||||
message += "\nArduino safing unsuccessful: %s" % e
|
||||
# this throws no exception, even when arduino is not connected
|
||||
# ToDo (optional): figure out error handling for this
|
||||
if g.ARDUINO.connected == "Connected":
|
||||
try:
|
||||
g.ARDUINO.close()
|
||||
except BaseException as e:
|
||||
try:
|
||||
g.ARDUINO.close()
|
||||
except BaseException as e:
|
||||
if g.ARDUINO.connected == "Connected":
|
||||
ui_print("Closing Arduino connection failed:", e)
|
||||
message += "\nClosing Arduino connection failed: %s" % e
|
||||
else:
|
||||
ui_print("Serial connection to Arduino closed.")
|
||||
ui_print("Arduino not connected, can't close connection.")
|
||||
message += "\nArduino not connected, can't close connection."
|
||||
else:
|
||||
ui_print("Arduino not connected, can't close connection.")
|
||||
ui_print("Serial connection to Arduino closed.")
|
||||
message += "\nSerial connection to Arduino closed."
|
||||
|
||||
messagebox.showinfo("Shutdown Status", message)
|
||||
|
||||
|
||||
def set_field_simple(vector): # forms magnetic field as specified by vector, w/o cancelling ambient field
|
||||
|
||||
+5
-6
@@ -8,21 +8,20 @@ import globals as g
|
||||
|
||||
class ExecCSVThread(Thread):
|
||||
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.parent = parent # object from which this is called
|
||||
self.controller = controller # object on which mainloop() is running, usually main window
|
||||
|
||||
def run(self):
|
||||
ui.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, self.controller)
|
||||
self.parent.running = False
|
||||
# reset buttons:
|
||||
execute_sequence(self.array, 0.1, self.controller) # run sequence
|
||||
self.parent.running = False # sequence finished --> no longer running
|
||||
# reset buttons on UI:
|
||||
self.parent.select_file_button["state"] = "normal"
|
||||
self.parent.execute_button["state"] = "normal"
|
||||
self.parent.stop_button["state"] = "disabled"
|
||||
@@ -58,7 +57,7 @@ def execute_sequence(array, delay, controller): # runs through array containing
|
||||
|
||||
|
||||
def read_csv_to_array(filepath):
|
||||
# csv format: time (s); xField (T); yField (T); zField (T)
|
||||
# csv format: time (s); xField (T); yField (T); zField (T) (german excel)
|
||||
# decimal commas
|
||||
ui.ui_print("Reading File:", filepath)
|
||||
file = pandas.read_csv(filepath, sep=';', decimal=',', header=0) # read csv file
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from os.path import exists
|
||||
import traceback
|
||||
from tkinter import messagebox
|
||||
|
||||
import cage_func as func
|
||||
from User_Interface import HelmholtzGUI
|
||||
from User_Interface import ui_print
|
||||
import traceback
|
||||
import globals as g
|
||||
import config_handling as config
|
||||
|
||||
@@ -36,7 +37,10 @@ try: # start normal operations
|
||||
|
||||
except BaseException as e: # if there is an error, print what happened
|
||||
print("\nAn error occurred, Shutting down.")
|
||||
print(e)
|
||||
# shop pup-up error message:
|
||||
message = "%s.\nSee python console traceback for more details. " \
|
||||
"\nShutting down devices, check equipment to confirm." % e
|
||||
messagebox.showerror("Error!", message)
|
||||
print(traceback.print_exc())
|
||||
|
||||
finally: # safely shut everything down at the end
|
||||
|
||||
Reference in New Issue
Block a user