statechart_stove.xml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <statechart>
  2. <!-- this statechart is shown as an example in the thesis -->
  3. <!-- is included here and can be "checked" for syntax correctness with the tool in sccd.statechart.cmd.check_model -->
  4. <datamodel>
  5. burners = [0, 0, 0, 0];
  6. selected = 0;
  7. min = func(a: int, b: int) {
  8. if (a &lt; b) return a;
  9. return b;
  10. };
  11. increase = func {
  12. burners[selected] = min(burners[selected] + 1, 9);
  13. };
  14. </datamodel>
  15. <inport name="in">
  16. <event name="pressed_increase"/>
  17. <event name="released_increase"/>
  18. <event name="select_next"/>
  19. </inport>
  20. <root>
  21. <parallel id="p">
  22. <!-- upper orthogonal region -->
  23. <state id="heat" initial="Released">
  24. <state id="Released">
  25. <transition event="pressed_increase" target="../Pushed"/>
  26. </state>
  27. <state id="Pushed" initial="Waiting">
  28. <onentry>
  29. <code> increase(); </code>
  30. </onentry>
  31. <transition event="released_increase" target="../Released"/>
  32. <state id="Waiting">
  33. <transition after="1 s" target="../Increasing"/>
  34. </state>
  35. <state id="Increasing">
  36. <transition after="200 ms" target=".">
  37. <code> increase(); </code>
  38. </transition>
  39. </state>
  40. </state>
  41. </state>
  42. <!-- lower orthogonal region -->
  43. <state id="burner_select">
  44. <state id="BurnerSelect">
  45. <transition event="select_next" target=".">
  46. <code> selected = (selected + 1) % 4; </code>
  47. </transition>
  48. </state>
  49. </state>
  50. </parallel>
  51. </root>
  52. </statechart>