SCCD_Example.mvc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. include "primitives.alh"
  2. Diagram SCCD_my_PM {
  3. name = "SCCD example "
  4. {diagram_classes} Class A {
  5. name = "A"
  6. constructor_body = $
  7. Void function constructor(attributes : Element, parameters : Element):
  8. dict_add(attributes, "id", '')
  9. dict_add(attributes, "parent_id", '')
  10. return !
  11. $
  12. {behaviour} CompositeState root_a {
  13. name = "main"
  14. isInitial = True
  15. {composite_children} BasicState initial_a {
  16. name = "Init"
  17. isInitial = True
  18. }
  19. {composite_children} BasicState running_a {
  20. name = "Running"
  21. isInitial = False
  22. }
  23. {composite_children} BasicState done_a {
  24. name = "Done"
  25. isInitial = False
  26. }
  27. }
  28. }
  29. {diagram_classes} Class B {
  30. name = "B"
  31. constructor_body = $
  32. Void function constructor(attributes : Element, parameters : Element):
  33. dict_add(attributes, "id", '')
  34. dict_add(attributes, "parent_id", '')
  35. return !
  36. $
  37. {behaviour} CompositeState root_b {
  38. name = "main"
  39. isInitial = True
  40. {composite_children} BasicState initial_b {
  41. name = "Init"
  42. isInitial = True
  43. }
  44. {composite_children} BasicState running_b {
  45. name = "Running"
  46. isInitial = False
  47. }
  48. {composite_children} BasicState done_b {
  49. name = "Done"
  50. isInitial = False
  51. }
  52. }
  53. }
  54. {diagram_classes} Class C {
  55. name = "C"
  56. constructor_body = $
  57. Void function constructor(attributes : Element, parameters : Element):
  58. dict_add(attributes, "id", '')
  59. dict_add(attributes, "parent_id", '')
  60. return !
  61. $
  62. {behaviour} CompositeState root_c {
  63. name = "main"
  64. isInitial = True
  65. {composite_children} BasicState initial_c {
  66. name = "Init"
  67. isInitial = True
  68. }
  69. {composite_children} BasicState running_c {
  70. name = "Running"
  71. isInitial = False
  72. }
  73. {composite_children} BasicState done_c {
  74. name = "Done"
  75. isInitial = False
  76. }
  77. }
  78. }
  79. {diagram_classes} Class E {
  80. name = "E"
  81. constructor_body = $
  82. Void function constructor(attributes : Element, parameters : Element):
  83. dict_add(attributes, "id", '')
  84. dict_add(attributes, "parent_id", '')
  85. return !
  86. $
  87. {behaviour} CompositeState root_e {
  88. name = "main"
  89. isInitial = True
  90. {composite_children} BasicState initial_e {
  91. name = "Init"
  92. isInitial = True
  93. }
  94. {composite_children} BasicState running_e {
  95. name = "Running"
  96. isInitial = False
  97. {state_onentry_raises} Raise {
  98. event = "save"
  99. scope = "narrow"
  100. target = $
  101. Element function raise(attributes : Element):
  102. return attributes["parent_id"]!
  103. $
  104. parameters = $
  105. Element function raise(attributes : Element):
  106. Element result
  107. result = list_create()
  108. list_append(result, "bool")
  109. list_append(result, "E")
  110. return result!
  111. $
  112. }
  113. }
  114. {composite_children} BasicState done_e {
  115. name = "Done"
  116. isInitial = False
  117. }
  118. }
  119. }
  120. {diagram_classes} Class D {
  121. name = "D"
  122. constructor_body = $
  123. Void function constructor(attributes : Element, parameters : Element):
  124. dict_add(attributes, "id", '')
  125. dict_add(attributes, "parent_id", '')
  126. return !
  127. $
  128. {behaviour} CompositeState root_d {
  129. name = "main"
  130. isInitial = True
  131. {composite_children} BasicState initial_d {
  132. name = "Init"
  133. isInitial = True
  134. }
  135. {composite_children} BasicState running_d {
  136. name = "Running"
  137. isInitial = False
  138. }
  139. {composite_children} BasicState done_d {
  140. name = "Done"
  141. isInitial = False
  142. }
  143. }
  144. }
  145. {diagram_classes} Class F {
  146. name = "F"
  147. constructor_body = $
  148. Void function constructor(attributes : Element, parameters : Element):
  149. dict_add(attributes, "id", '')
  150. dict_add(attributes, "parent_id", '')
  151. return !
  152. $
  153. {behaviour} CompositeState root_f {
  154. name = "main"
  155. isInitial = True
  156. {composite_children} BasicState initial_f {
  157. name = "Init"
  158. isInitial = True
  159. }
  160. {composite_children} BasicState running_f {
  161. name = "Running"
  162. isInitial = False
  163. }
  164. {composite_children} BasicState done_f {
  165. name = "Done"
  166. isInitial = False
  167. }
  168. }
  169. }
  170. }
  171. transition (initial_a, running_a){
  172. event = "set_id"
  173. script = $
  174. Void function script(attributes : Element, parameters : Element):
  175. dict_overwrite(attributes, "id", parameters[0])
  176. dict_overwrite(attributes, "parent_id", parameters[1])
  177. log("CREATED ---- A")
  178. return!
  179. $
  180. }
  181. transition (running_a, done_a){
  182. after = $
  183. Float function after(attributes : Element):
  184. return 0.5!
  185. $
  186. script = $
  187. Void function script(attributes : Element, parameters : Element):
  188. log("FINISHED ---- A")
  189. return!
  190. $
  191. {transition_raises} Raise {
  192. scope = "narrow"
  193. event = "terminated"
  194. target = $
  195. String function raise(attributes : Element):
  196. return attributes["parent_id"]!
  197. $
  198. parameters = $
  199. Element function raise(attributes : Element, parameters : Element):
  200. Element result
  201. result = list_create()
  202. list_append(result, 'A')
  203. return result!
  204. $
  205. }
  206. {transition_raises} Raise {
  207. scope = "cd"
  208. event = "delete_instance"
  209. parameters = $
  210. Element function raise(attributes : Element, parameters : Element):
  211. Element result
  212. result = list_create()
  213. list_append(result, attributes["id"])
  214. return result!
  215. $
  216. }
  217. }
  218. transition (initial_b, running_b){
  219. event = "set_id"
  220. script = $
  221. Void function script(attributes : Element, parameters : Element):
  222. dict_overwrite(attributes, "id", parameters[0])
  223. dict_overwrite(attributes, "parent_id", parameters[1])
  224. log("CREATED ---- B")
  225. return!
  226. $
  227. }
  228. transition (running_b, done_b){
  229. after = $
  230. Float function after(attributes : Element):
  231. return 0.9!
  232. $
  233. script = $
  234. Void function script(attributes : Element, parameters : Element):
  235. log("FINISHED ---- B")
  236. return!
  237. $
  238. {transition_raises} Raise {
  239. scope = "narrow"
  240. event = "terminated"
  241. target = $
  242. Element function raise(attributes : Element):
  243. return attributes["parent_id"]!
  244. $
  245. parameters = $
  246. Element function raise(attributes : Element, parameters : Element):
  247. Element result
  248. result = list_create()
  249. list_append(result, 'B')
  250. return result!
  251. $
  252. }
  253. {transition_raises} Raise {
  254. scope = "cd"
  255. event = "delete_instance"
  256. parameters = $
  257. Element function raise(attributes : Element, parameters : Element):
  258. Element result
  259. result = list_create()
  260. list_append(result, attributes["id"])
  261. return result!
  262. $
  263. }
  264. }
  265. transition (initial_c, running_c){
  266. event = "set_id"
  267. script = $
  268. Void function script(attributes : Element, parameters : Element):
  269. dict_overwrite(attributes, "id", parameters[0])
  270. dict_overwrite(attributes, "parent_id", parameters[1])
  271. log("CREATED ---- C")
  272. return!
  273. $
  274. }
  275. transition (running_c, done_c){
  276. after = $
  277. Float function after(attributes : Element):
  278. return 0.5!
  279. $
  280. script = $
  281. Void function script(attributes : Element, parameters : Element):
  282. log("FINISHED ---- C")
  283. return!
  284. $
  285. {transition_raises} Raise {
  286. scope = "narrow"
  287. event = "terminated"
  288. target = $
  289. Element function raise(attributes : Element):
  290. return attributes["parent_id"]!
  291. $
  292. parameters = $
  293. Element function raise(attributes : Element, parameters : Element):
  294. Element result
  295. result = list_create()
  296. list_append(result, "C")
  297. return result!
  298. $
  299. }
  300. {transition_raises} Raise {
  301. scope = "cd"
  302. event = "delete_instance"
  303. parameters = $
  304. Element function raise(attributes : Element, parameters : Element):
  305. Element result
  306. result = list_create()
  307. list_append(result, attributes["id"])
  308. return result!
  309. $
  310. }
  311. }
  312. transition (initial_e, running_e){
  313. event = "set_id"
  314. script = $
  315. Void function script(attributes : Element, parameters : Element):
  316. dict_overwrite(attributes, "id", parameters[0])
  317. dict_overwrite(attributes, "parent_id", parameters[1])
  318. log("CREATED ---- E")
  319. return!
  320. $
  321. }
  322. transition (running_e, done_e){
  323. after = $
  324. Float function after(attributes : Element):
  325. return 0.5!
  326. $
  327. script = $
  328. Void function script(attributes : Element, parameters : Element):
  329. log("FINISHED ---- E")
  330. return!
  331. $
  332. {transition_raises} Raise {
  333. scope = "narrow"
  334. event = "terminated"
  335. target = $
  336. Element function raise(attributes : Element):
  337. return attributes["parent_id"]!
  338. $
  339. parameters = $
  340. Element function raise(attributes : Element, parameters : Element):
  341. Element result
  342. result = list_create()
  343. list_append(result, "E")
  344. return result!
  345. $
  346. }
  347. {transition_raises} Raise {
  348. scope = "cd"
  349. event = "delete_instance"
  350. parameters = $
  351. Element function raise(attributes : Element, parameters : Element):
  352. Element result
  353. result = list_create()
  354. list_append(result, attributes["id"])
  355. return result!
  356. $
  357. }
  358. }
  359. transition (initial_f, running_f){
  360. event = "set_id"
  361. script = $
  362. Void function script(attributes : Element, parameters : Element):
  363. dict_overwrite(attributes, "id", parameters[0])
  364. dict_overwrite(attributes, "parent_id", parameters[1])
  365. log("CREATED ---- F")
  366. return!
  367. $
  368. }
  369. transition (running_f, done_f){
  370. after = $
  371. Float function after(attributes : Element):
  372. return 0.5!
  373. $
  374. script = $
  375. Void function script(attributes : Element, parameters : Element):
  376. log("FINISHED ---- F")
  377. return!
  378. $
  379. {transition_raises} Raise {
  380. scope = "narrow"
  381. event = "terminated"
  382. target = $
  383. Element function raise(attributes : Element):
  384. return attributes["parent_id"]!
  385. $
  386. parameters = $
  387. Element function raise(attributes : Element, parameters : Element):
  388. Element result
  389. result = list_create()
  390. list_append(result, attributes['id'])
  391. return result!
  392. $
  393. }
  394. {transition_raises} Raise {
  395. scope = "cd"
  396. event = "delete_instance"
  397. parameters = $
  398. Element function raise(attributes : Element, parameters : Element):
  399. Element result
  400. result = list_create()
  401. list_append(result, attributes["id"])
  402. return result!
  403. $
  404. }
  405. }