Yentl Van Tendeloo 8 лет назад
Родитель
Сommit
0f1a25a6bf
2 измененных файлов с 29 добавлено и 12 удалено
  1. 17 0
      integration/code/cbd_design.mvc
  2. 12 12
      integration/code/cbd_semantics.alc

+ 17 - 0
integration/code/cbd_design.mvc

@@ -41,3 +41,20 @@ SCD CausalBlockDiagrams_Design{
 }
 
 export CausalBlockDiagrams_Design to models/CausalBlockDiagrams_Design
+
+CausalBlockDiagrams_Design my_CBD{
+    ConstantBlock a{
+        value = 1.0
+    }
+
+    ConstantBlock b{
+        value = 1.0
+    }
+
+    AdditionBlock c{}
+
+    Link(a, c){}
+    Link(b, c){}
+}
+
+export my_CBD to models/my_CBD

+ 12 - 12
integration/code/cbd_semantics.alc

@@ -37,12 +37,12 @@ Void function translate_to_runtime(design_model : Element):
 	String dst
 	Element all_attributes
 
-	output("Translating to runtime model!")
+	log("Translating to runtime model!")
 
-	output("Creating empty runtime model")
+	log("Creating empty runtime model")
 	runtime_model = instantiate_model("models/CausalBlockDiagrams_Runtime")
 
-	output("Converting blocks")
+	log("Converting blocks")
 	all_blocks = allInstances(design_model, "Block")
 	while (list_len(all_blocks) > 0):
 		element_name = set_pop(all_blocks)
@@ -53,36 +53,36 @@ Void function translate_to_runtime(design_model : Element):
 			attr_name = set_pop(all_attributes)
 			if (bool_not(set_in(runtime_model["model"], read_attribute(design_model, element_name, attr_name)))):
 				instantiate_attribute(runtime_model, element_name, attr_name, read_attribute(design_model, element_name, attr_name))
-		output("    Converted block " + element_name)
+		log("    Converted block " + element_name)
 
 	// Don't merge this together with the block conversion, as the destination block might not exist yet!
-	output("Relinking blocks")
+	log("Relinking blocks")
 	all_links = allInstances(design_model, "Link")
 	while (read_nr_out(all_links) > 0):
 		element_name = set_pop(all_links)
 		src = reverseKeyLookup(design_model["model"], read_edge_src(design_model["model"][element_name]))
 		dst = reverseKeyLookup(design_model["model"], read_edge_dst(design_model["model"][element_name]))
 		instantiate_link(runtime_model, "Link", element_name, src, dst)
-		output((("    Relinked blocks " + src) + " and ") + dst)
+		log((("    Relinked blocks " + src) + " and ") + dst)
 
-	output("Resetting initial conditions")
+	log("Resetting initial conditions")
 	all_links = allInstances(design_model, "InitialCondition")
 	while (read_nr_out(all_links) > 0):
 		element_name = set_pop(all_links)
 		src = reverseKeyLookup(design_model["model"], read_edge_src(design_model["model"][element_name]))
 		dst = reverseKeyLookup(design_model["model"], read_edge_dst(design_model["model"][element_name]))
 		instantiate_link(runtime_model, "InitialCondition", element_name, src, dst)
-		output("    Reset IC of " + dst)
+		log("    Reset IC of " + dst)
 
-	output("Creating schedule at time = 0")
+	log("Creating schedule at time = 0")
 	create_schedule(runtime_model, True)
 
-	output("Creating schedule at time > 0")
+	log("Creating schedule at time > 0")
 	create_schedule(runtime_model, False)
 
-	output("Solving loops (TODO)")
+	log("Solving loops (TODO)")
 
-	output("DONE!")
+	log("DONE!")
 	return !
 
 Void function create_schedule(model : Element, is_time_zero : Boolean):