Browse Source

Fixed fmu.cpp
Cleaned imports and removed various warnings

Casper Thule 3 years ago
parent
commit
7b78dc059e
10 changed files with 69 additions and 85 deletions
  1. 0 3
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/data/InOutRulesBlockResult.java
  2. 5 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/exceptions/IncorrectAmountOfElementsException.java
  3. 5 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/exceptions/InvalidConversionException.java
  4. 5 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/exceptions/MissingScalarVariableInformationException.java
  5. 5 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/exceptions/TypeException.java
  6. 7 9
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/ControlConditionSwitch.xtend
  7. 24 31
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/CppGenerator.xtend
  8. 3 3
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/FmuGenerator.xtend
  9. 1 3
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/GeneralConditionSwitch.xtend
  10. 14 36
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/RulesConditionSwitch.xtend

+ 0 - 3
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/data/InOutRulesBlockResult.java

@@ -1,10 +1,7 @@
 package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data;
 
-import java.util.LinkedHashMap;
 import java.util.List;
 
-import org.eclipse.xtext.xbase.lib.Pair;
-
 public class InOutRulesBlockResult extends RulesBlockResult {
 	//public final LinkedHashMap<String, GlobalInOutVariable> gVars;
 	//public final String constructorInitialization;

+ 5 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/exceptions/IncorrectAmountOfElementsException.java

@@ -1,6 +1,11 @@
 package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.exceptions;
 
 public class IncorrectAmountOfElementsException extends Exception {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
 	public IncorrectAmountOfElementsException(String arg0) {
 		super(arg0);
 	}

+ 5 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/exceptions/InvalidConversionException.java

@@ -1,6 +1,11 @@
 package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.exceptions;
 
 public class InvalidConversionException extends Exception {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
 	// Constructor that accepts a message
 	public InvalidConversionException(String message) {
 		super(message);

+ 5 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/exceptions/MissingScalarVariableInformationException.java

@@ -1,6 +1,11 @@
 package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.exceptions;
 
 public class MissingScalarVariableInformationException extends Exception {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
 	public MissingScalarVariableInformationException(String message) {
 		super(message);
 	}

+ 5 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/exceptions/TypeException.java

@@ -1,6 +1,11 @@
 package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.exceptions;
 
 public class TypeException extends Exception {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
 	public TypeException(String arg0) {
 		super(arg0);
 	}

+ 7 - 9
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/ControlConditionSwitch.xtend

@@ -1,26 +1,24 @@
 package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.generation
 
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.GlobalInOutVariable
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.MappedScalarVariable
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ReturnInformation
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SAScalarVariable
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Assignment
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.BreakStatement
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Close
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ControlRuleBlock
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.CurrentTime
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.CustomControlRule
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.DoStep
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.DoStepFun
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.GetNextInternalTimeStep
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Rollback
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SaveState
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.StepSize
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Variable
 import java.util.LinkedHashMap
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Port
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Assignment
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.MappedScalarVariable
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SaveState
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Close
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.BreakStatement
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Rollback
-import java.util.List
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.GetNextInternalTimeStep
 
 class ControlConditionSwitch extends RulesConditionSwitch {
 

+ 24 - 31
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/CppGenerator.xtend

@@ -1,41 +1,35 @@
 package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.generation
 
-import be.uantwerpen.ansymo.semanticadaptation.generator.SemanticAdaptationGenerator
-import org.eclipse.xtext.generator.IFileSystemAccess2
-
-import org.eclipse.xtext.generator.IGeneratorContext
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
-import org.eclipse.emf.ecore.resource.Resource
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Adaptation
-import java.util.ArrayList
-import java.util.LinkedHashMap
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.GlobalInOutVariable
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.IORuleType
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.InOutRulesBlockResult
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.InnerFMUData
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.MappedScalarVariable
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InnerFMU
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.exceptions.IncorrectAmountOfElementsException
-import java.io.File
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SAScalarVariable
-import org.eclipse.emf.common.util.EList
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Port
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVCausality
-import java.util.Collection
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InOutRules
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InRulesBlock
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.InOutRulesBlockResult
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.OutRulesBlock
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.GlobalInOutVariable
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ControlRuleBlock
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.RulesBlockResult
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ScalarVariable
-import java.util.List
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ParamDeclarations
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.InnerFMUData
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.IORuleType
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.RuleType
-import org.eclipse.emf.ecore.EObject
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ScalarVariable
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.exceptions.IncorrectAmountOfElementsException
+import be.uantwerpen.ansymo.semanticadaptation.generator.SemanticAdaptationGenerator
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Adaptation
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ControlRuleBlock
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Declaration
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InOutRules
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InnerFMU
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.MooreOrMealy
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ParamDeclarations
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Port
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ReactiveOrDelayed
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
+import java.io.File
+import java.util.ArrayList
+import java.util.Collection
+import java.util.LinkedHashMap
+import java.util.List
+import org.eclipse.emf.common.util.EList
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.xtext.generator.IFileSystemAccess2
+import org.eclipse.xtext.generator.IGeneratorContext
 
 class CppGenerator extends SemanticAdaptationGenerator {
 	private var IFileSystemAccess2 fsa;
@@ -714,7 +708,6 @@ class CppGenerator extends SemanticAdaptationGenerator {
 						else
 							currentPort.sourcedependency);
 					val newCount = visitor.functionSignatures.length + i + 1;
-					val inOrOut = (if(ioType == IORuleType.Input) "in" else "out")
 					val funcSigCon = visitor.createFunctionSignature('''condition''', "bool", newCount,
 						depFunctionSignatures)
 					val funcSigBody = visitor.createFunctionSignature('''body''', "void", newCount,
@@ -812,7 +805,7 @@ class CppGenerator extends SemanticAdaptationGenerator {
 				saSV.defineName = (definePrefix + inport.name).toUpperCase
 				saSV.causality = SVCausality.input;
 				saSVs.put(saSV.name, saSV);
-				if (inport.targetdependency != null) {
+				if (inport.targetdependency !== null) {
 					saSV.type = mSVs.get(inport.targetdependency.owner.name).get(inport.targetdependency.port.name).
 						mappedSv.type;
 					saSV.variability = mSVs.get(inport.targetdependency.owner.name).get(

+ 3 - 3
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/FmuGenerator.xtend

@@ -259,15 +259,15 @@ class FmuGenerator {
 		
 		extern "C" fmi2Status fmi2GetFMUstate(fmi2Component c, fmi2FMUstate* FMUstate)
 		{
-			return fmi2OK;
+		 return g_adaptation->fmi2GetFMUstate(c,FMUstate);
 		}
 		extern "C" fmi2Status fmi2SetFMUstate(fmi2Component c, fmi2FMUstate FMUstate)
 		{
-			return fmi2OK;
+		 return g_adaptation->fmi2SetFMUstate(c,FMUstate);
 		}
 		extern "C" fmi2Status fmi2FreeFMUstate(fmi2Component c, fmi2FMUstate* FMUstate)
 		{
-			return fmi2OK;
+		 return g_adaptation->fmi2FreeFMUstate(c,FMUstate);
 		}
 		
 		extern "C" fmi2Status fmi2SerializedFMUstateSize(fmi2Component c, fmi2FMUstate FMUstate, size_t *size)

+ 1 - 3
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/GeneralConditionSwitch.xtend

@@ -3,12 +3,10 @@ package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.generation
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ReturnInformation
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.BoolLiteral
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ParamDeclarations
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.IntLiteral
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.RealLiteral
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SingleParamDeclaration
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.util.SemanticAdaptationSwitch
 import org.eclipse.emf.ecore.EObject
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.IntLiteral
 
 class GeneralConditionSwitch extends SemanticAdaptationSwitch<ReturnInformation> {
 	override ReturnInformation caseIntLiteral(IntLiteral object){

+ 14 - 36
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/RulesConditionSwitch.xtend

@@ -1,50 +1,28 @@
 package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.generation
 
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.util.SemanticAdaptationSwitch
-import java.util.LinkedHashMap
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.GlobalInOutVariable
-import java.util.List
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.MappedScalarVariable
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SAScalarVariable
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ReturnInformation
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Literal
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.RealLiteral
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.IntLiteral
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.BoolLiteral
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.OutRulesBlock
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.DataRule
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InRulesBlock
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.RuleCondition
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.StateTransitionFunction
-import org.eclipse.emf.ecore.EObject
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SAScalarVariable
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Assignment
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Multi
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Neg
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SingleVarDeclaration
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.If
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.CompositeOutputFunction
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Variable
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.LValueDeclaration
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.DataRule
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Declaration
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.IsSet
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Div
-import org.eclipse.emf.common.util.EList
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InOutRules
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Min
-import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.exceptions.TypeException
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Minus
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.For
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SaveState
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Rollback
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.If
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.InOutRules
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.IsSet
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.LValueDeclaration
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Range
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Close
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.BreakStatement
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Port
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.CurrentTime
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.RuleCondition
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SingleVarDeclaration
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.StateTransitionFunction
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Var
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Plus
-import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.LessThan
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Variable
+import java.util.LinkedHashMap
+import java.util.List
+import org.eclipse.emf.common.util.EList
 
 class RulesConditionSwitch extends BasicConditionSwitch {
 	// Global params