1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?xml version="1.0" ?>
- <diagram author="Simon Van Mierlo" name="Timer">
- <inport name="ui" />
- <class name="MainApp" default="true">
- <method name="MainApp">
- <body>
- <![CDATA[
- this.canvas = ui.append_canvas(ui.window,400,150,{'background':'#eee'})
- this.clock_text = this.canvas.add_text(25,25,'0.0')
- this.actual_clock_text = this.canvas.add_text(25,50,'0.0')
- var interrupt_button = ui.append_button(ui.window, 'INTERRUPT');
- var continue_button = ui.append_button(ui.window, 'CONTINUE');
- ui.bind_event(interrupt_button.element, ui.EVENTS.MOUSE_CLICK, this.controller, 'interrupt_clicked');
- ui.bind_event(continue_button.element, ui.EVENTS.MOUSE_CLICK, this.controller, 'continue_clicked');
- ]]>
- </body>
- </method>
- <method name="update_timers">
- <body>
- this.clock_text.set_text((this.getSimulatedTime() / 1000).toFixed(2));
- this.actual_clock_text.set_text((this.getSimulatedTime() / 1000).toFixed(2));
- </body>
- </method>
- <scxml initial="running">
- <state id="running">
- <transition target="." after="0.05">
- <script>
- this.update_timers();
- </script>
- </transition>
- <transition target="../interrupted" event="interrupt_clicked" port="ui">
- <script>
- this.update_timers();
- </script>
- </transition>
- </state>
- <state id="interrupted">
- <transition target="." event="interrupt_clicked" port="ui">
- <script>
- this.update_timers();
- </script>
- </transition>
- <transition target="../running" event="continue_clicked" port="ui">
- <script>
- this.update_timers();
- </script>
- </transition>
- </state>
- </scxml>
- </class>
- </diagram>
|