浏览代码

CBD runtime model is also checked right after construction

Yentl Van Tendeloo 8 年之前
父节点
当前提交
fc6b7ce3bf

+ 0 - 1
integration/code/cbd_design.mvc

@@ -1,6 +1,5 @@
 import models/SimpleClassDiagrams as SCD
 include "primitives.alh"
-include "object_operations.alh"
 
 SCD CausalBlockDiagrams_Design{
     Class Float {

+ 1 - 13
integration/code/cbd_runtime.mvc

@@ -11,27 +11,15 @@ SCD CausalBlockDiagrams_Runtime{
         $
     }
 
-    Class Boolean {
-        $
-            if (bool_not(is_physical_boolean(self))):
-                return "Boolean has no bool value"!
-            else:
-                return "OK"!
-        $
-    }
-
     Class Natural {
         $
             if (bool_not(is_physical_int(self))):
-                return "Natural has no integer value at " + name!
-            elif (integer_lt(self, 0)):
-                return "Natural does not have a positive or zero value at " + name!
+                return "Natural has no integer value"!
             else:
                 return "OK"!
         $
     }
 
-
     Class Block{
         signal : Float {
             target_lower_cardinality = 1

+ 5 - 0
integration/code/cbd_semantics.alc

@@ -270,7 +270,12 @@ Void function set_termination_time(model : Element):
 	return !
 
 Void function execute_cbd(model : Element):
+	String verify_result
 	model = translate_to_runtime(model)
+	verify_result = conformance_scd(model)
+	if (verify_result != "OK"):
+		output("Error constructing conforming runtime model: " + verify_result)
+		return!
 
 	String cmd
 	Boolean running

+ 2 - 1
interface/HUTN/hutn_compiler/model_visitor.py

@@ -114,7 +114,8 @@ class ModelVisitor(Visitor):
                 f.write(constraint)
                 f.flush()
             directory = os.path.realpath(__file__).rsplit(os.sep, 1)[0]
-            self.constructors.extend(["add_constraint", self.current_model, self.current_element] + do_compile(".constraint.alc", directory + "/../grammars/actionlanguage.g", "CS"))
+            compiled = do_compile(".constraint.alc", directory + "/../grammars/actionlanguage.g", "CS")
+            self.constructors.extend(["add_constraint", self.current_model, self.current_element] + compiled)
 
     def visit_model_attr_instance(self, tree):
         children = tree.get_children("MODEL_ID")