Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.gnuplot')
-rw-r--r--plugins/org.eclipse.etrice.generator.gnuplot/.classpath8
-rw-r--r--plugins/org.eclipse.etrice.generator.gnuplot/.gitignore2
-rw-r--r--plugins/org.eclipse.etrice.generator.gnuplot/.project34
-rw-r--r--plugins/org.eclipse.etrice.generator.gnuplot/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--plugins/org.eclipse.etrice.generator.gnuplot/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/org.eclipse.etrice.generator.gnuplot/META-INF/MANIFEST.MF22
-rw-r--r--plugins/org.eclipse.etrice.generator.gnuplot/build.properties5
-rw-r--r--plugins/org.eclipse.etrice.generator.gnuplot/src/org/eclipse/etrice/generator/gnuplot/GnuplotScriptGenerator.xtend170
-rw-r--r--plugins/org.eclipse.etrice.generator.gnuplot/xtend-gen/org/eclipse/etrice/generator/gnuplot/GnuplotScriptGenerator.java407
9 files changed, 657 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.generator.gnuplot/.classpath b/plugins/org.eclipse.etrice.generator.gnuplot/.classpath
new file mode 100644
index 000000000..5cef82c24
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.gnuplot/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="xtend-gen"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.etrice.generator.gnuplot/.gitignore b/plugins/org.eclipse.etrice.generator.gnuplot/.gitignore
new file mode 100644
index 000000000..65847a73f
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.gnuplot/.gitignore
@@ -0,0 +1,2 @@
+bin
+*._trace
diff --git a/plugins/org.eclipse.etrice.generator.gnuplot/.project b/plugins/org.eclipse.etrice.generator.gnuplot/.project
new file mode 100644
index 000000000..69d0f9b43
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.gnuplot/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.generator.gnuplot</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.etrice.generator.gnuplot/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.etrice.generator.gnuplot/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..7a7ab3463
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.gnuplot/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/org/eclipse/etrice/generator/gnuplot/GnuplotScriptGenerator.xtend=UTF-8
diff --git a/plugins/org.eclipse.etrice.generator.gnuplot/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.etrice.generator.gnuplot/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..c537b6306
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.gnuplot/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.etrice.generator.gnuplot/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.gnuplot/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..c6b605017
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.gnuplot/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Gnuplot generator
+Bundle-SymbolicName: org.eclipse.etrice.generator.gnuplot
+Bundle-Version: 1.0.0.qualifier
+Export-Package: org.eclipse.etrice.generator.gnuplot
+Require-Bundle: org.eclipse.xtext;bundle-version="2.6.0",
+ org.eclipse.xtend.lib;bundle-version="2.6.0",
+ org.eclipse.etrice.generator;bundle-version="0.5.0",
+ org.eclipse.etrice.generator.fsm;bundle-version="0.5.0",
+ org.eclipse.etrice.core.room;bundle-version="0.5.0",
+ org.eclipse.etrice.core.genmodel;bundle-version="0.5.0",
+ org.eclipse.etrice.core.etphys;bundle-version="0.5.0",
+ org.eclipse.etrice.generator.config;bundle-version="0.5.0",
+ org.eclipse.etrice.generator.java;bundle-version="0.5.0",
+ org.eclipse.etrice.core.config;bundle-version="0.5.0",
+ org.eclipse.etrice.core.etmap;bundle-version="0.5.0",
+ org.eclipse.core.runtime;bundle-version="3.10.0",
+ org.eclipse.etrice.generator.doc;bundle-version="0.5.0",
+ org.eclipse.etrice.abstractexec.behavior;bundle-version="0.5.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.etrice.generator.gnuplot/build.properties b/plugins/org.eclipse.etrice.generator.gnuplot/build.properties
new file mode 100644
index 000000000..c3d5e96b2
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.gnuplot/build.properties
@@ -0,0 +1,5 @@
+source.. = src/,\
+ xtend-gen/
+bin.includes = META-INF/,\
+ .
+
diff --git a/plugins/org.eclipse.etrice.generator.gnuplot/src/org/eclipse/etrice/generator/gnuplot/GnuplotScriptGenerator.xtend b/plugins/org.eclipse.etrice.generator.gnuplot/src/org/eclipse/etrice/generator/gnuplot/GnuplotScriptGenerator.xtend
new file mode 100644
index 000000000..d6cfafe09
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.gnuplot/src/org/eclipse/etrice/generator/gnuplot/GnuplotScriptGenerator.xtend
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Eyrak Pean (initial contribution)
+ * Juergen Haug
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.gnuplot
+
+import com.google.inject.Inject
+import org.eclipse.etrice.core.common.base.Annotation
+import org.eclipse.etrice.core.common.base.IntLiteral
+import org.eclipse.etrice.core.common.base.KeyValue
+import org.eclipse.etrice.core.common.base.RealLiteral
+import org.eclipse.etrice.core.common.base.StringLiteral
+import org.eclipse.etrice.core.genmodel.etricegen.Root
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance
+import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo
+import org.eclipse.etrice.generator.generic.RoomExtensions
+
+class GnuplotScriptGenerator {
+ @Inject
+ IGeneratorFileIo fileIo
+
+ @Inject
+ extension RoomExtensions roomExtensions
+
+ def doGenerate(Root root) {
+ if (root.subSystemInstances.empty)
+ return;
+
+ // TODO: warning more than one ssi
+ val ssi = root.subSystemInstances.head
+ val path = ssi.subSystemClass.getGenerationTargetPath
+ val infoPath = ssi.subSystemClass.generationInfoPath
+ try {
+ fileIo.generateFile("Generating gnuplot script for subsystem " + ssi.name, path, infoPath,
+ "/gnuplot/log_main.data.csv-Script.plt", ssi.generatePlotScript)
+ fileIo.generateFile("Generating gnuplot launch configuration", path, infoPath,
+ "/gnuplot/create_gnuplot.launch", gnuPlotLaunchFile)
+ } catch (Exception e) {
+ //e.printStackTrace
+ }
+
+ }
+
+ def protected gnuPlotLaunchFile() '''
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
+ <launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${none}"/>
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${system_path:gnuplot}"/>
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="${project_loc}/src-gen/gnuplot/log_main.data.csv-Script.plt"/>
+ <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${project_loc}"/>
+ </launchConfiguration>
+
+ '''
+
+ def protected getAttribute(Annotation anno, String name) {
+ anno.attributes.findFirst[attr|attr.key == name]
+ }
+
+ def protected asString(KeyValue kv) {
+ if (kv.value instanceof StringLiteral)
+ (kv.value as StringLiteral).value
+ else
+ null
+ }
+
+ def protected asReal(KeyValue kv) {
+ if (kv.value instanceof RealLiteral)
+ (kv.value as RealLiteral).value
+ else if (kv.value instanceof IntLiteral)
+ (kv.value as IntLiteral).value as double
+ else
+ null
+ }
+
+ def protected asInteger(KeyValue kv) {
+ if (kv.value instanceof IntLiteral)
+ (kv.value as IntLiteral).value
+ else
+ null
+ }
+
+ def protected generatePlotScript(SubSystemInstance ssi) {
+
+ // TODO: warn if more than one GnuPlot annotation
+ val plotAnnotation = ssi.subSystemClass.annotations.filter [ a |
+ a.type.name == "Gnuplot"
+ ].head
+
+ val defaultFontsize = 10
+
+ // TODO: error checking
+ val format = plotAnnotation?.getAttribute("format")?.asString
+ val outputfile = plotAnnotation?.getAttribute("outputfile")?.asString
+ val width = plotAnnotation?.getAttribute("width")?.asInteger
+ val height = plotAnnotation?.getAttribute("height")?.asInteger
+ val fontsize = plotAnnotation?.getAttribute("fontsize")?.asInteger ?: defaultFontsize
+
+ val graphAnnotations = ssi.subSystemClass.annotations.filter [ a |
+ a.type.name == "GnuplotGraph"
+ ].toList
+
+ '''
+ #!/gnuplot
+
+ # Color Brewer set1 5-set
+ set linetype 1 lc rgb '#e41a1c' lw 1
+ set linetype 2 lc rgb '#377eb8' lw 1
+ set linetype 3 lc rgb '#4daf4a' lw 1
+ set linetype 4 lc rgb '#984ea3' lw 1
+ set linetype 5 lc rgb '#ff7f00' lw 1
+ set linetype cycle 5
+
+ cd 'log'
+ set datafile separator comma
+ set terminal «format» size «width»,«height» font ",«fontsize»" background "white"
+ set output '«outputfile»'
+ set size 1,1
+ set multiplot layout «graphAnnotations.size»,1
+ set grid
+ show grid
+ set format y "% 5.3f"
+ «var i = 0»
+ «FOR a : graphAnnotations»
+
+ «ssi.generateGraph(a, i++, graphAnnotations.size)»
+ «ENDFOR»
+
+ unset multiplot
+ unset output
+
+ '''
+ }
+
+ def protected generateGraph(SubSystemInstance ssi, Annotation graph, int index, int total) {
+
+ // TODO: handle multiple paths in the same graph
+ val paths = graph.getAttribute("paths")?.asString
+
+ // TODO: take interval from physical thread associated with actor instance instead of annotation attribute
+ val interval = graph.getAttribute("interval")?.asInteger ?: 20
+ val xtics = graph.getAttribute("xtics")?.asReal ?: 100
+ val mxtics = graph.getAttribute("mxtics")?.asInteger ?: 4
+ val ymin = graph.getAttribute("ymin")?.asReal
+ val ymax = graph.getAttribute("ymax")?.asReal
+
+ val vertOrigin = ((total - (index + 1)) as double) / total
+ val vertSize = 1.0F / total
+
+ '''
+ set yrange [«ymin ?: "*"» : «ymax ?: "*"»]
+ set xtics rotate «xtics»
+ set mxtics «mxtics»
+ set ylabel
+ set xlabel "time (ms)"
+ timeInMs(x) = «interval» * x
+ set origin 0,«vertOrigin»
+ set size 1,«vertSize»
+ plot 'main.data.csv' using (timeInMs(column(1))):(column("«paths»")) with lines
+ '''
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.gnuplot/xtend-gen/org/eclipse/etrice/generator/gnuplot/GnuplotScriptGenerator.java b/plugins/org.eclipse.etrice.generator.gnuplot/xtend-gen/org/eclipse/etrice/generator/gnuplot/GnuplotScriptGenerator.java
new file mode 100644
index 000000000..c0e4cf035
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.gnuplot/xtend-gen/org/eclipse/etrice/generator/gnuplot/GnuplotScriptGenerator.java
@@ -0,0 +1,407 @@
+/**
+ * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Eyrak Pean (initial contribution)
+ * Juergen Haug
+ */
+package org.eclipse.etrice.generator.gnuplot;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.common.base.Annotation;
+import org.eclipse.etrice.core.common.base.AnnotationType;
+import org.eclipse.etrice.core.common.base.IntLiteral;
+import org.eclipse.etrice.core.common.base.KeyValue;
+import org.eclipse.etrice.core.common.base.Literal;
+import org.eclipse.etrice.core.common.base.RealLiteral;
+import org.eclipse.etrice.core.common.base.StringLiteral;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.xbase.lib.Exceptions;
+import org.eclipse.xtext.xbase.lib.Extension;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@SuppressWarnings("all")
+public class GnuplotScriptGenerator {
+ @Inject
+ private IGeneratorFileIo fileIo;
+
+ @Inject
+ @Extension
+ private RoomExtensions roomExtensions;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ boolean _isEmpty = _subSystemInstances.isEmpty();
+ if (_isEmpty) {
+ return;
+ }
+ EList<SubSystemInstance> _subSystemInstances_1 = root.getSubSystemInstances();
+ final SubSystemInstance ssi = IterableExtensions.<SubSystemInstance>head(_subSystemInstances_1);
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ final String path = this.roomExtensions.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ final String infoPath = this.roomExtensions.getGenerationInfoPath(_subSystemClass_1);
+ try {
+ String _name = ssi.getName();
+ String _plus = ("Generating gnuplot script for subsystem " + _name);
+ CharSequence _generatePlotScript = this.generatePlotScript(ssi);
+ this.fileIo.generateFile(_plus, path, infoPath,
+ "/gnuplot/log_main.data.csv-Script.plt", _generatePlotScript);
+ CharSequence _gnuPlotLaunchFile = this.gnuPlotLaunchFile();
+ this.fileIo.generateFile("Generating gnuplot launch configuration", path, infoPath,
+ "/gnuplot/create_gnuplot.launch", _gnuPlotLaunchFile);
+ } catch (final Throwable _t) {
+ if (_t instanceof Exception) {
+ final Exception e = (Exception)_t;
+ } else {
+ throw Exceptions.sneakyThrow(_t);
+ }
+ }
+ }
+
+ protected CharSequence gnuPlotLaunchFile() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
+ _builder.newLine();
+ _builder.append("<launchConfiguration type=\"org.eclipse.ui.externaltools.ProgramLaunchConfigurationType\">");
+ _builder.newLine();
+ _builder.append("<stringAttribute key=\"org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE\" value=\"${none}\"/>");
+ _builder.newLine();
+ _builder.append("<stringAttribute key=\"org.eclipse.ui.externaltools.ATTR_LOCATION\" value=\"${system_path:gnuplot}\"/>");
+ _builder.newLine();
+ _builder.append("<stringAttribute key=\"org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS\" value=\"${project_loc}/src-gen/gnuplot/log_main.data.csv-Script.plt\"/>");
+ _builder.newLine();
+ _builder.append("<stringAttribute key=\"org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY\" value=\"${project_loc}\"/>");
+ _builder.newLine();
+ _builder.append("</launchConfiguration>");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+
+ protected KeyValue getAttribute(final Annotation anno, final String name) {
+ EList<KeyValue> _attributes = anno.getAttributes();
+ final Function1<KeyValue, Boolean> _function = new Function1<KeyValue, Boolean>() {
+ public Boolean apply(final KeyValue attr) {
+ String _key = attr.getKey();
+ return Boolean.valueOf(Objects.equal(_key, name));
+ }
+ };
+ return IterableExtensions.<KeyValue>findFirst(_attributes, _function);
+ }
+
+ protected String asString(final KeyValue kv) {
+ String _xifexpression = null;
+ Literal _value = kv.getValue();
+ if ((_value instanceof StringLiteral)) {
+ Literal _value_1 = kv.getValue();
+ _xifexpression = ((StringLiteral) _value_1).getValue();
+ } else {
+ _xifexpression = null;
+ }
+ return _xifexpression;
+ }
+
+ protected Double asReal(final KeyValue kv) {
+ Double _xifexpression = null;
+ Literal _value = kv.getValue();
+ if ((_value instanceof RealLiteral)) {
+ Literal _value_1 = kv.getValue();
+ _xifexpression = Double.valueOf(((RealLiteral) _value_1).getValue());
+ } else {
+ Double _xifexpression_1 = null;
+ Literal _value_2 = kv.getValue();
+ if ((_value_2 instanceof IntLiteral)) {
+ Literal _value_3 = kv.getValue();
+ long _value_4 = ((IntLiteral) _value_3).getValue();
+ _xifexpression_1 = Double.valueOf(((double) _value_4));
+ } else {
+ _xifexpression_1 = null;
+ }
+ _xifexpression = _xifexpression_1;
+ }
+ return _xifexpression;
+ }
+
+ protected Long asInteger(final KeyValue kv) {
+ Long _xifexpression = null;
+ Literal _value = kv.getValue();
+ if ((_value instanceof IntLiteral)) {
+ Literal _value_1 = kv.getValue();
+ _xifexpression = Long.valueOf(((IntLiteral) _value_1).getValue());
+ } else {
+ _xifexpression = null;
+ }
+ return _xifexpression;
+ }
+
+ protected CharSequence generatePlotScript(final SubSystemInstance ssi) {
+ CharSequence _xblockexpression = null;
+ {
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ EList<Annotation> _annotations = _subSystemClass.getAnnotations();
+ final Function1<Annotation, Boolean> _function = new Function1<Annotation, Boolean>() {
+ public Boolean apply(final Annotation a) {
+ AnnotationType _type = a.getType();
+ String _name = _type.getName();
+ return Boolean.valueOf(Objects.equal(_name, "Gnuplot"));
+ }
+ };
+ Iterable<Annotation> _filter = IterableExtensions.<Annotation>filter(_annotations, _function);
+ final Annotation plotAnnotation = IterableExtensions.<Annotation>head(_filter);
+ final int defaultFontsize = 10;
+ KeyValue _attribute = null;
+ if (plotAnnotation!=null) {
+ _attribute=this.getAttribute(plotAnnotation, "format");
+ }
+ String _asString = null;
+ if (_attribute!=null) {
+ _asString=this.asString(_attribute);
+ }
+ final String format = _asString;
+ KeyValue _attribute_1 = null;
+ if (plotAnnotation!=null) {
+ _attribute_1=this.getAttribute(plotAnnotation, "outputfile");
+ }
+ String _asString_1 = null;
+ if (_attribute_1!=null) {
+ _asString_1=this.asString(_attribute_1);
+ }
+ final String outputfile = _asString_1;
+ KeyValue _attribute_2 = null;
+ if (plotAnnotation!=null) {
+ _attribute_2=this.getAttribute(plotAnnotation, "width");
+ }
+ Long _asInteger = null;
+ if (_attribute_2!=null) {
+ _asInteger=this.asInteger(_attribute_2);
+ }
+ final Long width = _asInteger;
+ KeyValue _attribute_3 = null;
+ if (plotAnnotation!=null) {
+ _attribute_3=this.getAttribute(plotAnnotation, "height");
+ }
+ Long _asInteger_1 = null;
+ if (_attribute_3!=null) {
+ _asInteger_1=this.asInteger(_attribute_3);
+ }
+ final Long height = _asInteger_1;
+ Number _elvis = null;
+ KeyValue _attribute_4 = null;
+ if (plotAnnotation!=null) {
+ _attribute_4=this.getAttribute(plotAnnotation, "fontsize");
+ }
+ Long _asInteger_2 = null;
+ if (_attribute_4!=null) {
+ _asInteger_2=this.asInteger(_attribute_4);
+ }
+ if (_asInteger_2 != null) {
+ _elvis = _asInteger_2;
+ } else {
+ _elvis = Integer.valueOf(defaultFontsize);
+ }
+ final Number fontsize = ((Number)_elvis);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ EList<Annotation> _annotations_1 = _subSystemClass_1.getAnnotations();
+ final Function1<Annotation, Boolean> _function_1 = new Function1<Annotation, Boolean>() {
+ public Boolean apply(final Annotation a) {
+ AnnotationType _type = a.getType();
+ String _name = _type.getName();
+ return Boolean.valueOf(Objects.equal(_name, "GnuplotGraph"));
+ }
+ };
+ Iterable<Annotation> _filter_1 = IterableExtensions.<Annotation>filter(_annotations_1, _function_1);
+ final List<Annotation> graphAnnotations = IterableExtensions.<Annotation>toList(_filter_1);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("#!/gnuplot");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("# Color Brewer set1 5-set");
+ _builder.newLine();
+ _builder.append("set linetype 1 lc rgb \'#e41a1c\' lw 1");
+ _builder.newLine();
+ _builder.append("set linetype 2 lc rgb \'#377eb8\' lw 1");
+ _builder.newLine();
+ _builder.append("set linetype 3 lc rgb \'#4daf4a\' lw 1");
+ _builder.newLine();
+ _builder.append("set linetype 4 lc rgb \'#984ea3\' lw 1");
+ _builder.newLine();
+ _builder.append("set linetype 5 lc rgb \'#ff7f00\' lw 1");
+ _builder.newLine();
+ _builder.append("set linetype cycle 5");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("cd \'log\'");
+ _builder.newLine();
+ _builder.append("set datafile separator comma");
+ _builder.newLine();
+ _builder.append("set terminal ");
+ _builder.append(format, "");
+ _builder.append(" size ");
+ _builder.append(width, "");
+ _builder.append(",");
+ _builder.append(height, "");
+ _builder.append(" font \",");
+ _builder.append(((Number)fontsize), "");
+ _builder.append("\" background \"white\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("set output \'");
+ _builder.append(outputfile, "");
+ _builder.append("\'");
+ _builder.newLineIfNotEmpty();
+ _builder.append("set size 1,1");
+ _builder.newLine();
+ _builder.append("set multiplot layout ");
+ int _size = graphAnnotations.size();
+ _builder.append(_size, "");
+ _builder.append(",1");
+ _builder.newLineIfNotEmpty();
+ _builder.append("set grid");
+ _builder.newLine();
+ _builder.append("show grid");
+ _builder.newLine();
+ _builder.append("set format y \"% 5.3f\"");
+ _builder.newLine();
+ int i = 0;
+ _builder.newLineIfNotEmpty();
+ {
+ for(final Annotation a : graphAnnotations) {
+ _builder.newLine();
+ int _plusPlus = i++;
+ int _size_1 = graphAnnotations.size();
+ CharSequence _generateGraph = this.generateGraph(ssi, a, _plusPlus, _size_1);
+ _builder.append(_generateGraph, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("unset multiplot");
+ _builder.newLine();
+ _builder.append("unset output");
+ _builder.newLine();
+ _builder.newLine();
+ _xblockexpression = _builder;
+ }
+ return _xblockexpression;
+ }
+
+ protected CharSequence generateGraph(final SubSystemInstance ssi, final Annotation graph, final int index, final int total) {
+ CharSequence _xblockexpression = null;
+ {
+ KeyValue _attribute = this.getAttribute(graph, "paths");
+ String _asString = null;
+ if (_attribute!=null) {
+ _asString=this.asString(_attribute);
+ }
+ final String paths = _asString;
+ Number _elvis = null;
+ KeyValue _attribute_1 = this.getAttribute(graph, "interval");
+ Long _asInteger = null;
+ if (_attribute_1!=null) {
+ _asInteger=this.asInteger(_attribute_1);
+ }
+ if (_asInteger != null) {
+ _elvis = _asInteger;
+ } else {
+ _elvis = Integer.valueOf(20);
+ }
+ final Number interval = ((Number)_elvis);
+ Number _elvis_1 = null;
+ KeyValue _attribute_2 = this.getAttribute(graph, "xtics");
+ Double _asReal = null;
+ if (_attribute_2!=null) {
+ _asReal=this.asReal(_attribute_2);
+ }
+ if (_asReal != null) {
+ _elvis_1 = _asReal;
+ } else {
+ _elvis_1 = Integer.valueOf(100);
+ }
+ final Number xtics = ((Number)_elvis_1);
+ Number _elvis_2 = null;
+ KeyValue _attribute_3 = this.getAttribute(graph, "mxtics");
+ Long _asInteger_1 = null;
+ if (_attribute_3!=null) {
+ _asInteger_1=this.asInteger(_attribute_3);
+ }
+ if (_asInteger_1 != null) {
+ _elvis_2 = _asInteger_1;
+ } else {
+ _elvis_2 = Integer.valueOf(4);
+ }
+ final Number mxtics = ((Number)_elvis_2);
+ KeyValue _attribute_4 = this.getAttribute(graph, "ymin");
+ Double _asReal_1 = null;
+ if (_attribute_4!=null) {
+ _asReal_1=this.asReal(_attribute_4);
+ }
+ final Double ymin = _asReal_1;
+ KeyValue _attribute_5 = this.getAttribute(graph, "ymax");
+ Double _asReal_2 = null;
+ if (_attribute_5!=null) {
+ _asReal_2=this.asReal(_attribute_5);
+ }
+ final Double ymax = _asReal_2;
+ final double vertOrigin = (((double) (total - (index + 1))) / total);
+ final float vertSize = (1.0F / total);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("set yrange [");
+ Object _elvis_3 = null;
+ if (ymin != null) {
+ _elvis_3 = ymin;
+ } else {
+ _elvis_3 = "*";
+ }
+ _builder.append(((Object)_elvis_3), "");
+ _builder.append(" : ");
+ Object _elvis_4 = null;
+ if (ymax != null) {
+ _elvis_4 = ymax;
+ } else {
+ _elvis_4 = "*";
+ }
+ _builder.append(((Object)_elvis_4), "");
+ _builder.append("]");
+ _builder.newLineIfNotEmpty();
+ _builder.append("set xtics rotate ");
+ _builder.append(((Number)xtics), "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("set mxtics ");
+ _builder.append(((Number)mxtics), "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("set ylabel");
+ _builder.newLine();
+ _builder.append("set xlabel \"time (ms)\"");
+ _builder.newLine();
+ _builder.append("timeInMs(x) = ");
+ _builder.append(((Number)interval), "");
+ _builder.append(" * x");
+ _builder.newLineIfNotEmpty();
+ _builder.append("set origin 0,");
+ _builder.append(vertOrigin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("set size 1,");
+ _builder.append(vertSize, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("plot \'main.data.csv\' using (timeInMs(column(1))):(column(\"");
+ _builder.append(paths, "");
+ _builder.append("\")) with lines");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = _builder;
+ }
+ return _xblockexpression;
+ }
+}

Back to the top