Browse Source

Fixed model rendering

Yentl Van Tendeloo 8 years ago
parent
commit
a1936c47dd
3 changed files with 18 additions and 28 deletions
  1. 5 5
      bootstrap/transform.alc
  2. 0 14
      core/core_algorithm.alc
  3. 13 9
      models/CBD_mapper.mvc

+ 5 - 5
bootstrap/transform.alc

@@ -290,7 +290,7 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
 	set_add(mappings, initial_mapping)
 	while (read_nr_out(schedule) > 0):
 		current_element = list_pop(schedule, read_nr_out(schedule) - 1)
-		log("Binding element with label " + cast_v2s(read_attribute(schedule_model, current_element, "label")))
+		//log("Binding element with label " + cast_v2s(read_attribute(schedule_model, current_element, "label")))
 		new_mappings = create_node()
 
 		while (read_nr_out(mappings) > 0):
@@ -304,7 +304,7 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
 				set_add(new_mappings, new_map)
 
 		mappings = new_mappings
-		log("Remaining options: " + cast_v2s(read_nr_out(mappings)))
+		//log("Remaining options: " + cast_v2s(read_nr_out(mappings)))
 
 		if (read_nr_out(mappings) == 0):
 			// Stop because we have no more options remaining!
@@ -380,7 +380,7 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 	while (read_nr_out(labels_to_add) > 0):
 		// Add the elements linked to these labels
 		label = list_pop(labels_to_add, read_nr_out(labels_to_add) - 1)
-		log("Instantiate label " + label)
+		//log("Instantiate label " + label)
 		if (is_edge(schedule_model["model"][RHS_map[label]])):
 			// Edge
 			src = read_attribute(schedule_model, reverse[cast_id2s(read_edge_src(schedule_model["model"][RHS_map[label]]))], "label")
@@ -488,7 +488,7 @@ Boolean function transform_composite(host_model : Element, schedule_model : Elem
 
 	current = set_pop(allAssociationDestinations(schedule_model, composite, "Initial"))
 	while (is_nominal_instance(schedule_model, current, "Rule")):
-		log("Executing " + current)
+		//log("Executing " + current)
 		// Still a rule that we must execute
 		typename = read_type(schedule_model, current)
 		if (typename == "Atomic"):
@@ -541,7 +541,7 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
 	else:
 		result = False
 
-	log("Matches in forall: " + cast_v2s(read_nr_out(mappings)))
+	//log("Matches in forall: " + cast_v2s(read_nr_out(mappings)))
 	while (read_nr_out(mappings) > 0):
 		mapping = set_pop(mappings)
 		// TODO check if there are actually no deletions happening in the meantime of other matched elements...

+ 0 - 14
core/core_algorithm.alc

@@ -437,22 +437,17 @@ Void function model_overwrite(model : Element, model_id : String):
 	String location
 	String instanceOf_link
 
-	log("Phase 1")
 	location = "models/" + cast_id2s(model)
-	log("Export location content: " + cast_e2s(import_node(location)))
 	export_node(location, model["model"])
 
 	// Change location in meta-data
-	log("Phase 2")
 	unset_attribute(core, model_id, "location")
 	instantiate_attribute(core, model_id, "location", location)
 
-	log("Phase 3")
 	instanceOf_link = get_instanceOf_link(model_id)
 	unset_attribute(core, instanceOf_link, "type_mapping")
 	instantiate_attribute(core, instanceOf_link, "type_mapping", model["type_mapping"])
 
-	log("Phase 4")
 	return!
 
 Boolean function check_is_typed_by(model_id : String, metamodel_id : String):
@@ -515,7 +510,6 @@ Element function execute_operation(operation_id : String, input_models : Element
 	Boolean tracability
 
 	// 1) Find merged metamodel
-	log("Find merged")
 
 	exact_type = read_type(core, operation_id)
 
@@ -541,7 +535,6 @@ Element function execute_operation(operation_id : String, input_models : Element
 
 	if (merged_metamodel_id != ""):
 		// 2) Merge source models
-		log("Merge source")
 
 		model_tuples = create_node()
 		while (read_nr_out(input_models) > 0):
@@ -553,10 +546,6 @@ Element function execute_operation(operation_id : String, input_models : Element
 		merged_model = model_join(model_tuples, get_full_model(merged_metamodel_id), read_root())
 
 		// 3) Transform
-		log("Transform")
-		log("Source model: " + pretty_print(merged_model))
-		log("Types of merged: " + set_to_string(dict_keys(merged_model["metamodel"]["model"])))
-		log("operation: " + pretty_print(get_full_model(operation_id)))
 
 		if (exact_type == "ModelTransformation"):
 			result = transform(merged_model, get_full_model(operation_id))
@@ -572,7 +561,6 @@ Element function execute_operation(operation_id : String, input_models : Element
 			log("ERROR")
 
 		// 4) Split in different models depending on type
-		log("Split")
 
 		if (element_neq(tracability_model, read_root())):
 			tracability = True
@@ -590,7 +578,6 @@ Element function execute_operation(operation_id : String, input_models : Element
 			result = model_split(merged_model, model_tuples, tracability)
 
 			if (tracability):
-				log("Trace")
 				Element new_tracability_model
 				new_tracability_model = result["__tracability"]
 				dict_overwrite(tracability_model, "model", new_tracability_model["model"])
@@ -598,7 +585,6 @@ Element function execute_operation(operation_id : String, input_models : Element
 				dict_overwrite(tracability_model, "metamodel", new_tracability_model["metamodel"])
 				dict_delete(result, "__tracability")
 
-			log("Done")
 			return result!
 		else:
 			return read_root()!

+ 13 - 9
models/CBD_mapper.mvc

@@ -79,23 +79,27 @@ A B {
                     value_text = $
                         String function value(model : Element, name : String, mapping : Element):
                             String type
-                            type = read_type(model, name)
-                            if (type == "AdditionBlock"):
+                            type = read_type(model, mapping["0"])
+                            if (type == "CausalBlockDiagrams/AdditionBlock"):
                                 return "+"!
-                            elif (type == "NegatorBlock"):
+                            elif (type == "CausalBlockDiagrams/NegatorBlock"):
                                 return "-"!
-                            elif (type == "MultiplyBlock"):
+                            elif (type == "CausalBlockDiagrams/ConstantBlock"):
+                                return "c"!
+                            elif (type == "CausalBlockDiagrams/MultiplyBlock"):
                                 return "*"!
-                            elif (type == "InverseBlock"):
+                            elif (type == "CausalBlockDiagrams/InverseBlock"):
                                 return "/"!
-                            elif (type == "DerivatorBlock"):
+                            elif (type == "CausalBlockDiagrams/DerivatorBlock"):
                                 return "d/dx"!
-                            elif (type == "IntegratorBlock"):
+                            elif (type == "CausalBlockDiagrams/IntegratorBlock"):
                                 return "1/s"!
-                            elif (type == "DelayBlock"):
+                            elif (type == "CausalBlockDiagrams/DelayBlock"):
                                 return "DELAY"!
-                            elif (type == "ProbeBlock"):
+                            elif (type == "CausalBlockDiagrams/ProbeBlock"):
                                 return "PROBE"!
+                            else:
+                                return ("Unknown type: " + type)!
                         $
                 }
                 Post_MM_rendered_graphical/contains (post_block_1, post_block_2) {