summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-11-04 11:36:13 (EST)
committerJuergen Haug2012-11-04 11:36:13 (EST)
commit84eaee9b6c00c189510ed82543bb783780db8867 (patch)
tree4ca726bbd1912060adb22a5538c66c6033631a9a
parent3b04960843e75bcdb210663541a6117d83727f51 (diff)
downloadorg.eclipse.etrice-84eaee9b6c00c189510ed82543bb783780db8867.zip
org.eclipse.etrice-84eaee9b6c00c189510ed82543bb783780db8867.tar.gz
org.eclipse.etrice-84eaee9b6c00c189510ed82543bb783780db8867.tar.bz2
[CQ 6485][config, generator] static configrefs/changes/11/8511/1
-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
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend30
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend56
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend7
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java6
7 files changed, 467 insertions, 60 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 0000000..4debf24
--- /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 79a74fe..bba25fd 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 0000000..a89ceb9
--- /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;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
index bb3c9de..dcd44fe 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend
@@ -35,35 +35,37 @@ class ConfigGenAddon {
// For SubSystemClassGen
- def public genActorInstanceConfig(ActorInstance ai){'''
- «FOR a : ai.actorClass.attributes»
- «applyInstanceConfig(ai, "inst", ai.path+"/"+a.name, a)»
- «ENDFOR»
+ def public genActorInstanceConfig(ActorInstance ai, String aiVariableName){'''
+ «FOR a : ai.actorClass.attributes»
+ «applyInstanceConfig(ai, aiVariableName, new ArrayList<Attribute>().union(a))»
+ «ENDFOR»
'''
}
- def public applyInstanceConfig(ActorInstance ai, String invokes, String instancePath, Attribute a){
+ def private applyInstanceConfig(ActorInstance ai, String invokes, List<Attribute> path){
+ var a = path.last
var aType = a.refType.type
if(aType.primitive){
- var value = dataConfigExt.getAttrInstanceConfigValue(ai, instancePath)
+ var value = dataConfigExt.getAttrInstanceConfigValue(ai, path)
if(value == null)
''''''
else if(a.size == 0 || aType.characterType)
'''«invokes».«a.name.invokeSetter(null, (aType as PrimitiveType).toValueLiteral(value))»;'''
else if(a.size == value.split(",").size){
- var arrayExpr = '''«FOR s : value.split(",") SEPARATOR ','»«(aType as PrimitiveType).toValueLiteral(s.trim)»«ENDFOR»'''
- '''«invokes».«a.name.invokeSetter(null, '''new «aType.typeName»[]«arrayExpr»'''.toString)»'''
- } else
- '''{
+ var arrayExpr = '''{ «FOR s : value.split(",") SEPARATOR ', '»«(aType as PrimitiveType).toValueLiteral(s.trim)»«ENDFOR» }'''
+ '''«invokes».«a.name.invokeSetter(null, '''new «aType.typeName»[] «arrayExpr»'''.toString)»;'''
+ } else '''
+ {
«aType.typeName»[] array = «invokes».«a.name.invokeGetter(null)»;
for (int i=0;i<«a.size»;i++){
array[i] = «(aType as PrimitiveType).toValueLiteral(value)»;
}'''
}
- else if (aType.dataClass)
- '''«FOR e : (aType as DataClass).attributes»
- «applyInstanceConfig(ai, invokes+"."+a.name.invokeGetter(null), instancePath+"/"+e.name, e)»
- «ENDFOR»'''
+ else if (aType.dataClass)'''
+ «FOR e : (aType as DataClass).attributes»
+ «applyInstanceConfig(ai, invokes+"."+a.name.invokeGetter(null), path.union(e))»
+ «ENDFOR»
+ '''
}
// For ActorClassGen
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
index 552272d..402a944 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend
@@ -12,21 +12,23 @@
package org.eclipse.etrice.generator.java.gen
-import org.eclipse.etrice.core.room.Attribute
-import java.util.List
import com.google.inject.Inject
-import org.eclipse.etrice.generator.generic.TypeHelpers
-import org.eclipse.etrice.core.room.ComplexType
-import org.eclipse.etrice.generator.generic.ILanguageExtension
import com.google.inject.Singleton
-import org.eclipse.etrice.generator.base.IDataConfiguration
import java.util.ArrayList
+import java.util.List
import org.eclipse.emf.ecore.EObject
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.ComplexType
import org.eclipse.etrice.core.room.DataClass
-import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.core.room.PortClass
import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.generator.generic.ILanguageExtension
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.generator.generic.TypeHelpers
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
@Singleton
class Initialization {
@@ -35,6 +37,7 @@ class Initialization {
@Inject extension RoomExtensions
@Inject ILanguageExtension languageExt
@Inject IDataConfiguration dataConfigExt
+ @Inject ProcedureHelpers procedureHelpers
def attributeInitialization(List<Attribute> attribs, EObject roomClass, boolean useClassDefaultsOnly) {
'''
@@ -48,23 +51,31 @@ class Initialization {
def private attributeInit(EObject roomClass, List<Attribute> path, boolean useClassDefaultsOnly) {
var a = path.last
if(a.refType.type.dataClass){
- var result = '''«(a.refType.type as DataClass).attributes.forEach(e | attributeInit(roomClass, path.union(e), useClassDefaultsOnly))»'''
+ var result =
+ '''
+ «FOR e : (a.refType.type as DataClass).attributes»
+ «attributeInit(roomClass, path.union(e), useClassDefaultsOnly)»
+ «ENDFOR»
+ '''
if(result.length > 0)
result
}
else {
'''
«var aType = a.refType.type»
- «var value = a.getInitValueLiteral(roomClass)»
+ «var value = getInitValueLiteral(roomClass, path)»
«IF value!=null»
«IF a.size == 0 || aType.characterType»
- «a.name» = «value»;
+ «path.take(path.size-1).invokeGetter»«procedureHelpers.invokeSetter(a.name,null,value)»;
«ELSEIF value.startsWith("{")»
- «a.name» = new «aType.typeName»[] «value»;
+ «path.take(path.size-1).invokeGetter»«procedureHelpers.invokeSetter(a.name,null, '''new «aType.typeName»[] «value»''')»;
«ELSE»
- «a.name» = new «aType.typeName»[«a.size»];
- for (int i=0;i<«a.size»;i++){
- «a.name»[i] = «value»;
+ {
+ «a.name» = new «aType.typeName»[«a.size»];
+ for (int i=0;i<«a.size»;i++){
+ «a.name»[i] = «value»;
+ }
+ «path.take(path.size-1).invokeGetter»«procedureHelpers.invokeSetter(a.name,null,a.name)»;
}
«ENDIF»
«ELSEIF aType instanceof ComplexType || a.size>1 || !useClassDefaultsOnly»
@@ -87,12 +98,17 @@ class Initialization {
}
}
- def private getInitValueLiteral(Attribute a, EObject roomClass){
+ def private getInitValueLiteral(EObject roomClass, List<Attribute> path){
+ var a = path.last
if(a.refType.type.primitive){
var aType = a.refType.type as PrimitiveType
var result = switch roomClass {
- ActorClass: dataConfigExt.getAttrClassConfigValue(roomClass, new ArrayList<Attribute>.union(a))
- PortClass: dataConfigExt.getAttrClassConfigValue(roomClass, new ArrayList<Attribute>.union(a))
+ ActorClass: dataConfigExt.getAttrClassConfigValue(roomClass, path)
+ PortClass:
+ if(roomClass.eContainer instanceof ProtocolClass){
+ var pc = roomClass.eContainer as ProtocolClass
+ dataConfigExt.getAttrClassConfigValue(pc, pc.regular.equals(roomClass), path)
+ }
}
if(result != null)
return if(a.size == 0 || aType.characterType)
@@ -103,4 +119,8 @@ class Initialization {
}
a.defaultValueLiteral
}
+
+ def private invokeGetter(Iterable<Attribute> path){
+ '''«FOR a : path»«procedureHelpers.invokeGetter(a.name, null)».«ENDFOR»'''
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
index 224b092..d9afa54 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
@@ -174,7 +174,12 @@ class SubSystemClassGen {
«ENDFOR»
// apply instance attribute configurations
- «comp.allContainedInstances.forEach(ai | configGenAddon.genActorInstanceConfig(ai))»
+ «FOR ai: comp.allContainedInstances»
+ {
+ «ai.actorClass.name» inst = («ai.actorClass.name») instances[«comp.allContainedInstances.indexOf(ai)»];
+ «configGenAddon.genActorInstanceConfig(ai, "inst")»
+ }
+ «ENDFOR»
// create the subsystem system port
RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, "RTSystemPort",
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java
index 4451042..b4416ef 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java
@@ -7,7 +7,7 @@ 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.PortClass;
+import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SubSystemClass;
public interface IDataConfiguration {
@@ -21,11 +21,11 @@ public interface IDataConfiguration {
// static configuration
public String getAttrClassConfigValue(ActorClass actor, List<Attribute> path);
- public String getAttrClassConfigValue(PortClass port, List<Attribute> path);
+ public String getAttrClassConfigValue(ProtocolClass pc, boolean regular, List<Attribute> path);
public String getAttrClassConfigMinValue(ActorClass actor, List<Attribute> path);
public String getAttrClassConfigMaxValue(ActorClass actor, List<Attribute> path);
- public String getAttrInstanceConfigValue(ActorInstance ai, String path);
+ public String getAttrInstanceConfigValue(ActorInstance ai, List<Attribute> path);
// dynamic configuration