Browse Source

Fixes to the calling mechanism in PM execution of transformation/AL

Yentl Van Tendeloo 8 years ago
parent
commit
c8f39db2cb

+ 13 - 7
core/core_algorithm.alc

@@ -480,10 +480,14 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 	String exact_type
 	Element trace_links
 	Element output_mms
+	Element consumes_link
+	Element types
+	String name
 
 	inputs = create_node()
 	outputs = create_node()
 	output_mms = create_node()
+	types = create_node()
 
 	// TODO use the prefix for data locations (in model write/read in MvC)
 
@@ -491,12 +495,13 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 	transformation_id = get_model_id(read_attribute(pm, element, "name"))
 
 	// Find all inputs and their types (i.e., key)
-	lst = allAssociationOrigins(pm, element, "Consumes")
+	lst = allOutgoingAssociationInstances(pm, element, "Consumes")
 	while (read_nr_out(lst) > 0):
-		elem = set_pop(lst)
+		consumes_link = set_pop(lst)
 		// As there are no inheritance relations between full models, we can just read out the typename
-		type_name = read_attribute(pm, elem, "type")
-		dict_add(inputs, type_name, string_join(prefix, read_attribute(pm, elem, "name")))
+		name = read_attribute(pm, consumes_link, "name")
+		dict_add(inputs, name, string_join(prefix, read_attribute(pm, elem, "name")))
+		dict_add(types, name, get_attribute(pm, followAssociation(pm, elem), "type"))
 
 	// Find all outputs and their types (i.e., key)
 	lst = allAssociationDestinations(pm, element, "Produces")
@@ -548,7 +553,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			input_keys = dict_keys(inputs)
 			while (read_nr_out(input_keys) > 0):
 				key = set_pop(input_keys)
-				model_join(merged_model, get_full_model(get_model_id(inputs[key])), key + "/")
+				model_join(merged_model, get_full_model(get_model_id(inputs[key])), string_join(types[key], "/"))
 
 			// 3) Transform
 
@@ -563,7 +568,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			while (read_nr_out(output_keys) > 0):
 				key = set_pop(output_keys)
 				desired_metamodel_id = get_model_id(key)
-				split_off_model = model_split(merged_model, get_full_model(desired_metamodel_id), key + "/")
+				split_off_model = model_split(merged_model, get_full_model(desired_metamodel_id), key + "/"))
 
 				// Check if the destination model already exists
 				if (get_model_id(outputs[key]) == ""):
@@ -576,6 +581,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			log("Intermediate not found")
 
 	elif (exact_type == "ActionLanguage"):
+		// TODO might be broken with switch to name-based merging of inputs with same type
 		Element dictionary
 		Element new_inputs
 		Element input_keys
@@ -639,7 +645,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			input_keys = dict_keys(inputs)
 			while (read_nr_out(input_keys) > 0):
 				key = set_pop(input_keys)
-				model_join(merged_model, get_full_model(get_model_id(inputs[key])), key + "/")
+				model_join(merged_model, get_full_model(get_model_id(inputs[key])), string_join(types[key], "/"))
 
 			// 3) Transform
 

+ 1 - 1
core/pm.mvc

@@ -43,7 +43,7 @@ SimpleClassDiagrams ProcessModel {
     }
 
     Association Produces (Exec, Data) {}
-    Association Consumes (Data, Exec) {
+    Association Consumes (Exec, Data) {
         name : String
     }
     Association Then (Decision, Activity) {}

+ 1 - 1
integration/code/reachability.alc

@@ -36,7 +36,7 @@ Element function reachability_graph(params : Element, output_mms : Element):
 
 	result = create_node()
 	out_model = instantiate_model(output_mms["ReachabilityGraph"])
-	in_model = params["PetriNet"]
+	in_model = params["pn"]
 
 	// Create a dictionary representation for each transition
 	transition_vectors_produce = create_node()

+ 1 - 1
models/environment_to_EPN.alc

@@ -75,7 +75,7 @@ Element function env_to_EPN(params : Element, output_mms : Element):
 
 	result = create_node()
 	out_model = instantiate_model(output_mms["Encapsulated_PetriNet"])
-	in_model = params["Environment_PW"]
+	in_model = params["environment"]
 
 	// Create the initial place
 	init_place = instantiate_node(out_model, "Place", "")

+ 20 - 20
models/pm_req_analyse.mvc

@@ -136,29 +136,29 @@ ProcessModel analyse_requirements {
     Produces (make_initial_models, query) {
     }
 
-    Consumes (req, refine_plant) {
+    Consumes (refine_plant, req) {
         name = "requirements"
     }
-    Consumes (req, refine_environment) {
+    Consumes (refine_environment, req) {
         name = "requirements"
     }
-    Consumes (req, refine_control) {
+    Consumes (refine_control, req) {
         name = "requirements"
     }
-    Consumes (req, refine_query) {
+    Consumes (refine_query, req) {
         name = "requirements"
     }
 
-    Consumes (plant_model, refine_plant) {
+    Consumes (refine_plant, plant_model) {
         name = "plant"
     }
-    Consumes (environment_model, refine_environment) {
+    Consumes (refine_environment, environment_model) {
         name = "environment"
     }
-    Consumes (control_model, refine_control) {
+    Consumes (refine_control, control_model) {
         name = "control"
     }
-    Consumes (query, refine_query) {
+    Consumes (refine_query, query) {
         name = "query"
     }
     Produces (refine_plant, plant_EPN) {
@@ -170,34 +170,34 @@ ProcessModel analyse_requirements {
     Produces (refine_query, query) {
     }
 
-    Consumes (plant_EPN, combine_EPN) {
-        name = "EPN_1"
+    Consumes (combine_EPN, plant_EPN) {
+        name = "epn_1"
     }
-    Consumes (environment_EPN, combine_EPN) {
-        name = "EPN_2"
+    Consumes (combine_EPN, environment_EPN) {
+        name = "epn_2"
     }
-    Consumes (control_EPN, combine_EPN) {
-        name = "EPN_3"
+    Consumes (combine_EPN, control_EPN) {
+        name = "epn_3"
     }
     Produces (combine_EPN, merged_EPN) {
     }
 
-    Consumes (merged_EPN, EPN_to_PN) {
-        name = "EPN"
+    Consumes (EPN_to_PN, merged_EPN) {
+        name = "epn"
     }
     Produces (EPN_to_PN, pn) {
     }
 
-    Consumes (pn, analyse) {
-        name = "PN"
+    Consumes (analyse, pn) {
+        name = "pn"
     }
     Produces (analyse, reachability_graph) {
     }
 
-    Consumes (reachability_graph, matches) {
+    Consumes (matches, reachability_graph) {
         name = "reachability_graph"
     }
-    Consumes (query, matches) {
+    Consumes (matches, query) {
         name = "query"
     }
 }