CBD_mapper.mvc 10 KB

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