Browse Source

Small changes to make semantics easier

Yentl Van Tendeloo 8 years ago
parent
commit
0628760c36
4 changed files with 39 additions and 109 deletions
  1. BIN
      bootstrap/bootstrap.m.gz
  2. 5 2
      bootstrap/modelling.alc
  3. 13 57
      integration/code/cbd_design.mvc
  4. 21 50
      integration/code/cbd_runtime.mvc

BIN
bootstrap/bootstrap.m.gz


+ 5 - 2
bootstrap/modelling.alc

@@ -172,8 +172,11 @@ Void function instantiate_attribute(model : Element, element : String, attribute
 		log("Could not find attribute!")
 		return!
 		
-	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])))
+	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])))
 	instantiate_link(model, attr_type, "", element, attr_name)
 
 	return!

+ 13 - 57
integration/code/cbd_design.mvc

@@ -1,22 +1,17 @@
 import models/SimpleClassDiagrams as SCD
 include "primitives.alh"
 
-SCD CausalBlockDiagrams{
+SCD CausalBlockDiagrams_Design{
     Class Float {
         $
             if (bool_not(is_physical_float(self))):
                 return "Natural has no float value"!
             else:
                 return "OK"!
-         $
+        $
     }
 
-    Class Block{
-        output : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-    }
+    Class Block{}
 
     Class ConstantBlock{
         value : Float {
@@ -25,55 +20,16 @@ SCD CausalBlockDiagrams{
         }
     }
 
-    Class AdditionBlock{
-        input1 : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-        input2 : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-    }
-
-    Class NegatorBlock{
-        input1 : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-        input2 : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-    }
+    Class AdditionBlock{}
+    Class NegatorBlock{}
+    Class MultiplyBlock{}
+    Class InverseBlock{}
+    Class DelayBlock{}
 
-    Class MultiplyBlock{
-        input1 : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-        input2 : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-    }
-
-    Class InverseBlock{
-        input1 : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-    }
-
-    Class DelayBlock{
-        input : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-        initial : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
+    Association Link(Block, Block){}
+    Association InitialCondition(Block, DelayBlock){
+        source_lower_multiplicity = 1
+        source_upper_multiplicity = 1
     }
 
     Inheritance (ConstantBlock, Block){}
@@ -84,4 +40,4 @@ SCD CausalBlockDiagrams{
     Inheritance (DelayBlock, Block){}
 }
 
-export CausalBlockDiagrams to models/CausalBlockDiagrams
+export CausalBlockDiagrams_Design to models/CausalBlockDiagrams_Design

+ 21 - 50
integration/code/cbd_runtime.mvc

@@ -1,26 +1,17 @@
 import models/SimpleClassDiagrams as SCD
 include "primitives.alh"
 
-SCD CausalBlockDiagrams{
+SCD CausalBlockDiagrams_Runtime{
     Class Float {
         $
             if (bool_not(is_physical_float(self))):
                 return "Float has no float value"!
             else:
                 return "OK"!
-         $
+        $
     }
 
-    Class Block{
-        output : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-        signal : Float {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-    }
+    Class Block{}
 
     Class ConstantBlock{
         value : Float {
@@ -29,59 +20,39 @@ SCD CausalBlockDiagrams{
         }
     }
 
-    Class AdditionBlock{
-        input1 : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-        input2 : Block {
+    Class AdditionBlock{}
+    Class NegatorBlock{}
+    Class MultiplyBlock{}
+    Class InverseBlock{}
+    Class DelayBlock{
+        memory : Float {
             target_lower_multiplicity = 1
             target_upper_multiplicity = 1
         }
     }
 
-    Class NegatorBlock{
-        input1 : Block {
-            target_lower_multiplicity = 1
+    Class Schedule {
+        block : Block {
+            target_lower_multiplicity = 0
             target_upper_multiplicity = 1
         }
-        input2 : Block {
+        next : Schedule {
             target_lower_multiplicity = 1
             target_upper_multiplicity = 1
         }
-    }
 
-    Class MultiplyBlock{
-        input1 : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-        input2 : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
+        lower_multiplicity = 1
     }
 
-    Class InverseBlock{
-        input1 : Block {
-            target_lower_multiplicity = 1
+    Association Link(Block, Block){
+        signal : Float {
+            target_lower_multiplicity = 0
             target_upper_multiplicity = 1
         }
     }
-
-    Class DelayBlock{
-        input : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-        initial : Block {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
-        memory : Float {
-            target_lower_multiplicity = 1
-            target_upper_multiplicity = 1
-        }
+    Association InitialCondition(Block, DelayBlock){
+        source_lower_multiplicity = 0
+        source_upper_multiplicity = 1
     }
 
     Inheritance (ConstantBlock, Block){}
@@ -92,4 +63,4 @@ SCD CausalBlockDiagrams{
     Inheritance (DelayBlock, Block){}
 }
 
-export CausalBlockDiagrams to models/CausalBlockDiagrams
+export CausalBlockDiagrams_Runtime to models/CausalBlockDiagrams_Runtime