Commit 370f5adb authored by Jean Meurice's avatar Jean Meurice

Merge branch 'sim_dev' into 'master'

Adapter Generation (DynamicInterface, Server-Adapter)

See merge request !44
parents 1c3a9400 3c17cd3f
Pipeline #366592 passed with stages
in 4 minutes and 46 seconds
......@@ -9,7 +9,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-emadl-generator</artifactId>
<version>0.4.3-SNAPSHOT</version>
<version>0.4.4</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......@@ -25,7 +25,7 @@
<cnnarch-gluon-generator.version>0.4.0-SNAPSHOT</cnnarch-gluon-generator.version>
<cnnarch-tensorflow-generator.version>0.4.0-SNAPSHOT</cnnarch-tensorflow-generator.version>
<Common-MontiCar.version>0.2.12-SNAPSHOT</Common-MontiCar.version>
<embedded-montiarc-math-generator.version>0.4.0-SNAPSHOT</embedded-montiarc-math-generator.version>
<embedded-montiarc-math-generator.version>0.4.1</embedded-montiarc-math-generator.version>
<!-- .. Libraries .................................................. -->
<guava.version>25.1-jre</guava.version>
......
......@@ -47,7 +47,6 @@ import freemarker.template.TemplateException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import javax.xml.bind.DatatypeConverter;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
......@@ -230,12 +229,20 @@ public class EMADLGenerator implements EMAMGenerator {
md5.update(Files.readAllBytes(wiki_path));
byte[] digest = md5.digest();
return DatatypeConverter.printHexBinary(digest).toUpperCase();
return hex(digest);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return "No_Such_Algorithm_Exception";
}
}
public static String hex(byte[] bytes) {
StringBuilder result = new StringBuilder();
for (byte aByte : bytes) {
result.append(String.format("%02X", aByte));
}
return result.toString();
}
public String getChecksumForLargerFile(String filePath) throws IOException {
try {
......@@ -250,6 +257,9 @@ public class EMADLGenerator implements EMAMGenerator {
Set<EMAComponentInstanceSymbol> allInstances = new HashSet<>();
List<FileContent> fileContents = generateStrings(taggingResolver, EMAComponentSymbol, allInstances, forced);
List<File> generatedFiles = new ArrayList<>();
System.out.println("Generating Adapters");
emamGen.generateAdapters(fileContents, EMAComponentSymbol);
for (FileContent fileContent : fileContents) {
generatedFiles.add(emamGen.generateFile(fileContent));
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.emadl.generator;
import de.monticore.lang.monticar.generator.cpp.GeneratorCPP;
import de.se_rwth.commons.logging.Log;
import freemarker.template.TemplateException;
import org.apache.commons.cli.*;
import org.apache.commons.lang3.SystemUtils;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
......@@ -68,7 +68,7 @@ public class EMADLGeneratorCli {
public static Options getOptions() {
Options options = new Options();
addBaseOptions(options);
addEMADL2CPPOptions(options);
addEMAM2CPPOptions(options);
addEMADL2CPPOptions(options);
return options;
}
......@@ -145,23 +145,29 @@ public class EMADLGeneratorCli {
// EMAM2CPP options
GeneratorCPP emamGen = generator.getEmamGen();
Path modelsDirPath = Paths.get(cliArgs.getOptionValue(OPTION_MODELS_PATH.getOpt()));
generator.getEmamGen().setUseAlgebraicOptimizations(false);
generator.getEmamGen().setUseThreadingOptimization(false);
generator.getEmamGen().setModelsDirPath(modelsDirPath);
// generator.getEmamGen().setGenerationTargetPath(outputPath); // done by EMADLGenerator
generator.getEmamGen().setGenerateTests(cliArgs.hasOption(OPTION_FLAG_TESTS.getOpt()));
emamGen.setUseAlgebraicOptimizations(false);
emamGen.setUseThreadingOptimization(false);
emamGen.setModelsDirPath(modelsDirPath);
// emamGen.setGenerationTargetPath(outputPath); // done by EMADLGenerator
emamGen.setGenerateTests(cliArgs.hasOption(OPTION_FLAG_TESTS.getOpt()));
emamGen.setImportArmadillo(cliArgs.hasOption(OPTION_IMPORT_ARMADILLO.getLongOpt()));
emamGen.setGenerateDynamicInterface(cliArgs.hasOption(OPTION_FLAG_DYNAMIC_INTERFACE.getLongOpt()));
emamGen.setGenerateServerAdapter(cliArgs.hasOption(OPTION_FLAG_GEN_TCP_SERVER.getLongOpt()));
emamGen.setGenerateDDCAdapter(cliArgs.hasOption(OPTION_FLAG_GEN_DDC_ADAPTER.getLongOpt()));
emamGen.setOutputName(cliArgs.getOptionValue(OPTION_OUTPUT_NAME.getOpt()));
if (cliArgs.hasOption(OPTION_FLAG_ARMADILLO.getOpt())) {
generator.getEmamGen().useArmadilloBackend();
emamGen.useArmadilloBackend();
}
generator.getEmamGen().setCheckModelDir(cliArgs.hasOption(OPTION_FLAG_CHECK_MODEL_DIR.getLongOpt()));
generator.getEmamGen().setGenerateServerWrapper(cliArgs.hasOption(OPTION_FLAG_SERVER_WRAPPER.getLongOpt()));
generator.getEmamGen().setGenerateAutopilotAdapter(cliArgs.hasOption(OPTION_FLAG_AUTOPILOT_ADAPTER.getLongOpt()));
generator.getEmamGen().setUseAlgebraicOptimizations(cliArgs.hasOption(OPTION_FLAG_ALGEBRAIC.getLongOpt()));
generator.getEmamGen().setUseThreadingOptimization(cliArgs.hasOption(OPTION_FLAG_THREADING.getLongOpt()));
generator.getEmamGen().setExecutionLoggingActive(cliArgs.hasOption(OPTION_FLAG_EXEC_LOGGING.getLongOpt()));
generator.getEmamGen().setGenerateCMake(cliArgs.hasOption(OPTION_FLAG_CMAKE.getLongOpt()));
emamGen.setCheckModelDir(cliArgs.hasOption(OPTION_FLAG_CHECK_MODEL_DIR.getLongOpt()));
emamGen.setGenerateServerWrapper(cliArgs.hasOption(OPTION_FLAG_SERVER_WRAPPER.getLongOpt()));
emamGen.setUseAlgebraicOptimizations(cliArgs.hasOption(OPTION_FLAG_ALGEBRAIC.getLongOpt()));
emamGen.setUseThreadingOptimization(cliArgs.hasOption(OPTION_FLAG_THREADING.getLongOpt()));
emamGen.setExecutionLoggingActive(cliArgs.hasOption(OPTION_FLAG_EXEC_LOGGING.getLongOpt()));
emamGen.setGenerateCMake(cliArgs.hasOption(OPTION_FLAG_CMAKE.getLongOpt()));
// end EMAM2CPP options
......
......@@ -219,7 +219,7 @@ public class GenerationTest extends AbstractSymtabTest {
"cartpole_master.h",
"cartpole_master_dqn.h",
"cartpole_master_policy.h",
"CMakeLists.txt",
//"CMakeLists.txt",
"CNNModelLoader.h",
"CNNCreator_cartpole_master_dqn.py",
"CNNNet_cartpole_master_dqn.py",
......@@ -264,7 +264,7 @@ public class GenerationTest extends AbstractSymtabTest {
"mountaincar_master.cpp",
"mountaincar_master.h",
"mountaincar_master_actor.h",
"CMakeLists.txt",
//"CMakeLists.txt",
"CNNModelLoader.h",
"CNNCreator_mountaincar_master_actor.py",
"CNNNet_mountaincar_master_actor.py",
......
......@@ -25,7 +25,7 @@ public class IntegrationPythonWrapperTest extends AbstractSymtabTest {
Paths.get("./target/generated-sources-emadl"),
Paths.get("./src/test/resources/target_code/gluon/reinforcementModel/torcs"),
Arrays.asList(
"CMakeLists.txt",
//"CMakeLists.txt",
"CNNModelLoader.h",
"torcs_agent_torcsAgent.cpp",
"torcs_agent_torcsAgent.h",
......@@ -38,11 +38,11 @@ public class IntegrationPythonWrapperTest extends AbstractSymtabTest {
"CNNTranslator.h",
"HelperA.h",
"start_training.sh",
"reward/CMakeLists.txt",
//"reward/CMakeLists.txt",
"reward/HelperA.h",
"reward/torcs_agent_dqn_reward.cpp",
"reward/torcs_agent_dqn_reward.h",
"reward/pylib/CMakeLists.txt",
//"reward/pylib/CMakeLists.txt",
"reward/pylib/torcs_agent_dqn_reward_executor.cpp",
"reward/pylib/torcs_agent_dqn_reward_executor.h",
"reward/pylib/torcs_agent_dqn_reward_executor.i",
......@@ -79,7 +79,7 @@ public class IntegrationPythonWrapperTest extends AbstractSymtabTest {
Paths.get("./target/generated-sources-emadl"),
Paths.get("./src/test/resources/target_code/gluon/reinforcementModel/torcs_td3"),
Arrays.asList(
"CMakeLists.txt",
//"CMakeLists.txt",
"CNNModelLoader.h",
"torcs_agent_torcsAgent.cpp",
"torcs_agent_torcsAgent.h",
......@@ -89,10 +89,10 @@ public class IntegrationPythonWrapperTest extends AbstractSymtabTest {
"CNNPredictor_torcs_agent_torcsAgent_actor.h",
"CNNTrainer_torcs_agent_torcsAgent_actor.py",
"start_training.sh",
"reward/CMakeLists.txt",
//"reward/CMakeLists.txt",
"reward/torcs_agent_network_reward.cpp",
"reward/torcs_agent_network_reward.h",
"reward/pylib/CMakeLists.txt",
//"reward/pylib/CMakeLists.txt",
"reward/pylib/torcs_agent_network_reward_executor.cpp",
"reward/pylib/torcs_agent_network_reward_executor.h",
"reward/pylib/torcs_agent_network_reward_executor.i",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment