Quellcode durchsuchen

Update microwave example

Joeri Exelmans vor 4 Jahren
Ursprung
Commit
6b2195749d

+ 2 - 8
examples/microwave/GUI.py

@@ -1,3 +1,5 @@
+# Based on "Digital Watch GUI" OCT 2008 by Reehan Shaikh reehan.shaikh@cs.mcgill.ca
+
 from tkinter import Frame, PhotoImage, Canvas
 from tkinter.constants import BOTH
 
@@ -68,19 +70,11 @@ class GUI(Frame):
             (INCTIME_X0, INCTIME_X1, INCTIME_Y0, INCTIME_Y1, "INCTIME"),
             (DOOR_X0, DOOR_X1, DOOR_Y0, DOOR_Y1, "DOOR"),
         ]
-                        
-        # self.buttonStart = self.canvas.create_rectangle(START_X0, START_Y0, START_X1, START_Y1)
-        # self.buttonStop = self.canvas.create_rectangle(STOP_X0, STOP_Y0, STOP_X1, STOP_Y1)
-        # self.buttonIncTime = self.canvas.create_rectangle(INCTIME_X0, INCTIME_Y0, INCTIME_X1, INCTIME_Y1)
-        # self.buttonDoor = self.canvas.create_rectangle(DOOR_X0, DOOR_Y0, DOOR_X1, DOOR_Y1, fill='')
 
         self.timeTag = self.canvas.create_text(
             TIME_X1-16, TIME_Y0+7,
             font=FONT_TIME, justify="center", fill="#0f0", text="0")
 
-        # self.timeTag = None
-        # self.setTime(0)
-
         self.canvas.bind("<ButtonPress-1>", self.mouse1Click)
         self.canvas.bind("<ButtonRelease-1>", self.mouse1Release)
         

+ 3 - 0
examples/microwave/README.txt

@@ -0,0 +1,3 @@
+Microwave example.
+
+TODO: For a fully immersive experience, add sounds :) (seems to be difficult to do this right in a cross-platform way)

BIN
examples/microwave/bell.wav


+ 4 - 1
examples/microwave/model_microwave.xml

@@ -25,6 +25,7 @@
       <event name="micro_on"/>
       <event name="micro_off"/>
       <event name="set_time"/>
+      <event name="ping"/>
     </outport>
     <root>
       <parallel id="P">
@@ -41,7 +42,9 @@
                   <param expr="time"/>
                 </raise>
               </transition>
-              <transition cond="time == 0" target="../NotRunning"/>
+              <transition cond="time == 0" target="../NotRunning">
+                <raise port="out" event="ping"/>
+              </transition>
             </state>
             <state id="NotRunning">
               <transition port="in" event="start" target="../Running">

+ 1 - 1
examples/microwave/run.py

@@ -15,7 +15,7 @@ if __name__ == '__main__':
     tk.withdraw()
     topLevel = tkinter.Toplevel(tk)
     topLevel.resizable(width=NO, height=NO)
-    topLevel.title("Microwave oven")
+    topLevel.title("Microwave oven simulator")
     gui = GUI.GUI(topLevel, send_event)
 
     def on_output(event):

BIN
examples/microwave/running.wav