summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-10-29 07:38:43 (EDT)
committerJuergen Haug2012-10-29 07:38:43 (EDT)
commit3b04960843e75bcdb210663541a6117d83727f51 (patch)
treecbe60410875a30e742fe59ad2639a287535c5ae3
parent0f9be31bd213f7bb86b1e7359967997efd8f73e4 (diff)
downloadorg.eclipse.etrice-3b04960843e75bcdb210663541a6117d83727f51.zip
org.eclipse.etrice-3b04960843e75bcdb210663541a6117d83727f51.tar.gz
org.eclipse.etrice-3b04960843e75bcdb210663541a6117d83727f51.tar.bz2
[CQ 6485][config, generator] refactor: draft IDataConfiguration, staticrefs/changes/89/8389/1
-rw-r--r--plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF12
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java (renamed from plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ConfigHelper.java)30
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java6
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java10
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend33
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend194
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend95
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend35
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend12
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java3
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java67
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java590
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java161
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java2
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java132
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java940
-rw-r--r--plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java8
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java43
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ConfigExtension.xtend203
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend7
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java475
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java8
28 files changed, 769 insertions, 2312 deletions
diff --git a/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
index 2044ade..fe79b8a 100644
--- a/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.core.config/META-INF/MANIFEST.MF
@@ -19,11 +19,13 @@ Require-Bundle: org.eclipse.xtext;bundle-version="2.1.1";visibility:=reexport,
org.eclipse.emf.common,
org.antlr.runtime,
org.eclipse.xtext.common.types;bundle-version="2.1.1",
- org.eclipse.etrice.core.room;bundle-version="0.2.0"
-Import-Package: org.apache.log4j,
- org.apache.commons.logging,
- org.eclipse.xtext.xbase.lib,
- org.eclipse.xtend.lib
+ org.eclipse.etrice.core.room;bundle-version="0.2.0",
+ org.eclipse.etrice.core.genmodel;bundle-version="0.2.0"
+Import-Package: org.apache.commons.logging,
+ org.apache.log4j,
+ org.eclipse.etrice.generator.base,
+ org.eclipse.xtend.lib,
+ org.eclipse.xtext.xbase.lib
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.etrice.core,
org.eclipse.etrice.core.services,
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ConfigHelper.java b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
index 1877b63..79a74fe 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ConfigHelper.java
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
@@ -9,12 +9,15 @@
* Juergen Haug
*
*******************************************************************************/
-package org.eclipse.etrice.generator.base;
+package org.eclipse.etrice.core.config;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -27,13 +30,14 @@ 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.ProtocolClass;
import org.eclipse.etrice.core.room.SubSystemClass;
-public class ConfigHelper {
+public class DataConfigurationHelper {
public static Map<ActorClass, ActorClassConfig> ac2acConfMap = new HashMap<ActorClass, ActorClassConfig>();
- public static Map<ProtocolClass, ProtocolClassConfig> pc2pcConfMap = new HashMap<ProtocolClass, ProtocolClassConfig>();
+ public static Map<PortClass, PortClassConfig> pc2pcConfMap = new HashMap<PortClass, PortClassConfig>();
public static Map<String, ActorInstanceConfig> path2aiConfMap = new HashMap<String, ActorInstanceConfig>();
public static Map<SubSystemClass, SubSystemConfig> ssc2ssConfMap = new HashMap<SubSystemClass, SubSystemConfig>();
public static Map<SubSystemClass, List<AttrInstanceConfig>> ssc2attrInstConfMap = new HashMap<SubSystemClass, List<AttrInstanceConfig>>();
@@ -60,26 +64,34 @@ public class ConfigHelper {
if (!configs.isEmpty())
logger.logInfo("-- loading configurations");
+ Set<ActorClass> actorClasses = new HashSet<ActorClass>();
+ Set<ProtocolClass> protocolClasses = new HashSet<ProtocolClass>();
for (ConfigModel config : configs) {
for (ActorClassConfig classConfig : config.getActorClassConfigs()) {
- if (ac2acConfMap.containsKey(classConfig.getActor())) {
+ if (actorClasses.contains(classConfig.getActor())) {
logger.logError("Multiple configurations for actor class "
+ classConfig.getActor().getName() + " found", null);
error = true;
- } else
+ } else {
+ actorClasses.add(classConfig.getActor());
ac2acConfMap.put(classConfig.getActor(), classConfig);
+ }
}
for (ProtocolClassConfig protocolConfig : config
.getProtocolClassConfigs()) {
- if (pc2pcConfMap.containsKey(protocolConfig)) {
+ if (protocolClasses.contains(protocolConfig.getProtocol())) {
logger.logError(
"Multiple configurations for protocol class "
+ protocolConfig.getProtocol().getName()
+ " found", null);
error = true;
- } else
- pc2pcConfMap.put(protocolConfig.getProtocol(),
- protocolConfig);
+ } else {
+ protocolClasses.add(protocolConfig.getProtocol());
+ pc2pcConfMap.put(protocolConfig.getProtocol().getRegular(),
+ protocolConfig.getRegular());
+ pc2pcConfMap.put(protocolConfig.getProtocol()
+ .getConjugate(), protocolConfig.getConjugated());
+ }
}
for (ActorInstanceConfig instanceConfig : config
.getActorInstanceConfigs()) {
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java
index 50b3ba1..79732bc 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java
@@ -182,7 +182,7 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
ConfigPackage.Literals.ATTR_CONFIG__VALUE);
if (a.getSize() > 0)
error("DataClass arrays not supported",
- ConfigPackage.Literals.ATTR_CLASS_CONFIG__ATTRIBUTES);
+ ConfigPackage.Literals.ATTR_CONFIG__ATTRIBUTE);
}
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
index 85114d5..bc73031 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend
@@ -35,7 +35,6 @@ import org.eclipse.etrice.core.room.ActorCommunicationType
import org.eclipse.etrice.generator.generic.ILanguageExtension
import static extension org.eclipse.etrice.generator.base.Indexed.*
import org.eclipse.etrice.core.room.Attribute
-import org.eclipse.etrice.generator.generic.ConfigExtension
@Singleton
class SubSystemClassGen {
@@ -44,7 +43,6 @@ class SubSystemClassGen {
@Inject extension CExtensions stdExt
@Inject extension RoomExtensions roomExt
@Inject extension ProcedureHelpers helpers
- @Inject extension ConfigExtension
@Inject ILanguageExtension languageExt
@Inject ILogger logger
@@ -420,7 +418,7 @@ class SubSystemClassGen {
}
def private genAttributeInitializer(ActorInstance ai, Attribute att) {
- val value = att.initValueLiteral
+ val value = null as String // att.initValueLiteral
if (value==null)
att.initializationWithDefaultValues
else
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
index 56bcb6c..8da6909 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.java
@@ -35,7 +35,6 @@ import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.c.gen.CExtensions;
-import org.eclipse.etrice.generator.generic.ConfigExtension;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
@@ -61,9 +60,6 @@ public class SubSystemClassGen {
private ProcedureHelpers helpers;
@Inject
- private ConfigExtension _configExtension;
-
- @Inject
private ILanguageExtension languageExt;
@Inject
@@ -1305,7 +1301,7 @@ public class SubSystemClassGen {
private String genAttributeInitializer(final ActorInstance ai, final Attribute att) {
String _xblockexpression = null;
{
- final String value = this._configExtension.getInitValueLiteral(att);
+ final String value = ((String) null);
String _xifexpression = null;
boolean _equals = Objects.equal(value, null);
if (_equals) {
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
index 5e2b780..61f7d3b 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/Main.java
@@ -18,7 +18,7 @@ import java.util.List;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.generator.base.AbstractGenerator;
-import org.eclipse.etrice.generator.base.ConfigHelper;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
import org.eclipse.etrice.generator.java.gen.Validator;
import org.eclipse.etrice.generator.java.setup.GeneratorModule;
import org.eclipse.xtext.generator.IGenerator;
@@ -57,10 +57,12 @@ public class Main extends AbstractGenerator {
@Inject
protected org.eclipse.etrice.generator.doc.gen.MainGen mainDocGenerator;
-
@Inject
private Validator validator;
+ @Inject
+ protected IDataConfiguration dataConfig;
+
public int runGenerator(String[] args) {
if (args.length == 0) {
logger.logError(Main.class.getName()+" - aborting: no arguments!", null);
@@ -94,7 +96,7 @@ public class Main extends AbstractGenerator {
}
setupRoomModel();
- setupConfigModel();
+ dataConfig.doSetup();
if (!runGenerator(uriList, genModelPath, genInstDiag, asLibrary))
return GENERATOR_ERROR;
@@ -110,7 +112,7 @@ public class Main extends AbstractGenerator {
if (!validateModels(rs))
return false;
- if(!ConfigHelper.setConfigModels(rs, logger))
+ if(!dataConfig.setResources(rs, logger))
return false;
Root genModel = createGeneratorModel(rs, asLibrary, genModelPath);
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
index f9a08f3..7e5f189 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend
@@ -21,10 +21,10 @@ import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import static extension org.eclipse.etrice.core.room.util.RoomHelpers.*
import org.eclipse.etrice.generator.base.AbstractGenerator
-import org.eclipse.etrice.generator.generic.ConfigExtension
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.GenericActorClassGenerator
+import org.eclipse.etrice.generator.base.IDataConfiguration
@Singleton
class ActorClassGen extends GenericActorClassGenerator {
@@ -32,8 +32,8 @@ class ActorClassGen extends GenericActorClassGenerator {
@Inject JavaIoFileSystemAccess fileAccess
@Inject extension JavaExtensions
@Inject extension RoomExtensions
- @Inject extension ConfigExtension
- @Inject ConfigGenAddon configAddon
+ @Inject IDataConfiguration dataConfigExt
+ @Inject ConfigGenAddon configGenAddon
@Inject extension ProcedureHelpers
@Inject extension Initialization
@@ -53,14 +53,14 @@ class ActorClassGen extends GenericActorClassGenerator {
def generate(Root root, ExpandedActorClass xpac, ActorClass ac) {
val ctor = ac.operations.filter(op|op.constructor).head
val dtor = ac.operations.filter(op|op.destructor).head
- val dynConfigReadAttributes = ac.getDynConfigAttributes(true, false)
- val dynConfigWriteAttributes = ac.getDynConfigAttributes(false, true)
'''
package «ac.getPackage»;
- «IF !dynConfigReadAttributes.empty»import org.eclipse.etrice.runtime.java.config.DynConfigLock;«ENDIF»
- «IF !dynConfigReadAttributes.empty || !dynConfigWriteAttributes.empty»import org.eclipse.etrice.runtime.java.config.VariableService;«ENDIF»
+ «IF dataConfigExt.hasDynConfigReadAttributes(ac)»
+ import org.eclipse.etrice.runtime.java.config.DynConfigLock;«ENDIF»
+ «IF dataConfigExt.hasDynConfigReadAttributes(ac) || dataConfigExt.hasDynConfigWriteAttributes(ac)»
+ import org.eclipse.etrice.runtime.java.config.VariableService;«ENDIF»
import org.eclipse.etrice.runtime.java.messaging.Address;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
@@ -85,7 +85,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«ac.userCode(2)»
- «IF !dynConfigWriteAttributes.empty»
+ «IF dataConfigExt.hasDynConfigWriteAttributes(ac)»
private VariableService variableService;
«ENDIF»
@@ -107,9 +107,9 @@ class ActorClassGen extends GenericActorClassGenerator {
//--------------------- interface item IDs
«genInterfaceItemConstants(xpac, ac)»
- «configAddon.genMinMaxConstants(ac)»
+ «configGenAddon.genMinMaxConstants(ac)»
«ac.attributes.attributes»
- «FOR a : dynConfigReadAttributes»
+ «FOR a : dataConfigExt.getAllDynConfigReadAttributes(ac)»
private DynConfigLock lock_«a.name»;
«ENDFOR»
«ac.operationsImplementation»
@@ -123,7 +123,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«ENDIF»
setClassName("«ac.name»");
- «ac.attributes.attributeInitialization(false)»
+ «ac.attributes.attributeInitialization(ac, false)»
// own ports
«FOR ep : ac.getEndPorts()»
@@ -148,22 +148,22 @@ class ActorClassGen extends GenericActorClassGenerator {
«ENDIF»
}
- «IF !dynConfigReadAttributes.empty || !dynConfigWriteAttributes.empty»
+ «IF dataConfigExt.hasDynConfigReadAttributes(ac) || dataConfigExt.hasDynConfigWriteAttributes(ac)»
public «ac.name»(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr, VariableService variableService){
this(parent, name, port_addr, peer_addr);
- «IF !dynConfigWriteAttributes.empty»
+ «IF dataConfigExt.hasDynConfigWriteAttributes(ac)»
this.variableService = variableService;
«ENDIF»
- «FOR a : dynConfigReadAttributes»
+ «FOR a : dataConfigExt.getAllDynConfigReadAttributes(ac)»
lock_«a.name» = new DynConfigLock();
«ENDFOR»
}
«ENDIF»
- «attributeSettersGettersImplementation(ac.attributes.minus(dynConfigReadAttributes.toList), ac.name)»
+ «attributeSettersGettersImplementation(ac.attributes.minus(dataConfigExt.getAllDynConfigReadAttributes(ac).toList), ac.name)»
- «configAddon.genDynConfigGetterSetter(ac)»
+ «configGenAddon.genDynConfigGetterSetter(ac)»
//--------------------- port getters
«FOR ep : ac.getEndPorts()»
@@ -213,4 +213,5 @@ class ActorClassGen extends GenericActorClassGenerator {
};
'''
}
+
}
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 8d93ad8..bb3c9de 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
@@ -10,112 +10,140 @@
*
*******************************************************************************/
-package org.eclipse.etrice.generator.java.gen
-
-import com.google.inject.Inject
-import java.util.List
-import org.eclipse.etrice.core.config.AttrInstanceConfig
-import org.eclipse.etrice.core.room.ActorClass
-import org.eclipse.etrice.core.room.PrimitiveType
-import org.eclipse.etrice.generator.generic.ConfigExtension
-import org.eclipse.etrice.generator.generic.ProcedureHelpers
+package org.eclipse.etrice.generator.java.gen
+
+import com.google.inject.Inject
+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.DataClass
+import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
-
+import java.util.List
+import java.util.ArrayList
class ConfigGenAddon {
@Inject extension JavaExtensions stdExt
@Inject extension TypeHelpers typeHelpers
@Inject extension ProcedureHelpers helpers
- @Inject extension ConfigExtension configExt
+ @Inject IDataConfiguration dataConfigExt
+ @Inject extension RoomExtensions
// For SubSystemClassGen
- def public applyInstanceConfig(String instance, String className, List<AttrInstanceConfig> attrConfigs){'''
- «FOR attrConfig : attrConfigs»
- «var a = attrConfig.attribute»
- «var aType = a.refType.type»
- «IF aType.primitive»
- «var values = attrConfig.value?.values»
- «IF values == null»
- «ELSEIF a.size == 0 || aType.characterType»
- «instance».«a.name.invokeSetter(className, (aType as PrimitiveType).toValueLiteral(values.get(0)))»;
- «ELSEIF a.size == values.size»
- «instance».«a.name.invokeSetter(className, "new "+aType.typeName+"[]"+(aType as PrimitiveType).toArrayValueLiteral(values))»;
- «ELSE»
- {
- «aType.typeName»[] array = «instance».«a.name.invokeGetter(className)»;
- for (int i=0;i<«a.size»;i++){
- array[i] = «(aType as PrimitiveType).toValueLiteral(values.get(0))»;
- }
- }
- «ENDIF»
- «ELSEIF aType.dataClass»
- «(instance+"."+a.name.invokeGetter(className)).applyInstanceConfig(aType.typeName, attrConfig.attributes)»
- «ENDIF»
+ def public genActorInstanceConfig(ActorInstance ai){'''
+ «FOR a : ai.actorClass.attributes»
+ «applyInstanceConfig(ai, "inst", ai.path+"/"+a.name, a)»
«ENDFOR»
- '''}
+ '''
+ }
+
+ def public applyInstanceConfig(ActorInstance ai, String invokes, String instancePath, Attribute a){
+ var aType = a.refType.type
+ if(aType.primitive){
+ var value = dataConfigExt.getAttrInstanceConfigValue(ai, instancePath)
+ 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
+ '''{
+ «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»'''
+ }
// For ActorClassGen
- def public genDynConfigGetterSetter(ActorClass ac){'''
- «FOR a : ac.getDynConfigAttributes(true, false)»
- public «a.refType.type.typeName»«IF a.size>0»[]«ENDIF» get«a.name.toFirstUpper»(){
- if(lock_«a.name» == null)
- return «a.name»;
- else
- synchronized(lock_«a.name»){
- return «a.name»;
- }
- }
- public void set«a.name.toFirstUpper»(«a.refType.type.typeName»«IF a.size>0»[]«ENDIF» «a.name»){
- if(lock_«a.name» == null)
- this.«a.name» = «a.name»;
- else
- synchronized(lock_«a.name»){
- this.«a.name» = «a.name»;
- }
- }
- public DynConfigLock get«a.name.toFirstUpper»Lock(){
- return lock_«a.name»;
- }
- «ENDFOR»
- «FOR a : ac.getDynConfigAttributes(false, true)»
- public void setAndWrite«a.name.toFirstUpper»(«a.refType.type.typeName»«IF a.size>0»[]«ENDIF» «a.name»){
- set«a.name.toFirstUpper»(«a.name»);
- variableService.write(this.getInstancePath()+"/«a.name»", «a.name»);
- }
- «ENDFOR»
- '''}
+// def public genDynConfigGetterSetter(ActorClass ac){'''
+// «FOR a : dataConfigExt.getAllDynConfigReadAttributes(ac)»
+// public «a.refType.type.typeName»«IF a.size>0»[]«ENDIF» get«a.name.toFirstUpper»(){
+// if(lock_«a.name» == null)
+// return «a.name»;
+// else
+// synchronized(lock_«a.name»){
+// return «a.name»;
+// }
+// }
+// public void set«a.name.toFirstUpper»(«a.refType.type.typeName»«IF a.size>0»[]«ENDIF» «a.name»){
+// if(lock_«a.name» == null)
+// this.«a.name» = «a.name»;
+// else
+// synchronized(lock_«a.name»){
+// this.«a.name» = «a.name»;
+// }
+// }
+// public DynConfigLock get«a.name.toFirstUpper»Lock(){
+// return lock_«a.name»;
+// }
+// «ENDFOR»
+// «FOR a : dataConfigExt.getAllDynConfigWriteAttributes(ac)»
+// public void setAndWrite«a.name.toFirstUpper»(«a.refType.type.typeName»«IF a.size>0»[]«ENDIF» «a.name»){
+// set«a.name.toFirstUpper»(«a.name»);
+// variableService.write(this.getInstancePath()+"/«a.name»", «a.name»);
+// }
+// «ENDFOR»
+// '''}
+
+ def genDynConfigGetterSetter(ActorClass ac){
+
+ }
def public genMinMaxConstants(ActorClass ac){
- var attrConfigs = ac.allAttrConfigFlat.filter(c | c.min != null || c.max != null)
- '''
- «IF !attrConfigs.empty»
- //--------------------- attribute specifications
- «ENDIF»
-
- «FOR c : attrConfigs»
- «var aType = (c.attribute.refType.type as PrimitiveType)»
- «IF c.min != null»
- public static «aType.minMaxType» MIN«c.getPath(false, false, true, true).toPath("_")» = «aType.toValueLiteral(c.min.value)»;
- «ENDIF»
- «IF c.max != null»
- public static «aType.minMaxType» MAX«c.getPath(false, false, true, true).toPath("_")» = «aType.toValueLiteral(c.max.value)»;
- «ENDIF»
- «ENDFOR»
+ var result = '''
+ «FOR a : ac.attributes»
+ «genMinMaxConstantsRec(ac, a.name, new ArrayList<Attribute>().union(a))»
+ «ENDFOR»
'''
+ if(result.length != 0)
+ result = result+'''//--------------------- Attribute Specifications'''
+ return result
+ }
+
+ def private genMinMaxConstantsRec(ActorClass ac, String varNamePath, List<Attribute> path){
+ var temp = null as String
+ if(path.last.refType.type.dataClass)
+ '''
+ «FOR e : (path.last.refType.type as DataClass).allAttributes»
+ «genMinMaxConstantsRec(ac, varNamePath+"_"+e.name, path.union(e))»
+ «ENDFOR»
+ '''
+ else {
+ var aType = (path.last.refType.type as PrimitiveType)
+ '''
+ «IF (temp = dataConfigExt.getAttrClassConfigMinValue(ac, path)) != null»
+ public static «aType.minMaxType» MIN_«varNamePath» = «aType.toValueLiteral(temp)»;
+ «ENDIF»
+ «IF (temp = dataConfigExt.getAttrClassConfigMaxValue(ac, path)) != null»
+ public static «aType.minMaxType» MAX_«varNamePath» = «aType.toValueLiteral(temp)»;
+ «ENDIF»
+ '''
+ }
}
def private getMinMaxType(PrimitiveType type){
- switch(type.typeName){
+ return switch(type.typeName){
case "byte":
- return "int"
+ "int"
case "short":
- return "int"
+ "int"
case "float":
- return "double"
+ "double"
+ default:
+ type.typeName
}
- return type.typeName
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
index 6c8c44c..327c4f4 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/DataClassGen.xtend
@@ -74,7 +74,7 @@ class DataClassGen {
public «dc.name»() {
super();
- «dc.attributes.attributeInitialization(true)»
+ «dc.attributes.attributeInitialization(dc, true)»
«IF ctor!=null»
{
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 5ae8109..552272d 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
@@ -15,53 +15,92 @@ 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.ConfigExtension
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 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.DataClass
+import org.eclipse.etrice.generator.generic.RoomExtensions
+import org.eclipse.etrice.core.room.PrimitiveType
@Singleton
class Initialization {
- @Inject extension ConfigExtension
@Inject extension TypeHelpers
+ @Inject extension RoomExtensions
@Inject ILanguageExtension languageExt
+ @Inject IDataConfiguration dataConfigExt
- def attributeInitialization(List<Attribute> attribs, boolean useClassDefaultsOnly) {
+ def attributeInitialization(List<Attribute> attribs, EObject roomClass, boolean useClassDefaultsOnly) {
'''
// initialize attributes
«FOR a : attribs»
- «var aType = a.refType.type»
- «var value = a.initValueLiteral»
- «IF value!=null»
- «IF a.size == 0 || aType.characterType»
- «a.name» = «value»;
- «ELSEIF value.startsWith("{")»
- «a.name» = new «aType.typeName»[] «value»;
+ «attributeInit(roomClass, new ArrayList<Attribute>.union(a), useClassDefaultsOnly)»
+ «ENDFOR»
+ '''
+ }
+
+ 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))»'''
+ if(result.length > 0)
+ result
+ }
+ else {
+ '''
+ «var aType = a.refType.type»
+ «var value = a.getInitValueLiteral(roomClass)»
+ «IF value!=null»
+ «IF a.size == 0 || aType.characterType»
+ «a.name» = «value»;
+ «ELSEIF value.startsWith("{")»
+ «a.name» = new «aType.typeName»[] «value»;
+ «ELSE»
+ «a.name» = new «aType.typeName»[«a.size»];
+ for (int i=0;i<«a.size»;i++){
+ «a.name»[i] = «value»;
+ }
+ «ENDIF»
+ «ELSEIF aType instanceof ComplexType || a.size>1 || !useClassDefaultsOnly»
+ «IF a.size==0»
+ «IF a.refType.isRef»
+ «a.name» = «languageExt.nullPointer()»;
«ELSE»
- «a.name» = new «aType.typeName»[«a.size»];
+ «a.name» = «languageExt.defaultValue(aType)»;
+ «ENDIF»
+ «ELSE»
+ «a.name» = new «aType.typeName»[«a.size»];
+ «IF !useClassDefaultsOnly»
for (int i=0;i<«a.size»;i++){
- «a.name»[i] = «value»;
+ «a.name»[i] = «IF a.refType.isRef»«languageExt.nullPointer()»«ELSE»«languageExt.defaultValue(aType)»«ENDIF»;
}
«ENDIF»
- «ELSEIF aType instanceof ComplexType || a.size>1 || !useClassDefaultsOnly»
- «IF a.size==0»
- «IF a.refType.isRef»
- «a.name» = «languageExt.nullPointer()»;
- «ELSE»
- «a.name» = «languageExt.defaultValue(aType)»;
- «ENDIF»
- «ELSE»
- «a.name» = new «aType.typeName»[«a.size»];
- «IF !useClassDefaultsOnly»
- for (int i=0;i<«a.size»;i++){
- «a.name»[i] = «IF a.refType.isRef»«languageExt.nullPointer()»«ELSE»«languageExt.defaultValue(aType)»«ENDIF»;
- }
- «ENDIF»
- «ENDIF»
«ENDIF»
- «ENDFOR»
+ «ENDIF»
'''
+ }
+ }
+
+ def private getInitValueLiteral(Attribute a, EObject roomClass){
+ 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))
+ }
+ if(result != null)
+ return if(a.size == 0 || aType.characterType)
+ languageExt.toValueLiteral(aType, result)
+ else
+ // array syntax ?
+ '''{ «FOR s : result.split(",") SEPARATOR ' ,'»«languageExt.toValueLiteral(aType, s.trim)»«ENDFOR» }'''.toString
+ }
+ a.defaultValueLiteral
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
index bfff54f..85bc4a9 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.xtend
@@ -110,7 +110,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
public «portClassName»(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
super(actor, name, localId, idx, addr, peerAddress);
«IF pclass!=null»
- «pclass.attributes.attributeInitialization(true)»
+ «pclass.attributes.attributeInitialization(pc, true)»
«ENDIF»
DebuggingService.getInstance().addPortInstance(this);
}
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 b704c9c..224b092 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
@@ -18,13 +18,12 @@ import org.eclipse.etrice.core.genmodel.base.ILogger
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.generic.ConfigExtension
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import static extension org.eclipse.etrice.generator.base.Indexed.*
-
+import org.eclipse.etrice.generator.base.IDataConfiguration
@Singleton
class SubSystemClassGen {
@@ -32,8 +31,8 @@ class SubSystemClassGen {
@Inject JavaIoFileSystemAccess fileAccess
@Inject extension JavaExtensions
@Inject extension RoomExtensions
- @Inject extension ConfigExtension
- @Inject ConfigGenAddon configAddon
+ @Inject IDataConfiguration dataConfigExt
+ @Inject ConfigGenAddon configGenAddon
@Inject extension ProcedureHelpers
@Inject VariableServiceGen varService
@@ -46,15 +45,15 @@ class SubSystemClassGen {
logger.logInfo("generating SubSystemClass implementation: '"+file+"' in '"+path+"'")
fileAccess.setOutputPath(path)
fileAccess.generateFile(file, root.generate(ssi, ssi.subSystemClass))
- if(ssi.subSystemClass.hasVariableService)
- varService.doGenerate(root, ssi);
+ //if(dataConfigExt.hasVariableService(ssi.subSystemClass))
+ // varService.doGenerate(root, ssi);
}
}
def generate(Root root, SubSystemInstance comp, SubSystemClass cc) {'''
package «cc.getPackage()»;
- «IF cc.hasVariableService»import org.eclipse.etrice.runtime.java.config.VariableService;«ENDIF»
+ «IF dataConfigExt.hasVariableService(cc)»import org.eclipse.etrice.runtime.java.config.VariableService;«ENDIF»
import org.eclipse.etrice.runtime.java.messaging.MessageService;
import org.eclipse.etrice.runtime.java.messaging.RTServices;
import org.eclipse.etrice.runtime.java.messaging.Address;
@@ -168,24 +167,14 @@ class SubSystemClassGen {
«ENDIF»
«ENDFOR»
}
- «IF ai.configAttributes.exists(c | c.dynConfig)»
+ «IF false»
, variableService
«ENDIF»
);
«ENDFOR»
// apply instance attribute configurations
- «FOR ai : comp.allContainedInstances»
- «IF !(ai.configAttributes.empty && ai.getConfigPorts.empty)»
- {
- «ai.actorClass.name» inst = («ai.actorClass.name») instances[«comp.allContainedInstances.indexOf(ai)»];
- «configAddon.applyInstanceConfig("inst", ai.actorClass.name, ai.configAttributes)»
- «FOR portConfig : ai.configPorts»
- «configAddon.applyInstanceConfig(("inst."+portConfig.item.name.invokeGetter(ai.actorClass.name)), portConfig.item.portClassName, portConfig.attributes)»
- «ENDFOR»
- }
- «ENDIF»
- «ENDFOR»
+ «comp.allContainedInstances.forEach(ai | configGenAddon.genActorInstanceConfig(ai))»
// create the subsystem system port
RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, "RTSystemPort",
@@ -204,17 +193,17 @@ class SubSystemClassGen {
});
}
- «IF cc.hasVariableService»
+ «IF dataConfigExt.hasVariableService(cc)»
private VariableService variableService;
«ENDIF»
@Override
public void init(){
- «IF cc.hasVariableService»
+ «IF dataConfigExt.hasVariableService(cc)»
variableService = new «comp.name»VariableService(this);
«ENDIF»
super.init();
- «IF cc.hasVariableService»
+ «IF dataConfigExt.hasVariableService(cc)»
variableService.init();
«ENDIF»
}
@@ -222,7 +211,7 @@ class SubSystemClassGen {
@Override
public void stop(){
super.stop();
- «IF cc.hasVariableService»
+ «IF dataConfigExt.hasVariableService(cc)»
variableService.stop();
«ENDIF»
}
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
index 0334901..7145acb 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend
@@ -31,11 +31,11 @@ import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.core.room.DataClass
import org.eclipse.etrice.core.room.RoomModel
import org.eclipse.etrice.core.room.SubSystemClass
-import org.eclipse.etrice.generator.generic.ConfigExtension
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.base.IDataConfiguration
@Singleton
class VariableServiceGen {
@@ -43,11 +43,11 @@ class VariableServiceGen {
@Inject extension JavaIoFileSystemAccess fileAccess
@Inject extension JavaExtensions stdExt
@Inject extension RoomExtensions roomExt
- @Inject extension ConfigExtension configExt
+ @Inject extension IDataConfiguration configExt
@Inject extension ProcedureHelpers helpers
@Inject extension TypeHelpers
@Inject ILogger logger
-
+ /*
def doGenerate(Root root, SubSystemInstance ssi) {
var path = ssi.subSystemClass.generationTargetPath+ssi.subSystemClass.getPath
var file = ssi.subSystemClass.name+"VariableService.java"
@@ -102,7 +102,7 @@ class VariableServiceGen {
protected void setAttributeValues(Map<String, Object> values) {
Object object;
String id = null;
- «FOR attrConfig : cc.getAttrDynConfigs(true, false)»
+ «FOR attrConfig : cc.dynConfigReadAttributes»
«var aiName = (attrConfig.eContainer as ActorInstanceConfig).path.refs.toPath("_")»
try{
boolean changed = false;
@@ -224,7 +224,7 @@ class VariableServiceGen {
def private List<ActorInstance> dynConfigsAIs(SubSystemInstance comp){
val aiPaths = new HashSet<String>();
- for(attrConfig : comp.subSystemClass.getAttrDynConfigs(true, false))
+ for(attrConfig : comp.subSystemClass.dynConfigReadAttributes)
aiPaths.add(attrConfig.getPath(true, true, false, false).toPath("/"))
var ais = new ArrayList<ActorInstance>();
@@ -279,5 +279,5 @@ class VariableServiceGen {
return models
}
-
+ */
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
index e1e35d8..59d479e 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorModule.java
@@ -14,6 +14,7 @@ package org.eclipse.etrice.generator.java.setup;
import org.eclipse.etrice.generator.base.AbstractGenerator;
import org.eclipse.etrice.generator.base.GeneratorBaseModule;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
import org.eclipse.etrice.generator.base.ITranslationProvider;
import org.eclipse.etrice.generator.java.Main;
import org.eclipse.etrice.generator.java.gen.MainGen;
@@ -39,6 +40,8 @@ public class GeneratorModule extends GeneratorBaseModule {
binder.bind(ILanguageExtension.class).to(JavaExtensions.class);
binder.bind(ITranslationProvider.class).to(JavaTranslationProvider.class);
+
+ binder.bind(IDataConfiguration.class).to(org.eclipse.etrice.core.config.DataConfiguration.class);
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
index 5bfbf52..2da7d87 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java
@@ -3,7 +3,6 @@ package org.eclipse.etrice.generator.java.gen;
import com.google.common.base.Objects;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import java.util.HashSet;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.genmodel.base.ILogger;
@@ -21,7 +20,7 @@ import org.eclipse.etrice.core.room.ServiceImplementation;
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.base.AbstractGenerator;
-import org.eclipse.etrice.generator.generic.ConfigExtension;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
@@ -47,10 +46,10 @@ public class ActorClassGen extends GenericActorClassGenerator {
private RoomExtensions _roomExtensions;
@Inject
- private ConfigExtension _configExtension;
+ private IDataConfiguration dataConfigExt;
@Inject
- private ConfigGenAddon configAddon;
+ private ConfigGenAddon configGenAddon;
@Inject
private ProcedureHelpers _procedureHelpers;
@@ -109,8 +108,6 @@ public class ActorClassGen extends GenericActorClassGenerator {
};
Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
- final HashSet<Attribute> dynConfigReadAttributes = this._configExtension.getDynConfigAttributes(ac, true, false);
- final HashSet<Attribute> dynConfigWriteAttributes = this._configExtension.getDynConfigAttributes(ac, false, true);
StringConcatenation _builder = new StringConcatenation();
_builder.append("package ");
String _package = this._roomExtensions.getPackage(ac);
@@ -119,23 +116,20 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLineIfNotEmpty();
_builder.newLine();
{
- boolean _isEmpty = dynConfigReadAttributes.isEmpty();
- boolean _not = (!_isEmpty);
- if (_not) {
+ boolean _hasDynConfigReadAttributes = this.dataConfigExt.hasDynConfigReadAttributes(ac);
+ if (_hasDynConfigReadAttributes) {
_builder.append("import org.eclipse.etrice.runtime.java.config.DynConfigLock;");
}
}
_builder.newLineIfNotEmpty();
{
boolean _or = false;
- boolean _isEmpty_1 = dynConfigReadAttributes.isEmpty();
- boolean _not_1 = (!_isEmpty_1);
- if (_not_1) {
+ boolean _hasDynConfigReadAttributes_1 = this.dataConfigExt.hasDynConfigReadAttributes(ac);
+ if (_hasDynConfigReadAttributes_1) {
_or = true;
} else {
- boolean _isEmpty_2 = dynConfigWriteAttributes.isEmpty();
- boolean _not_2 = (!_isEmpty_2);
- _or = (_not_1 || _not_2);
+ boolean _hasDynConfigWriteAttributes = this.dataConfigExt.hasDynConfigWriteAttributes(ac);
+ _or = (_hasDynConfigReadAttributes_1 || _hasDynConfigWriteAttributes);
}
if (_or) {
_builder.append("import org.eclipse.etrice.runtime.java.config.VariableService;");
@@ -221,9 +215,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.newLine();
{
- boolean _isEmpty_3 = dynConfigWriteAttributes.isEmpty();
- boolean _not_3 = (!_isEmpty_3);
- if (_not_3) {
+ boolean _hasDynConfigWriteAttributes_1 = this.dataConfigExt.hasDynConfigWriteAttributes(ac);
+ if (_hasDynConfigWriteAttributes_1) {
_builder.append("\t");
_builder.append("private VariableService variableService;");
_builder.newLine();
@@ -297,7 +290,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
- CharSequence _genMinMaxConstants = this.configAddon.genMinMaxConstants(ac);
+ CharSequence _genMinMaxConstants = this.configGenAddon.genMinMaxConstants(ac);
_builder.append(_genMinMaxConstants, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -306,7 +299,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append(_attributes_1, " ");
_builder.newLineIfNotEmpty();
{
- for(final Attribute a : dynConfigReadAttributes) {
+ List<Attribute> _allDynConfigReadAttributes = this.dataConfigExt.getAllDynConfigReadAttributes(ac);
+ for(final Attribute a : _allDynConfigReadAttributes) {
_builder.append("\t");
_builder.append("private DynConfigLock lock_");
String _name_7 = a.getName();
@@ -352,7 +346,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
_builder.append("\t\t");
EList<Attribute> _attributes_2 = ac.getAttributes();
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes_2, false);
+ CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes_2, ac, false);
_builder.append(_attributeInitialization, " ");
_builder.newLineIfNotEmpty();
_builder.newLine();
@@ -503,14 +497,12 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
{
boolean _or_1 = false;
- boolean _isEmpty_4 = dynConfigReadAttributes.isEmpty();
- boolean _not_4 = (!_isEmpty_4);
- if (_not_4) {
+ boolean _hasDynConfigReadAttributes_2 = this.dataConfigExt.hasDynConfigReadAttributes(ac);
+ if (_hasDynConfigReadAttributes_2) {
_or_1 = true;
} else {
- boolean _isEmpty_5 = dynConfigWriteAttributes.isEmpty();
- boolean _not_5 = (!_isEmpty_5);
- _or_1 = (_not_4 || _not_5);
+ boolean _hasDynConfigWriteAttributes_2 = this.dataConfigExt.hasDynConfigWriteAttributes(ac);
+ _or_1 = (_hasDynConfigReadAttributes_2 || _hasDynConfigWriteAttributes_2);
}
if (_or_1) {
_builder.append("\t");
@@ -527,9 +519,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.newLine();
{
- boolean _isEmpty_6 = dynConfigWriteAttributes.isEmpty();
- boolean _not_6 = (!_isEmpty_6);
- if (_not_6) {
+ boolean _hasDynConfigWriteAttributes_3 = this.dataConfigExt.hasDynConfigWriteAttributes(ac);
+ if (_hasDynConfigWriteAttributes_3) {
_builder.append("\t");
_builder.append("\t");
_builder.append("this.variableService = variableService;");
@@ -537,7 +528,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
}
}
{
- for(final Attribute a_1 : dynConfigReadAttributes) {
+ List<Attribute> _allDynConfigReadAttributes_1 = this.dataConfigExt.getAllDynConfigReadAttributes(ac);
+ for(final Attribute a_1 : _allDynConfigReadAttributes_1) {
_builder.append("\t");
_builder.append("\t");
_builder.append("lock_");
@@ -556,7 +548,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
_builder.append("\t");
EList<Attribute> _attributes_3 = ac.getAttributes();
- List<Attribute> _list = IterableExtensions.<Attribute>toList(dynConfigReadAttributes);
+ List<Attribute> _allDynConfigReadAttributes_2 = this.dataConfigExt.getAllDynConfigReadAttributes(ac);
+ List<Attribute> _list = IterableExtensions.<Attribute>toList(_allDynConfigReadAttributes_2);
List<Attribute> _minus = this._roomExtensions.<Attribute>minus(_attributes_3, _list);
String _name_27 = ac.getName();
CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_minus, _name_27);
@@ -565,7 +558,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
- CharSequence _genDynConfigGetterSetter = this.configAddon.genDynConfigGetterSetter(ac);
+ Object _genDynConfigGetterSetter = this.configGenAddon.genDynConfigGetterSetter(ac);
_builder.append(_genDynConfigGetterSetter, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -636,8 +629,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
{
boolean _overridesStop = this._roomExtensions.overridesStop(ac);
- boolean _not_7 = (!_overridesStop);
- if (_not_7) {
+ boolean _not = (!_overridesStop);
+ if (_not) {
_builder.append("\t");
_builder.append("public void stop(){");
_builder.newLine();
@@ -679,8 +672,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLineIfNotEmpty();
} else {
boolean _hasStateMachine = xpac.hasStateMachine();
- boolean _not_8 = (!_hasStateMachine);
- if (_not_8) {
+ boolean _not_1 = (!_hasStateMachine);
+ if (_not_1) {
_builder.append("\t");
_builder.append("//--------------------- no state machine");
_builder.newLine();
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
index 238102d..1c5ba56 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
@@ -2,27 +2,24 @@ package org.eclipse.etrice.generator.java.gen;
import com.google.common.base.Objects;
import com.google.inject.Inject;
-import java.util.HashSet;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
-import org.eclipse.etrice.core.config.AttrClassConfig;
-import org.eclipse.etrice.core.config.AttrInstanceConfig;
-import org.eclipse.etrice.core.config.LiteralArray;
-import org.eclipse.etrice.core.config.NumberLiteral;
+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.DataClass;
import org.eclipse.etrice.core.room.DataType;
import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.generator.generic.ConfigExtension;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Conversions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
@SuppressWarnings("all")
public class ConfigGenAddon {
@@ -36,409 +33,310 @@ public class ConfigGenAddon {
private ProcedureHelpers helpers;
@Inject
- private ConfigExtension configExt;
+ private IDataConfiguration dataConfigExt;
- public CharSequence applyInstanceConfig(final String instance, final String className, final List<AttrInstanceConfig> attrConfigs) {
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ public CharSequence genActorInstanceConfig(final ActorInstance ai) {
StringConcatenation _builder = new StringConcatenation();
{
- for(final AttrInstanceConfig attrConfig : attrConfigs) {
- Attribute a = attrConfig.getAttribute();
- _builder.newLineIfNotEmpty();
- RefableType _refType = a.getRefType();
- DataType aType = _refType.getType();
+ ActorClass _actorClass = ai.getActorClass();
+ EList<Attribute> _attributes = _actorClass.getAttributes();
+ for(final Attribute a : _attributes) {
+ String _path = ai.getPath();
+ String _plus = (_path + "/");
+ String _name = a.getName();
+ String _plus_1 = (_plus + _name);
+ CharSequence _applyInstanceConfig = this.applyInstanceConfig(ai, "inst", _plus_1, a);
+ _builder.append(_applyInstanceConfig, "");
_builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence applyInstanceConfig(final ActorInstance ai, final String invokes, final String instancePath, final Attribute a) {
+ CharSequence _xblockexpression = null;
+ {
+ RefableType _refType = a.getRefType();
+ DataType aType = _refType.getType();
+ CharSequence _xifexpression = null;
+ boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
+ if (_isPrimitive) {
+ CharSequence _xblockexpression_1 = null;
{
- boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
- if (_isPrimitive) {
- LiteralArray _value = attrConfig.getValue();
- String[] values = _value==null?(String[])null:this.configExt.getValues(_value);
- _builder.newLineIfNotEmpty();
- {
- boolean _equals = Objects.equal(values, null);
- if (_equals) {
- } else {
- boolean _or = false;
- int _size = a.getSize();
- boolean _equals_1 = (_size == 0);
- if (_equals_1) {
- _or = true;
- } else {
- boolean _isCharacterType = this.typeHelpers.isCharacterType(aType);
- _or = (_equals_1 || _isCharacterType);
- }
- if (_or) {
- _builder.append(instance, "");
- _builder.append(".");
- String _name = a.getName();
- final String[] _converted_values = (String[])values;
- String _get = ((List<String>)Conversions.doWrapArray(_converted_values)).get(0);
- String _valueLiteral = this.stdExt.toValueLiteral(((PrimitiveType) aType), _get);
- CharSequence _invokeSetter = this.helpers.invokeSetter(_name, className, _valueLiteral);
- _builder.append(_invokeSetter, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- int _size_1 = a.getSize();
- final String[] _converted_values_1 = (String[])values;
- int _size_2 = ((List<String>)Conversions.doWrapArray(_converted_values_1)).size();
- boolean _equals_2 = (_size_1 == _size_2);
- if (_equals_2) {
- _builder.append(instance, "");
- _builder.append(".");
- String _name_1 = a.getName();
- String _typeName = this.typeHelpers.typeName(aType);
- String _plus = ("new " + _typeName);
- String _plus_1 = (_plus + "[]");
- String _arrayValueLiteral = this.configExt.toArrayValueLiteral(((PrimitiveType) aType), values);
- String _plus_2 = (_plus_1 + _arrayValueLiteral);
- CharSequence _invokeSetter_1 = this.helpers.invokeSetter(_name_1, className, _plus_2);
- _builder.append(_invokeSetter_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- String _typeName_1 = this.typeHelpers.typeName(aType);
- _builder.append(_typeName_1, " ");
- _builder.append("[] array = ");
- _builder.append(instance, " ");
- _builder.append(".");
- String _name_2 = a.getName();
- CharSequence _invokeGetter = this.helpers.invokeGetter(_name_2, className);
- _builder.append(_invokeGetter, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (int i=0;i<");
- int _size_3 = a.getSize();
- _builder.append(_size_3, " ");
- _builder.append(";i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("array[i] = ");
- final String[] _converted_values_2 = (String[])values;
- String _get_1 = ((List<String>)Conversions.doWrapArray(_converted_values_2)).get(0);
- String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), _get_1);
- _builder.append(_valueLiteral_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
+ String value = this.dataConfigExt.getAttrInstanceConfigValue(ai, instancePath);
+ CharSequence _xifexpression_1 = null;
+ boolean _equals = Objects.equal(value, null);
+ if (_equals) {
+ StringConcatenation _builder = new StringConcatenation();
+ _xifexpression_1 = _builder;
+ } else {
+ CharSequence _xifexpression_2 = null;
+ boolean _or = false;
+ int _size = a.getSize();
+ boolean _equals_1 = (_size == 0);
+ if (_equals_1) {
+ _or = true;
+ } else {
+ boolean _isCharacterType = this.typeHelpers.isCharacterType(aType);
+ _or = (_equals_1 || _isCharacterType);
+ }
+ if (_or) {
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append(invokes, "");
+ _builder_1.append(".");
+ String _name = a.getName();
+ String _valueLiteral = this.stdExt.toValueLiteral(((PrimitiveType) aType), value);
+ CharSequence _invokeSetter = this.helpers.invokeSetter(_name, null, _valueLiteral);
+ _builder_1.append(_invokeSetter, "");
+ _builder_1.append(";");
+ _xifexpression_2 = _builder_1;
+ } else {
+ CharSequence _xifexpression_3 = null;
+ int _size_1 = a.getSize();
+ String[] _split = value.split(",");
+ int _size_2 = ((List<String>)Conversions.doWrapArray(_split)).size();
+ boolean _equals_2 = (_size_1 == _size_2);
+ if (_equals_2) {
+ CharSequence _xblockexpression_2 = null;
+ {
+ StringConcatenation _builder_2 = new StringConcatenation();
+ {
+ String[] _split_1 = value.split(",");
+ boolean _hasElements = false;
+ for(final String s : _split_1) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder_2.appendImmediate(",", "");
+ }
+ String _trim = s.trim();
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), _trim);
+ _builder_2.append(_valueLiteral_1, "");
+ }
}
+ CharSequence arrayExpr = _builder_2;
+ StringConcatenation _builder_3 = new StringConcatenation();
+ _builder_3.append(invokes, "");
+ _builder_3.append(".");
+ String _name_1 = a.getName();
+ StringConcatenation _builder_4 = new StringConcatenation();
+ _builder_4.append("new ");
+ String _typeName = this.typeHelpers.typeName(aType);
+ _builder_4.append(_typeName, "");
+ _builder_4.append("[]");
+ _builder_4.append(arrayExpr, "");
+ String _string = _builder_4.toString();
+ CharSequence _invokeSetter_1 = this.helpers.invokeSetter(_name_1, null, _string);
+ _builder_3.append(_invokeSetter_1, "");
+ _xblockexpression_2 = (_builder_3);
}
+ _xifexpression_3 = _xblockexpression_2;
+ } else {
+ StringConcatenation _builder_2 = new StringConcatenation();
+ _builder_2.append("{");
+ _builder_2.newLine();
+ _builder_2.append("\t\t\t\t\t\t");
+ String _typeName = this.typeHelpers.typeName(aType);
+ _builder_2.append(_typeName, " ");
+ _builder_2.append("[] array = ");
+ _builder_2.append(invokes, " ");
+ _builder_2.append(".");
+ String _name_1 = a.getName();
+ CharSequence _invokeGetter = this.helpers.invokeGetter(_name_1, null);
+ _builder_2.append(_invokeGetter, " ");
+ _builder_2.append(";");
+ _builder_2.newLineIfNotEmpty();
+ _builder_2.append("\t\t\t\t\t\t");
+ _builder_2.append("for (int i=0;i<");
+ int _size_3 = a.getSize();
+ _builder_2.append(_size_3, " ");
+ _builder_2.append(";i++){");
+ _builder_2.newLineIfNotEmpty();
+ _builder_2.append("\t\t\t\t\t\t\t");
+ _builder_2.append("array[i] = ");
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), value);
+ _builder_2.append(_valueLiteral_1, " ");
+ _builder_2.append(";");
+ _builder_2.newLineIfNotEmpty();
+ _builder_2.append("\t\t\t\t\t");
+ _builder_2.append("}");
+ _xifexpression_3 = _builder_2;
}
+ _xifexpression_2 = _xifexpression_3;
}
- } else {
- boolean _isDataClass = this.typeHelpers.isDataClass(aType);
- if (_isDataClass) {
- String _plus_3 = (instance + ".");
- String _name_3 = a.getName();
- CharSequence _invokeGetter_1 = this.helpers.invokeGetter(_name_3, className);
- String _plus_4 = (_plus_3 + _invokeGetter_1);
- String _typeName_2 = this.typeHelpers.typeName(aType);
- EList<AttrInstanceConfig> _attributes = attrConfig.getAttributes();
- CharSequence _applyInstanceConfig = this.applyInstanceConfig(_plus_4, _typeName_2, _attributes);
+ _xifexpression_1 = _xifexpression_2;
+ }
+ _xblockexpression_1 = (_xifexpression_1);
+ }
+ _xifexpression = _xblockexpression_1;
+ } else {
+ CharSequence _xifexpression_1 = null;
+ boolean _isDataClass = this.typeHelpers.isDataClass(aType);
+ if (_isDataClass) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<Attribute> _attributes = ((DataClass) aType).getAttributes();
+ for(final Attribute e : _attributes) {
+ _builder.newLineIfNotEmpty();
+ String _plus = (invokes + ".");
+ String _name = a.getName();
+ CharSequence _invokeGetter = this.helpers.invokeGetter(_name, null);
+ String _plus_1 = (_plus + _invokeGetter);
+ String _plus_2 = (instancePath + "/");
+ String _name_1 = e.getName();
+ String _plus_3 = (_plus_2 + _name_1);
+ CharSequence _applyInstanceConfig = this.applyInstanceConfig(ai, _plus_1, _plus_3, e);
_builder.append(_applyInstanceConfig, "");
_builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
}
}
+ _xifexpression_1 = _builder;
}
+ _xifexpression = _xifexpression_1;
}
+ _xblockexpression = (_xifexpression);
}
- return _builder;
+ return _xblockexpression;
+ }
+
+ public Object genDynConfigGetterSetter(final ActorClass ac) {
+ return null;
}
- public CharSequence genDynConfigGetterSetter(final ActorClass ac) {
+ public CharSequence genMinMaxConstants(final ActorClass ac) {
StringConcatenation _builder = new StringConcatenation();
{
- HashSet<Attribute> _dynConfigAttributes = this.configExt.getDynConfigAttributes(ac, true, false);
- for(final Attribute a : _dynConfigAttributes) {
- _builder.append("public ");
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this.typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- {
- int _size = a.getSize();
- boolean _greaterThan = (_size > 0);
- if (_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" get");
+ EList<Attribute> _attributes = ac.getAttributes();
+ for(final Attribute a : _attributes) {
String _name = a.getName();
- String _firstUpper = StringExtensions.toFirstUpper(_name);
- _builder.append(_firstUpper, "");
- _builder.append("(){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if(lock_");
- String _name_1 = a.getName();
- _builder.append(_name_1, " ");
- _builder.append(" == null)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("return ");
- String _name_2 = a.getName();
- _builder.append(_name_2, " ");
- _builder.append(";");
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
+ CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _name, _union);
+ _builder.append(_genMinMaxConstantsRec, "");
_builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("else");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("synchronized(lock_");
- String _name_3 = a.getName();
- _builder.append(_name_3, " ");
- _builder.append("){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("return ");
- String _name_4 = a.getName();
- _builder.append(_name_4, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("public void set");
- String _name_5 = a.getName();
- String _firstUpper_1 = StringExtensions.toFirstUpper(_name_5);
- _builder.append(_firstUpper_1, "");
- _builder.append("(");
- RefableType _refType_1 = a.getRefType();
- DataType _type_1 = _refType_1.getType();
- String _typeName_1 = this.typeHelpers.typeName(_type_1);
- _builder.append(_typeName_1, "");
- {
- int _size_1 = a.getSize();
- boolean _greaterThan_1 = (_size_1 > 0);
- if (_greaterThan_1) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_6 = a.getName();
- _builder.append(_name_6, "");
- _builder.append("){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if(lock_");
- String _name_7 = a.getName();
- _builder.append(_name_7, " ");
- _builder.append(" == null)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("this.");
- String _name_8 = a.getName();
- _builder.append(_name_8, " ");
- _builder.append(" = ");
- String _name_9 = a.getName();
- _builder.append(_name_9, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("else");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("synchronized(lock_");
- String _name_10 = a.getName();
- _builder.append(_name_10, " ");
- _builder.append("){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t\t");
- _builder.append("this.");
- String _name_11 = a.getName();
- _builder.append(_name_11, " ");
- _builder.append(" = ");
- String _name_12 = a.getName();
- _builder.append(_name_12, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("public DynConfigLock get");
- String _name_13 = a.getName();
- String _firstUpper_2 = StringExtensions.toFirstUpper(_name_13);
- _builder.append(_firstUpper_2, "");
- _builder.append("Lock(){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("return lock_");
- String _name_14 = a.getName();
- _builder.append(_name_14, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}\t");
- _builder.newLine();
}
}
- {
- HashSet<Attribute> _dynConfigAttributes_1 = this.configExt.getDynConfigAttributes(ac, false, true);
- for(final Attribute a_1 : _dynConfigAttributes_1) {
- _builder.append("public void setAndWrite");
- String _name_15 = a_1.getName();
- String _firstUpper_3 = StringExtensions.toFirstUpper(_name_15);
- _builder.append(_firstUpper_3, "");
- _builder.append("(");
- RefableType _refType_2 = a_1.getRefType();
- DataType _type_2 = _refType_2.getType();
- String _typeName_2 = this.typeHelpers.typeName(_type_2);
- _builder.append(_typeName_2, "");
- {
- int _size_2 = a_1.getSize();
- boolean _greaterThan_2 = (_size_2 > 0);
- if (_greaterThan_2) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_16 = a_1.getName();
- _builder.append(_name_16, "");
- _builder.append("){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("set");
- String _name_17 = a_1.getName();
- String _firstUpper_4 = StringExtensions.toFirstUpper(_name_17);
- _builder.append(_firstUpper_4, " ");
- _builder.append("(");
- String _name_18 = a_1.getName();
- _builder.append(_name_18, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("variableService.write(this.getInstancePath()+\"/");
- String _name_19 = a_1.getName();
- _builder.append(_name_19, " ");
- _builder.append("\", ");
- String _name_20 = a_1.getName();
- _builder.append(_name_20, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
+ CharSequence result = _builder;
+ int _length = result.length();
+ boolean _notEquals = (_length != 0);
+ if (_notEquals) {
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("//--------------------- Attribute Specifications");
+ String _plus = (result + _builder_1.toString());
+ result = _plus;
}
- return _builder;
+ return result;
}
- public CharSequence genMinMaxConstants(final ActorClass ac) {
+ private CharSequence genMinMaxConstantsRec(final ActorClass ac, final String varNamePath, final List<Attribute> path) {
CharSequence _xblockexpression = null;
{
- List<AttrClassConfig> _allAttrConfigFlat = this.configExt.getAllAttrConfigFlat(ac);
- final Function1<AttrClassConfig,Boolean> _function = new Function1<AttrClassConfig,Boolean>() {
- public Boolean apply(final AttrClassConfig c) {
- boolean _or = false;
- NumberLiteral _min = c.getMin();
- boolean _notEquals = (!Objects.equal(_min, null));
- if (_notEquals) {
- _or = true;
- } else {
- NumberLiteral _max = c.getMax();
- boolean _notEquals_1 = (!Objects.equal(_max, null));
- _or = (_notEquals || _notEquals_1);
- }
- return Boolean.valueOf(_or);
+ String temp = ((String) null);
+ CharSequence _xifexpression = null;
+ Attribute _last = IterableExtensions.<Attribute>last(path);
+ RefableType _refType = _last.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isDataClass = this.typeHelpers.isDataClass(_type);
+ if (_isDataClass) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ Attribute _last_1 = IterableExtensions.<Attribute>last(path);
+ RefableType _refType_1 = _last_1.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(((DataClass) _type_1));
+ for(final Attribute e : _allAttributes) {
+ String _plus = (varNamePath + "_");
+ String _name = e.getName();
+ String _plus_1 = (_plus + _name);
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
+ CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _plus_1, _union);
+ _builder.append(_genMinMaxConstantsRec, "");
+ _builder.newLineIfNotEmpty();
}
- };
- Iterable<AttrClassConfig> attrConfigs = IterableExtensions.<AttrClassConfig>filter(_allAttrConfigFlat, _function);
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _isEmpty = IterableExtensions.isEmpty(attrConfigs);
- boolean _not = (!_isEmpty);
- if (_not) {
- _builder.append("//--------------------- attribute specifications");
- _builder.newLine();
}
- }
- _builder.append("\t");
- _builder.newLine();
- {
- for(final AttrClassConfig c : attrConfigs) {
- Attribute _attribute = c.getAttribute();
- RefableType _refType = _attribute.getRefType();
- DataType _type = _refType.getType();
- PrimitiveType aType = ((PrimitiveType) _type);
- _builder.newLineIfNotEmpty();
+ _xifexpression = _builder;
+ } else {
+ CharSequence _xblockexpression_1 = null;
+ {
+ Attribute _last_2 = IterableExtensions.<Attribute>last(path);
+ RefableType _refType_2 = _last_2.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ PrimitiveType aType = ((PrimitiveType) _type_2);
+ StringConcatenation _builder_1 = new StringConcatenation();
{
- NumberLiteral _min = c.getMin();
- boolean _notEquals = (!Objects.equal(_min, null));
+ String _attrClassConfigMinValue = this.dataConfigExt.getAttrClassConfigMinValue(ac, path);
+ String _temp = temp = _attrClassConfigMinValue;
+ boolean _notEquals = (!Objects.equal(_temp, null));
if (_notEquals) {
- _builder.append("public static ");
+ _builder_1.append("public static ");
String _minMaxType = this.getMinMaxType(aType);
- _builder.append(_minMaxType, "");
- _builder.append(" MIN");
- List<String> _path = this.configExt.getPath(c, false, false, true, true);
- String _path_1 = this.configExt.toPath(_path, "_");
- _builder.append(_path_1, "");
- _builder.append(" = ");
- NumberLiteral _min_1 = c.getMin();
- String _value = this.configExt.getValue(_min_1);
- String _valueLiteral = this.stdExt.toValueLiteral(aType, _value);
- _builder.append(_valueLiteral, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
+ _builder_1.append(_minMaxType, "");
+ _builder_1.append(" MIN_");
+ _builder_1.append(varNamePath, "");
+ _builder_1.append(" = ");
+ String _valueLiteral = this.stdExt.toValueLiteral(aType, temp);
+ _builder_1.append(_valueLiteral, "");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
}
}
{
- NumberLiteral _max = c.getMax();
- boolean _notEquals_1 = (!Objects.equal(_max, null));
+ String _attrClassConfigMaxValue = this.dataConfigExt.getAttrClassConfigMaxValue(ac, path);
+ String _temp_1 = temp = _attrClassConfigMaxValue;
+ boolean _notEquals_1 = (!Objects.equal(_temp_1, null));
if (_notEquals_1) {
- _builder.append("public static ");
+ _builder_1.append("public static ");
String _minMaxType_1 = this.getMinMaxType(aType);
- _builder.append(_minMaxType_1, "");
- _builder.append(" MAX");
- List<String> _path_2 = this.configExt.getPath(c, false, false, true, true);
- String _path_3 = this.configExt.toPath(_path_2, "_");
- _builder.append(_path_3, "");
- _builder.append(" = ");
- NumberLiteral _max_1 = c.getMax();
- String _value_1 = this.configExt.getValue(_max_1);
- String _valueLiteral_1 = this.stdExt.toValueLiteral(aType, _value_1);
- _builder.append(_valueLiteral_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
+ _builder_1.append(_minMaxType_1, "");
+ _builder_1.append(" MAX_");
+ _builder_1.append(varNamePath, "");
+ _builder_1.append(" = ");
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(aType, temp);
+ _builder_1.append(_valueLiteral_1, "");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
}
}
+ _xblockexpression_1 = (_builder_1);
}
+ _xifexpression = _xblockexpression_1;
}
- _xblockexpression = (_builder);
+ _xblockexpression = (_xifexpression);
}
return _xblockexpression;
}
private String getMinMaxType(final PrimitiveType type) {
+ String _switchResult = null;
String _typeName = this.typeHelpers.typeName(type);
final String _switchValue = _typeName;
boolean _matched = false;
if (!_matched) {
if (Objects.equal(_switchValue,"byte")) {
_matched=true;
- return "int";
+ _switchResult = "int";
}
}
if (!_matched) {
if (Objects.equal(_switchValue,"short")) {
_matched=true;
- return "int";
+ _switchResult = "int";
}
}
if (!_matched) {
if (Objects.equal(_switchValue,"float")) {
_matched=true;
- return "double";
+ _switchResult = "double";
}
}
- return this.typeHelpers.typeName(type);
+ if (!_matched) {
+ String _typeName_1 = this.typeHelpers.typeName(type);
+ _switchResult = _typeName_1;
+ }
+ return _switchResult;
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
index c694b08..7321933 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/DataClassGen.java
@@ -164,7 +164,7 @@ public class DataClassGen {
_builder.newLine();
_builder.append("\t\t");
EList<Attribute> _attributes_3 = dc.getAttributes();
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes_3, true);
+ CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes_3, dc, true);
_builder.append(_attributeInitialization, " ");
_builder.newLineIfNotEmpty();
{
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
index 41fdc15..0beac50 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java
@@ -3,38 +3,95 @@ package org.eclipse.etrice.generator.java.gen;
import com.google.common.base.Objects;
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.util.ArrayList;
import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.room.ActorClass;
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.core.room.DataType;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.generator.generic.ConfigExtension;
+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.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
@Singleton
@SuppressWarnings("all")
public class Initialization {
@Inject
- private ConfigExtension _configExtension;
+ private TypeHelpers _typeHelpers;
@Inject
- private TypeHelpers _typeHelpers;
+ private RoomExtensions _roomExtensions;
@Inject
private ILanguageExtension languageExt;
- public CharSequence attributeInitialization(final List<Attribute> attribs, final boolean useClassDefaultsOnly) {
+ @Inject
+ private IDataConfiguration dataConfigExt;
+
+ public CharSequence attributeInitialization(final List<Attribute> attribs, final EObject roomClass, final boolean useClassDefaultsOnly) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("// initialize attributes");
_builder.newLine();
{
for(final Attribute a : attribs) {
- RefableType _refType = a.getRefType();
- DataType aType = _refType.getType();
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
+ CharSequence _attributeInit = this.attributeInit(roomClass, _union, useClassDefaultsOnly);
+ _builder.append(_attributeInit, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ private CharSequence attributeInit(final EObject roomClass, final List<Attribute> path, final boolean useClassDefaultsOnly) {
+ CharSequence _xblockexpression = null;
+ {
+ Attribute a = IterableExtensions.<Attribute>last(path);
+ CharSequence _xifexpression = null;
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(_type);
+ if (_isDataClass) {
+ CharSequence _xblockexpression_1 = null;
+ {
+ StringConcatenation _builder = new StringConcatenation();
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ EList<Attribute> _attributes = ((DataClass) _type_1).getAttributes();
+ final Procedure1<Attribute> _function = new Procedure1<Attribute>() {
+ public void apply(final Attribute e) {
+ List<Attribute> _union = Initialization.this._roomExtensions.<Attribute>union(path, e);
+ Initialization.this.attributeInit(roomClass, _union, useClassDefaultsOnly);
+ }
+ };
+ IterableExtensions.<Attribute>forEach(_attributes, _function);
+ CharSequence result = _builder;
+ CharSequence _xifexpression_1 = null;
+ int _length = result.length();
+ boolean _greaterThan = (_length > 0);
+ if (_greaterThan) {
+ _xifexpression_1 = result;
+ }
+ _xblockexpression_1 = (_xifexpression_1);
+ }
+ _xifexpression = _xblockexpression_1;
+ } else {
+ StringConcatenation _builder = new StringConcatenation();
+ RefableType _refType_1 = a.getRefType();
+ DataType aType = _refType_1.getType();
_builder.newLineIfNotEmpty();
- String value = this._configExtension.getInitValueLiteral(a);
+ String value = this.getInitValueLiteral(a, roomClass);
_builder.newLineIfNotEmpty();
{
boolean _notEquals = (!Objects.equal(value, null));
@@ -118,8 +175,8 @@ public class Initialization {
boolean _equals_1 = (_size_4 == 0);
if (_equals_1) {
{
- RefableType _refType_1 = a.getRefType();
- boolean _isRef = _refType_1.isRef();
+ RefableType _refType_2 = a.getRefType();
+ boolean _isRef = _refType_2.isRef();
if (_isRef) {
String _name_4 = a.getName();
_builder.append(_name_4, "");
@@ -162,8 +219,8 @@ public class Initialization {
_builder.append(_name_7, " ");
_builder.append("[i] = ");
{
- RefableType _refType_2 = a.getRefType();
- boolean _isRef_1 = _refType_2.isRef();
+ RefableType _refType_3 = a.getRefType();
+ boolean _isRef_1 = _refType_3.isRef();
if (_isRef_1) {
String _nullPointer_1 = this.languageExt.nullPointer();
_builder.append(_nullPointer_1, " ");
@@ -183,8 +240,88 @@ public class Initialization {
}
}
}
+ _xifexpression = _builder;
}
+ _xblockexpression = (_xifexpression);
}
- return _builder;
+ return _xblockexpression;
+ }
+
+ private String getInitValueLiteral(final Attribute a, final EObject roomClass) {
+ String _xblockexpression = null;
+ {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (_isPrimitive) {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ PrimitiveType aType = ((PrimitiveType) _type_1);
+ String _switchResult = null;
+ boolean _matched = false;
+ if (!_matched) {
+ if (roomClass instanceof ActorClass) {
+ final ActorClass _actorClass = (ActorClass)roomClass;
+ _matched=true;
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
+ String _attrClassConfigValue = this.dataConfigExt.getAttrClassConfigValue(_actorClass, _union);
+ _switchResult = _attrClassConfigValue;
+ }
+ }
+ if (!_matched) {
+ if (roomClass instanceof PortClass) {
+ final PortClass _portClass = (PortClass)roomClass;
+ _matched=true;
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
+ String _attrClassConfigValue = this.dataConfigExt.getAttrClassConfigValue(_portClass, _union);
+ _switchResult = _attrClassConfigValue;
+ }
+ }
+ String result = _switchResult;
+ boolean _notEquals = (!Objects.equal(result, null));
+ if (_notEquals) {
+ String _xifexpression = null;
+ boolean _or = false;
+ int _size = a.getSize();
+ boolean _equals = (_size == 0);
+ if (_equals) {
+ _or = true;
+ } else {
+ boolean _isCharacterType = this._typeHelpers.isCharacterType(aType);
+ _or = (_equals || _isCharacterType);
+ }
+ if (_or) {
+ String _valueLiteral = this.languageExt.toValueLiteral(aType, result);
+ _xifexpression = _valueLiteral;
+ } else {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("{ ");
+ {
+ String[] _split = result.split(",");
+ boolean _hasElements = false;
+ for(final String s : _split) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(" ,", "");
+ }
+ String _trim = s.trim();
+ String _valueLiteral_1 = this.languageExt.toValueLiteral(aType, _trim);
+ _builder.append(_valueLiteral_1, "");
+ }
+ }
+ _builder.append(" }");
+ String _string = _builder.toString();
+ _xifexpression = _string;
+ }
+ return _xifexpression;
+ }
+ }
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ _xblockexpression = (_defaultValueLiteral);
+ }
+ return _xblockexpression;
}
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
index d1857cd..6526e87 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ProtocolClassGen.java
@@ -252,7 +252,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
if (_notEquals_1) {
_builder.append("\t\t");
EList<Attribute> _attributes = pclass.getAttributes();
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes, true);
+ CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes, pc, true);
_builder.append(_attributeInitialization, " ");
_builder.newLineIfNotEmpty();
}
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
index b11ff3f..369741d 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java
@@ -2,23 +2,19 @@ package org.eclipse.etrice.generator.java.gen;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.config.AttrInstanceConfig;
-import org.eclipse.etrice.core.config.PortInstanceConfig;
import org.eclipse.etrice.core.genmodel.base.ILogger;
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.LogicalThread;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
import org.eclipse.etrice.generator.base.Indexed;
-import org.eclipse.etrice.generator.generic.ConfigExtension;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.java.gen.ConfigGenAddon;
@@ -26,8 +22,8 @@ import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.etrice.generator.java.gen.VariableServiceGen;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
@Singleton
@SuppressWarnings("all")
@@ -42,10 +38,10 @@ public class SubSystemClassGen {
private RoomExtensions _roomExtensions;
@Inject
- private ConfigExtension _configExtension;
+ private IDataConfiguration dataConfigExt;
@Inject
- private ConfigGenAddon configAddon;
+ private ConfigGenAddon configGenAddon;
@Inject
private ProcedureHelpers _procedureHelpers;
@@ -76,11 +72,6 @@ public class SubSystemClassGen {
SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
CharSequence _generate = this.generate(root, ssi, _subSystemClass_3);
this.fileAccess.generateFile(file, _generate);
- SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
- boolean _hasVariableService = this._configExtension.hasVariableService(_subSystemClass_4);
- if (_hasVariableService) {
- this.varService.doGenerate(root, ssi);
- }
}
}
}
@@ -94,7 +85,7 @@ public class SubSystemClassGen {
_builder.newLineIfNotEmpty();
_builder.newLine();
{
- boolean _hasVariableService = this._configExtension.hasVariableService(cc);
+ boolean _hasVariableService = this.dataConfigExt.hasVariableService(cc);
if (_hasVariableService) {
_builder.append("import org.eclipse.etrice.runtime.java.config.VariableService;");
}
@@ -576,15 +567,7 @@ public class SubSystemClassGen {
_builder.append("}");
_builder.newLine();
{
- List<AttrInstanceConfig> _configAttributes = this._configExtension.getConfigAttributes(ai_2);
- final Function1<AttrInstanceConfig,Boolean> _function = new Function1<AttrInstanceConfig,Boolean>() {
- public Boolean apply(final AttrInstanceConfig c) {
- boolean _isDynConfig = c.isDynConfig();
- return Boolean.valueOf(_isDynConfig);
- }
- };
- boolean _exists = IterableExtensions.<AttrInstanceConfig>exists(_configAttributes, _function);
- if (_exists) {
+ if (false) {
_builder.append("\t\t");
_builder.append("\t");
_builder.append(", variableService");
@@ -601,74 +584,15 @@ public class SubSystemClassGen {
_builder.append("\t\t");
_builder.append("// apply instance attribute configurations");
_builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
- for(final ActorInstance ai_3 : _allContainedInstances_8) {
- {
- boolean _and_1 = false;
- List<AttrInstanceConfig> _configAttributes_1 = this._configExtension.getConfigAttributes(ai_3);
- boolean _isEmpty_5 = _configAttributes_1.isEmpty();
- if (!_isEmpty_5) {
- _and_1 = false;
- } else {
- List<PortInstanceConfig> _configPorts = this._configExtension.getConfigPorts(ai_3);
- boolean _isEmpty_6 = _configPorts.isEmpty();
- _and_1 = (_isEmpty_5 && _isEmpty_6);
- }
- boolean _not_2 = (!_and_1);
- if (_not_2) {
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- ActorClass _actorClass_1 = ai_3.getActorClass();
- String _name_6 = _actorClass_1.getName();
- _builder.append(_name_6, " ");
- _builder.append(" inst = (");
- ActorClass _actorClass_2 = ai_3.getActorClass();
- String _name_7 = _actorClass_2.getName();
- _builder.append(_name_7, " ");
- _builder.append(") instances[");
- EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
- int _indexOf_7 = _allContainedInstances_9.indexOf(ai_3);
- _builder.append(_indexOf_7, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- ActorClass _actorClass_3 = ai_3.getActorClass();
- String _name_8 = _actorClass_3.getName();
- List<AttrInstanceConfig> _configAttributes_2 = this._configExtension.getConfigAttributes(ai_3);
- CharSequence _applyInstanceConfig = this.configAddon.applyInstanceConfig("inst", _name_8, _configAttributes_2);
- _builder.append(_applyInstanceConfig, " ");
- _builder.newLineIfNotEmpty();
- {
- List<PortInstanceConfig> _configPorts_1 = this._configExtension.getConfigPorts(ai_3);
- for(final PortInstanceConfig portConfig : _configPorts_1) {
- _builder.append("\t\t");
- _builder.append("\t");
- InterfaceItem _item = portConfig.getItem();
- String _name_9 = _item.getName();
- ActorClass _actorClass_4 = ai_3.getActorClass();
- String _name_10 = _actorClass_4.getName();
- CharSequence _invokeGetter = this._procedureHelpers.invokeGetter(_name_9, _name_10);
- String _plus_2 = ("inst." + _invokeGetter);
- InterfaceItem _item_1 = portConfig.getItem();
- String _portClassName = this._roomExtensions.getPortClassName(_item_1);
- EList<AttrInstanceConfig> _attributes = portConfig.getAttributes();
- CharSequence _applyInstanceConfig_1 = this.configAddon.applyInstanceConfig(_plus_2, _portClassName, _attributes);
- _builder.append(_applyInstanceConfig_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
+ _builder.append("\t\t");
+ EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
+ final Procedure1<ActorInstance> _function = new Procedure1<ActorInstance>() {
+ public void apply(final ActorInstance ai) {
+ SubSystemClassGen.this.configGenAddon.genActorInstanceConfig(ai);
}
- }
- }
+ };
+ IterableExtensions.<ActorInstance>forEach(_allContainedInstances_8, _function);
+ _builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t\t");
_builder.append("// create the subsystem system port\t");
@@ -686,9 +610,9 @@ public class SubSystemClassGen {
_builder.append("new Address[]{");
_builder.newLine();
{
- EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
+ EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
boolean _hasElements_4 = false;
- for(final ActorInstance ai_4 : _allContainedInstances_10) {
+ for(final ActorInstance ai_3 : _allContainedInstances_9) {
if (!_hasElements_4) {
_hasElements_4 = true;
} else {
@@ -696,9 +620,9 @@ public class SubSystemClassGen {
}
_builder.append("\t\t\t\t\t");
_builder.append("addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
- int _indexOf_8 = _allContainedInstances_11.indexOf(ai_4);
- _builder.append(_indexOf_8, " ");
+ EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
+ int _indexOf_7 = _allContainedInstances_10.indexOf(ai_3);
+ _builder.append(_indexOf_7, " ");
_builder.newLineIfNotEmpty();
}
}
@@ -712,9 +636,9 @@ public class SubSystemClassGen {
_builder.append("new Address[]{");
_builder.newLine();
{
- EList<ActorInstance> _allContainedInstances_12 = comp.getAllContainedInstances();
+ EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
boolean _hasElements_5 = false;
- for(final ActorInstance ai_5 : _allContainedInstances_12) {
+ for(final ActorInstance ai_4 : _allContainedInstances_11) {
if (!_hasElements_5) {
_hasElements_5 = true;
} else {
@@ -722,7 +646,7 @@ public class SubSystemClassGen {
}
_builder.append("\t\t\t\t\t");
_builder.append("addr_item_");
- String _path_10 = ai_5.getPath();
+ String _path_10 = ai_4.getPath();
String _pathName_8 = this._roomExtensions.getPathName(_path_10);
_builder.append(_pathName_8, " ");
_builder.newLineIfNotEmpty();
@@ -737,7 +661,7 @@ public class SubSystemClassGen {
_builder.append("\t");
_builder.newLine();
{
- boolean _hasVariableService_1 = this._configExtension.hasVariableService(cc);
+ boolean _hasVariableService_1 = this.dataConfigExt.hasVariableService(cc);
if (_hasVariableService_1) {
_builder.append("\t\t");
_builder.append("private VariableService variableService;");
@@ -753,12 +677,12 @@ public class SubSystemClassGen {
_builder.append("public void init(){");
_builder.newLine();
{
- boolean _hasVariableService_2 = this._configExtension.hasVariableService(cc);
+ boolean _hasVariableService_2 = this.dataConfigExt.hasVariableService(cc);
if (_hasVariableService_2) {
_builder.append("\t\t\t");
_builder.append("variableService = new ");
- String _name_11 = comp.getName();
- _builder.append(_name_11, " ");
+ String _name_6 = comp.getName();
+ _builder.append(_name_6, " ");
_builder.append("VariableService(this);");
_builder.newLineIfNotEmpty();
}
@@ -767,7 +691,7 @@ public class SubSystemClassGen {
_builder.append("super.init();");
_builder.newLine();
{
- boolean _hasVariableService_3 = this._configExtension.hasVariableService(cc);
+ boolean _hasVariableService_3 = this.dataConfigExt.hasVariableService(cc);
if (_hasVariableService_3) {
_builder.append("\t\t\t");
_builder.append("variableService.init();");
@@ -789,7 +713,7 @@ public class SubSystemClassGen {
_builder.append("super.stop();");
_builder.newLine();
{
- boolean _hasVariableService_4 = this._configExtension.hasVariableService(cc);
+ boolean _hasVariableService_4 = this.dataConfigExt.hasVariableService(cc);
if (_hasVariableService_4) {
_builder.append("\t\t\t");
_builder.append("variableService.stop();");
diff --git a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
index bee7d72..c63f887 100644
--- a/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
@@ -1,50 +1,14 @@
package org.eclipse.etrice.generator.java.gen;
-import com.google.common.base.Objects;
-import com.google.common.collect.Iterables;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.config.ActorClassConfig;
-import org.eclipse.etrice.core.config.ActorInstanceConfig;
-import org.eclipse.etrice.core.config.AttrClassConfig;
-import org.eclipse.etrice.core.config.AttrInstanceConfig;
-import org.eclipse.etrice.core.config.DynamicConfig;
-import org.eclipse.etrice.core.config.NumberLiteral;
-import org.eclipse.etrice.core.config.RefPath;
-import org.eclipse.etrice.core.config.SubSystemConfig;
import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.generic.ConfigExtension;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Conversions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
@Singleton
@SuppressWarnings("all")
@@ -59,7 +23,7 @@ public class VariableServiceGen {
private RoomExtensions roomExt;
@Inject
- private ConfigExtension configExt;
+ private IDataConfiguration configExt;
@Inject
private ProcedureHelpers helpers;
@@ -69,904 +33,4 @@ public class VariableServiceGen {
@Inject
private ILogger logger;
-
- public void doGenerate(final Root root, final SubSystemInstance ssi) {
- SubSystemClass _subSystemClass = ssi.getSubSystemClass();
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
- String _path = this.roomExt.getPath(_subSystemClass_1);
- String path = (_generationTargetPath + _path);
- SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String _name = _subSystemClass_2.getName();
- String file = (_name + "VariableService.java");
- String _plus = ("generating VariableService implementation: \'" + file);
- String _plus_1 = (_plus + "\' in \'");
- String _plus_2 = (_plus_1 + path);
- String _plus_3 = (_plus_2 + "\'");
- this.logger.logInfo(_plus_3);
- this.fileAccess.setOutputPath(path);
- SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
- CharSequence _generate = this.generate(root, ssi, _subSystemClass_3);
- this.fileAccess.generateFile(file, _generate);
- }
-
- private CharSequence generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
- StringConcatenation _builder = new StringConcatenation();
- SubSystemConfig _subSystemConfig = this.configExt.getSubSystemConfig(cc);
- final DynamicConfig dynConfig = _subSystemConfig.getDynConfig();
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("package ");
- String _package = this.roomExt.getPackage(cc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("import java.util.Arrays;");
- _builder.newLine();
- _builder.append("import java.util.HashMap;");
- _builder.newLine();
- _builder.append("import java.util.Map;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.config.VariableService;");
- _builder.newLine();
- {
- String _userCode1 = dynConfig.getUserCode1();
- boolean _notEquals = (!Objects.equal(_userCode1, null));
- if (_notEquals) {
- String _userCode1_1 = dynConfig.getUserCode1();
- _builder.append(_userCode1_1, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("import org.eclipse.etrice.runtime.java.config.ConfigSourceFile;");
- _builder.newLine();
- }
- }
- List<ActorInstance> ais = this.dynConfigsAIs(comp);
- _builder.newLineIfNotEmpty();
- {
- HashSet<RoomModel> _roomModels = this.getRoomModels(ais);
- for(final RoomModel model : _roomModels) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.newLine();
- _builder.append("public class ");
- String _name_1 = comp.getName();
- String _plus = (_name_1 + "VariableService");
- _builder.append(_plus, "");
- _builder.append(" extends VariableService{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("private ");
- String _name_2 = cc.getName();
- _builder.append(_name_2, " ");
- _builder.append(" subSystem;");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// Actor instances");
- _builder.newLine();
- {
- for(final ActorInstance ai : ais) {
- _builder.append("\t");
- _builder.append("private ");
- ActorClass _actorClass = ai.getActorClass();
- String _name_3 = _actorClass.getName();
- _builder.append(_name_3, " ");
- _builder.append(" ");
- String _path = ai.getPath();
- String[] _split = _path.split("/");
- Iterable<String> _drop = IterableExtensions.<String>drop(((Iterable<String>)Conversions.doWrapArray(_split)), 2);
- String _path_1 = this.configExt.toPath(_drop, "_");
- _builder.append(_path_1, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_4 = comp.getName();
- String _plus_1 = (_name_4 + "VariableService");
- _builder.append(_plus_1, " ");
- _builder.append("(");
- String _name_5 = cc.getName();
- _builder.append(_name_5, " ");
- _builder.append(" subSystem) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super(");
- {
- String _filePath = dynConfig.getFilePath();
- boolean _notEquals_1 = (!Objects.equal(_filePath, null));
- if (_notEquals_1) {
- _builder.append("new ConfigSourceFile(\"");
- String _filePath_1 = dynConfig.getFilePath();
- _builder.append(_filePath_1, " ");
- _builder.append("\")");
- } else {
- String _userCode2 = dynConfig.getUserCode2();
- _builder.append(_userCode2, " ");
- }
- }
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("this.subSystem = subSystem;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("protected void initInstances(){");
- _builder.newLine();
- {
- for(final ActorInstance ai_1 : ais) {
- _builder.append("\t\t");
- String _path_2 = ai_1.getPath();
- String[] _split_1 = _path_2.split("/");
- Iterable<String> _drop_1 = IterableExtensions.<String>drop(((Iterable<String>)Conversions.doWrapArray(_split_1)), 2);
- String _path_3 = this.configExt.toPath(_drop_1, "_");
- _builder.append(_path_3, " ");
- _builder.append(" = (");
- ActorClass _actorClass_1 = ai_1.getActorClass();
- String _name_6 = _actorClass_1.getName();
- _builder.append(_name_6, " ");
- _builder.append(")subSystem.getInstance(\"");
- String _path_4 = ai_1.getPath();
- _builder.append(_path_4, " ");
- _builder.append("\");");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("protected void setAttributeValues(Map<String, Object> values) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("Object object;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("String id = null;");
- _builder.newLine();
- {
- Iterable<AttrInstanceConfig> _attrDynConfigs = this.configExt.getAttrDynConfigs(cc, true, false);
- for(final AttrInstanceConfig attrConfig : _attrDynConfigs) {
- _builder.append("\t\t");
- EObject _eContainer = attrConfig.eContainer();
- RefPath _path_5 = ((ActorInstanceConfig) _eContainer).getPath();
- EList<String> _refs = _path_5.getRefs();
- String aiName = this.configExt.toPath(_refs, "_");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("try{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("boolean changed = false;");
- _builder.newLine();
- {
- Map<Attribute,List<String>> _allAttributes = this.getAllAttributes(attrConfig);
- Set<Entry<Attribute,List<String>>> _entrySet = _allAttributes.entrySet();
- for(final Entry<Attribute,List<String>> entry : _entrySet) {
- _builder.append("\t\t");
- _builder.append("\t");
- Attribute a = entry.getKey();
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- List<String> _path_6 = this.configExt.getPath(attrConfig, true, true, true, false);
- String _path_7 = this.configExt.toPath(_path_6, "/");
- List<String> _value = entry.getValue();
- String _path_8 = this.configExt.toPath(_value, "/");
- String _plus_2 = (_path_7 + _path_8);
- String _plus_3 = (_plus_2 + "/");
- String _name_7 = a.getName();
- String aPath = (_plus_3 + _name_7);
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("id = \"");
- _builder.append(aPath, " ");
- _builder.append("\";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- {
- int _size = a.getSize();
- boolean _equals = (_size == 0);
- if (_equals) {
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- String _wrapper = this.stdExt.toWrapper(_typeName);
- _builder.append(_wrapper, " ");
- } else {
- RefableType _refType_1 = a.getRefType();
- DataType _type_1 = _refType_1.getType();
- String _typeName_1 = this._typeHelpers.typeName(_type_1);
- _builder.append(_typeName_1, " ");
- _builder.append("[]");
- }
- }
- _builder.append(" _");
- String _name_8 = a.getName();
- _builder.append(_name_8, " ");
- _builder.append(" = null;");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("object = values.get(id);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("if(object != null){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("_");
- String _name_9 = a.getName();
- _builder.append(_name_9, " ");
- _builder.append(" = ensure");
- RefableType _refType_2 = a.getRefType();
- DataType _type_2 = _refType_2.getType();
- String _typeName_2 = this._typeHelpers.typeName(_type_2);
- String _firstUpper = StringExtensions.toFirstUpper(_typeName_2);
- _builder.append(_firstUpper, " ");
- {
- int _size_1 = a.getSize();
- boolean _greaterThan = (_size_1 > 0);
- if (_greaterThan) {
- _builder.append("Array");
- }
- }
- _builder.append("(object");
- {
- int _size_2 = a.getSize();
- boolean _greaterThan_1 = (_size_2 > 0);
- if (_greaterThan_1) {
- _builder.append(", ");
- int _size_3 = a.getSize();
- _builder.append(_size_3, " ");
- }
- }
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- EObject _eContainer_1 = attrConfig.eContainer();
- ActorClassConfig _actorClassConfig = this.configExt.getActorClassConfig(((ActorInstanceConfig) _eContainer_1));
- CharSequence _genMinMaxCheck = this.genMinMaxCheck(attrConfig, _actorClassConfig);
- _builder.append(_genMinMaxCheck, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("if(!");
- {
- int _size_4 = a.getSize();
- boolean _equals_1 = (_size_4 == 0);
- if (_equals_1) {
- _builder.append("_");
- String _name_10 = a.getName();
- _builder.append(_name_10, " ");
- _builder.append(".equals(");
- } else {
- _builder.append("Arrays.equals(_");
- String _name_11 = a.getName();
- _builder.append(_name_11, " ");
- _builder.append(", ");
- }
- }
- _builder.append("(");
- {
- int _size_5 = a.getSize();
- boolean _equals_2 = (_size_5 == 0);
- if (_equals_2) {
- RefableType _refType_3 = a.getRefType();
- DataType _type_3 = _refType_3.getType();
- String _typeName_3 = this._typeHelpers.typeName(_type_3);
- String _wrapper_1 = this.stdExt.toWrapper(_typeName_3);
- _builder.append(_wrapper_1, " ");
- } else {
- RefableType _refType_4 = a.getRefType();
- DataType _type_4 = _refType_4.getType();
- String _typeName_4 = this._typeHelpers.typeName(_type_4);
- _builder.append(_typeName_4, " ");
- _builder.append("[]");
- }
- }
- _builder.append(")getDiffMap().get(id)))");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append("changed = true;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("} else");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("warning(id, \"is missing\");");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("if(changed)");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("synchronized(");
- _builder.append(aiName, " ");
- _builder.append(".");
- Attribute _attribute = attrConfig.getAttribute();
- String _name_12 = _attribute.getName();
- String _plus_4 = (_name_12 + "Lock");
- CharSequence _invokeGetter = this.helpers.invokeGetter(_plus_4, null);
- _builder.append(_invokeGetter, " ");
- _builder.append("){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t\t\t");
- _builder.append("if(");
- _builder.append(aiName, " ");
- _builder.append(".");
- Attribute _attribute_1 = attrConfig.getAttribute();
- String _name_13 = _attribute_1.getName();
- String _plus_5 = (_name_13 + "Lock");
- CharSequence _invokeGetter_1 = this.helpers.invokeGetter(_plus_5, null);
- _builder.append(_invokeGetter_1, " ");
- _builder.append(".isUpdate()){");
- _builder.newLineIfNotEmpty();
- {
- Map<Attribute,List<String>> _allAttributes_1 = this.getAllAttributes(attrConfig);
- Set<Entry<Attribute,List<String>>> _entrySet_1 = _allAttributes_1.entrySet();
- for(final Entry<Attribute,List<String>> entry_1 : _entrySet_1) {
- _builder.append("\t\t");
- _builder.append("\t\t\t\t");
- _builder.append("if(_");
- Attribute _key = entry_1.getKey();
- String _name_14 = _key.getName();
- _builder.append(_name_14, " ");
- _builder.append(" != null){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append(aiName, " ");
- List<String> _value_1 = entry_1.getValue();
- String _invoke = this.toInvoke(_value_1);
- _builder.append(_invoke, " ");
- _builder.append(".");
- Attribute _key_1 = entry_1.getKey();
- String _name_15 = _key_1.getName();
- Attribute _key_2 = entry_1.getKey();
- String _name_16 = _key_2.getName();
- String _plus_6 = ("_" + _name_16);
- CharSequence _invokeSetter = this.helpers.invokeSetter(_name_15, null, _plus_6);
- _builder.append(_invokeSetter, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t\t\t\t");
- _builder.append("\t");
- _builder.append("getDiffMap().put(\"");
- List<String> _path_9 = this.configExt.getPath(attrConfig, true, true, true, false);
- String _path_10 = this.configExt.toPath(_path_9, "/");
- List<String> _value_2 = entry_1.getValue();
- String _path_11 = this.configExt.toPath(_value_2, "/");
- String _plus_7 = (_path_10 + _path_11);
- String _plus_8 = (_plus_7 + "/");
- Attribute _key_3 = entry_1.getKey();
- String _name_17 = _key_3.getName();
- String _plus_9 = (_plus_8 + _name_17);
- _builder.append(_plus_9, " ");
- _builder.append("\", _");
- Attribute _key_4 = entry_1.getKey();
- String _name_18 = _key_4.getName();
- _builder.append(_name_18, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t\t\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t\t\t");
- _builder.append("} ");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}catch(IllegalArgumentException e){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("error(id, e);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("protected Map<String, Object> getAttributeValues(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("Map<String, Object> values = new HashMap<String, Object>();");
- _builder.newLine();
- {
- Iterable<AttrInstanceConfig> _attrDynConfigs_1 = this.configExt.getAttrDynConfigs(cc, true, false);
- for(final AttrInstanceConfig attrConfig_1 : _attrDynConfigs_1) {
- _builder.append("\t\t");
- EObject _eContainer_2 = attrConfig_1.eContainer();
- RefPath _path_12 = ((ActorInstanceConfig) _eContainer_2).getPath();
- EList<String> _refs_1 = _path_12.getRefs();
- String aiName_1 = this.configExt.toPath(_refs_1, "_");
- _builder.newLineIfNotEmpty();
- {
- Map<Attribute,List<String>> _allAttributes_2 = this.getAllAttributes(attrConfig_1);
- Set<Entry<Attribute,List<String>>> _entrySet_2 = _allAttributes_2.entrySet();
- for(final Entry<Attribute,List<String>> entry_2 : _entrySet_2) {
- _builder.append("\t\t");
- Attribute _key_5 = entry_2.getKey();
- int _size_6 = _key_5.getSize();
- boolean array = (_size_6 > 0);
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- List<String> _path_13 = this.configExt.getPath(attrConfig_1, true, true, true, false);
- String _path_14 = this.configExt.toPath(_path_13, "/");
- List<String> _value_3 = entry_2.getValue();
- String _path_15 = this.configExt.toPath(_value_3, "/");
- String _plus_10 = (_path_14 + _path_15);
- String _plus_11 = (_plus_10 + "/");
- Attribute _key_6 = entry_2.getKey();
- String _name_19 = _key_6.getName();
- String aPath_1 = (_plus_11 + _name_19);
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("values.put(\"");
- _builder.append(aPath_1, " ");
- _builder.append("\", ");
- {
- if (array) {
- _builder.append("toObjectArray(");
- }
- }
- _builder.append(aiName_1, " ");
- List<String> _value_4 = entry_2.getValue();
- String _invoke_1 = this.toInvoke(_value_4);
- _builder.append(_invoke_1, " ");
- _builder.append(".");
- Attribute _key_7 = entry_2.getKey();
- String _name_20 = _key_7.getName();
- CharSequence _invokeGetter_2 = this.helpers.invokeGetter(_name_20, null);
- _builder.append(_invokeGetter_2, " ");
- {
- if (array) {
- _builder.append(")");
- }
- }
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return values;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void writeDataClass(String id, Object dcObject, Map<String, Object> writeMap) {");
- _builder.newLine();
- {
- HashSet<DataClass> _dynDataClasses = this.getDynDataClasses(comp);
- for(final DataClass dc : _dynDataClasses) {
- _builder.append("\t\t");
- _builder.append("if(dcObject.getClass().equals(");
- String _typeName_5 = this._typeHelpers.typeName(dc);
- _builder.append(_typeName_5, " ");
- _builder.append(".class))");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("writeDataClass(id, (");
- String _typeName_6 = this._typeHelpers.typeName(dc);
- _builder.append(_typeName_6, " ");
- _builder.append(") dcObject, writeTasks);");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// DataClasses write operations");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- HashSet<DataClass> _allDynDataClasses = this.getAllDynDataClasses(comp);
- for(final DataClass dc_1 : _allDynDataClasses) {
- _builder.append("\t");
- _builder.append("private void writeDataClass(String id, ");
- String _typeName_7 = this._typeHelpers.typeName(dc_1);
- _builder.append(_typeName_7, " ");
- _builder.append(" object, Map<String, Object> map){");
- _builder.newLineIfNotEmpty();
- {
- EList<Attribute> _attributes = dc_1.getAttributes();
- for(final Attribute a_1 : _attributes) {
- {
- RefableType _refType_5 = a_1.getRefType();
- DataType _type_5 = _refType_5.getType();
- boolean _isPrimitive = this._typeHelpers.isPrimitive(_type_5);
- if (_isPrimitive) {
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("map.put(id+\"/");
- String _name_21 = a_1.getName();
- _builder.append(_name_21, " ");
- _builder.append("\", ");
- {
- int _size_7 = a_1.getSize();
- boolean _greaterThan_2 = (_size_7 > 0);
- if (_greaterThan_2) {
- _builder.append("toObjectArray(");
- }
- }
- _builder.append("object.");
- String _name_22 = a_1.getName();
- CharSequence _invokeGetter_3 = this.helpers.invokeGetter(_name_22, null);
- _builder.append(_invokeGetter_3, " ");
- {
- int _size_8 = a_1.getSize();
- boolean _greaterThan_3 = (_size_8 > 0);
- if (_greaterThan_3) {
- _builder.append(")");
- }
- }
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("writeDataClass(id+\"/");
- String _name_23 = a_1.getName();
- _builder.append(_name_23, " ");
- _builder.append("\", object.");
- String _name_24 = a_1.getName();
- CharSequence _invokeGetter_4 = this.helpers.invokeGetter(_name_24, null);
- _builder.append(_invokeGetter_4, " ");
- _builder.append(", map);");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("protected int getPollingTimerUser(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return ");
- int _polling = dynConfig.getPolling();
- _builder.append(_polling, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-
- private CharSequence genMinMaxCheck(final AttrInstanceConfig instConf, final ActorClassConfig acConf) {
- CharSequence _xblockexpression = null;
- {
- List<String> _path = this.configExt.getPath(instConf, false, false, true, true);
- AttrClassConfig config = acConf==null?(AttrClassConfig)null:this.resolve(acConf, ((String[])Conversions.unwrapArray(_path, String.class)));
- boolean _and = false;
- NumberLiteral _min = config==null?(NumberLiteral)null:config.getMin();
- boolean _equals = Objects.equal(_min, null);
- if (!_equals) {
- _and = false;
- } else {
- NumberLiteral _max = config==null?(NumberLiteral)null:config.getMax();
- boolean _equals_1 = Objects.equal(_max, null);
- _and = (_equals && _equals_1);
- }
- if (_and) {
- StringConcatenation _builder = new StringConcatenation();
- return _builder;
- }
- List<String> _path_1 = this.configExt.getPath(config, false, false, true, true);
- String path = this.configExt.toPath(_path_1, "_");
- EObject _eContainer = config.eContainer();
- ActorClass _actor = ((ActorClassConfig) _eContainer).getActor();
- String acName = _actor.getName();
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append("checkMinMax(_");
- Attribute _attribute = config.getAttribute();
- String _name = _attribute.getName();
- _builder_1.append(_name, "");
- _builder_1.append(", ");
- {
- NumberLiteral _min_1 = config.getMin();
- boolean _notEquals = (!Objects.equal(_min_1, null));
- if (_notEquals) {
- _builder_1.append(acName, "");
- _builder_1.append(".MIN");
- _builder_1.append(path, "");
- } else {
- _builder_1.append("null");
- }
- }
- _builder_1.append(", ");
- {
- NumberLiteral _max_1 = config.getMax();
- boolean _notEquals_1 = (!Objects.equal(_max_1, null));
- if (_notEquals_1) {
- _builder_1.append(acName, "");
- _builder_1.append(".MAX");
- _builder_1.append(path, "");
- } else {
- _builder_1.append("null");
- }
- }
- _builder_1.append(");");
- _builder_1.newLineIfNotEmpty();
- _xblockexpression = (_builder_1);
- }
- return _xblockexpression;
- }
-
- private Map<Attribute,List<String>> getAllAttributes(final AttrInstanceConfig config) {
- HashMap<Attribute,List<String>> _hashMap = new HashMap<Attribute,List<String>>();
- HashMap<Attribute,List<String>> map = _hashMap;
- Attribute _attribute = config.getAttribute();
- RefableType _refType = _attribute.getRefType();
- DataType _type = _refType.getType();
- boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
- if (_isPrimitive) {
- Attribute _attribute_1 = config.getAttribute();
- ArrayList<String> _arrayList = new ArrayList<String>();
- map.put(_attribute_1, _arrayList);
- } else {
- Attribute _attribute_2 = config.getAttribute();
- LinkedList<String> _linkedList = new LinkedList<String>();
- this.getAllAttributes(_attribute_2, _linkedList, map);
- }
- return map;
- }
-
- private void getAllAttributes(final Attribute attribute, final List<String> path, final Map<Attribute,List<String>> map) {
- RefableType _refType = attribute.getRefType();
- DataType _type = _refType.getType();
- boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
- if (_isPrimitive) {
- map.put(attribute, path);
- } else {
- RefableType _refType_1 = attribute.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _isDataClass = this._typeHelpers.isDataClass(_type_1);
- if (_isDataClass) {
- ArrayList<String> _arrayList = new ArrayList<String>(path);
- ArrayList<String> new_path = _arrayList;
- String _name = attribute.getName();
- new_path.add(_name);
- RefableType _refType_2 = attribute.getRefType();
- DataType _type_2 = _refType_2.getType();
- List<Attribute> _allAttributes = this.roomExt.getAllAttributes(((DataClass) _type_2));
- for (final Attribute dc : _allAttributes) {
- this.getAllAttributes(dc, new_path, map);
- }
- }
- }
- }
-
- private String toInvoke(final List<String> path) {
- StringBuilder _stringBuilder = new StringBuilder();
- StringBuilder builder = _stringBuilder;
- for (final String p : path) {
- CharSequence _invokeGetter = this.helpers.invokeGetter(p, null);
- String _plus = ("." + _invokeGetter);
- builder.append(_plus);
- }
- return builder.toString();
- }
-
- private List<ActorInstance> dynConfigsAIs(final SubSystemInstance comp) {
- HashSet<String> _hashSet = new HashSet<String>();
- final HashSet<String> aiPaths = _hashSet;
- SubSystemClass _subSystemClass = comp.getSubSystemClass();
- Iterable<AttrInstanceConfig> _attrDynConfigs = this.configExt.getAttrDynConfigs(_subSystemClass, true, false);
- for (final AttrInstanceConfig attrConfig : _attrDynConfigs) {
- List<String> _path = this.configExt.getPath(attrConfig, true, true, false, false);
- String _path_1 = this.configExt.toPath(_path, "/");
- aiPaths.add(_path_1);
- }
- ArrayList<ActorInstance> _arrayList = new ArrayList<ActorInstance>();
- ArrayList<ActorInstance> ais = _arrayList;
- EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
- for (final ActorInstance ai : _allContainedInstances) {
- String _path_2 = ai.getPath();
- boolean _contains = aiPaths.contains(_path_2);
- if (_contains) {
- ais.add(ai);
- }
- }
- return ais;
- }
-
- private HashSet<DataClass> getDynDataClasses(final SubSystemInstance comp) {
- HashSet<DataClass> _hashSet = new HashSet<DataClass>();
- HashSet<DataClass> dcs = _hashSet;
- SubSystemClass _subSystemClass = comp.getSubSystemClass();
- Iterable<AttrInstanceConfig> _attrDynConfigs = this.configExt.getAttrDynConfigs(_subSystemClass, false, true);
- for (final AttrInstanceConfig config : _attrDynConfigs) {
- Attribute _attribute = config.getAttribute();
- RefableType _refType = _attribute.getRefType();
- DataType _type = _refType.getType();
- boolean _isDataClass = this._typeHelpers.isDataClass(_type);
- if (_isDataClass) {
- Attribute _attribute_1 = config.getAttribute();
- RefableType _refType_1 = _attribute_1.getRefType();
- DataType _type_1 = _refType_1.getType();
- dcs.add(((DataClass) _type_1));
- }
- }
- return dcs;
- }
-
- private HashSet<DataClass> getAllDynDataClasses(final SubSystemInstance comp) {
- HashSet<DataClass> _hashSet = new HashSet<DataClass>();
- HashSet<DataClass> dcs = _hashSet;
- LinkedList<DataClass> _linkedList = new LinkedList<DataClass>();
- LinkedList<DataClass> stack = _linkedList;
- HashSet<DataClass> _dynDataClasses = this.getDynDataClasses(comp);
- stack.addAll(_dynDataClasses);
- Iterables.<DataClass>addAll(dcs, stack);
- boolean _isEmpty = stack.isEmpty();
- boolean _not = (!_isEmpty);
- boolean _while = _not;
- while (_while) {
- {
- DataClass dc = stack.pop();
- List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc);
- for (final Attribute a : _allAttributes) {
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- boolean _isDataClass = this._typeHelpers.isDataClass(_type);
- if (_isDataClass) {
- RefableType _refType_1 = a.getRefType();
- DataType _type_1 = _refType_1.getType();
- dcs.add(((DataClass) _type_1));
- RefableType _refType_2 = a.getRefType();
- DataType _type_2 = _refType_2.getType();
- stack.push(((DataClass) _type_2));
- }
- }
- }
- boolean _isEmpty_1 = stack.isEmpty();
- boolean _not_1 = (!_isEmpty_1);
- _while = _not_1;
- }
- return dcs;
- }
-
- private AttrClassConfig resolve(final ActorClassConfig config, final String[] path) {
- EList<AttrClassConfig> _attributes = config.getAttributes();
- final Function1<AttrClassConfig,Boolean> _function = new Function1<AttrClassConfig,Boolean>() {
- public Boolean apply(final AttrClassConfig c) {
- Attribute _attribute = c.getAttribute();
- String _name = _attribute.getName();
- String _head = IterableExtensions.<String>head(((Iterable<String>)Conversions.doWrapArray(path)));
- boolean _equals = _name.equals(_head);
- return Boolean.valueOf(_equals);
- }
- };
- AttrClassConfig result = IterableExtensions.<AttrClassConfig>findFirst(_attributes, _function);
- Iterable<String> _tail = IterableExtensions.<String>tail(((Iterable<String>)Conversions.doWrapArray(path)));
- for (final String ref : _tail) {
- {
- EList<AttrClassConfig> _attributes_1 = result==null?(EList<AttrClassConfig>)null:result.getAttributes();
- final Function1<AttrClassConfig,Boolean> _function_1 = new Function1<AttrClassConfig,Boolean>() {
- public Boolean apply(final AttrClassConfig c) {
- Attribute _attribute = c.getAttribute();
- String _name = _attribute.getName();
- boolean _equals = _name.equals(ref);
- return Boolean.valueOf(_equals);
- }
- };
- AttrClassConfig _findFirst = IterableExtensions.<AttrClassConfig>findFirst(_attributes_1, _function_1);
- result = _findFirst;
- boolean _equals = Objects.equal(result, null);
- if (_equals) {
- return null;
- }
- }
- }
- return result;
- }
-
- private HashSet<RoomModel> getRoomModels(final List<ActorInstance> ais) {
- HashSet<RoomModel> _hashSet = new HashSet<RoomModel>();
- final HashSet<RoomModel> models = _hashSet;
- final Procedure1<ActorInstance> _function = new Procedure1<ActorInstance>() {
- public void apply(final ActorInstance ai) {
- ActorClass _actorClass = ai.getActorClass();
- EObject _eContainer = _actorClass.eContainer();
- models.add(((RoomModel) _eContainer));
- }
- };
- IterableExtensions.<ActorInstance>forEach(ais, _function);
- return models;
- }
}
diff --git a/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
index 7b0bd00..f2beb78 100644
--- a/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator/META-INF/MANIFEST.MF
@@ -16,7 +16,6 @@ Require-Bundle: org.eclipse.etrice.core.room;bundle-version="0.1.0",
org.eclipse.core.resources;bundle-version="3.7.100",
org.eclipse.xtext.generator;bundle-version="2.1.1",
org.eclipse.xtext;bundle-version="2.1.1",
- org.eclipse.xtend.lib;bundle-version="2.3.0",
- org.eclipse.etrice.core.config;bundle-version="0.2.0"
+ org.eclipse.xtend.lib;bundle-version="2.3.0"
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.etrice.generator.generic
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
index 188c675..3f34d42 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
@@ -25,7 +25,6 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.etrice.core.ConfigStandaloneSetup;
import org.eclipse.etrice.core.room.DataClass;
import org.eclipse.etrice.core.room.DetailCode;
import org.eclipse.etrice.core.room.ProtocolClass;
@@ -129,13 +128,6 @@ public abstract class AbstractGenerator {
validator = roomInjector.getInstance(IResourceValidator.class);
org.eclipse.etrice.core.genmodel.SetupGenmodel.doSetup();
}
-
- /**
- * setup the Config model plug-in
- */
- protected void setupConfigModel() {
- ConfigStandaloneSetup.doSetup();
- }
/**
* @param rs the {@link ResourceSet} to which the generator model should be added
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
new file mode 100644
index 0000000..4451042
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java
@@ -0,0 +1,43 @@
+package org.eclipse.etrice.generator.base;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+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.SubSystemClass;
+
+public interface IDataConfiguration {
+
+ public static boolean LANGUAGE_SPECIFIC_VALUES = false;
+
+ public void doSetup();
+
+ public boolean setResources(ResourceSet resource, ILogger logger);
+
+ // static configuration
+
+ public String getAttrClassConfigValue(ActorClass actor, List<Attribute> path);
+ public String getAttrClassConfigValue(PortClass port, 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);
+
+ // dynamic configuration
+
+ public boolean hasVariableService(SubSystemClass subsystem);
+
+ public boolean hasDynConfigReadAttributes(ActorClass actor);
+ public boolean hasDynConfigWriteAttributes(ActorClass actor);
+
+ public List<Attribute> getAllDynConfigReadAttributes(ActorClass actor);
+ public List<Attribute> getAllDynConfigWriteAttributes(ActorClass actor);
+
+ public List<Attribute> getDynConfigReadAttributes(SubSystemClass subsystem);
+ public List<Attribute> getDynConfigWriteAttributes(SubSystemClass subsystem);
+
+}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ConfigExtension.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ConfigExtension.xtend
deleted file mode 100644
index c948f60..0000000
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ConfigExtension.xtend
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Juergen Haug
- * 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:
- * Juergen Haug
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.generator.generic
-
-import com.google.inject.Inject
-import com.google.inject.Singleton
-import java.util.ArrayList
-import java.util.HashSet
-import java.util.LinkedList
-import java.util.List
-import org.eclipse.etrice.core.config.ActorClassConfig
-import org.eclipse.etrice.core.config.ActorInstanceConfig
-import org.eclipse.etrice.core.config.AttrClassConfig
-import org.eclipse.etrice.core.config.AttrConfig
-import org.eclipse.etrice.core.config.AttrInstanceConfig
-import org.eclipse.etrice.core.config.BooleanLiteral
-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.PortInstanceConfig
-import org.eclipse.etrice.core.config.ProtocolClassConfig
-import org.eclipse.etrice.core.config.RealLiteral
-import org.eclipse.etrice.core.config.StringLiteral
-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.DataClass
-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.core.room.SubSystemClass
-import org.eclipse.etrice.generator.base.ConfigHelper
-
-@Singleton
-class ConfigExtension {
- @Inject ILanguageExtension languageExt
-
- // language operations
-
- def String toArrayValueLiteral(PrimitiveType type, String[] values){
- '''«FOR v : values BEFORE '{' SEPARATOR ', ' AFTER '}'»«languageExt.toValueLiteral(type, v)»«ENDFOR»'''.toString
- }
-
- // ConfigHelper
- def ActorClassConfig getClassConfig(ActorClass ac){
- ConfigHelper::ac2acConfMap.get(ac)
- }
-
- def ProtocolClassConfig getProtocolConfig(ProtocolClass prc){
- ConfigHelper::pc2pcConfMap.get(prc);
- }
-
- def getSubSystemConfig(SubSystemClass ssc){
- ConfigHelper::ssc2ssConfMap.get(ssc)
- }
-
- def ActorClassConfig getActorClassConfig(ActorInstanceConfig ai){
- ConfigHelper::ac2acConfMap.get(ConfigHelper::aiConf2acMap.get(ai))
- }
-
- // config operations
-
- def String getInitValueLiteral(Attribute a){
- var configValues = a.configClassValues
- var type = a.refType.type
- var configValue = switch type{
- case configValues == null:
- null
- PrimitiveType case a.size != configValues.size:
- languageExt.toValueLiteral(type, configValues.get(0))
- PrimitiveType:
- toArrayValueLiteral(type, configValues)
- }
-
- return if(configValue != null) configValue else a.defaultValueLiteral
- }
-
- def String[] getConfigClassValues(Attribute attr){
- if(attr.eContainer instanceof DataClass)
- return null
-
- if (attr.eContainer instanceof ActorClass) {
- var ac = attr.eContainer as ActorClass
- return ac.classConfig?.attributes?.getConfigValue(attr)
- } else
- if(attr.eContainer instanceof PortClass) {
- var pc = attr.eContainer as PortClass;
- var protocol = pc.eContainer as ProtocolClass
- var prcConfig = getProtocolConfig(protocol as ProtocolClass)
- if(pc.equals(protocol.regular)) {
- return prcConfig?.regular?.attributes?.getConfigValue(attr)
- } else
- return prcConfig?.conjugated?.attributes?.getConfigValue(attr)
- }
- }
-
- def String[] getConfigValue(List<AttrClassConfig> attrConfigs, Attribute attr){
- attrConfigs.findFirst(attrConfig | attrConfig.attribute.equals(attr))?.value?.getValues;
- }
-
- def String[] getValues(LiteralArray literalArray){
- val result = new ArrayList<String>()
- literalArray.literals.forEach(l | result.add(l.value))
- return if(!result.empty) result else null
- }
-
- def String getValue(Literal literal){
- return switch literal {
- BooleanLiteral:
- String::valueOf(literal.isTrue)
- IntLiteral:
- String::valueOf(literal.value)
- RealLiteral:
- String::valueOf(literal.value)
- StringLiteral:
- String::valueOf(literal.value)
- }
- }
-
- def List<AttrInstanceConfig> getConfigAttributes(ActorInstance ai){
- var config = ConfigHelper::path2aiConfMap.get(ai.path)
- return if(config != null) config.attributes else new ArrayList<AttrInstanceConfig>()
- }
-
- def List<PortInstanceConfig> getConfigPorts(ActorInstance ai){
- val result = new ArrayList<PortInstanceConfig>()
- var config = ConfigHelper::path2aiConfMap.get(ai.path)
- config?.ports?.forEach(portConf | result.add(portConf))
- return result
- }
-
- def hasVariableService(SubSystemClass ssc){
- ssc.getSubSystemConfig?.dynConfig != null
- }
-
- def List<AttrClassConfig> getAllAttrConfigFlat(ActorClass ac){
- var result = new ArrayList<AttrClassConfig>()
- if(ac.classConfig != null) {
- var stack = new LinkedList<AttrClassConfig>()
- stack.addAll(ac.classConfig.attributes)
- while(!stack.empty){
- var c = stack.pop
- result.add(c)
- stack.addAll(c.attributes)
- }
- }
- return result
- }
-
- def Iterable<AttrInstanceConfig> getAttrDynConfigs(SubSystemClass ssc, boolean read, boolean write){
- ConfigHelper::ssc2attrInstConfMap.get(ssc).filter(c |
- c.dynConfig && ((read && c.readOnly) || (write && !c.readOnly))
- )
- }
-
- def List<String> getPath(AttrConfig config, boolean ss, boolean actor, boolean dc, boolean attr){
- var result = new LinkedList<String>()
- var c = config
- while(c.eContainer instanceof AttrConfig){
- c = c.eContainer as AttrConfig
- if(dc)
- result.addFirst(c.attribute.name)
- }
- if(c.eContainer instanceof ActorInstanceConfig) {
- var aic = c.eContainer as ActorInstanceConfig
- if(actor)
- result.addAll(0, aic.path.refs)
- if(ss)
- result.addFirst(aic.root.name)
- } else
- if(c.eContainer instanceof ActorClassConfig) {
- var ac= c.eContainer as ActorClassConfig
- if(actor)
- result.addFirst(ac.actor.name)
- }
- if(attr)
- result.add(config.attribute.name)
- return result
- }
-
- def String toPath(Iterable<String> path, String pathDelim){
- ConfigHelper::toPath(path, pathDelim)
- }
-
- def getDynConfigAttributes(ActorClass ac, boolean read, boolean write){
- val result = new HashSet<Attribute>()
- ConfigHelper::ac2aiConfMap.get(ac)?.
- forEach(aiConf | aiConf.attributes.
- filter(c | c.dynConfig && ((read && c.readOnly) || (write && !c.readOnly))).
- forEach(dynConf | result.add(dynConf.attribute)))
- return result
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
index e586d02..3ca6b8f 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
@@ -69,6 +69,13 @@ class RoomExtensions {
return ret
}
+ def <T> List<T> union(List<T> l, T e) {
+ var ret = new ArrayList<T>()
+ ret.addAll(l)
+ ret.add(e)
+ return ret
+ }
+
def <T> Iterable<T> union(Iterable<T> l1, Iterable<T> l2) {
var ret = new ArrayList<T>()
ret.addAll(l1)
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java
deleted file mode 100644
index aac2378..0000000
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ConfigExtension.java
+++ /dev/null
@@ -1,475 +0,0 @@
-package org.eclipse.etrice.generator.generic;
-
-import com.google.common.base.Objects;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.config.ActorClassConfig;
-import org.eclipse.etrice.core.config.ActorInstanceConfig;
-import org.eclipse.etrice.core.config.AttrClassConfig;
-import org.eclipse.etrice.core.config.AttrConfig;
-import org.eclipse.etrice.core.config.AttrInstanceConfig;
-import org.eclipse.etrice.core.config.BooleanLiteral;
-import org.eclipse.etrice.core.config.DynamicConfig;
-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.PortClassConfig;
-import org.eclipse.etrice.core.config.PortInstanceConfig;
-import org.eclipse.etrice.core.config.ProtocolClassConfig;
-import org.eclipse.etrice.core.config.RealLiteral;
-import org.eclipse.etrice.core.config.RefPath;
-import org.eclipse.etrice.core.config.StringLiteral;
-import org.eclipse.etrice.core.config.SubSystemConfig;
-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.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-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.core.room.RefableType;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.ConfigHelper;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.xbase.lib.Conversions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
-
-@Singleton
-@SuppressWarnings("all")
-public class ConfigExtension {
- @Inject
- private ILanguageExtension languageExt;
-
- public String toArrayValueLiteral(final PrimitiveType type, final String[] values) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _hasElements = false;
- for(final String v : values) {
- if (!_hasElements) {
- _hasElements = true;
- _builder.append("{", "");
- } else {
- _builder.appendImmediate(", ", "");
- }
- String _valueLiteral = this.languageExt.toValueLiteral(type, v);
- _builder.append(_valueLiteral, "");
- }
- if (_hasElements) {
- _builder.append("}", "");
- }
- }
- String _string = _builder.toString();
- return _string;
- }
-
- public ActorClassConfig getClassConfig(final ActorClass ac) {
- ActorClassConfig _get = ConfigHelper.ac2acConfMap.get(ac);
- return _get;
- }
-
- public ProtocolClassConfig getProtocolConfig(final ProtocolClass prc) {
- ProtocolClassConfig _get = ConfigHelper.pc2pcConfMap.get(prc);
- return _get;
- }
-
- public SubSystemConfig getSubSystemConfig(final SubSystemClass ssc) {
- SubSystemConfig _get = ConfigHelper.ssc2ssConfMap.get(ssc);
- return _get;
- }
-
- public ActorClassConfig getActorClassConfig(final ActorInstanceConfig ai) {
- ActorClass _get = ConfigHelper.aiConf2acMap.get(ai);
- ActorClassConfig _get_1 = ConfigHelper.ac2acConfMap.get(_get);
- return _get_1;
- }
-
- public String getInitValueLiteral(final Attribute a) {
- String[] configValues = this.getConfigClassValues(a);
- RefableType _refType = a.getRefType();
- DataType type = _refType.getType();
- String _switchResult = null;
- boolean _matched = false;
- if (!_matched) {
- boolean _equals = Objects.equal(configValues, null);
- if (_equals) {
- _matched=true;
- _switchResult = null;
- }
- }
- if (!_matched) {
- if (type instanceof PrimitiveType) {
- final PrimitiveType _primitiveType = (PrimitiveType)type;
- int _size = a.getSize();
- final String[] _converted_configValues = (String[])configValues;
- int _size_1 = ((List<String>)Conversions.doWrapArray(_converted_configValues)).size();
- boolean _notEquals = (_size != _size_1);
- if (_notEquals) {
- _matched=true;
- final String[] _converted_configValues_1 = (String[])configValues;
- String _get = ((List<String>)Conversions.doWrapArray(_converted_configValues_1)).get(0);
- String _valueLiteral = this.languageExt.toValueLiteral(_primitiveType, _get);
- _switchResult = _valueLiteral;
- }
- }
- }
- if (!_matched) {
- if (type instanceof PrimitiveType) {
- final PrimitiveType _primitiveType = (PrimitiveType)type;
- _matched=true;
- String _arrayValueLiteral = this.toArrayValueLiteral(_primitiveType, configValues);
- _switchResult = _arrayValueLiteral;
- }
- }
- String configValue = _switchResult;
- String _xifexpression = null;
- boolean _notEquals = (!Objects.equal(configValue, null));
- if (_notEquals) {
- _xifexpression = configValue;
- } else {
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- _xifexpression = _defaultValueLiteral;
- }
- return _xifexpression;
- }
-
- public String[] getConfigClassValues(final Attribute attr) {
- EObject _eContainer = attr.eContainer();
- if ((_eContainer instanceof DataClass)) {
- return null;
- }
- EObject _eContainer_1 = attr.eContainer();
- if ((_eContainer_1 instanceof ActorClass)) {
- EObject _eContainer_2 = attr.eContainer();
- ActorClass ac = ((ActorClass) _eContainer_2);
- ActorClassConfig _classConfig = this.getClassConfig(ac);
- EList<AttrClassConfig> _attributes = _classConfig==null?(EList<AttrClassConfig>)null:_classConfig.getAttributes();
- return _attributes==null?(String[])null:this.getConfigValue(_attributes, attr);
- } else {
- EObject _eContainer_3 = attr.eContainer();
- if ((_eContainer_3 instanceof PortClass)) {
- EObject _eContainer_4 = attr.eContainer();
- PortClass pc = ((PortClass) _eContainer_4);
- EObject _eContainer_5 = pc.eContainer();
- ProtocolClass protocol = ((ProtocolClass) _eContainer_5);
- ProtocolClassConfig prcConfig = this.getProtocolConfig(((ProtocolClass) protocol));
- PortClass _regular = protocol.getRegular();
- boolean _equals = pc.equals(_regular);
- if (_equals) {
- PortClassConfig _regular_1 = prcConfig==null?(PortClassConfig)null:prcConfig.getRegular();
- EList<AttrClassConfig> _attributes_1 = _regular_1==null?(EList<AttrClassConfig>)null:_regular_1.getAttributes();
- return _attributes_1==null?(String[])null:this.getConfigValue(_attributes_1, attr);
- } else {
- PortClassConfig _conjugated = prcConfig==null?(PortClassConfig)null:prcConfig.getConjugated();
- EList<AttrClassConfig> _attributes_2 = _conjugated==null?(EList<AttrClassConfig>)null:_conjugated.getAttributes();
- return _attributes_2==null?(String[])null:this.getConfigValue(_attributes_2, attr);
- }
- }
- }
- return null;
- }
-
- public String[] getConfigValue(final List<AttrClassConfig> attrConfigs, final Attribute attr) {
- final Function1<AttrClassConfig,Boolean> _function = new Function1<AttrClassConfig,Boolean>() {
- public Boolean apply(final AttrClassConfig attrConfig) {
- Attribute _attribute = attrConfig.getAttribute();
- boolean _equals = _attribute.equals(attr);
- return Boolean.valueOf(_equals);
- }
- };
- AttrClassConfig _findFirst = IterableExtensions.<AttrClassConfig>findFirst(attrConfigs, _function);
- LiteralArray _value = _findFirst==null?(LiteralArray)null:_findFirst.getValue();
- String[] _values = _value==null?(String[])null:this.getValues(_value);
- return _values;
- }
-
- public String[] getValues(final LiteralArray literalArray) {
- ArrayList<String> _arrayList = new ArrayList<String>();
- final ArrayList<String> result = _arrayList;
- EList<Literal> _literals = literalArray.getLiterals();
- final Procedure1<Literal> _function = new Procedure1<Literal>() {
- public void apply(final Literal l) {
- String _value = ConfigExtension.this.getValue(l);
- result.add(_value);
- }
- };
- IterableExtensions.<Literal>forEach(_literals, _function);
- ArrayList<String> _xifexpression = null;
- boolean _isEmpty = result.isEmpty();
- boolean _not = (!_isEmpty);
- if (_not) {
- _xifexpression = result;
- } else {
- _xifexpression = null;
- }
- return ((String[])Conversions.unwrapArray(_xifexpression, String.class));
- }
-
- public String getValue(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 _valueOf = String.valueOf(_isIsTrue);
- _switchResult = _valueOf;
- }
- }
- if (!_matched) {
- if (literal instanceof IntLiteral) {
- final IntLiteral _intLiteral = (IntLiteral)literal;
- _matched=true;
- long _value = _intLiteral.getValue();
- String _valueOf = String.valueOf(_value);
- _switchResult = _valueOf;
- }
- }
- if (!_matched) {
- if (literal instanceof RealLiteral) {
- final RealLiteral _realLiteral = (RealLiteral)literal;
- _matched=true;
- double _value = _realLiteral.getValue();
- String _valueOf = String.valueOf(_value);
- _switchResult = _valueOf;
- }
- }
- if (!_matched) {
- if (literal instanceof StringLiteral) {
- final StringLiteral _stringLiteral = (StringLiteral)literal;
- _matched=true;
- String _value = _stringLiteral.getValue();
- String _valueOf = String.valueOf(_value);
- _switchResult = _valueOf;
- }
- }
- return _switchResult;
- }
-
- public List<AttrInstanceConfig> getConfigAttributes(final ActorInstance ai) {
- String _path = ai.getPath();
- ActorInstanceConfig config = ConfigHelper.path2aiConfMap.get(_path);
- List<AttrInstanceConfig> _xifexpression = null;
- boolean _notEquals = (!Objects.equal(config, null));
- if (_notEquals) {
- EList<AttrInstanceConfig> _attributes = config.getAttributes();
- _xifexpression = _attributes;
- } else {
- ArrayList<AttrInstanceConfig> _arrayList = new ArrayList<AttrInstanceConfig>();
- _xifexpression = _arrayList;
- }
- return _xifexpression;
- }
-
- public List<PortInstanceConfig> getConfigPorts(final ActorInstance ai) {
- ArrayList<PortInstanceConfig> _arrayList = new ArrayList<PortInstanceConfig>();
- final ArrayList<PortInstanceConfig> result = _arrayList;
- String _path = ai.getPath();
- ActorInstanceConfig config = ConfigHelper.path2aiConfMap.get(_path);
- EList<PortInstanceConfig> _ports = config==null?(EList<PortInstanceConfig>)null:config.getPorts();
- final Procedure1<PortInstanceConfig> _function = new Procedure1<PortInstanceConfig>() {
- public void apply(final PortInstanceConfig portConf) {
- result.add(portConf);
- }
- };
- if (_ports!=null) IterableExtensions.<PortInstanceConfig>forEach(_ports, _function);
- return result;
- }
-
- public boolean hasVariableService(final SubSystemClass ssc) {
- SubSystemConfig _subSystemConfig = this.getSubSystemConfig(ssc);
- DynamicConfig _dynConfig = _subSystemConfig==null?(DynamicConfig)null:_subSystemConfig.getDynConfig();
- boolean _notEquals = (!Objects.equal(_dynConfig, null));
- return _notEquals;
- }
-
- public List<AttrClassConfig> getAllAttrConfigFlat(final ActorClass ac) {
- ArrayList<AttrClassConfig> _arrayList = new ArrayList<AttrClassConfig>();
- ArrayList<AttrClassConfig> result = _arrayList;
- ActorClassConfig _classConfig = this.getClassConfig(ac);
- boolean _notEquals = (!Objects.equal(_classConfig, null));
- if (_notEquals) {
- LinkedList<AttrClassConfig> _linkedList = new LinkedList<AttrClassConfig>();
- LinkedList<AttrClassConfig> stack = _linkedList;
- ActorClassConfig _classConfig_1 = this.getClassConfig(ac);
- EList<AttrClassConfig> _attributes = _classConfig_1.getAttributes();
- stack.addAll(_attributes);
- boolean _isEmpty = stack.isEmpty();
- boolean _not = (!_isEmpty);
- boolean _while = _not;
- while (_while) {
- {
- AttrClassConfig c = stack.pop();
- result.add(c);
- EList<AttrClassConfig> _attributes_1 = c.getAttributes();
- stack.addAll(_attributes_1);
- }
- boolean _isEmpty_1 = stack.isEmpty();
- boolean _not_1 = (!_isEmpty_1);
- _while = _not_1;
- }
- }
- return result;
- }
-
- public Iterable<AttrInstanceConfig> getAttrDynConfigs(final SubSystemClass ssc, final boolean read, final boolean write) {
- List<AttrInstanceConfig> _get = ConfigHelper.ssc2attrInstConfMap.get(ssc);
- final Function1<AttrInstanceConfig,Boolean> _function = new Function1<AttrInstanceConfig,Boolean>() {
- public Boolean apply(final AttrInstanceConfig c) {
- boolean _and = false;
- boolean _isDynConfig = c.isDynConfig();
- if (!_isDynConfig) {
- _and = false;
- } else {
- boolean _or = false;
- boolean _and_1 = false;
- if (!read) {
- _and_1 = false;
- } else {
- boolean _isReadOnly = c.isReadOnly();
- _and_1 = (read && _isReadOnly);
- }
- if (_and_1) {
- _or = true;
- } else {
- boolean _and_2 = false;
- if (!write) {
- _and_2 = false;
- } else {
- boolean _isReadOnly_1 = c.isReadOnly();
- boolean _not = (!_isReadOnly_1);
- _and_2 = (write && _not);
- }
- _or = (_and_1 || _and_2);
- }
- _and = (_isDynConfig && _or);
- }
- return Boolean.valueOf(_and);
- }
- };
- Iterable<AttrInstanceConfig> _filter = IterableExtensions.<AttrInstanceConfig>filter(_get, _function);
- return _filter;
- }
-
- public List<String> getPath(final AttrConfig config, final boolean ss, final boolean actor, final boolean dc, final boolean attr) {
- LinkedList<String> _linkedList = new LinkedList<String>();
- LinkedList<String> result = _linkedList;
- AttrConfig c = config;
- EObject _eContainer = c.eContainer();
- boolean _while = (_eContainer instanceof AttrConfig);
- while (_while) {
- {
- EObject _eContainer_1 = c.eContainer();
- c = ((AttrConfig) _eContainer_1);
- if (dc) {
- Attribute _attribute = c.getAttribute();
- String _name = _attribute.getName();
- result.addFirst(_name);
- }
- }
- EObject _eContainer_1 = c.eContainer();
- _while = (_eContainer_1 instanceof AttrConfig);
- }
- EObject _eContainer_1 = c.eContainer();
- if ((_eContainer_1 instanceof ActorInstanceConfig)) {
- EObject _eContainer_2 = c.eContainer();
- ActorInstanceConfig aic = ((ActorInstanceConfig) _eContainer_2);
- if (actor) {
- RefPath _path = aic.getPath();
- EList<String> _refs = _path.getRefs();
- result.addAll(0, _refs);
- }
- if (ss) {
- SubSystemClass _root = aic.getRoot();
- String _name = _root.getName();
- result.addFirst(_name);
- }
- } else {
- EObject _eContainer_3 = c.eContainer();
- if ((_eContainer_3 instanceof ActorClassConfig)) {
- EObject _eContainer_4 = c.eContainer();
- ActorClassConfig ac = ((ActorClassConfig) _eContainer_4);
- if (actor) {
- ActorClass _actor = ac.getActor();
- String _name_1 = _actor.getName();
- result.addFirst(_name_1);
- }
- }
- }
- if (attr) {
- Attribute _attribute = config.getAttribute();
- String _name_2 = _attribute.getName();
- result.add(_name_2);
- }
- return result;
- }
-
- public String toPath(final Iterable<String> path, final String pathDelim) {
- String _path = ConfigHelper.toPath(path, pathDelim);
- return _path;
- }
-
- public HashSet<Attribute> getDynConfigAttributes(final ActorClass ac, final boolean read, final boolean write) {
- HashSet<Attribute> _hashSet = new HashSet<Attribute>();
- final HashSet<Attribute> result = _hashSet;
- List<ActorInstanceConfig> _get = ConfigHelper.ac2aiConfMap.get(ac);
- final Procedure1<ActorInstanceConfig> _function = new Procedure1<ActorInstanceConfig>() {
- public void apply(final ActorInstanceConfig aiConf) {
- EList<AttrInstanceConfig> _attributes = aiConf.getAttributes();
- final Function1<AttrInstanceConfig,Boolean> _function = new Function1<AttrInstanceConfig,Boolean>() {
- public Boolean apply(final AttrInstanceConfig c) {
- boolean _and = false;
- boolean _isDynConfig = c.isDynConfig();
- if (!_isDynConfig) {
- _and = false;
- } else {
- boolean _or = false;
- boolean _and_1 = false;
- if (!read) {
- _and_1 = false;
- } else {
- boolean _isReadOnly = c.isReadOnly();
- _and_1 = (read && _isReadOnly);
- }
- if (_and_1) {
- _or = true;
- } else {
- boolean _and_2 = false;
- if (!write) {
- _and_2 = false;
- } else {
- boolean _isReadOnly_1 = c.isReadOnly();
- boolean _not = (!_isReadOnly_1);
- _and_2 = (write && _not);
- }
- _or = (_and_1 || _and_2);
- }
- _and = (_isDynConfig && _or);
- }
- return Boolean.valueOf(_and);
- }
- };
- Iterable<AttrInstanceConfig> _filter = IterableExtensions.<AttrInstanceConfig>filter(_attributes, _function);
- final Procedure1<AttrInstanceConfig> _function_1 = new Procedure1<AttrInstanceConfig>() {
- public void apply(final AttrInstanceConfig dynConf) {
- Attribute _attribute = dynConf.getAttribute();
- result.add(_attribute);
- }
- };
- IterableExtensions.<AttrInstanceConfig>forEach(_filter, _function_1);
- }
- };
- if (_get!=null) IterableExtensions.<ActorInstanceConfig>forEach(_get, _function);
- return result;
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
index 4e01d09..9c1dd65 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
@@ -64,6 +64,14 @@ public class RoomExtensions {
return ret;
}
+ public <T extends Object> List<T> union(final List<T> l, final T e) {
+ ArrayList<T> _arrayList = new ArrayList<T>();
+ ArrayList<T> ret = _arrayList;
+ ret.addAll(l);
+ ret.add(e);
+ return ret;
+ }
+
public <T extends Object> Iterable<T> union(final Iterable<T> l1, final Iterable<T> l2) {
ArrayList<T> _arrayList = new ArrayList<T>();
ArrayList<T> ret = _arrayList;