Commit 6aacf769 authored by Nicola Gatto's avatar Nicola Gatto

Add update rate parameterin JSON and middleware

UpdateRate defines the time between two ticks
parent fa69f9dc
Pipeline #149538 failed with stages
in 40 seconds
......@@ -9,7 +9,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-middleware-generator</artifactId>
<version>0.0.23-SNAPSHOT</version>
<version>0.0.23-SNAPSHOT-NG</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......@@ -22,7 +22,7 @@
<embedded-montiarc.version>0.1.9-SNAPSHOT</embedded-montiarc.version>
<Embedded-montiarc-math-generator.version>0.1.8-SNAPSHOT</Embedded-montiarc-math-generator.version>
<Embedded-montiarc-math-roscpp-generator.version>0.1.4-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<EMADL2CPP.version>0.3.1-SNAPSHOT</EMADL2CPP.version>
<EMADL2CPP.version>0.3.2-SNAPSHOT-NG</EMADL2CPP.version>
<EMADL.version>0.2.7-SNAPSHOT</EMADL.version>
<embedded-montiarc-component-clustering.version>0.0.2-SNAPSHOT</embedded-montiarc-component-clustering.version>
......
......@@ -25,6 +25,7 @@ public class DistributedTargetGenerator{
private ClusteringResultList clusteringResults = new ClusteringResultList();
private CMakeGenerator generatorBlueprint = new CMakeGenerator();
private String generationTargetPath;
private Integer updateRate;
public boolean isGenerateMiddlewareTags() {
return generateMiddlewareTags;
......@@ -157,6 +158,7 @@ public class DistributedTargetGenerator{
private GeneratorImpl createFullGenerator(String subdir) {
MiddlewareGenerator res = new MiddlewareGenerator();
res.setGenerationTargetPath(generationTargetPath + "src/" + (subdir.endsWith("/") ? subdir : subdir + "/"));
res.setUpdateRate(updateRate);
generatorBlueprint.getGeneratorImpls().forEach(gen -> res.add(gen, generatorBlueprint.getImplSubdir(gen)));
......@@ -205,4 +207,8 @@ public class DistributedTargetGenerator{
public void add(GeneratorImpl generator, String subdir) {
generatorBlueprint.add(generator, subdir);
}
public void setUpdateRate(int updateRate) {
this.updateRate = updateRate;
}
}
......@@ -15,6 +15,11 @@ import java.util.List;
import java.util.stream.Collectors;
public class MiddlewareGenerator extends CMakeGenerator {
private Integer updateRate = 100;
public void setUpdateRate(int updateRate) {
this.updateRate = updateRate;
}
@Override
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
......@@ -79,7 +84,8 @@ public class MiddlewareGenerator extends CMakeGenerator {
.replace("${compName}", name)
.replace("${includes}", includes)
.replace("${addAdapters}", addAdapters)
.replace("${initParams}",initParams);
.replace("${initParams}",initParams)
.replace("${updateRate}", updateRate.toString());
FileContent res = new FileContent();
......
......@@ -6,6 +6,7 @@ import java.util.Set;
public class CliParameters {
private static final boolean DEFAULT_WRITE_TAG_FILE = false;
private static final String DEFAULT_EMADL_BACKEND = "MXNET";
private static final int DEFAULT_UPDATE_RATE = 100;
private String modelsDir;
private String outputDir;
......@@ -14,11 +15,12 @@ public class CliParameters {
private String emadlBackend;
private Boolean writeTagFile;
private ClusteringParameters clusteringParameters;
private Integer updateRate;
public CliParameters() {
}
public CliParameters(String modelsDir, String outputDir, String rootModel, Set<String> generators, String emadlBackend, Boolean writeTagFile, ClusteringParameters clusteringParameters) {
public CliParameters(String modelsDir, String outputDir, String rootModel, Set<String> generators, String emadlBackend, Boolean writeTagFile, ClusteringParameters clusteringParameters, Integer updateRate) {
this.modelsDir = modelsDir;
this.outputDir = outputDir;
this.rootModel = rootModel;
......@@ -26,6 +28,7 @@ public class CliParameters {
this.emadlBackend = emadlBackend;
this.writeTagFile = writeTagFile;
this.clusteringParameters = clusteringParameters;
this.updateRate = updateRate;
}
public String getModelsDir() {
......@@ -56,4 +59,8 @@ public class CliParameters {
return Optional.ofNullable(clusteringParameters);
}
public int getUpdateRate() {
return updateRate == null ? DEFAULT_UPDATE_RATE : updateRate;
}
}
......@@ -46,7 +46,7 @@ public class CliParametersLoader {
.create();
JsonDeserializer<CliParameters> desCliParameters = new StrictJsonDeserializer<>(Arrays.asList("emadlBackend","writeTagFile","clusteringParameters","modelsDir","outputDir","rootModel","generators"), delegateGson);
JsonDeserializer<CliParameters> desCliParameters = new StrictJsonDeserializer<>(Arrays.asList("emadlBackend","writeTagFile","clusteringParameters","modelsDir","outputDir","rootModel","generators", "updateRate"), delegateGson);
JsonDeserializer<ClusteringParameters> desClustering = new StrictJsonDeserializer<>(Arrays.asList("numberOfClusters","flatten","flattenLevel","chooseBy","algorithmParameters", "metric"), delegateGson);
JsonDeserializer<DynamicSpectralClusteringCliParameters> desSpectral = new StrictJsonDeserializer<>(Arrays.asList("numberOfClusters","l","sigma"), delegateGson);
......
......@@ -119,6 +119,7 @@ public final class DistributedTargetGeneratorCli {
DistributedTargetGenerator generator = new DistributedTargetGenerator();
generator.setGenerationTargetPath(cliParameters.getOutputDir());
generator.setGenerateMiddlewareTags(cliParameters.getWriteTagFile());
generator.setUpdateRate(cliParameters.getUpdateRate());
Set<String> validGenNames = getGeneratorNames();
......
......@@ -10,7 +10,7 @@ ${includes}
using namespace std;
using namespace chrono;
static int exeMs = 100;
static int exeMs = ${updateRate};
bool parseCommandLineParameters(int argc, char* argv[]){
if(argc == 1){
......
......@@ -185,5 +185,9 @@ public class ParameterLoadingTest {
Log.enableFailQuick(true);
}
@Test
public void testUpdateRateSet() throws FileNotFoundException {
CliParameters params = loadCliParameters("updateRateSet");
assertEquals(200, params.getUpdateRate());
}
}
{
"modelsDir": "src/test/resources/pacman/",
"outputDir": "target/cliTest/flattenSpectralMultiOverride/",
"rootModel": "de.rwth.pacman.heithoff2.controller",
"generators": ["cpp","roscpp"],
"updateRate": 200
}
\ No newline at end of file
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