CBD_mapper.mvc 10 KB

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