|
@@ -11,15 +11,16 @@ import logHandler
|
|
|
|
|
|
|
|
|
|
class MainWindow(tk.Frame):
|
|
class MainWindow(tk.Frame):
|
|
- def __init__(self, root, conf, ac_sensor, opt_sensor):
|
|
|
|
- self.root = root
|
|
|
|
- self.conf = conf
|
|
|
|
- self.ac_sensor = ac_sensor
|
|
|
|
- self.opt_sensor = opt_sensor
|
|
|
|
- self.log_handler = logHandler.get_log_handler()
|
|
|
|
- self.popup_window = None
|
|
|
|
- self.log_window = None
|
|
|
|
- self.mainWindow= None
|
|
|
|
|
|
+ def __init__(self, root, conf, ac_sensor, opt_sensor, mag_sensor):
|
|
|
|
+ self.root = root
|
|
|
|
+ self.conf = conf
|
|
|
|
+ self.ac_sensor = ac_sensor
|
|
|
|
+ self.opt_sensor = opt_sensor
|
|
|
|
+ self.mag_sensor = mag_sensor
|
|
|
|
+ self.log_handler = logHandler.get_log_handler()
|
|
|
|
+ self.popup_window = None
|
|
|
|
+ self.log_window = None
|
|
|
|
+ self.mainWindow = None
|
|
|
|
|
|
tk.Frame.__init__(self, root)
|
|
tk.Frame.__init__(self, root)
|
|
# data plot at left side
|
|
# data plot at left side
|
|
@@ -56,7 +57,8 @@ class MainWindow(tk.Frame):
|
|
tk.Label(self.controls, textvariable=self.opt_dro_offset, anchor="nw").pack(side="top", fill="both", expand=False)
|
|
tk.Label(self.controls, textvariable=self.opt_dro_offset, anchor="nw").pack(side="top", fill="both", expand=False)
|
|
tk.Label(self.controls, textvariable=self.opt_dro_size, anchor="nw").pack(side="top", fill="both", expand=False)
|
|
tk.Label(self.controls, textvariable=self.opt_dro_size, anchor="nw").pack(side="top", fill="both", expand=False)
|
|
|
|
|
|
-
|
|
|
|
|
|
+ self.mag_label = tk.Label(self.controls, text="Magnetic Sensor", anchor="c", font=("Helvatica", 10, 'bold'))
|
|
|
|
+ self.mag_label.pack(side="top", fill="both", expand=False)
|
|
|
|
|
|
self.quit_button = tk.Button(self.controls, text="Quit", command=self.root.destroy, height=2, foreground="red")
|
|
self.quit_button = tk.Button(self.controls, text="Quit", command=self.root.destroy, height=2, foreground="red")
|
|
self.quit_button.pack(side="bottom", fill="both")
|
|
self.quit_button.pack(side="bottom", fill="both")
|
|
@@ -84,6 +86,7 @@ class MainWindow(tk.Frame):
|
|
|
|
|
|
self.logscreen_button.pack_forget()
|
|
self.logscreen_button.pack_forget()
|
|
|
|
|
|
|
|
+
|
|
def update(self):
|
|
def update(self):
|
|
if not self.root.winfo_exists():
|
|
if not self.root.winfo_exists():
|
|
return
|
|
return
|
|
@@ -104,8 +107,17 @@ class MainWindow(tk.Frame):
|
|
opt_positions.append(data[0:2])
|
|
opt_positions.append(data[0:2])
|
|
self.opt_dro_val_sums += data
|
|
self.opt_dro_val_sums += data
|
|
self.opt_dro_val_count += 1
|
|
self.opt_dro_val_count += 1
|
|
|
|
+
|
|
|
|
+ mag_positions = []
|
|
|
|
+ while self.mag_sensor.queue.qsize() > 0:
|
|
|
|
+ name, data = self.mag_sensor.queue.get()
|
|
|
|
+ if name == 'data':
|
|
|
|
+ mag_positions.append(data[0:2])
|
|
|
|
+ self.mag_dro_val_sums += data
|
|
|
|
+ self.mag_dro_val_count += 1
|
|
|
|
+
|
|
# graph shows all values as a line
|
|
# graph shows all values as a line
|
|
- self.graph.update([ac_positions, opt_positions])
|
|
|
|
|
|
+ self.graph.update([ac_positions, opt_positions, mag_positions])
|
|
|
|
|
|
# update status color
|
|
# update status color
|
|
if self.ac_sensor.dummyActive:
|
|
if self.ac_sensor.dummyActive:
|
|
@@ -123,6 +135,14 @@ class MainWindow(tk.Frame):
|
|
else:
|
|
else:
|
|
self.opt_label.config(fg="black", bg="yellow")
|
|
self.opt_label.config(fg="black", bg="yellow")
|
|
|
|
|
|
|
|
+ # if not self.mag_sensor.:
|
|
|
|
+ # self.mag_label.config(fg="white", bg="red")
|
|
|
|
+ # elif len(mag_positions) > 0:
|
|
|
|
+ # self.mag_label.config(fg="white", bg="green")
|
|
|
|
+ # else:
|
|
|
|
+ # self.mag_label.config(fg="black", bg="yellow")
|
|
|
|
+
|
|
|
|
+
|
|
# readouts will only be updated so often
|
|
# readouts will only be updated so often
|
|
if self.controlsUpdateTime + 0.4 < time.time():
|
|
if self.controlsUpdateTime + 0.4 < time.time():
|
|
self.controlsUpdateTime = time.time()
|
|
self.controlsUpdateTime = time.time()
|
|
@@ -191,27 +211,18 @@ class MainWindow(tk.Frame):
|
|
self.log_window = LogScreen(self.log_root)
|
|
self.log_window = LogScreen(self.log_root)
|
|
self.log_window.pack(side="top", fill="both", expand=True)
|
|
self.log_window.pack(side="top", fill="both", expand=True)
|
|
|
|
|
|
|
|
+
|
|
|
|
+ # Menu Button
|
|
def menu(self):
|
|
def menu(self):
|
|
- #Menu
|
|
|
|
|
|
+ self.menu_back_button.pack(side="bottom", fill="both")
|
|
self.calibrate_button.pack(side="bottom", fill="both")
|
|
self.calibrate_button.pack(side="bottom", fill="both")
|
|
self.clear_button.pack(side="bottom", fill="both")
|
|
self.clear_button.pack(side="bottom", fill="both")
|
|
self.logscreen_button.pack(side="bottom", fill="both")
|
|
self.logscreen_button.pack(side="bottom", fill="both")
|
|
self.menu_button.pack_forget()
|
|
self.menu_button.pack_forget()
|
|
- self.menu_back_button.pack(side="bottom", fill="both")
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
def back(self):
|
|
def back(self):
|
|
self.calibrate_button.pack_forget()
|
|
self.calibrate_button.pack_forget()
|
|
self.clear_button.pack_forget()
|
|
self.clear_button.pack_forget()
|
|
self.logscreen_button.pack_forget()
|
|
self.logscreen_button.pack_forget()
|
|
self.menu_button.pack(side="bottom", fill="both")
|
|
self.menu_button.pack(side="bottom", fill="both")
|
|
- self.menu_back_button.pack_forget()
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ self.menu_back_button.pack_forget()
|