minimal_SCCD.mvc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. include "primitives.alh"
  2. Diagram my_SCCD {
  3. name = "SimpleSCCD"
  4. author = "Yentl"
  5. }
  6. Class main {
  7. name = "Main"
  8. default = True
  9. }
  10. Attribute attr_a {
  11. name = "a"
  12. }
  13. Attribute attr_b {
  14. name = "b"
  15. }
  16. class_attributes (main, attr_a) {}
  17. class_attributes (main, attr_b) {}
  18. CompositeState main_statechart {
  19. name = "root"
  20. isInitial = True
  21. {composite_children} BasicState init {
  22. name = "initial"
  23. isInitial = True
  24. onEntryScript = $
  25. Void function entry(attributes : Element):
  26. log("ENTRY initial")
  27. return!
  28. $
  29. }
  30. {composite_children} BasicState exit {
  31. name = "exit"
  32. isInitial = False
  33. onEntryScript = $
  34. Void function entry(attributes : Element):
  35. log("ENTRY exit")
  36. return!
  37. $
  38. }
  39. {composite_children} ParallelState main_parallel {
  40. name = "parallel"
  41. isInitial = False
  42. {parallel_children} CompositeState parallel_x {
  43. {composite_children} BasicState x_a {
  44. name = "xa"
  45. isInitial = True
  46. onEntryScript = $
  47. Void function entry(attributes : Element):
  48. log("ENTRY xa")
  49. return!
  50. $
  51. onExitScript = $
  52. Void function exit(attributes : Element):
  53. log("EXIT xa")
  54. return!
  55. $
  56. }
  57. {composite_children} BasicState x_b {
  58. name = "xb"
  59. isInitial = False
  60. onEntryScript = $
  61. Void function entry(attributes : Element):
  62. log("ENTRY xb")
  63. return!
  64. $
  65. onExitScript = $
  66. Void function exit(attributes : Element):
  67. log("EXIT xb")
  68. return!
  69. $
  70. }
  71. {composite_children} BasicState x_c {
  72. name = "xc"
  73. isInitial = False
  74. }
  75. {composite_children} BasicState x_d {
  76. name = "xd"
  77. isInitial = False
  78. }
  79. }
  80. {parallel_children} CompositeState parallel_y {
  81. {composite_children} BasicState y_a {
  82. name = "ya"
  83. isInitial = True
  84. }
  85. {composite_children} BasicState y_b {
  86. name = "yb"
  87. isInitial = False
  88. }
  89. }
  90. }
  91. }
  92. transition (x_a, x_b) {
  93. name = "X"
  94. event = "X"
  95. script = $
  96. Void function script(attributes : Element):
  97. log("In script")
  98. dict_overwrite(attributes, "a", 1)
  99. dict_overwrite(attributes, "b", 2)
  100. return!
  101. $
  102. }
  103. transition (x_a, x_d) {
  104. name = "timeout"
  105. after = $
  106. Float function after(attributes : Element):
  107. log("In after")
  108. return 3.0!
  109. $
  110. }
  111. transition (x_b, x_c) {
  112. name = "Z"
  113. cond = $
  114. Boolean function cond(attributes : Element):
  115. log("In condition")
  116. return integer_lt(attributes["a"], attributes["b"])!
  117. $
  118. }
  119. transition (y_a, y_b) {
  120. name = "Y"
  121. event = "Y"
  122. }
  123. transition (init, main_parallel) {
  124. name = "init"
  125. event = "init"
  126. }
  127. transition (main_parallel, exit) {
  128. name = "exit"
  129. event = "exit"
  130. }
  131. diagram_classes (my_SCCD, main) {}
  132. behaviour (main, main_statechart) {}