浏览代码

Fixed PM enactment for the live modelling of CBDs

Yentl Van Tendeloo 7 年之前
父节点
当前提交
161be36d78

二进制
bootstrap/bootstrap.m.gz


+ 15 - 0
bootstrap/core_algorithm.alc

@@ -382,15 +382,19 @@ String function store_entry(model_id : String, full_name : String, user_id : Str
 	return full_name!
 
 String function export_typing(model : Element, name : String):
+	log("Export typing of model with name " + name)
 	String result
 	result = instantiate_node(core, "TypeMapping", "")
 	name = "type mappings/" + name
 
 	// Create type mapping model
+	log("OK")
+	log("Model: " + cast_id(model))
 	String location
 	location = "type mappings/" + cast_id(get_type_mapping(model))
 	export_node(location, get_type_mapping(model))
 
+	log("Creating new instance of")
 	String instance_of
 	name = store_entry(result, name, get_user_id("admin"))
 	instantiate_attribute(core, result, "name", name)
@@ -400,6 +404,7 @@ String function export_typing(model : Element, name : String):
 	instantiate_link(core, "group", "", result, get_group_id("nobody"))
 	instance_of = instantiate_link(core, "instanceOf", "", result, get_entry_id("formalisms/TypeMapping"))
 	instantiate_link(core, "semantics", "", instance_of, get_entry_id("models/conformance_mv"))
+	log("Export OK")
 
 	return result!
 
@@ -445,10 +450,12 @@ Void function model_overwrite(model : Element, model_id : String, metamodel_id :
 	if (element_neq(choice, read_root())):
 		// There was a link, so we remove it
 
+		log("Remove previous instanceOf link")
 		// First remove the type mapping it referred to
 		Element tl
 		tl = allAssociationDestinations(core, choice, "typing")
 		while (set_len(tl) > 0):
+			log("Remove typing")
 			model_delete_element(core, set_pop(tl))
 
 		// Now delete the element itself
@@ -673,6 +680,7 @@ Element function execute_operation(operation_id : String, input_models : Element
 			output("Merged metamodel in operation is not of type formalisms/SimpleClassDiagrams")
 			return read_root()!
 
+		log("Joining")
 		merged_model = model_join(model_tuples, merged_metamodel, tracability_model)
 	else:
 		if (bool_and(dict_len(input_models) == 1, dict_len(output_metamodels) == 0)):
@@ -693,6 +701,7 @@ Element function execute_operation(operation_id : String, input_models : Element
 
 	// 3) Transform
 
+	log("Start transform")
 	if (exact_type == "ModelTransformation"):
 		trace_links = allOutgoingAssociationInstances(core, merged_metamodel_id, "tracability")
 		ramified_metamodel_id = ""
@@ -735,6 +744,7 @@ Element function execute_operation(operation_id : String, input_models : Element
 		output("Unknown type of operation: " + exact_type)
 		return read_root()!
 
+	log("OK, now split")
 	// 4) Split in different models depending on type
 
 	if (element_neq(tracability_model, read_root())):
@@ -755,7 +765,10 @@ Element function execute_operation(operation_id : String, input_models : Element
 				return read_root()!
 			set_add_node(model_tuples, create_tuple(key, mm))
 
+		log("Split!")
 		result = model_split(merged_model, model_tuples, tracability)
+		log("Split OK")
+		log("Result: " + dict_to_string(result))
 
 		if (tracability):
 			Element new_tracability_model
@@ -835,6 +848,8 @@ Boolean function enact_action(pm : Element, element : String, mapping : Element)
 		keys = dict_keys(outputs)
 		while (set_len(keys) > 0):
 			key = set_pop(keys)
+			log("Overwriting model at " + key)
+			log("Read from result: " + cast_id(result[key]))
 			if (get_entry_id(output_map[key]) == ""):
 				// New model
 				model_create(result[key], output_map[key], get_entry_id(outputs[key]), "Model")

+ 0 - 4
kernel/modelverse_kernel/main.py

@@ -336,10 +336,6 @@ class ModelverseKernel(object):
         else:
             raise Exception("Could not process break statement!")
 
-        # Remove the self.taskname link from the evalstack, as we will repush it
-        lnk, = yield [("RDE", [evalstack_root, self.taskname])]
-        yield [("DE", [lnk])]
-
         prev_evalstack_roots, old_evalstack_phase_link = \
                             yield [("RRD", [evalstack_root, "prev"]),
                                    ("RDE", [evalstack_root, "phase"]),

+ 10 - 0
models/cbd_merge.alc

@@ -2,6 +2,8 @@ include "primitives.alh"
 include "modelling.alh"
 include "object_operations.alh"
 include "conformance_scd.alh"
+include "utils.alh"
+include "typing.alh"
 
 String function map_P2F(model : Element, name : String):
 	return readAssociationDestination(model, set_pop(allAssociationDestinations(model, name, "P2F_block")))!
@@ -38,4 +40,12 @@ Boolean function main(model : Element):
 	instantiate_attribute(model, time_block, "start_time", current_time)
 	instantiate_attribute(model, time_block, "current_time", current_time)
 
+	Element all_elements
+	String elem
+	all_elements = dict_keys(model["model"])
+	while (set_len(all_elements) > 0):
+		elem = set_pop(all_elements)
+		if (string_startswith(read_type(model, elem), "PartialRuntime/")):
+			retype(model, elem, "NewFullRuntime/" + cast_string(list_read(string_split_nr(read_type(model, elem), "/", 1), 1)))
+
 	return True!

+ 7 - 4
models/cbd_toRuntime.alc

@@ -3,7 +3,10 @@ include "modelling.alh"
 include "object_operations.alh"
 
 String function map_D2P(model : Element, name : String):
-	return readAssociationDestination(model, set_pop(allAssociationDestinations(model, name, "D2P_block")))!
+	log("Mapping element to Partial")
+	Element elems
+	elems = allAssociationDestinations(model, name, "D2P_block")
+	return set_pop(elems)!
 
 Boolean function main(model : Element):
 	Element all_blocks
@@ -23,7 +26,7 @@ Boolean function main(model : Element):
 			instantiate_link(model, "D2P_block", "", element_name, new_element_name)
 
 		// Always update the value of attributes of PartialRuntime
-		new_element_name = set_pop(readAssociationDestination(model, set_pop(allOutgoingAssociationInstances(model, element_name, "D2P_block"))))
+		new_element_name = map_D2P(model, element_name)
 		if (mm_type_name == "PartialRuntime/ConstantBlock"):
             instantiate_attribute(model, new_element_name, "value", read_attribute(model, element_name, "value"))
 		elif (mm_type_name == "PartialRuntime/ProbeBlock"):
@@ -47,12 +50,12 @@ Boolean function main(model : Element):
 
 	// Recreate all of them
     all_links = allInstances(model, "Design/Link")
-    while (read_nr_out(all_links) > 0):
+    while (set_len(all_links) > 0):
         element_name = set_pop(all_links)
         instantiate_link(model, "PartialRuntime/Link", "", map_D2P(model, readAssociationSource(model, element_name)), map_D2P(model, readAssociationDestination(model, element_name)))
 
     all_links = allInstances(model, "Design/InitialCondition")
-    while (read_nr_out(all_links) > 0):
+    while (set_len(all_links) > 0):
         element_name = set_pop(all_links)
         instantiate_link(model, "PartialRuntime/InitialCondition", "", map_D2P(model, readAssociationSource(model, element_name)), map_D2P(model, readAssociationDestination(model, element_name)))
 

+ 2 - 2
models/pm_live_CBD.mvc

@@ -86,7 +86,7 @@ Consumes (merge, full_runtime_model) {
     name = "FullRuntime"
 }
 Produces (merge, full_runtime_model) {
-    name = "PartialRuntime"
+    name = "NewFullRuntime"
 }
 
 Consumes (merge_0, partial_runtime_model) {
@@ -96,7 +96,7 @@ Consumes (merge_0, full_runtime_model) {
     name = "FullRuntime"
 }
 Produces (merge_0, full_runtime_model) {
-    name = "PartialRuntime"
+    name = "NewFullRuntime"
 }
 
 Consumes (simulate, full_runtime_model) {

+ 1 - 1
models/upload_models.py

@@ -25,7 +25,7 @@ transformation_add_AL({"Design": "formalisms/CBD/Design_MM"}, {"PartialRuntime":
 def trace_P2F(model):
     instantiate(model, "Association", ("PartialRuntime/Block", "FullRuntime/Block"), ID="P2F_block")
 
-transformation_add_AL({"PartialRuntime": "formalisms/CBD/PartialRuntime_MM", "FullRuntime": "formalisms/CBD/FullRuntime_MM"}, {"FullRuntime": "formalisms/CBD/FullRuntime_MM"}, "models/CBD/merge", open("models/cbd_merge.alc", 'r').read(), trace_P2F)
+transformation_add_AL({"PartialRuntime": "formalisms/CBD/PartialRuntime_MM", "FullRuntime": "formalisms/CBD/FullRuntime_MM"}, {"NewFullRuntime": "formalisms/CBD/FullRuntime_MM"}, "models/CBD/merge", open("models/cbd_merge.alc", 'r').read(), trace_P2F)
 transformation_add_AL({"FullRuntime": "formalisms/CBD/FullRuntime_MM"}, {"FullRuntime": "formalisms/CBD/FullRuntime_MM"}, "models/CBD/simulate", open("models/cbd_simulate.alc", 'r').read())
 transformation_add_AL({}, {}, "models/CBD/restartSim", open("models/cbd_restartSim.alc", 'r').read())
 

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Wed Nov 15 16:56:08 2017
+Date:   Thu Nov 16 08:33:01 2017
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server