Переглянути джерело

Added simple mapper for CBD models (untested)

Yentl Van Tendeloo 8 роки тому
батько
коміт
10d61a6caf
1 змінених файлів з 198 додано та 0 видалено
  1. 198 0
      models/CBD_mapper.mvc

+ 198 - 0
models/CBD_mapper.mvc

@@ -0,0 +1,198 @@
+include "primitives.alh"
+include "modelling.alh"
+include "object_operations.alh"
+
+A B {
+    Composite schedule {
+        {Contains} Success success {}
+
+        {Contains} ForAll render_blocks {
+            LHS {
+                Pre_CBD/Block pre_block_0 {
+                    label = "0"
+                }
+            }
+            RHS {
+                Post_CBD/Block post_block_0 {
+                    label = "0"
+                }
+                Post_Rendered/Group post_block_1 {
+                    label = "1"
+                    post_x = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                    post_y = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                }
+                Post_Rendered/Rectangle post_block_2 {
+                    label = "2"
+                    post_x = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                    post_y = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
+                    post_width = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 10!
+                        $
+                    post_height = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 10!
+                        $
+                    post_lineWidth = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 2!
+                        $
+                    post_lineColour = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "black"!
+                        $
+                    post_fillColour = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "white"!
+                        $
+                }
+                Post_Rendered/Text post_block_3 {
+                    label = "3"
+                    post_x = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 10!
+                        $
+                    post_y = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 10!
+                        $
+                    post_lineWidth = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 1!
+                        $
+                    post_lineColour = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            return "black"!
+                        $
+                    post_content = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            String type
+                            type = read_type(model, name)
+                            if (type == "AdditionBlock"):
+                                return "+"!
+                            elif (type == "NegatorBlock"):
+                                return "-"!
+                            elif (type == "MultiplyBlock"):
+                                return "*"!
+                            elif (type == "InverseBlock"):
+                                return "/"!
+                            elif (type == "DerivatorBlock"):
+                                return "d/dx"!
+                            elif (type == "IntegratorBlock"):
+                                return "1/s"!
+                            elif (type == "DelayBlock"):
+                                return "DELAY"!
+                            elif (type == "ProbeBlock"):
+                                return "PROBE"!
+                        $
+                }
+                Post_Rendered/contains (post_block_1, post_block2) {}
+                Post_Rendered/contains (post_block_1, post_block3) {}
+
+                Post_Tracability (post_block_0, post_block_1) {}
+            }
+        }
+
+        {Contains} ForAll render_connections {
+            LHS {
+                Pre_CBD/Block pre_conn_0 {
+                    label = "0"
+                }
+
+                Pre_CBD/Block pre_conn_1 {
+                    label = "1"
+                }
+
+                Pre_CBD/Link (pre_conn_0, pre_conn_1){
+                    label = "2"
+                }
+
+                Pre_Rendered/Group pre_conn_3 {
+                    label = "3"
+                }
+
+                Pre_Rendered/Group pre_conn_4 {
+                    label = "4"
+                }
+
+                Pre_Tracability (pre_conn_0, pre_conn_3) {}
+                Pre_Tracability (pre_conn_0, pre_conn_4) {}
+            }
+            RHS {
+                Post_CBD/Block post_conn_0 {
+                    label = "0"
+                }
+
+                Post_CBD/Block post_conn_1 {
+                    label = "1"
+                }
+
+                Post_CBD/Link (post_conn_0, post_conn_1){
+                    label = "2"
+                }
+
+                Post_Rendered/Group post_conn_3 {
+                    label = "3"
+                }
+
+                Post_Rendered/Group post_conn_4 {
+                    label = "4"
+                }
+
+                Post_Tracability (post_conn_0, post_conn_3) {}
+                Post_Tracability (post_conn_0, post_conn_4) {}
+
+                Post_Rendered/Link {
+                    label = "5"
+                    post_x = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["3"], "x")!
+                        $
+                    post_y = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["3"], "y")!
+                        $
+                    post_lineWidth = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 1!
+                        $
+                    post_lineColour = $
+                        String function value(model : Element, name : String, mapping : Element):
+                            if (read_type(model, name) == "ICLink"):
+                                return "red"!
+                            else:
+                                return "black"!
+                        $
+                    post_targetX = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["4"], "x")!
+                        $
+                    post_targetY = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["4"], "y")!
+                        $
+                }
+            }
+        }
+    }
+
+    Initial (schedule, render_blocks) {}
+
+    OnSuccess (render_blocks, render_connections) {}
+    OnFailure (render_blocks, render_connections) {}
+
+    OnSuccess (render_connections, success) {}
+    OnFailure (render_connections, success) {}
+}