Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-09-17 06:57:34 +0000
committerHenrik Rentz-Reichert2012-09-17 06:57:34 +0000
commitef2848f9baa26bdb688c843d6dd7597a75be24d2 (patch)
tree27313666ba84c5c7769fbc2a5a81e378f449e1f7 /plugins
parentabc7afeccd432d7fae8ce2384bf099bafbee4e6f (diff)
downloadorg.eclipse.etrice-ef2848f9baa26bdb688c843d6dd7597a75be24d2.tar.gz
org.eclipse.etrice-ef2848f9baa26bdb688c843d6dd7597a75be24d2.tar.xz
org.eclipse.etrice-ef2848f9baa26bdb688c843d6dd7597a75be24d2.zip
[generator.java] xtend-gen files
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java444
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/SubSystemClassGen.java1634
-rw-r--r--plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java972
3 files changed, 2233 insertions, 817 deletions
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
new file mode 100644
index 000000000..238102d24
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/ConfigGenAddon.java
@@ -0,0 +1,444 @@
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.config.AttrClassConfig;
+import org.eclipse.etrice.core.config.AttrInstanceConfig;
+import org.eclipse.etrice.core.config.LiteralArray;
+import org.eclipse.etrice.core.config.NumberLiteral;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.generator.generic.ConfigExtension;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.xbase.lib.Conversions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+
+@SuppressWarnings("all")
+public class ConfigGenAddon {
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private TypeHelpers typeHelpers;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private ConfigExtension configExt;
+
+ public CharSequence applyInstanceConfig(final String instance, final String className, final List<AttrInstanceConfig> attrConfigs) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ for(final AttrInstanceConfig attrConfig : attrConfigs) {
+ Attribute a = attrConfig.getAttribute();
+ _builder.newLineIfNotEmpty();
+ RefableType _refType = a.getRefType();
+ DataType aType = _refType.getType();
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
+ if (_isPrimitive) {
+ LiteralArray _value = attrConfig.getValue();
+ String[] values = _value==null?(String[])null:this.configExt.getValues(_value);
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _equals = Objects.equal(values, null);
+ if (_equals) {
+ } else {
+ boolean _or = false;
+ int _size = a.getSize();
+ boolean _equals_1 = (_size == 0);
+ if (_equals_1) {
+ _or = true;
+ } else {
+ boolean _isCharacterType = this.typeHelpers.isCharacterType(aType);
+ _or = (_equals_1 || _isCharacterType);
+ }
+ if (_or) {
+ _builder.append(instance, "");
+ _builder.append(".");
+ String _name = a.getName();
+ final String[] _converted_values = (String[])values;
+ String _get = ((List<String>)Conversions.doWrapArray(_converted_values)).get(0);
+ String _valueLiteral = this.stdExt.toValueLiteral(((PrimitiveType) aType), _get);
+ CharSequence _invokeSetter = this.helpers.invokeSetter(_name, className, _valueLiteral);
+ _builder.append(_invokeSetter, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ int _size_1 = a.getSize();
+ final String[] _converted_values_1 = (String[])values;
+ int _size_2 = ((List<String>)Conversions.doWrapArray(_converted_values_1)).size();
+ boolean _equals_2 = (_size_1 == _size_2);
+ if (_equals_2) {
+ _builder.append(instance, "");
+ _builder.append(".");
+ String _name_1 = a.getName();
+ String _typeName = this.typeHelpers.typeName(aType);
+ String _plus = ("new " + _typeName);
+ String _plus_1 = (_plus + "[]");
+ String _arrayValueLiteral = this.configExt.toArrayValueLiteral(((PrimitiveType) aType), values);
+ String _plus_2 = (_plus_1 + _arrayValueLiteral);
+ CharSequence _invokeSetter_1 = this.helpers.invokeSetter(_name_1, className, _plus_2);
+ _builder.append(_invokeSetter_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ String _typeName_1 = this.typeHelpers.typeName(aType);
+ _builder.append(_typeName_1, " ");
+ _builder.append("[] array = ");
+ _builder.append(instance, " ");
+ _builder.append(".");
+ String _name_2 = a.getName();
+ CharSequence _invokeGetter = this.helpers.invokeGetter(_name_2, className);
+ _builder.append(_invokeGetter, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("for (int i=0;i<");
+ int _size_3 = a.getSize();
+ _builder.append(_size_3, " ");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("array[i] = ");
+ final String[] _converted_values_2 = (String[])values;
+ String _get_1 = ((List<String>)Conversions.doWrapArray(_converted_values_2)).get(0);
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), _get_1);
+ _builder.append(_valueLiteral_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ } else {
+ boolean _isDataClass = this.typeHelpers.isDataClass(aType);
+ if (_isDataClass) {
+ String _plus_3 = (instance + ".");
+ String _name_3 = a.getName();
+ CharSequence _invokeGetter_1 = this.helpers.invokeGetter(_name_3, className);
+ String _plus_4 = (_plus_3 + _invokeGetter_1);
+ String _typeName_2 = this.typeHelpers.typeName(aType);
+ EList<AttrInstanceConfig> _attributes = attrConfig.getAttributes();
+ CharSequence _applyInstanceConfig = this.applyInstanceConfig(_plus_4, _typeName_2, _attributes);
+ _builder.append(_applyInstanceConfig, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence genDynConfigGetterSetter(final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ HashSet<Attribute> _dynConfigAttributes = this.configExt.getDynConfigAttributes(ac, true, false);
+ for(final Attribute a : _dynConfigAttributes) {
+ _builder.append("public ");
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this.typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ {
+ int _size = a.getSize();
+ boolean _greaterThan = (_size > 0);
+ if (_greaterThan) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" get");
+ 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();
+ }
+ }
+ {
+ HashSet<Attribute> _dynConfigAttributes_1 = this.configExt.getDynConfigAttributes(ac, false, true);
+ for(final Attribute a_1 : _dynConfigAttributes_1) {
+ _builder.append("public void setAndWrite");
+ String _name_15 = a_1.getName();
+ String _firstUpper_3 = StringExtensions.toFirstUpper(_name_15);
+ _builder.append(_firstUpper_3, "");
+ _builder.append("(");
+ RefableType _refType_2 = a_1.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ String _typeName_2 = this.typeHelpers.typeName(_type_2);
+ _builder.append(_typeName_2, "");
+ {
+ int _size_2 = a_1.getSize();
+ boolean _greaterThan_2 = (_size_2 > 0);
+ if (_greaterThan_2) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name_16 = a_1.getName();
+ _builder.append(_name_16, "");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("set");
+ String _name_17 = a_1.getName();
+ String _firstUpper_4 = StringExtensions.toFirstUpper(_name_17);
+ _builder.append(_firstUpper_4, " ");
+ _builder.append("(");
+ String _name_18 = a_1.getName();
+ _builder.append(_name_18, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("variableService.write(this.getInstancePath()+\"/");
+ String _name_19 = a_1.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("\", ");
+ String _name_20 = a_1.getName();
+ _builder.append(_name_20, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence genMinMaxConstants(final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ List<AttrClassConfig> _allAttrConfigFlat = this.configExt.getAllAttrConfigFlat(ac);
+ final Function1<AttrClassConfig,Boolean> _function = new Function1<AttrClassConfig,Boolean>() {
+ public Boolean apply(final AttrClassConfig c) {
+ boolean _or = false;
+ NumberLiteral _min = c.getMin();
+ boolean _notEquals = (!Objects.equal(_min, null));
+ if (_notEquals) {
+ _or = true;
+ } else {
+ NumberLiteral _max = c.getMax();
+ boolean _notEquals_1 = (!Objects.equal(_max, null));
+ _or = (_notEquals || _notEquals_1);
+ }
+ return Boolean.valueOf(_or);
+ }
+ };
+ Iterable<AttrClassConfig> attrConfigs = IterableExtensions.<AttrClassConfig>filter(_allAttrConfigFlat, _function);
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ boolean _isEmpty = IterableExtensions.isEmpty(attrConfigs);
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append("//--------------------- attribute specifications");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ for(final AttrClassConfig c : attrConfigs) {
+ Attribute _attribute = c.getAttribute();
+ RefableType _refType = _attribute.getRefType();
+ DataType _type = _refType.getType();
+ PrimitiveType aType = ((PrimitiveType) _type);
+ _builder.newLineIfNotEmpty();
+ {
+ NumberLiteral _min = c.getMin();
+ boolean _notEquals = (!Objects.equal(_min, null));
+ if (_notEquals) {
+ _builder.append("public static ");
+ String _minMaxType = this.getMinMaxType(aType);
+ _builder.append(_minMaxType, "");
+ _builder.append(" MIN");
+ List<String> _path = this.configExt.getPath(c, false, false, true, true);
+ String _path_1 = this.configExt.toPath(_path, "_");
+ _builder.append(_path_1, "");
+ _builder.append(" = ");
+ NumberLiteral _min_1 = c.getMin();
+ String _value = this.configExt.getValue(_min_1);
+ String _valueLiteral = this.stdExt.toValueLiteral(aType, _value);
+ _builder.append(_valueLiteral, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ NumberLiteral _max = c.getMax();
+ boolean _notEquals_1 = (!Objects.equal(_max, null));
+ if (_notEquals_1) {
+ _builder.append("public static ");
+ String _minMaxType_1 = this.getMinMaxType(aType);
+ _builder.append(_minMaxType_1, "");
+ _builder.append(" MAX");
+ List<String> _path_2 = this.configExt.getPath(c, false, false, true, true);
+ String _path_3 = this.configExt.toPath(_path_2, "_");
+ _builder.append(_path_3, "");
+ _builder.append(" = ");
+ NumberLiteral _max_1 = c.getMax();
+ String _value_1 = this.configExt.getValue(_max_1);
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(aType, _value_1);
+ _builder.append(_valueLiteral_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private String getMinMaxType(final PrimitiveType type) {
+ String _typeName = this.typeHelpers.typeName(type);
+ final String _switchValue = _typeName;
+ boolean _matched = false;
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"byte")) {
+ _matched=true;
+ return "int";
+ }
+ }
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"short")) {
+ _matched=true;
+ return "int";
+ }
+ }
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"float")) {
+ _matched=true;
+ return "double";
+ }
+ }
+ return this.typeHelpers.typeName(type);
+ }
+}
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 372e133ca..3854a7427 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
@@ -1,817 +1,817 @@
-package org.eclipse.etrice.generator.java.gen;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.config.AttrInstanceConfig;
-import org.eclipse.etrice.core.config.PortInstanceConfig;
-import org.eclipse.etrice.core.genmodel.base.ILogger;
-import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
-import org.eclipse.etrice.core.room.ActorClass;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.LogicalThread;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.SubSystemClass;
-import org.eclipse.etrice.generator.base.Indexed;
-import org.eclipse.etrice.generator.generic.ConfigExtension;
-import org.eclipse.etrice.generator.generic.ProcedureHelpers;
-import org.eclipse.etrice.generator.generic.RoomExtensions;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.etrice.generator.java.gen.ConfigGenAddon;
-import org.eclipse.etrice.generator.java.gen.JavaExtensions;
-import org.eclipse.etrice.generator.java.gen.VariableServiceGen;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class SubSystemClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private JavaExtensions _javaExtensions;
-
- @Inject
- private RoomExtensions _roomExtensions;
-
- @Inject
- private ConfigExtension _configExtension;
-
- @Inject
- private ConfigGenAddon configAddon;
-
- @Inject
- private ProcedureHelpers _procedureHelpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private VariableServiceGen varService;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
- for (final SubSystemInstance ssi : _subSystemInstances) {
- {
- SubSystemClass _subSystemClass = ssi.getSubSystemClass();
- String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(_subSystemClass);
- SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
- String _path = this._roomExtensions.getPath(_subSystemClass_1);
- String path = (_generationTargetPath + _path);
- SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
- String file = this._javaExtensions.getJavaFileName(_subSystemClass_2);
- String _plus = ("generating SubSystemClass 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);
- SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
- boolean _hasVariableService = this._configExtension.hasVariableService(_subSystemClass_4);
- if (_hasVariableService) {
- this.varService.doGenerate(root, ssi);
- }
- }
- }
- }
-
- public CharSequence generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("package ");
- String _package = this._roomExtensions.getPackage(cc);
- _builder.append(_package, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- boolean _hasVariableService = this._configExtension.hasVariableService(cc);
- if (_hasVariableService) {
- _builder.append("import org.eclipse.etrice.runtime.java.config.VariableService;");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.MessageService;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTServices;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
- _builder.newLine();
- _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
- _builder.newLine();
- _builder.newLine();
- EList<RoomModel> models = root.getReferencedModels(cc);
- _builder.newLineIfNotEmpty();
- {
- for(final RoomModel model : models) {
- _builder.append("import ");
- String _name = model.getName();
- _builder.append(_name, "");
- _builder.append(".*;");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- CharSequence _userCode = this._procedureHelpers.userCode(cc, 1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("public class ");
- String _name_1 = comp.getName();
- _builder.append(_name_1, "");
- _builder.append(" extends SubSystemClassBase{");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- CharSequence _userCode_1 = this._procedureHelpers.userCode(cc, 2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public ");
- String _name_2 = comp.getName();
- _builder.append(_name_2, " ");
- _builder.append("(IRTObject parent, String name) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("super(parent, name);");
- _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 receiveEvent(InterfaceItemBase ifitem, int evt, Object data){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void instantiateMessageServices(){");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),\"MessageService_Main\"));");
- _builder.newLine();
- {
- EList<LogicalThread> _threads = cc.getThreads();
- for(final LogicalThread thread : _threads) {
- _builder.append("\t\t");
- _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, ");
- EList<LogicalThread> _threads_1 = cc.getThreads();
- int _indexOf = _threads_1.indexOf(thread);
- int _plus = (_indexOf + 1);
- _builder.append(_plus, " ");
- _builder.append(", 0),\"MessageService_");
- String _name_3 = thread.getName();
- _builder.append(_name_3, " ");
- _builder.append("\", ");
- int _prio = thread.getPrio();
- _builder.append(_prio, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public void instantiateActors(){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// all addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// Addresses for the Subsystem Systemport");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
- int _maxObjId = comp.getMaxObjId();
- Iterable<Indexed<ActorInstance>> _indexed = Indexed.<ActorInstance>indexed(_allContainedInstances, _maxObjId);
- for(final Indexed<ActorInstance> ai : _indexed) {
- _builder.append("\t\t");
- _builder.append("Address addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances();
- ActorInstance _value = ai.getValue();
- int _indexOf_1 = _allContainedInstances_1.indexOf(_value);
- _builder.append(_indexOf_1, " ");
- _builder.append(" = new Address(0,0,");
- int _index1 = ai.getIndex1();
- _builder.append(_index1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_2 = comp.getAllContainedInstances();
- for(final ActorInstance ai_1 : _allContainedInstances_2) {
- _builder.append("\t\t");
- _builder.append("// actor instance ");
- String _path = ai_1.getPath();
- _builder.append(_path, " ");
- _builder.append(" itself => Systemport Address");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("// TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_1 = ai_1.getPath();
- String _pathName = this._roomExtensions.getPathName(_path_1);
- _builder.append(_pathName, " ");
- _builder.append(" = new Address(0,");
- int _threadId = ai_1.getThreadId();
- _builder.append(_threadId, " ");
- _builder.append(",");
- int _objId = ai_1.getObjId();
- _builder.append(_objId, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("// interface items of ");
- String _path_2 = ai_1.getPath();
- _builder.append(_path_2, " ");
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
- for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
- {
- boolean _isReplicated = pi.isReplicated();
- if (_isReplicated) {
- {
- EList<InterfaceItemInstance> _peers = pi.getPeers();
- for(final InterfaceItemInstance peer : _peers) {
- _builder.append("\t\t");
- EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
- int i = _peers_1.indexOf(peer);
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_3 = pi.getPath();
- String _pathName_1 = this._roomExtensions.getPathName(_path_3);
- _builder.append(_pathName_1, " ");
- _builder.append("_");
- _builder.append(i, " ");
- _builder.append(" = new Address(0,");
- int _threadId_1 = pi.getThreadId();
- _builder.append(_threadId_1, " ");
- _builder.append(",");
- int _objId_1 = pi.getObjId();
- int _plus_1 = (_objId_1 + i);
- _builder.append(_plus_1, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t\t");
- _builder.append("Address addr_item_");
- String _path_4 = pi.getPath();
- String _pathName_2 = this._roomExtensions.getPathName(_path_4);
- _builder.append(_pathName_2, " ");
- _builder.append(" = new Address(0,");
- int _threadId_2 = ai_1.getThreadId();
- _builder.append(_threadId_2, " ");
- _builder.append(",");
- int _objId_2 = pi.getObjId();
- _builder.append(_objId_2, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// instantiate all actor instances");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("instances = new ActorClassBase[");
- EList<ActorInstance> _allContainedInstances_3 = comp.getAllContainedInstances();
- int _size = _allContainedInstances_3.size();
- _builder.append(_size, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- {
- EList<ActorInstance> _allContainedInstances_4 = comp.getAllContainedInstances();
- for(final ActorInstance ai_2 : _allContainedInstances_4) {
- _builder.append("\t\t");
- _builder.append("instances[");
- EList<ActorInstance> _allContainedInstances_5 = comp.getAllContainedInstances();
- int _indexOf_2 = _allContainedInstances_5.indexOf(ai_2);
- _builder.append(_indexOf_2, " ");
- _builder.append("] = new ");
- ActorClass _actorClass = ai_2.getActorClass();
- String _name_4 = _actorClass.getName();
- _builder.append(_name_4, " ");
- _builder.append("(");
- _builder.newLineIfNotEmpty();
- {
- EObject _eContainer = ai_2.eContainer();
- if ((_eContainer instanceof SubSystemInstance)) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("this,");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("instances[");
- EList<ActorInstance> _allContainedInstances_6 = comp.getAllContainedInstances();
- EObject _eContainer_1 = ai_2.eContainer();
- int _indexOf_3 = _allContainedInstances_6.indexOf(_eContainer_1);
- _builder.append(_indexOf_3, " ");
- _builder.append("],");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\"");
- String _name_5 = ai_2.getName();
- _builder.append(_name_5, " ");
- _builder.append("\",");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// own interface item addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("new Address[][] {{addr_item_");
- String _path_5 = ai_2.getPath();
- String _pathName_3 = this._roomExtensions.getPathName(_path_5);
- _builder.append(_pathName_3, " ");
- _builder.append("}");
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_2.getOrderedIfItemInstances();
- boolean _isEmpty = _orderedIfItemInstances_1.isEmpty();
- boolean _not = (!_isEmpty);
- if (_not) {
- _builder.append(",");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
- boolean _hasElements = false;
- for(final InterfaceItemInstance pi_1 : _orderedIfItemInstances_2) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _isReplicated_1 = pi_1.isReplicated();
- if (_isReplicated_1) {
- {
- EList<InterfaceItemInstance> _peers_2 = pi_1.getPeers();
- boolean _isEmpty_1 = _peers_2.isEmpty();
- if (_isEmpty_1) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("null");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- {
- EList<InterfaceItemInstance> _peers_3 = pi_1.getPeers();
- boolean _hasElements_1 = false;
- for(final InterfaceItemInstance peer_1 : _peers_3) {
- if (!_hasElements_1) {
- _hasElements_1 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_6 = pi_1.getPath();
- String _pathName_4 = this._roomExtensions.getPathName(_path_6);
- _builder.append(_pathName_4, " ");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
- int _indexOf_4 = _peers_4.indexOf(peer_1);
- _builder.append(_indexOf_4, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_7 = pi_1.getPath();
- String _pathName_5 = this._roomExtensions.getPathName(_path_7);
- _builder.append(_pathName_5, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("},");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("// peer interface item addresses");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("new Address[][] {{addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_7 = comp.getAllContainedInstances();
- int _indexOf_5 = _allContainedInstances_7.indexOf(ai_2);
- _builder.append(_indexOf_5, " ");
- _builder.append("}");
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_3 = ai_2.getOrderedIfItemInstances();
- boolean _isEmpty_2 = _orderedIfItemInstances_3.isEmpty();
- boolean _not_1 = (!_isEmpty_2);
- if (_not_1) {
- _builder.append(",");
- }
- }
- _builder.newLineIfNotEmpty();
- {
- EList<InterfaceItemInstance> _orderedIfItemInstances_4 = ai_2.getOrderedIfItemInstances();
- boolean _hasElements_2 = false;
- for(final InterfaceItemInstance pi_2 : _orderedIfItemInstances_4) {
- if (!_hasElements_2) {
- _hasElements_2 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _and = false;
- boolean _isReplicated_2 = pi_2.isReplicated();
- if (!_isReplicated_2) {
- _and = false;
- } else {
- EList<InterfaceItemInstance> _peers_5 = pi_2.getPeers();
- boolean _isEmpty_3 = _peers_5.isEmpty();
- _and = (_isReplicated_2 && _isEmpty_3);
- }
- if (_and) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("null");
- _builder.newLine();
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- {
- EList<InterfaceItemInstance> _peers_6 = pi_2.getPeers();
- boolean _isEmpty_4 = _peers_6.isEmpty();
- if (_isEmpty_4) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("null");
- _builder.newLine();
- } else {
- {
- EList<InterfaceItemInstance> _peers_7 = pi_2.getPeers();
- boolean _hasElements_3 = false;
- for(final InterfaceItemInstance pp : _peers_7) {
- if (!_hasElements_3) {
- _hasElements_3 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- {
- boolean _isReplicated_3 = pp.isReplicated();
- if (_isReplicated_3) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_8 = pp.getPath();
- String _pathName_6 = this._roomExtensions.getPathName(_path_8);
- _builder.append(_pathName_6, " ");
- _builder.append("_");
- EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
- int _indexOf_6 = _peers_8.indexOf(pi_2);
- _builder.append(_indexOf_6, " ");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("addr_item_");
- String _path_9 = pp.getPath();
- String _pathName_7 = this._roomExtensions.getPathName(_path_9);
- _builder.append(_pathName_7, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- {
- List<AttrInstanceConfig> _configAttributes = this._configExtension.getConfigAttributes(ai_2);
- final Function1<AttrInstanceConfig,Boolean> _function = new Function1<AttrInstanceConfig,Boolean>() {
- public Boolean apply(final AttrInstanceConfig c) {
- boolean _isDynConfig = c.isDynConfig();
- return Boolean.valueOf(_isDynConfig);
- }
- };
- boolean _exists = IterableExtensions.<AttrInstanceConfig>exists(_configAttributes, _function);
- if (_exists) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append(", variableService");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("); ");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// apply instance attribute configurations");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
- for(final ActorInstance ai_3 : _allContainedInstances_8) {
- {
- boolean _and_1 = false;
- List<AttrInstanceConfig> _configAttributes_1 = this._configExtension.getConfigAttributes(ai_3);
- boolean _isEmpty_5 = _configAttributes_1.isEmpty();
- if (!_isEmpty_5) {
- _and_1 = false;
- } else {
- List<PortInstanceConfig> _configPorts = this._configExtension.getConfigPorts(ai_3);
- boolean _isEmpty_6 = _configPorts.isEmpty();
- _and_1 = (_isEmpty_5 && _isEmpty_6);
- }
- boolean _not_2 = (!_and_1);
- if (_not_2) {
- _builder.append("\t\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- ActorClass _actorClass_1 = ai_3.getActorClass();
- String _name_6 = _actorClass_1.getName();
- _builder.append(_name_6, " ");
- _builder.append(" inst = (");
- ActorClass _actorClass_2 = ai_3.getActorClass();
- String _name_7 = _actorClass_2.getName();
- _builder.append(_name_7, " ");
- _builder.append(") instances[");
- EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
- int _indexOf_7 = _allContainedInstances_9.indexOf(ai_3);
- _builder.append(_indexOf_7, " ");
- _builder.append("];");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- ActorClass _actorClass_3 = ai_3.getActorClass();
- String _name_8 = _actorClass_3.getName();
- List<AttrInstanceConfig> _configAttributes_2 = this._configExtension.getConfigAttributes(ai_3);
- CharSequence _applyInstanceConfig = this.configAddon.applyInstanceConfig("inst", _name_8, _configAttributes_2);
- _builder.append(_applyInstanceConfig, " ");
- _builder.newLineIfNotEmpty();
- {
- List<PortInstanceConfig> _configPorts_1 = this._configExtension.getConfigPorts(ai_3);
- for(final PortInstanceConfig portConfig : _configPorts_1) {
- _builder.append("\t\t");
- _builder.append("\t");
- InterfaceItem _item = portConfig.getItem();
- String _name_9 = _item.getName();
- ActorClass _actorClass_4 = ai_3.getActorClass();
- String _name_10 = _actorClass_4.getName();
- CharSequence _invokeGetter = this._procedureHelpers.invokeGetter(_name_9, _name_10);
- String _plus_2 = ("inst." + _invokeGetter);
- InterfaceItem _item_1 = portConfig.getItem();
- String _portClassName = this._roomExtensions.getPortClassName(_item_1);
- EList<AttrInstanceConfig> _attributes = portConfig.getAttributes();
- CharSequence _applyInstanceConfig_1 = this.configAddon.applyInstanceConfig(_plus_2, _portClassName, _attributes);
- _builder.append(_applyInstanceConfig_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// create the subsystem system port\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, \"RTSystemPort\",");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("0, //local ID");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("// own addresses");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("new Address[]{");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
- boolean _hasElements_4 = false;
- for(final ActorInstance ai_4 : _allContainedInstances_10) {
- if (!_hasElements_4) {
- _hasElements_4 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("addr_item_SystemPort_");
- EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
- int _indexOf_8 = _allContainedInstances_11.indexOf(ai_4);
- _builder.append(_indexOf_8, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("},");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("// peer addresses");
- _builder.newLine();
- _builder.append("\t\t\t\t");
- _builder.append("new Address[]{");
- _builder.newLine();
- {
- EList<ActorInstance> _allContainedInstances_12 = comp.getAllContainedInstances();
- boolean _hasElements_5 = false;
- for(final ActorInstance ai_5 : _allContainedInstances_12) {
- if (!_hasElements_5) {
- _hasElements_5 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t\t\t\t\t");
- _builder.append("addr_item_");
- String _path_10 = ai_5.getPath();
- String _pathName_8 = this._roomExtensions.getPathName(_path_10);
- _builder.append(_pathName_8, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("});");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- boolean _hasVariableService_1 = this._configExtension.hasVariableService(cc);
- if (_hasVariableService_1) {
- _builder.append("\t\t");
- _builder.append("private VariableService variableService;");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("public void init(){");
- _builder.newLine();
- {
- boolean _hasVariableService_2 = this._configExtension.hasVariableService(cc);
- if (_hasVariableService_2) {
- _builder.append("\t\t\t");
- _builder.append("variableService = new ");
- String _name_11 = comp.getName();
- _builder.append(_name_11, " ");
- _builder.append("VariableService(this);");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t\t");
- _builder.append("super.init();");
- _builder.newLine();
- {
- boolean _hasVariableService_3 = this._configExtension.hasVariableService(cc);
- if (_hasVariableService_3) {
- _builder.append("\t\t\t");
- _builder.append("variableService.init();");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("@Override");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("public void stop(){");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("super.stop();");
- _builder.newLine();
- {
- boolean _hasVariableService_4 = this._configExtension.hasVariableService(cc);
- if (_hasVariableService_4) {
- _builder.append("\t\t\t");
- _builder.append("variableService.stop();");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.config.AttrInstanceConfig;
+import org.eclipse.etrice.core.config.PortInstanceConfig;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.LogicalThread;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.Indexed;
+import org.eclipse.etrice.generator.generic.ConfigExtension;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.ConfigGenAddon;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.etrice.generator.java.gen.VariableServiceGen;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class SubSystemClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions _javaExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ConfigExtension _configExtension;
+
+ @Inject
+ private ConfigGenAddon configAddon;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private VariableServiceGen varService;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance ssi : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ String _path = this._roomExtensions.getPath(_subSystemClass_1);
+ String path = (_generationTargetPath + _path);
+ SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
+ String file = this._javaExtensions.getJavaFileName(_subSystemClass_2);
+ String _plus = ("generating SubSystemClass 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);
+ SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
+ boolean _hasVariableService = this._configExtension.hasVariableService(_subSystemClass_4);
+ if (_hasVariableService) {
+ this.varService.doGenerate(root, ssi);
+ }
+ }
+ }
+ }
+
+ public CharSequence generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("package ");
+ String _package = this._roomExtensions.getPackage(cc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ boolean _hasVariableService = this._configExtension.hasVariableService(cc);
+ if (_hasVariableService) {
+ _builder.append("import org.eclipse.etrice.runtime.java.config.VariableService;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.MessageService;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTServices;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.Address;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.IRTObject;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;");
+ _builder.newLine();
+ _builder.newLine();
+ EList<RoomModel> models = root.getReferencedModels(cc);
+ _builder.newLineIfNotEmpty();
+ {
+ for(final RoomModel model : models) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.newLine();
+ CharSequence _userCode = this._procedureHelpers.userCode(cc, 1);
+ _builder.append(_userCode, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("public class ");
+ String _name_1 = comp.getName();
+ _builder.append(_name_1, "");
+ _builder.append(" extends SubSystemClassBase{");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(cc, 2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_2 = comp.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("(String name) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super(name);");
+ _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 receiveEvent(InterfaceItemBase ifitem, int evt, Object data){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void instantiateMessageServices(){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),\"MessageService_Main\"));");
+ _builder.newLine();
+ {
+ EList<LogicalThread> _threads = cc.getThreads();
+ for(final LogicalThread thread : _threads) {
+ _builder.append("\t\t");
+ _builder.append("RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, ");
+ EList<LogicalThread> _threads_1 = cc.getThreads();
+ int _indexOf = _threads_1.indexOf(thread);
+ int _plus = (_indexOf + 1);
+ _builder.append(_plus, " ");
+ _builder.append(", 0),\"MessageService_");
+ String _name_3 = thread.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\", ");
+ int _prio = thread.getPrio();
+ _builder.append(_prio, " ");
+ _builder.append("));");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void instantiateActors(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// all addresses");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// Addresses for the Subsystem Systemport");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
+ int _maxObjId = comp.getMaxObjId();
+ Iterable<Indexed<ActorInstance>> _indexed = Indexed.<ActorInstance>indexed(_allContainedInstances, _maxObjId);
+ for(final Indexed<ActorInstance> ai : _indexed) {
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances();
+ ActorInstance _value = ai.getValue();
+ int _indexOf_1 = _allContainedInstances_1.indexOf(_value);
+ _builder.append(_indexOf_1, " ");
+ _builder.append(" = new Address(0,0,");
+ int _index1 = ai.getIndex1();
+ _builder.append(_index1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_2 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_1 : _allContainedInstances_2) {
+ _builder.append("\t\t");
+ _builder.append("// actor instance ");
+ String _path = ai_1.getPath();
+ _builder.append(_path, " ");
+ _builder.append(" itself => Systemport Address");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("// TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_");
+ String _path_1 = ai_1.getPath();
+ String _pathName = this._roomExtensions.getPathName(_path_1);
+ _builder.append(_pathName, " ");
+ _builder.append(" = new Address(0,");
+ int _threadId = ai_1.getThreadId();
+ _builder.append(_threadId, " ");
+ _builder.append(",");
+ int _objId = ai_1.getObjId();
+ _builder.append(_objId, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("// interface items of ");
+ String _path_2 = ai_1.getPath();
+ _builder.append(_path_2, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
+ for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
+ {
+ boolean _isReplicated = pi.isReplicated();
+ if (_isReplicated) {
+ {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ for(final InterfaceItemInstance peer : _peers) {
+ _builder.append("\t\t");
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int i = _peers_1.indexOf(peer);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_");
+ String _path_3 = pi.getPath();
+ String _pathName_1 = this._roomExtensions.getPathName(_path_3);
+ _builder.append(_pathName_1, " ");
+ _builder.append("_");
+ _builder.append(i, " ");
+ _builder.append(" = new Address(0,");
+ int _threadId_1 = pi.getThreadId();
+ _builder.append(_threadId_1, " ");
+ _builder.append(",");
+ int _objId_1 = pi.getObjId();
+ int _plus_1 = (_objId_1 + i);
+ _builder.append(_plus_1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("Address addr_item_");
+ String _path_4 = pi.getPath();
+ String _pathName_2 = this._roomExtensions.getPathName(_path_4);
+ _builder.append(_pathName_2, " ");
+ _builder.append(" = new Address(0,");
+ int _threadId_2 = ai_1.getThreadId();
+ _builder.append(_threadId_2, " ");
+ _builder.append(",");
+ int _objId_2 = pi.getObjId();
+ _builder.append(_objId_2, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// instantiate all actor instances");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("instances = new ActorClassBase[");
+ EList<ActorInstance> _allContainedInstances_3 = comp.getAllContainedInstances();
+ int _size = _allContainedInstances_3.size();
+ _builder.append(_size, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances_4 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_2 : _allContainedInstances_4) {
+ _builder.append("\t\t");
+ _builder.append("instances[");
+ EList<ActorInstance> _allContainedInstances_5 = comp.getAllContainedInstances();
+ int _indexOf_2 = _allContainedInstances_5.indexOf(ai_2);
+ _builder.append(_indexOf_2, " ");
+ _builder.append("] = new ");
+ ActorClass _actorClass = ai_2.getActorClass();
+ String _name_4 = _actorClass.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("(");
+ _builder.newLineIfNotEmpty();
+ {
+ EObject _eContainer = ai_2.eContainer();
+ if ((_eContainer instanceof SubSystemInstance)) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("this,");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("instances[");
+ EList<ActorInstance> _allContainedInstances_6 = comp.getAllContainedInstances();
+ EObject _eContainer_1 = ai_2.eContainer();
+ int _indexOf_3 = _allContainedInstances_6.indexOf(_eContainer_1);
+ _builder.append(_indexOf_3, " ");
+ _builder.append("],");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\"");
+ String _name_5 = ai_2.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("\",");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// own interface item addresses");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("new Address[][] {{addr_item_");
+ String _path_5 = ai_2.getPath();
+ String _pathName_3 = this._roomExtensions.getPathName(_path_5);
+ _builder.append(_pathName_3, " ");
+ _builder.append("}");
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_2.getOrderedIfItemInstances();
+ boolean _isEmpty = _orderedIfItemInstances_1.isEmpty();
+ boolean _not = (!_isEmpty);
+ if (_not) {
+ _builder.append(",");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
+ boolean _hasElements = false;
+ for(final InterfaceItemInstance pi_1 : _orderedIfItemInstances_2) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ boolean _isReplicated_1 = pi_1.isReplicated();
+ if (_isReplicated_1) {
+ {
+ EList<InterfaceItemInstance> _peers_2 = pi_1.getPeers();
+ boolean _isEmpty_1 = _peers_2.isEmpty();
+ if (_isEmpty_1) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("null");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ EList<InterfaceItemInstance> _peers_3 = pi_1.getPeers();
+ boolean _hasElements_1 = false;
+ for(final InterfaceItemInstance peer_1 : _peers_3) {
+ if (!_hasElements_1) {
+ _hasElements_1 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_6 = pi_1.getPath();
+ String _pathName_4 = this._roomExtensions.getPathName(_path_6);
+ _builder.append(_pathName_4, " ");
+ _builder.append("_");
+ EList<InterfaceItemInstance> _peers_4 = pi_1.getPeers();
+ int _indexOf_4 = _peers_4.indexOf(peer_1);
+ _builder.append(_indexOf_4, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_7 = pi_1.getPath();
+ String _pathName_5 = this._roomExtensions.getPathName(_path_7);
+ _builder.append(_pathName_5, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("},");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("// peer interface item addresses");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("new Address[][] {{addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_7 = comp.getAllContainedInstances();
+ int _indexOf_5 = _allContainedInstances_7.indexOf(ai_2);
+ _builder.append(_indexOf_5, " ");
+ _builder.append("}");
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_3 = ai_2.getOrderedIfItemInstances();
+ boolean _isEmpty_2 = _orderedIfItemInstances_3.isEmpty();
+ boolean _not_1 = (!_isEmpty_2);
+ if (_not_1) {
+ _builder.append(",");
+ }
+ }
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances_4 = ai_2.getOrderedIfItemInstances();
+ boolean _hasElements_2 = false;
+ for(final InterfaceItemInstance pi_2 : _orderedIfItemInstances_4) {
+ if (!_hasElements_2) {
+ _hasElements_2 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ boolean _and = false;
+ boolean _isReplicated_2 = pi_2.isReplicated();
+ if (!_isReplicated_2) {
+ _and = false;
+ } else {
+ EList<InterfaceItemInstance> _peers_5 = pi_2.getPeers();
+ boolean _isEmpty_3 = _peers_5.isEmpty();
+ _and = (_isReplicated_2 && _isEmpty_3);
+ }
+ if (_and) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("null");
+ _builder.newLine();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ {
+ EList<InterfaceItemInstance> _peers_6 = pi_2.getPeers();
+ boolean _isEmpty_4 = _peers_6.isEmpty();
+ if (_isEmpty_4) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("null");
+ _builder.newLine();
+ } else {
+ {
+ EList<InterfaceItemInstance> _peers_7 = pi_2.getPeers();
+ boolean _hasElements_3 = false;
+ for(final InterfaceItemInstance pp : _peers_7) {
+ if (!_hasElements_3) {
+ _hasElements_3 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ {
+ boolean _isReplicated_3 = pp.isReplicated();
+ if (_isReplicated_3) {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_8 = pp.getPath();
+ String _pathName_6 = this._roomExtensions.getPathName(_path_8);
+ _builder.append(_pathName_6, " ");
+ _builder.append("_");
+ EList<InterfaceItemInstance> _peers_8 = pp.getPeers();
+ int _indexOf_6 = _peers_8.indexOf(pi_2);
+ _builder.append(_indexOf_6, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("addr_item_");
+ String _path_9 = pp.getPath();
+ String _pathName_7 = this._roomExtensions.getPathName(_path_9);
+ _builder.append(_pathName_7, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ {
+ List<AttrInstanceConfig> _configAttributes = this._configExtension.getConfigAttributes(ai_2);
+ final Function1<AttrInstanceConfig,Boolean> _function = new Function1<AttrInstanceConfig,Boolean>() {
+ public Boolean apply(final AttrInstanceConfig c) {
+ boolean _isDynConfig = c.isDynConfig();
+ return Boolean.valueOf(_isDynConfig);
+ }
+ };
+ boolean _exists = IterableExtensions.<AttrInstanceConfig>exists(_configAttributes, _function);
+ if (_exists) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append(", variableService");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("); ");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// apply instance attribute configurations");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_3 : _allContainedInstances_8) {
+ {
+ boolean _and_1 = false;
+ List<AttrInstanceConfig> _configAttributes_1 = this._configExtension.getConfigAttributes(ai_3);
+ boolean _isEmpty_5 = _configAttributes_1.isEmpty();
+ if (!_isEmpty_5) {
+ _and_1 = false;
+ } else {
+ List<PortInstanceConfig> _configPorts = this._configExtension.getConfigPorts(ai_3);
+ boolean _isEmpty_6 = _configPorts.isEmpty();
+ _and_1 = (_isEmpty_5 && _isEmpty_6);
+ }
+ boolean _not_2 = (!_and_1);
+ if (_not_2) {
+ _builder.append("\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ ActorClass _actorClass_1 = ai_3.getActorClass();
+ String _name_6 = _actorClass_1.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(" inst = (");
+ ActorClass _actorClass_2 = ai_3.getActorClass();
+ String _name_7 = _actorClass_2.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(") instances[");
+ EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
+ int _indexOf_7 = _allContainedInstances_9.indexOf(ai_3);
+ _builder.append(_indexOf_7, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ ActorClass _actorClass_3 = ai_3.getActorClass();
+ String _name_8 = _actorClass_3.getName();
+ List<AttrInstanceConfig> _configAttributes_2 = this._configExtension.getConfigAttributes(ai_3);
+ CharSequence _applyInstanceConfig = this.configAddon.applyInstanceConfig("inst", _name_8, _configAttributes_2);
+ _builder.append(_applyInstanceConfig, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ List<PortInstanceConfig> _configPorts_1 = this._configExtension.getConfigPorts(ai_3);
+ for(final PortInstanceConfig portConfig : _configPorts_1) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ InterfaceItem _item = portConfig.getItem();
+ String _name_9 = _item.getName();
+ ActorClass _actorClass_4 = ai_3.getActorClass();
+ String _name_10 = _actorClass_4.getName();
+ CharSequence _invokeGetter = this._procedureHelpers.invokeGetter(_name_9, _name_10);
+ String _plus_2 = ("inst." + _invokeGetter);
+ InterfaceItem _item_1 = portConfig.getItem();
+ String _portClassName = this._roomExtensions.getPortClassName(_item_1);
+ EList<AttrInstanceConfig> _attributes = portConfig.getAttributes();
+ CharSequence _applyInstanceConfig_1 = this.configAddon.applyInstanceConfig(_plus_2, _portClassName, _attributes);
+ _builder.append(_applyInstanceConfig_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// create the subsystem system port\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, \"RTSystemPort\",");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("0, //local ID");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("// own addresses");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("new Address[]{");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
+ boolean _hasElements_4 = false;
+ for(final ActorInstance ai_4 : _allContainedInstances_10) {
+ if (!_hasElements_4) {
+ _hasElements_4 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t\t\t\t");
+ _builder.append("addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
+ int _indexOf_8 = _allContainedInstances_11.indexOf(ai_4);
+ _builder.append(_indexOf_8, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("},");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("// peer addresses");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("new Address[]{");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_12 = comp.getAllContainedInstances();
+ boolean _hasElements_5 = false;
+ for(final ActorInstance ai_5 : _allContainedInstances_12) {
+ if (!_hasElements_5) {
+ _hasElements_5 = true;
+ } else {
+ _builder.appendImmediate(",", " ");
+ }
+ _builder.append("\t\t\t\t\t");
+ _builder.append("addr_item_");
+ String _path_10 = ai_5.getPath();
+ String _pathName_8 = this._roomExtensions.getPathName(_path_10);
+ _builder.append(_pathName_8, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t\t");
+ _builder.append("});");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ boolean _hasVariableService_1 = this._configExtension.hasVariableService(cc);
+ if (_hasVariableService_1) {
+ _builder.append("\t\t");
+ _builder.append("private VariableService variableService;");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("public void init(){");
+ _builder.newLine();
+ {
+ boolean _hasVariableService_2 = this._configExtension.hasVariableService(cc);
+ if (_hasVariableService_2) {
+ _builder.append("\t\t\t");
+ _builder.append("variableService = new ");
+ String _name_11 = comp.getName();
+ _builder.append(_name_11, " ");
+ _builder.append("VariableService(this);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("super.init();");
+ _builder.newLine();
+ {
+ boolean _hasVariableService_3 = this._configExtension.hasVariableService(cc);
+ if (_hasVariableService_3) {
+ _builder.append("\t\t\t");
+ _builder.append("variableService.init();");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("public void stop(){");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("super.stop();");
+ _builder.newLine();
+ {
+ boolean _hasVariableService_4 = this._configExtension.hasVariableService(cc);
+ if (_hasVariableService_4) {
+ _builder.append("\t\t\t");
+ _builder.append("variableService.stop();");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ return _builder;
+ }
+}
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
new file mode 100644
index 000000000..bee7d72ec
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.java/xtend-gen/org/eclipse/etrice/generator/java/gen/VariableServiceGen.java
@@ -0,0 +1,972 @@
+package org.eclipse.etrice.generator.java.gen;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.config.ActorClassConfig;
+import org.eclipse.etrice.core.config.ActorInstanceConfig;
+import org.eclipse.etrice.core.config.AttrClassConfig;
+import org.eclipse.etrice.core.config.AttrInstanceConfig;
+import org.eclipse.etrice.core.config.DynamicConfig;
+import org.eclipse.etrice.core.config.NumberLiteral;
+import org.eclipse.etrice.core.config.RefPath;
+import org.eclipse.etrice.core.config.SubSystemConfig;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.generic.ConfigExtension;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.etrice.generator.java.gen.JavaExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Conversions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class VariableServiceGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private JavaExtensions stdExt;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ConfigExtension configExt;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root, final SubSystemInstance ssi) {
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String path = (_generationTargetPath + _path);
+ SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
+ String _name = _subSystemClass_2.getName();
+ String file = (_name + "VariableService.java");
+ String _plus = ("generating VariableService implementation: \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
+ CharSequence _generate = this.generate(root, ssi, _subSystemClass_3);
+ this.fileAccess.generateFile(file, _generate);
+ }
+
+ private CharSequence generate(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ SubSystemConfig _subSystemConfig = this.configExt.getSubSystemConfig(cc);
+ final DynamicConfig dynConfig = _subSystemConfig.getDynConfig();
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("package ");
+ String _package = this.roomExt.getPackage(cc);
+ _builder.append(_package, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("import java.util.Arrays;");
+ _builder.newLine();
+ _builder.append("import java.util.HashMap;");
+ _builder.newLine();
+ _builder.append("import java.util.Map;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.etrice.runtime.java.config.VariableService;");
+ _builder.newLine();
+ {
+ String _userCode1 = dynConfig.getUserCode1();
+ boolean _notEquals = (!Objects.equal(_userCode1, null));
+ if (_notEquals) {
+ String _userCode1_1 = dynConfig.getUserCode1();
+ _builder.append(_userCode1_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("import org.eclipse.etrice.runtime.java.config.ConfigSourceFile;");
+ _builder.newLine();
+ }
+ }
+ List<ActorInstance> ais = this.dynConfigsAIs(comp);
+ _builder.newLineIfNotEmpty();
+ {
+ HashSet<RoomModel> _roomModels = this.getRoomModels(ais);
+ for(final RoomModel model : _roomModels) {
+ _builder.append("import ");
+ String _name = model.getName();
+ _builder.append(_name, "");
+ _builder.append(".*;");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("public class ");
+ String _name_1 = comp.getName();
+ String _plus = (_name_1 + "VariableService");
+ _builder.append(_plus, "");
+ _builder.append(" extends VariableService{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("private ");
+ String _name_2 = cc.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(" subSystem;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// Actor instances");
+ _builder.newLine();
+ {
+ for(final ActorInstance ai : ais) {
+ _builder.append("\t");
+ _builder.append("private ");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_3 = _actorClass.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(" ");
+ String _path = ai.getPath();
+ String[] _split = _path.split("/");
+ Iterable<String> _drop = IterableExtensions.<String>drop(((Iterable<String>)Conversions.doWrapArray(_split)), 2);
+ String _path_1 = this.configExt.toPath(_drop, "_");
+ _builder.append(_path_1, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public ");
+ String _name_4 = comp.getName();
+ String _plus_1 = (_name_4 + "VariableService");
+ _builder.append(_plus_1, " ");
+ _builder.append("(");
+ String _name_5 = cc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append(" subSystem) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("super(");
+ {
+ String _filePath = dynConfig.getFilePath();
+ boolean _notEquals_1 = (!Objects.equal(_filePath, null));
+ if (_notEquals_1) {
+ _builder.append("new ConfigSourceFile(\"");
+ String _filePath_1 = dynConfig.getFilePath();
+ _builder.append(_filePath_1, " ");
+ _builder.append("\")");
+ } else {
+ String _userCode2 = dynConfig.getUserCode2();
+ _builder.append(_userCode2, " ");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("this.subSystem = subSystem;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("protected void initInstances(){");
+ _builder.newLine();
+ {
+ for(final ActorInstance ai_1 : ais) {
+ _builder.append("\t\t");
+ String _path_2 = ai_1.getPath();
+ String[] _split_1 = _path_2.split("/");
+ Iterable<String> _drop_1 = IterableExtensions.<String>drop(((Iterable<String>)Conversions.doWrapArray(_split_1)), 2);
+ String _path_3 = this.configExt.toPath(_drop_1, "_");
+ _builder.append(_path_3, " ");
+ _builder.append(" = (");
+ ActorClass _actorClass_1 = ai_1.getActorClass();
+ String _name_6 = _actorClass_1.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(")subSystem.getInstance(\"");
+ String _path_4 = ai_1.getPath();
+ _builder.append(_path_4, " ");
+ _builder.append("\");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("protected void setAttributeValues(Map<String, Object> values) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("Object object;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("String id = null;");
+ _builder.newLine();
+ {
+ Iterable<AttrInstanceConfig> _attrDynConfigs = this.configExt.getAttrDynConfigs(cc, true, false);
+ for(final AttrInstanceConfig attrConfig : _attrDynConfigs) {
+ _builder.append("\t\t");
+ EObject _eContainer = attrConfig.eContainer();
+ RefPath _path_5 = ((ActorInstanceConfig) _eContainer).getPath();
+ EList<String> _refs = _path_5.getRefs();
+ String aiName = this.configExt.toPath(_refs, "_");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("try{");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("boolean changed = false;");
+ _builder.newLine();
+ {
+ Map<Attribute,List<String>> _allAttributes = this.getAllAttributes(attrConfig);
+ Set<Entry<Attribute,List<String>>> _entrySet = _allAttributes.entrySet();
+ for(final Entry<Attribute,List<String>> entry : _entrySet) {
+ _builder.append("\t\t");
+ _builder.append("\t");
+ Attribute a = entry.getKey();
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ List<String> _path_6 = this.configExt.getPath(attrConfig, true, true, true, false);
+ String _path_7 = this.configExt.toPath(_path_6, "/");
+ List<String> _value = entry.getValue();
+ String _path_8 = this.configExt.toPath(_value, "/");
+ String _plus_2 = (_path_7 + _path_8);
+ String _plus_3 = (_plus_2 + "/");
+ String _name_7 = a.getName();
+ String aPath = (_plus_3 + _name_7);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("id = \"");
+ _builder.append(aPath, " ");
+ _builder.append("\";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ {
+ int _size = a.getSize();
+ boolean _equals = (_size == 0);
+ if (_equals) {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ String _wrapper = this.stdExt.toWrapper(_typeName);
+ _builder.append(_wrapper, " ");
+ } else {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName_1 = this._typeHelpers.typeName(_type_1);
+ _builder.append(_typeName_1, " ");
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" _");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(" = null;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("object = values.get(id);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("if(object != null){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("_");
+ String _name_9 = a.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(" = ensure");
+ RefableType _refType_2 = a.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ String _typeName_2 = this._typeHelpers.typeName(_type_2);
+ String _firstUpper = StringExtensions.toFirstUpper(_typeName_2);
+ _builder.append(_firstUpper, " ");
+ {
+ int _size_1 = a.getSize();
+ boolean _greaterThan = (_size_1 > 0);
+ if (_greaterThan) {
+ _builder.append("Array");
+ }
+ }
+ _builder.append("(object");
+ {
+ int _size_2 = a.getSize();
+ boolean _greaterThan_1 = (_size_2 > 0);
+ if (_greaterThan_1) {
+ _builder.append(", ");
+ int _size_3 = a.getSize();
+ _builder.append(_size_3, " ");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ EObject _eContainer_1 = attrConfig.eContainer();
+ ActorClassConfig _actorClassConfig = this.configExt.getActorClassConfig(((ActorInstanceConfig) _eContainer_1));
+ CharSequence _genMinMaxCheck = this.genMinMaxCheck(attrConfig, _actorClassConfig);
+ _builder.append(_genMinMaxCheck, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("if(!");
+ {
+ int _size_4 = a.getSize();
+ boolean _equals_1 = (_size_4 == 0);
+ if (_equals_1) {
+ _builder.append("_");
+ String _name_10 = a.getName();
+ _builder.append(_name_10, " ");
+ _builder.append(".equals(");
+ } else {
+ _builder.append("Arrays.equals(_");
+ String _name_11 = a.getName();
+ _builder.append(_name_11, " ");
+ _builder.append(", ");
+ }
+ }
+ _builder.append("(");
+ {
+ int _size_5 = a.getSize();
+ boolean _equals_2 = (_size_5 == 0);
+ if (_equals_2) {
+ RefableType _refType_3 = a.getRefType();
+ DataType _type_3 = _refType_3.getType();
+ String _typeName_3 = this._typeHelpers.typeName(_type_3);
+ String _wrapper_1 = this.stdExt.toWrapper(_typeName_3);
+ _builder.append(_wrapper_1, " ");
+ } else {
+ RefableType _refType_4 = a.getRefType();
+ DataType _type_4 = _refType_4.getType();
+ String _typeName_4 = this._typeHelpers.typeName(_type_4);
+ _builder.append(_typeName_4, " ");
+ _builder.append("[]");
+ }
+ }
+ _builder.append(")getDiffMap().get(id)))");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t\t");
+ _builder.append("changed = true;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("} else");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("warning(id, \"is missing\");");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("if(changed)");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("synchronized(");
+ _builder.append(aiName, " ");
+ _builder.append(".");
+ Attribute _attribute = attrConfig.getAttribute();
+ String _name_12 = _attribute.getName();
+ String _plus_4 = (_name_12 + "Lock");
+ CharSequence _invokeGetter = this.helpers.invokeGetter(_plus_4, null);
+ _builder.append(_invokeGetter, " ");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t\t");
+ _builder.append("if(");
+ _builder.append(aiName, " ");
+ _builder.append(".");
+ Attribute _attribute_1 = attrConfig.getAttribute();
+ String _name_13 = _attribute_1.getName();
+ String _plus_5 = (_name_13 + "Lock");
+ CharSequence _invokeGetter_1 = this.helpers.invokeGetter(_plus_5, null);
+ _builder.append(_invokeGetter_1, " ");
+ _builder.append(".isUpdate()){");
+ _builder.newLineIfNotEmpty();
+ {
+ Map<Attribute,List<String>> _allAttributes_1 = this.getAllAttributes(attrConfig);
+ Set<Entry<Attribute,List<String>>> _entrySet_1 = _allAttributes_1.entrySet();
+ for(final Entry<Attribute,List<String>> entry_1 : _entrySet_1) {
+ _builder.append("\t\t");
+ _builder.append("\t\t\t\t");
+ _builder.append("if(_");
+ Attribute _key = entry_1.getKey();
+ String _name_14 = _key.getName();
+ _builder.append(_name_14, " ");
+ _builder.append(" != null){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append(aiName, " ");
+ List<String> _value_1 = entry_1.getValue();
+ String _invoke = this.toInvoke(_value_1);
+ _builder.append(_invoke, " ");
+ _builder.append(".");
+ Attribute _key_1 = entry_1.getKey();
+ String _name_15 = _key_1.getName();
+ Attribute _key_2 = entry_1.getKey();
+ String _name_16 = _key_2.getName();
+ String _plus_6 = ("_" + _name_16);
+ CharSequence _invokeSetter = this.helpers.invokeSetter(_name_15, null, _plus_6);
+ _builder.append(_invokeSetter, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t\t\t");
+ _builder.append("\t");
+ _builder.append("getDiffMap().put(\"");
+ List<String> _path_9 = this.configExt.getPath(attrConfig, true, true, true, false);
+ String _path_10 = this.configExt.toPath(_path_9, "/");
+ List<String> _value_2 = entry_1.getValue();
+ String _path_11 = this.configExt.toPath(_value_2, "/");
+ String _plus_7 = (_path_10 + _path_11);
+ String _plus_8 = (_plus_7 + "/");
+ Attribute _key_3 = entry_1.getKey();
+ String _name_17 = _key_3.getName();
+ String _plus_9 = (_plus_8 + _name_17);
+ _builder.append(_plus_9, " ");
+ _builder.append("\", _");
+ Attribute _key_4 = entry_1.getKey();
+ String _name_18 = _key_4.getName();
+ _builder.append(_name_18, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("\t\t\t");
+ _builder.append("} ");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}catch(IllegalArgumentException e){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("error(id, e);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("protected Map<String, Object> getAttributeValues(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("Map<String, Object> values = new HashMap<String, Object>();");
+ _builder.newLine();
+ {
+ Iterable<AttrInstanceConfig> _attrDynConfigs_1 = this.configExt.getAttrDynConfigs(cc, true, false);
+ for(final AttrInstanceConfig attrConfig_1 : _attrDynConfigs_1) {
+ _builder.append("\t\t");
+ EObject _eContainer_2 = attrConfig_1.eContainer();
+ RefPath _path_12 = ((ActorInstanceConfig) _eContainer_2).getPath();
+ EList<String> _refs_1 = _path_12.getRefs();
+ String aiName_1 = this.configExt.toPath(_refs_1, "_");
+ _builder.newLineIfNotEmpty();
+ {
+ Map<Attribute,List<String>> _allAttributes_2 = this.getAllAttributes(attrConfig_1);
+ Set<Entry<Attribute,List<String>>> _entrySet_2 = _allAttributes_2.entrySet();
+ for(final Entry<Attribute,List<String>> entry_2 : _entrySet_2) {
+ _builder.append("\t\t");
+ Attribute _key_5 = entry_2.getKey();
+ int _size_6 = _key_5.getSize();
+ boolean array = (_size_6 > 0);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ List<String> _path_13 = this.configExt.getPath(attrConfig_1, true, true, true, false);
+ String _path_14 = this.configExt.toPath(_path_13, "/");
+ List<String> _value_3 = entry_2.getValue();
+ String _path_15 = this.configExt.toPath(_value_3, "/");
+ String _plus_10 = (_path_14 + _path_15);
+ String _plus_11 = (_plus_10 + "/");
+ Attribute _key_6 = entry_2.getKey();
+ String _name_19 = _key_6.getName();
+ String aPath_1 = (_plus_11 + _name_19);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("values.put(\"");
+ _builder.append(aPath_1, " ");
+ _builder.append("\", ");
+ {
+ if (array) {
+ _builder.append("toObjectArray(");
+ }
+ }
+ _builder.append(aiName_1, " ");
+ List<String> _value_4 = entry_2.getValue();
+ String _invoke_1 = this.toInvoke(_value_4);
+ _builder.append(_invoke_1, " ");
+ _builder.append(".");
+ Attribute _key_7 = entry_2.getKey();
+ String _name_20 = _key_7.getName();
+ CharSequence _invokeGetter_2 = this.helpers.invokeGetter(_name_20, null);
+ _builder.append(_invokeGetter_2, " ");
+ {
+ if (array) {
+ _builder.append(")");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return values;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public void writeDataClass(String id, Object dcObject, Map<String, Object> writeMap) {");
+ _builder.newLine();
+ {
+ HashSet<DataClass> _dynDataClasses = this.getDynDataClasses(comp);
+ for(final DataClass dc : _dynDataClasses) {
+ _builder.append("\t\t");
+ _builder.append("if(dcObject.getClass().equals(");
+ String _typeName_5 = this._typeHelpers.typeName(dc);
+ _builder.append(_typeName_5, " ");
+ _builder.append(".class))");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("writeDataClass(id, (");
+ String _typeName_6 = this._typeHelpers.typeName(dc);
+ _builder.append(_typeName_6, " ");
+ _builder.append(") dcObject, writeTasks);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// DataClasses write operations");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ HashSet<DataClass> _allDynDataClasses = this.getAllDynDataClasses(comp);
+ for(final DataClass dc_1 : _allDynDataClasses) {
+ _builder.append("\t");
+ _builder.append("private void writeDataClass(String id, ");
+ String _typeName_7 = this._typeHelpers.typeName(dc_1);
+ _builder.append(_typeName_7, " ");
+ _builder.append(" object, Map<String, Object> map){");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<Attribute> _attributes = dc_1.getAttributes();
+ for(final Attribute a_1 : _attributes) {
+ {
+ RefableType _refType_5 = a_1.getRefType();
+ DataType _type_5 = _refType_5.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type_5);
+ if (_isPrimitive) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("map.put(id+\"/");
+ String _name_21 = a_1.getName();
+ _builder.append(_name_21, " ");
+ _builder.append("\", ");
+ {
+ int _size_7 = a_1.getSize();
+ boolean _greaterThan_2 = (_size_7 > 0);
+ if (_greaterThan_2) {
+ _builder.append("toObjectArray(");
+ }
+ }
+ _builder.append("object.");
+ String _name_22 = a_1.getName();
+ CharSequence _invokeGetter_3 = this.helpers.invokeGetter(_name_22, null);
+ _builder.append(_invokeGetter_3, " ");
+ {
+ int _size_8 = a_1.getSize();
+ boolean _greaterThan_3 = (_size_8 > 0);
+ if (_greaterThan_3) {
+ _builder.append(")");
+ }
+ }
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("writeDataClass(id+\"/");
+ String _name_23 = a_1.getName();
+ _builder.append(_name_23, " ");
+ _builder.append("\", object.");
+ String _name_24 = a_1.getName();
+ CharSequence _invokeGetter_4 = this.helpers.invokeGetter(_name_24, null);
+ _builder.append(_invokeGetter_4, " ");
+ _builder.append(", map);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("@Override");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("protected int getPollingTimerUser(){");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("return ");
+ int _polling = dynConfig.getPolling();
+ _builder.append(_polling, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ private CharSequence genMinMaxCheck(final AttrInstanceConfig instConf, final ActorClassConfig acConf) {
+ CharSequence _xblockexpression = null;
+ {
+ List<String> _path = this.configExt.getPath(instConf, false, false, true, true);
+ AttrClassConfig config = acConf==null?(AttrClassConfig)null:this.resolve(acConf, ((String[])Conversions.unwrapArray(_path, String.class)));
+ boolean _and = false;
+ NumberLiteral _min = config==null?(NumberLiteral)null:config.getMin();
+ boolean _equals = Objects.equal(_min, null);
+ if (!_equals) {
+ _and = false;
+ } else {
+ NumberLiteral _max = config==null?(NumberLiteral)null:config.getMax();
+ boolean _equals_1 = Objects.equal(_max, null);
+ _and = (_equals && _equals_1);
+ }
+ if (_and) {
+ StringConcatenation _builder = new StringConcatenation();
+ return _builder;
+ }
+ List<String> _path_1 = this.configExt.getPath(config, false, false, true, true);
+ String path = this.configExt.toPath(_path_1, "_");
+ EObject _eContainer = config.eContainer();
+ ActorClass _actor = ((ActorClassConfig) _eContainer).getActor();
+ String acName = _actor.getName();
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("checkMinMax(_");
+ Attribute _attribute = config.getAttribute();
+ String _name = _attribute.getName();
+ _builder_1.append(_name, "");
+ _builder_1.append(", ");
+ {
+ NumberLiteral _min_1 = config.getMin();
+ boolean _notEquals = (!Objects.equal(_min_1, null));
+ if (_notEquals) {
+ _builder_1.append(acName, "");
+ _builder_1.append(".MIN");
+ _builder_1.append(path, "");
+ } else {
+ _builder_1.append("null");
+ }
+ }
+ _builder_1.append(", ");
+ {
+ NumberLiteral _max_1 = config.getMax();
+ boolean _notEquals_1 = (!Objects.equal(_max_1, null));
+ if (_notEquals_1) {
+ _builder_1.append(acName, "");
+ _builder_1.append(".MAX");
+ _builder_1.append(path, "");
+ } else {
+ _builder_1.append("null");
+ }
+ }
+ _builder_1.append(");");
+ _builder_1.newLineIfNotEmpty();
+ _xblockexpression = (_builder_1);
+ }
+ return _xblockexpression;
+ }
+
+ private Map<Attribute,List<String>> getAllAttributes(final AttrInstanceConfig config) {
+ HashMap<Attribute,List<String>> _hashMap = new HashMap<Attribute,List<String>>();
+ HashMap<Attribute,List<String>> map = _hashMap;
+ Attribute _attribute = config.getAttribute();
+ RefableType _refType = _attribute.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (_isPrimitive) {
+ Attribute _attribute_1 = config.getAttribute();
+ ArrayList<String> _arrayList = new ArrayList<String>();
+ map.put(_attribute_1, _arrayList);
+ } else {
+ Attribute _attribute_2 = config.getAttribute();
+ LinkedList<String> _linkedList = new LinkedList<String>();
+ this.getAllAttributes(_attribute_2, _linkedList, map);
+ }
+ return map;
+ }
+
+ private void getAllAttributes(final Attribute attribute, final List<String> path, final Map<Attribute,List<String>> map) {
+ RefableType _refType = attribute.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isPrimitive = this._typeHelpers.isPrimitive(_type);
+ if (_isPrimitive) {
+ map.put(attribute, path);
+ } else {
+ RefableType _refType_1 = attribute.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(_type_1);
+ if (_isDataClass) {
+ ArrayList<String> _arrayList = new ArrayList<String>(path);
+ ArrayList<String> new_path = _arrayList;
+ String _name = attribute.getName();
+ new_path.add(_name);
+ RefableType _refType_2 = attribute.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(((DataClass) _type_2));
+ for (final Attribute dc : _allAttributes) {
+ this.getAllAttributes(dc, new_path, map);
+ }
+ }
+ }
+ }
+
+ private String toInvoke(final List<String> path) {
+ StringBuilder _stringBuilder = new StringBuilder();
+ StringBuilder builder = _stringBuilder;
+ for (final String p : path) {
+ CharSequence _invokeGetter = this.helpers.invokeGetter(p, null);
+ String _plus = ("." + _invokeGetter);
+ builder.append(_plus);
+ }
+ return builder.toString();
+ }
+
+ private List<ActorInstance> dynConfigsAIs(final SubSystemInstance comp) {
+ HashSet<String> _hashSet = new HashSet<String>();
+ final HashSet<String> aiPaths = _hashSet;
+ SubSystemClass _subSystemClass = comp.getSubSystemClass();
+ Iterable<AttrInstanceConfig> _attrDynConfigs = this.configExt.getAttrDynConfigs(_subSystemClass, true, false);
+ for (final AttrInstanceConfig attrConfig : _attrDynConfigs) {
+ List<String> _path = this.configExt.getPath(attrConfig, true, true, false, false);
+ String _path_1 = this.configExt.toPath(_path, "/");
+ aiPaths.add(_path_1);
+ }
+ ArrayList<ActorInstance> _arrayList = new ArrayList<ActorInstance>();
+ ArrayList<ActorInstance> ais = _arrayList;
+ EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
+ for (final ActorInstance ai : _allContainedInstances) {
+ String _path_2 = ai.getPath();
+ boolean _contains = aiPaths.contains(_path_2);
+ if (_contains) {
+ ais.add(ai);
+ }
+ }
+ return ais;
+ }
+
+ private HashSet<DataClass> getDynDataClasses(final SubSystemInstance comp) {
+ HashSet<DataClass> _hashSet = new HashSet<DataClass>();
+ HashSet<DataClass> dcs = _hashSet;
+ SubSystemClass _subSystemClass = comp.getSubSystemClass();
+ Iterable<AttrInstanceConfig> _attrDynConfigs = this.configExt.getAttrDynConfigs(_subSystemClass, false, true);
+ for (final AttrInstanceConfig config : _attrDynConfigs) {
+ Attribute _attribute = config.getAttribute();
+ RefableType _refType = _attribute.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(_type);
+ if (_isDataClass) {
+ Attribute _attribute_1 = config.getAttribute();
+ RefableType _refType_1 = _attribute_1.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ dcs.add(((DataClass) _type_1));
+ }
+ }
+ return dcs;
+ }
+
+ private HashSet<DataClass> getAllDynDataClasses(final SubSystemInstance comp) {
+ HashSet<DataClass> _hashSet = new HashSet<DataClass>();
+ HashSet<DataClass> dcs = _hashSet;
+ LinkedList<DataClass> _linkedList = new LinkedList<DataClass>();
+ LinkedList<DataClass> stack = _linkedList;
+ HashSet<DataClass> _dynDataClasses = this.getDynDataClasses(comp);
+ stack.addAll(_dynDataClasses);
+ Iterables.<DataClass>addAll(dcs, stack);
+ boolean _isEmpty = stack.isEmpty();
+ boolean _not = (!_isEmpty);
+ boolean _while = _not;
+ while (_while) {
+ {
+ DataClass dc = stack.pop();
+ List<Attribute> _allAttributes = this.roomExt.getAllAttributes(dc);
+ for (final Attribute a : _allAttributes) {
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isDataClass = this._typeHelpers.isDataClass(_type);
+ if (_isDataClass) {
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ dcs.add(((DataClass) _type_1));
+ RefableType _refType_2 = a.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ stack.push(((DataClass) _type_2));
+ }
+ }
+ }
+ boolean _isEmpty_1 = stack.isEmpty();
+ boolean _not_1 = (!_isEmpty_1);
+ _while = _not_1;
+ }
+ return dcs;
+ }
+
+ private AttrClassConfig resolve(final ActorClassConfig config, final String[] path) {
+ EList<AttrClassConfig> _attributes = config.getAttributes();
+ final Function1<AttrClassConfig,Boolean> _function = new Function1<AttrClassConfig,Boolean>() {
+ public Boolean apply(final AttrClassConfig c) {
+ Attribute _attribute = c.getAttribute();
+ String _name = _attribute.getName();
+ String _head = IterableExtensions.<String>head(((Iterable<String>)Conversions.doWrapArray(path)));
+ boolean _equals = _name.equals(_head);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ AttrClassConfig result = IterableExtensions.<AttrClassConfig>findFirst(_attributes, _function);
+ Iterable<String> _tail = IterableExtensions.<String>tail(((Iterable<String>)Conversions.doWrapArray(path)));
+ for (final String ref : _tail) {
+ {
+ EList<AttrClassConfig> _attributes_1 = result==null?(EList<AttrClassConfig>)null:result.getAttributes();
+ final Function1<AttrClassConfig,Boolean> _function_1 = new Function1<AttrClassConfig,Boolean>() {
+ public Boolean apply(final AttrClassConfig c) {
+ Attribute _attribute = c.getAttribute();
+ String _name = _attribute.getName();
+ boolean _equals = _name.equals(ref);
+ return Boolean.valueOf(_equals);
+ }
+ };
+ AttrClassConfig _findFirst = IterableExtensions.<AttrClassConfig>findFirst(_attributes_1, _function_1);
+ result = _findFirst;
+ boolean _equals = Objects.equal(result, null);
+ if (_equals) {
+ return null;
+ }
+ }
+ }
+ return result;
+ }
+
+ private HashSet<RoomModel> getRoomModels(final List<ActorInstance> ais) {
+ HashSet<RoomModel> _hashSet = new HashSet<RoomModel>();
+ final HashSet<RoomModel> models = _hashSet;
+ final Procedure1<ActorInstance> _function = new Procedure1<ActorInstance>() {
+ public void apply(final ActorInstance ai) {
+ ActorClass _actorClass = ai.getActorClass();
+ EObject _eContainer = _actorClass.eContainer();
+ models.add(((RoomModel) _eContainer));
+ }
+ };
+ IterableExtensions.<ActorInstance>forEach(ais, _function);
+ return models;
+ }
+}

Back to the top