Commit aeb57dcf authored by Malte Heithoff's avatar Malte Heithoff
Browse files

Merge branch 'master' into semantics

# Conflicts:
#	pom.xml
#	src/main/java/de/monticore/lang/monticar/generator/cpp/GeneratorCPP.java
#	src/main/java/de/monticore/lang/monticar/generator/cpp/GeneratorCppCli.java
parents 4c2cf14e 5af3b434
......@@ -26,3 +26,4 @@ buildNumber.properties
.vscode/
.settings/
temp/
\ No newline at end of file
......@@ -59,12 +59,12 @@
<version>${EmbeddedMontiArc-executionSemantics.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>montiarc.verification</groupId>-->
<!-- <artifactId>montiarc-execution-order</artifactId>-->
<!-- <version>4.0.1-SNAPSHOT</version>-->
<!-- </dependency>-->
<!-- MontiSim Dependency for the DynamicInterface generation -->
<dependency>
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>2.0.11</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
......
......@@ -59,6 +59,7 @@ public class CMakeConfig {
public CMakeConfig(String compName) {
cMakeListsViewModel.setCompName(compName);
cMakeListsViewModel.setModuleDependencies(moduleList);
configureCMakeListsViewModel();
}
// methods
......@@ -106,7 +107,7 @@ public class CMakeConfig {
public FileContent generateCMakeLists() {
FileContent result = null;
configureCMakeListsViewModel();
//configureCMakeListsViewModel();
// map data
Map<String, Object> dataForTemplate = TemplateHelper.getDataForTemplate(cMakeListsViewModel);
// try generate file content
......
......@@ -13,6 +13,7 @@ public final class FileUtil {
public static FileContent getResourceAsFile(String resourcePath, String destinationFilePath) {
InputStream resource = FileUtil.class.getResourceAsStream(resourcePath);
if (resource == null) throw new IllegalArgumentException("Could not get resource: "+resourcePath);
String body = new Scanner(resource, "UTF-8").useDelimiter("\\A").next();
return new FileContent(body, destinationFilePath);
}
......
......@@ -14,13 +14,13 @@ import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.Dynamics.DynamicHelper;
import de.monticore.lang.monticar.generator.cpp.Dynamics.EventPortValueCheck;
import de.monticore.lang.monticar.generator.cpp.converter.*;
import de.monticore.lang.monticar.generator.cpp.dynamic_interface.DynamicInterfaceGenerator;
import de.monticore.lang.monticar.generator.cpp.loopSolver.CPPEquationSystemHelper;
import de.monticore.lang.monticar.generator.cpp.loopSolver.EquationSystemComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.loopSolver.NumericSolverOptions;
import de.monticore.lang.monticar.generator.cpp.loopSolver.RHSComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.mathopt.MathOptSolverConfig;
import de.monticore.lang.monticar.generator.cpp.template.AllTemplates;
import de.monticore.lang.monticar.generator.cpp.viewmodel.AutopilotAdapterDataModel;
import de.monticore.lang.monticar.generator.cpp.viewmodel.ServerWrapperViewModel;
import de.monticore.lang.monticar.generator.testing.StreamTestGenerator;
import de.monticore.lang.monticar.semantics.ExecutionSemantics;
......@@ -30,6 +30,7 @@ import de.monticore.lang.monticar.semantics.loops.symbols.LoopComponentInstanceS
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.Scope;
import de.rwth.montisim.commons.utils.json.SerializationException;
import de.se_rwth.commons.Names;
import de.se_rwth.commons.logging.Log;
import org.apache.commons.lang3.StringUtils;
......@@ -48,7 +49,11 @@ public class GeneratorCPP implements EMAMGenerator {
public static GeneratorCPP currentInstance;
private Path modelsDirPath;
private boolean isGenerateTests = false;
private boolean isGenerateAutopilotAdapter = false;
private boolean genDynamicInterface = false;
private boolean genServerAdapter = false;
private boolean genDDCAdapter = false;
private boolean importArmadillo = false;
private String outputName = "";
private boolean isGenerateServerWrapper = false;
protected boolean isExecutionLoggingActive = false;
private final List<EMAMBluePrintCPP> bluePrints = new ArrayList<>();
......@@ -70,7 +75,7 @@ public class GeneratorCPP implements EMAMGenerator {
private CMakeConfig cMakeConfig;
//MathOpt
// MathOpt
private MathOptSolverConfig mathOptSolverConfig = new MathOptSolverConfig();
private OptimizationSymbolHandler mathOptExecuteMethodGenerator = new OptimizationSymbolHandler();
private MathOptFunctionFixer mathOptFunctionFixer = new MathOptFunctionFixer();
......@@ -94,7 +99,6 @@ public class GeneratorCPP implements EMAMGenerator {
emamFunctionFixer.setSuccessor(mathOptFunctionFixer);
}
public boolean isExecutionLoggingActive() {
return isExecutionLoggingActive;
}
......@@ -107,7 +111,21 @@ public class GeneratorCPP implements EMAMGenerator {
cMakeConfig = new CMakeConfig("");
if (usesArmadilloBackend()) {
// add dependency on module Armadillo
cMakeConfig.addModuleDependency(new CMakeFindModule("Armadillo", true));
if (importArmadillo) {
// cMakeConfig.addCMakeCommand("SET(BUILD_SHARED_LIBS OFF)");
// cMakeConfig.addCMakeCommand("SET(CMAKE_EXE_LINKER_FLAGS \"-static\")");
// cMakeConfig.addCMakeCommand("add_subdirectory($ENV{ARMADILLO_PATH} armadillo)");
// cMakeConfig.addCMakeCommand("set(LIBS ${LIBS} armadillo)");
//cMakeConfig.addCMakeCommand("target_link_libraries(armadillo -static)");
cMakeConfig.addCMakeCommand("# Add simple Wrapper for header-only armadillo");
cMakeConfig.addCMakeCommand("add_library(armadillo INTERFACE)");
cMakeConfig.addCMakeCommand("target_include_directories(armadillo INTERFACE $ENV{ARMADILLO_PATH}/include)");
cMakeConfig.addCMakeCommand("target_compile_definitions(armadillo INTERFACE ARMA_DONT_USE_WRAPPER)");
cMakeConfig.addCMakeCommand("set(LIBS ${LIBS} armadillo)");
} else {
cMakeConfig.addModuleDependency(new CMakeFindModule("Armadillo", true));
}
}
}
......@@ -136,7 +154,8 @@ public class GeneratorCPP implements EMAMGenerator {
public void useOctaveBackend() {
MathConverter.curBackend = new OctaveBackend();
setupCMake();
//Log.warn("This backend has been deprecated. Armadillo is the recommended backend now.");
// Log.warn("This backend has been deprecated. Armadillo is the recommended
// backend now.");
}
public String generateString(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentInstanceSymbol) {
......@@ -167,8 +186,9 @@ public class GeneratorCPP implements EMAMGenerator {
}
public String generateString(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentSymbol,
MathStatementsSymbol mathStatementsSymbol) {
StreamTestGenerator streamTestGenerator = new StreamTestGenerator();//only used when creating streamTestsForAComponent
MathStatementsSymbol mathStatementsSymbol) {
StreamTestGenerator streamTestGenerator = new StreamTestGenerator();// only used when creating
// streamTestsForAComponent
LanguageUnitCPP languageUnitCPP = new LanguageUnitCPP();
languageUnitCPP.setGeneratorCPP(this);
languageUnitCPP.addSymbolToConvert(componentSymbol);
......@@ -206,24 +226,25 @@ public class GeneratorCPP implements EMAMGenerator {
private static Set<EMAMEquationSymbol> equationSystemsAlreadyBuild = new HashSet<>();
@Override
public List<FileContent> generateStrings(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentInstanceSymbol) {
public List<FileContent> generateStrings(TaggingResolver taggingResolver,
EMAComponentInstanceSymbol componentInstanceSymbol) {
List<FileContent> fileContents = new ArrayList<>();
if (componentInstanceSymbol.getFullName().equals("simulator.mainController")) {
setGenerateSimulatorInterface(true);
} else {
//setGenerateMainClass(true);
// setGenerateMainClass(true);
}
// ImplementExecutionOrder.exOrder(taggingResolver, componentInstanceSymbol);
String lastNameWithoutArrayPart = "";
if (!streamTestGenerationMode) {
for (EMAComponentInstanceSymbol instanceSymbol : componentInstanceSymbol.getSubComponents()) {
//fileContents.add(new FileContent(generateString(instanceSymbol, symtab), instanceSymbol));
// fileContents.add(new FileContent(generateString(instanceSymbol, symtab),
// instanceSymbol));
int arrayBracketIndex = instanceSymbol.getName().indexOf("[");
boolean generateComponentInstance = true;
if (arrayBracketIndex != -1) {
generateComponentInstance = !instanceSymbol.getName().substring(0, arrayBracketIndex).equals(lastNameWithoutArrayPart);
generateComponentInstance = !instanceSymbol.getName().substring(0, arrayBracketIndex)
.equals(lastNameWithoutArrayPart);
lastNameWithoutArrayPart = instanceSymbol.getName().substring(0, arrayBracketIndex);
Log.info(lastNameWithoutArrayPart, "Without:");
Log.info(generateComponentInstance + "", "Bool:");
......@@ -273,7 +294,7 @@ public class GeneratorCPP implements EMAMGenerator {
fileContents.add(ArmadilloHelper.getArmadilloHelperFileContent(isGenerateTests));
if (componentInstanceSymbol instanceof EMADynamicComponentInstanceSymbol) {
//TODO: add Events Value Helper
// TODO: add Events Value Helper
if (!((EMADynamicComponentInstanceSymbol) componentInstanceSymbol).getEventHandlers().isEmpty())
fileContents.add(EventPortValueCheck.getEventPortValueCheckFileContent());
......@@ -292,9 +313,10 @@ public class GeneratorCPP implements EMAMGenerator {
}
//TODO add incremental generation based on described concept
public List<File> generateFiles(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentSymbol) throws IOException {
public List<File> generateFiles(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentSymbol)
throws IOException {
this.rootModel = componentSymbol;
List<FileContent> fileContents = new ArrayList<>();
if (componentSymbol == null) {
ComponentScanner componentScanner = new ComponentScanner(getModelsDirPath(), taggingResolver, "emam");
......@@ -321,9 +343,9 @@ public class GeneratorCPP implements EMAMGenerator {
}
fileContents.addAll(generateTypes(TypeConverter.getTypeSymbols()));
fileContents.addAll(handleTestAndCheckDir(taggingResolver, componentSymbol));
if (isGenerateAutopilotAdapter()) {
fileContents.addAll(getAutopilotAdapterFiles(componentSymbol));
}
generateAdapters(fileContents, componentSymbol);
if (isGenerateServerWrapper()) {
fileContents.addAll(getServerWrapperFiles(componentSymbol));
}
......@@ -359,6 +381,27 @@ public class GeneratorCPP implements EMAMGenerator {
return files;
}
public void generateAdapters(List<FileContent> fileContents, EMAComponentInstanceSymbol component) {
if (genDynamicInterface || genServerAdapter || genDDCAdapter) {
try {
fileContents.addAll(
new DynamicInterfaceGenerator(
component,
cMakeConfig,
outputName,
genDynamicInterface,
genServerAdapter,
genDDCAdapter
).getFiles()
);
} catch (SerializationException | IOException e) {
throw new RuntimeException(e);
}
}
}
public List<File> saveFilesToDisk(List<FileContent> fileContents) throws IOException {
List<File> files = new ArrayList<>();
for (FileContent fileContent : fileContents) {
......@@ -490,12 +533,44 @@ public class GeneratorCPP implements EMAMGenerator {
isGenerateTests = generateTests;
}
public boolean isGenerateAutopilotAdapter() {
return isGenerateAutopilotAdapter;
public boolean isGenerateDynamicInterface() {
return genDynamicInterface;
}
public void setImportArmadillo(boolean doImport) {
this.importArmadillo = doImport;
}
public void setGenerateAutopilotAdapter(boolean generateAutopilotAdapter) {
isGenerateAutopilotAdapter = generateAutopilotAdapter;
public boolean isImportArmadillo() {
return importArmadillo;
}
public void setGenerateDynamicInterface(boolean gen) {
genDynamicInterface = gen;
}
public boolean isGenerateServerAdapter() {
return genServerAdapter;
}
public void setGenerateServerAdapter(boolean gen) {
genServerAdapter = gen;
}
public boolean isGenerateDDCAdapter() {
return genDDCAdapter;
}
public void setGenerateDDCAdapter(boolean gen) {
genDDCAdapter = gen;
}
public void setOutputName(String name) {
this.outputName = name;
}
public String getOutputName() {
return outputName;
}
public boolean isGenerateServerWrapper() {
......@@ -523,55 +598,6 @@ public class GeneratorCPP implements EMAMGenerator {
return tg.generateTypes(typeSymbols);
}
private static List<FileContent> getAutopilotAdapterFiles(EMAComponentInstanceSymbol componentSymbol) {
List<FileContent> result = new ArrayList<>();
AutopilotAdapterDataModel dm = new AutopilotAdapterDataModel();
dm.setMainModelName(GeneralHelperMethods.getTargetLanguageComponentName(componentSymbol.getFullName()));
dm.setInputCount(componentSymbol.getIncomingPortInstances().size());
dm.setOutputCount(componentSymbol.getOutgoingPortInstances().size());
for (EMAPortInstanceSymbol port : componentSymbol.getIncomingPortInstances()) {
dm.addInput(port.getName(), port.getTypeReference().getName());
}
for (EMAPortInstanceSymbol port : componentSymbol.getOutgoingPortInstances()) {
dm.addOutput(port.getName(), port.getTypeReference().getName());
}
result.add(generateAutopilotAdapterH(dm));
result.add(generateAutopilotAdapterCpp(dm));
return result;
}
private static FileContent generateAutopilotAdapterH(AutopilotAdapterDataModel dm) {
String fileContents = AllTemplates.generateAutopilotAdapterH(dm);
return new FileContent(fileContents, "AutopilotAdapter.h");
}
private static FileContent generateAutopilotAdapterCpp(AutopilotAdapterDataModel dm) {
String fileContents = AllTemplates.generateAutopilotAdapterCpp(dm);
if (currentInstance.generateCMake)
addAutopilotAdapterCMakeConfig();
return new FileContent(fileContents, "AutopilotAdapter.cpp");
}
private static void addAutopilotAdapterCMakeConfig() {
CMakeConfig cmake = currentInstance.cMakeConfig;
// add jni
cmake.addCMakeCommand("find_package(JNI)");
cmake.addCMakeCommand("set(INCLUDE_DIRS ${INCLUDE_DIRS} ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})");
// create shared lib
cmake.addCMakeCommandEnd("add_library(AutopilotAdapter SHARED AutopilotAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR})");
cmake.addCMakeCommandEnd("target_include_directories(AutopilotAdapter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})");
cmake.addCMakeCommandEnd("target_link_libraries(AutopilotAdapter PUBLIC ${LIBS})");
cmake.addCMakeCommandEnd("set_target_properties(AutopilotAdapter PROPERTIES LINKER_LANGUAGE CXX)");
cmake.addCMakeCommand("IF (WIN32)");
cmake.addCMakeCommandEnd("set_target_properties(AutopilotAdapter PROPERTIES PREFIX \"\")");
cmake.addCMakeCommand("ENDIF()");
// install shared lib
cmake.addCMakeCommandEnd("install(TARGETS AutopilotAdapter DESTINATION $ENV{DLL_DIR})");
cmake.addCMakeCommandEnd("export(TARGETS AutopilotAdapter FILE de_rwth_armin_modeling_autopilot_autopilotAdapter.cmake)");
}
private static List<FileContent> getServerWrapperFiles(EMAComponentInstanceSymbol componentSymbol) {
List<FileContent> result = new ArrayList<>();
String[] filesToCopy = new String[]{
......
......@@ -53,6 +53,13 @@ public final class GeneratorCppCli {
.required(false)
.build();
public static final Option OPTION_OUTPUT_NAME = Option.builder("n")
.longOpt("output-name")
.desc("Name for the dynamic-interface or server adapter.")
.hasArg(true)
.required(false)
.build();
public static final Option OPTION_FLAG_TESTS = Option.builder("t")
.longOpt("flag-generate-tests")
.desc("optional flag indicating if tests generation is needed")
......@@ -67,6 +74,13 @@ public final class GeneratorCppCli {
.required(false)
.build();
public static final Option OPTION_IMPORT_ARMADILLO = Option.builder()
.longOpt("armadillo-import")
.desc("If enabled, the project will include Armadillo for compilation based on the ARMADILLO_PATH environment variable")
.hasArg(false)
.required(false)
.build();
public static final Option OPTION_FLAG_ALGEBRAIC = Option.builder("a")
.longOpt("flag-use-algebraic")
.desc("optional flag indicating if algebraic optimizations should be on")
......@@ -89,9 +103,24 @@ public final class GeneratorCppCli {
.required(false)
.build();
public static final Option OPTION_FLAG_AUTOPILOT_ADAPTER = Option.builder()
.longOpt("flag-generate-autopilot-adapter")
.desc("optional flag indicating if autopilot adapter should be generated")
public static final Option OPTION_FLAG_DYNAMIC_INTERFACE = Option.builder("di")
.longOpt("dyn-interface")
.desc("Enable autopilot adapter generation")
.hasArg(false)
.required(false)
.build();
public static final Option OPTION_FLAG_GEN_TCP_SERVER = Option.builder("tcp")
.longOpt("tcp-adapter")
.desc("Generate the TCP-Server adapter for the model")
.hasArg(false)
.required(false)
.build();
public static final Option OPTION_FLAG_GEN_DDC_ADAPTER = Option.builder("ddc")
.longOpt("ddc-adapter")
.desc("Generate the DDC adapter for the model")
.hasArg(false)
.required(false)
.build();
......@@ -219,18 +248,31 @@ public final class GeneratorCppCli {
public static Options getOptions() {
Options options = new Options();
addBaseOptions(options);
addEMAM2CPPOptions(options);
return options;
}
public static void addBaseOptions(Options options) {
options.addOption(OPTION_MODELS_PATH);
options.addOption(OPTION_ROOT_MODEL);
options.addOption(OPTION_OUTPUT_PATH);
options.addOption(OPTION_FLAG_CMAKE);
}
public static void addEMAM2CPPOptions(Options options) {
options.addOption(OPTION_FLAG_TESTS);
options.addOption(OPTION_FLAG_ARMADILLO);
options.addOption(OPTION_FLAG_AUTOPILOT_ADAPTER);
options.addOption(OPTION_IMPORT_ARMADILLO);
options.addOption(OPTION_FLAG_DYNAMIC_INTERFACE);
options.addOption(OPTION_OUTPUT_NAME);
options.addOption(OPTION_FLAG_GEN_TCP_SERVER);
options.addOption(OPTION_FLAG_GEN_DDC_ADAPTER);
options.addOption(OPTION_FLAG_CHECK_MODEL_DIR);
options.addOption(OPTION_FLAG_SERVER_WRAPPER);
options.addOption(OPTION_FLAG_ALGEBRAIC);
options.addOption(OPTION_FLAG_THREADING);
options.addOption(OPTION_FLAG_EXEC_LOGGING);
options.addOption(OPTION_FLAG_CMAKE);
options.addOption(OPTION_DELTA_T);
options.addOption(OPTION_ATOL);
options.addOption(OPTION_RTOL);
......@@ -243,8 +285,6 @@ public final class GeneratorCppCli {
options.addOption(OPTION_WARN_LOOPS);
options.addOption(OPTION_WARN_ARTIFICIAL_LOOPS);
options.addOption(OPTION_LOG_SYMBOLIC_SOLVE);
return options;
}
public static CommandLine parseArgs(Options options, CommandLineParser parser, String[] args) {
......@@ -273,20 +313,22 @@ public final class GeneratorCppCli {
g.setModelsDirPath(modelsDirPath);
g.setGenerationTargetPath(outputPath);
g.setGenerateTests(cliArgs.hasOption(OPTION_FLAG_TESTS.getOpt()));
g.setImportArmadillo(cliArgs.hasOption(OPTION_IMPORT_ARMADILLO.getLongOpt()));
if (cliArgs.hasOption(OPTION_FLAG_ARMADILLO.getOpt())) {
g.useArmadilloBackend();
}
g.setCheckModelDir(cliArgs.hasOption(OPTION_FLAG_CHECK_MODEL_DIR.getLongOpt()));
g.setGenerateServerWrapper(cliArgs.hasOption(OPTION_FLAG_SERVER_WRAPPER.getLongOpt()));
g.setGenerateAutopilotAdapter(cliArgs.hasOption(OPTION_FLAG_AUTOPILOT_ADAPTER.getLongOpt()));
g.setGenerateDynamicInterface(cliArgs.hasOption(OPTION_FLAG_DYNAMIC_INTERFACE.getLongOpt()));
g.setGenerateServerAdapter(cliArgs.hasOption(OPTION_FLAG_GEN_TCP_SERVER.getLongOpt()));
g.setGenerateDDCAdapter(cliArgs.hasOption(OPTION_FLAG_GEN_DDC_ADAPTER.getLongOpt()));
g.setOutputName(cliArgs.getOptionValue(OPTION_OUTPUT_NAME.getOpt()));
g.setUseAlgebraicOptimizations(cliArgs.hasOption(OPTION_FLAG_ALGEBRAIC.getLongOpt()));
g.setUseThreadingOptimization(cliArgs.hasOption(OPTION_FLAG_THREADING.getLongOpt()));
g.setExecutionLoggingActive(cliArgs.hasOption(OPTION_FLAG_EXEC_LOGGING.getLongOpt()));
g.setGenerateCMake(cliArgs.hasOption(OPTION_FLAG_CMAKE.getLongOpt()));
g.setGenerateCMake(cliArgs.hasOption(OPTION_FLAG_CMAKE.getLongOpt()));
if (cliArgs.hasOption(OPTION_DELTA_T.getOpt()))
g.setDeltaT(cliArgs.getOptionValue(OPTION_DELTA_T.getOpt()));
if (cliArgs.hasOption(OPTION_DELTA_T.getLongOpt()))
......
package de.monticore.lang.monticar.generator.cpp.dynamic_interface;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import de.monticore.lang.monticar.generator.FileContent;
import de.rwth.montisim.commons.utils.json.SerializationException;
public class DDCCommunication {
static final String BASE_SPACES = " ";
final DynamicInterfaceGenerator gen;
FileBuilder b = new FileBuilder();
public DDCCommunication(DynamicInterfaceGenerator gen) {
this.gen = gen;
throw new IllegalArgumentException("DDCCommunication not implemented yet.");
}
public List<FileContent> generate() throws SerializationException {
List<FileContent> files = new ArrayList<>();
return files;
}
public void getSources(HashSet<String> sources) {
sources.add("ddc_mode.cpp");
}
public void getLibs(HashSet<String> libs) {
libs.add("ddc_load");
}
}
package de.monticore.lang.monticar.generator.cpp.dynamic_interface;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import de.rwth.montisim.commons.dynamicinterface.*;
import de.rwth.montisim.commons.dynamicinterface.PortInformation.PortDirection;
import de.rwth.montisim.commons.utils.json.Json;
import de.rwth.montisim.commons.utils.json.SerializationException;
import de.monticore.ast.ASTNode;
import de.monticore.expressionsbasis._ast.ASTExpression;
import de.monticore.javaclassexpressions._ast.ASTNameExpression;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.math._ast.ASTNumberExpression;
import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.monticar.common2._ast.ASTCommonMatrixType;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.cmake.CMakeConfig;
import de.monticore.lang.monticar.generator.cpp.FileUtil;
import de.monticore.lang.monticar.generator.cpp.GeneralHelperMethods;
import de.monticore.lang.monticar.struct._ast.ASTStruct;
import de.monticore.lang.monticar.struct._ast.ASTStructFieldDefinition;
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.lang.monticar.ts.references.MCASTTypeSymbolReference;
import de.monticore.lang.monticar.ts.references.MCTypeReference;
import de.monticore.lang.monticar.types2._ast.ASTElementType;
import de.monticore.numberunit._ast.ASTNumberWithUnit;
import de.monticore.types.types._ast.ASTType;
/*
Generates the CPP files necessary to build the 'DynamicInterface'
DISCLAIMER: Do not assume the use of the EmbeddedMontiArc framework here is optimal, someone with experience in
the EMA suite should verify how the different types and symbols are resolved.
*/
public class DynamicInterfaceGenerator {
HashSet<String> cppFileDependencies = new HashSet<>();
List<FileContent> files = new ArrayList<>();
String componentName;
ProgramInterface programInterface;
String progInterfaceString;
JsonCommunication dyn;
TcpCommunication tcp;
DDCCommunication ddc;
public DynamicInterfaceGenerator(
EMAComponentInstanceSymbol componentSymbol,
CMakeConfig cmake,
String outputName,
boolean genDynamicInterface,
boolean genServer,
boolean genDDC
) throws SerializationException, IOException {
// Read the ProgramInterface from the model
resolve(componentSymbol);
progInterfaceString = Json.toJson(programInterface);
// Generate the files
if (genDynamicInterface) {
dyn = new JsonCommunication(this);
files.addAll(dyn.generate());
}