Browse Source

Fixed several bugs in metamodels

Yentl Van Tendeloo 8 years ago
parent
commit
5e66e3fc5f

BIN
bootstrap/bootstrap.m.gz


+ 3 - 6
bootstrap/modelling.alc

@@ -169,14 +169,11 @@ Void function instantiate_attribute(model : Element, element : String, attribute
 	attr_type = find_attribute_type(model, element, attribute_name)
 
 	if (attr_type == ""):
-		log("Could not find attribute!")
+		log("Could not find attribute " + cast_v2s(attribute_name))
 		return!
 		
-	if (set_in(model["model"], value)):
-		attr_name = reverseKeyLookup(model["model"], value)
-	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])))
+	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])))
 	instantiate_link(model, attr_type, "", element, attr_name)
 
 	return!

+ 4 - 4
integration/code/cbd_design.mvc

@@ -15,8 +15,8 @@ SCD CausalBlockDiagrams_Design{
 
     Class ConstantBlock{
         value : Float {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
+            target_lower_cardinality = 1
+            target_upper_cardinality = 1
         }
     }
 
@@ -28,8 +28,8 @@ SCD CausalBlockDiagrams_Design{
 
     Association Link(Block, Block){}
     Association InitialCondition(Block, DelayBlock){
-        source_lower_multiplicity = 1
-        source_upper_multiplicity = 1
+        source_lower_cardinality = 1
+        source_upper_cardinality = 1
     }
 
     Inheritance (ConstantBlock, Block){}

+ 23 - 13
integration/code/cbd_runtime.mvc

@@ -15,8 +15,8 @@ SCD CausalBlockDiagrams_Runtime{
 
     Class ConstantBlock{
         value : Float {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
+            target_lower_cardinality = 1
+            target_upper_cardinality = 1
         }
     }
 
@@ -26,33 +26,43 @@ SCD CausalBlockDiagrams_Runtime{
     Class InverseBlock{}
     Class DelayBlock{
         memory : Float {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
+            target_lower_cardinality = 1
+            target_upper_cardinality = 1
         }
     }
 
+    Class Pointers {
+        lower_cardinality = 1
+        upper_multiplicit = 1
+    }
+
     Class Schedule {
         block : Block {
-            target_lower_multiplicity = 0
-            target_upper_multiplicity = 1
+            target_lower_cardinality = 0
+            target_upper_cardinality = 1
         }
         next : Schedule {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
+            target_lower_cardinality = 1
+            target_upper_cardinality = 1
         }
 
-        lower_multiplicity = 1
+        lower_cardinality = 1
+    }
+
+    Association ActiveSchedule(Pointers, Schedule) {
+        target_lower_cardinality = 1
+        target_upper_cardinality = 1
     }
 
     Association Link(Block, Block){
         signal : Float {
-            target_lower_multiplicity = 0
-            target_upper_multiplicity = 1
+            target_lower_cardinality = 0
+            target_upper_cardinality = 1
         }
     }
     Association InitialCondition(Block, DelayBlock){
-        source_lower_multiplicity = 0
-        source_upper_multiplicity = 1
+        source_lower_cardinality = 0
+        source_upper_cardinality = 1
     }
 
     Inheritance (ConstantBlock, Block){}

+ 13 - 2
integration/code/cbd_semantics.alc

@@ -85,15 +85,24 @@ Void function translate_to_runtime(design_model : Element):
 	return !
 
 Void function create_schedule(model : Element, is_time_zero : Boolean):
+	Element all_blocks
+	Element visited
+	Element to_visit
+	Element incoming_links
+	String schedule
+	String element_name
+	String link
+	Boolean ready
+
 	all_blocks = allInstances(model, "Block")
 	visited = create_node()
 	to_visit = create_node()
 	if (is_time_zero):
 		schedule = instantiate_node(model, "Schedule", "schedule_init")
 	else:
-		schedule = instantiate_node(model, "Schedule", "schedule_running")
+		schedule = instantiate_node(model, "Schedule", "schedule_run")
 
-	while (set_len(all_blocks) > 0):
+	while (bool_and(set_len(all_blocks) > 0)):
 		element_name = set_pop(all_blocks)
 		if (bool_not(set_in(visited, element_name))):
 			list_append(to_visit, element_name)
@@ -121,6 +130,8 @@ Void function create_schedule(model : Element, is_time_zero : Boolean):
 				instantiate_attribute(model, reverseKeyLookup(model["model"], schedule), "block", model["model"][element_name])
 				instantiate_attribute(model, reverseKeyLookup(model["model"], schedule), "next", model["model"][new_schedule])
 				schedule = new_schedule
+				list_delete(to_visit, list_len(to_visit) - 1)
+				set_add(visited, element_name)
 
 	return !