Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.core.config')
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend102
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java98
-rw-r--r--plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java228
3 files changed, 404 insertions, 24 deletions
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend
new file mode 100644
index 000000000..4debf24c9
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend
@@ -0,0 +1,102 @@
+package org.eclipse.etrice.core.config
+
+import java.util.List
+import org.eclipse.emf.ecore.resource.ResourceSet
+import org.eclipse.etrice.core.ConfigStandaloneSetup
+import org.eclipse.etrice.core.genmodel.base.ILogger
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
+import org.eclipse.etrice.core.room.ActorClass
+import org.eclipse.etrice.core.room.Attribute
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.core.room.SubSystemClass
+import org.eclipse.etrice.generator.base.IDataConfiguration
+import java.util.ArrayList
+
+class DataConfiguration implements IDataConfiguration {
+
+
+ override doSetup() {
+ ConfigStandaloneSetup::doSetup()
+ }
+
+ override setResources(ResourceSet resource, ILogger logger) {
+ DataConfigurationHelper::setConfigModels(resource, logger)
+ }
+
+ // static
+
+ override getAttrClassConfigValue(ActorClass actor, List<Attribute> path) {
+ actor.getAttrClassConfig(path)?.value?.toStringExpr
+ }
+
+ override getAttrClassConfigMaxValue(ActorClass actor, List<Attribute> path) {
+ actor.getAttrClassConfig(path)?.min?.toStringExpr
+ }
+
+ override getAttrClassConfigMinValue(ActorClass actor, List<Attribute> path) {
+ actor.getAttrClassConfig(path)?.max?.toStringExpr
+ }
+
+ def private getAttrClassConfig(ActorClass actor, List<Attribute> path){
+ var id = '''/«actor.name»/«path.toStringPath»'''.toString
+ DataConfigurationHelper::actorClassAttrMap.get(id)
+ }
+
+ override getAttrClassConfigValue(ProtocolClass pc, boolean regular, List<Attribute> path) {
+ var id = '''/«pc.name»/«IF regular»regular«ELSE»conjugated«ENDIF»/«path.toStringPath»'''.toString
+ DataConfigurationHelper::protocolClassAttrMap.get(id)?.value?.toStringExpr
+ }
+
+ def private toStringPath(List<Attribute> path){
+ '''«FOR a : path SEPARATOR '/'»«a.name»«ENDFOR»'''.toString
+ }
+
+ override getAttrInstanceConfigValue(ActorInstance ai, List<Attribute> path) {
+ var id = ai.path+"/"+path.toStringPath
+ DataConfigurationHelper::actorInstanceAttrMap.get(id)?.value?.toStringExpr
+ }
+
+ // dynamic
+
+ override getAllDynConfigReadAttributes(ActorClass actor) {
+ return new ArrayList<Attribute>
+ }
+
+ override getAllDynConfigWriteAttributes(ActorClass actor) {
+ return new ArrayList<Attribute>
+ }
+
+ override getDynConfigReadAttributes(SubSystemClass subsystem) {
+ return new ArrayList<Attribute>
+ }
+
+ override getDynConfigWriteAttributes(SubSystemClass subsystem) {
+ return new ArrayList<Attribute>
+ }
+
+ override hasDynConfigReadAttributes(ActorClass actor) {
+ false
+ }
+
+ override hasDynConfigWriteAttributes(ActorClass actor) {
+ false
+ }
+
+ override hasVariableService(SubSystemClass subsystem) {
+ false
+ }
+
+ def private toStringExpr(LiteralArray literal){
+ '''«FOR l : literal.literals SEPARATOR ','»«l.toStringExpr»«ENDFOR»'''.toString
+ }
+
+ def private toStringExpr(Literal literal){
+ switch(literal){
+ BooleanLiteral: literal.isTrue.toString
+ IntLiteral: literal.value.toString
+ RealLiteral: literal.value.toString
+ StringLiteral: literal.value.toString
+ }
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
index 79a74fedf..bba25fd0c 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
@@ -30,24 +30,30 @@ import org.eclipse.etrice.core.config.SubSystemConfig;
import org.eclipse.etrice.core.config.util.ConfigUtil;
import org.eclipse.etrice.core.genmodel.base.ILogger;
import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SubSystemClass;
public class DataConfigurationHelper {
- public static Map<ActorClass, ActorClassConfig> ac2acConfMap = new HashMap<ActorClass, ActorClassConfig>();
- public static Map<PortClass, PortClassConfig> pc2pcConfMap = new HashMap<PortClass, PortClassConfig>();
- public static Map<String, ActorInstanceConfig> path2aiConfMap = new HashMap<String, ActorInstanceConfig>();
+ // static
+ public static Map<String, AttrClassConfig> actorClassAttrMap = new HashMap<String, AttrClassConfig>();
+ public static Map<String, AttrClassConfig> protocolClassAttrMap = new HashMap<String, AttrClassConfig>();
+ public static Map<String, AttrInstanceConfig> actorInstanceAttrMap = new HashMap<String, AttrInstanceConfig>();
+
+ // dynamic
public static Map<SubSystemClass, SubSystemConfig> ssc2ssConfMap = new HashMap<SubSystemClass, SubSystemConfig>();
public static Map<SubSystemClass, List<AttrInstanceConfig>> ssc2attrInstConfMap = new HashMap<SubSystemClass, List<AttrInstanceConfig>>();
public static Map<ActorClass, List<ActorInstanceConfig>> ac2aiConfMap = new HashMap<ActorClass, List<ActorInstanceConfig>>();
public static Map<ActorInstanceConfig, ActorClass> aiConf2acMap = new HashMap<ActorInstanceConfig, ActorClass>();
public static boolean setConfigModels(ResourceSet rs, ILogger logger) {
- ac2acConfMap.clear();
- pc2pcConfMap.clear();
- path2aiConfMap.clear();
+ actorClassAttrMap.clear();
+ protocolClassAttrMap.clear();
+ actorInstanceAttrMap.clear();
+
ssc2ssConfMap.clear();
ssc2attrInstConfMap.clear();
ac2aiConfMap.clear();
@@ -66,6 +72,7 @@ public class DataConfigurationHelper {
Set<ActorClass> actorClasses = new HashSet<ActorClass>();
Set<ProtocolClass> protocolClasses = new HashSet<ProtocolClass>();
+ Set<String> actorInstances = new HashSet<String>();
for (ConfigModel config : configs) {
for (ActorClassConfig classConfig : config.getActorClassConfigs()) {
if (actorClasses.contains(classConfig.getActor())) {
@@ -74,7 +81,7 @@ public class DataConfigurationHelper {
error = true;
} else {
actorClasses.add(classConfig.getActor());
- ac2acConfMap.put(classConfig.getActor(), classConfig);
+ collectConfigs(classConfig, actorClassAttrMap);
}
}
for (ProtocolClassConfig protocolConfig : config
@@ -87,22 +94,21 @@ public class DataConfigurationHelper {
error = true;
} else {
protocolClasses.add(protocolConfig.getProtocol());
- pc2pcConfMap.put(protocolConfig.getProtocol().getRegular(),
- protocolConfig.getRegular());
- pc2pcConfMap.put(protocolConfig.getProtocol()
- .getConjugate(), protocolConfig.getConjugated());
+ collectConfigs(protocolConfig, protocolClassAttrMap);
}
}
for (ActorInstanceConfig instanceConfig : config
.getActorInstanceConfigs()) {
String path = "/" + instanceConfig.getRoot().getName()
+ toPath(instanceConfig.getPath().getRefs(), "/");
- if (path2aiConfMap.containsKey(path)) {
+ if (actorInstances.contains(path)) {
logger.logError(
"Multiple configurations for actor instance "
+ path + " found", null);
- } else
- path2aiConfMap.put(path, instanceConfig);
+ } else {
+ actorInstances.add(path);
+ collectConfigs(instanceConfig, path, actorInstanceAttrMap);
+ }
ActorClass ac = ConfigUtil.resolve(instanceConfig.getRoot(),
instanceConfig.getPath());
@@ -128,19 +134,63 @@ public class DataConfigurationHelper {
}
// dynConfigSubsystemMap
- for (ActorInstanceConfig instanceConfig : path2aiConfMap.values()) {
- List<AttrInstanceConfig> dynConfigs = new ArrayList<AttrInstanceConfig>();
- for (AttrInstanceConfig config : instanceConfig.getAttributes())
- if (config.isDynConfig())
- dynConfigs.add(config);
- if (!dynConfigs.isEmpty())
- ssc2attrInstConfMap.get(instanceConfig.getRoot()).addAll(
- dynConfigs);
- }
+ // for (ActorInstanceConfig instanceConfig : actorInstanceMap.values())
+ // {
+ // List<AttrInstanceConfig> dynConfigs = new
+ // ArrayList<AttrInstanceConfig>();
+ // for (AttrInstanceConfig config : instanceConfig.getAttributes())
+ // if (config.isDynConfig())
+ // dynConfigs.add(config);
+ // if (!dynConfigs.isEmpty())
+ // ssc2attrInstConfMap.get(instanceConfig.getRoot()).addAll(
+ // dynConfigs);
+ // }
return !error;
}
+ private static void collectConfigs(ActorInstanceConfig actorConfig,
+ String path, Map<String, AttrInstanceConfig> map) {
+ for (AttrInstanceConfig c : actorConfig.getAttributes())
+ collectConfigs(c, path + "/" + c.getAttribute().getName(), map);
+ }
+
+ private static void collectConfigs(ProtocolClassConfig protocolConfig,
+ Map<String, AttrClassConfig> map) {
+ String path = "/" + protocolConfig.getProtocol().getName();
+ for (AttrClassConfig c : protocolConfig.getRegular().getAttributes())
+ collectConfigs(c, path + "/regular/" + c.getAttribute().getName(),
+ map);
+ for (AttrClassConfig c : protocolConfig.getConjugated().getAttributes())
+ collectConfigs(c, path + "/conjugated/"
+ + c.getAttribute().getName(), map);
+ }
+
+ private static void collectConfigs(ActorClassConfig actorConfig,
+ Map<String, AttrClassConfig> map) {
+ String path = "/" + actorConfig.getActor().getName();
+ for (AttrClassConfig c : actorConfig.getAttributes())
+ collectConfigs(c, path + "/" + c.getAttribute().getName(), map);
+ }
+
+ private static void collectConfigs(AttrClassConfig config, String path,
+ Map<String, AttrClassConfig> map) {
+ Attribute a = config.getAttribute();
+ if (a.getRefType().getType() instanceof DataClass)
+ for (AttrClassConfig c : config.getAttributes())
+ collectConfigs(c, path + "/" + c.getAttribute().getName(), map);
+ map.put(path, config);
+ }
+
+ private static void collectConfigs(AttrInstanceConfig config, String path,
+ Map<String, AttrInstanceConfig> map) {
+ Attribute a = config.getAttribute();
+ if (a.getRefType().getType() instanceof DataClass)
+ for (AttrInstanceConfig c : config.getAttributes())
+ collectConfigs(c, path + "/" + c.getAttribute().getName(), map);
+ map.put(path, config);
+ }
+
public static String toPath(Iterable<String> path, String pathDelim) {
StringBuilder b = new StringBuilder();
for (String p : path)
diff --git a/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java b/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java
new file mode 100644
index 000000000..a89ceb930
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java
@@ -0,0 +1,228 @@
+package org.eclipse.etrice.core.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.etrice.core.ConfigStandaloneSetup;
+import org.eclipse.etrice.core.config.AttrClassConfig;
+import org.eclipse.etrice.core.config.AttrInstanceConfig;
+import org.eclipse.etrice.core.config.BooleanLiteral;
+import org.eclipse.etrice.core.config.DataConfigurationHelper;
+import org.eclipse.etrice.core.config.IntLiteral;
+import org.eclipse.etrice.core.config.Literal;
+import org.eclipse.etrice.core.config.LiteralArray;
+import org.eclipse.etrice.core.config.NumberLiteral;
+import org.eclipse.etrice.core.config.RealLiteral;
+import org.eclipse.etrice.core.config.StringLiteral;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
+import org.eclipse.xtend2.lib.StringConcatenation;
+
+@SuppressWarnings("all")
+public class DataConfiguration implements IDataConfiguration {
+ public void doSetup() {
+ ConfigStandaloneSetup.doSetup();
+ }
+
+ public boolean setResources(final ResourceSet resource, final ILogger logger) {
+ boolean _setConfigModels = DataConfigurationHelper.setConfigModels(resource, logger);
+ return _setConfigModels;
+ }
+
+ public String getAttrClassConfigValue(final ActorClass actor, final List<Attribute> path) {
+ AttrClassConfig _attrClassConfig = this.getAttrClassConfig(actor, path);
+ LiteralArray _value = _attrClassConfig==null?(LiteralArray)null:_attrClassConfig.getValue();
+ String _stringExpr = _value==null?(String)null:this.toStringExpr(_value);
+ return _stringExpr;
+ }
+
+ public String getAttrClassConfigMaxValue(final ActorClass actor, final List<Attribute> path) {
+ AttrClassConfig _attrClassConfig = this.getAttrClassConfig(actor, path);
+ NumberLiteral _min = _attrClassConfig==null?(NumberLiteral)null:_attrClassConfig.getMin();
+ String _stringExpr = _min==null?(String)null:this.toStringExpr(_min);
+ return _stringExpr;
+ }
+
+ public String getAttrClassConfigMinValue(final ActorClass actor, final List<Attribute> path) {
+ AttrClassConfig _attrClassConfig = this.getAttrClassConfig(actor, path);
+ NumberLiteral _max = _attrClassConfig==null?(NumberLiteral)null:_attrClassConfig.getMax();
+ String _stringExpr = _max==null?(String)null:this.toStringExpr(_max);
+ return _stringExpr;
+ }
+
+ private AttrClassConfig getAttrClassConfig(final ActorClass actor, final List<Attribute> path) {
+ AttrClassConfig _xblockexpression = null;
+ {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/");
+ String _name = actor.getName();
+ _builder.append(_name, "");
+ _builder.append("/");
+ String _stringPath = this.toStringPath(path);
+ _builder.append(_stringPath, "");
+ String id = _builder.toString();
+ AttrClassConfig _get = DataConfigurationHelper.actorClassAttrMap.get(id);
+ _xblockexpression = (_get);
+ }
+ return _xblockexpression;
+ }
+
+ public String getAttrClassConfigValue(final ProtocolClass pc, final boolean regular, final List<Attribute> path) {
+ String _xblockexpression = null;
+ {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/");
+ String _name = pc.getName();
+ _builder.append(_name, "");
+ _builder.append("/");
+ {
+ if (regular) {
+ _builder.append("regular");
+ } else {
+ _builder.append("conjugated");
+ }
+ }
+ _builder.append("/");
+ String _stringPath = this.toStringPath(path);
+ _builder.append(_stringPath, "");
+ String id = _builder.toString();
+ AttrClassConfig _get = DataConfigurationHelper.protocolClassAttrMap.get(id);
+ LiteralArray _value = _get==null?(LiteralArray)null:_get.getValue();
+ String _stringExpr = _value==null?(String)null:this.toStringExpr(_value);
+ _xblockexpression = (_stringExpr);
+ }
+ return _xblockexpression;
+ }
+
+ private String toStringPath(final List<Attribute> path) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _hasElements = false;
+ for(final Attribute a : path) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate("/", "");
+ }
+ String _name = a.getName();
+ _builder.append(_name, "");
+ }
+ }
+ String _string = _builder.toString();
+ return _string;
+ }
+
+ public String getAttrInstanceConfigValue(final ActorInstance ai, final List<Attribute> path) {
+ String _xblockexpression = null;
+ {
+ String _path = ai.getPath();
+ String _plus = (_path + "/");
+ String _stringPath = this.toStringPath(path);
+ String id = (_plus + _stringPath);
+ AttrInstanceConfig _get = DataConfigurationHelper.actorInstanceAttrMap.get(id);
+ LiteralArray _value = _get==null?(LiteralArray)null:_get.getValue();
+ String _stringExpr = _value==null?(String)null:this.toStringExpr(_value);
+ _xblockexpression = (_stringExpr);
+ }
+ return _xblockexpression;
+ }
+
+ public List<Attribute> getAllDynConfigReadAttributes(final ActorClass actor) {
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ return _arrayList;
+ }
+
+ public List<Attribute> getAllDynConfigWriteAttributes(final ActorClass actor) {
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ return _arrayList;
+ }
+
+ public List<Attribute> getDynConfigReadAttributes(final SubSystemClass subsystem) {
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ return _arrayList;
+ }
+
+ public List<Attribute> getDynConfigWriteAttributes(final SubSystemClass subsystem) {
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ return _arrayList;
+ }
+
+ public boolean hasDynConfigReadAttributes(final ActorClass actor) {
+ return false;
+ }
+
+ public boolean hasDynConfigWriteAttributes(final ActorClass actor) {
+ return false;
+ }
+
+ public boolean hasVariableService(final SubSystemClass subsystem) {
+ return false;
+ }
+
+ private String toStringExpr(final LiteralArray literal) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<Literal> _literals = literal.getLiterals();
+ boolean _hasElements = false;
+ for(final Literal l : _literals) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", "");
+ }
+ String _stringExpr = this.toStringExpr(l);
+ _builder.append(_stringExpr, "");
+ }
+ }
+ String _string = _builder.toString();
+ return _string;
+ }
+
+ private String toStringExpr(final Literal literal) {
+ String _switchResult = null;
+ boolean _matched = false;
+ if (!_matched) {
+ if (literal instanceof BooleanLiteral) {
+ final BooleanLiteral _booleanLiteral = (BooleanLiteral)literal;
+ _matched=true;
+ boolean _isIsTrue = _booleanLiteral.isIsTrue();
+ String _string = Boolean.valueOf(_isIsTrue).toString();
+ _switchResult = _string;
+ }
+ }
+ if (!_matched) {
+ if (literal instanceof IntLiteral) {
+ final IntLiteral _intLiteral = (IntLiteral)literal;
+ _matched=true;
+ long _value = _intLiteral.getValue();
+ String _string = Long.valueOf(_value).toString();
+ _switchResult = _string;
+ }
+ }
+ if (!_matched) {
+ if (literal instanceof RealLiteral) {
+ final RealLiteral _realLiteral = (RealLiteral)literal;
+ _matched=true;
+ double _value = _realLiteral.getValue();
+ String _string = Double.valueOf(_value).toString();
+ _switchResult = _string;
+ }
+ }
+ if (!_matched) {
+ if (literal instanceof StringLiteral) {
+ final StringLiteral _stringLiteral = (StringLiteral)literal;
+ _matched=true;
+ String _value = _stringLiteral.getValue();
+ String _string = _value.toString();
+ _switchResult = _string;
+ }
+ }
+ return _switchResult;
+ }
+}

Back to the top