Prechádzať zdrojové kódy

Updated rules and their integration

Yentl Van Tendeloo 8 rokov pred
rodič
commit
cf211a3b73

+ 25 - 18
integration/test_powerwindow.py

@@ -41,39 +41,39 @@ class TestPowerWindow(unittest.TestCase):
                 "model_add",
                     "SimpleClassDiagrams",
                     "ReachabilityGraph",
-                    ] + get_model_constructor(open("integration/code/reachability_graph.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("integration/code/reachability_graph.mvc") + [
                 "model_add",
                     "SimpleClassDiagrams",
                     "PetriNet",
-                    ] + get_model_constructor(open("integration/code/pn_design.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("integration/code/pn_design.mvc") + [
                 "model_add",
                     "SimpleClassDiagrams",
                     "Encapsulated_PetriNet",
-                    ] + get_model_constructor(open("models/petrinet_ports.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/petrinet_ports.mvc") + [
                 "model_add",
                     "SimpleClassDiagrams",
                     "PW_Plant",
-                    ] + get_model_constructor(open("models/plant_PW.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/plant_PW.mvc") + [
                 "model_add",
                     "SimpleClassDiagrams",
                     "PW_Environment",
-                    ] + get_model_constructor(open("models/environment_PW.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/environment_PW.mvc") + [
                 "model_add",
                     "SimpleClassDiagrams",
                     "PW_Control",
-                    ] + get_model_constructor(open("models/control_PW.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/control_PW.mvc") + [
                 "model_add",
                     "SimpleClassDiagrams",
                     "Requirements",
-                    ] + get_model_constructor(open("models/requirements.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/requirements.mvc") + [
                 "model_add",
                     "SimpleClassDiagrams",
                     "Query",
-                    ] + get_model_constructor(open("models/query.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/query.mvc") + [
                 "model_add",
                     "ProcessModel",
                     "pm_powerwindow",
-                    ] + get_model_constructor(open("models/pm_req_analyse.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/pm_req_analyse.mvc") + [
                 "model_list",
                 "transformation_add_MT_language",
                 "PetriNet",
@@ -113,24 +113,28 @@ class TestPowerWindow(unittest.TestCase):
                     "",
                     "define_req",
                 "transformation_add_MANUAL",
+                    "Requirements",
                     "PW_Environment",
                     "",
                     "PW_Environment",
                     "",
                     "refine_environment",
                 "transformation_add_MANUAL",
+                    "Requirements",
                     "PW_Plant",
                     "",
                     "PW_Plant",
                     "",
                     "refine_plant",
                 "transformation_add_MANUAL",
+                    "Requirements",
                     "PW_Control",
                     "",
                     "PW_Control",
                     "",
                     "refine_control",
                 "transformation_add_MANUAL",
+                    "Requirements",
                     "Query",
                     "",
                     "Query",
@@ -145,7 +149,7 @@ class TestPowerWindow(unittest.TestCase):
                     "Query",
                     "",
                     "make_initial_models",
-                    ] + get_model_constructor(open("models/initialize.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/initialize.mvc") + [
                 "transformation_add_MT",
                     "All_RAM",
                     "PW_Plant",
@@ -153,7 +157,7 @@ class TestPowerWindow(unittest.TestCase):
                     "Encapsulated_PetriNet",
                     "",
                     "plant_to_EPN",
-                    ] + get_model_constructor(open("models/plant_to_EPN.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/plant_to_EPN.mvc") + [
                 "transformation_add_MT",
                     "All_RAM",
                     "PW_Control",
@@ -161,7 +165,7 @@ class TestPowerWindow(unittest.TestCase):
                     "Encapsulated_PetriNet",
                     "",
                     "control_to_EPN",
-                    ] + get_model_constructor(open("models/control_to_EPN.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/control_to_EPN.mvc") + [
                 "transformation_add_MT",
                     "All_RAM",
                     "PW_Environment",
@@ -169,7 +173,7 @@ class TestPowerWindow(unittest.TestCase):
                     "Encapsulated_PetriNet",
                     "",
                     "environment_to_EPN",
-                    ] + get_model_constructor(open("models/environment_to_EPN.mvc", "r").read()) + [
+                    ] + get_model_constructor_2("models/environment_to_EPN.mvc") + [
                 "transformation_add_AL",
                     "PetriNet",
                     "",
@@ -183,23 +187,23 @@ class TestPowerWindow(unittest.TestCase):
                 "pm_",
                 # define_req
                 "upload",
-                ] + get_model_constructor(open("models/requirements_model.mvc", "r").read()) + [
+                ] + get_model_constructor_2("models/requirements_model.mvc") + [
                 "exit",
                 # refine_plant
                 "upload",
-                ] + get_model_constructor(open("models/plant_model.mvc", "r").read()) + [
+                ] + get_model_constructor_2("models/plant_model.mvc") + [
                 "exit",
                 # refine_environment
                 "upload",
-                ] + get_model_constructor(open("models/environment_model.mvc", "r").read()) + [
+                ] + get_model_constructor_2("models/environment_model.mvc") + [
                 "exit",
                 # refine_control
                 "upload",
-                ] + get_model_constructor(open("models/control_model.mvc", "r").read()) + [
+                ] + get_model_constructor_2("models/control_model.mvc") + [
                 "exit",
                 # refine_query
                 "upload",
-                ] + get_model_constructor(open("models/query_model.mvc", "r").read()) + [
+                ] + get_model_constructor_2("models/query_model.mvc") + [
                 "exit",
             ],
             [   # bootup phase
@@ -264,6 +268,7 @@ class TestPowerWindow(unittest.TestCase):
                 ] + [
                     "Which metamodels do you want to use as source for the manual operation (empty string to finish)?",
                     "Model added as source",
+                    "Model added as source",
                     "Which metamodels do you want to use as target for the manual operation (empty string to finish)?",
                     "Model added as target",
                     "Name of Manual operation model?",
@@ -428,4 +433,6 @@ class TestPowerWindow(unittest.TestCase):
                 "Please give your command.",
                 "Waiting for model constructors...",
                 "Please give your command.",
+                # Computations happen without output
+                "",
             ]))

+ 3 - 2
integration/utils.py

@@ -315,6 +315,7 @@ def get_model_constructor(code):
         f.write(code)
         f.flush()
 
-    constructors = do_compile("__model.mvc", "interface/HUTN/grammars/modelling.g", "M") + ["exit"]
+    return get_model_constructor_2("__model.mvc")
 
-    return constructors
+def get_model_constructor_2(f):
+    return do_compile(f, "interface/HUTN/grammars/modelling.g", "M") + ["exit"]

+ 1 - 1
models/control_PW.mvc

@@ -24,7 +24,7 @@ SimpleClassDiagram Control_PW{
     Class Neutral : State {}
 
     Association Transition (State, State) {
-        objectDetected : TriState
+        objDetected : TriState
     }
     Association UpPressed : Transition (State, State) {}
     Association NonePressed : Transition (State, State) {}

+ 15 - 15
models/control_model.mvc

@@ -1,36 +1,36 @@
 Control_PW control_model_PW {
-    Up up {
+    PW_Control/Up up {
         isInitial = False
         isError = False
         name = "up"
     }
-    Down down {
+    PW_Control/Down down {
         isInitial = False
         isError = False
         name = "down"
     }
-    Neutral neutral {
+    PW_Control/Neutral neutral {
         isInitial = True
         isError = True
         name = "neutral"
     }
 
-    UpPressed (down, neutral) {
-        objectDetected = "*"
+    PW_Control/UpPressed (down, neutral) {
+        objDetected = "*"
     }
-    UpPressed (neutral, up) {
-        objectDetected = "N"
+    PW_Control/UpPressed (neutral, up) {
+        objDetected = "N"
     }
-    DownPressed (up, neutral) {
-        objectDetected = "*"
+    PW_Control/DownPressed (up, neutral) {
+        objDetected = "*"
     }
-    DownPressed (neutral, down) {
-        objectDetected = "*"
+    PW_Control/DownPressed (neutral, down) {
+        objDetected = "*"
     }
-    NonePressed (up, neutral) {
-        objectDetected = "*"
+    PW_Control/NonePressed (up, neutral) {
+        objDetected = "*"
     }
-    NonePressed (down, neutral) {
-        objectDetected = "*"
+    PW_Control/NonePressed (down, neutral) {
+        objDetected = "*"
     }
 }

+ 6 - 10
models/control_to_EPN.mvc

@@ -212,7 +212,7 @@ All_RAM Control2EPN {
                 Post_PW_Control/State post_cs_0 {
                     label = "0"
                 }
-                Post_Encapsulated_PetriNet/Place post_cs1 {
+                Post_Encapsulated_PetriNet/Place post_cs_1 {
                     label = "1"
                     value_name = $
                         String function value(model : Element, name : String, mapping : Element):
@@ -240,7 +240,7 @@ All_RAM Control2EPN {
                 Pre_PW_Control/State pre_ct_1 {
                     label = "1"
                 }
-                Pre_PW_Control/Transition (pre_ct_0, pre_ct_1) {
+                Pre_PW_Control/Transition pre_ct_2 (pre_ct_0, pre_ct_1) {
                     label = "2"
                 }
                 Pre_Encapsulated_PetriNet/Place pre_ct_3 {
@@ -249,10 +249,10 @@ All_RAM Control2EPN {
                 Pre_Encapsulated_PetriNet/Place pre_ct_4 {
                     label = "4"
                 }
-                Pre_CTRL2EPN_link (pre_ct_s1, pre_ct_3) {
+                Pre_CTRL2EPN_link (pre_ct_1, pre_ct_3) {
                     label = "5"
                 }
-                Pre_CTRL2EPN_link (pre_ct_s2, pre_ct_4) {
+                Pre_CTRL2EPN_link (pre_ct_2, pre_ct_4) {
                     label = "6"
                 }
 
@@ -366,10 +366,10 @@ All_RAM Control2EPN {
                 Post_Encapsulated_PetriNet/Place post_ct_7 {
                     label = "7"
                 }
-                Post_Encapsulated_PetriNet/Port post_ct_9 {
+                Post_Encapsulated_PetriNet/Port post_ct_8 {
                     label = "8"
                 }
-                Post_Encapsulated_PetriNet/PortPlace (post_ct_9, post_ct_8) {
+                Post_Encapsulated_PetriNet/PortPlace (post_ct_8, post_ct_7) {
                     label = "9"
                 }
 
@@ -605,10 +605,6 @@ All_RAM Control2EPN {
                 }
                 Post_PW_Control/State post_fi_1 {
                     label = "1"
-                    constraint_isError = $
-                        Boolean function constraint(value : Boolean):
-                            return value!
-                        $
                 }
                 Post_Encapsulated_PetriNet/Place post_fi_2 {
                     label = "2"

+ 7 - 7
models/environment_model.mvc

@@ -1,21 +1,21 @@
 Environment_PW environment_model_PW {
-    Group {
-        Event {
+    PW_Environment/Group {
+        PW_Environment/Event {
             name = "cmdUp"
         }
-        Event {
+        PW_Environment/Event {
             name = "cmdNeutral"
         }
-        Event {
+        PW_Environment/Event {
             name = "cmdDown"
         }
     }
 
-    Group {
-        Event {
+    PW_Environment/Group {
+        PW_Environment/Event {
             name = "objPresent"
         }
-        Event {
+        PW_Environment/Event {
             name = "no_objPresent"
         }
     }

+ 19 - 19
models/environment_to_EPN.mvc

@@ -13,7 +13,7 @@ A B {
                 }
             }
             RHS {
-                Post_PW_Environment/Event {
+                Post_PW_Environment/Event cp_evt {
                     label = "1"
                 }
                 Post_Encapsulated_PetriNet/Place cp_place {
@@ -22,6 +22,10 @@ A B {
                         String function value(model : Element, name : String, mapping : Element):
                             return read_attribute(model, mapping["0"], "name")!
                         $
+                    value_tokens = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return 0!
+                        $
                 }
                 Post_Encapsulated_PetriNet/Port cp_port {
                     label = "3"
@@ -35,10 +39,6 @@ A B {
                 }
                 Post_Encapsulated_PetriNet/PortPlace (cp_port, cp_place) {
                     label = "5"
-                    value_tokens = $
-                        Integer function value(model : Element, name : String, mapping : Element):
-                            return 0!
-                        $
                 }
             }
         }
@@ -59,18 +59,18 @@ A B {
                 Pre_PW_Environment/Contains (pre_grp, pre_evt_b) {
                     label = "5"
                 }
-                Pre_ENV2EPN_link (pre_evt_a, pre_place_a) {
-                    label = "6"
-                }
-                Pre_ENV2EPN_link (pre_evt_b, pre_place_b) {
-                    label = "7"
-                }
                 Pre_Encapsulated_PetriNet/Place pre_place_a {
                     label = "8"
                 }
                 Pre_Encapsulated_PetriNet/Place pre_place_b {
                     label = "9"
                 }
+                Pre_ENV2EPN_link (pre_evt_a, pre_place_a) {
+                    label = "6"
+                }
+                Pre_ENV2EPN_link (pre_evt_b, pre_place_b) {
+                    label = "7"
+                }
             }
             RHS {
                 Post_PW_Environment/Group post_grp {
@@ -88,26 +88,26 @@ A B {
                 Post_PW_Environment/Contains (post_grp, post_evt_b) {
                     label = "5"
                 }
-                Post_ENV2EPN_link (post_evt_a, post_place_a) {
-                    label = "6"
-                }
-                Post_ENV2EPN_link (post_evt_b, post_place_b) {
-                    label = "7"
-                }
                 Post_Encapsulated_PetriNet/Place post_place_a {
                     label = "8"
                 }
                 Post_Encapsulated_PetriNet/Place post_place_b {
                     label = "9"
                 }
+                Post_Encapsulated_PetriNet/Transition post_transition {
+                    label = "12"
+                }
                 Post_Encapsulated_PetriNet/P2T (post_place_a, post_transition) {
                     label = "10"
                 }
                 Post_Encapsulated_PetriNet/T2P (post_transition, post_place_b) {
                     label = "11"
                 }
-                Post_Encapsulated_PetriNet/Transition post_transition {
-                    label = "12"
+                Post_ENV2EPN_link (post_evt_a, post_place_a) {
+                    label = "6"
+                }
+                Post_ENV2EPN_link (post_evt_b, post_place_b) {
+                    label = "7"
                 }
             }
         }

+ 1 - 1
models/plant_PW.mvc

@@ -11,7 +11,7 @@ A B{
     Class NormalState : State {}
 
     Association Transition (State, State) {
-        objectPresent : TriState
+        objPresent : TriState
     }
     Association OnUp : Transition (State, State) {}
     Association OnDown : Transition (State, State) {}

+ 57 - 57
models/plant_model.mvc

@@ -1,113 +1,113 @@
 B C{
-    NormalState lt {
+    PW_Plant/NormalState lt {
         name = "low_top"
         isInitial = False
     }
-    NormalState mt {
+    PW_Plant/NormalState mt {
         name = "medium_top"
         isInitial = False
     }
-    NormalState ht {
+    PW_Plant/NormalState ht {
         name = "high_top"
         isInitial = False
     }
-    NormalState lm {
+    PW_Plant/NormalState lm {
         name = "low_medium"
         isInitial = False
     }
-    ErrorState mm {
+    PW_Plant/ErrorState mm {
         name = "medium_medium"
         isInitial = False
     }
-    ErrorState hm {
+    PW_Plant/ErrorState hm {
         name = "high_medium"
         isInitial = False
     }
-    NormalState lb {
+    PW_Plant/NormalState lb {
         name = "low_bottom"
         isInitial = False
     }
-    NormalState mb {
+    PW_Plant/NormalState mb {
         name = "medium_bottom"
         isInitial = False
     }
-    NormalState hb {
+    PW_Plant/NormalState hb {
         name = "high_bottom"
         isInitial = True
     }
 
-    OnUp (hb, mb) {
-        objectPresent = "*"
+    PW_Plant/OnUp (hb, mb) {
+        objPresent = "*"
     }
-    OnUp (mb, lb) {
-        objectPresent = "*"
+    PW_Plant/OnUp (mb, lb) {
+        objPresent = "*"
     }
-    OnUp (lb, lm) {
-        objectPresent = "*"
+    PW_Plant/OnUp (lb, lm) {
+        objPresent = "*"
     }
-    OnUp (lm, lt) {
-        objectPresent = "N"
+    PW_Plant/OnUp (lm, lt) {
+        objPresent = "N"
     }
-    OnUp (lm, mm) {
-        objectPresent = "Y"
+    PW_Plant/OnUp (lm, mm) {
+        objPresent = "Y"
     }
-    OnUp (mm, hm) {
-        objectPresent = "Y"
+    PW_Plant/OnUp (mm, hm) {
+        objPresent = "Y"
     }
-    OnUp (lt, mt) {
-        objectPresent = "*"
+    PW_Plant/OnUp (lt, mt) {
+        objPresent = "*"
     }
-    OnUp (mt, ht) {
-        objectPresent = "*"
+    PW_Plant/OnUp (mt, ht) {
+        objPresent = "*"
     }
 
-    OnDown (ht, mt) {
-        objectPresent = "*"
+    PW_Plant/OnDown (ht, mt) {
+        objPresent = "*"
     }
-    OnDown (mt, lt) {
-        objectPresent = "*"
+    PW_Plant/OnDown (mt, lt) {
+        objPresent = "*"
     }
-    OnDown (lt, lm) {
-        objectPresent = "*"
+    PW_Plant/OnDown (lt, lm) {
+        objPresent = "*"
     }
-    OnDown (hm, mm) {
-        objectPresent = "*"
+    PW_Plant/OnDown (hm, mm) {
+        objPresent = "*"
     }
-    OnDown (mm, lm) {
-        objectPresent = "*"
+    PW_Plant/OnDown (mm, lm) {
+        objPresent = "*"
     }
-    OnDown (lm, lb) {
-        objectPresent = "*"
+    PW_Plant/OnDown (lm, lb) {
+        objPresent = "*"
     }
-    OnDown (lb, mb) {
-        objectPresent = "*"
+    PW_Plant/OnDown (lb, mb) {
+        objPresent = "*"
     }
-    OnDown (mb, hb) {
-        objectPresent = "*"
+    PW_Plant/OnDown (mb, hb) {
+        objPresent = "*"
     }
 
-    OnNeutral (hb, mb) {
-        objectPresent = "*"
+    PW_Plant/OnNeutral (hb, mb) {
+        objPresent = "*"
     }
-    OnNeutral (mb, lb) {
-        objectPresent = "*"
+    PW_Plant/OnNeutral (mb, lb) {
+        objPresent = "*"
     }
-    OnNeutral (hm, mm) {
-        objectPresent = "*"
+    PW_Plant/OnNeutral (hm, mm) {
+        objPresent = "*"
     }
-    OnNeutral (mm, lm) {
-        objectPresent = "*"
+    PW_Plant/OnNeutral (mm, lm) {
+        objPresent = "*"
     }
-    OnNeutral (hm, mm) {
-        objectPresent = "*"
+    PW_Plant/OnNeutral (hm, mm) {
+        objPresent = "*"
     }
-    OnNeutral (mm, lm) {
-        objectPresent = "*"
+    PW_Plant/OnNeutral (mm, lm) {
+        objPresent = "*"
     }
-    OnNeutral (ht, mt) {
-        objectPresent = "*"
+    PW_Plant/OnNeutral (ht, mt) {
+        objPresent = "*"
     }
-    OnNeutral (mt, lt) {
-        objectPresent = "*"
+    PW_Plant/OnNeutral (mt, lt) {
+        objPresent = "*"
     }
 }

+ 1 - 1
models/plant_to_EPN.mvc

@@ -196,7 +196,7 @@ A B {
                 Post_PW_Plant/State post_cs_0 {
                     label = "0"
                 }
-                Post_Encapsulated_PetriNet/Place post_cs1 {
+                Post_Encapsulated_PetriNet/Place post_cs_1 {
                     label = "1"
                     value_name = $
                         String function value(model : Element, name : String, mapping : Element):

+ 12 - 0
models/query_model.mvc

@@ -0,0 +1,12 @@
+A B {
+    Query/State a {
+        name = "illegal"
+    }
+
+    Query/Place med_mid {
+        name = "med_mid"
+        tokens = 1
+    }
+
+    Query/Contains (a, med_mid) {}
+}

+ 1 - 0
models/requirements.mvc

@@ -13,6 +13,7 @@ SimpleClassDiagrams Requirements{
 
     Class UseCase {
         name : String
+        scope : String
         level : String
         actors : String
         preconditions : String

+ 1 - 1
models/requirements_model.mvc

@@ -1,5 +1,5 @@
 Requirements req {
-    UseCase {
+    Requirements/UseCase {
         name = "Raise passenger window"
         scope = "System-wide"
         postconditions = "Window has stopped."