summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2012-12-12 13:39:49 (EST)
committer Juergen Haug2012-12-12 13:39:49 (EST)
commitc8fb83cda6ba0297d86272d914bf49e70bd4d2ed (patch)
treef90273398b3d05678c74a510494c78e6a72bff74
parent5d9b58598e7ca37940afb777337975f4afad4dbf (diff)
downloadorg.eclipse.etrice-c8fb83cda6ba0297d86272d914bf49e70bd4d2ed.zip
org.eclipse.etrice-c8fb83cda6ba0297d86272d914bf49e70bd4d2ed.tar.gz
org.eclipse.etrice-c8fb83cda6ba0297d86272d914bf49e70bd4d2ed.tar.bz2
[generator,doc] update gen.cpp and doc
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.xtend56
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java821
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java558
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/Initialization.java297
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java143
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.java930
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.java263
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java237
8 files changed, 3275 insertions, 30 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.xtend
index adcb471..25375c7 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.xtend
@@ -16,18 +16,17 @@ import com.google.inject.Inject
import java.util.ArrayList
import java.util.List
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance
+import org.eclipse.etrice.core.genmodel.etricegen.InstanceBase
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.GeneralProtocolClass
-import org.eclipse.etrice.core.room.InterfaceItem
+import org.eclipse.etrice.core.room.ExternalType
import org.eclipse.etrice.core.room.PrimitiveType
-import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.core.room.util.RoomHelpers
import org.eclipse.etrice.generator.base.IDataConfiguration
import org.eclipse.etrice.generator.generic.ProcedureHelpers
import org.eclipse.etrice.generator.generic.RoomExtensions
import org.eclipse.etrice.generator.generic.TypeHelpers
-import org.eclipse.etrice.core.room.ExternalType
class ConfigGenAddon {
@@ -40,40 +39,37 @@ class ConfigGenAddon {
// For SubSystemClassGen
def public genActorInstanceConfig(ActorInstance ai, String aiVariableName){'''
- «FOR a : ai.actorClass.attributes»
- «applyInstanceConfig(ai, null, aiVariableName, new ArrayList<Attribute>().union(a))»
+ «FOR a : ai.actorClass.allAttributes»
+ «applyInstanceConfig(ai, aiVariableName, new ArrayList<Attribute>().union(a))»
«ENDFOR»
- «FOR p : ai.actorClass.allEndPorts»
- «FOR a : getAttributes(p.protocol, !p.conjugated)»
- «applyInstanceConfig(ai, p, aiVariableName+"."+invokeGetter(p.name, null), new ArrayList<Attribute>().union(a))»
- «ENDFOR»
- «ENDFOR»
- «FOR sap : ai.actorClass.allSAPs»
- «FOR a : getAttributes(sap.protocol, true)»
- «applyInstanceConfig(ai, sap, aiVariableName+"."+invokeGetter(sap.name, null), new ArrayList<Attribute>().union(a))»
- «ENDFOR»
+ «FOR pi : ai.orderedIfItemInstances»
+ «var attribs = RoomHelpers::getPortClass(pi.interfaceItem)?.attributes»
+ «IF attribs != null»
+ «FOR a : attribs»
+ «applyInstanceConfig(pi, aiVariableName+"."+invokeGetter(pi.name, null), new ArrayList<Attribute>().union(a))»
+ «ENDFOR»
+ «ENDIF»
«ENDFOR»
'''
}
- def private List<Attribute> getAttributes(GeneralProtocolClass gpc, boolean regular){
- var result = new ArrayList<Attribute>
- if(gpc instanceof ProtocolClass){
- var protocol = gpc as ProtocolClass
- if(regular && protocol.regular?.attributes != null)
- result.addAll(protocol.regular.attributes)
- else if(!regular && protocol.conjugate?.attributes != null)
- result.addAll(protocol.conjugate.attributes)
- }
- return result
- }
+// def private List<Attribute> getAttributes(GeneralProtocolClass gpc, boolean regular){
+// var result = new ArrayList<Attribute>
+// if(gpc instanceof ProtocolClass){
+// var protocol = gpc as ProtocolClass
+// if(regular && protocol.regular?.attributes != null)
+// result.addAll(protocol.regular.attributes)
+// else if(!regular && protocol.conjugate?.attributes != null)
+// result.addAll(protocol.conjugate.attributes)
+// }
+// return result
+// }
- def private applyInstanceConfig(ActorInstance ai, InterfaceItem port, String invokes, List<Attribute> path){
+ def private applyInstanceConfig(InstanceBase instance, String invokes, List<Attribute> path){
var a = path.last
var aType = a.refType.type
if(aType.primitive){
- var value = if(port==null)dataConfigExt.getAttrInstanceConfigValue(ai, path)
- else dataConfigExt.getAttrInstanceConfigValue(ai, port, path)
+ var value = typeHelpers.getAttrInstanceConfigValue(path, instance)
if(value == null)
''''''
else if(a.size == 0 || aType.characterType)
@@ -90,7 +86,7 @@ class ConfigGenAddon {
}
else if (aType.dataClass)'''
«FOR e : (aType as DataClass).attributes»
- «applyInstanceConfig(ai, port, invokes+"."+a.name.invokeGetter(null), path.union(e))»
+ «applyInstanceConfig(instance, invokes+"."+a.name.invokeGetter(null), path.union(e))»
«ENDFOR»
'''
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java
new file mode 100644
index 0000000..65bf467
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java
@@ -0,0 +1,821 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.ActorCommunicationType;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.DataClass;
+import org.eclipse.etrice.core.room.DetailCode;
+import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.ProtocolClass;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SAPRef;
+import org.eclipse.etrice.core.room.SPPRef;
+import org.eclipse.etrice.core.room.ServiceImplementation;
+import org.eclipse.etrice.core.room.StandardOperation;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.generator.cpp.GeneratorOptions;
+import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
+import org.eclipse.etrice.generator.cpp.gen.Initialization;
+import org.eclipse.etrice.generator.cpp.gen.StateMachineGen;
+import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class ActorClassGen extends GenericActorClassGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CppExtensions _cppExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private Initialization _initialization;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private StateMachineGen _stateMachineGen;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
+ for (final ExpandedActorClass xpac : _xpActorClasses) {
+ {
+ ActorClass _actorClass = xpac.getActorClass();
+ String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(_actorClass);
+ ActorClass _actorClass_1 = xpac.getActorClass();
+ String _path = this._roomExtensions.getPath(_actorClass_1);
+ String path = (_generationTargetPath + _path);
+ ActorClass _actorClass_2 = xpac.getActorClass();
+ String _cppHeaderFileName = this._cppExtensions.getCppHeaderFileName(_actorClass_2);
+ String _plus = ("generating ActorClass header \'" + _cppHeaderFileName);
+ 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);
+ ActorClass _actorClass_3 = xpac.getActorClass();
+ String _cppHeaderFileName_1 = this._cppExtensions.getCppHeaderFileName(_actorClass_3);
+ ActorClass _actorClass_4 = xpac.getActorClass();
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, xpac, _actorClass_4);
+ this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
+ ActorClass _actorClass_5 = xpac.getActorClass();
+ String _cppSourceFileName = this._cppExtensions.getCppSourceFileName(_actorClass_5);
+ String _plus_4 = ("generating ActorClass source \'" + _cppSourceFileName);
+ String _plus_5 = (_plus_4 + "\' in \'");
+ String _plus_6 = (_plus_5 + path);
+ String _plus_7 = (_plus_6 + "\'");
+ this.logger.logInfo(_plus_7);
+ this.fileAccess.setOutputPath(path);
+ ActorClass _actorClass_6 = xpac.getActorClass();
+ String _cppSourceFileName_1 = this._cppExtensions.getCppSourceFileName(_actorClass_6);
+ ActorClass _actorClass_7 = xpac.getActorClass();
+ CharSequence _generateSourceFile = this.generateSourceFile(root, xpac, _actorClass_7);
+ this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
+ }
+ }
+ }
+
+ private CharSequence generateHeaderFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ EList<StandardOperation> _operations = ac.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isConstructor = RoomHelpers.isConstructor(op);
+ return Boolean.valueOf(_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
+ EList<StandardOperation> _operations_1 = ac.getOperations();
+ final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isDestructor = op.isDestructor();
+ return Boolean.valueOf(_isDestructor);
+ }
+ };
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
+ final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* Header File of ActorClass ");
+ String _name = ac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_1 = ac.getName();
+ CharSequence _generateIncludeGuardBegin = this._cppExtensions.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"platforms/generic/etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/messaging/IRTObject.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/modelbase/PortBase.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/modelbase/InterfaceItemBase.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/modelbase/ActorClassBase.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/modelbase/SubSystemClassBase.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/messaging/Address.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/messaging/IMessageReceiver.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/debugging/DebuggingService.h\"");
+ _builder.newLine();
+ {
+ boolean _isUseEtUnit = GeneratorOptions.isUseEtUnit();
+ if (_isUseEtUnit) {
+ _builder.append("\t");
+ _builder.append("extern \"C\" {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("#include \"etUnit.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("#include <string>");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include <vector>");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ EList<RoomModel> _referencedModels = root.getReferencedModels(ac);
+ for(final RoomModel model : _referencedModels) {
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
+ for(final ProtocolClass pc : _referencedProtocolClasses) {
+ _builder.append("\t");
+ _builder.append("#include \"");
+ String _path = this._roomExtensions.getPath(pc);
+ _builder.append(_path, " ");
+ String _name_2 = pc.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
+ for(final DataClass dc : _referencedDataClasses) {
+ _builder.append("\t");
+ _builder.append("#include \"");
+ String _path_1 = this._roomExtensions.getPath(dc);
+ _builder.append(_path_1, " ");
+ String _name_3 = dc.getName();
+ _builder.append(_name_3, " ");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _userCode = this._procedureHelpers.userCode(ac, 1);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("class ");
+ String _name_4 = ac.getName();
+ _builder.append(_name_4, " ");
+ _builder.append(" : public ");
+ {
+ ActorClass _base = ac.getBase();
+ boolean _notEquals = (!Objects.equal(_base, null));
+ if (_notEquals) {
+ ActorClass _base_1 = ac.getBase();
+ String _name_5 = _base_1.getName();
+ _builder.append(_name_5, " ");
+ } else {
+ _builder.append("etRuntime::ActorClassBase");
+ }
+ }
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("protected:");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("//--------------------- ports");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ List<Port> _endPorts = this._roomExtensions.getEndPorts(ac);
+ final Function1<Port,CharSequence> _function_2 = new Function1<Port,CharSequence>() {
+ public CharSequence apply(final Port port) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _portClassName = ActorClassGen.this._roomExtensions.getPortClassName(port);
+ _builder.append(_portClassName, "");
+ _builder.append(" ");
+ String _name = port.getName();
+ _builder.append(_name, "");
+ _builder.append(";");
+ return _builder;
+ }
+ };
+ List<CharSequence> _map = ListExtensions.<Port, CharSequence>map(_endPorts, _function_2);
+ String _join = IterableExtensions.join(_map, "\n");
+ _builder.append(_join, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("//--------------------- saps");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ EList<SAPRef> _strSAPs = ac.getStrSAPs();
+ final Function1<SAPRef,CharSequence> _function_3 = new Function1<SAPRef,CharSequence>() {
+ public CharSequence apply(final SAPRef sap) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _portClassName = ActorClassGen.this._roomExtensions.getPortClassName(sap);
+ _builder.append(_portClassName, "");
+ _builder.append(" ");
+ String _name = sap.getName();
+ _builder.append(_name, "");
+ _builder.append(";");
+ return _builder;
+ }
+ };
+ List<CharSequence> _map_1 = ListExtensions.<SAPRef, CharSequence>map(_strSAPs, _function_3);
+ String _join_1 = IterableExtensions.join(_map_1, "\n");
+ _builder.append(_join_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("//--------------------- services");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
+ final Function1<ServiceImplementation,CharSequence> _function_4 = new Function1<ServiceImplementation,CharSequence>() {
+ public CharSequence apply(final ServiceImplementation svc) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _portClassName = ActorClassGen.this._roomExtensions.getPortClassName(svc);
+ _builder.append(_portClassName, "");
+ _builder.append(" ");
+ SPPRef _spp = svc.getSpp();
+ String _name = _spp.getName();
+ _builder.append(_name, "");
+ _builder.append(";");
+ return _builder;
+ }
+ };
+ List<CharSequence> _map_2 = ListExtensions.<ServiceImplementation, CharSequence>map(_serviceImplementations, _function_4);
+ String _join_2 = IterableExtensions.join(_map_2, "\n");
+ _builder.append(_join_2, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("//--------------------- interface item IDs");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac, ac);
+ _builder.append(_genInterfaceItemConstants, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ EList<Attribute> _attributes = ac.getAttributes();
+ CharSequence _attributes_1 = this._procedureHelpers.attributes(_attributes);
+ _builder.append(_attributes_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(ac);
+ _builder.append(_operationsImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("//--------------------- construction");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ String _name_6 = ac.getName();
+ _builder.append(_name_6, " ");
+ _builder.append("(etRuntime::IRTObject* parent, std::string name, const std::vector<std::vector<etRuntime::Address> >& port_addr, ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ");
+ _builder.append("const std::vector<std::vector<etRuntime::Address> >& peer_addr);");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("//--------------------- port getters");
+ _builder.newLine();
+ {
+ List<Port> _endPorts_1 = this._roomExtensions.getEndPorts(ac);
+ for(final Port ep : _endPorts_1) {
+ _builder.append("\t\t");
+ String _portClassName = this._roomExtensions.getPortClassName(ep);
+ String _name_7 = ep.getName();
+ String _name_8 = ac.getName();
+ CharSequence _terImplementation = this._procedureHelpers.getterImplementation(_portClassName, _name_7, _name_8);
+ _builder.append(_terImplementation, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<SAPRef> _strSAPs_1 = ac.getStrSAPs();
+ for(final SAPRef sap : _strSAPs_1) {
+ _builder.append("\t\t");
+ String _portClassName_1 = this._roomExtensions.getPortClassName(sap);
+ String _name_9 = sap.getName();
+ String _name_10 = ac.getName();
+ CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(_portClassName_1, _name_9, _name_10);
+ _builder.append(_terImplementation_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
+ for(final ServiceImplementation svc : _serviceImplementations_1) {
+ _builder.append("\t\t");
+ String _portClassName_2 = this._roomExtensions.getPortClassName(svc);
+ SPPRef _spp = svc.getSpp();
+ String _name_11 = _spp.getName();
+ String _name_12 = ac.getName();
+ CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(_portClassName_2, _name_11, _name_12);
+ _builder.append(_terImplementation_2, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("//--------------------- lifecycle functions");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("virtual void init();");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("virtual void start();");
+ _builder.newLine();
+ {
+ boolean _overridesStop = this._roomExtensions.overridesStop(ac);
+ boolean _not = (!_overridesStop);
+ if (_not) {
+ _builder.append("\t\t");
+ _builder.append("virtual void stop();");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t\t\t");
+ _builder.append("virtual void destroy();\t\t\t");
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine = RoomHelpers.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine) {
+ _builder.append("\t\t");
+ CharSequence _genStateMachineMethodDeclarations = this._stateMachineGen.genStateMachineMethodDeclarations(xpac);
+ _builder.append(_genStateMachineMethodDeclarations, " ");
+ _builder.newLineIfNotEmpty();
+ } else {
+ boolean _hasStateMachine = xpac.hasStateMachine();
+ boolean _not_1 = (!_hasStateMachine);
+ if (_not_1) {
+ _builder.append("\t\t");
+ _builder.append("public: ");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("//--------------------- no state machine");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("virtual void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("\t");
+ _builder.append("virtual void executeInitTransition();");
+ _builder.newLine();
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t\t");
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("};");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_13 = ac.getName();
+ CharSequence _generateIncludeGuardEnd = this._cppExtensions.generateIncludeGuardEnd(_name_13);
+ _builder.append(_generateIncludeGuardEnd, " ");
+ _builder.newLineIfNotEmpty();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ private CharSequence generateConstructorInitalizerList(final ActorClass ac) {
+ ArrayList<CharSequence> _arrayList = new ArrayList<CharSequence>();
+ ArrayList<CharSequence> initializerList = _arrayList;
+ ActorClass _base = ac.getBase();
+ boolean _equals = Objects.equal(_base, null);
+ if (_equals) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("ActorClassBase( parent, name, port_addr[0][0], peer_addr[0][0])");
+ initializerList.add(_builder);
+ } else {
+ StringConcatenation _builder_1 = new StringConcatenation();
+ ActorClass _base_1 = ac.getBase();
+ String _name = _base_1.getName();
+ _builder_1.append(_name, "");
+ _builder_1.append("(*this, parent, name, port_addr, peer_addr)");
+ initializerList.add(_builder_1);
+ }
+ List<Port> _endPorts = this._roomExtensions.getEndPorts(ac);
+ for (final Port ep : _endPorts) {
+ StringConcatenation _builder_2 = new StringConcatenation();
+ String _name_1 = ep.getName();
+ _builder_2.append(_name_1, "");
+ _builder_2.append("(*this, this, \"");
+ String _name_2 = ep.getName();
+ _builder_2.append(_name_2, "");
+ _builder_2.append("\", IFITEM_");
+ String _name_3 = ep.getName();
+ _builder_2.append(_name_3, "");
+ _builder_2.append(", ");
+ {
+ int _multiplicity = ep.getMultiplicity();
+ boolean _equals_1 = (_multiplicity == 1);
+ if (_equals_1) {
+ _builder_2.append("0, ");
+ }
+ }
+ _builder_2.append("port_addr[IFITEM_");
+ String _name_4 = ep.getName();
+ _builder_2.append(_name_4, "");
+ _builder_2.append("]");
+ {
+ int _multiplicity_1 = ep.getMultiplicity();
+ boolean _equals_2 = (_multiplicity_1 == 1);
+ if (_equals_2) {
+ _builder_2.append("[0]");
+ }
+ }
+ _builder_2.append(", peer_addr[IFITEM_");
+ String _name_5 = ep.getName();
+ _builder_2.append(_name_5, "");
+ _builder_2.append("]");
+ {
+ int _multiplicity_2 = ep.getMultiplicity();
+ boolean _equals_3 = (_multiplicity_2 == 1);
+ if (_equals_3) {
+ _builder_2.append("[0]");
+ }
+ }
+ _builder_2.append(")");
+ initializerList.add(_builder_2);
+ }
+ EList<SAPRef> _strSAPs = ac.getStrSAPs();
+ for (final SAPRef sap : _strSAPs) {
+ StringConcatenation _builder_3 = new StringConcatenation();
+ String _name_6 = sap.getName();
+ _builder_3.append(_name_6, "");
+ _builder_3.append("(*this, this, \"");
+ String _name_7 = sap.getName();
+ _builder_3.append(_name_7, "");
+ _builder_3.append("\", IFITEM_");
+ String _name_8 = sap.getName();
+ _builder_3.append(_name_8, "");
+ _builder_3.append(", 0, port_addr[IFITEM_");
+ String _name_9 = sap.getName();
+ _builder_3.append(_name_9, "");
+ _builder_3.append("][0], peer_addr[IFITEM_");
+ String _name_10 = sap.getName();
+ _builder_3.append(_name_10, "");
+ _builder_3.append("][0])");
+ initializerList.add(_builder_3);
+ }
+ EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
+ for (final ServiceImplementation svc : _serviceImplementations) {
+ StringConcatenation _builder_4 = new StringConcatenation();
+ SPPRef _spp = svc.getSpp();
+ String _name_11 = _spp.getName();
+ _builder_4.append(_name_11, "");
+ _builder_4.append("(*this, this, \"");
+ SPPRef _spp_1 = svc.getSpp();
+ String _name_12 = _spp_1.getName();
+ _builder_4.append(_name_12, "");
+ _builder_4.append("\", IFITEM_");
+ SPPRef _spp_2 = svc.getSpp();
+ String _name_13 = _spp_2.getName();
+ _builder_4.append(_name_13, "");
+ _builder_4.append(", port_addr[IFITEM_");
+ SPPRef _spp_3 = svc.getSpp();
+ String _name_14 = _spp_3.getName();
+ _builder_4.append(_name_14, "");
+ _builder_4.append("], peer_addr[IFITEM_");
+ SPPRef _spp_4 = svc.getSpp();
+ String _name_15 = _spp_4.getName();
+ _builder_4.append(_name_15, "");
+ _builder_4.append("])");
+ initializerList.add(_builder_4);
+ }
+ EList<Attribute> _attributes = ac.getAttributes();
+ for (final Attribute attrib : _attributes) {
+ CharSequence _attributeInitialization = this._initialization.attributeInitialization(attrib, false);
+ initializerList.add(_attributeInitialization);
+ }
+ StringConcatenation _builder_5 = new StringConcatenation();
+ String _join = IterableExtensions.join(initializerList, ",\n");
+ _builder_5.append(_join, "");
+ _builder_5.newLineIfNotEmpty();
+ return _builder_5;
+ }
+
+ private CharSequence generateSourceFile(final Root root, final ExpandedActorClass xpac, final ActorClass ac) {
+ CharSequence _xblockexpression = null;
+ {
+ EList<StandardOperation> _operations = ac.getOperations();
+ final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isConstructor = RoomHelpers.isConstructor(op);
+ return Boolean.valueOf(_isConstructor);
+ }
+ };
+ Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
+ final StandardOperation ctor = IterableExtensions.<StandardOperation>head(_filter);
+ EList<StandardOperation> _operations_1 = ac.getOperations();
+ final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
+ public Boolean apply(final StandardOperation op) {
+ boolean _isDestructor = op.isDestructor();
+ return Boolean.valueOf(_isDestructor);
+ }
+ };
+ Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
+ final StandardOperation dtor = IterableExtensions.<StandardOperation>head(_filter_1);
+ ActorClass _actorClass = xpac.getActorClass();
+ ActorCommunicationType _commType = _actorClass.getCommType();
+ final boolean async = Objects.equal(_commType, ActorCommunicationType.ASYNCHRONOUS);
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Source File of ActorClass ");
+ String _name = ac.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _cppHeaderFileName = this._cppExtensions.getCppHeaderFileName(ac);
+ _builder.append(_cppHeaderFileName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#include \"common/debugging/DebuggingService.h\"");
+ _builder.newLine();
+ _builder.append("#include <iostream>");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("using namespace etRuntime;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ String _name_1 = ac.getName();
+ _builder.append(_name_1, "");
+ _builder.append("::");
+ String _name_2 = ac.getName();
+ _builder.append(_name_2, "");
+ _builder.append("(etRuntime::IRTObject* parent, std::string name, const std::vector<std::vector<etRuntime::Address> >& port_addr, ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" \t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t ");
+ _builder.append("const std::vector<std::vector<etRuntime::Address> >& peer_addr)");
+ _builder.newLine();
+ _builder.append(": ");
+ CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(ac);
+ _builder.append(_generateConstructorInitalizerList, "");
+ _builder.newLineIfNotEmpty();
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("setClassName(\"");
+ String _name_3 = ac.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ EList<Attribute> _attributes = ac.getAttributes();
+ CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes, false);
+ _builder.append(_attributeInitialization, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ {
+ if (async) {
+ _builder.append("\t");
+ _builder.append("getMsgsvc()->addAsyncActor(*this);");
+ _builder.newLine();
+ }
+ }
+ {
+ boolean _notEquals = (!Objects.equal(ctor, null));
+ if (_notEquals) {
+ _builder.append("\t");
+ _builder.append("// user defined constructor body");
+ _builder.newLine();
+ _builder.append("\t");
+ AbstractGenerator _instance = AbstractGenerator.getInstance();
+ DetailCode _detailCode = ctor.getDetailCode();
+ String _translatedCode = _instance.getTranslatedCode(_detailCode);
+ _builder.append(_translatedCode, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_4 = ac.getName();
+ _builder.append(_name_4, "");
+ _builder.append("::init(){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("initUser();");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_5 = ac.getName();
+ _builder.append(_name_5, "");
+ _builder.append("::start(){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("startUser();");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ boolean _overridesStop = this._roomExtensions.overridesStop(ac);
+ boolean _not = (!_overridesStop);
+ if (_not) {
+ _builder.append("void ");
+ String _name_6 = ac.getName();
+ _builder.append(_name_6, "");
+ _builder.append("::stop(){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("stopUser();");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_7 = ac.getName();
+ _builder.append(_name_7, "");
+ _builder.append("::destroy(){");
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals_1 = (!Objects.equal(dtor, null));
+ if (_notEquals_1) {
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("// user defined destructor body");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ AbstractGenerator _instance_1 = AbstractGenerator.getInstance();
+ DetailCode _detailCode_1 = dtor.getDetailCode();
+ String _translatedCode_1 = _instance_1.getTranslatedCode(_detailCode_1);
+ _builder.append(_translatedCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ {
+ boolean _hasNonEmptyStateMachine = RoomHelpers.hasNonEmptyStateMachine(ac);
+ if (_hasNonEmptyStateMachine) {
+ CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac, false);
+ _builder.append(_genStateMachine, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ boolean _hasStateMachine = xpac.hasStateMachine();
+ boolean _not_1 = (!_hasStateMachine);
+ if (_not_1) {
+ _builder.append("//--------------------- no state machine");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_8 = ac.getName();
+ _builder.append(_name_8, "");
+ _builder.append("::receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("handleSystemEvent(ifitem, evt, data);");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_9 = ac.getName();
+ _builder.append(_name_9, "");
+ _builder.append("::executeInitTransition(){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java
new file mode 100644
index 0000000..25db9c5
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java
@@ -0,0 +1,558 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.InstanceBase;
+import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
+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.ExternalType;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.PortClass;
+import org.eclipse.etrice.core.room.PrimitiveType;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.core.room.util.RoomHelpers;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
+import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.xbase.lib.Conversions;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.StringExtensions;
+
+@SuppressWarnings("all")
+public class ConfigGenAddon {
+ @Inject
+ private CppExtensions stdExt;
+
+ @Inject
+ private TypeHelpers typeHelpers;
+
+ @Inject
+ private ProcedureHelpers helpers;
+
+ @Inject
+ private IDataConfiguration dataConfigExt;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ public CharSequence genActorInstanceConfig(final ActorInstance ai, final String aiVariableName) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ ActorClass _actorClass = ai.getActorClass();
+ List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(_actorClass);
+ for(final Attribute a : _allAttributes) {
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
+ CharSequence _applyInstanceConfig = this.applyInstanceConfig(ai, aiVariableName, _union);
+ _builder.append(_applyInstanceConfig, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
+ for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
+ InterfaceItem _interfaceItem = pi.getInterfaceItem();
+ PortClass _portClass = RoomHelpers.getPortClass(_interfaceItem);
+ EList<Attribute> attribs = _portClass==null?(EList<Attribute>)null:_portClass.getAttributes();
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(attribs, null));
+ if (_notEquals) {
+ {
+ for(final Attribute a_1 : attribs) {
+ String _plus = (aiVariableName + ".");
+ String _name = pi.getName();
+ CharSequence _invokeGetter = this.helpers.invokeGetter(_name, null);
+ String _plus_1 = (_plus + _invokeGetter);
+ ArrayList<Attribute> _arrayList_1 = new ArrayList<Attribute>();
+ List<Attribute> _union_1 = this._roomExtensions.<Attribute>union(_arrayList_1, a_1);
+ CharSequence _applyInstanceConfig_1 = this.applyInstanceConfig(pi, _plus_1, _union_1);
+ _builder.append(_applyInstanceConfig_1, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ private CharSequence applyInstanceConfig(final InstanceBase instance, final String invokes, final List<Attribute> path) {
+ CharSequence _xblockexpression = null;
+ {
+ Attribute a = IterableExtensions.<Attribute>last(path);
+ RefableType _refType = a.getRefType();
+ DataType aType = _refType.getType();
+ CharSequence _xifexpression = null;
+ boolean _isPrimitive = this.typeHelpers.isPrimitive(aType);
+ if (_isPrimitive) {
+ CharSequence _xblockexpression_1 = null;
+ {
+ String value = this.typeHelpers.getAttrInstanceConfigValue(path, instance);
+ CharSequence _xifexpression_1 = null;
+ boolean _equals = Objects.equal(value, null);
+ if (_equals) {
+ StringConcatenation _builder = new StringConcatenation();
+ _xifexpression_1 = _builder;
+ } else {
+ CharSequence _xifexpression_2 = null;
+ boolean _or = false;
+ int _size = a.getSize();
+ boolean _equals_1 = (_size == 0);
+ if (_equals_1) {
+ _or = true;
+ } else {
+ boolean _isCharacterType = this.typeHelpers.isCharacterType(aType);
+ _or = (_equals_1 || _isCharacterType);
+ }
+ if (_or) {
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append(invokes, "");
+ _builder_1.append(".");
+ String _name = a.getName();
+ String _valueLiteral = this.stdExt.toValueLiteral(((PrimitiveType) aType), value);
+ CharSequence _invokeSetter = this.helpers.invokeSetter(_name, null, _valueLiteral);
+ _builder_1.append(_invokeSetter, "");
+ _builder_1.append(";");
+ _xifexpression_2 = _builder_1;
+ } else {
+ CharSequence _xifexpression_3 = null;
+ int _size_1 = a.getSize();
+ String[] _split = value.split(",");
+ int _size_2 = ((List<String>)Conversions.doWrapArray(_split)).size();
+ boolean _equals_2 = (_size_1 == _size_2);
+ if (_equals_2) {
+ CharSequence _xblockexpression_2 = null;
+ {
+ StringConcatenation _builder_2 = new StringConcatenation();
+ _builder_2.append("{ ");
+ {
+ String[] _split_1 = value.split(",");
+ boolean _hasElements = false;
+ for(final String s : _split_1) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder_2.appendImmediate(", ", "");
+ }
+ String _trim = s.trim();
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), _trim);
+ _builder_2.append(_valueLiteral_1, "");
+ }
+ }
+ _builder_2.append(" }");
+ CharSequence arrayExpr = _builder_2;
+ StringConcatenation _builder_3 = new StringConcatenation();
+ _builder_3.append(invokes, "");
+ _builder_3.append(".");
+ String _name_1 = a.getName();
+ StringConcatenation _builder_4 = new StringConcatenation();
+ _builder_4.append("new ");
+ String _typeName = this.typeHelpers.typeName(aType);
+ _builder_4.append(_typeName, "");
+ _builder_4.append("[] ");
+ _builder_4.append(arrayExpr, "");
+ String _string = _builder_4.toString();
+ CharSequence _invokeSetter_1 = this.helpers.invokeSetter(_name_1, null, _string);
+ _builder_3.append(_invokeSetter_1, "");
+ _builder_3.append(";");
+ _xblockexpression_2 = (_builder_3);
+ }
+ _xifexpression_3 = _xblockexpression_2;
+ } else {
+ StringConcatenation _builder_2 = new StringConcatenation();
+ _builder_2.append("{");
+ _builder_2.newLine();
+ _builder_2.append("\t");
+ String _typeName = this.typeHelpers.typeName(aType);
+ _builder_2.append(_typeName, " ");
+ _builder_2.append("[] array = ");
+ _builder_2.append(invokes, " ");
+ _builder_2.append(".");
+ String _name_1 = a.getName();
+ CharSequence _invokeGetter = this.helpers.invokeGetter(_name_1, null);
+ _builder_2.append(_invokeGetter, " ");
+ _builder_2.append(";");
+ _builder_2.newLineIfNotEmpty();
+ _builder_2.append("\t");
+ _builder_2.append("for (int i=0;i<");
+ int _size_3 = a.getSize();
+ _builder_2.append(_size_3, " ");
+ _builder_2.append(";i++){");
+ _builder_2.newLineIfNotEmpty();
+ _builder_2.append("\t\t");
+ _builder_2.append("array[i] = ");
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(((PrimitiveType) aType), value);
+ _builder_2.append(_valueLiteral_1, " ");
+ _builder_2.append(";");
+ _builder_2.newLineIfNotEmpty();
+ _builder_2.append("}");
+ _xifexpression_3 = _builder_2;
+ }
+ _xifexpression_2 = _xifexpression_3;
+ }
+ _xifexpression_1 = _xifexpression_2;
+ }
+ _xblockexpression_1 = (_xifexpression_1);
+ }
+ _xifexpression = _xblockexpression_1;
+ } else {
+ CharSequence _xifexpression_1 = null;
+ boolean _isDataClass = this.typeHelpers.isDataClass(aType);
+ if (_isDataClass) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<Attribute> _attributes = ((DataClass) aType).getAttributes();
+ for(final Attribute e : _attributes) {
+ String _plus = (invokes + ".");
+ String _name = a.getName();
+ CharSequence _invokeGetter = this.helpers.invokeGetter(_name, null);
+ String _plus_1 = (_plus + _invokeGetter);
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
+ CharSequence _applyInstanceConfig = this.applyInstanceConfig(instance, _plus_1, _union);
+ _builder.append(_applyInstanceConfig, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xifexpression_1 = _builder;
+ }
+ _xifexpression = _xifexpression_1;
+ }
+ _xblockexpression = (_xifexpression);
+ }
+ return _xblockexpression;
+ }
+
+ public CharSequence genDynConfigGetterSetter(final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ List<Attribute> _dynConfigReadAttributes = this.dataConfigExt.getDynConfigReadAttributes(ac);
+ for(final Attribute a : _dynConfigReadAttributes) {
+ _builder.append("public ");
+ RefableType _refType = a.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this.typeHelpers.typeName(_type);
+ _builder.append(_typeName, "");
+ {
+ int _size = a.getSize();
+ boolean _greaterThan = (_size > 0);
+ if (_greaterThan) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" get");
+ String _name = a.getName();
+ String _firstUpper = StringExtensions.toFirstUpper(_name);
+ _builder.append(_firstUpper, "");
+ _builder.append("(){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if(lock_");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" == null)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("return ");
+ String _name_2 = a.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("else");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("synchronized(lock_");
+ String _name_3 = a.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("return ");
+ String _name_4 = a.getName();
+ _builder.append(_name_4, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("public void set");
+ String _name_5 = a.getName();
+ String _firstUpper_1 = StringExtensions.toFirstUpper(_name_5);
+ _builder.append(_firstUpper_1, "");
+ _builder.append("(");
+ RefableType _refType_1 = a.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ String _typeName_1 = this.typeHelpers.typeName(_type_1);
+ _builder.append(_typeName_1, "");
+ {
+ int _size_1 = a.getSize();
+ boolean _greaterThan_1 = (_size_1 > 0);
+ if (_greaterThan_1) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name_6 = a.getName();
+ _builder.append(_name_6, "");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("if(lock_");
+ String _name_7 = a.getName();
+ _builder.append(_name_7, " ");
+ _builder.append(" == null)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("this.");
+ String _name_8 = a.getName();
+ _builder.append(_name_8, " ");
+ _builder.append(" = ");
+ String _name_9 = a.getName();
+ _builder.append(_name_9, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("else");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("synchronized(lock_");
+ String _name_10 = a.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t");
+ _builder.append("this.");
+ String _name_11 = a.getName();
+ _builder.append(_name_11, " ");
+ _builder.append(" = ");
+ String _name_12 = a.getName();
+ _builder.append(_name_12, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("public DynConfigLock get");
+ String _name_13 = a.getName();
+ String _firstUpper_2 = StringExtensions.toFirstUpper(_name_13);
+ _builder.append(_firstUpper_2, "");
+ _builder.append("Lock(){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return lock_");
+ String _name_14 = a.getName();
+ _builder.append(_name_14, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}\t");
+ _builder.newLine();
+ }
+ }
+ {
+ List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(ac);
+ for(final Attribute a_1 : _dynConfigWriteAttributes) {
+ _builder.append("public void setAndWrite");
+ String _name_15 = a_1.getName();
+ String _firstUpper_3 = StringExtensions.toFirstUpper(_name_15);
+ _builder.append(_firstUpper_3, "");
+ _builder.append("(");
+ RefableType _refType_2 = a_1.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ String _typeName_2 = this.typeHelpers.typeName(_type_2);
+ _builder.append(_typeName_2, "");
+ {
+ int _size_2 = a_1.getSize();
+ boolean _greaterThan_2 = (_size_2 > 0);
+ if (_greaterThan_2) {
+ _builder.append("[]");
+ }
+ }
+ _builder.append(" ");
+ String _name_16 = a_1.getName();
+ _builder.append(_name_16, "");
+ _builder.append("){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("set");
+ String _name_17 = a_1.getName();
+ String _firstUpper_4 = StringExtensions.toFirstUpper(_name_17);
+ _builder.append(_firstUpper_4, " ");
+ _builder.append("(");
+ String _name_18 = a_1.getName();
+ _builder.append(_name_18, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("variableService.write(this.getInstancePath()+\"/");
+ String _name_19 = a_1.getName();
+ _builder.append(_name_19, " ");
+ _builder.append("\", ");
+ String _name_20 = a_1.getName();
+ _builder.append(_name_20, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence genMinMaxConstants(final ActorClass ac) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<Attribute> _attributes = ac.getAttributes();
+ for(final Attribute a : _attributes) {
+ String _name = a.getName();
+ ArrayList<Attribute> _arrayList = new ArrayList<Attribute>();
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(_arrayList, a);
+ CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _name, _union);
+ _builder.append(_genMinMaxConstantsRec, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ CharSequence result = _builder;
+ int _length = result.length();
+ boolean _notEquals = (_length != 0);
+ if (_notEquals) {
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("//--------------------- Attribute Specifications");
+ String _plus = (result + _builder_1.toString());
+ result = _plus;
+ }
+ return result;
+ }
+
+ private CharSequence genMinMaxConstantsRec(final ActorClass ac, final String varNamePath, final List<Attribute> path) {
+ CharSequence _xblockexpression = null;
+ {
+ String temp = ((String) null);
+ CharSequence _xifexpression = null;
+ Attribute _last = IterableExtensions.<Attribute>last(path);
+ RefableType _refType = _last.getRefType();
+ DataType _type = _refType.getType();
+ boolean _isDataClass = this.typeHelpers.isDataClass(_type);
+ if (_isDataClass) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ Attribute _last_1 = IterableExtensions.<Attribute>last(path);
+ RefableType _refType_1 = _last_1.getRefType();
+ DataType _type_1 = _refType_1.getType();
+ List<Attribute> _allAttributes = this._roomExtensions.getAllAttributes(((DataClass) _type_1));
+ for(final Attribute e : _allAttributes) {
+ String _plus = (varNamePath + "_");
+ String _name = e.getName();
+ String _plus_1 = (_plus + _name);
+ List<Attribute> _union = this._roomExtensions.<Attribute>union(path, e);
+ CharSequence _genMinMaxConstantsRec = this.genMinMaxConstantsRec(ac, _plus_1, _union);
+ _builder.append(_genMinMaxConstantsRec, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xifexpression = _builder;
+ } else {
+ CharSequence _xifexpression_1 = null;
+ Attribute _last_2 = IterableExtensions.<Attribute>last(path);
+ RefableType _refType_2 = _last_2.getRefType();
+ DataType _type_2 = _refType_2.getType();
+ if ((_type_2 instanceof ExternalType)) {
+ _xifexpression_1 = null;
+ } else {
+ CharSequence _xblockexpression_1 = null;
+ {
+ Attribute _last_3 = IterableExtensions.<Attribute>last(path);
+ RefableType _refType_3 = _last_3.getRefType();
+ DataType _type_3 = _refType_3.getType();
+ PrimitiveType aType = ((PrimitiveType) _type_3);
+ StringConcatenation _builder_1 = new StringConcatenation();
+ {
+ String _attrClassConfigMinValue = this.dataConfigExt.getAttrClassConfigMinValue(ac, path);
+ String _temp = temp = _attrClassConfigMinValue;
+ boolean _notEquals = (!Objects.equal(_temp, null));
+ if (_notEquals) {
+ _builder_1.append("public static ");
+ String _minMaxType = this.getMinMaxType(aType);
+ _builder_1.append(_minMaxType, "");
+ _builder_1.append(" MIN_");
+ _builder_1.append(varNamePath, "");
+ _builder_1.append(" = ");
+ String _valueLiteral = this.stdExt.toValueLiteral(aType, temp);
+ _builder_1.append(_valueLiteral, "");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
+ }
+ }
+ {
+ String _attrClassConfigMaxValue = this.dataConfigExt.getAttrClassConfigMaxValue(ac, path);
+ String _temp_1 = temp = _attrClassConfigMaxValue;
+ boolean _notEquals_1 = (!Objects.equal(_temp_1, null));
+ if (_notEquals_1) {
+ _builder_1.append("public static ");
+ String _minMaxType_1 = this.getMinMaxType(aType);
+ _builder_1.append(_minMaxType_1, "");
+ _builder_1.append(" MAX_");
+ _builder_1.append(varNamePath, "");
+ _builder_1.append(" = ");
+ String _valueLiteral_1 = this.stdExt.toValueLiteral(aType, temp);
+ _builder_1.append(_valueLiteral_1, "");
+ _builder_1.append(";");
+ _builder_1.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression_1 = (_builder_1);
+ }
+ _xifexpression_1 = _xblockexpression_1;
+ }
+ _xifexpression = _xifexpression_1;
+ }
+ _xblockexpression = (_xifexpression);
+ }
+ return _xblockexpression;
+ }
+
+ private String getMinMaxType(final PrimitiveType type) {
+ String _switchResult = null;
+ String _typeName = this.typeHelpers.typeName(type);
+ final String _switchValue = _typeName;
+ boolean _matched = false;
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"byte")) {
+ _matched=true;
+ _switchResult = "int";
+ }
+ }
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"short")) {
+ _matched=true;
+ _switchResult = "int";
+ }
+ }
+ if (!_matched) {
+ if (Objects.equal(_switchValue,"float")) {
+ _matched=true;
+ _switchResult = "double";
+ }
+ }
+ if (!_matched) {
+ String _typeName_1 = this.typeHelpers.typeName(type);
+ _switchResult = _typeName_1;
+ }
+ return _switchResult;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/Initialization.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/Initialization.java
new file mode 100644
index 0000000..25fb481
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/Initialization.java
@@ -0,0 +1,297 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.List;
+import org.eclipse.etrice.core.room.Attribute;
+import org.eclipse.etrice.core.room.ComplexType;
+import org.eclipse.etrice.core.room.DataType;
+import org.eclipse.etrice.core.room.RefableType;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.etrice.generator.generic.TypeHelpers;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.xbase.lib.Conversions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+
+@Singleton
+@SuppressWarnings("all")
+public class Initialization {
+ @Inject
+ private TypeHelpers _typeHelpers;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ILanguageExtension languageExt;
+
+ @Inject
+ private IDataConfiguration dataConfigExt;
+
+ @Inject
+ private ProcedureHelpers procedureHelpers;
+
+ public CharSequence attributeInitialization(final List<Attribute> attribs, final boolean useClassDefaultsOnly) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("// initialize attributes");
+ _builder.newLine();
+ {
+ for(final Attribute a : attribs) {
+ RefableType _refType = a.getRefType();
+ DataType aType = _refType.getType();
+ _builder.newLineIfNotEmpty();
+ String value = a.getDefaultValueLiteral();
+ _builder.newLineIfNotEmpty();
+ {
+ boolean _notEquals = (!Objects.equal(value, null));
+ if (_notEquals) {
+ {
+ boolean _or = false;
+ int _size = a.getSize();
+ boolean _equals = (_size == 0);
+ if (_equals) {
+ _or = true;
+ } else {
+ boolean _isCharacterType = this._typeHelpers.isCharacterType(aType);
+ _or = (_equals || _isCharacterType);
+ }
+ if (_or) {
+ } else {
+ boolean _startsWith = value.startsWith("{");
+ if (_startsWith) {
+ String _name = a.getName();
+ String _replace = value.replace("{", "");
+ String _replace_1 = _replace.replace("}", "");
+ String[] _split = _replace_1.split(",");
+ CharSequence _initializeArrayWithValues = this.initializeArrayWithValues(_name, _split);
+ _builder.append(_initializeArrayWithValues, "");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("for (int i=0;i<");
+ int _size_1 = a.getSize();
+ _builder.append(_size_1, "");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_1 = a.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("[i] = ");
+ _builder.append(value, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ } else {
+ boolean _or_1 = false;
+ boolean _or_2 = false;
+ if ((aType instanceof ComplexType)) {
+ _or_2 = true;
+ } else {
+ int _size_2 = a.getSize();
+ boolean _greaterThan = (_size_2 > 1);
+ _or_2 = ((aType instanceof ComplexType) || _greaterThan);
+ }
+ if (_or_2) {
+ _or_1 = true;
+ } else {
+ boolean _not = (!useClassDefaultsOnly);
+ _or_1 = (_or_2 || _not);
+ }
+ if (_or_1) {
+ {
+ int _size_3 = a.getSize();
+ boolean _equals_1 = (_size_3 == 0);
+ if (_equals_1) {
+ } else {
+ {
+ boolean _not_1 = (!useClassDefaultsOnly);
+ if (_not_1) {
+ _builder.append("for (int i=0;i<");
+ int _size_4 = a.getSize();
+ _builder.append(_size_4, "");
+ _builder.append(";i++){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_2 = a.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("[i] = ");
+ {
+ RefableType _refType_1 = a.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (_isRef) {
+ String _nullPointer = this.languageExt.nullPointer();
+ _builder.append(_nullPointer, " ");
+ } else {
+ String _defaultValue = this.languageExt.defaultValue(aType);
+ _builder.append(_defaultValue, " ");
+ }
+ }
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence initializeArrayWithValues(final String varName, final String[] values) {
+ StringConcatenation _builder = new StringConcatenation();
+ final Function1<String,String> _function = new Function1<String,String>() {
+ public String apply(final String v) {
+ String _plus = (varName + "[");
+ int _indexOf = ((List<String>)Conversions.doWrapArray(values)).indexOf(v);
+ String _plus_1 = (_plus + Integer.valueOf(_indexOf));
+ String _plus_2 = (_plus_1 + "] = ");
+ String _plus_3 = (_plus_2 + v);
+ String _plus_4 = (_plus_3 + ";");
+ return _plus_4;
+ }
+ };
+ List<String> _map = ListExtensions.<String, String>map(((List<String>)Conversions.doWrapArray(values)), _function);
+ String _join = IterableExtensions.join(_map, "\r\n");
+ _builder.append(_join, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public CharSequence attributeInitialization(final Attribute a, final boolean useClassDefaultsOnly) {
+ CharSequence _xblockexpression = null;
+ {
+ RefableType _refType = a.getRefType();
+ DataType aType = _refType.getType();
+ String value = a.getDefaultValueLiteral();
+ CharSequence _xifexpression = null;
+ boolean _notEquals = (!Objects.equal(value, null));
+ if (_notEquals) {
+ CharSequence _xifexpression_1 = null;
+ boolean _or = false;
+ int _size = a.getSize();
+ boolean _equals = (_size == 0);
+ if (_equals) {
+ _or = true;
+ } else {
+ boolean _isCharacterType = this._typeHelpers.isCharacterType(aType);
+ _or = (_equals || _isCharacterType);
+ }
+ if (_or) {
+ CharSequence _xifexpression_2 = null;
+ RefableType _refType_1 = a.getRefType();
+ boolean _isRef = _refType_1.isRef();
+ if (_isRef) {
+ StringConcatenation _builder = new StringConcatenation();
+ String _name = a.getName();
+ _builder.append(_name, "");
+ _builder.append("(new ");
+ String _name_1 = aType.getName();
+ _builder.append(_name_1, "");
+ _builder.append("(");
+ _builder.append(value, "");
+ _builder.append("))");
+ _xifexpression_2 = _builder;
+ } else {
+ StringConcatenation _builder_1 = new StringConcatenation();
+ String _name_2 = a.getName();
+ _builder_1.append(_name_2, "");
+ _builder_1.append("(");
+ _builder_1.append(value, "");
+ _builder_1.append(")");
+ _xifexpression_2 = _builder_1;
+ }
+ _xifexpression_1 = _xifexpression_2;
+ } else {
+ CharSequence _xifexpression_3 = null;
+ boolean _startsWith = value.startsWith("{");
+ if (_startsWith) {
+ StringConcatenation _builder_2 = new StringConcatenation();
+ String _name_3 = a.getName();
+ _builder_2.append(_name_3, "");
+ _builder_2.append("()");
+ _xifexpression_3 = _builder_2;
+ } else {
+ StringConcatenation _builder_3 = new StringConcatenation();
+ String _name_4 = a.getName();
+ _builder_3.append(_name_4, "");
+ _builder_3.append("()");
+ _xifexpression_3 = _builder_3;
+ }
+ _xifexpression_1 = _xifexpression_3;
+ }
+ _xifexpression = _xifexpression_1;
+ } else {
+ CharSequence _xifexpression_4 = null;
+ boolean _or_1 = false;
+ boolean _or_2 = false;
+ if ((aType instanceof ComplexType)) {
+ _or_2 = true;
+ } else {
+ int _size_1 = a.getSize();
+ boolean _greaterThan = (_size_1 > 1);
+ _or_2 = ((aType instanceof ComplexType) || _greaterThan);
+ }
+ if (_or_2) {
+ _or_1 = true;
+ } else {
+ boolean _not = (!useClassDefaultsOnly);
+ _or_1 = (_or_2 || _not);
+ }
+ if (_or_1) {
+ CharSequence _xifexpression_5 = null;
+ int _size_2 = a.getSize();
+ boolean _equals_1 = (_size_2 == 0);
+ if (_equals_1) {
+ CharSequence _xifexpression_6 = null;
+ RefableType _refType_2 = a.getRefType();
+ boolean _isRef_1 = _refType_2.isRef();
+ if (_isRef_1) {
+ StringConcatenation _builder_4 = new StringConcatenation();
+ String _name_5 = a.getName();
+ _builder_4.append(_name_5, "");
+ _builder_4.append("(");
+ String _nullPointer = this.languageExt.nullPointer();
+ _builder_4.append(_nullPointer, "");
+ _builder_4.append(")");
+ _xifexpression_6 = _builder_4;
+ } else {
+ StringConcatenation _builder_5 = new StringConcatenation();
+ String _name_6 = a.getName();
+ _builder_5.append(_name_6, "");
+ _builder_5.append("(");
+ String _defaultValue = this.languageExt.defaultValue(aType);
+ _builder_5.append(_defaultValue, "");
+ _builder_5.append(")");
+ _xifexpression_6 = _builder_5;
+ }
+ _xifexpression_5 = _xifexpression_6;
+ } else {
+ StringConcatenation _builder_6 = new StringConcatenation();
+ String _name_7 = a.getName();
+ _builder_6.append(_name_7, "");
+ _builder_6.append("()");
+ _xifexpression_5 = _builder_6;
+ }
+ _xifexpression_4 = _xifexpression_5;
+ }
+ _xifexpression = _xifexpression_4;
+ }
+ _xblockexpression = (_xifexpression);
+ }
+ return _xblockexpression;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
new file mode 100644
index 0000000..d0ea74d
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
@@ -0,0 +1,143 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.InterfaceItem;
+import org.eclipse.etrice.core.room.MessageFromIf;
+import org.eclipse.etrice.core.room.State;
+import org.eclipse.etrice.generator.cpp.gen.ProtocolClassGen;
+import org.eclipse.etrice.generator.generic.GenericStateMachineGenerator;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.util.Pair;
+import org.eclipse.xtext.util.Tuples;
+
+@Singleton
+@SuppressWarnings("all")
+public class StateMachineGen extends GenericStateMachineGenerator {
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProtocolClassGen cppProtGen;
+
+ public CharSequence genExtraDecl(final ExpandedActorClass xpac) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("protected:");
+ _builder.newLine();
+ _builder.append(" \t");
+ _builder.append("static std::string s_stateStrings[];");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append(" \t");
+ _builder.append("int history[];");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("private:");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("void setState(int new_state);");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence genExtra(final ExpandedActorClass xpac) {
+ CharSequence _xblockexpression = null;
+ {
+ final ActorClass ac = xpac.getActorClass();
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("std::string ");
+ String _name = ac.getName();
+ _builder.append(_name, "");
+ _builder.append("::s_stateStrings[] = {\"<no state>\",\"<top>\",");
+ {
+ List<State> _allBaseStatesLeavesLast = this._roomExtensions.getAllBaseStatesLeavesLast(ac);
+ boolean _hasElements = false;
+ for(final State state : _allBaseStatesLeavesLast) {
+ if (!_hasElements) {
+ _hasElements = true;
+ } else {
+ _builder.appendImmediate(",", "");
+ }
+ _builder.append("\"");
+ String _statePathName = this._roomExtensions.getStatePathName(state);
+ _builder.append(_statePathName, "");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("};");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_1 = ac.getName();
+ _builder.append(_name_1, "");
+ _builder.append("::setState(int new_state) {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state]);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (s_stateStrings[new_state]!=\"Idle\") {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("std::cout << getInstancePath() << \" -> \" << s_stateStrings[new_state] << std::endl;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("m_state = new_state;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public String genTriggerConstants(final ExpandedActorClass xpac) {
+ EList<MessageFromIf> _xifexpression = null;
+ boolean _usesInheritance = this.langExt.usesInheritance();
+ if (_usesInheritance) {
+ EList<MessageFromIf> _ownTriggers = xpac.getOwnTriggers();
+ _xifexpression = _ownTriggers;
+ } else {
+ EList<MessageFromIf> _triggers = xpac.getTriggers();
+ _xifexpression = _triggers;
+ }
+ final EList<MessageFromIf> triggers = _xifexpression;
+ ArrayList<Pair<String,String>> _arrayList = new ArrayList<Pair<String,String>>();
+ final ArrayList<Pair<String,String>> list = _arrayList;
+ Pair<String,String> _pair = Tuples.<String, String>pair("POLLING", "0");
+ list.add(_pair);
+ for (final MessageFromIf mif : triggers) {
+ String _triggerCodeName = xpac.getTriggerCodeName(mif);
+ InterfaceItem _from = mif.getFrom();
+ String _name = _from.getName();
+ String _plus = ("IFITEM_" + _name);
+ String _plus_1 = (_plus + " + EVT_SHIFT*");
+ String _messageID = this.cppProtGen.getMessageID(mif);
+ String _plus_2 = (_plus_1 + _messageID);
+ Pair<String,String> _pair_1 = Tuples.<String, String>pair(_triggerCodeName, _plus_2);
+ list.add(_pair_1);
+ }
+ return this.langExt.genEnumeration("triggers", list);
+ }
+
+ public String constPointer(final String classname) {
+ String _plus = ("const " + classname);
+ return (_plus + "*");
+ }
+
+ public String boolType() {
+ return "bool";
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.java
new file mode 100644
index 0000000..368d980
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.java
@@ -0,0 +1,930 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.genmodel.base.ILogger;
+import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.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.LogicalThread;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.IDataConfiguration;
+import org.eclipse.etrice.generator.base.Indexed;
+import org.eclipse.etrice.generator.cpp.gen.ConfigGenAddon;
+import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
+import org.eclipse.etrice.generator.generic.ProcedureHelpers;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+public class SubSystemClassGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CppExtensions _cppExtensions;
+
+ @Inject
+ private RoomExtensions _roomExtensions;
+
+ @Inject
+ private ProcedureHelpers _procedureHelpers;
+
+ @Inject
+ private IDataConfiguration dataConfigExt;
+
+ @Inject
+ private ConfigGenAddon configGenAddon;
+
+ @Inject
+ private ConfigGenAddon configAddon;
+
+ @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._cppExtensions.getCppHeaderFileName(_subSystemClass_2);
+ String _plus = ("generating SubSystemClass declaration: \'" + 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 _generateHeaderFile = this.generateHeaderFile(root, ssi, _subSystemClass_3);
+ this.fileAccess.generateFile(file, _generateHeaderFile);
+ SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
+ String _cppSourceFileName = this._cppExtensions.getCppSourceFileName(_subSystemClass_4);
+ file = _cppSourceFileName;
+ String _plus_4 = ("generating SubSystemClass implementation: \'" + file);
+ String _plus_5 = (_plus_4 + "\' in \'");
+ String _plus_6 = (_plus_5 + path);
+ String _plus_7 = (_plus_6 + "\'");
+ this.logger.logInfo(_plus_7);
+ this.fileAccess.setOutputPath(path);
+ SubSystemClass _subSystemClass_5 = ssi.getSubSystemClass();
+ CharSequence _generateSourceFile = this.generateSourceFile(root, ssi, _subSystemClass_5);
+ this.fileAccess.generateFile(file, _generateSourceFile);
+ }
+ }
+ }
+
+ public CharSequence generateHeaderFile(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* Header File of SubSystemClass ");
+ String _name = cc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_1 = cc.getName();
+ CharSequence _generateIncludeGuardBegin = this._cppExtensions.generateIncludeGuardBegin(_name_1);
+ _builder.append(_generateIncludeGuardBegin, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"platforms/generic/etDatatypes.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/messaging/IRTObject.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/modelbase/PortBase.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/modelbase/InterfaceItemBase.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/modelbase/ActorClassBase.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/modelbase/SubSystemClassBase.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/messaging/Address.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/messaging/IMessageReceiver.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/debugging/DebuggingService.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include <string>");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include <vector>");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ EList<RoomModel> _referencedModels = root.getReferencedModels(cc);
+ for(final RoomModel model : _referencedModels) {
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _userCode = this._procedureHelpers.userCode(cc, 1);
+ _builder.append(_userCode, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("class ");
+ String _name_2 = cc.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(" : public etRuntime::SubSystemClassBase{");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ CharSequence _userCode_1 = this._procedureHelpers.userCode(cc, 2);
+ _builder.append(_userCode_1, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ String _name_3 = cc.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("(IRTObject* parent, std::string name)");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append(": etRuntime::SubSystemClassBase(parent, name)");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("virtual void receiveEvent(etRuntime::InterfaceItemBase* ifitem, int evt, void* data);");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("virtual void instantiateMessageServices();");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("virtual void instantiateActors();");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("private:");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("std::vector<etRuntime::MessageService*> m_msgServices;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("};");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_4 = cc.getName();
+ CharSequence _generateIncludeGuardEnd = this._cppExtensions.generateIncludeGuardEnd(_name_4);
+ _builder.append(_generateIncludeGuardEnd, " ");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public CharSequence generateSourceFile(final Root root, final SubSystemInstance comp, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("* Source File of SubsystemClass ");
+ String _name = cc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t ");
+ _builder.append("* ");
+ _builder.newLine();
+ _builder.append("\t ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"");
+ String _cppHeaderFileName = this._cppExtensions.getCppHeaderFileName(cc);
+ _builder.append(_cppHeaderFileName, " ");
+ _builder.append("\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("#include \"common/debugging/DebuggingService.h\"");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("#include \"common/messaging/RTSystemServicesProtocol.h\"");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
+ for(final ActorInstance ai : _allContainedInstances) {
+ _builder.append("\t");
+ _builder.append("#include \"");
+ ActorClass _actorClass = ai.getActorClass();
+ String _path = this._roomExtensions.getPath(_actorClass);
+ _builder.append(_path, " ");
+ ActorClass _actorClass_1 = ai.getActorClass();
+ String _name_1 = _actorClass_1.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("#include <iostream>");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("using namespace etRuntime;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("void ");
+ String _name_2 = cc.getName();
+ _builder.append(_name_2, " ");
+ _builder.append("::receiveEvent(InterfaceItemBase* ifitem, int evt, void* data){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("void ");
+ String _name_3 = cc.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("::instantiateMessageServices(){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("m_msgServices.push_back( new MessageService(this, Address(0, 0, 0),\"MessageService_Main\") );");
+ _builder.newLine();
+ {
+ EList<LogicalThread> _threads = cc.getThreads();
+ for(final LogicalThread thread : _threads) {
+ _builder.append("\t\t");
+ _builder.append("m_msgServices.push_back(new MessageService(this, 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_4 = thread.getName();
+ _builder.append(_name_4, " ");
+ _builder.append("\", /* threadprio */ 0));");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t\t");
+ _builder.append("for (std::vector<MessageService*>::iterator it=m_msgServices.begin(); it != m_msgServices.end(); ++it) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("RTServices::getInstance().getMsgSvcCtrl().addMsgSvc( *(*it));");
+ _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("void ");
+ String _name_5 = cc.getName();
+ _builder.append(_name_5, " ");
+ _builder.append("::instantiateActors(){");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("// all addresses");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// Addresses for the Subsystem Systemport");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_1 = comp.getAllContainedInstances();
+ int _maxObjId = comp.getMaxObjId();
+ Iterable<Indexed<ActorInstance>> _indexed = Indexed.<ActorInstance>indexed(_allContainedInstances_1, _maxObjId);
+ for(final Indexed<ActorInstance> ai_1 : _indexed) {
+ _builder.append("\t");
+ _builder.append("Address addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_2 = comp.getAllContainedInstances();
+ ActorInstance _value = ai_1.getValue();
+ int _indexOf_1 = _allContainedInstances_2.indexOf(_value);
+ _builder.append(_indexOf_1, " ");
+ _builder.append("(0,0,");
+ int _index1 = ai_1.getIndex1();
+ _builder.append(_index1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_3 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_2 : _allContainedInstances_3) {
+ _builder.append("\t");
+ _builder.append("// actor instance ");
+ String _path_1 = ai_2.getPath();
+ _builder.append(_path_1, " ");
+ _builder.append(" itself => Systemport Address");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("// TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("Address addr_item_");
+ String _path_2 = ai_2.getPath();
+ String _pathName = this._roomExtensions.getPathName(_path_2);
+ _builder.append(_pathName, " ");
+ _builder.append("(0,");
+ int _threadId = ai_2.getThreadId();
+ _builder.append(_threadId, " ");
+ _builder.append(",");
+ int _objId = ai_2.getObjId();
+ _builder.append(_objId, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("// interface items of ");
+ String _path_3 = ai_2.getPath();
+ _builder.append(_path_3, " ");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai_2.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");
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int i = _peers_1.indexOf(peer);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("Address addr_item_");
+ String _path_4 = pi.getPath();
+ String _pathName_1 = this._roomExtensions.getPathName(_path_4);
+ _builder.append(_pathName_1, " ");
+ _builder.append("_");
+ _builder.append(i, " ");
+ _builder.append("(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");
+ _builder.append("Address addr_item_");
+ String _path_5 = pi.getPath();
+ String _pathName_2 = this._roomExtensions.getPathName(_path_5);
+ _builder.append(_pathName_2, " ");
+ _builder.append("(0,");
+ int _threadId_2 = ai_2.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");
+ _builder.append("// instantiate all actor instances");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("m_instances.reserve(");
+ EList<ActorInstance> _allContainedInstances_4 = comp.getAllContainedInstances();
+ int _size = _allContainedInstances_4.size();
+ _builder.append(_size, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances_5 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_3 : _allContainedInstances_5) {
+ _builder.append("\t");
+ _builder.append("//----------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// addresses for actor instance: ");
+ String _name_6 = ai_3.getName();
+ _builder.append(_name_6, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("//----------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("\t");
+ CharSequence _generateOwnInterfaceItemAddresses = this.generateOwnInterfaceItemAddresses(ai_3);
+ _builder.append(_generateOwnInterfaceItemAddresses, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ CharSequence _generatePeerInterfaceItemAddresses = this.generatePeerInterfaceItemAddresses(ai_3, comp);
+ _builder.append(_generatePeerInterfaceItemAddresses, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("m_instances[");
+ EList<ActorInstance> _allContainedInstances_6 = comp.getAllContainedInstances();
+ int _indexOf_2 = _allContainedInstances_6.indexOf(ai_3);
+ _builder.append(_indexOf_2, " ");
+ _builder.append("] = new ");
+ ActorClass _actorClass_2 = ai_3.getActorClass();
+ String _name_7 = _actorClass_2.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("(");
+ _builder.newLineIfNotEmpty();
+ {
+ EObject _eContainer = ai_3.eContainer();
+ if ((_eContainer instanceof SubSystemInstance)) {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("this,");
+ _builder.newLine();
+ } else {
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("m_instances[");
+ EList<ActorInstance> _allContainedInstances_7 = comp.getAllContainedInstances();
+ EObject _eContainer_1 = ai_3.eContainer();
+ int _indexOf_3 = _allContainedInstances_7.indexOf(_eContainer_1);
+ _builder.append(_indexOf_3, " ");
+ _builder.append("],");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("\"");
+ String _name_8 = ai_3.getName();
+ _builder.append(_name_8, " ");
+ _builder.append("\",");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_9 = ai_3.getName();
+ _builder.append(_name_9, " ");
+ _builder.append("_ownInterfaceItemAddresses,");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
+ String _name_10 = ai_3.getName();
+ _builder.append(_name_10, " ");
+ _builder.append("_peerInterfaceItemAddresses");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("); ");
+ _builder.newLine();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("// apply instance attribute configurations");
+ _builder.newLine();
+ {
+ EList<ActorInstance> _allContainedInstances_8 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_4 : _allContainedInstances_8) {
+ final CharSequence cfg = this.configGenAddon.genActorInstanceConfig(ai_4, "inst");
+ _builder.newLineIfNotEmpty();
+ {
+ int _length = cfg.length();
+ boolean _greaterThan = (_length > 0);
+ if (_greaterThan) {
+ _builder.append("{");
+ _builder.newLine();
+ _builder.append("\t");
+ ActorClass _actorClass_3 = ai_4.getActorClass();
+ String _name_11 = _actorClass_3.getName();
+ _builder.append(_name_11, " ");
+ _builder.append(" inst = (");
+ ActorClass _actorClass_4 = ai_4.getActorClass();
+ String _name_12 = _actorClass_4.getName();
+ _builder.append(_name_12, " ");
+ _builder.append(") instances[");
+ EList<ActorInstance> _allContainedInstances_9 = comp.getAllContainedInstances();
+ int _indexOf_4 = _allContainedInstances_9.indexOf(ai_4);
+ _builder.append(_indexOf_4, " ");
+ _builder.append("];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append(cfg, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append("}");
+ _builder.newLine();
+ }
+ }
+ }
+ }
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//----------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// addresses for the subsystem system port");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//----------------------------------------------------------------------------------------------");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("std::vector<Address> ownAddresses(");
+ EList<ActorInstance> _allContainedInstances_10 = comp.getAllContainedInstances();
+ int _size_1 = _allContainedInstances_10.size();
+ _builder.append(_size_1, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances_11 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_5 : _allContainedInstances_11) {
+ _builder.append("\t");
+ _builder.append("ownAddresses[");
+ EList<ActorInstance> _allContainedInstances_12 = comp.getAllContainedInstances();
+ int _indexOf_5 = _allContainedInstances_12.indexOf(ai_5);
+ _builder.append(_indexOf_5, " ");
+ _builder.append("] = addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances_13 = comp.getAllContainedInstances();
+ int _indexOf_6 = _allContainedInstances_13.indexOf(ai_5);
+ _builder.append(_indexOf_6, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.append("std::vector<Address> peerAddresses(");
+ EList<ActorInstance> _allContainedInstances_14 = comp.getAllContainedInstances();
+ int _size_2 = _allContainedInstances_14.size();
+ _builder.append(_size_2, " ");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _allContainedInstances_15 = comp.getAllContainedInstances();
+ for(final ActorInstance ai_6 : _allContainedInstances_15) {
+ _builder.append("\t");
+ _builder.append("peerAddresses[");
+ EList<ActorInstance> _allContainedInstances_16 = comp.getAllContainedInstances();
+ int _indexOf_7 = _allContainedInstances_16.indexOf(ai_6);
+ _builder.append(_indexOf_7, " ");
+ _builder.append("] = addr_item_");
+ String _path_6 = ai_6.getPath();
+ String _pathName_3 = this._roomExtensions.getPathName(_path_6);
+ _builder.append(_pathName_3, " ");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// create the subsystem system port\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("m_RTSystemPort = new RTSystemServicesProtocolConjPortRepl(*this, this, \"RTSystemPort\",");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("0, //local ID");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("ownAddresses,");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("peerAddresses);");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence generateOwnInterfaceItemAddresses(final ActorInstance ai) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("std::vector<std::vector<Address> > ");
+ String _name = ai.getName();
+ _builder.append(_name, "");
+ _builder.append("_ownInterfaceItemAddresses;");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("std::vector<Address> ");
+ String _name_1 = ai.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_actorInstanceAddresses(1);");
+ _builder.newLineIfNotEmpty();
+ String _name_2 = ai.getName();
+ _builder.append(_name_2, "");
+ _builder.append("_actorInstanceAddresses[0] = addr_item_");
+ String _path = ai.getPath();
+ String _pathName = this._roomExtensions.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_3 = ai.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_ownInterfaceItemAddresses.push_back(");
+ String _name_4 = ai.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_actorInstanceAddresses);");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
+ for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
+ {
+ boolean _isReplicated = pi.isReplicated();
+ if (_isReplicated) {
+ {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ boolean _isEmpty = _peers.isEmpty();
+ if (_isEmpty) {
+ _builder.append("std::vector<Address> ");
+ String _name_5 = ai.getName();
+ _builder.append(_name_5, "");
+ _builder.append("_");
+ String _name_6 = pi.getName();
+ _builder.append(_name_6, "");
+ _builder.append("Addresses;");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("std::vector<Address> ");
+ String _name_7 = ai.getName();
+ _builder.append(_name_7, "");
+ _builder.append("_");
+ String _name_8 = pi.getName();
+ _builder.append(_name_8, "");
+ _builder.append("Addresses(");
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ int _size = _peers_1.size();
+ _builder.append(_size, "");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ for(final InterfaceItemInstance peer : _peers_2) {
+ String _name_9 = ai.getName();
+ _builder.append(_name_9, "");
+ _builder.append("_");
+ String _name_10 = pi.getName();
+ _builder.append(_name_10, "");
+ _builder.append("Addresses[");
+ EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
+ int _indexOf = _peers_3.indexOf(peer);
+ _builder.append(_indexOf, "");
+ _builder.append("] = addr_item_");
+ String _path_1 = pi.getPath();
+ String _pathName_1 = this._roomExtensions.getPathName(_path_1);
+ _builder.append(_pathName_1, "");
+ _builder.append("_");
+ EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
+ int _indexOf_1 = _peers_4.indexOf(peer);
+ _builder.append(_indexOf_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ } else {
+ _builder.append("std::vector<Address> ");
+ String _name_11 = ai.getName();
+ _builder.append(_name_11, "");
+ _builder.append("_");
+ String _name_12 = pi.getName();
+ _builder.append(_name_12, "");
+ _builder.append("Addresses(1);");
+ _builder.newLineIfNotEmpty();
+ String _name_13 = ai.getName();
+ _builder.append(_name_13, "");
+ _builder.append("_");
+ String _name_14 = pi.getName();
+ _builder.append(_name_14, "");
+ _builder.append("Addresses[0] = addr_item_");
+ String _path_2 = pi.getPath();
+ String _pathName_2 = this._roomExtensions.getPathName(_path_2);
+ _builder.append(_pathName_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ String _name_15 = ai.getName();
+ _builder.append(_name_15, "");
+ _builder.append("_ownInterfaceItemAddresses.push_back(");
+ String _name_16 = ai.getName();
+ _builder.append(_name_16, "");
+ _builder.append("_");
+ String _name_17 = pi.getName();
+ _builder.append(_name_17, "");
+ _builder.append("Addresses);");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence generatePeerInterfaceItemAddresses(final ActorInstance ai, final SubSystemInstance comp) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("std::vector<std::vector<Address> > ");
+ String _name = ai.getName();
+ _builder.append(_name, "");
+ _builder.append("_peerInterfaceItemAddresses;");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("std::vector<Address> ");
+ String _name_1 = ai.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_systemPortAddresses(1);");
+ _builder.newLineIfNotEmpty();
+ String _name_2 = ai.getName();
+ _builder.append(_name_2, "");
+ _builder.append("_systemPortAddresses[0] = addr_item_SystemPort_");
+ EList<ActorInstance> _allContainedInstances = comp.getAllContainedInstances();
+ int _indexOf = _allContainedInstances.indexOf(ai);
+ _builder.append(_indexOf, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ String _name_3 = ai.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_peerInterfaceItemAddresses.push_back(");
+ String _name_4 = ai.getName();
+ _builder.append(_name_4, "");
+ _builder.append("_systemPortAddresses);");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
+ for(final InterfaceItemInstance pi : _orderedIfItemInstances) {
+ {
+ boolean _and = false;
+ boolean _isReplicated = pi.isReplicated();
+ if (!_isReplicated) {
+ _and = false;
+ } else {
+ EList<InterfaceItemInstance> _peers = pi.getPeers();
+ boolean _isEmpty = _peers.isEmpty();
+ _and = (_isReplicated && _isEmpty);
+ }
+ if (_and) {
+ } else {
+ {
+ EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
+ boolean _isEmpty_1 = _peers_1.isEmpty();
+ if (_isEmpty_1) {
+ _builder.append("std::vector<Address> ");
+ String _name_5 = ai.getName();
+ _builder.append(_name_5, "");
+ _builder.append("_");
+ String _name_6 = pi.getName();
+ _builder.append(_name_6, "");
+ _builder.append("PeerAddresses;");
+ _builder.newLineIfNotEmpty();
+ } else {
+ _builder.append("std::vector<Address> ");
+ String _name_7 = ai.getName();
+ _builder.append(_name_7, "");
+ _builder.append("_");
+ String _name_8 = pi.getName();
+ _builder.append(_name_8, "");
+ _builder.append("PeerAddresses(");
+ EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
+ int _size = _peers_2.size();
+ _builder.append(_size, "");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
+ for(final InterfaceItemInstance pp : _peers_3) {
+ {
+ boolean _isReplicated_1 = pp.isReplicated();
+ if (_isReplicated_1) {
+ String _name_9 = ai.getName();
+ _builder.append(_name_9, "");
+ _builder.append("_");
+ String _name_10 = pi.getName();
+ _builder.append(_name_10, "");
+ _builder.append("PeerAddresses[");
+ EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
+ int _indexOf_1 = _peers_4.indexOf(pp);
+ _builder.append(_indexOf_1, "");
+ _builder.append("] = addr_item_");
+ String _path = pp.getPath();
+ String _pathName = this._roomExtensions.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append("_");
+ EList<InterfaceItemInstance> _peers_5 = pp.getPeers();
+ int _indexOf_2 = _peers_5.indexOf(pi);
+ _builder.append(_indexOf_2, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ } else {
+ String _name_11 = ai.getName();
+ _builder.append(_name_11, "");
+ _builder.append("_");
+ String _name_12 = pi.getName();
+ _builder.append(_name_12, "");
+ _builder.append("PeerAddresses[");
+ EList<InterfaceItemInstance> _peers_6 = pi.getPeers();
+ int _indexOf_3 = _peers_6.indexOf(pp);
+ _builder.append(_indexOf_3, "");
+ _builder.append("] = addr_item_");
+ String _path_1 = pp.getPath();
+ String _pathName_1 = this._roomExtensions.getPathName(_path_1);
+ _builder.append(_pathName_1, "");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ }
+ }
+ String _name_13 = ai.getName();
+ _builder.append(_name_13, "");
+ _builder.append("_peerInterfaceItemAddresses.push_back(");
+ String _name_14 = ai.getName();
+ _builder.append(_name_14, "");
+ _builder.append("_");
+ String _name_15 = pi.getName();
+ _builder.append(_name_15, "");
+ _builder.append("PeerAddresses);");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.java
new file mode 100644
index 0000000..b84ba20
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.java
@@ -0,0 +1,263 @@
+package org.eclipse.etrice.generator.cpp.gen;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.etrice.core.genmodel.etricegen.Root;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.cpp.gen.CppExtensions;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+@Singleton
+@SuppressWarnings("all")
+public class SubSystemRunnerGen {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private CppExtensions _cppExtensions;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ public void doGenerate(final Root root) {
+ EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
+ for (final SubSystemInstance sc : _subSystemInstances) {
+ {
+ SubSystemClass _subSystemClass = sc.getSubSystemClass();
+ String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
+ SubSystemClass _subSystemClass_1 = sc.getSubSystemClass();
+ String _path = this.roomExt.getPath(_subSystemClass_1);
+ String _plus = (_generationTargetPath + _path);
+ this.fileAccess.setOutputPath(_plus);
+ SubSystemClass _subSystemClass_2 = sc.getSubSystemClass();
+ String _name = _subSystemClass_2.getName();
+ String _plus_1 = (_name + "_Runner.h");
+ SubSystemClass _subSystemClass_3 = sc.getSubSystemClass();
+ CharSequence _generateHeaderFile = this.generateHeaderFile(root, sc, _subSystemClass_3);
+ this.fileAccess.generateFile(_plus_1, _generateHeaderFile);
+ SubSystemClass _subSystemClass_4 = sc.getSubSystemClass();
+ String _generationTargetPath_1 = this.roomExt.getGenerationTargetPath(_subSystemClass_4);
+ SubSystemClass _subSystemClass_5 = sc.getSubSystemClass();
+ String _path_1 = this.roomExt.getPath(_subSystemClass_5);
+ String _plus_2 = (_generationTargetPath_1 + _path_1);
+ this.fileAccess.setOutputPath(_plus_2);
+ SubSystemClass _subSystemClass_6 = sc.getSubSystemClass();
+ String _name_1 = _subSystemClass_6.getName();
+ String _plus_3 = (_name_1 + "_Runner.cpp");
+ SubSystemClass _subSystemClass_7 = sc.getSubSystemClass();
+ CharSequence _generateSourceFile = this.generateSourceFile(root, sc, _subSystemClass_7);
+ this.fileAccess.generateFile(_plus_3, _generateSourceFile);
+ }
+ }
+ }
+
+ public CharSequence generateHeaderFile(final Root root, final SubSystemInstance ssc, final SubSystemClass cc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* this class contains the main function running component ");
+ String _name = cc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* it instantiates ");
+ String _name_1 = cc.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" and starts and ends the lifecycle");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_2 = cc.getName();
+ String _plus = (_name_2 + "_Runner");
+ CharSequence _generateIncludeGuardBegin = this._cppExtensions.generateIncludeGuardBegin(_plus);
+ _builder.append(_generateIncludeGuardBegin, "");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include \"common/modelbase/SubSystemRunnerBase.h\"");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("class ");
+ String _name_3 = cc.getName();
+ String _plus_1 = (_name_3 + "Runner");
+ _builder.append(_plus_1, "");
+ _builder.append(" :public etRuntime::SubSystemRunnerBase {");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* main function");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* creates component and starts and stops the lifecycle");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public:");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("static void run(); ");
+ _builder.newLine();
+ _builder.append("};");
+ _builder.newLine();
+ _builder.newLine();
+ String _name_4 = cc.getName();
+ String _plus_2 = (_name_4 + "_Runner");
+ CharSequence _generateIncludeGuardEnd = this._cppExtensions.generateIncludeGuardEnd(_plus_2);
+ _builder.append(_generateIncludeGuardEnd, "");
+ _builder.newLineIfNotEmpty();
+ return _builder;
+ }
+
+ public CharSequence generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* @author generated by eTrice");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* this class contains the main function running component ");
+ String _name = ssc.getName();
+ _builder.append(_name, " ");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("* it instantiates ");
+ String _name_1 = ssc.getName();
+ _builder.append(_name_1, " ");
+ _builder.append(" and starts and ends the lifecycle");
+ _builder.newLineIfNotEmpty();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("#include \"");
+ String _name_2 = ssc.getName();
+ _builder.append(_name_2, "");
+ _builder.append(".h\"");
+ _builder.newLineIfNotEmpty();
+ _builder.append("#include \"");
+ String _name_3 = ssc.getName();
+ _builder.append(_name_3, "");
+ _builder.append("_Runner.h\"");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("#include <iostream>");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("/**");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* main function");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* creates component and starts and stops the lifecycle");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*/");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("int main(void) {");
+ _builder.newLine();
+ _builder.append("\t");
+ String _name_4 = ssc.getName();
+ String _plus = (_name_4 + "Runner");
+ _builder.append(_plus, " ");
+ _builder.append("::run();");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("return 0;");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("void ");
+ String _name_5 = ssc.getName();
+ String _plus_1 = (_name_5 + "Runner");
+ _builder.append(_plus_1, "");
+ _builder.append("::run() {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _name_6 = ssc.getName();
+ _builder.append(_name_6, " ");
+ _builder.append(" main_component(0, \"");
+ String _name_7 = ssc.getName();
+ _builder.append(_name_7, " ");
+ _builder.append("\");");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//etUserEntry(); /* platform specific */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("std::cout << \"*** T H E B E G I N ***\" << std::endl;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("main_component.init(); // lifecycle init");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("main_component.start(); // lifecycle start");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// application runs until quit ");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("waitForQuit(main_component);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("// end the lifecycle");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("main_component.stop(); // lifecycle stop");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("main_component.destroy(); // lifecycle destroy");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("std::cout << \"*** T H E E N D ***\" << std::endl;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("//etUserExit(); /* platform specific */");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ _builder.newLine();
+ return _builder;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
new file mode 100644
index 0000000..ec54b2a
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.doc/xtend-gen/org/eclipse/etrice/generator/doc/gen/InstanceDiagramGen.java
@@ -0,0 +1,237 @@
+package org.eclipse.etrice.generator.doc.gen;
+
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.io.File;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.etrice.core.etmap.util.ETMapUtil;
+import org.eclipse.etrice.core.etphys.eTPhys.NodeRef;
+import org.eclipse.etrice.core.etphys.eTPhys.PhysicalThread;
+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.StructureInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
+import org.eclipse.etrice.core.genmodel.etricegen.SystemInstance;
+import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.eclipse.etrice.generator.base.IRoomGenerator;
+import org.eclipse.etrice.generator.generic.RoomExtensions;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+import org.eclipse.xtext.xbase.lib.Exceptions;
+
+@Singleton
+@SuppressWarnings("all")
+public class InstanceDiagramGen implements IRoomGenerator {
+ @Inject
+ private JavaIoFileSystemAccess fileAccess;
+
+ @Inject
+ private RoomExtensions roomExt;
+
+ @Inject
+ private ILogger logger;
+
+ public void doGenerate(final Root root) {
+ EList<RoomModel> _models = root.getModels();
+ for (final RoomModel model : _models) {
+ {
+ String _docGenerationTargetPath = this.roomExt.getDocGenerationTargetPath(model);
+ String path = (_docGenerationTargetPath + "/images");
+ this.fileAccess.setOutputPath(path);
+ String batchFile = "dot2jpg.bat";
+ EList<SystemInstance> _systemInstances = root.getSystemInstances();
+ for (final SystemInstance sys : _systemInstances) {
+ {
+ String _name = sys.getName();
+ String file = (_name + "_instanceTree.dot");
+ String _plus = ("generating instance tree diagram: \'" + file);
+ String _plus_1 = (_plus + "\' in \'");
+ String _plus_2 = (_plus_1 + path);
+ String _plus_3 = (_plus_2 + "\'");
+ this.logger.logInfo(_plus_3);
+ CharSequence _generate = this.generate(root, sys);
+ this.fileAccess.generateFile(file, _generate);
+ }
+ }
+ CharSequence _generate2jpg = this.generate2jpg(root);
+ this.fileAccess.generateFile(batchFile, _generate2jpg);
+ this.runDot2Jpg(path, batchFile);
+ }
+ }
+ }
+
+ public CharSequence generate2jpg(final Root root) {
+ StringConcatenation _builder = new StringConcatenation();
+ {
+ EList<SystemInstance> _systemInstances = root.getSystemInstances();
+ for(final SystemInstance sys : _systemInstances) {
+ _builder.append("dot -Tjpg -o ");
+ String _name = sys.getName();
+ _builder.append(_name, "");
+ _builder.append("_instanceTree.jpg ");
+ String _name_1 = sys.getName();
+ _builder.append(_name_1, "");
+ _builder.append("_instanceTree.dot");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ return _builder;
+ }
+
+ public CharSequence generate(final Root root, final SystemInstance sys) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("digraph ");
+ String _name = sys.getName();
+ _builder.append(_name, "");
+ _builder.append(" {");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("rankdir=TD;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("node [shape=box];");
+ _builder.newLine();
+ _builder.append("\t");
+ String _path = sys.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, " ");
+ _builder.append(" [label=\"");
+ String _name_1 = sys.getName();
+ _builder.append(_name_1, " ");
+ _builder.append("\\n(");
+ String _name_2 = sys.getName();
+ _builder.append(_name_2, " ");
+ _builder.append(")\" style=filled color=red];");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<SubSystemInstance> _instances = sys.getInstances();
+ for(final SubSystemInstance ssi : _instances) {
+ _builder.append("\t");
+ String _path_1 = ssi.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, " ");
+ _builder.append(" [label=\"");
+ String _name_3 = ssi.getName();
+ _builder.append(_name_3, " ");
+ _builder.append("\\n(");
+ SubSystemClass _subSystemClass = ssi.getSubSystemClass();
+ String _name_4 = _subSystemClass.getName();
+ _builder.append(_name_4, " ");
+ _builder.append(")\" style=filled color=yellow];");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ String _path_2 = sys.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_2, " ");
+ _builder.append(" -> ");
+ String _path_3 = ssi.getPath();
+ String _pathName_3 = this.roomExt.getPathName(_path_3);
+ _builder.append(_pathName_3, " ");
+ _builder.append("; ");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _instances_1 = ssi.getInstances();
+ for(final ActorInstance ai : _instances_1) {
+ _builder.append("\t");
+ CharSequence _instance = this.instance(ai);
+ _builder.append(_instance, " ");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ }
+ }
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
+ public CharSequence instance(final ActorInstance ai) {
+ CharSequence _xblockexpression = null;
+ {
+ EObject _eContainer = ai.eContainer();
+ final StructureInstance parent = ((StructureInstance) _eContainer);
+ final PhysicalThread pthread = ETMapUtil.getPhysicalThread(ai);
+ String _xifexpression = null;
+ boolean _equals = Objects.equal(pthread, null);
+ if (_equals) {
+ _xifexpression = "?";
+ } else {
+ String _name = pthread.getName();
+ _xifexpression = _name;
+ }
+ final String tname = _xifexpression;
+ final NodeRef node = ETMapUtil.getNodeRef(ai);
+ String _xifexpression_1 = null;
+ boolean _equals_1 = Objects.equal(node, null);
+ if (_equals_1) {
+ _xifexpression_1 = "?";
+ } else {
+ String _name_1 = node.getName();
+ _xifexpression_1 = _name_1;
+ }
+ final String nname = _xifexpression_1;
+ StringConcatenation _builder = new StringConcatenation();
+ String _path = ai.getPath();
+ String _pathName = this.roomExt.getPathName(_path);
+ _builder.append(_pathName, "");
+ _builder.append(" [label=\"");
+ String _name_2 = ai.getName();
+ _builder.append(_name_2, "");
+ _builder.append("\\n(");
+ ActorClass _actorClass = ai.getActorClass();
+ String _name_3 = _actorClass.getName();
+ _builder.append(_name_3, "");
+ _builder.append(")\\n@");
+ _builder.append(nname, "");
+ _builder.append(":");
+ _builder.append(tname, "");
+ _builder.append("\"];");
+ _builder.newLineIfNotEmpty();
+ String _path_1 = parent.getPath();
+ String _pathName_1 = this.roomExt.getPathName(_path_1);
+ _builder.append(_pathName_1, "");
+ _builder.append(" -> ");
+ String _path_2 = ai.getPath();
+ String _pathName_2 = this.roomExt.getPathName(_path_2);
+ _builder.append(_pathName_2, "");
+ _builder.append("; ");
+ _builder.newLineIfNotEmpty();
+ {
+ EList<ActorInstance> _instances = ai.getInstances();
+ for(final ActorInstance sub_ai : _instances) {
+ CharSequence _instance = this.instance(sub_ai);
+ _builder.append(_instance, "");
+ _builder.newLineIfNotEmpty();
+ }
+ }
+ _xblockexpression = (_builder);
+ }
+ return _xblockexpression;
+ }
+
+ public void runDot2Jpg(final String path, final String bat) {
+ File _file = new File(path);
+ File wdir = _file;
+ try {
+ Runtime _runtime = Runtime.getRuntime();
+ String _plus = ("cmd /C " + bat);
+ final Process p = _runtime.exec(_plus, null, wdir);
+ String _plus_1 = (bat + " finished with ");
+ int _waitFor = p.waitFor();
+ String _plus_2 = (_plus_1 + Integer.valueOf(_waitFor));
+ this.logger.logInfo(_plus_2);
+ } catch (final Throwable _t) {
+ if (_t instanceof Exception) {
+ final Exception e = (Exception)_t;
+ e.printStackTrace();
+ } else {
+ throw Exceptions.sneakyThrow(_t);
+ }
+ }
+ }
+}