CBD_mapper.mvc 11 KB

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