model_01c_flat_nodoor.xml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <single_instance_cd>
  2. <!-- "Syntactic"-variant with "Choice" state, modeled as non-stable state -->
  3. <delta>1 ms</delta>
  4. <statechart>
  5. <semantics
  6. big_step_maximality="syntactic"
  7. input_event_lifeline="whole"
  8. same_source_priority="explicit"
  9. />
  10. <datamodel>
  11. import GUI;
  12. time = 0;
  13. checkStartTime = func {
  14. if (time == 0) {
  15. time = 30;
  16. display_time(time);
  17. }
  18. };
  19. </datamodel>
  20. <inport name="in">
  21. <event name="start"/>
  22. <event name="stop"/>
  23. <event name="increase_time"/>
  24. <event name="door_opened"/>
  25. <event name="door_closed"/>
  26. </inport>
  27. <outport name="out">
  28. <event name="micro_on"/>
  29. <event name="micro_off"/>
  30. <event name="bell"/>
  31. </outport>
  32. <root initial="NotRunning">
  33. <state id="Running" initial="Running">
  34. <onentry> <raise port="out" event="micro_on"/> </onentry>
  35. <onexit> <raise port="out" event="micro_off"/> </onexit>
  36. <transition port="in" event="stop" target="../NotRunning"/>
  37. <state id="Running" stable="true">
  38. <transition after="1 s" target="../Choice">
  39. <code> time -= 1; display_time(time); </code>
  40. </transition>
  41. <transition port="in" event="increase_time" target=".">
  42. <code> time += 10; display_time(time); </code>
  43. </transition>
  44. </state>
  45. <state id="Choice">
  46. <transition cond="time > 0" target="../Running"/>
  47. <transition cond="time == 0" target="/NotRunning">
  48. <raise port="out" event="bell"/>
  49. </transition>
  50. </state>
  51. </state>
  52. <state id="NotRunning" stable="true">
  53. <transition port="in" event="start" target="../Running">
  54. <code> checkStartTime(); </code>
  55. </transition>
  56. <transition port="in" event="stop" target=".">
  57. <code> time = 0; display_time(time); </code>
  58. </transition>
  59. <transition port="in" event="increase_time" target=".">
  60. <code> time += 10; display_time(time); </code>
  61. </transition>
  62. </state>
  63. </root>
  64. </statechart>
  65. </single_instance_cd>