Selaa lähdekoodia

Merge EPN2PN into combine_EPN

Yentl Van Tendeloo 8 vuotta sitten
vanhempi
commit
dc77ba9cc0
4 muutettua tiedostoa jossa 196 lisäystä ja 14 poistoa
  1. 7 2
      core/core_algorithm.alc
  2. 12 2
      integration/test_powerwindow.py
  3. 175 1
      models/combine_EPN.mvc
  4. 2 9
      models/pm_req_analyse.mvc

+ 7 - 2
core/core_algorithm.alc

@@ -483,6 +483,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 	Element consumes_link
 	Element types
 	String name
+	String value
 
 	inputs = create_node()
 	outputs = create_node()
@@ -500,8 +501,9 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 		consumes_link = set_pop(lst)
 		// As there are no inheritance relations between full models, we can just read out the typename
 		name = read_attribute(pm, consumes_link, "name")
-		dict_add(inputs, name, string_join(prefix, read_attribute(pm, elem, "name")))
-		dict_add(types, name, read_attribute(pm, readAssociationDestination(pm, elem), "type"))
+		value = read_attribute(pm, readAssociationDestination(pm, consumes_link), "name")
+		dict_add(inputs, name, prefix + value)
+		dict_add(types, name, read_attribute(pm, readAssociationDestination(pm, consumes_link), "type"))
 
 	// Find all outputs and their types (i.e., key)
 	lst = allAssociationDestinations(pm, element, "Produces")
@@ -643,9 +645,12 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			Element output_keys
 
 			input_keys = dict_keys(inputs)
+			log("Commence merge")
 			while (read_nr_out(input_keys) > 0):
 				key = set_pop(input_keys)
+				log("Key: " + key)
 				model_join(merged_model, get_full_model(get_model_id(inputs[key])), string_join(types[key], "/"))
+			log("Merge OK")
 
 			// 3) Transform
 

+ 12 - 2
integration/test_powerwindow.py

@@ -103,6 +103,16 @@ class TestPowerWindow(unittest.TestCase):
                             "ENV2EPN_link",
                             "PW_Environment/Event",
                             "Encapsulated_PetriNet/Place",
+                        "instantiate",
+                            "Association",
+                            "EPN2PN_place_link",
+                            "Encapsulated_PetriNet/Place",
+                            "PetriNet/Place",
+                        "instantiate",
+                            "Association",
+                            "EPN2PN_transition_link",
+                            "Encapsulated_PetriNet/Transition",
+                            "PetriNet/Transition",
                         "exit",
                 "transformation_RAMify",
                     "__merged_All_RAM",
@@ -252,13 +262,13 @@ class TestPowerWindow(unittest.TestCase):
                 "Model loaded, ready for commands!",
                 "Use 'help' command for a list of possible commands",
                 "Please give your command.",
-                # instantiate * 3
+                # instantiate * 5
                 ] + [   "Type to instantiate?",
                         "Name of new element?",
                         "Source name?",
                         "Destination name?",
                         "Instantiation successful!",
-                        "Please give your command.", ] * 3 + [
+                        "Please give your command.", ] * 5 + [
                 "Ready for command...",
                 # transformation_RAMify
                 "Which metamodel do you want to RAMify?",

+ 175 - 1
models/combine_EPN.mvc

@@ -246,7 +246,171 @@ A B {
                 }
             }
         }
+
+        {Contains} ForAll copy_transitions {
+            LHS {
+                Pre_Encapsulated_PetriNets/Transition {
+                    label = "0"
+                }
+            }
+            RHS {
+                Post_Encapsulated_PetriNets/Transition ct1 {
+                    label = "0"
+                }
+                Post_PetriNets/Transition ct2 {
+                    label = "1"
+                    value_executing = $
+                        Boolean function value(model : Element, name : String, mapping : Element):
+                            return True!
+                        $
+                    value_name = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["0"], "name")!
+                        $
+                }
+                Post_EPN2PN_transition_link (ct1, ct2){
+                    label = "2"
+                }
+            }
+        }
+        {Contains} ForAll copy_places {
+            LHS {
+                Pre_Encapsulated_PetriNets/Place {
+                    label = "0"
+                }
+            }
+            RHS {
+                Post_Encapsulated_PetriNets/Place cp1 {
+                    label = "0"
+                }
+                Post_PetriNets/Place cp2 {
+                    label = "1"
+                    value_tokens = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["0"], "tokens")!
+                        $
+                    value_name = $
+                        Integer function value(model : Element, name : String, mapping : Element):
+                            return read_attribute(model, mapping["0"], "name")!
+                        $
+                }
+                Post_EPN2PN_place_link (cp1, cp2){
+                    label = "2"
+                }
+            }
+        }
+        {Contains} ForAll copy_P2T {
+            LHS {
+                Pre_Encapsulated_PetriNets/Place cp2t_p{
+                    label = "0"
+                }
+                Pre_Encapsulated_PetriNets/Transition cp2t_t{
+                    label = "1"
+                }
+                Pre_Encapsulated_PetriNets/P2T (cp2t_p, cp2t_t){
+                    label = "2"
+                }
+                Pre_PetriNets/Place cp2t_p2{
+                    label = "3"
+                }
+                Pre_PetriNets/Transition cp2t_t2{
+                    label = "4"
+                }
+                Pre_EPN2PN_place_link (cp2t_p, cp2t_p2){
+                    label = "5"
+                }
+                Pre_EPN2PN_transition_link (cp2t_t, cp2t_t2){
+                    label = "6"
+                }
+            }
+            RHS {
+                Post_Encapsulated_PetriNets/Place rhs_cp2t_p{
+                    label = "0"
+                }
+                Post_Encapsulated_PetriNets/Transition rhs_cp2t_t{
+                    label = "1"
+                }
+                Post_Encapsulated_PetriNets/P2T rhs_cp2t_p2t (rhs_cp2t_p, rhs_cp2t_t){
+                    label = "2"
+                }
+                Post_PetriNets/Place rhs_cp2t_p2 {
+                    label = "3"
+                }
+                Post_PetriNets/Transition rhs_cp2t_t2 {
+                    label = "4"
+                }
+                Post_EPN2PN_place_link (rhs_cp2t_p, rhs_cp2t_p2){
+                    label = "5"
+                }
+                Post_EPN2PN_transition_link (rhs_cp2t_t, rhs_cp2t_t2){
+                    label = "6"
+                }
+                Post_PetriNets/P2T rhs_cp2t_p2t2(rhs_cp2t_p2, rhs_cp2t_t2) {
+                    label = "7"
+                    value_weight = $
+                        Integer function value(host_model : Element, name : String, mapping : Element):
+                            return 1!
+                        $
+                }
+            }
+        }
+        {Contains} ForAll copy_T2P {
+            LHS {
+                Pre_Encapsulated_PetriNets/Place ct2p_p{
+                    label = "0"
+                }
+                Pre_Encapsulated_PetriNets/Transition ct2p_t{
+                    label = "1"
+                }
+                Pre_Encapsulated_PetriNets/T2P (ct2p_t, ct2p_p){
+                    label = "2"
+                }
+                Pre_PetriNets/Place ct2p_p2{
+                    label = "3"
+                }
+                Pre_PetriNets/Transition ct2p_t2{
+                    label = "4"
+                }
+                Pre_EPN2PN_place_link (ct2p_p, ct2p_p2){
+                    label = "5"
+                }
+                Pre_EPN2PN_transition_link (ct2p_t, ct2p_t2){
+                    label = "6"
+                }
+            }
+            RHS {
+                Post_Encapsulated_PetriNets/Place rhs_ct2p_p{
+                    label = "0"
+                }
+                Post_Encapsulated_PetriNets/Transition rhs_ct2p_t{
+                    label = "1"
+                }
+                Post_Encapsulated_PetriNets/T2P (rhs_ct2p_t, rhs_ct2p_p){
+                    label = "2"
+                }
+                Post_PetriNets/Place rhs_ct2p_p2 {
+                    label = "3"
+                }
+                Post_PetriNets/Transition rhs_ct2p_t2 {
+                    label = "4"
+                }
+                Post_EPN2PN_place_link (rhs_ct2p_p, rhs_ct2p_p2){
+                    label = "5"
+                }
+                Post_EPN2PN_transition_link (rhs_ct2p_t, rhs_ct2p_t2){
+                    label = "6"
+                }
+                Post_PetriNets/T2P (rhs_ct2p_t2, rhs_ct2p_p2) {
+                    label = "7"
+                    value_weight = $
+                        Integer function value(host_model : Element, name : String, mapping : Element):
+                            return 1!
+                        $
+                }
+            }
+        }
     }
+
     Initial (schedule, unselect_all) {}
 
     OnSuccess (unselect_all, select) {}
@@ -255,11 +419,21 @@ A B {
     OnSuccess (merge_T2P, remove_old) {}
     OnSuccess (remove_old, unselect) {}
     OnSuccess (unselect, select) {}
-    OnFailure (select, success) {}
+    OnFailure (select, copy_places) {}
 
     OnFailure (unselect_all, select) {}
     OnFailure (merge_P2T, merge_T2P) {}
     OnFailure (merge_T2P, remove_old) {}
     OnFailure (remove_old, unselect) {}
     OnFailure (unselect, failure) {}
+
+    OnSuccess (copy_places, copy_transitions) {}
+    OnSuccess (copy_transitions, copy_P2T) {}
+    OnSuccess (copy_P2T, copy_T2P) {}
+    OnSuccess (copy_T2P, success) {}
+    OnFailure (copy_places, copy_transitions) {}
+    OnFailure (copy_transitions, copy_P2T) {}
+    OnFailure (copy_P2T, copy_T2P) {}
+    OnFailure (copy_T2P, success) {}
+
 }

+ 2 - 9
models/pm_req_analyse.mvc

@@ -115,8 +115,7 @@ ProcessModel analyse_requirements {
     Next (environment_to_EPN, forkjoin2) {}
     Next (control_to_EPN, forkjoin2) {}
     Next (forkjoin2, combine_EPN) {}
-    Next (combine_EPN, EPN_to_PN) {}
-    Next (EPN_to_PN, analyse) {}
+    Next (combine_EPN, analyse) {}
     Next (analyse, forkjoin3) {}
     Next (refine_query, forkjoin3) {}
     Next (forkjoin3, matches) {}
@@ -179,13 +178,7 @@ ProcessModel analyse_requirements {
     Consumes (combine_EPN, control_EPN) {
         name = "epn_3"
     }
-    Produces (combine_EPN, merged_EPN) {
-    }
-
-    Consumes (EPN_to_PN, merged_EPN) {
-        name = "epn"
-    }
-    Produces (EPN_to_PN, pn) {
+    Produces (combine_EPN, pn) {
     }
 
     Consumes (analyse, pn) {