CBD_mapper.mvc 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. include "primitives.alh"
  2. include "modelling.alh"
  3. include "object_operations.alh"
  4. Composite schedule {
  5. {Contains} Success success {}
  6. {Contains} Failure failure {}
  7. {Contains} ForAll render_blocks {
  8. LHS {
  9. Pre_abstract/Block pre_block_0 {
  10. label = "0"
  11. }
  12. constraint = $
  13. Boolean function constraint(model : Element, mapping : Element):
  14. Element trace_links
  15. trace_links = allOutgoingAssociationInstances(model, mapping["0"], "TracabilityLink")
  16. if (read_nr_out(trace_links) > 0):
  17. log("Block already connected; ignoring!")
  18. return False!
  19. else:
  20. return True!
  21. $
  22. }
  23. RHS {
  24. Post_abstract/Block post_block_0 {
  25. label = "0"
  26. }
  27. Post_rendered/Group post_block_1 {
  28. label = "1"
  29. value___asid = $
  30. String function value(model : Element, name : String, mapping : Element):
  31. return mapping["0"]!
  32. $
  33. value_x = $
  34. Integer function value(model : Element, name : String, mapping : Element):
  35. return 0!
  36. $
  37. value_y = $
  38. Integer function value(model : Element, name : String, mapping : Element):
  39. return 0!
  40. $
  41. }
  42. Post_rendered/Rectangle post_block_2 {
  43. label = "2"
  44. value_x = $
  45. Integer function value(model : Element, name : String, mapping : Element):
  46. return 0!
  47. $
  48. value_y = $
  49. Integer function value(model : Element, name : String, mapping : Element):
  50. return 0!
  51. $
  52. value_width = $
  53. Integer function value(model : Element, name : String, mapping : Element):
  54. return 30!
  55. $
  56. value_height = $
  57. Integer function value(model : Element, name : String, mapping : Element):
  58. return 30!
  59. $
  60. value_lineWidth = $
  61. Integer function value(model : Element, name : String, mapping : Element):
  62. return 2!
  63. $
  64. value_lineColour = $
  65. String function value(model : Element, name : String, mapping : Element):
  66. return "black"!
  67. $
  68. value_fillColour = $
  69. String function value(model : Element, name : String, mapping : Element):
  70. return "white"!
  71. $
  72. }
  73. Post_rendered/Text post_block_3 {
  74. label = "3"
  75. value_x = $
  76. Integer function value(model : Element, name : String, mapping : Element):
  77. return 10!
  78. $
  79. value_y = $
  80. Integer function value(model : Element, name : String, mapping : Element):
  81. return 10!
  82. $
  83. value_lineWidth = $
  84. Integer function value(model : Element, name : String, mapping : Element):
  85. return 1!
  86. $
  87. value_lineColour = $
  88. String function value(model : Element, name : String, mapping : Element):
  89. return "black"!
  90. $
  91. value_text = $
  92. String function value(model : Element, name : String, mapping : Element):
  93. String type
  94. type = read_type(model, mapping["0"])
  95. if (type == "abstract/AdditionBlock"):
  96. return "+"!
  97. elif (type == "abstract/NegatorBlock"):
  98. return "-"!
  99. elif (type == "abstract/ConstantBlock"):
  100. return "c"!
  101. elif (type == "abstract/MultiplyBlock"):
  102. return "*"!
  103. elif (type == "abstract/InverseBlock"):
  104. return "/"!
  105. elif (type == "abstract/DerivatorBlock"):
  106. return "d/dx"!
  107. elif (type == "abstract/IntegratorBlock"):
  108. return "1/s"!
  109. elif (type == "abstract/DelayBlock"):
  110. return "DELAY"!
  111. elif (type == "abstract/ProbeBlock"):
  112. return "PROBE"!
  113. else:
  114. return ("Unknown type: " + type)!
  115. $
  116. }
  117. Post_rendered/contains (post_block_1, post_block_2) {
  118. label = "4"
  119. }
  120. Post_rendered/contains (post_block_1, post_block_3) {
  121. label = "5"
  122. }
  123. Post_TracabilityLink (post_block_0, post_block_1) {
  124. label = "6"
  125. }
  126. }
  127. }
  128. {Contains} ForAll remove_connections {
  129. LHS {
  130. Pre_rendered/Line {
  131. label = "0"
  132. }
  133. }
  134. RHS {
  135. }
  136. }
  137. {Contains} ForAll render_connections {
  138. LHS {
  139. Pre_abstract/Block pre_conn_0 {
  140. label = "0"
  141. }
  142. Pre_abstract/Block pre_conn_1 {
  143. label = "1"
  144. }
  145. Pre_abstract/Link (pre_conn_0, pre_conn_1){
  146. label = "2"
  147. }
  148. Pre_rendered/Group pre_conn_3 {
  149. label = "3"
  150. }
  151. Pre_rendered/Group pre_conn_4 {
  152. label = "4"
  153. }
  154. Pre_TracabilityLink (pre_conn_0, pre_conn_3) {
  155. label = "5"
  156. }
  157. Pre_TracabilityLink (pre_conn_1, pre_conn_4) {
  158. label = "6"
  159. }
  160. }
  161. RHS {
  162. Post_abstract/Block post_conn_0 {
  163. label = "0"
  164. }
  165. Post_abstract/Block post_conn_1 {
  166. label = "1"
  167. }
  168. Post_abstract/Link (post_conn_0, post_conn_1){
  169. label = "2"
  170. }
  171. Post_rendered/Group post_conn_3 {
  172. label = "3"
  173. }
  174. Post_rendered/Group post_conn_4 {
  175. label = "4"
  176. }
  177. Post_TracabilityLink (post_conn_0, post_conn_3) {
  178. label = "5"
  179. }
  180. Post_TracabilityLink (post_conn_1, post_conn_4) {
  181. label = "6"
  182. }
  183. Post_rendered/Line {
  184. label = "7"
  185. value___asid = $
  186. String function value(model : Element, name : String, mapping : Element):
  187. return mapping["2"]!
  188. $
  189. value_x = $
  190. Integer function value(model : Element, name : String, mapping : Element):
  191. return read_attribute(model, mapping["3"], "x")!
  192. $
  193. value_y = $
  194. Integer function value(model : Element, name : String, mapping : Element):
  195. return read_attribute(model, mapping["3"], "y")!
  196. $
  197. value_lineWidth = $
  198. Integer function value(model : Element, name : String, mapping : Element):
  199. return 1!
  200. $
  201. value_lineColour = $
  202. String function value(model : Element, name : String, mapping : Element):
  203. if (read_type(model, name) == "ICLink"):
  204. return "red"!
  205. else:
  206. return "black"!
  207. $
  208. value_targetX = $
  209. Integer function value(model : Element, name : String, mapping : Element):
  210. return read_attribute(model, mapping["4"], "x")!
  211. $
  212. value_targetY = $
  213. Integer function value(model : Element, name : String, mapping : Element):
  214. return read_attribute(model, mapping["4"], "y")!
  215. $
  216. }
  217. }
  218. }
  219. }
  220. Initial (schedule, render_blocks) {}
  221. OnSuccess (render_blocks, remove_connections) {}
  222. OnFailure (render_blocks, remove_connections) {}
  223. OnSuccess (remove_connections, render_connections) {}
  224. OnFailure (remove_connections, render_connections) {}
  225. OnSuccess (render_connections, success) {}
  226. OnFailure (render_connections, success) {}