Browse Source

Fixed issue related to h and dt

Casper Thule 3 years ago
parent
commit
d97173bb78

+ 12 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/CppGenerator.xtend

@@ -724,12 +724,18 @@ class CppGenerator extends SemanticAdaptationGenerator {
 						val getValueCpp = '''getValue«Conversions.fmiTypeToGetValueString(type)»(«dependency.owner.name»,«define»)''';
 						ruleCpp = '''
 							«funcSigCon»{
+								double h = 0;
+								double dt = 0;
 								return true;
 							}
 							«funcSigBody»{
+								double h = 0;
+								double dt = 0;
 								this->internalState.stored_«dependency.owner.name»_«dependency.port.name» = «getValueCpp»;
 							}
 							«funcSigFlush»{
+								double h = 0;
+								double dt = 0;
 								this->internalState.«currentPort.name» = this->internalState.stored_«dependency.owner.name»_«dependency.port.name»;
 							}
 						'''
@@ -737,12 +743,18 @@ class CppGenerator extends SemanticAdaptationGenerator {
 						val setValueCpp = '''setValue(«dependency.owner.name»,«define»,this->internalState.stored_«dependency.owner.name»_«dependency.port.name»);''';
 						ruleCpp = '''
 							«funcSigCon»{
+								double h = 0;
+								double dt = 0;
 								return true;
 							}
 							«funcSigBody»{
+								double h = 0;
+								double dt = 0;
 								this->internalState.stored_«dependency.owner.name»_«dependency.port.name» = this->internalState.«currentPort.name»;
 							}
 							«funcSigFlush»{
+								double h = 0;
+								double dt = 0;
 								«setValueCpp»
 							}
 						'''

+ 6 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/RulesConditionSwitch.xtend

@@ -184,6 +184,8 @@ class RulesConditionSwitch extends BasicConditionSwitch {
 		val functionSignature = createFunctionSignature("condition", "bool", this.count, this.functionSignatures);
 		retVal.code = '''
 			«functionSignature»{
+				double h = 0;
+				double dt = 0;
 				return «doSwitch(object.condition).code»;
 			}
 		''';
@@ -197,6 +199,8 @@ class RulesConditionSwitch extends BasicConditionSwitch {
 		val functionSig = createFunctionSignature("body", "void", this.count, this.functionSignatures);
 		retVal.code = '''
 			«functionSig»{
+				double h = 0;
+				double dt = 0;
 				«IF object.expression !== null»
 					«val result = doSwitch(object.expression)»
 					«result.code»«if (!result.isExpression) ";"»
@@ -302,6 +306,8 @@ class RulesConditionSwitch extends BasicConditionSwitch {
 		val functionSig = createFunctionSignature("flush", "void", this.count, this.functionSignatures);
 		retVal.code = '''
 			«functionSig»{
+				double h = 0;
+				double dt = 0;
 				«FOR stm : object.statements»
 					«val result = doSwitch(stm)»
 					«result.code»«if(!result.isExpression) ";"»