summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-11-06 07:15:06 (EST)
committer Juergen Haug2012-11-06 07:15:06 (EST)
commit1a88593291ca91aebc655ceebcbd3a053f4f41b6 (patch)
tree7e5247f75bc10e29def9835cad6c868188191a84
parent84eaee9b6c00c189510ed82543bb783780db8867 (diff)
downloadorg.eclipse.etrice-1a88593291ca91aebc655ceebcbd3a053f4f41b6.zip
org.eclipse.etrice-1a88593291ca91aebc655ceebcbd3a053f4f41b6.tar.gz
org.eclipse.etrice-1a88593291ca91aebc655ceebcbd3a053f4f41b6.tar.bz2
[CQ 6485][config, generator] missing gen .java files + fixesrefs/changes/16/8516/2
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend65
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java70
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/validation/ConfigJavaValidator.java285
-rw-r--r--plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java133
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ActorClassGen.xtend16
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.xtend63
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/Initialization.xtend35
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend6
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/VariableServiceGen.xtend309
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ActorClassGen.java65
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java228
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/Initialization.java405
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java77
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java913
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java18
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend4
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java18
17 files changed, 2038 insertions, 672 deletions
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend
index 4debf24..fe0d33f 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfiguration.xtend
@@ -1,5 +1,6 @@
package org.eclipse.etrice.core.config
+import java.util.ArrayList
import java.util.List
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.etrice.core.ConfigStandaloneSetup
@@ -10,7 +11,6 @@ import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.core.room.ProtocolClass
import org.eclipse.etrice.core.room.SubSystemClass
import org.eclipse.etrice.generator.base.IDataConfiguration
-import java.util.ArrayList
class DataConfiguration implements IDataConfiguration {
@@ -58,32 +58,47 @@ class DataConfiguration implements IDataConfiguration {
// dynamic
- override getAllDynConfigReadAttributes(ActorClass actor) {
- return new ArrayList<Attribute>
+ override getPollingTimerUser(SubSystemClass subsystem) {
+ subsystem.config?.dynConfig?.polling
}
- override getAllDynConfigWriteAttributes(ActorClass actor) {
- return new ArrayList<Attribute>
- }
-
- override getDynConfigReadAttributes(SubSystemClass subsystem) {
- return new ArrayList<Attribute>
+ override getUserCode1(SubSystemClass subsystem) {
+ var dynConfig = subsystem.config?.dynConfig
+ return
+ if(dynConfig?.filePath != null)
+ "import org.eclipse.etrice.runtime.java.config.ConfigSourceFile; // TODO JH make lang independent"
+ else
+ dynConfig?.userCode1
}
- override getDynConfigWriteAttributes(SubSystemClass subsystem) {
- return new ArrayList<Attribute>
+ override getUserCode2(SubSystemClass subsystem) {
+ var dynConfig = subsystem.config?.dynConfig
+ return
+ if(dynConfig?.filePath != null)
+ '''new ConfigSourceFile("«dynConfig.filePath»")'''
+ else
+ dynConfig?.userCode2
}
- override hasDynConfigReadAttributes(ActorClass actor) {
- false
+ override getDynConfigReadAttributes(String actorInstance) {
+ val result = new ArrayList<Attribute>
+ var configs = DataConfigurationHelper::dynActorInstanceAttrMap.get(actorInstance)
+ configs?.forEach(c | if(c.readOnly)result.add(c.attribute))
+
+ return result
}
- override hasDynConfigWriteAttributes(ActorClass actor) {
- false
+ override getDynConfigWriteAttributes(String actorInstance) {
+ val result = new ArrayList<Attribute>
+ var configs = DataConfigurationHelper::dynActorInstanceAttrMap.get(actorInstance)
+ configs?.forEach(c | if(!c.readOnly)result.add(c.attribute))
+
+ return result
}
+
override hasVariableService(SubSystemClass subsystem) {
- false
+ subsystem.config?.dynConfig != null
}
def private toStringExpr(LiteralArray literal){
@@ -98,5 +113,23 @@ class DataConfiguration implements IDataConfiguration {
StringLiteral: literal.value.toString
}
}
+
+ def private getConfig(SubSystemClass cc){
+ DataConfigurationHelper::subSystemConfigMap.get(cc)
+ }
+
+ override getDynConfigReadAttributes(ActorClass actor) {
+ val result = new ArrayList<Attribute>
+ var configs = DataConfigurationHelper::dynActorClassAttrMap.get(actor)
+ configs?.forEach(c | if(c.readOnly)result.add(c.attribute))
+ return result
+ }
+
+ override getDynConfigWriteAttributes(ActorClass actor) {
+ val result = new ArrayList<Attribute>
+ var configs = DataConfigurationHelper::dynActorClassAttrMap.get(actor)
+ configs?.forEach(c | if(!c.readOnly)result.add(c.attribute))
+ return result
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
index bba25fd..7dd9106 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/DataConfigurationHelper.java
@@ -32,7 +32,6 @@ import org.eclipse.etrice.core.genmodel.base.ILogger;
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.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SubSystemClass;
@@ -44,20 +43,18 @@ public class DataConfigurationHelper {
public static Map<String, AttrInstanceConfig> actorInstanceAttrMap = new HashMap<String, AttrInstanceConfig>();
// dynamic
- public static Map<SubSystemClass, SubSystemConfig> ssc2ssConfMap = new HashMap<SubSystemClass, SubSystemConfig>();
- public static Map<SubSystemClass, List<AttrInstanceConfig>> ssc2attrInstConfMap = new HashMap<SubSystemClass, List<AttrInstanceConfig>>();
- public static Map<ActorClass, List<ActorInstanceConfig>> ac2aiConfMap = new HashMap<ActorClass, List<ActorInstanceConfig>>();
- public static Map<ActorInstanceConfig, ActorClass> aiConf2acMap = new HashMap<ActorInstanceConfig, ActorClass>();
+ public static Map<SubSystemClass, SubSystemConfig> subSystemConfigMap = new HashMap<SubSystemClass, SubSystemConfig>();
+ public static Map<String, List<AttrInstanceConfig>> dynActorInstanceAttrMap = new HashMap<String, List<AttrInstanceConfig>>();
+ public static Map<ActorClass, List<AttrInstanceConfig>> dynActorClassAttrMap = new HashMap<ActorClass, List<AttrInstanceConfig>>();
public static boolean setConfigModels(ResourceSet rs, ILogger logger) {
actorClassAttrMap.clear();
protocolClassAttrMap.clear();
actorInstanceAttrMap.clear();
-
- ssc2ssConfMap.clear();
- ssc2attrInstConfMap.clear();
- ac2aiConfMap.clear();
- aiConf2acMap.clear();
+ subSystemConfigMap.clear();
+ dynActorInstanceAttrMap.clear();
+ dynActorClassAttrMap.clear();
+
boolean error = false;
List<ConfigModel> configs = new ArrayList<ConfigModel>();
@@ -100,7 +97,7 @@ public class DataConfigurationHelper {
for (ActorInstanceConfig instanceConfig : config
.getActorInstanceConfigs()) {
String path = "/" + instanceConfig.getRoot().getName()
- + toPath(instanceConfig.getPath().getRefs(), "/");
+ + toStringPath(instanceConfig.getPath().getRefs(), "/");
if (actorInstances.contains(path)) {
logger.logError(
"Multiple configurations for actor instance "
@@ -109,50 +106,43 @@ public class DataConfigurationHelper {
actorInstances.add(path);
collectConfigs(instanceConfig, path, actorInstanceAttrMap);
}
-
- ActorClass ac = ConfigUtil.resolve(instanceConfig.getRoot(),
- instanceConfig.getPath());
- if (ac2aiConfMap.get(ac) == null)
- ac2aiConfMap.put(ac, new ArrayList<ActorInstanceConfig>());
- ac2aiConfMap.get(ac).add(instanceConfig);
-
- aiConf2acMap.put(instanceConfig, ac);
}
for (SubSystemConfig ssConfig : config.getSubSystemConfigs()) {
- if (ssc2ssConfMap.containsKey(ssConfig)) {
+ if (subSystemConfigMap.containsKey(ssConfig.getSubSystem())) {
logger.logError(
"Multiple configurations for subSystem class "
+ ssConfig.getSubSystem().getName()
+ " found", null);
error = true;
- } else {
- ssc2ssConfMap.put(ssConfig.getSubSystem(), ssConfig);
- ssc2attrInstConfMap.put(ssConfig.getSubSystem(),
- new ArrayList<AttrInstanceConfig>());
- }
+ } else
+ subSystemConfigMap.put(ssConfig.getSubSystem(), ssConfig);
}
}
- // dynConfigSubsystemMap
- // for (ActorInstanceConfig instanceConfig : actorInstanceMap.values())
- // {
- // List<AttrInstanceConfig> dynConfigs = new
- // ArrayList<AttrInstanceConfig>();
- // for (AttrInstanceConfig config : instanceConfig.getAttributes())
- // if (config.isDynConfig())
- // dynConfigs.add(config);
- // if (!dynConfigs.isEmpty())
- // ssc2attrInstConfMap.get(instanceConfig.getRoot()).addAll(
- // dynConfigs);
- // }
-
return !error;
}
private static void collectConfigs(ActorInstanceConfig actorConfig,
String path, Map<String, AttrInstanceConfig> map) {
- for (AttrInstanceConfig c : actorConfig.getAttributes())
+ for (AttrInstanceConfig c : actorConfig.getAttributes()) {
collectConfigs(c, path + "/" + c.getAttribute().getName(), map);
+
+ if (c.isDynConfig()) {
+ List<AttrInstanceConfig> list = dynActorInstanceAttrMap
+ .get(path);
+ if (list == null)
+ list = new ArrayList<AttrInstanceConfig>();
+ list.add(c);
+ dynActorInstanceAttrMap.put(path, list);
+
+ ActorClass ac = ConfigUtil.getLastActorRef(
+ actorConfig.getRoot(), actorConfig.getPath()).getType();
+ if ((list = dynActorClassAttrMap.get(ac)) == null)
+ list = new ArrayList<AttrInstanceConfig>();
+ list.add(c);
+ dynActorClassAttrMap.put(ac, list);
+ }
+ }
}
private static void collectConfigs(ProtocolClassConfig protocolConfig,
@@ -191,7 +181,7 @@ public class DataConfigurationHelper {
map.put(path, config);
}
- public static String toPath(Iterable<String> path, String pathDelim) {
+ public static String toStringPath(Iterable<String> path, String pathDelim) {
StringBuilder b = new StringBuilder();
for (String p : path)
b.append(pathDelim + p);
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 79732bc..24abc0a 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
@@ -12,6 +12,8 @@
package org.eclipse.etrice.core.validation;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -44,16 +46,17 @@ import org.eclipse.etrice.core.room.ActorContainerClass;
import org.eclipse.etrice.core.room.ActorRef;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.LiteralType;
import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.xtext.conversion.ValueConverterException;
import org.eclipse.xtext.validation.Check;
public class ConfigJavaValidator extends AbstractConfigJavaValidator {
+ @SuppressWarnings("unused")
private ConfigValueConverterService converter = new ConfigValueConverterService();
@Check
@@ -283,30 +286,11 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
// numeric check
if ((type == LiteralType.INT || type == LiteralType.REAL)) {
- ActorClassConfig classConfig = null;
- if (config.eContainer() instanceof ActorInstanceConfig) {
- ActorInstanceConfig actorConfig = (ActorInstanceConfig) config
- .eContainer();
- ActorContainerClass actorClass = ConfigUtil.resolve(
- actorConfig.getRoot(), actorConfig.getPath());
- // find ActorClassConfig
- ConfigModel model = getConfigModel(actorConfig);
- for (ActorClassConfig cf : model.getActorClassConfigs()) {
- if (cf.getActor().equals(actorClass)) {
- classConfig = cf;
- break;
- }
- }
- } else if (config.eContainer() instanceof ActorClassConfig)
- classConfig = (ActorClassConfig) config.eContainer();
-
AttrClassConfig attrClassConfig = null;
- if (classConfig != null) {
- for (AttrClassConfig acf : classConfig.getAttributes())
- if (config.getAttribute().equals(acf.getAttribute())) {
- attrClassConfig = acf;
- break;
- }
+ if (config instanceof AttrInstanceConfig) {
+ attrClassConfig = resolveAttrClassConfig((AttrInstanceConfig) config);
+ } else if (config instanceof AttrClassConfig) {
+ attrClassConfig = (AttrClassConfig) config;
}
if (attrClassConfig != null) {
@@ -324,14 +308,20 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
error("value is less than minimum",
config.getValue(), arrayRef,
values.indexOf(value));
- }
+ } else if (min != null)
+ warning("could not compare with minimum (incompatible datatypes)",
+ config.getValue(), arrayRef,
+ values.indexOf(value));
if (max instanceof RealLiteral) {
double dbMax = ((RealLiteral) max).getValue();
if (dbMax < dbValue)
error("value exceeds maximum",
config.getValue(), arrayRef,
values.indexOf(value));
- }
+ } else if (max != null)
+ warning("could not compare with maximum (incompatible datatypes)",
+ config.getValue(), arrayRef,
+ values.indexOf(value));
} else if (value instanceof IntLiteral) {
long lValue = ((IntLiteral) value).getValue();
if (min instanceof IntLiteral) {
@@ -340,14 +330,20 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
error("value is less than minimum",
config.getValue(), arrayRef,
values.indexOf(value));
- }
+ } else if (min != null)
+ warning("could not compare with minimum (incompatible datatypes)",
+ config.getValue(), arrayRef,
+ values.indexOf(value));
if (max instanceof IntLiteral) {
long lMax = ((IntLiteral) max).getValue();
if (lMax < lValue)
error("value exceeds maximum",
config.getValue(), arrayRef,
values.indexOf(value));
- }
+ } else if (max != null)
+ warning("could not compare with maximum (incompatible datatypes)",
+ config.getValue(), arrayRef,
+ values.indexOf(value));
}
}
}
@@ -367,50 +363,47 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
if (primitive.getType() == LiteralType.INT) {
if (!(min instanceof IntLiteral))
error("incompatible datatype: maximum is not int", minRef);
- } else if (primitive.getType() == LiteralType.REAL) {
- if (!(min instanceof RealLiteral))
- error("incompatible datatype: maximum is not real", minRef);
}
// check room default if config default is not set
- String defaultValue = config.getAttribute()
- .getDefaultValueLiteral();
- if (config.getValue() == null && defaultValue != null) {
- if (type == LiteralType.INT) {
- if (min instanceof IntLiteral) {
- try {
- long lDefaultValue = converter.getLongConverter()
- .toValue(defaultValue, null);
- long lMax = ((IntLiteral) min).getValue();
- if (lMax < lDefaultValue)
- error("default value in ROOM model is less than this maximum",
- minRef);
- } catch (ValueConverterException e) {
- warning("could not compare with int value in ROOM model (parse error)",
- minRef);
- }
- } else
- warning("could not compare with int value in ROOM model (incompatible datatypes)",
- minRef);
- } else if (type == LiteralType.REAL) {
- if (min instanceof RealLiteral) {
- try {
- double dbDefaultValue = converter
- .getRealConverter().toValue(defaultValue,
- null);
- double dbMax = ((RealLiteral) min).getValue();
- if (dbMax < dbDefaultValue)
- error("default value in ROOM model is less than this maximum",
- minRef);
- } catch (ValueConverterException e1) {
- warning("could not compare with real value in ROOM model (parse error)",
- minRef);
- }
- } else
- warning("could not compare with real value in ROOM model (incompatible datatypes)",
- minRef);
- }
-
- }
+// String defaultValue = config.getAttribute()
+// .getDefaultValueLiteral();
+// if (config.getValue() == null && defaultValue != null) {
+// if (type == LiteralType.INT) {
+// if (min instanceof IntLiteral) {
+// try {
+// long lDefaultValue = converter.getLongConverter()
+// .toValue(defaultValue, null);
+// long lMax = ((IntLiteral) min).getValue();
+// if (lMax < lDefaultValue)
+// error("default value in ROOM model is less than this maximum",
+// minRef);
+// } catch (ValueConverterException e) {
+// warning("could not compare with int value in ROOM model (parse error)",
+// minRef);
+// }
+// } else
+// warning("could not compare with int value in ROOM model (incompatible datatypes)",
+// minRef);
+// } else if (type == LiteralType.REAL) {
+// if (min instanceof RealLiteral) {
+// try {
+// double dbDefaultValue = converter
+// .getRealConverter().toValue(defaultValue,
+// null);
+// double dbMax = ((RealLiteral) min).getValue();
+// if (dbMax < dbDefaultValue)
+// error("default value in ROOM model is less than this maximum",
+// minRef);
+// } catch (ValueConverterException e1) {
+// warning("could not compare with real value in ROOM model (parse error)",
+// minRef);
+// }
+// } else
+// warning("could not compare with real value in ROOM model (incompatible datatypes)",
+// minRef);
+// }
+//
+// }
}
}
@@ -428,50 +421,47 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
if (primitive.getType() == LiteralType.INT) {
if (!(max instanceof IntLiteral))
error("incompatible datatype: maximum is not int", maxRef);
- } else if (primitive.getType() == LiteralType.REAL) {
- if (!(max instanceof RealLiteral))
- error("incompatible datatype: maximum is not real", maxRef);
}
// check room default if config default is not set
- String defaultValue = config.getAttribute()
- .getDefaultValueLiteral();
- if (config.getValue() == null && defaultValue != null) {
- if (type == LiteralType.INT) {
- if (max instanceof IntLiteral) {
- try {
- long lDefaultValue = converter.getLongConverter()
- .toValue(defaultValue, null);
- long lMax = ((IntLiteral) max).getValue();
- if (lMax < lDefaultValue)
- error("default value in ROOM model exceeds this maximum",
- maxRef);
- } catch (ValueConverterException e) {
- warning("could not compare with int value in ROOM model (parse error)",
- maxRef);
- }
- } else
- warning("could not compare with int value in ROOM model (incompatible datatypes)",
- maxRef);
- } else if (type == LiteralType.REAL) {
- if (max instanceof RealLiteral) {
- try {
- double dbDefaultValue = converter
- .getRealConverter().toValue(defaultValue,
- null);
- double dbMax = ((RealLiteral) max).getValue();
- if (dbMax < dbDefaultValue)
- error("default value in ROOM model exceeds this maximum",
- maxRef);
- } catch (ValueConverterException e1) {
- warning("could not compare with real value in ROOM model (parse error)",
- maxRef);
- }
- } else
- warning("could not compare with real value in ROOM model (incompatible datatypes)",
- maxRef);
- }
-
- }
+// String defaultValue = config.getAttribute()
+// .getDefaultValueLiteral();
+// if (config.getValue() == null && defaultValue != null) {
+// if (type == LiteralType.INT) {
+// if (max instanceof IntLiteral) {
+// try {
+// long lDefaultValue = converter.getLongConverter()
+// .toValue(defaultValue, null);
+// long lMax = ((IntLiteral) max).getValue();
+// if (lMax < lDefaultValue)
+// error("default value in ROOM model exceeds this maximum",
+// maxRef);
+// } catch (ValueConverterException e) {
+// warning("could not compare with int value in ROOM model (parse error)",
+// maxRef);
+// }
+// } else
+// warning("could not compare with int value in ROOM model (incompatible datatypes)",
+// maxRef);
+// } else if (type == LiteralType.REAL) {
+// if (max instanceof RealLiteral) {
+// try {
+// double dbDefaultValue = converter
+// .getRealConverter().toValue(defaultValue,
+// null);
+// double dbMax = ((RealLiteral) max).getValue();
+// if (dbMax < dbDefaultValue)
+// error("default value in ROOM model exceeds this maximum",
+// maxRef);
+// } catch (ValueConverterException e1) {
+// warning("could not compare with real value in ROOM model (parse error)",
+// maxRef);
+// }
+// } else
+// warning("could not compare with real value in ROOM model (incompatible datatypes)",
+// maxRef);
+// }
+//
+// }
}
}
@@ -483,6 +473,77 @@ public class ConfigJavaValidator extends AbstractConfigJavaValidator {
return (ConfigModel) root;
}
+ private AttrClassConfig resolveAttrClassConfig(AttrInstanceConfig config) {
+ // AttrInstanceConfig -> root AttrInstanceConfig
+ List<Attribute> path = new ArrayList<Attribute>();
+ path.add(config.getAttribute());
+ AttrInstanceConfig source = config;
+ while (source.eContainer() instanceof AttrInstanceConfig) {
+ source = (AttrInstanceConfig) source.eContainer();
+ path.add(source.getAttribute());
+ }
+ Collections.reverse(path);
+ // ActorClassConfig or PortClassConfig
+ ConfigModel model = getConfigModel(source);
+ List<AttrClassConfig> rootClassAttrConfigs = new ArrayList<AttrClassConfig>();
+ if (source.eContainer() instanceof PortInstanceConfig) {
+ PortInstanceConfig portInstanceConfig = (PortInstanceConfig) source
+ .eContainer();
+ GeneralProtocolClass generalProtocol = portInstanceConfig.getItem()
+ .getGeneralProtocol();
+ PortClassConfig portClassConfig = null;
+ if (generalProtocol instanceof ProtocolClass) {
+ ProtocolClass protocol = (ProtocolClass) generalProtocol;
+ for (ProtocolClassConfig cf : model.getProtocolClassConfigs()) {
+ if (cf.getProtocol().equals(protocol)) {
+ if (protocol.getRegular().equals(
+ ConfigUtil.getPortClass(portInstanceConfig)))
+ portClassConfig = cf.getRegular();
+ else
+ portClassConfig = cf.getConjugated();
+ break;
+ }
+ }
+ }
+ if (portClassConfig != null)
+ rootClassAttrConfigs = portClassConfig.getAttributes();
+ } else if (source.eContainer() instanceof ActorInstanceConfig) {
+ ActorInstanceConfig aiConfig = (ActorInstanceConfig) source
+ .eContainer();
+ ActorClass actor = ConfigUtil.getLastActorRef(aiConfig.getRoot(),
+ aiConfig.getPath()).getType();
+ // find ActorClassConfig
+ for (ActorClassConfig cf : model.getActorClassConfigs()) {
+ if (cf.getActor().equals(actor)) {
+ rootClassAttrConfigs = cf.getAttributes();
+ break;
+ }
+ }
+ }
+
+ // -> AttrClassConfig
+ AttrClassConfig target = null;
+ for (AttrClassConfig c : rootClassAttrConfigs)
+ if (c.getAttribute().equals(path.get(0)))
+ target = c;
+ if (target != null) {
+ path.remove(0);
+ for (Attribute a : path) {
+ AttrClassConfig match = null;
+ for (AttrClassConfig c : target.getAttributes())
+ if (c.getAttribute().equals(a)) {
+ match = c;
+ break;
+ }
+ if (match == null)
+ return null;
+ target = match;
+ }
+ }
+
+ return target;
+ }
+
private String refPathToString(RefPath path) {
String str = "";
for (String s : path.getRefs())
diff --git a/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java b/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java
index a89ceb9..d56189b 100644
--- a/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java
+++ b/plugins/org.eclipse.etrice.core.config/xtend-gen/org/eclipse/etrice/core/config/DataConfiguration.java
@@ -1,5 +1,6 @@
package org.eclipse.etrice.core.config;
+import com.google.common.base.Objects;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
@@ -9,12 +10,14 @@ import org.eclipse.etrice.core.config.AttrClassConfig;
import org.eclipse.etrice.core.config.AttrInstanceConfig;
import org.eclipse.etrice.core.config.BooleanLiteral;
import org.eclipse.etrice.core.config.DataConfigurationHelper;
+import org.eclipse.etrice.core.config.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.NumberLiteral;
import org.eclipse.etrice.core.config.RealLiteral;
import org.eclipse.etrice.core.config.StringLiteral;
+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.room.ActorClass;
@@ -23,6 +26,8 @@ import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.generator.base.IDataConfiguration;
import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
@SuppressWarnings("all")
public class DataConfiguration implements IDataConfiguration {
@@ -133,36 +138,88 @@ public class DataConfiguration implements IDataConfiguration {
return _xblockexpression;
}
- public List<Attribute> getAllDynConfigReadAttributes(final ActorClass actor) {
- ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
- return _arrayList;
+ public int getPollingTimerUser(final SubSystemClass subsystem) {
+ SubSystemConfig _config = this.getConfig(subsystem);
+ DynamicConfig _dynConfig = _config==null?(DynamicConfig)null:_config.getDynConfig();
+ int _polling = _dynConfig==null?0:_dynConfig.getPolling();
+ return _polling;
}
- public List<Attribute> getAllDynConfigWriteAttributes(final ActorClass actor) {
- ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
- return _arrayList;
+ public String getUserCode1(final SubSystemClass subsystem) {
+ SubSystemConfig _config = this.getConfig(subsystem);
+ DynamicConfig dynConfig = _config==null?(DynamicConfig)null:_config.getDynConfig();
+ String _xifexpression = null;
+ String _filePath = dynConfig==null?(String)null:dynConfig.getFilePath();
+ boolean _notEquals = (!Objects.equal(_filePath, null));
+ if (_notEquals) {
+ _xifexpression = "import org.eclipse.etrice.runtime.java.config.ConfigSourceFile; // TODO JH make lang independent";
+ } else {
+ String _userCode1 = dynConfig==null?(String)null:dynConfig.getUserCode1();
+ _xifexpression = _userCode1;
+ }
+ return _xifexpression;
}
- public List<Attribute> getDynConfigReadAttributes(final SubSystemClass subsystem) {
- ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
- return _arrayList;
+ public String getUserCode2(final SubSystemClass subsystem) {
+ SubSystemConfig _config = this.getConfig(subsystem);
+ DynamicConfig dynConfig = _config==null?(DynamicConfig)null:_config.getDynConfig();
+ String _xifexpression = null;
+ String _filePath = dynConfig==null?(String)null:dynConfig.getFilePath();
+ boolean _notEquals = (!Objects.equal(_filePath, null));
+ if (_notEquals) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("new ConfigSourceFile(\"");
+ String _filePath_1 = dynConfig.getFilePath();
+ _builder.append(_filePath_1, "");
+ _builder.append("\")");
+ _xifexpression = _builder.toString();
+ } else {
+ String _userCode2 = dynConfig==null?(String)null:dynConfig.getUserCode2();
+ _xifexpression = _userCode2;
+ }
+ return _xifexpression;
}
- public List<Attribute> getDynConfigWriteAttributes(final SubSystemClass subsystem) {
+ public List<Attribute> getDynConfigReadAttributes(final String actorInstance) {
ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
- return _arrayList;
- }
-
- public boolean hasDynConfigReadAttributes(final ActorClass actor) {
- return false;
+ final ArrayList<Attribute> result = _arrayList;
+ List<AttrInstanceConfig> configs = DataConfigurationHelper.dynActorInstanceAttrMap.get(actorInstance);
+ final Procedure1<AttrInstanceConfig> _function = new Procedure1<AttrInstanceConfig>() {
+ public void apply(final AttrInstanceConfig c) {
+ boolean _isReadOnly = c.isReadOnly();
+ if (_isReadOnly) {
+ Attribute _attribute = c.getAttribute();
+ result.add(_attribute);
+ }
+ }
+ };
+ if (configs!=null) IterableExtensions.<AttrInstanceConfig>forEach(configs, _function);
+ return result;
}
- public boolean hasDynConfigWriteAttributes(final ActorClass actor) {
- return false;
+ public List<Attribute> getDynConfigWriteAttributes(final String actorInstance) {
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ final ArrayList<Attribute> result = _arrayList;
+ List<AttrInstanceConfig> configs = DataConfigurationHelper.dynActorInstanceAttrMap.get(actorInstance);
+ final Procedure1<AttrInstanceConfig> _function = new Procedure1<AttrInstanceConfig>() {
+ public void apply(final AttrInstanceConfig c) {
+ boolean _isReadOnly = c.isReadOnly();
+ boolean _not = (!_isReadOnly);
+ if (_not) {
+ Attribute _attribute = c.getAttribute();
+ result.add(_attribute);
+ }
+ }
+ };
+ if (configs!=null) IterableExtensions.<AttrInstanceConfig>forEach(configs, _function);
+ return result;
}
public boolean hasVariableService(final SubSystemClass subsystem) {
- return false;
+ SubSystemConfig _config = this.getConfig(subsystem);
+ DynamicConfig _dynConfig = _config==null?(DynamicConfig)null:_config.getDynConfig();
+ boolean _notEquals = (!Objects.equal(_dynConfig, null));
+ return _notEquals;
}
private String toStringExpr(final LiteralArray literal) {
@@ -225,4 +282,44 @@ public class DataConfiguration implements IDataConfiguration {
}
return _switchResult;
}
+
+ private SubSystemConfig getConfig(final SubSystemClass cc) {
+ SubSystemConfig _get = DataConfigurationHelper.subSystemConfigMap.get(cc);
+ return _get;
+ }
+
+ public List<Attribute> getDynConfigReadAttributes(final ActorClass actor) {
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ final ArrayList<Attribute> result = _arrayList;
+ List<AttrInstanceConfig> configs = DataConfigurationHelper.dynActorClassAttrMap.get(actor);
+ final Procedure1<AttrInstanceConfig> _function = new Procedure1<AttrInstanceConfig>() {
+ public void apply(final AttrInstanceConfig c) {
+ boolean _isReadOnly = c.isReadOnly();
+ if (_isReadOnly) {
+ Attribute _attribute = c.getAttribute();
+ result.add(_attribute);
+ }
+ }
+ };
+ if (configs!=null) IterableExtensions.<AttrInstanceConfig>forEach(configs, _function);
+ return result;
+ }
+
+ public List<Attribute> getDynConfigWriteAttributes(final ActorClass actor) {
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ final ArrayList<Attribute> result = _arrayList;
+ List<AttrInstanceConfig> configs = DataConfigurationHelper.dynActorClassAttrMap.get(actor);
+ final Procedure1<AttrInstanceConfig> _function = new Procedure1<AttrInstanceConfig>() {
+ public void apply(final AttrInstanceConfig c) {
+ boolean _isReadOnly = c.isReadOnly();
+ boolean _not = (!_isReadOnly);
+ if (_not) {
+ Attribute _attribute = c.getAttribute();
+ result.add(_attribute);
+ }
+ }
+ };
+ if (configs!=null) IterableExtensions.<AttrInstanceConfig>forEach(configs, _function);
+ return result;
+ }
}
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 7e5f189..e6418cd 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
@@ -57,9 +57,9 @@ class ActorClassGen extends GenericActorClassGenerator {
'''
package «ac.getPackage»;
- «IF dataConfigExt.hasDynConfigReadAttributes(ac)»
+ «IF !dataConfigExt.getDynConfigReadAttributes(ac).empty»
import org.eclipse.etrice.runtime.java.config.DynConfigLock;«ENDIF»
- «IF dataConfigExt.hasDynConfigReadAttributes(ac) || dataConfigExt.hasDynConfigWriteAttributes(ac)»
+ «IF !dataConfigExt.getDynConfigReadAttributes(ac).empty || !dataConfigExt.getDynConfigWriteAttributes(ac).empty»
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;
@@ -85,7 +85,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«ac.userCode(2)»
- «IF dataConfigExt.hasDynConfigWriteAttributes(ac)»
+ «IF !dataConfigExt.getDynConfigWriteAttributes(ac).empty»
private VariableService variableService;
«ENDIF»
@@ -109,7 +109,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«configGenAddon.genMinMaxConstants(ac)»
«ac.attributes.attributes»
- «FOR a : dataConfigExt.getAllDynConfigReadAttributes(ac)»
+ «FOR a : dataConfigExt.getDynConfigReadAttributes(ac)»
private DynConfigLock lock_«a.name»;
«ENDFOR»
«ac.operationsImplementation»
@@ -148,20 +148,20 @@ class ActorClassGen extends GenericActorClassGenerator {
«ENDIF»
}
- «IF dataConfigExt.hasDynConfigReadAttributes(ac) || dataConfigExt.hasDynConfigWriteAttributes(ac)»
+ «IF !dataConfigExt.getDynConfigReadAttributes(ac).empty || !dataConfigExt.getDynConfigWriteAttributes(ac).empty»
public «ac.name»(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr, VariableService variableService){
this(parent, name, port_addr, peer_addr);
- «IF dataConfigExt.hasDynConfigWriteAttributes(ac)»
+ «IF !dataConfigExt.getDynConfigWriteAttributes(ac).empty»
this.variableService = variableService;
«ENDIF»
- «FOR a : dataConfigExt.getAllDynConfigReadAttributes(ac)»
+ «FOR a : dataConfigExt.getDynConfigReadAttributes(ac)»
lock_«a.name» = new DynConfigLock();
«ENDFOR»
}
«ENDIF»
- «attributeSettersGettersImplementation(ac.attributes.minus(dataConfigExt.getAllDynConfigReadAttributes(ac).toList), ac.name)»
+ «attributeSettersGettersImplementation(ac.attributes.minus(dataConfigExt.getDynConfigReadAttributes(ac)), ac.name)»
«configGenAddon.genDynConfigGetterSetter(ac)»
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 dcd44fe..bc5af53 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
@@ -70,39 +70,35 @@ class ConfigGenAddon {
// For ActorClassGen
-// 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 genDynConfigGetterSetter(ActorClass ac){'''
+ «FOR a : dataConfigExt.getDynConfigReadAttributes(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.getDynConfigWriteAttributes(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 public genMinMaxConstants(ActorClass ac){
var result = '''
@@ -148,4 +144,5 @@ class ConfigGenAddon {
type.typeName
}
}
+
} \ No newline at end of file
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 402a944..27524c4 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
@@ -50,35 +50,37 @@ class Initialization {
def private attributeInit(EObject roomClass, List<Attribute> path, boolean useClassDefaultsOnly) {
var a = path.last
- if(a.refType.type.dataClass){
+ var aType = a.refType.type
+ if(aType.dataClass){
var result =
'''
- «FOR e : (a.refType.type as DataClass).attributes»
+ «FOR e : (aType as DataClass).attributes»
«attributeInit(roomClass, path.union(e), useClassDefaultsOnly)»
«ENDFOR»
'''
if(result.length > 0)
- result
+ return result
}
- else {
+
+ var value = getInitValueLiteral(roomClass, path)
+ var getter = if(path.size > 1)procedureHelpers.invokeGetters(path.take(path.size-1), null)+"." else ""
+ return
'''
- «var aType = a.refType.type»
- «var value = getInitValueLiteral(roomClass, path)»
«IF value!=null»
«IF a.size == 0 || aType.characterType»
- «path.take(path.size-1).invokeGetter»«procedureHelpers.invokeSetter(a.name,null,value)»;
+ «getter»«procedureHelpers.invokeSetter(a.name,null,value)»;
«ELSEIF value.startsWith("{")»
- «path.take(path.size-1).invokeGetter»«procedureHelpers.invokeSetter(a.name,null, '''new «aType.typeName»[] «value»''')»;
+ «getter»«procedureHelpers.invokeSetter(a.name,null, '''new «aType.typeName»[] «value»''')»;
«ELSE»
{
- «a.name» = new «aType.typeName»[«a.size»];
+ «aType.typeName»[] _«a.name» = new «aType.typeName»[«a.size»];
for (int i=0;i<«a.size»;i++){
- «a.name»[i] = «value»;
+ _«a.name»[i] = «value»;
}
- «path.take(path.size-1).invokeGetter»«procedureHelpers.invokeSetter(a.name,null,a.name)»;
+ «getter»«procedureHelpers.invokeSetter(a.name,null,"_"+a.name)»;
}
«ENDIF»
- «ELSEIF aType instanceof ComplexType || a.size>1 || !useClassDefaultsOnly»
+ «ELSEIF path.size == 1 && (aType instanceof ComplexType || a.size>1 || !useClassDefaultsOnly)»
«IF a.size==0»
«IF a.refType.isRef»
«a.name» = «languageExt.nullPointer()»;
@@ -95,7 +97,7 @@ class Initialization {
«ENDIF»
«ENDIF»
'''
- }
+
}
def private getInitValueLiteral(EObject roomClass, List<Attribute> path){
@@ -117,10 +119,7 @@ class Initialization {
// array syntax ?
'''{ «FOR s : result.split(",") SEPARATOR ' ,'»«languageExt.toValueLiteral(aType, s.trim)»«ENDFOR» }'''.toString
}
- a.defaultValueLiteral
- }
-
- def private invokeGetter(Iterable<Attribute> path){
- '''«FOR a : path»«procedureHelpers.invokeGetter(a.name, null)».«ENDFOR»'''
+ if(path.size == 1)
+ a.defaultValueLiteral
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.xtend
index d9afa54..a6ea5f4 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
@@ -45,8 +45,8 @@ class SubSystemClassGen {
logger.logInfo("generating SubSystemClass implementation: '"+file+"' in '"+path+"'")
fileAccess.setOutputPath(path)
fileAccess.generateFile(file, root.generate(ssi, ssi.subSystemClass))
- //if(dataConfigExt.hasVariableService(ssi.subSystemClass))
- // varService.doGenerate(root, ssi);
+ if(dataConfigExt.hasVariableService(ssi.subSystemClass))
+ varService.doGenerate(root, ssi);
}
}
@@ -167,7 +167,7 @@ class SubSystemClassGen {
«ENDIF»
«ENDFOR»
}
- «IF false»
+ «IF !dataConfigExt.getDynConfigWriteAttributes(ai.path).empty»
, variableService
«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 7145acb..70a69b5 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
@@ -10,32 +10,30 @@
*
*******************************************************************************/
-package org.eclipse.etrice.generator.java.gen
-
-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 org.eclipse.etrice.core.config.ActorClassConfig
-import org.eclipse.etrice.core.config.ActorInstanceConfig
-import org.eclipse.etrice.core.config.AttrInstanceConfig
-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.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.ProcedureHelpers
-import org.eclipse.etrice.generator.generic.RoomExtensions
-import org.eclipse.etrice.generator.generic.TypeHelpers
+package org.eclipse.etrice.generator.java.gen
+
+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 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.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.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.xtext.generator.JavaIoFileSystemAccess
-import org.eclipse.etrice.generator.base.IDataConfiguration
+import org.eclipse.etrice.core.room.ActorClass
+import java.util.Collection
@Singleton
class VariableServiceGen {
@@ -43,11 +41,11 @@ class VariableServiceGen {
@Inject extension JavaIoFileSystemAccess fileAccess
@Inject extension JavaExtensions stdExt
@Inject extension RoomExtensions roomExt
- @Inject extension IDataConfiguration configExt
+ @Inject 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"
@@ -56,8 +54,10 @@ class VariableServiceGen {
fileAccess.generateFile(file, root.generate(ssi, ssi.subSystemClass))
}
- def private generate(Root root, SubSystemInstance comp, SubSystemClass cc) {'''
- «val dynConfig = cc.subSystemConfig.dynConfig»
+ def private generate(Root root, SubSystemInstance comp, SubSystemClass cc) {
+ val aisAttrMap = new HashMap<ActorInstance, List<Attribute>>
+ comp.allContainedInstances.forEach(ai | if(!configExt.getDynConfigReadAttributes(ai.path).empty)aisAttrMap.put(ai, configExt.getDynConfigReadAttributes(ai.path)))
+ '''
package «cc.getPackage()»;
@@ -65,13 +65,8 @@ class VariableServiceGen {
import java.util.HashMap;
import java.util.Map;
import org.eclipse.etrice.runtime.java.config.VariableService;
- «IF dynConfig.userCode1 != null»
- «dynConfig.userCode1»;
- «ELSE»
- import org.eclipse.etrice.runtime.java.config.ConfigSourceFile;
- «ENDIF»
- «var ais = dynConfigsAIs(comp)»
- «FOR model : ais.roomModels»
+ «configExt.getUserCode1(cc)»
+ «FOR model : aisAttrMap.keySet.roomModels»
import «model.name».*;
«ENDFOR»
@@ -81,19 +76,19 @@ class VariableServiceGen {
private «cc.name» subSystem;
// Actor instances
- «FOR ai : ais»
- private «ai.actorClass.name» «ai.path.split("/").drop(2).toPath("_")»;
+ «FOR ai : aisAttrMap.keySet»
+ private «ai.actorClass.name» «ai.varName»;
«ENDFOR»
public «comp.name+"VariableService"»(«cc.name» subSystem) {
- super(«IF dynConfig.filePath != null»new ConfigSourceFile("«dynConfig.filePath»")«ELSE»«dynConfig.userCode2»«ENDIF»);
+ super(«configExt.getUserCode2(cc)»);
this.subSystem = subSystem;
}
@Override
protected void initInstances(){
- «FOR ai : ais»
- «ai.path.split("/").drop(2).toPath("_")» = («ai.actorClass.name»)subSystem.getInstance("«ai.path»");
+ «FOR ai : aisAttrMap.keySet»
+ «ai.varName» = («ai.actorClass.name»)subSystem.getInstance("«ai.path»");
«ENDFOR»
}
@@ -102,50 +97,31 @@ class VariableServiceGen {
protected void setAttributeValues(Map<String, Object> values) {
Object object;
String id = null;
- «FOR attrConfig : cc.dynConfigReadAttributes»
- «var aiName = (attrConfig.eContainer as ActorInstanceConfig).path.refs.toPath("_")»
- try{
- boolean changed = false;
- «FOR entry : attrConfig.allAttributes.entrySet»
- «var a = entry.key»
- «var aPath = attrConfig.getPath(true, true, true, false).toPath("/")+entry.value.toPath("/")+"/"+a.name»
- id = "«aPath»";
- «IF a.size==0»«a.refType.type.typeName.toWrapper»«ELSE»«a.refType.type.typeName»[]«ENDIF» _«a.name» = null;
- object = values.get(id);
- if(object != null){
- _«a.name» = ensure«a.refType.type.typeName.toFirstUpper»«IF a.size>0»Array«ENDIF»(object«IF a.size>0», «a.size»«ENDIF»);
- «genMinMaxCheck(attrConfig, (attrConfig.eContainer as ActorInstanceConfig).actorClassConfig)»
- if(!«IF a.size==0»_«a.name».equals(«ELSE»Arrays.equals(_«a.name», «ENDIF»(«IF a.size==0»«a.refType.type.typeName.toWrapper»«ELSE»«a.refType.type.typeName»[]«ENDIF»)getDiffMap().get(id)))
- changed = true;
- } else
- warning(id, "is missing");
- «ENDFOR»
- if(changed)
- synchronized(«aiName».«invokeGetter(attrConfig.attribute.name+"Lock", null)»){
- if(«aiName».«invokeGetter(attrConfig.attribute.name+"Lock", null)».isUpdate()){
- «FOR entry : attrConfig.allAttributes.entrySet»
- if(_«entry.key.name» != null){
- «aiName»«entry.value.toInvoke».«invokeSetter(entry.key.name, null, "_"+entry.key.name)»;
- getDiffMap().put("«attrConfig.getPath(true, true, true, false).toPath("/")+entry.value.toPath("/")+"/"+entry.key.name»", _«entry.key.name»);
- }
- «ENDFOR»
- }
- }
- }catch(IllegalArgumentException e){
- error(id, e);
- }
+
+ «FOR ai : aisAttrMap.keySet»
+ «FOR a : aisAttrMap.get(ai)»
+ try{
+ boolean changed = false;
+ «genSetAttributeValues1(new ArrayList<Attribute>.union(a), ai)»
+ if(changed)
+ synchronized(«ai.varName».«invokeGetter(a.name+"Lock", null)»){
+ if(«ai.varName».«invokeGetter(a.name+"Lock", null)».isUpdate()){
+ «genSetAttributeValues2(new ArrayList<Attribute>.union(a), ai)»
+ }
+ }
+ }catch(IllegalArgumentException e){
+ error(id, e);
+ }
+ «ENDFOR»
«ENDFOR»
}
@Override
protected Map<String, Object> getAttributeValues(){
Map<String, Object> values = new HashMap<String, Object>();
- «FOR attrConfig : cc.getAttrDynConfigs(true, false)»
- «var aiName = (attrConfig.eContainer as ActorInstanceConfig).path.refs.toPath("_")»
- «FOR entry : attrConfig.allAttributes.entrySet»
- «var array = entry.key.size>0»
- «var aPath = attrConfig.getPath(true, true, true, false).toPath("/")+entry.value.toPath("/")+"/"+entry.key.name»
- values.put("«aPath»", «IF array»toObjectArray(«ENDIF»«aiName»«entry.value.toInvoke».«invokeGetter(entry.key.name, null)»«IF array»)«ENDIF»);
+ «FOR ai : aisAttrMap.keySet»
+ «FOR a : aisAttrMap.get(ai)»
+ «genGetAttributeValues(new ArrayList<Attribute>.union(a), ai)»
«ENDFOR»
«ENDFOR»
@@ -154,7 +130,8 @@ class VariableServiceGen {
@Override
public void writeDataClass(String id, Object dcObject, Map<String, Object> writeMap) {
- «FOR dc : comp.dynDataClasses»
+ «var dataClasses = aisAttrMap.keySet.dynConfigDataClasses»
+ «FOR dc : dataClasses»
if(dcObject.getClass().equals(«dc.typeName».class))
writeDataClass(id, («dc.typeName») dcObject, writeTasks);
«ENDFOR»
@@ -162,7 +139,7 @@ class VariableServiceGen {
// DataClasses write operations
- «FOR dc : comp.allDynDataClasses»
+ «FOR dc : getAllDataClasses(dataClasses)»
private void writeDataClass(String id, «dc.typeName» object, Map<String, Object> map){
«FOR a : dc.attributes»
«IF a.refType.type.primitive»
@@ -176,108 +153,118 @@ class VariableServiceGen {
@Override
protected int getPollingTimerUser(){
- return «dynConfig.polling»;
+ return «configExt.getPollingTimerUser(cc)»;
}
}
'''}
- def private genMinMaxCheck(AttrInstanceConfig instConf, ActorClassConfig acConf){
- var config = acConf?.resolve(instConf.getPath(false, false, true, true))
- if(config?.min == null && config?.max == null)
- return ''''''
- var path = config.getPath(false, false, true, true).toPath("_")
- var acName = (config.eContainer as ActorClassConfig).actor.name
- '''
- checkMinMax(_«config.attribute.name», «IF config.min != null»«acName».MIN«path»«ELSE»null«ENDIF», «IF config.max != null»«acName».MAX«path»«ELSE»null«ENDIF»);
- '''
- }
-
- def private Map<Attribute, List<String>> getAllAttributes(AttrInstanceConfig config){
- var map = new HashMap<Attribute, List<String>>()
- if(config.attribute.refType.type.primitive)
- map.put(config.attribute, new ArrayList<String>())
+ def private genMinMaxCheck(List<Attribute> path, ActorClass ac){
+ var aVarName = path.toAbsolutePath("_")
+ var min = configExt.getAttrClassConfigMinValue(ac, path) != null
+ var max = configExt.getAttrClassConfigMaxValue(ac, path) != null
+ if(min || max)
+ '''
+ checkMinMax(«aVarName», «IF min»«ac.name».MIN«aVarName»«ELSE»null«ENDIF», «IF max»«ac.name».MAX«aVarName»«ELSE»null«ENDIF»);
+ '''
else
- config.attribute.getAllAttributes(new LinkedList<String>(), map)
-
- return map
+ ''''''
+ }
+
+ def private getDynConfigDataClasses(Iterable<ActorInstance> ais){
+ val result = new HashSet<DataClass>
+ ais.forEach(ai | configExt.getDynConfigReadAttributes(ai.path).
+ forEach(a | if(a.refType.type.dataClass)result.add(a.refType.type as DataClass)
+ ))
+ return result
}
- def private void getAllAttributes(Attribute attribute, List<String> path, Map<Attribute, List<String>> map){
- if(attribute.refType.type.primitive)
- map.put(attribute, path)
- else if (attribute.refType.type.dataClass){
- var new_path = new ArrayList<String>(path)
- new_path.add(attribute.name)
- for(dc : (attribute.refType.type as DataClass).allAttributes)
- dc.getAllAttributes(new_path, map)
+ def private getAllDataClasses(Iterable<DataClass> dcs){
+ val result = new HashSet<DataClass>
+ result.addAll(dcs)
+ val visit = new LinkedList<DataClass>
+ visit.addAll(dcs)
+ while(!visit.empty){
+ var dc = visit.pop
+ dc.allAttributes.forEach(a | if(a.refType.type.dataClass)visit.add(a.refType.type as DataClass))
}
+ return result
}
- def private String toInvoke(List<String> path){
- var builder = new StringBuilder()
- for(p : path)
- builder.append("."+p.invokeGetter(null))
-
- return builder.toString
+ def private getRoomModels(Collection<ActorInstance> ais){
+ val models = new HashSet<RoomModel>
+ ais.forEach(ai | models.add(ai.actorClass.eContainer as RoomModel))
+ return models
}
- def private List<ActorInstance> dynConfigsAIs(SubSystemInstance comp){
- val aiPaths = new HashSet<String>();
- for(attrConfig : comp.subSystemClass.dynConfigReadAttributes)
- aiPaths.add(attrConfig.getPath(true, true, false, false).toPath("/"))
-
- var ais = new ArrayList<ActorInstance>();
- for(ai : comp.allContainedInstances)
- if(aiPaths.contains(ai.path))
- ais.add(ai);
-
- return ais
+ def private toAbsolutePath(List<Attribute> path, String pathDelim){
+ '''«FOR p : path»«pathDelim»«p.name»«ENDFOR»'''.toString
}
-
- def private getDynDataClasses(SubSystemInstance comp){
- var dcs = new HashSet<DataClass>()
- for(config : comp.subSystemClass.getAttrDynConfigs(false, true))
- if(config.attribute.refType.type.dataClass)
- dcs.add(config.attribute.refType.type as DataClass)
-
- return dcs
+ def private getVarName(ActorInstance ai){
+ '''«FOR p : ai.path.split('/').drop(2) SEPARATOR '_'»«p»«ENDFOR»'''
}
- def private getAllDynDataClasses(SubSystemInstance comp){
- var dcs = new HashSet<DataClass>()
- var stack = new LinkedList<DataClass>()
- stack.addAll(comp.dynDataClasses)
- dcs.addAll(stack)
- while(!stack.empty){
- var dc = stack.pop
- for(a : dc.allAttributes)
- if(a.refType.type.dataClass){
- dcs.add(a.refType.type as DataClass)
- stack.push(a.refType.type as DataClass);
- }
- }
-
- return dcs
+ def private genGetAttributeValues(List<Attribute> path, ActorInstance ai){
+ var a = path.last
+ if(a.refType.type.primitive){'''
+ values.put("«ai.path»«path.toAbsolutePath('/')»", «IF a.size>0»toObjectArray(«ENDIF»«ai.varName».«path.invokeGetters(null)»«IF a.size>0»)«ENDIF»);
+ '''
+ } else if(a.refType.type.dataClass){
+ var dataClass = (a.refType.type as DataClass)
+ '''
+ «FOR at : dataClass.allAttributes»
+ «genGetAttributeValues(path.union(at), ai)»
+ «ENDFOR»
+ '''
+ }
}
- def private resolve(ActorClassConfig config, String[] path){
- var result = config.attributes.findFirst(c | c.attribute.name.equals(path.head))
- for (String ref : path.tail) {
- result = result?.attributes.findFirst(c | c.attribute.name.equals(ref))
- if (result == null)
- return null
+ def private genSetAttributeValues1(List<Attribute> path, ActorInstance ai){
+ var a = path.last
+ var aVarName = path.toAbsolutePath("_")
+ if(a.refType.type.primitive){'''
+ id = "«ai.path»«path.toAbsolutePath("/")»";
+ «IF a.size==0»«a.refType.type.typeName.toWrapper»«ELSE»«a.refType.type.typeName»[]«ENDIF» «aVarName» = null;
+ object = values.get(id);
+ if(object != null){
+ «aVarName» = ensure«a.refType.type.typeName.toFirstUpper»«IF a.size>0»Array«ENDIF»(object«IF a.size>0», «a.size»«ENDIF»);
+ «genMinMaxCheck(path, ai.actorClass)»
+ if(!«IF a.size==0»«aVarName».equals(«ELSE»Arrays.equals(«aVarName», «ENDIF»(«IF a.size==0»«a.refType.type.typeName.toWrapper»«ELSE»«a.refType.type.typeName»[]«ENDIF»)getDiffMap().get(id)))
+ changed = true;
+ } else
+ warning(id, "is missing");
+ '''
+ } else if(a.refType.type.dataClass){
+ var dataClass = (a.refType.type as DataClass)
+ '''
+ «FOR at : dataClass.allAttributes»
+ «genSetAttributeValues1(path.union(at), ai)»
+ «ENDFOR»
+ '''
}
-
- return result
}
- def private getRoomModels(List<ActorInstance> ais){
- val models = new HashSet<RoomModel>
- ais.forEach(ai | models.add(ai.actorClass.eContainer as RoomModel))
- return models
+ def private genSetAttributeValues2(List<Attribute> path, ActorInstance ai){
+ var a = path.last
+ var aVarName = path.toAbsolutePath("_")
+ if(a.refType.type.primitive){
+ var getters = if(path.size>1)path.take(path.size-1).invokeGetters(null)+"." else ""
+ '''
+ if(«aVarName» != null){
+ «ai.varName».«getters»«invokeSetter(a.name, null, aVarName)»;
+ getDiffMap().put("«ai.path»«path.toAbsolutePath("/")»", «aVarName»);
+ }
+ '''
+ } else if(a.refType.type.dataClass){
+ var dataClass = (a.refType.type as DataClass)
+ '''
+ «FOR at : dataClass.allAttributes»
+ «genSetAttributeValues2(path.union(at), ai)»
+ «ENDFOR»
+ '''
+ }
}
- */
+
} \ No newline at end of file
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 2da7d87..0d44f61 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
@@ -116,20 +116,26 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLineIfNotEmpty();
_builder.newLine();
{
- boolean _hasDynConfigReadAttributes = this.dataConfigExt.hasDynConfigReadAttributes(ac);
- if (_hasDynConfigReadAttributes) {
+ List<Attribute> _dynConfigReadAttributes = this.dataConfigExt.getDynConfigReadAttributes(ac);
+ boolean _isEmpty = _dynConfigReadAttributes.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
_builder.append("import org.eclipse.etrice.runtime.java.config.DynConfigLock;");
}
}
_builder.newLineIfNotEmpty();
{
boolean _or = false;
- boolean _hasDynConfigReadAttributes_1 = this.dataConfigExt.hasDynConfigReadAttributes(ac);
- if (_hasDynConfigReadAttributes_1) {
+ List<Attribute> _dynConfigReadAttributes_1 = this.dataConfigExt.getDynConfigReadAttributes(ac);
+ boolean _isEmpty_1 = _dynConfigReadAttributes_1.isEmpty();
+ boolean _not_1 = (!_isEmpty_1);
+ if (_not_1) {
_or = true;
} else {
- boolean _hasDynConfigWriteAttributes = this.dataConfigExt.hasDynConfigWriteAttributes(ac);
- _or = (_hasDynConfigReadAttributes_1 || _hasDynConfigWriteAttributes);
+ List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(ac);
+ boolean _isEmpty_2 = _dynConfigWriteAttributes.isEmpty();
+ boolean _not_2 = (!_isEmpty_2);
+ _or = (_not_1 || _not_2);
}
if (_or) {
_builder.append("import org.eclipse.etrice.runtime.java.config.VariableService;");
@@ -215,8 +221,10 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.newLine();
{
- boolean _hasDynConfigWriteAttributes_1 = this.dataConfigExt.hasDynConfigWriteAttributes(ac);
- if (_hasDynConfigWriteAttributes_1) {
+ List<Attribute> _dynConfigWriteAttributes_1 = this.dataConfigExt.getDynConfigWriteAttributes(ac);
+ boolean _isEmpty_3 = _dynConfigWriteAttributes_1.isEmpty();
+ boolean _not_3 = (!_isEmpty_3);
+ if (_not_3) {
_builder.append("\t");
_builder.append("private VariableService variableService;");
_builder.newLine();
@@ -299,8 +307,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append(_attributes_1, " ");
_builder.newLineIfNotEmpty();
{
- List<Attribute> _allDynConfigReadAttributes = this.dataConfigExt.getAllDynConfigReadAttributes(ac);
- for(final Attribute a : _allDynConfigReadAttributes) {
+ List<Attribute> _dynConfigReadAttributes_2 = this.dataConfigExt.getDynConfigReadAttributes(ac);
+ for(final Attribute a : _dynConfigReadAttributes_2) {
_builder.append("\t");
_builder.append("private DynConfigLock lock_");
String _name_7 = a.getName();
@@ -497,12 +505,16 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
{
boolean _or_1 = false;
- boolean _hasDynConfigReadAttributes_2 = this.dataConfigExt.hasDynConfigReadAttributes(ac);
- if (_hasDynConfigReadAttributes_2) {
+ List<Attribute> _dynConfigReadAttributes_3 = this.dataConfigExt.getDynConfigReadAttributes(ac);
+ boolean _isEmpty_4 = _dynConfigReadAttributes_3.isEmpty();
+ boolean _not_4 = (!_isEmpty_4);
+ if (_not_4) {
_or_1 = true;
} else {
- boolean _hasDynConfigWriteAttributes_2 = this.dataConfigExt.hasDynConfigWriteAttributes(ac);
- _or_1 = (_hasDynConfigReadAttributes_2 || _hasDynConfigWriteAttributes_2);
+ List<Attribute> _dynConfigWriteAttributes_2 = this.dataConfigExt.getDynConfigWriteAttributes(ac);
+ boolean _isEmpty_5 = _dynConfigWriteAttributes_2.isEmpty();
+ boolean _not_5 = (!_isEmpty_5);
+ _or_1 = (_not_4 || _not_5);
}
if (_or_1) {
_builder.append("\t");
@@ -519,8 +531,10 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.newLine();
{
- boolean _hasDynConfigWriteAttributes_3 = this.dataConfigExt.hasDynConfigWriteAttributes(ac);
- if (_hasDynConfigWriteAttributes_3) {
+ List<Attribute> _dynConfigWriteAttributes_3 = this.dataConfigExt.getDynConfigWriteAttributes(ac);
+ boolean _isEmpty_6 = _dynConfigWriteAttributes_3.isEmpty();
+ boolean _not_6 = (!_isEmpty_6);
+ if (_not_6) {
_builder.append("\t");
_builder.append("\t");
_builder.append("this.variableService = variableService;");
@@ -528,8 +542,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
}
}
{
- List<Attribute> _allDynConfigReadAttributes_1 = this.dataConfigExt.getAllDynConfigReadAttributes(ac);
- for(final Attribute a_1 : _allDynConfigReadAttributes_1) {
+ List<Attribute> _dynConfigReadAttributes_4 = this.dataConfigExt.getDynConfigReadAttributes(ac);
+ for(final Attribute a_1 : _dynConfigReadAttributes_4) {
_builder.append("\t");
_builder.append("\t");
_builder.append("lock_");
@@ -548,9 +562,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
_builder.append("\t");
EList<Attribute> _attributes_3 = ac.getAttributes();
- 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);
+ List<Attribute> _dynConfigReadAttributes_5 = this.dataConfigExt.getDynConfigReadAttributes(ac);
+ List<Attribute> _minus = this._roomExtensions.<Attribute>minus(_attributes_3, _dynConfigReadAttributes_5);
String _name_27 = ac.getName();
CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_minus, _name_27);
_builder.append(_attributeSettersGettersImplementation, " ");
@@ -558,7 +571,7 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
- Object _genDynConfigGetterSetter = this.configGenAddon.genDynConfigGetterSetter(ac);
+ CharSequence _genDynConfigGetterSetter = this.configGenAddon.genDynConfigGetterSetter(ac);
_builder.append(_genDynConfigGetterSetter, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -629,8 +642,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLine();
{
boolean _overridesStop = this._roomExtensions.overridesStop(ac);
- boolean _not = (!_overridesStop);
- if (_not) {
+ boolean _not_7 = (!_overridesStop);
+ if (_not_7) {
_builder.append("\t");
_builder.append("public void stop(){");
_builder.newLine();
@@ -672,8 +685,8 @@ public class ActorClassGen extends GenericActorClassGenerator {
_builder.newLineIfNotEmpty();
} else {
boolean _hasStateMachine = xpac.hasStateMachine();
- boolean _not_1 = (!_hasStateMachine);
- if (_not_1) {
+ boolean _not_8 = (!_hasStateMachine);
+ if (_not_8) {
_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 1c5ba56..80d84c1 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
@@ -20,6 +20,7 @@ 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.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
@SuppressWarnings("all")
public class ConfigGenAddon {
@@ -38,17 +39,15 @@ public class ConfigGenAddon {
@Inject
private RoomExtensions _roomExtensions;
- public CharSequence genActorInstanceConfig(final ActorInstance ai) {
+ public CharSequence genActorInstanceConfig(final ActorInstance ai, final String aiVariableName) {
StringConcatenation _builder = new StringConcatenation();
{
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);
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
+ CharSequence _applyInstanceConfig = this.applyInstanceConfig(ai, aiVariableName, _union);
_builder.append(_applyInstanceConfig, "");
_builder.newLineIfNotEmpty();
}
@@ -56,9 +55,10 @@ public class ConfigGenAddon {
return _builder;
}
- public CharSequence applyInstanceConfig(final ActorInstance ai, final String invokes, final String instancePath, final Attribute a) {
+ private CharSequence applyInstanceConfig(final ActorInstance ai, final String invokes, final List<Attribute> path) {
CharSequence _xblockexpression = null;
{
+ Attribute a = IterableExtensions.<Attribute>last(path);
RefableType _refType = a.getRefType();
DataType aType = _refType.getType();
CharSequence _xifexpression = null;
@@ -66,7 +66,7 @@ public class ConfigGenAddon {
if (_isPrimitive) {
CharSequence _xblockexpression_1 = null;
{
- String value = this.dataConfigExt.getAttrInstanceConfigValue(ai, instancePath);
+ String value = this.dataConfigExt.getAttrInstanceConfigValue(ai, path);
CharSequence _xifexpression_1 = null;
boolean _equals = Objects.equal(value, null);
if (_equals) {
@@ -103,6 +103,7 @@ public class ConfigGenAddon {
CharSequence _xblockexpression_2 = null;
{
StringConcatenation _builder_2 = new StringConcatenation();
+ _builder_2.append("{ ");
{
String[] _split_1 = value.split(",");
boolean _hasElements = false;
@@ -110,13 +111,14 @@ public class ConfigGenAddon {
if (!_hasElements) {
_hasElements = true;
} else {
- _builder_2.appendImmediate(",", "");
+ _builder_2.appendImmediate(", ", "");
}
String _trim = s.trim();
String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), _trim);
_builder_2.append(_valueLiteral_1, "");
}
}
+ _builder_2.append(" }");
CharSequence arrayExpr = _builder_2;
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(invokes, "");
@@ -126,11 +128,12 @@ public class ConfigGenAddon {
_builder_4.append("new ");
String _typeName = this.typeHelpers.typeName(aType);
_builder_4.append(_typeName, "");
- _builder_4.append("[]");
+ _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, "");
+ _builder_3.append(";");
_xblockexpression_2 = (_builder_3);
}
_xifexpression_3 = _xblockexpression_2;
@@ -138,30 +141,29 @@ public class ConfigGenAddon {
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("{");
_builder_2.newLine();
- _builder_2.append("\t\t\t\t\t\t");
+ _builder_2.append("\t");
String _typeName = this.typeHelpers.typeName(aType);
- _builder_2.append(_typeName, " ");
+ _builder_2.append(_typeName, " ");
_builder_2.append("[] array = ");
- _builder_2.append(invokes, " ");
+ _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(_invokeGetter, " ");
_builder_2.append(";");
_builder_2.newLineIfNotEmpty();
- _builder_2.append("\t\t\t\t\t\t");
+ _builder_2.append("\t");
_builder_2.append("for (int i=0;i<");
int _size_3 = a.getSize();
- _builder_2.append(_size_3, " ");
+ _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("\t\t");
_builder_2.append("array[i] = ");
String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), value);
- _builder_2.append(_valueLiteral_1, " ");
+ _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;
}
@@ -180,18 +182,14 @@ public class ConfigGenAddon {
{
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);
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
+ CharSequence _applyInstanceConfig = this.applyInstanceConfig(ai, _plus_1, _union);
_builder.append(_applyInstanceConfig, "");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t\t\t");
}
}
_xifexpression_1 = _builder;
@@ -203,8 +201,184 @@ public class ConfigGenAddon {
return _xblockexpression;
}
- public Object genDynConfigGetterSetter(final ActorClass ac) {
- return null;
+ public CharSequence genDynConfigGetterSetter(final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ List<Attribute> _dynConfigReadAttributes = this.dataConfigExt.getDynConfigReadAttributes(ac);
+ for(final Attribute a : _dynConfigReadAttributes) {
+ _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");
+ 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(";");
+ _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();
+ }
+ }
+ {
+ List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(ac);
+ for(final Attribute a_1 : _dynConfigWriteAttributes) {
+ _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();
+ }
+ }
+ return _builder;
}
public CharSequence genMinMaxConstants(final ActorClass ac) {
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 0beac50..23921e1 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
@@ -14,14 +14,15 @@ 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.generator.base.IDataConfiguration;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
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")
@@ -38,6 +39,9 @@ public class Initialization {
@Inject
private IDataConfiguration dataConfigExt;
+ @Inject
+ private ProcedureHelpers procedureHelpers;
+
public CharSequence attributeInitialization(final List<Attribute> attribs, final EObject roomClass, final boolean useClassDefaultsOnly) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("// initialize attributes");
@@ -55,201 +59,229 @@ public class Initialization {
}
private CharSequence attributeInit(final EObject roomClass, final List<Attribute> path, final boolean useClassDefaultsOnly) {
- CharSequence _xblockexpression = null;
+ Attribute a = IterableExtensions.<Attribute>last(path);
+ RefableType _refType = a.getRefType();
+ DataType aType = _refType.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(aType);
+ if (_isDataClass) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<Attribute> _attributes = ((DataClass) aType).getAttributes();
+ for(final Attribute e : _attributes) {
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
+ CharSequence _attributeInit = this.attributeInit(roomClass, _union, useClassDefaultsOnly);
+ _builder.append(_attributeInit, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ CharSequence result = _builder;
+ int _length = result.length();
+ boolean _greaterThan = (_length > 0);
+ if (_greaterThan) {
+ return result;
+ }
+ }
+ String value = this.getInitValueLiteral(roomClass, path);
+ String _xifexpression = null;
+ int _size = path.size();
+ boolean _greaterThan_1 = (_size > 1);
+ if (_greaterThan_1) {
+ int _size_1 = path.size();
+ int _minus = (_size_1 - 1);
+ Iterable<Attribute> _take = IterableExtensions.<Attribute>take(path, _minus);
+ CharSequence _invokeGetters = this.procedureHelpers.invokeGetters(_take, null);
+ String _plus = (_invokeGetters + ".");
+ _xifexpression = _plus;
+ } else {
+ _xifexpression = "";
+ }
+ String getter = _xifexpression;
+ StringConcatenation _builder_1 = new StringConcatenation();
{
- 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;
+ boolean _notEquals = (!Objects.equal(value, null));
+ if (_notEquals) {
{
- 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;
+ boolean _or = false;
+ int _size_2 = a.getSize();
+ boolean _equals = (_size_2 == 0);
+ if (_equals) {
+ _or = true;
+ } else {
+ boolean _isCharacterType = this._typeHelpers.isCharacterType(aType);
+ _or = (_equals || _isCharacterType);
+ }
+ if (_or) {
+ _builder_1.append(getter, "");
+ String _name = a.getName();
+ CharSequence _invokeSetter = this.procedureHelpers.invokeSetter(_name, null, value);
+ _builder_1.append(_invokeSetter, "");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
+ } else {
+ boolean _startsWith = value.startsWith("{");
+ if (_startsWith) {
+ _builder_1.append(getter, "");
+ String _name_1 = a.getName();
+ StringConcatenation _builder_2 = new StringConcatenation();
+ _builder_2.append("new ");
+ String _typeName = this._typeHelpers.typeName(aType);
+ _builder_2.append(_typeName, "");
+ _builder_2.append("[] ");
+ _builder_2.append(value, "");
+ CharSequence _invokeSetter_1 = this.procedureHelpers.invokeSetter(_name_1, null, _builder_2.toString());
+ _builder_1.append(_invokeSetter_1, "");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
+ } else {
+ _builder_1.append("{");
+ _builder_1.newLine();
+ _builder_1.append("\t");
+ String _typeName_1 = this._typeHelpers.typeName(aType);
+ _builder_1.append(_typeName_1, " ");
+ _builder_1.append("[] _");
+ String _name_2 = a.getName();
+ _builder_1.append(_name_2, " ");
+ _builder_1.append(" = new ");
+ String _typeName_2 = this._typeHelpers.typeName(aType);
+ _builder_1.append(_typeName_2, " ");
+ _builder_1.append("[");
+ int _size_3 = a.getSize();
+ _builder_1.append(_size_3, " ");
+ _builder_1.append("];");
+ _builder_1.newLineIfNotEmpty();
+ _builder_1.append("\t");
+ _builder_1.append("for (int i=0;i<");
+ int _size_4 = a.getSize();
+ _builder_1.append(_size_4, " ");
+ _builder_1.append(";i++){");
+ _builder_1.newLineIfNotEmpty();
+ _builder_1.append("\t\t");
+ _builder_1.append("_");
+ String _name_3 = a.getName();
+ _builder_1.append(_name_3, " ");
+ _builder_1.append("[i] = ");
+ _builder_1.append(value, " ");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
+ _builder_1.append("\t");
+ _builder_1.append("}");
+ _builder_1.newLine();
+ _builder_1.append("\t");
+ _builder_1.append(getter, " ");
+ String _name_4 = a.getName();
+ String _name_5 = a.getName();
+ String _plus_1 = ("_" + _name_5);
+ CharSequence _invokeSetter_2 = this.procedureHelpers.invokeSetter(_name_4, null, _plus_1);
+ _builder_1.append(_invokeSetter_2, " ");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
+ _builder_1.append("}");
+ _builder_1.newLine();
+ }
}
- _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.getInitValueLiteral(a, roomClass);
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals = (!Objects.equal(value, null));
- if (_notEquals) {
- {
- 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 _name = a.getName();
- _builder.append(_name, "");
- _builder.append(" = ");
- _builder.append(value, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- boolean _startsWith = value.startsWith("{");
- if (_startsWith) {
- String _name_1 = a.getName();
- _builder.append(_name_1, "");
- _builder.append(" = new ");
- String _typeName = this._typeHelpers.typeName(aType);
- _builder.append(_typeName, "");
- _builder.append("[] ");
- _builder.append(value, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
+ boolean _and = false;
+ int _size_5 = path.size();
+ boolean _equals_1 = (_size_5 == 1);
+ if (!_equals_1) {
+ _and = false;
+ } else {
+ boolean _or_1 = false;
+ boolean _or_2 = false;
+ if ((aType instanceof ComplexType)) {
+ _or_2 = true;
+ } else {
+ int _size_6 = a.getSize();
+ boolean _greaterThan_2 = (_size_6 > 1);
+ _or_2 = ((aType instanceof ComplexType) || _greaterThan_2);
+ }
+ if (_or_2) {
+ _or_1 = true;
+ } else {
+ boolean _not = (!useClassDefaultsOnly);
+ _or_1 = (_or_2 || _not);
+ }
+ _and = (_equals_1 && _or_1);
+ }
+ if (_and) {
+ {
+ int _size_7 = a.getSize();
+ boolean _equals_2 = (_size_7 == 0);
+ if (_equals_2) {
+ {
+ RefableType _refType_1 = a.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (_isRef) {
+ String _name_6 = a.getName();
+ _builder_1.append(_name_6, "");
+ _builder_1.append(" = ");
+ String _nullPointer = this.languageExt.nullPointer();
+ _builder_1.append(_nullPointer, "");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
} else {
- String _name_2 = a.getName();
- _builder.append(_name_2, "");
- _builder.append(" = new ");
- String _typeName_1 = this._typeHelpers.typeName(aType);
- _builder.append(_typeName_1, "");
- _builder.append("[");
- int _size_1 = a.getSize();
- _builder.append(_size_1, "");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- _builder.append("for (int i=0;i<");
- int _size_2 = a.getSize();
- _builder.append(_size_2, "");
- _builder.append(";i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_3 = a.getName();
- _builder.append(_name_3, " ");
- _builder.append("[i] = ");
- _builder.append(value, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
+ String _name_7 = a.getName();
+ _builder_1.append(_name_7, "");
+ _builder_1.append(" = ");
+ String _defaultValue = this.languageExt.defaultValue(aType);
+ _builder_1.append(_defaultValue, "");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
}
}
- }
- } else {
- boolean _or_1 = false;
- boolean _or_2 = false;
- if ((aType instanceof ComplexType)) {
- _or_2 = true;
- } else {
- int _size_3 = a.getSize();
- boolean _greaterThan = (_size_3 > 1);
- _or_2 = ((aType instanceof ComplexType) || _greaterThan);
- }
- if (_or_2) {
- _or_1 = true;
} else {
- boolean _not = (!useClassDefaultsOnly);
- _or_1 = (_or_2 || _not);
- }
- if (_or_1) {
+ String _name_8 = a.getName();
+ _builder_1.append(_name_8, "");
+ _builder_1.append(" = new ");
+ String _typeName_3 = this._typeHelpers.typeName(aType);
+ _builder_1.append(_typeName_3, "");
+ _builder_1.append("[");
+ int _size_8 = a.getSize();
+ _builder_1.append(_size_8, "");
+ _builder_1.append("];");
+ _builder_1.newLineIfNotEmpty();
{
- int _size_4 = a.getSize();
- boolean _equals_1 = (_size_4 == 0);
- if (_equals_1) {
+ boolean _not_1 = (!useClassDefaultsOnly);
+ if (_not_1) {
+ _builder_1.append("for (int i=0;i<");
+ int _size_9 = a.getSize();
+ _builder_1.append(_size_9, "");
+ _builder_1.append(";i++){");
+ _builder_1.newLineIfNotEmpty();
+ _builder_1.append("\t");
+ String _name_9 = a.getName();
+ _builder_1.append(_name_9, " ");
+ _builder_1.append("[i] = ");
{
RefableType _refType_2 = a.getRefType();
- boolean _isRef = _refType_2.isRef();
- if (_isRef) {
- String _name_4 = a.getName();
- _builder.append(_name_4, "");
- _builder.append(" = ");
- String _nullPointer = this.languageExt.nullPointer();
- _builder.append(_nullPointer, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
+ boolean _isRef_1 = _refType_2.isRef();
+ if (_isRef_1) {
+ String _nullPointer_1 = this.languageExt.nullPointer();
+ _builder_1.append(_nullPointer_1, " ");
} else {
- String _name_5 = a.getName();
- _builder.append(_name_5, "");
- _builder.append(" = ");
- String _defaultValue = this.languageExt.defaultValue(aType);
- _builder.append(_defaultValue, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- String _name_6 = a.getName();
- _builder.append(_name_6, "");
- _builder.append(" = new ");
- String _typeName_2 = this._typeHelpers.typeName(aType);
- _builder.append(_typeName_2, "");
- _builder.append("[");
- int _size_5 = a.getSize();
- _builder.append(_size_5, "");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- {
- boolean _not_1 = (!useClassDefaultsOnly);
- if (_not_1) {
- _builder.append("for (int i=0;i<");
- int _size_6 = a.getSize();
- _builder.append(_size_6, "");
- _builder.append(";i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_7 = a.getName();
- _builder.append(_name_7, " ");
- _builder.append("[i] = ");
- {
- RefableType _refType_3 = a.getRefType();
- boolean _isRef_1 = _refType_3.isRef();
- if (_isRef_1) {
- String _nullPointer_1 = this.languageExt.nullPointer();
- _builder.append(_nullPointer_1, " ");
- } else {
- String _defaultValue_1 = this.languageExt.defaultValue(aType);
- _builder.append(_defaultValue_1, " ");
- }
- }
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
+ String _defaultValue_1 = this.languageExt.defaultValue(aType);
+ _builder_1.append(_defaultValue_1, " ");
}
}
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
+ _builder_1.append("}");
+ _builder_1.newLine();
}
}
}
}
}
- _xifexpression = _builder;
}
- _xblockexpression = (_xifexpression);
}
- return _xblockexpression;
+ return _builder_1;
}
- private String getInitValueLiteral(final Attribute a, final EObject roomClass) {
+ private String getInitValueLiteral(final EObject roomClass, final List<Attribute> path) {
String _xblockexpression = null;
{
+ Attribute a = IterableExtensions.<Attribute>last(path);
RefableType _refType = a.getRefType();
DataType _type = _refType.getType();
boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
@@ -263,9 +295,7 @@ public class Initialization {
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);
+ String _attrClassConfigValue = this.dataConfigExt.getAttrClassConfigValue(_actorClass, path);
_switchResult = _attrClassConfigValue;
}
}
@@ -273,10 +303,21 @@ public class Initialization {
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 _xifexpression = null;
+ EObject _eContainer = _portClass.eContainer();
+ if ((_eContainer instanceof ProtocolClass)) {
+ String _xblockexpression_1 = null;
+ {
+ EObject _eContainer_1 = _portClass.eContainer();
+ ProtocolClass pc = ((ProtocolClass) _eContainer_1);
+ PortClass _regular = pc.getRegular();
+ boolean _equals = _regular.equals(_portClass);
+ String _attrClassConfigValue = this.dataConfigExt.getAttrClassConfigValue(pc, _equals, path);
+ _xblockexpression_1 = (_attrClassConfigValue);
+ }
+ _xifexpression = _xblockexpression_1;
+ }
+ _switchResult = _xifexpression;
}
}
String result = _switchResult;
@@ -319,8 +360,14 @@ public class Initialization {
return _xifexpression;
}
}
- String _defaultValueLiteral = a.getDefaultValueLiteral();
- _xblockexpression = (_defaultValueLiteral);
+ String _xifexpression_1 = null;
+ int _size_1 = path.size();
+ boolean _equals_1 = (_size_1 == 1);
+ if (_equals_1) {
+ String _defaultValueLiteral = a.getDefaultValueLiteral();
+ _xifexpression_1 = _defaultValueLiteral;
+ }
+ _xblockexpression = (_xifexpression_1);
}
return _xblockexpression;
}
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 369741d..e78955b 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,6 +2,7 @@ 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.genmodel.base.ILogger;
@@ -10,6 +11,7 @@ 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.Attribute;
import org.eclipse.etrice.core.room.LogicalThread;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SubSystemClass;
@@ -22,8 +24,6 @@ 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.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
@Singleton
@SuppressWarnings("all")
@@ -72,6 +72,11 @@ 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.dataConfigExt.hasVariableService(_subSystemClass_4);
+ if (_hasVariableService) {
+ this.varService.doGenerate(root, ssi);
+ }
}
}
}
@@ -567,7 +572,11 @@ public class SubSystemClassGen {
_builder.append("}");
_builder.newLine();
{
- if (false) {
+ String _path_10 = ai_2.getPath();
+ List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(_path_10);
+ boolean _isEmpty_5 = _dynConfigWriteAttributes.isEmpty();
+ boolean _not_2 = (!_isEmpty_5);
+ if (_not_2) {
_builder.append("\t\t");
_builder.append("\t");
_builder.append(", variableService");
@@ -584,15 +593,37 @@ public class SubSystemClassGen {
_builder.append("\t\t");
_builder.append("// apply instance attribute configurations");
_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();
+ {
+ EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_3 : _allContainedInstances_8) {
+ _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");
+ CharSequence _genActorInstanceConfig = this.configGenAddon.genActorInstanceConfig(ai_3, "inst");
+ _builder.append(_genActorInstanceConfig, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
_builder.newLine();
_builder.append("\t\t");
_builder.append("// create the subsystem system port\t");
@@ -610,9 +641,9 @@ public class SubSystemClassGen {
_builder.append("new Address[]{");
_builder.newLine();
{
- EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
+ EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
boolean _hasElements_4 = false;
- for(final ActorInstance ai_3 : _allContainedInstances_9) {
+ for(final ActorInstance ai_4 : _allContainedInstances_10) {
if (!_hasElements_4) {
_hasElements_4 = true;
} else {
@@ -620,9 +651,9 @@ public class SubSystemClassGen {
}
_builder.append("\t\t\t\t\t");
_builder.append("addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
- int _indexOf_7 = _allContainedInstances_10.indexOf(ai_3);
- _builder.append(_indexOf_7, " ");
+ EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
+ int _indexOf_8 = _allContainedInstances_11.indexOf(ai_4);
+ _builder.append(_indexOf_8, " ");
_builder.newLineIfNotEmpty();
}
}
@@ -636,9 +667,9 @@ public class SubSystemClassGen {
_builder.append("new Address[]{");
_builder.newLine();
{
- EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
+ EList<ActorInstance> _allContainedInstances_12 = comp.getAllContainedInstances();
boolean _hasElements_5 = false;
- for(final ActorInstance ai_4 : _allContainedInstances_11) {
+ for(final ActorInstance ai_5 : _allContainedInstances_12) {
if (!_hasElements_5) {
_hasElements_5 = true;
} else {
@@ -646,8 +677,8 @@ public class SubSystemClassGen {
}
_builder.append("\t\t\t\t\t");
_builder.append("addr_item_");
- String _path_10 = ai_4.getPath();
- String _pathName_8 = this._roomExtensions.getPathName(_path_10);
+ String _path_11 = ai_5.getPath();
+ String _pathName_8 = this._roomExtensions.getPathName(_path_11);
_builder.append(_pathName_8, " ");
_builder.newLineIfNotEmpty();
}
@@ -681,8 +712,8 @@ public class SubSystemClassGen {
if (_hasVariableService_2) {
_builder.append("\t\t\t");
_builder.append("variableService = new ");
- String _name_6 = comp.getName();
- _builder.append(_name_6, " ");
+ String _name_8 = comp.getName();
+ _builder.append(_name_8, " ");
_builder.append("VariableService(this);");
_builder.newLineIfNotEmpty();
}
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 c63f887..9814b4c 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,14 +1,40 @@
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.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
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.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.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
@Singleton
@SuppressWarnings("all")
@@ -33,4 +59,891 @@ 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) {
+ CharSequence _xblockexpression = null;
+ {
+ HashMap<ActorInstance,List<Attribute>> _hashMap = new HashMap<ActorInstance,List<Attribute>>();
+ final HashMap<ActorInstance,List<Attribute>> aisAttrMap = _hashMap;
+ EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
+ final Procedure1<ActorInstance> _function = new Procedure1<ActorInstance>() {
+ public void apply(final ActorInstance ai) {
+ String _path = ai.getPath();
+ List<Attribute> _dynConfigReadAttributes = VariableServiceGen.this.configExt.getDynConfigReadAttributes(_path);
+ boolean _isEmpty = _dynConfigReadAttributes.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ String _path_1 = ai.getPath();
+ List<Attribute> _dynConfigReadAttributes_1 = VariableServiceGen.this.configExt.getDynConfigReadAttributes(_path_1);
+ aisAttrMap.put(ai, _dynConfigReadAttributes_1);
+ }
+ }
+ };
+ IterableExtensions.<ActorInstance>forEach(_allContainedInstances, _function);
+ StringConcatenation _builder = new StringConcatenation();
+ _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 = this.configExt.getUserCode1(cc);
+ _builder.append(_userCode1, "");
+ _builder.newLineIfNotEmpty();
+ {
+ Set<ActorInstance> _keySet = aisAttrMap.keySet();
+ HashSet<RoomModel> _roomModels = this.getRoomModels(_keySet);
+ 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();
+ {
+ Set<ActorInstance> _keySet_1 = aisAttrMap.keySet();
+ for(final ActorInstance ai : _keySet_1) {
+ _builder.append("\t");
+ _builder.append("private ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_3 = _actorClass.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(" ");
+ CharSequence _varName = this.getVarName(ai);
+ _builder.append(_varName, " ");
+ _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 _userCode2 = this.configExt.getUserCode2(cc);
+ _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();
+ {
+ Set<ActorInstance> _keySet_2 = aisAttrMap.keySet();
+ for(final ActorInstance ai_1 : _keySet_2) {
+ _builder.append("\t\t");
+ CharSequence _varName_1 = this.getVarName(ai_1);
+ _builder.append(_varName_1, " ");
+ _builder.append(" = (");
+ ActorClass _actorClass_1 = ai_1.getActorClass();
+ String _name_6 = _actorClass_1.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(")subSystem.getInstance(\"");
+ String _path = ai_1.getPath();
+ _builder.append(_path, " ");
+ _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();
+ _builder.append("\t\t");
+ _builder.newLine();
+ {
+ Set<ActorInstance> _keySet_3 = aisAttrMap.keySet();
+ for(final ActorInstance ai_2 : _keySet_3) {
+ {
+ List<Attribute> _get = aisAttrMap.get(ai_2);
+ for(final Attribute a : _get) {
+ _builder.append("\t\t");
+ _builder.append("try{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("boolean changed = false;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ List<Attribute> _union = this.roomExt.<Attribute>union(_arrayList, a);
+ CharSequence _genSetAttributeValues1 = this.genSetAttributeValues1(_union, ai_2);
+ _builder.append(_genSetAttributeValues1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("if(changed)");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("synchronized(");
+ CharSequence _varName_2 = this.getVarName(ai_2);
+ _builder.append(_varName_2, " ");
+ _builder.append(".");
+ String _name_7 = a.getName();
+ String _plus_2 = (_name_7 + "Lock");
+ CharSequence _invokeGetter = this.helpers.invokeGetter(_plus_2, null);
+ _builder.append(_invokeGetter, " ");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t\t");
+ _builder.append("if(");
+ CharSequence _varName_3 = this.getVarName(ai_2);
+ _builder.append(_varName_3, " ");
+ _builder.append(".");
+ String _name_8 = a.getName();
+ String _plus_3 = (_name_8 + "Lock");
+ CharSequence _invokeGetter_1 = this.helpers.invokeGetter(_plus_3, null);
+ _builder.append(_invokeGetter_1, " ");
+ _builder.append(".isUpdate()){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t\t\t");
+ ArrayList<Attribute> _arrayList_1 = new ArrayList<Attribute>();
+ List<Attribute> _union_1 = this.roomExt.<Attribute>union(_arrayList_1, a);
+ CharSequence _genSetAttributeValues2 = this.genSetAttributeValues2(_union_1, ai_2);
+ _builder.append(_genSetAttributeValues2, " ");
+ _builder.newLineIfNotEmpty();
+ _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();
+ {
+ Set<ActorInstance> _keySet_4 = aisAttrMap.keySet();
+ for(final ActorInstance ai_3 : _keySet_4) {
+ {
+ List<Attribute> _get_1 = aisAttrMap.get(ai_3);
+ for(final Attribute a_1 : _get_1) {
+ _builder.append("\t\t");
+ ArrayList<Attribute> _arrayList_2 = new ArrayList<Attribute>();
+ List<Attribute> _union_2 = this.roomExt.<Attribute>union(_arrayList_2, a_1);
+ CharSequence _genGetAttributeValues = this.genGetAttributeValues(_union_2, ai_3);
+ _builder.append(_genGetAttributeValues, " ");
+ _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();
+ _builder.append("\t\t");
+ Set<ActorInstance> _keySet_5 = aisAttrMap.keySet();
+ HashSet<DataClass> dataClasses = this.getDynConfigDataClasses(_keySet_5);
+ _builder.newLineIfNotEmpty();
+ {
+ for(final DataClass dc : dataClasses) {
+ _builder.append("\t\t");
+ _builder.append("if(dcObject.getClass().equals(");
+ String _typeName = this._typeHelpers.typeName(dc);
+ _builder.append(_typeName, " ");
+ _builder.append(".class))");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("writeDataClass(id, (");
+ String _typeName_1 = this._typeHelpers.typeName(dc);
+ _builder.append(_typeName_1, " ");
+ _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> _allDataClasses = this.getAllDataClasses(dataClasses);
+ for(final DataClass dc_1 : _allDataClasses) {
+ _builder.append("\t");
+ _builder.append("private void writeDataClass(String id, ");
+ String _typeName_2 = this._typeHelpers.typeName(dc_1);
+ _builder.append(_typeName_2, " ");
+ _builder.append(" object, Map<String, Object> map){");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<Attribute> _attributes = dc_1.getAttributes();
+ for(final Attribute a_2 : _attributes) {
+ {
+ RefableType _refType = a_2.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (_isPrimitive) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("map.put(id+\"/");
+ String _name_9 = a_2.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("\", ");
+ {
+ int _size = a_2.getSize();
+ boolean _greaterThan = (_size > 0);
+ if (_greaterThan) {
+ _builder.append("toObjectArray(");
+ }
+ }
+ _builder.append("object.");
+ String _name_10 = a_2.getName();
+ CharSequence _invokeGetter_2 = this.helpers.invokeGetter(_name_10, null);
+ _builder.append(_invokeGetter_2, " ");
+ {
+ int _size_1 = a_2.getSize();
+ boolean _greaterThan_1 = (_size_1 > 0);
+ if (_greaterThan_1) {
+ _builder.append(")");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("writeDataClass(id+\"/");
+ String _name_11 = a_2.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("\", object.");
+ String _name_12 = a_2.getName();
+ CharSequence _invokeGetter_3 = this.helpers.invokeGetter(_name_12, null);
+ _builder.append(_invokeGetter_3, " ");
+ _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 _pollingTimerUser = this.configExt.getPollingTimerUser(cc);
+ _builder.append(_pollingTimerUser, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genMinMaxCheck(final List<Attribute> path, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ String aVarName = this.toAbsolutePath(path, "_");
+ String _attrClassConfigMinValue = this.configExt.getAttrClassConfigMinValue(ac, path);
+ boolean min = (!Objects.equal(_attrClassConfigMinValue, null));
+ String _attrClassConfigMaxValue = this.configExt.getAttrClassConfigMaxValue(ac, path);
+ boolean max = (!Objects.equal(_attrClassConfigMaxValue, null));
+ CharSequence _xifexpression = null;
+ boolean _or = false;
+ if (min) {
+ _or = true;
+ } else {
+ _or = (min || max);
+ }
+ if (_or) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("checkMinMax(");
+ _builder.append(aVarName, "");
+ _builder.append(", ");
+ {
+ if (min) {
+ String _name = ac.getName();
+ _builder.append(_name, "");
+ _builder.append(".MIN");
+ _builder.append(aVarName, "");
+ } else {
+ _builder.append("null");
+ }
+ }
+ _builder.append(", ");
+ {
+ if (max) {
+ String _name_1 = ac.getName();
+ _builder.append(_name_1, "");
+ _builder.append(".MAX");
+ _builder.append(aVarName, "");
+ } else {
+ _builder.append("null");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _xifexpression = _builder;
+ } else {
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _xifexpression = _builder_1;
+ }
+ _xblockexpression = (_xifexpression);
+ }
+ return _xblockexpression;
+ }
+
+ private HashSet<DataClass> getDynConfigDataClasses(final Iterable<ActorInstance> ais) {
+ HashSet<DataClass> _hashSet = new HashSet<DataClass>();
+ final HashSet<DataClass> result = _hashSet;
+ final Procedure1<ActorInstance> _function = new Procedure1<ActorInstance>() {
+ public void apply(final ActorInstance ai) {
+ String _path = ai.getPath();
+ List<Attribute> _dynConfigReadAttributes = VariableServiceGen.this.configExt.getDynConfigReadAttributes(_path);
+ final Procedure1<Attribute> _function = new Procedure1<Attribute>() {
+ public void apply(final Attribute a) {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isDataClass = VariableServiceGen.this._typeHelpers.isDataClass(_type);
+ if (_isDataClass) {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ result.add(((DataClass) _type_1));
+ }
+ }
+ };
+ IterableExtensions.<Attribute>forEach(_dynConfigReadAttributes, _function);
+ }
+ };
+ IterableExtensions.<ActorInstance>forEach(ais, _function);
+ return result;
+ }
+
+ private HashSet<DataClass> getAllDataClasses(final Iterable<DataClass> dcs) {
+ HashSet<DataClass> _hashSet = new HashSet<DataClass>();
+ final HashSet<DataClass> result = _hashSet;
+ Iterables.<DataClass>addAll(result, dcs);
+ LinkedList<DataClass> _linkedList = new LinkedList<DataClass>();
+ final LinkedList<DataClass> visit = _linkedList;
+ Iterables.<DataClass>addAll(visit, dcs);
+ boolean _isEmpty = visit.isEmpty();
+ boolean _not = (!_isEmpty);
+ boolean _while = _not;
+ while (_while) {
+ {
+ DataClass dc = visit.pop();
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc);
+ final Procedure1<Attribute> _function = new Procedure1<Attribute>() {
+ public void apply(final Attribute a) {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isDataClass = VariableServiceGen.this._typeHelpers.isDataClass(_type);
+ if (_isDataClass) {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ visit.add(((DataClass) _type_1));
+ }
+ }
+ };
+ IterableExtensions.<Attribute>forEach(_allAttributes, _function);
+ }
+ boolean _isEmpty_1 = visit.isEmpty();
+ boolean _not_1 = (!_isEmpty_1);
+ _while = _not_1;
+ }
+ return result;
+ }
+
+ private HashSet<RoomModel> getRoomModels(final Collection<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;
+ }
+
+ private String toAbsolutePath(final List<Attribute> path, final String pathDelim) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final Attribute p : path) {
+ _builder.append(pathDelim, "");
+ String _name = p.getName();
+ _builder.append(_name, "");
+ }
+ }
+ String _string = _builder.toString();
+ return _string;
+ }
+
+ private CharSequence getVarName(final ActorInstance ai) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ String _path = ai.getPath();
+ String[] _split = _path.split("/");
+ Iterable<String> _drop = IterableExtensions.<String>drop(((Iterable<String>)Conversions.doWrapArray(_split)), 2);
+ boolean _hasElements = false;
+ for(final String p : _drop) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate("_", "");
+ }
+ _builder.append(p, "");
+ }
+ }
+ return _builder;
+ }
+
+ private CharSequence genGetAttributeValues(final List<Attribute> path, final ActorInstance ai) {
+ CharSequence _xblockexpression = null;
+ {
+ Attribute a = IterableExtensions.<Attribute>last(path);
+ CharSequence _xifexpression = null;
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (_isPrimitive) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("values.put(\"");
+ String _path = ai.getPath();
+ _builder.append(_path, "");
+ String _absolutePath = this.toAbsolutePath(path, "/");
+ _builder.append(_absolutePath, "");
+ _builder.append("\", ");
+ {
+ int _size = a.getSize();
+ boolean _greaterThan = (_size > 0);
+ if (_greaterThan) {
+ _builder.append("toObjectArray(");
+ }
+ }
+ CharSequence _varName = this.getVarName(ai);
+ _builder.append(_varName, "");
+ _builder.append(".");
+ CharSequence _invokeGetters = this.helpers.invokeGetters(path, null);
+ _builder.append(_invokeGetters, "");
+ {
+ int _size_1 = a.getSize();
+ boolean _greaterThan_1 = (_size_1 > 0);
+ if (_greaterThan_1) {
+ _builder.append(")");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _xifexpression = _builder;
+ } else {
+ CharSequence _xifexpression_1 = null;
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(_type_1);
+ if (_isDataClass) {
+ CharSequence _xblockexpression_1 = null;
+ {
+ RefableType _refType_2 = a.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ DataClass dataClass = ((DataClass) _type_2);
+ StringConcatenation _builder_1 = new StringConcatenation();
+ {
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dataClass);
+ for(final Attribute at : _allAttributes) {
+ List<Attribute> _union = this.roomExt.<Attribute>union(path, at);
+ CharSequence _genGetAttributeValues = this.genGetAttributeValues(_union, ai);
+ _builder_1.append(_genGetAttributeValues, "");
+ _builder_1.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression_1 = (_builder_1);
+ }
+ _xifexpression_1 = _xblockexpression_1;
+ }
+ _xifexpression = _xifexpression_1;
+ }
+ _xblockexpression = (_xifexpression);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genSetAttributeValues1(final List<Attribute> path, final ActorInstance ai) {
+ CharSequence _xblockexpression = null;
+ {
+ Attribute a = IterableExtensions.<Attribute>last(path);
+ String aVarName = this.toAbsolutePath(path, "_");
+ CharSequence _xifexpression = null;
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (_isPrimitive) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("id = \"");
+ String _path = ai.getPath();
+ _builder.append(_path, "");
+ String _absolutePath = this.toAbsolutePath(path, "/");
+ _builder.append(_absolutePath, "");
+ _builder.append("\";");
+ _builder.newLineIfNotEmpty();
+ {
+ int _size = a.getSize();
+ boolean _equals = (_size == 0);
+ if (_equals) {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName = this._typeHelpers.typeName(_type_1);
+ String _wrapper = this.stdExt.toWrapper(_typeName);
+ _builder.append(_wrapper, "");
+ } else {
+ RefableType _refType_2 = a.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_2);
+ _builder.append(_typeName_1, "");
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ _builder.append(aVarName, "");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("object = values.get(id);");
+ _builder.newLine();
+ _builder.append("if(object != null){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append(aVarName, " ");
+ _builder.append(" = ensure");
+ RefableType _refType_3 = a.getRefType();
+ DataType _type_3 = _refType_3.getType();
+ String _typeName_2 = this._typeHelpers.typeName(_type_3);
+ 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");
+ ActorClass _actorClass = ai.getActorClass();
+ CharSequence _genMinMaxCheck = this.genMinMaxCheck(path, _actorClass);
+ _builder.append(_genMinMaxCheck, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if(!");
+ {
+ int _size_4 = a.getSize();
+ boolean _equals_1 = (_size_4 == 0);
+ if (_equals_1) {
+ _builder.append(aVarName, " ");
+ _builder.append(".equals(");
+ } else {
+ _builder.append("Arrays.equals(");
+ _builder.append(aVarName, " ");
+ _builder.append(", ");
+ }
+ }
+ _builder.append("(");
+ {
+ int _size_5 = a.getSize();
+ boolean _equals_2 = (_size_5 == 0);
+ if (_equals_2) {
+ RefableType _refType_4 = a.getRefType();
+ DataType _type_4 = _refType_4.getType();
+ String _typeName_3 = this._typeHelpers.typeName(_type_4);
+ String _wrapper_1 = this.stdExt.toWrapper(_typeName_3);
+ _builder.append(_wrapper_1, " ");
+ } else {
+ RefableType _refType_5 = a.getRefType();
+ DataType _type_5 = _refType_5.getType();
+ String _typeName_4 = this._typeHelpers.typeName(_type_5);
+ _builder.append(_typeName_4, " ");
+ _builder.append("[]");
+ }
+ }
+ _builder.append(")getDiffMap().get(id)))");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("changed = true;");
+ _builder.newLine();
+ _builder.append("} else");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("warning(id, \"is missing\");");
+ _builder.newLine();
+ _xifexpression = _builder;
+ } else {
+ CharSequence _xifexpression_1 = null;
+ RefableType _refType_6 = a.getRefType();
+ DataType _type_6 = _refType_6.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(_type_6);
+ if (_isDataClass) {
+ CharSequence _xblockexpression_1 = null;
+ {
+ RefableType _refType_7 = a.getRefType();
+ DataType _type_7 = _refType_7.getType();
+ DataClass dataClass = ((DataClass) _type_7);
+ StringConcatenation _builder_1 = new StringConcatenation();
+ {
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dataClass);
+ for(final Attribute at : _allAttributes) {
+ List<Attribute> _union = this.roomExt.<Attribute>union(path, at);
+ CharSequence _genSetAttributeValues1 = this.genSetAttributeValues1(_union, ai);
+ _builder_1.append(_genSetAttributeValues1, "");
+ _builder_1.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression_1 = (_builder_1);
+ }
+ _xifexpression_1 = _xblockexpression_1;
+ }
+ _xifexpression = _xifexpression_1;
+ }
+ _xblockexpression = (_xifexpression);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence genSetAttributeValues2(final List<Attribute> path, final ActorInstance ai) {
+ CharSequence _xblockexpression = null;
+ {
+ Attribute a = IterableExtensions.<Attribute>last(path);
+ String aVarName = this.toAbsolutePath(path, "_");
+ CharSequence _xifexpression = null;
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (_isPrimitive) {
+ CharSequence _xblockexpression_1 = null;
+ {
+ String _xifexpression_1 = null;
+ int _size = path.size();
+ boolean _greaterThan = (_size > 1);
+ if (_greaterThan) {
+ int _size_1 = path.size();
+ int _minus = (_size_1 - 1);
+ Iterable<Attribute> _take = IterableExtensions.<Attribute>take(path, _minus);
+ CharSequence _invokeGetters = this.helpers.invokeGetters(_take, null);
+ String _plus = (_invokeGetters + ".");
+ _xifexpression_1 = _plus;
+ } else {
+ _xifexpression_1 = "";
+ }
+ String getters = _xifexpression_1;
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("if(");
+ _builder.append(aVarName, "");
+ _builder.append(" != null){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ CharSequence _varName = this.getVarName(ai);
+ _builder.append(_varName, " ");
+ _builder.append(".");
+ _builder.append(getters, " ");
+ String _name = a.getName();
+ CharSequence _invokeSetter = this.helpers.invokeSetter(_name, null, aVarName);
+ _builder.append(_invokeSetter, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("getDiffMap().put(\"");
+ String _path = ai.getPath();
+ _builder.append(_path, " ");
+ String _absolutePath = this.toAbsolutePath(path, "/");
+ _builder.append(_absolutePath, " ");
+ _builder.append("\", ");
+ _builder.append(aVarName, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ _xblockexpression_1 = (_builder);
+ }
+ _xifexpression = _xblockexpression_1;
+ } else {
+ CharSequence _xifexpression_1 = null;
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(_type_1);
+ if (_isDataClass) {
+ CharSequence _xblockexpression_2 = null;
+ {
+ RefableType _refType_2 = a.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ DataClass dataClass = ((DataClass) _type_2);
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dataClass);
+ for(final Attribute at : _allAttributes) {
+ List<Attribute> _union = this.roomExt.<Attribute>union(path, at);
+ CharSequence _genSetAttributeValues2 = this.genSetAttributeValues2(_union, ai);
+ _builder.append(_genSetAttributeValues2, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression_2 = (_builder);
+ }
+ _xifexpression_1 = _xblockexpression_2;
+ }
+ _xifexpression = _xifexpression_1;
+ }
+ _xblockexpression = (_xifexpression);
+ }
+ return _xblockexpression;
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java
index b4416ef..2f7d5b7 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/IDataConfiguration.java
@@ -1,7 +1,6 @@
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;
@@ -20,6 +19,9 @@ public interface IDataConfiguration {
// static configuration
+ /**
+ * Array formatting: x,x,x,x,x
+ */
public String getAttrClassConfigValue(ActorClass actor, List<Attribute> path);
public String getAttrClassConfigValue(ProtocolClass pc, boolean regular, List<Attribute> path);
public String getAttrClassConfigMinValue(ActorClass actor, List<Attribute> path);
@@ -29,15 +31,15 @@ public interface IDataConfiguration {
// dynamic configuration
+ public String getUserCode1(SubSystemClass subsystem);
+ public String getUserCode2(SubSystemClass subsystem);
+ public int getPollingTimerUser(SubSystemClass subsystem);
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(String actorInstance);
+ public List<Attribute> getDynConfigWriteAttributes(String actorInstance);
- public List<Attribute> getDynConfigReadAttributes(SubSystemClass subsystem);
- public List<Attribute> getDynConfigWriteAttributes(SubSystemClass subsystem);
+ public List<Attribute> getDynConfigReadAttributes(ActorClass actor);
+ public List<Attribute> getDynConfigWriteAttributes(ActorClass actor);
}
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
index 979e638..b4f4ae0 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/ProcedureHelpers.xtend
@@ -150,6 +150,10 @@ class ProcedureHelpers {
def argList(List<Attribute> attributes) {
'''«FOR a : attributes SEPARATOR ", "»«a.refType.type.typeName»«IF a.size>0»[]«ENDIF» «a.name»«ENDFOR»'''
}
+
+ def invokeGetters(Iterable<Attribute> path, String classname){
+ '''«FOR a : path SEPARATOR '.'»«invokeGetter(a.name, classname)»«ENDFOR»'''
+ }
// generic setters & getters
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
index 893baa4..555ccdf 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/ProcedureHelpers.java
@@ -416,6 +416,24 @@ public class ProcedureHelpers {
return _builder;
}
+ public CharSequence invokeGetters(final Iterable<Attribute> path, final String classname) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _hasElements = false;
+ for(final Attribute a : path) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(".", "");
+ }
+ String _name = a.getName();
+ CharSequence _invokeGetter = this.invokeGetter(_name, classname);
+ _builder.append(_invokeGetter, "");
+ }
+ }
+ return _builder;
+ }
+
public CharSequence getterImplementation(final String typeName, final String name, final String classname) {
StringConcatenation _builder = new StringConcatenation();
String _accessLevelPublic = this.languageExt.accessLevelPublic();