Browse Source

finished Calibration Popup window, renamed stages in State Mashine

w.mueller 4 years ago
parent
commit
e89fb0360d
3 changed files with 27 additions and 20 deletions
  1. 14 15
      raspberry-pi/gui/Popup.py
  2. 11 3
      raspberry-pi/gui/mainWindow.py
  3. 2 2
      raspberry-pi/main.py

+ 14 - 15
raspberry-pi/gui/Popup.py

@@ -11,23 +11,22 @@ class CalibrationPopUp(tk.Frame):
     self.down_queue = down_queue
     self.up_queue = up_queue
     tk.Frame.__init__(self, root)
+    self.killed = False
 
-    self.csString = tk.StringVar()
-    self.instruction_string = tk.StringVar()
-    self.instruction_string.set("start Calibration!")
-    self.csString.set(self.calibration_state.state_clearname())
-    cs = tk.Label(self,textvariable=self.csString, anchor="c")
-    cs.pack(side="top", fill="both", expand=True)
-    dummy = tk.Label(self,text="dummy im a dummy", anchor="c")
-    dummy.pack(side="top", fill="both", expand=True)
-    instruction = tk.Label(self,textvariable=self.instruction_string, anchor="c")
-    instruction.pack(side="top", fill="both", expand=True)
-    button = tk.Button(self,text="OK", command=self.calibration_state.next_state_gui, anchor="c")
+    self.instruction = tk.Label(self,text="Start Calibration", anchor="c",font=("Courier",18))
+    self.instruction.pack(side="top", fill="both", expand=True)
+    button = tk.Button(self,text="OK", command=self.calibration_state.next_state_gui, anchor="c",height=1,width=5)
     button.pack(side="top", fill="both", expand=True)
+    self.cs = tk.Label(self,text=self.calibration_state.state_clearname(), anchor="c")
+    self.cs.pack(side="top", fill="both", expand=True)
   
   def update(self):
-    self.csString.set(self.calibration_state.state_clearname())
+    self.cs["text"] = self.calibration_state.state_clearname()
     if self.calibration_state.get_state() == self.calibration_state.WAITING_POS_1:
-        self.instruction_string.set("Move gondola to far left corner!")
-    if self.calibration_state.get_state() == self.calibration_state.WAITING_POS_2:
-        self.instruction_string.set("Move gondole to far right corner!")
+      self.instruction["text"] = "Move gondola to far left corner!"
+    elif self.calibration_state.get_state() == self.calibration_state.WAITING_POS_2:
+      self.instruction["text"] = "Move gondola to far right corner!"
+    elif self.calibration_state.get_state() == self.calibration_state.CALIBRATION_DONE:
+      self.instruction["text"] = "Calibration Done!"
+    else:
+      self.instruction["text"] = "Processing..."

+ 11 - 3
raspberry-pi/gui/mainWindow.py

@@ -41,14 +41,22 @@ class MainWindow(tk.Frame):
       self.ac_dro_y.set("Y: {:3.1f} mm".format(ac_data[-1][1]))
 
     if self.popup:
+      if self.calibration_state.get_state() == self.calibration_state.CALIBRATION_DONE and not self.popup.killed:
+        self.popup.killed = True
+        self.root.after(1500,self.kill_popup)
       self.popup.update()
     self.root.after(30, self.update)
 
+  def kill_popup(self):
+    self.pu_root.destroy()
+    self.popup = None
+
   def calibrate(self):
     self.down_queue.put("calibrate")
-    pu_root = tk.Tk()
-    pu_root.title("Calibration")
-    self.popup = Popup.CalibrationPopUp(pu_root,self.up_queue,self.down_queue,self.calibration_state)
+    self.pu_root = tk.Tk()
+    self.pu_root.title("Calibration")
+    self.pu_root.geometry("500x200")
+    self.popup = Popup.CalibrationPopUp(self.pu_root,self.up_queue,self.down_queue,self.calibration_state)
     self.popup.pack(side="top", fill="both", expand=True)
     
     

+ 2 - 2
raspberry-pi/main.py

@@ -28,11 +28,11 @@ class CalibrationStateMashine():
     if self.state == self.NOT_CALIBRATED:
       return "not calibrated"
     elif self.state == self.WAITING_POS_1:
-      return "ready on position one"
+      return "Waiting for Position one"
     elif self.state == self.ACCUMULATING_1:
       return "gathering values on position one"
     elif self.state == self.WAITING_POS_2:
-      return "ready on position two"
+      return "Waiting for position two"
     elif self.state == self.ACCUMULATING_2:
       return "gathering values on position two"
     elif self.state == self.CALIBRATION_DONE: