Pārlūkot izejas kodu

Bug remaining: delayblock doesn't work

Yentl Van Tendeloo 8 gadi atpakaļ
vecāks
revīzija
dbf6c96522

BIN
bootstrap/bootstrap.m.gz


+ 4 - 0
bootstrap/modelling.alc

@@ -165,6 +165,7 @@ Void function instantiate_attribute(model : Element, element : String, attribute
 	// Actually a bit more difficult than all the rest, as we need to find the attribute to instantiate
 	String attr_type
 	String attr_name
+	log("Add attribute")
 
 	attr_type = find_attribute_type(model, element, attribute_name)
 
@@ -174,10 +175,13 @@ Void function instantiate_attribute(model : Element, element : String, attribute
 		
 	if (set_in_node(model["model"], value)):
 		attr_name = reverseKeyLookup(model["model"], value)
+		log("Reuse attribute " + attr_name)
 	else:
 		attr_name = model_add_value(model, (element + ".") + attribute_name, value)
 		retype(model, attr_name, reverseKeyLookup(model["metamodel"]["model"], read_edge_dst(model["metamodel"]["model"][attr_type])))
+		log("Added attribute " + attr_name)
 	instantiate_link(model, attr_type, "", element, attr_name)
+	log("instantiated link OK")
 
 	return!
 

+ 4 - 1
integration/code/cbd_design.mvc

@@ -51,13 +51,16 @@ CausalBlockDiagrams_Design my_CBD{
     }
 
     ConstantBlock b{
-        value = 1.0
+        value = 2.0
     }
 
     AdditionBlock c{}
+    DelayBlock d{}
 
     Link(a, c){}
     Link(b, c){}
+    Link(c, d){}
+    InitialCondition(a, d){}
 }
 
 export my_CBD to models/my_CBD

+ 6 - 2
integration/code/cbd_semantics.alc

@@ -235,11 +235,13 @@ Void function step_simulation(model : Element):
 				selected = readAssociationSource(model, set_pop(incoming))
 				signal = float_division(1.0, cast_s2f(cast_v2s(read_attribute(model, selected, "signal"))))
 		elif (blocktype == "DelayBlock"):
+			// TODO this is very broken...
 			if (schedule == "schedule_init"):
 				incoming = allIncomingAssociationInstances(model, block, "InitialCondition")
 				while (read_nr_out(incoming) > 0):
 					selected = readAssociationSource(model, set_pop(incoming))
 					signal = cast_s2f(cast_v2s(read_attribute(model, selected, "signal")))
+					log("Read signal from initial condition: " + cast_v2s(signal))
 			else:
 				signal = read_attribute(model, block, "memory")
 
@@ -247,8 +249,8 @@ Void function step_simulation(model : Element):
 			incoming = allIncomingAssociationInstances(model, block, "Link")
 			while (read_nr_out(incoming) > 0):
 				selected = readAssociationSource(model, set_pop(incoming))
-				unset_attribute(model, block, "memory")
-				instantiate_attribute(model, block, "memory", cast_s2f(cast_v2s(read_attribute(model, selected, "signal"))))
+			unset_attribute(model, block, "memory")
+			instantiate_attribute(model, block, "memory", cast_s2f(cast_v2s(read_attribute(model, selected, "signal"))))
 
 		unset_attribute(model, block, "signal")
 		instantiate_attribute(model, block, "signal", signal)
@@ -276,6 +278,8 @@ Void function execute_cbd(model : Element):
 	if (verify_result != "OK"):
 		output("Error constructing conforming runtime model: " + verify_result)
 		return!
+	
+	output("Runtime model constructed OK!")
 
 	String cmd
 	Boolean running