Commit 43a9e716 authored by Jean Meurice's avatar Jean Meurice

Merge branch 'sim_dev' into 'master'

Simulation Adapters (DynamicInterface, Server Adapter)

See merge request !47
parents ca7fa11d 525ed577
Pipeline #366524 passed with stage
in 32 seconds
......@@ -26,3 +26,4 @@ buildNumber.properties
.vscode/
.settings/
temp/
\ No newline at end of file
......@@ -10,7 +10,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-generator</artifactId>
<version>0.4.0-SNAPSHOT</version>
<version>0.4.1</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......@@ -67,6 +67,13 @@
<scope>provided</scope>
</dependency>
<!-- MontiSim Dependency for the DynamicInterface generation -->
<dependency>
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>montiarc.verification</groupId>
......
......@@ -60,6 +60,7 @@ public class CMakeConfig {
public CMakeConfig(String compName) {
cMakeListsViewModel.setCompName(compName);
cMakeListsViewModel.setModuleDependencies(moduleList);
configureCMakeListsViewModel();
}
// methods
......@@ -107,7 +108,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);
}
......
......@@ -4,7 +4,6 @@ package de.monticore.lang.monticar.generator.cpp;
import de.ma2cfg.helper.Names;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc.ComponentScanner;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.embeddedmontiarcdynamic.embeddedmontiarcdynamic._symboltable.instanceStructure.EMADynamicComponentInstanceSymbol;
import de.monticore.lang.math._symboltable.MathStatementsSymbol;
import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
......@@ -14,14 +13,15 @@ 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.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.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.logging.Log;
import java.io.BufferedWriter;
......@@ -37,7 +37,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<>();
......@@ -58,9 +62,7 @@ public class GeneratorCPP implements EMAMGenerator {
private boolean generateCMake = false;
private CMakeConfig cMakeConfig;
//MathOpt
// MathOpt
private MathOptSolverConfig mathOptSolverConfig = new MathOptSolverConfig();
private OptimizationSymbolHandler mathOptExecuteMethodGenerator = new OptimizationSymbolHandler();
private MathOptFunctionFixer mathOptFunctionFixer = new MathOptFunctionFixer();
......@@ -76,7 +78,6 @@ public class GeneratorCPP implements EMAMGenerator {
mathOptFunctionFixer.setSuccessor(MathFunctionFixer.getInstance());
}
public boolean isExecutionLoggingActive() {
return isExecutionLoggingActive;
}
......@@ -89,7 +90,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));
}
}
}
......@@ -118,7 +133,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) {
......@@ -148,8 +164,10 @@ public class GeneratorCPP implements EMAMGenerator {
this.generationTargetPath = newPath;
}
public String generateString(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentSymbol, MathStatementsSymbol mathStatementsSymbol) {
StreamTestGenerator streamTestGenerator = new StreamTestGenerator();//only used when creating streamTestsForAComponent
public String generateString(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentSymbol,
MathStatementsSymbol mathStatementsSymbol) {
StreamTestGenerator streamTestGenerator = new StreamTestGenerator();// only used when creating
// streamTestsForAComponent
LanguageUnitCPP languageUnitCPP = new LanguageUnitCPP();
languageUnitCPP.setGeneratorCPP(this);
languageUnitCPP.addSymbolToConvert(componentSymbol);
......@@ -180,28 +198,34 @@ public class GeneratorCPP implements EMAMGenerator {
public static List<FileContent> currentFileContentList = null;
@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);
}
currentFileContentList = fileContents;
if (!streamTestGenerationMode)
fileContents.add(new FileContent(generateString(taggingResolver, componentInstanceSymbol), componentInstanceSymbol));
fileContents.add(
new FileContent(generateString(taggingResolver, componentInstanceSymbol), componentInstanceSymbol));
else
fileContents.add(new FileContent(generateString(taggingResolver, componentInstanceSymbol),
componentInstanceSymbol.getPackageName().replaceAll("\\.", "\\/") + "/" + Names.FirstUpperCase(componentInstanceSymbol.getName()) + "Test" + testNamePostFix + ".stream"));
componentInstanceSymbol.getPackageName().replaceAll("\\.", "\\/") + "/"
+ Names.FirstUpperCase(componentInstanceSymbol.getName()) + "Test" + testNamePostFix
+ ".stream"));
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:");
......@@ -220,7 +244,8 @@ public class GeneratorCPP implements EMAMGenerator {
}
}
if (shouldGenerateMainClass()) {
//fileContents.add(getMainClassFileContent(componentInstanceSymbol, fileContents.get(0)));
// fileContents.add(getMainClassFileContent(componentInstanceSymbol,
// fileContents.get(0)));
} else if (shouldGenerateSimulatorInterface()) {
fileContents.addAll(SimulatorIntegrationHelper.getSimulatorIntegrationHelperFileContent());
}
......@@ -230,18 +255,19 @@ public class GeneratorCPP implements EMAMGenerator {
if (MathConverter.curBackend.getBackendName().equals("ArmadilloBackend"))
fileContents.add(ArmadilloHelper.getArmadilloHelperFileContent(isGenerateTests));
if(componentInstanceSymbol instanceof EMADynamicComponentInstanceSymbol){
//TODO: add Events Value Helper
if(!((EMADynamicComponentInstanceSymbol) componentInstanceSymbol).getEventHandlers().isEmpty())
if (componentInstanceSymbol instanceof EMADynamicComponentInstanceSymbol) {
// TODO: add Events Value Helper
if (!((EMADynamicComponentInstanceSymbol) componentInstanceSymbol).getEventHandlers().isEmpty())
fileContents.add(EventPortValueCheck.getEventPortValueCheckFileContent());
if(((EMADynamicComponentInstanceSymbol)componentInstanceSymbol).isDynamic()){
if (((EMADynamicComponentInstanceSymbol) componentInstanceSymbol).isDynamic()) {
fileContents.add(DynamicHelper.getDynamicHelperFileContent());
}
}
if (shouldGenerateMainClass()) {
//fileContents.add(getMainClassFileContent(componentInstanceSymbol, fileContents.get(0)));
// fileContents.add(getMainClassFileContent(componentInstanceSymbol,
// fileContents.get(0)));
} else if (shouldGenerateSimulatorInterface()) {
fileContents.addAll(SimulatorIntegrationHelper.getSimulatorIntegrationHelperFileContent());
}
......@@ -249,18 +275,18 @@ public class GeneratorCPP implements EMAMGenerator {
return fileContents;
}
//TODO add incremental generation based on described concept
public List<File> generateFiles(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentSymbol) throws IOException {
// TODO add incremental generation based on described concept
public List<File> generateFiles(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentSymbol)
throws IOException {
List<FileContent> fileContents = new ArrayList<>();
if (componentSymbol == null) {
ComponentScanner componentScanner = new ComponentScanner(getModelsDirPath(), taggingResolver, "emam");
Set<String> availableComponents = componentScanner.scan();
for (String componentFullName : availableComponents) {
componentFullName = Names.getExpandedComponentInstanceSymbolName(componentFullName);
if (taggingResolver.resolve(componentFullName,
EMAComponentInstanceSymbol.KIND).isPresent()) {
EMAComponentInstanceSymbol componentInstanceSymbol = (EMAComponentInstanceSymbol) taggingResolver.resolve(componentFullName,
EMAComponentInstanceSymbol.KIND).get();
if (taggingResolver.resolve(componentFullName, EMAComponentInstanceSymbol.KIND).isPresent()) {
EMAComponentInstanceSymbol componentInstanceSymbol = (EMAComponentInstanceSymbol) taggingResolver
.resolve(componentFullName, EMAComponentInstanceSymbol.KIND).get();
fileContents.addAll(generateStrings(taggingResolver, componentInstanceSymbol));
}
}
......@@ -270,9 +296,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));
}
......@@ -303,6 +329,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) {
......@@ -434,12 +481,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() {
......@@ -467,55 +546,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,22 @@ 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();
......@@ -150,7 +177,11 @@ public final class GeneratorCppCli {
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);
......@@ -184,12 +215,16 @@ 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()));
......
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