Commit b820d0b8 authored by Jean Meurice's avatar Jean Meurice
Browse files

ServerAdapter/DDCAdapter/DynamicInterface flags

parent 0a9c6fbd
......@@ -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 de.se_rwth.commons.Splitters;
import de.se_rwth.commons.logging.Log;
import freemarker.template.TemplateException;
import javax.xml.bind.DatatypeConverter;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
......@@ -131,8 +130,8 @@ public class EMADLGenerator implements EMAMGenerator {
}
private EMAComponentInstanceSymbol resolveComponentInstanceSymbol(String qualifiedName, TaggingResolver symtab) {
EMAComponentSymbol component = symtab.<EMAComponentSymbol>resolve(qualifiedName, EMAComponentSymbol.KIND).orElse(null);
//EMAComponentSymbol component = symtab.<EMAComponentSymbol>resolve(qualifiedName, EMAComponentSymbol.KIND).orElse(null);
EMAComponentInstanceSymbol component = symtab.<EMAComponentInstanceSymbol>resolve(qualifiedName, EMAComponentInstanceSymbol.KIND).orElse(null);
List<String> splitName = Splitters.DOT.splitToList(qualifiedName);
String componentName = splitName.get(splitName.size() - 1);
String instanceName = componentName.substring(0, 1).toLowerCase() + componentName.substring(1);
......@@ -198,12 +197,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 {
......
/* (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.*;
......@@ -61,6 +62,40 @@ public class EMADLGeneratorCli {
.build();
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();
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_OUTPUT_NAME = Option.builder("n")
.longOpt("output-name")
.desc("Name for the dynamic-interface or server adapter.")
.hasArg(true)
.required(false)
.build();
private EMADLGeneratorCli() {
}
......@@ -82,6 +117,11 @@ public class EMADLGeneratorCli {
options.addOption(OPTION_RESTRAINED_TRAINING);
options.addOption(OPTION_TRAINING_PYTHON_PATH);
options.addOption(OPTION_COMPILE);
options.addOption(OPTION_IMPORT_ARMADILLO);
options.addOption(OPTION_FLAG_GEN_TCP_SERVER);
options.addOption(OPTION_FLAG_GEN_DDC_ADAPTER);
options.addOption(OPTION_FLAG_DYNAMIC_INTERFACE);
options.addOption(OPTION_OUTPUT_NAME);
return options;
}
......@@ -144,6 +184,15 @@ public class EMADLGeneratorCli {
if (outputPath != null){
generator.setGenerationTargetPath(outputPath);
}
GeneratorCPP emamGen = generator.getEmamGen();
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()));
emamGen.useArmadilloBackend();
try{
generator.generate(cliArgs.getOptionValue(OPTION_MODELS_PATH.getOpt()), rootModelName, pythonPath, forced, compile.equals("y"));
}
......
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