minimal_SCCD.mvc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. constructor_body = $
  10. Void function const(attributes : Element, parameters : Element):
  11. dict_overwrite(attributes, "a", 0)
  12. if (element_eq(parameters, read_root())):
  13. dict_overwrite(attributes, "id", 0)
  14. else:
  15. dict_overwrite(attributes, "id", parameters)
  16. return !
  17. $
  18. }
  19. Attribute attr_a {
  20. name = "a"
  21. }
  22. Attribute attr_b {
  23. name = "id"
  24. }
  25. class_attributes (main, attr_a) {}
  26. class_attributes (main, attr_b) {}
  27. CompositeState main_statechart {
  28. name = "root"
  29. isInitial = True
  30. {composite_children} BasicState init {
  31. name = "initial"
  32. isInitial = True
  33. onEntryScript = $
  34. Void function entry(attributes : Element):
  35. log("ENTRY initial")
  36. return!
  37. $
  38. }
  39. {composite_children} BasicState exit {
  40. name = "exit"
  41. isInitial = False
  42. onEntryScript = $
  43. Void function entry(attributes : Element):
  44. log("ENTRY exit")
  45. return!
  46. $
  47. }
  48. {composite_children} ParallelState main_parallel {
  49. name = "parallel"
  50. isInitial = False
  51. {parallel_children} CompositeState parallel_x {
  52. {composite_children} BasicState x_a {
  53. name = "xa"
  54. isInitial = True
  55. onEntryScript = $
  56. Void function entry(attributes : Element):
  57. log("ENTRY xa")
  58. return!
  59. $
  60. onExitScript = $
  61. Void function exit(attributes : Element):
  62. log("EXIT xa")
  63. return!
  64. $
  65. }
  66. {composite_children} BasicState x_b {
  67. name = "xb"
  68. isInitial = False
  69. onEntryScript = $
  70. Void function entry(attributes : Element):
  71. log("ENTRY xb")
  72. return!
  73. $
  74. onExitScript = $
  75. Void function exit(attributes : Element):
  76. log("EXIT xb")
  77. return!
  78. $
  79. }
  80. {composite_children} BasicState x_c {
  81. name = "xc"
  82. isInitial = False
  83. }
  84. {composite_children} BasicState x_d {
  85. name = "xd"
  86. isInitial = False
  87. }
  88. }
  89. {parallel_children} CompositeState parallel_y {
  90. {composite_children} BasicState y_a {
  91. name = "ya"
  92. isInitial = True
  93. }
  94. {composite_children} BasicState y_b {
  95. name = "yb"
  96. isInitial = False
  97. }
  98. }
  99. }
  100. }
  101. transition (x_a, x_b) {
  102. name = "X"
  103. event = "X"
  104. script = $
  105. Void function script(attributes : Element, evt_param : Element):
  106. log("In script")
  107. dict_overwrite(attributes, "a", 1)
  108. dict_overwrite(attributes, "id", 2)
  109. return!
  110. $
  111. }
  112. transition (x_a, x_d) {
  113. name = "timeout"
  114. after = $
  115. Float function after(attributes : Element):
  116. log("In after")
  117. return 3.0!
  118. $
  119. }
  120. transition (x_b, x_c) {
  121. name = "Z"
  122. cond = $
  123. Boolean function cond(attributes : Element, evt_param : Element):
  124. log("In condition")
  125. return integer_lt(attributes["a"], attributes["id"])!
  126. $
  127. }
  128. transition transition_y (y_a, y_b) {
  129. name = "Y"
  130. event = "Y"
  131. }
  132. Raise create_new_class {
  133. scope = "cd"
  134. event = "create_instance"
  135. parameter = $
  136. Element function func(attributes : Element, parameters : Element):
  137. Element result
  138. log("Executing create_instance!")
  139. result = create_node()
  140. list_append(result, "Main")
  141. list_append(result, attributes["id"])
  142. dict_overwrite(attributes, "id", integer_addition(attributes["id"], 1))
  143. list_append(result, attributes["id"])
  144. return result!
  145. $
  146. }
  147. transition_raises (transition_y, create_new_class) {}
  148. transition (init, main_parallel) {
  149. name = "init"
  150. event = "init"
  151. }
  152. transition (main_parallel, exit) {
  153. name = "exit"
  154. event = "exit"
  155. }
  156. diagram_classes (my_SCCD, main) {}
  157. behaviour (main, main_statechart) {}