summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Karlitschek2013-01-23 02:26:33 (EST)
committer Peter Karlitschek2013-01-23 02:26:33 (EST)
commit1e65cf2de6f5cd270853b4cfa1dcd2169078a683 (patch)
tree18cce6833cb3ecda35bb18b817f2cd8db4954312
parentc6f4dda244f74e45aa6f8fb507098a6c97e2566b (diff)
downloadorg.eclipse.etrice-1e65cf2de6f5cd270853b4cfa1dcd2169078a683.zip
org.eclipse.etrice-1e65cf2de6f5cd270853b4cfa1dcd2169078a683.tar.gz
org.eclipse.etrice-1e65cf2de6f5cd270853b4cfa1dcd2169078a683.tar.bz2
first c++ tests and single/multithreaded runtime
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend6
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Initialization.xtend5
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend15
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend34
-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/CppExtensions.java412
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java846
-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/MainGen.java60
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java1394
-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--runtime/org.eclipse.etrice.modellib.cpp/build.txt6
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room2
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp16
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h3
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp6
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp16
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp79
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h19
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp24
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp4
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp8
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h10
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp18
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h6
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp117
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h17
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp17
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h31
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/.cproject141
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/.settings/org.eclipse.cdt.managedbuilder.core.prefs13
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_CPTest_Async.seq27
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_CPTest_Sync.seq1
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_HandlerTest_Async.seq48
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_HandlerTest_Sync.seq1
-rw-r--r--tests/org.eclipse.etrice.generator.cpp.tests/make.xml12
43 files changed, 535 insertions, 5902 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
index eab3f4c..268bf81 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.xtend
@@ -203,6 +203,12 @@ class ActorClassGen extends GenericActorClassGenerator {
const std::vector<std::vector<etRuntime::Address> >& peer_addr)
: «ac.generateConstructorInitalizerList»
{
+ «IF ac.hasNonEmptyStateMachine»
+ history = new int[s_numberOfStates];
+ for (int i = 0; i < s_numberOfStates; i++) {
+ history[i] = NO_STATE;
+ }
+ «ENDIF»
setClassName("«ac.name»");
«ac.attributes.attributeInitialization(false)»
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Initialization.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Initialization.xtend
index 96199a1..ea260c6 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Initialization.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/Initialization.xtend
@@ -63,7 +63,10 @@ class Initialization {
def initializeArrayWithValues(String varName, String[] values) {
'''
- «values.map(v | varName + "[" + values.indexOf(v) + "] = " + v + ";" ).join("\r\n")»
+ «var i = -1»
+ «FOR v : values»
+ «varName»[«i=i+1»] = «v»;
+ «ENDFOR»
'''
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
index e32101d..93ad2f3 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend
@@ -249,7 +249,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«ENDFOR»
default:
«ENDIF»
- getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
«IF pc.handlesReceive(conj)»
break;
}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
index 5c99814..67549ef 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.xtend
@@ -32,13 +32,7 @@ class StateMachineGen extends GenericStateMachineGenerator {
'''
protected:
static std::string s_stateStrings[];
-
-««« TODOHRR: history defined in ActorClassBase, init in constructor
-««« history = new int[5];
-««« for (int i = 0; i < history.length; i++) {
-««« history[i] = NO_STATE;
-««« }
- int history[];
+ static const int s_numberOfStates;
private:
void setState(int new_state);
@@ -49,13 +43,8 @@ class StateMachineGen extends GenericStateMachineGenerator {
'''
std::string «ac.name»::s_stateStrings[] = {"<no state>","<top>",«FOR state : ac.getAllBaseStatesLeavesLast() SEPARATOR ","»"«state.getStatePathName()»"
«ENDFOR»};
+ const int «ac.name»::s_numberOfStates = «ac.getAllBaseStatesLeavesLast().size + 2»;
-««« TODOHRR: history defined in ActorClassBase, init in constructor
-««« history = new int[5];
-««« for (int i = 0; i < history.length; i++) {
-««« history[i] = NO_STATE;
-««« }
-
void «ac.name»::setState(int new_state) {
DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state]);
if (s_stateStrings[new_state]!="Idle") {
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend
index bb05076..ce8e4e8 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.xtend
@@ -40,12 +40,6 @@ class SubSystemRunnerGen {
class «cc.name+"Runner"» :public etRuntime::SubSystemRunnerBase {
- /**
- * main function
- * creates component and starts and stops the lifecycle
- */
- public:
- static void run();
};
«generateIncludeGuardEnd(cc.name+"_Runner")»
@@ -72,34 +66,14 @@ class SubSystemRunnerGen {
* creates component and starts and stops the lifecycle
*/
- int main(void) {
- «ssc.name+"Runner"»::run();
+
+ int main(int argc, char* argv[]) {
+ «ssc.name» mainComponent(0, "«ssc.name»");
+ «ssc.name+"Runner"»::run(mainComponent, argc, argv);
return 0;
}
- void «ssc.name+"Runner"»::run() {
- «ssc.name» main_component(0, "«ssc.name»");
-
- //etUserEntry(); /* platform specific */
-
- std::cout << "*** T H E B E G I N ***" << std::endl;
-
- main_component.init(); // lifecycle init
- main_component.start(); // lifecycle start
-
- // application runs until quit
- waitForQuit(main_component);
-
- // end the lifecycle
- main_component.stop(); // lifecycle stop
- main_component.destroy(); // lifecycle destroy
-
- std::cout << "*** T H E E N D ***" << std::endl;
-
- //etUserExit(); /* platform specific */
- }
-
'''
}
} \ No newline at end of file
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
deleted file mode 100644
index 65bf467..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ActorClassGen.java
+++ /dev/null
@@ -1,821 +0,0 @@
-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
deleted file mode 100644
index 25db9c5..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ConfigGenAddon.java
+++ /dev/null
@@ -1,558 +0,0 @@
-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/CppExtensions.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
deleted file mode 100644
index fff0cfc..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/CppExtensions.java
+++ /dev/null
@@ -1,412 +0,0 @@
-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.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.etrice.core.genmodel.etricegen.IDiagnostician;
-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.Message;
-import org.eclipse.etrice.core.room.PrimitiveType;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomClass;
-import org.eclipse.etrice.core.room.VarDecl;
-import org.eclipse.etrice.generator.generic.ILanguageExtension;
-import org.eclipse.etrice.generator.generic.TypeHelpers;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.util.Pair;
-import org.eclipse.xtext.xbase.lib.CollectionLiterals;
-import org.eclipse.xtext.xbase.lib.Conversions;
-
-@Singleton
-@SuppressWarnings("all")
-public class CppExtensions implements ILanguageExtension {
- @Inject
- private IDiagnostician diagnostician;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- public String getTypedDataDefinition(final Message m) {
- VarDecl _data = m.getData();
- String[] _generateArglistAndTypedData = this.generateArglistAndTypedData(_data);
- String _get = ((List<String>)Conversions.doWrapArray(_generateArglistAndTypedData)).get(1);
- return _get;
- }
-
- public String getCppHeaderFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _plus = (_name + ".h");
- return _plus;
- }
-
- public String getCppSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _plus = (_name + ".cpp");
- return _plus;
- }
-
- public String getInstSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _plus = (_name + "_Inst.h");
- return _plus;
- }
-
- public String getDispSourceFileName(final RoomClass rc) {
- String _name = rc.getName();
- String _plus = (_name + "_Disp.h");
- return _plus;
- }
-
- public String accessLevelPrivate() {
- return "";
- }
-
- public String accessLevelProtected() {
- return "";
- }
-
- public String accessLevelPublic() {
- return "";
- }
-
- public String memberAccess() {
- return "this->";
- }
-
- public String selfPointer(final String classname, final boolean hasArgs) {
- return "";
- }
-
- public String selfPointer(final boolean hasArgs) {
- return "";
- }
-
- public String operationScope(final String classname, final boolean isDeclaration) {
- String _xifexpression = null;
- if (isDeclaration) {
- _xifexpression = "";
- } else {
- String _plus = (classname + "::");
- _xifexpression = _plus;
- }
- return _xifexpression;
- }
-
- public String memberInDeclaration(final String namespace, final String member) {
- return member;
- }
-
- public String memberInUse(final String namespace, final String member) {
- String _plus = (namespace + ".");
- return (_plus + member);
- }
-
- public boolean usesInheritance() {
- return true;
- }
-
- public boolean usesPointers() {
- return true;
- }
-
- public String genEnumeration(final String name, final List<Pair<String,String>> entries) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("typedef enum {");
- _builder.newLine();
- {
- for(final Pair<String,String> entry : entries) {
- String _first = entry.getFirst();
- _builder.append(_first, "");
- _builder.append(" = ");
- String _second = entry.getSecond();
- _builder.append(_second, "");
- _builder.append(",");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("} ");
- _builder.append(name, "");
- _builder.append(";");
- String _string = _builder.toString();
- return _string;
- }
-
- public String booleanConstant(final boolean b) {
- String _string = Boolean.valueOf(b).toString();
- return _string;
- }
-
- public String pointerLiteral() {
- return "*";
- }
-
- public String nullPointer() {
- return "0";
- }
-
- public String voidPointer() {
- return "void*";
- }
-
- public String arrayDeclaration(final String type, final int size, final String name, final boolean isRef) {
- String _plus = (type + " ");
- String _plus_1 = (_plus + name);
- String _plus_2 = (_plus_1 + "[");
- String _plus_3 = (_plus_2 + Integer.valueOf(size));
- String _plus_4 = (_plus_3 + "]");
- return _plus_4;
- }
-
- public String constructorName(final String cls) {
- return cls;
- }
-
- public String destructorName(final String cls) {
- String _plus = (cls + "_dtor");
- return _plus;
- }
-
- public String constructorReturnType() {
- return "";
- }
-
- public String destructorReturnType() {
- return "void";
- }
-
- public CharSequence getIncludeGuardString(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("_");
- String _replaceAll = filename.replaceAll("\\/.", "_");
- String _upperCase = _replaceAll.toUpperCase();
- _builder.append(_upperCase, "");
- _builder.append("_H_");
- return _builder;
- }
-
- public CharSequence generateIncludeGuardBegin(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#ifndef ");
- CharSequence _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.newLineIfNotEmpty();
- _builder.append("#define ");
- CharSequence _includeGuardString_1 = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString_1, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public CharSequence generateIncludeGuardEnd(final String filename) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("#endif /* ");
- CharSequence _includeGuardString = this.getIncludeGuardString(filename);
- _builder.append(_includeGuardString, "");
- _builder.append(" */");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public String superCall(final String baseClassName, final String method, final String arguments) {
- String _plus = (baseClassName + "::");
- String _plus_1 = (_plus + method);
- String _plus_2 = (_plus_1 + "(");
- String _plus_3 = (_plus_2 + arguments);
- String _plus_4 = (_plus_3 + ");");
- return _plus_4;
- }
-
- public String toValueLiteral(final PrimitiveType type, final String value) {
- UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("TODO Config for Cpp");
- throw _unsupportedOperationException;
- }
-
- public String defaultValue(final DataType dt) {
- String _xifexpression = null;
- if ((dt instanceof PrimitiveType)) {
- return ((PrimitiveType) dt).getDefaultValueLiteral();
- } else {
- String _xifexpression_1 = null;
- if ((dt instanceof ExternalType)) {
- String _name = dt.getName();
- String _plus = ("initialize external type with default constructor" + _name);
- EObject _eContainer = dt.eContainer();
- EStructuralFeature _eContainingFeature = dt.eContainingFeature();
- this.diagnostician.warning(_plus, _eContainer, _eContainingFeature);
- String _typeName = this._typeHelpers.typeName(dt);
- return (_typeName + "()");
- } else {
- String _xblockexpression = null;
- {
- final DataClass dc = ((DataClass) dt);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("{");
- _builder.newLine();
- {
- EList<Attribute> _attributes = dc.getAttributes();
- boolean _hasElements = false;
- for(final Attribute att : _attributes) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- RefableType _refType = att.getRefType();
- DataType _type = _refType.getType();
- int _size = att.getSize();
- String _initializationWithDefaultValues = this.initializationWithDefaultValues(_type, _size);
- _builder.append(_initializationWithDefaultValues, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _xblockexpression = (_builder.toString());
- }
- _xifexpression_1 = _xblockexpression;
- }
- _xifexpression = _xifexpression_1;
- }
- return _xifexpression;
- }
-
- public String initializationWithDefaultValues(final DataType dt, final int size) {
- String _xblockexpression = null;
- {
- final String dv = this.defaultValue(dt);
- String _xifexpression = null;
- boolean _greaterThan = (size > 1);
- if (_greaterThan) {
- String _xblockexpression_1 = null;
- {
- String res = "{";
- int i = 0;
- boolean _lessThan = (i < size);
- boolean _while = _lessThan;
- while (_while) {
- {
- String _plus = (res + dv);
- res = _plus;
- int _plus_1 = (i + 1);
- i = _plus_1;
- boolean _lessThan_1 = (i < size);
- if (_lessThan_1) {
- String _plus_2 = (res + ",");
- res = _plus_2;
- }
- }
- boolean _lessThan_1 = (i < size);
- _while = _lessThan_1;
- }
- String _plus = (res + "}");
- _xblockexpression_1 = (_plus);
- }
- _xifexpression = _xblockexpression_1;
- } else {
- _xifexpression = dv;
- }
- _xblockexpression = (_xifexpression);
- }
- return _xblockexpression;
- }
-
- public String[] generateArglistAndTypedData(final VarDecl data) {
- String deref = "*";
- boolean _equals = Objects.equal(data, null);
- if (_equals) {
- return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("", "", ""), String.class));
- }
- String _xifexpression = null;
- RefableType _refType = data.getRefType();
- DataType _type = _refType.getType();
- if ((_type instanceof PrimitiveType)) {
- RefableType _refType_1 = data.getRefType();
- DataType _type_1 = _refType_1.getType();
- String _targetName = ((PrimitiveType) _type_1).getTargetName();
- _xifexpression = _targetName;
- } else {
- RefableType _refType_2 = data.getRefType();
- DataType _type_2 = _refType_2.getType();
- String _name = _type_2.getName();
- _xifexpression = _name;
- }
- String typeName = _xifexpression;
- String _xifexpression_1 = null;
- RefableType _refType_3 = data.getRefType();
- DataType _type_3 = _refType_3.getType();
- if ((_type_3 instanceof PrimitiveType)) {
- String _xblockexpression = null;
- {
- RefableType _refType_4 = data.getRefType();
- DataType _type_4 = _refType_4.getType();
- final String ct = ((PrimitiveType) _type_4).getCastName();
- String _xifexpression_2 = null;
- boolean _and = false;
- boolean _notEquals = (!Objects.equal(ct, null));
- if (!_notEquals) {
- _and = false;
- } else {
- boolean _isEmpty = ct.isEmpty();
- boolean _not = (!_isEmpty);
- _and = (_notEquals && _not);
- }
- if (_and) {
- _xifexpression_2 = ct;
- } else {
- _xifexpression_2 = typeName;
- }
- _xblockexpression = (_xifexpression_2);
- }
- _xifexpression_1 = _xblockexpression;
- } else {
- _xifexpression_1 = typeName;
- }
- String castTypeName = _xifexpression_1;
- String _plus = (castTypeName + "*");
- castTypeName = _plus;
- RefableType _refType_4 = data.getRefType();
- boolean _isRef = _refType_4.isRef();
- if (_isRef) {
- String _plus_1 = (typeName + "*");
- typeName = _plus_1;
- String _plus_2 = (castTypeName + "*");
- castTypeName = _plus_2;
- } else {
- RefableType _refType_5 = data.getRefType();
- DataType _type_4 = _refType_5.getType();
- boolean _not = (!(_type_4 instanceof PrimitiveType));
- if (_not) {
- String _plus_3 = (typeName + "*");
- typeName = _plus_3;
- String _plus_4 = (castTypeName + "*");
- castTypeName = _plus_4;
- } else {
- castTypeName = typeName;
- deref = "";
- }
- }
- String _plus_5 = (typeName + " ");
- String _name_1 = data.getName();
- String _plus_6 = (_plus_5 + _name_1);
- String _plus_7 = (_plus_6 + " = ");
- String _plus_8 = (_plus_7 + deref);
- String _plus_9 = (_plus_8 + "((");
- String _plus_10 = (_plus_9 + castTypeName);
- final String typedData = (_plus_10 + ") generic_data);\n");
- String _name_2 = data.getName();
- final String dataArg = (", " + _name_2);
- String _plus_11 = (", " + typeName);
- String _plus_12 = (_plus_11 + " ");
- String _name_3 = data.getName();
- final String typedArgList = (_plus_12 + _name_3);
- return ((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList(dataArg, typedData, typedArgList), String.class));
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
deleted file mode 100644
index 8aff81f..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/DataClassGen.java
+++ /dev/null
@@ -1,846 +0,0 @@
-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.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.Root;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.ComplexType;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomModel;
-import org.eclipse.etrice.core.room.StandardOperation;
-import org.eclipse.etrice.core.room.util.RoomHelpers;
-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.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.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class DataClassGen {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CppExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private TypeHelpers typeHelpers;
-
- @Inject
- private Initialization _initialization;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- this.logger.logInfo("generating code");
- EList<DataClass> _usedDataClasses = root.getUsedDataClasses();
- for (final DataClass dc : _usedDataClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(dc);
- String _path = this.roomExt.getPath(dc);
- String path = (_generationTargetPath + _path);
- String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(dc);
- String _plus = ("generating DataClass 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);
- String _cppHeaderFileName_1 = this.stdExt.getCppHeaderFileName(dc);
- CharSequence _generateHeaderFile = this.generateHeaderFile(root, dc);
- this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
- String _cppSourceFileName = this.stdExt.getCppSourceFileName(dc);
- String _plus_4 = ("generating DataClass 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);
- String _cppSourceFileName_1 = this.stdExt.getCppSourceFileName(dc);
- CharSequence _generateSourceFile = this.generateSourceFile(root, dc);
- this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- public CharSequence generateHeaderFile(final Root root, final DataClass dc) {
- CharSequence _xblockexpression = null;
- {
- EList<StandardOperation> _operations = dc.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 = dc.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();
- String _path = this.roomExt.getPath(dc);
- String _name = dc.getName();
- String _plus = (_path + _name);
- CharSequence _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_plus);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- DataClass _base = dc.getBase();
- boolean _notEquals = (!Objects.equal(_base, null));
- if (_notEquals) {
- _builder.append("#include \"");
- DataClass _base_1 = dc.getBase();
- String _path_1 = this.roomExt.getPath(_base_1);
- _builder.append(_path_1, "");
- DataClass _base_2 = dc.getBase();
- String _name_1 = _base_2.getName();
- _builder.append(_name_1, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(dc);
- for(final DataClass classes : _referencedDataClasses) {
- _builder.append("#include \"");
- String _path_2 = this.roomExt.getPath(classes);
- _builder.append(_path_2, "");
- String _name_2 = classes.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- EList<RoomModel> models = root.getReferencedModels(dc);
- _builder.newLineIfNotEmpty();
- {
- for(final RoomModel model : models) {
- {
- EList<DataClass> _dataClasses = model.getDataClasses();
- for(final DataClass classes_1 : _dataClasses) {
- _builder.append("#include \"");
- String _path_3 = this.roomExt.getPath(classes_1);
- _builder.append(_path_3, "");
- String _name_3 = classes_1.getName();
- _builder.append(_name_3, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.newLine();
- DetailCode _userCode1 = dc.getUserCode1();
- CharSequence _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("class ");
- String _name_4 = dc.getName();
- _builder.append(_name_4, "");
- {
- DataClass _base_3 = dc.getBase();
- boolean _notEquals_1 = (!Objects.equal(_base_3, null));
- if (_notEquals_1) {
- _builder.append(" : public ");
- DataClass _base_4 = dc.getBase();
- String _name_5 = _base_4.getName();
- _builder.append(_name_5, "");
- }
- }
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("public:");
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode2 = dc.getUserCode2();
- CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _attributes_1 = this.helpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes_2 = dc.getAttributes();
- String _name_6 = dc.getName();
- CharSequence _attributeSettersGettersImplementation = this.helpers.attributeSettersGettersImplementation(_attributes_2, _name_6);
- _builder.append(_attributeSettersGettersImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- EList<StandardOperation> _operations_2 = dc.getOperations();
- String _name_7 = dc.getName();
- CharSequence _operationsDeclaration = this.helpers.operationsDeclaration(_operations_2, _name_7);
- _builder.append(_operationsDeclaration, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// default constructor, copy constructor and assignment operator");
- _builder.newLine();
- _builder.append("\t");
- String _name_8 = dc.getName();
- _builder.append(_name_8, " ");
- _builder.append("();");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_9 = dc.getName();
- _builder.append(_name_9, " ");
- _builder.append("(const ");
- String _name_10 = dc.getName();
- _builder.append(_name_10, " ");
- _builder.append("& rhs);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_11 = dc.getName();
- _builder.append(_name_11, " ");
- _builder.append("& operator=(const ");
- String _name_12 = dc.getName();
- _builder.append(_name_12, " ");
- _builder.append("& rhs);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// constructor using fields");
- _builder.newLine();
- _builder.append("\t");
- String _name_13 = dc.getName();
- _builder.append(_name_13, " ");
- _builder.append("(");
- String _argList = this.argList(dc);
- _builder.append(_argList, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- {
- DataClass _base_5 = dc.getBase();
- boolean _notEquals_2 = (!Objects.equal(_base_5, null));
- if (_notEquals_2) {
- _builder.append("\t");
- _builder.append("// constructor using base class constructor");
- _builder.newLine();
- _builder.append("\t");
- String _name_14 = dc.getName();
- _builder.append(_name_14, " ");
- _builder.append("(");
- DataClass _base_6 = dc.getBase();
- String _name_15 = _base_6.getName();
- _builder.append(_name_15, " ");
- _builder.append(" _super, ");
- EList<Attribute> _attributes_3 = dc.getAttributes();
- CharSequence _argListConstructor = this.argListConstructor(_attributes_3);
- String _string = _argListConstructor.toString();
- _builder.append(_string, " ");
- _builder.append(");");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- String _name_16 = dc.getName();
- CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_16);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence generateSourceFile(final Root root, final DataClass dc) {
- CharSequence _xblockexpression = null;
- {
- EList<StandardOperation> _operations = dc.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 = dc.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("/**");
- _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 DataClass ");
- String _name = dc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- _builder.append("#include \"");
- String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(dc);
- _builder.append(_cppHeaderFileName, "");
- _builder.append("\"");
- _builder.newLineIfNotEmpty();
- {
- boolean _isUseEtUnit = GeneratorOptions.isUseEtUnit();
- if (_isUseEtUnit) {
- _builder.append("extern \"C\" {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("#include \"etUnit.h\"");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.newLine();
- DetailCode _userCode3 = dc.getUserCode3();
- CharSequence _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.newLine();
- _builder.append("// default constructor");
- _builder.newLine();
- String _name_1 = dc.getName();
- _builder.append(_name_1, "");
- _builder.append("::");
- String _name_2 = dc.getName();
- _builder.append(_name_2, "");
- _builder.append("() ");
- _builder.newLineIfNotEmpty();
- {
- DataClass _base = dc.getBase();
- boolean _notEquals = (!Objects.equal(_base, null));
- if (_notEquals) {
- _builder.append("\t");
- _builder.append(":");
- DataClass _base_1 = dc.getBase();
- String _name_3 = _base_1.getName();
- _builder.append(_name_3, " ");
- _builder.append("()");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes, false);
- _builder.append(_attributeInitialization, " ");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals_1 = (!Objects.equal(ctor, null));
- if (_notEquals_1) {
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("// user defined constructor body");
- _builder.newLine();
- {
- DetailCode _detailCode = ctor.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String l : _commands) {
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(l, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("// copy constructor");
- _builder.newLine();
- String _name_4 = dc.getName();
- _builder.append(_name_4, "");
- _builder.append("::");
- String _name_5 = dc.getName();
- _builder.append(_name_5, "");
- _builder.append("(const ");
- String _name_6 = dc.getName();
- _builder.append(_name_6, "");
- _builder.append("& rhs)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(":");
- _builder.newLine();
- {
- DataClass _base_2 = dc.getBase();
- boolean _notEquals_2 = (!Objects.equal(_base_2, null));
- if (_notEquals_2) {
- _builder.append("\t");
- DataClass _base_3 = dc.getBase();
- String _name_7 = _base_3.getName();
- _builder.append(_name_7, " ");
- _builder.append("(rhs),");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<Attribute> _attributes_1 = dc.getAttributes();
- boolean _hasElements = false;
- for(final Attribute a : _attributes_1) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- String _name_8 = a.getName();
- _builder.append(_name_8, " ");
- _builder.append("(rhs.");
- String _name_9 = a.getName();
- _builder.append(_name_9, " ");
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("{");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append("// constructor using fields");
- _builder.newLine();
- String _name_10 = dc.getName();
- _builder.append(_name_10, "");
- _builder.append("::");
- String _name_11 = dc.getName();
- _builder.append(_name_11, "");
- _builder.append("(");
- String _argList = this.argList(dc);
- _builder.append(_argList, "");
- _builder.append(") ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(":");
- _builder.newLine();
- {
- DataClass _base_4 = dc.getBase();
- boolean _notEquals_3 = (!Objects.equal(_base_4, null));
- if (_notEquals_3) {
- _builder.append("\t");
- DataClass _base_5 = dc.getBase();
- String _name_12 = _base_5.getName();
- _builder.append(_name_12, " ");
- _builder.append("(");
- DataClass _base_6 = dc.getBase();
- String _paramList = this.paramList(_base_6);
- _builder.append(_paramList, " ");
- _builder.append("),");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<Attribute> _attributes_2 = dc.getAttributes();
- boolean _hasElements_1 = false;
- for(final Attribute a_1 : _attributes_2) {
- if (!_hasElements_1) {
- _hasElements_1 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- String _name_13 = a_1.getName();
- _builder.append(_name_13, " ");
- _builder.append("(");
- String _name_14 = a_1.getName();
- _builder.append(_name_14, " ");
- _builder.append("_)");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("{");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- DataClass _base_7 = dc.getBase();
- boolean _notEquals_4 = (!Objects.equal(_base_7, null));
- if (_notEquals_4) {
- _builder.append("// constructor using base class constructor");
- _builder.newLine();
- String _name_15 = dc.getName();
- _builder.append(_name_15, "");
- _builder.append("::");
- String _name_16 = dc.getName();
- _builder.append(_name_16, "");
- _builder.append("(");
- DataClass _base_8 = dc.getBase();
- String _name_17 = _base_8.getName();
- _builder.append(_name_17, "");
- _builder.append(" _super, ");
- EList<Attribute> _attributes_3 = dc.getAttributes();
- CharSequence _argListConstructor = this.argListConstructor(_attributes_3);
- String _string = _argListConstructor.toString();
- _builder.append(_string, "");
- _builder.append(")");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(":");
- _builder.newLine();
- _builder.append("\t");
- DataClass _base_9 = dc.getBase();
- String _name_18 = _base_9.getName();
- _builder.append(_name_18, " ");
- _builder.append("(_super),");
- _builder.newLineIfNotEmpty();
- {
- EList<Attribute> _attributes_4 = dc.getAttributes();
- boolean _hasElements_2 = false;
- for(final Attribute a_2 : _attributes_4) {
- if (!_hasElements_2) {
- _hasElements_2 = true;
- } else {
- _builder.appendImmediate(",", " ");
- }
- _builder.append("\t");
- String _name_19 = a_2.getName();
- _builder.append(_name_19, " ");
- _builder.append("(");
- String _name_20 = a_2.getName();
- _builder.append(_name_20, " ");
- _builder.append("_)");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("{");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.newLine();
- _builder.append("// assignment operator");
- _builder.newLine();
- String _name_21 = dc.getName();
- _builder.append(_name_21, "");
- _builder.append("& ");
- String _name_22 = dc.getName();
- _builder.append(_name_22, "");
- _builder.append("::operator=(const ");
- String _name_23 = dc.getName();
- _builder.append(_name_23, "");
- _builder.append("& rhs)");
- _builder.newLineIfNotEmpty();
- _builder.append("{\t\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (this == &rhs) { return *this; };");
- _builder.newLine();
- {
- DataClass _base_10 = dc.getBase();
- boolean _notEquals_5 = (!Objects.equal(_base_10, null));
- if (_notEquals_5) {
- _builder.append("\t");
- DataClass _base_11 = dc.getBase();
- String _name_24 = _base_11.getName();
- _builder.append(_name_24, " ");
- _builder.append("::operator=(rhs);");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- EList<Attribute> _attributes_5 = dc.getAttributes();
- for(final Attribute a_3 : _attributes_5) {
- _builder.append("\t");
- String _name_25 = a_3.getName();
- _builder.append(_name_25, " ");
- _builder.append("= rhs.");
- String _name_26 = a_3.getName();
- _builder.append(_name_26, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("return *this;");
- _builder.newLine();
- _builder.append("}\t\t\t");
- _builder.newLine();
- _builder.newLine();
- EList<StandardOperation> _operations_2 = dc.getOperations();
- String _name_27 = dc.getName();
- CharSequence _operationsImplementation = this.helpers.operationsImplementation(_operations_2, _name_27);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public String paramList(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _notEquals = (!Objects.equal(dc, null));
- boolean _while = _notEquals;
- while (_while) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _paramList = this.paramList(_attributes);
- String _string = _paramList.toString();
- String _plus = (_string + result);
- result = _plus;
- DataClass _base = dc.getBase();
- dc = _base;
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- if (_notEquals_1) {
- String _plus_1 = (", " + result);
- result = _plus_1;
- }
- }
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- _while = _notEquals_1;
- }
- return result;
- }
-
- public CharSequence paramList(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _hasElements = false;
- for(final Attribute a : attributes) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- String _name = a.getName();
- _builder.append(_name, "");
- _builder.append("_");
- }
- }
- return _builder;
- }
-
- public String argList(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _notEquals = (!Objects.equal(dc, null));
- boolean _while = _notEquals;
- while (_while) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _argListConstructor = this.argListConstructor(_attributes);
- String _string = _argListConstructor.toString();
- String _plus = (_string + result);
- result = _plus;
- DataClass _base = dc.getBase();
- dc = _base;
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- if (_notEquals_1) {
- String _plus_1 = (", " + result);
- result = _plus_1;
- }
- }
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- _while = _notEquals_1;
- }
- return result;
- }
-
- public CharSequence argListConstructor(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _hasElements = false;
- for(final Attribute a : attributes) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this.typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- {
- int _size = a.getSize();
- boolean _greaterThan = (_size > 1);
- if (_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name = a.getName();
- _builder.append(_name, "");
- _builder.append("_");
- }
- }
- return _builder;
- }
-
- public String deepCopy(final DataClass _dc) {
- String result = "";
- DataClass dc = _dc;
- boolean _notEquals = (!Objects.equal(dc, null));
- boolean _while = _notEquals;
- while (_while) {
- {
- EList<Attribute> _attributes = dc.getAttributes();
- CharSequence _deepCopy = this.deepCopy(_attributes);
- String _string = _deepCopy.toString();
- String _plus = (_string + result);
- result = _plus;
- DataClass _base = dc.getBase();
- dc = _base;
- }
- boolean _notEquals_1 = (!Objects.equal(dc, null));
- _while = _notEquals_1;
- }
- return result;
- }
-
- public CharSequence deepCopy(final List<Attribute> attributes) {
- StringConcatenation _builder = new StringConcatenation();
- {
- for(final Attribute a : attributes) {
- {
- RefableType _refType = a.getRefType();
- DataType _type = _refType.getType();
- if ((_type instanceof ComplexType)) {
- _builder.append("if (");
- String _name = a.getName();
- _builder.append(_name, "");
- _builder.append("!=null) {");
- _builder.newLineIfNotEmpty();
- {
- int _size = a.getSize();
- boolean _equals = (_size == 0);
- if (_equals) {
- _builder.append("\t");
- _builder.append("copy.");
- String _name_1 = a.getName();
- _builder.append(_name_1, " ");
- _builder.append(" = ");
- String _name_2 = a.getName();
- _builder.append(_name_2, " ");
- _builder.append(".deepCopy();");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("\t");
- _builder.append("for (int i=0;i<");
- String _name_3 = a.getName();
- _builder.append(_name_3, " ");
- _builder.append(".length;i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("copy.");
- String _name_4 = a.getName();
- _builder.append(_name_4, " ");
- _builder.append("[i] = ");
- String _name_5 = a.getName();
- _builder.append(_name_5, " ");
- _builder.append("[i].deepCopy();");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- } else {
- {
- int _size_1 = a.getSize();
- boolean _equals_1 = (_size_1 == 0);
- if (_equals_1) {
- _builder.append("copy.");
- String _name_6 = a.getName();
- _builder.append(_name_6, "");
- _builder.append(" = ");
- String _name_7 = a.getName();
- _builder.append(_name_7, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- } else {
- _builder.append("for (int i=0;i<");
- String _name_8 = a.getName();
- _builder.append(_name_8, "");
- _builder.append(".length;i++){");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("copy.");
- String _name_9 = a.getName();
- _builder.append(_name_9, " ");
- _builder.append("[i] = ");
- String _name_10 = a.getName();
- _builder.append(_name_10, " ");
- _builder.append("[i];");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- }
- }
- }
- }
- return _builder;
- }
-}
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
deleted file mode 100644
index 25fb481..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/Initialization.java
+++ /dev/null
@@ -1,297 +0,0 @@
-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/MainGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
deleted file mode 100644
index f2df9e0..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/MainGen.java
+++ /dev/null
@@ -1,60 +0,0 @@
-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.emf.ecore.resource.Resource;
-import org.eclipse.etrice.core.genmodel.etricegen.Root;
-import org.eclipse.etrice.generator.cpp.gen.ActorClassGen;
-import org.eclipse.etrice.generator.cpp.gen.DataClassGen;
-import org.eclipse.etrice.generator.cpp.gen.ProtocolClassGen;
-import org.eclipse.etrice.generator.cpp.gen.SubSystemClassGen;
-import org.eclipse.etrice.generator.cpp.gen.SubSystemRunnerGen;
-import org.eclipse.etrice.generator.generic.PrepareFileSystem;
-import org.eclipse.xtext.generator.IFileSystemAccess;
-import org.eclipse.xtext.generator.IGenerator;
-
-@Singleton
-@SuppressWarnings("all")
-public class MainGen implements IGenerator {
- @Inject
- private DataClassGen dataClassGen;
-
- @Inject
- private ProtocolClassGen protocolClassGen;
-
- @Inject
- private ActorClassGen actorClassGen;
-
- @Inject
- private SubSystemClassGen subsystemClassGen;
-
- @Inject
- private SubSystemRunnerGen subsystemRunnerGen;
-
- @Inject
- private PrepareFileSystem prepFS;
-
- public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
- this.prepFS.prepare(resource);
- EList<EObject> _contents = resource.getContents();
- for (final EObject e : _contents) {
- if ((e instanceof Root)) {
- this.doGenerate(((Root) e));
- }
- }
- }
-
- public void doGenerate(final Root e) {
- this.dataClassGen.doGenerate(e);
- this.protocolClassGen.doGenerate(e);
- this.actorClassGen.doGenerate(e);
- this.subsystemClassGen.doGenerate(e);
- boolean _isLibrary = e.isLibrary();
- boolean _not = (!_isLibrary);
- if (_not) {
- this.subsystemRunnerGen.doGenerate(e);
- }
- }
-}
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
deleted file mode 100644
index f08d2fa..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java
+++ /dev/null
@@ -1,1394 +0,0 @@
-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.Root;
-import org.eclipse.etrice.core.room.Attribute;
-import org.eclipse.etrice.core.room.CommunicationType;
-import org.eclipse.etrice.core.room.DataClass;
-import org.eclipse.etrice.core.room.DataType;
-import org.eclipse.etrice.core.room.DetailCode;
-import org.eclipse.etrice.core.room.GeneralProtocolClass;
-import org.eclipse.etrice.core.room.InterfaceItem;
-import org.eclipse.etrice.core.room.Message;
-import org.eclipse.etrice.core.room.MessageHandler;
-import org.eclipse.etrice.core.room.Port;
-import org.eclipse.etrice.core.room.PortClass;
-import org.eclipse.etrice.core.room.PortOperation;
-import org.eclipse.etrice.core.room.PrimitiveType;
-import org.eclipse.etrice.core.room.ProtocolClass;
-import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
-import org.eclipse.etrice.core.room.VarDecl;
-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.generic.GenericProtocolClassGenerator;
-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.generator.JavaIoFileSystemAccess;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-
-@Singleton
-@SuppressWarnings("all")
-public class ProtocolClassGen extends GenericProtocolClassGenerator {
- @Inject
- private JavaIoFileSystemAccess fileAccess;
-
- @Inject
- private CppExtensions stdExt;
-
- @Inject
- private RoomExtensions roomExt;
-
- @Inject
- private ProcedureHelpers helpers;
-
- @Inject
- private TypeHelpers _typeHelpers;
-
- @Inject
- private Initialization _initialization;
-
- @Inject
- private ILogger logger;
-
- public void doGenerate(final Root root) {
- EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
- for (final ProtocolClass pc : _usedProtocolClasses) {
- {
- String _generationTargetPath = this.roomExt.getGenerationTargetPath(pc);
- String _path = this.roomExt.getPath(pc);
- String path = (_generationTargetPath + _path);
- String _cppHeaderFileName = this.stdExt.getCppHeaderFileName(pc);
- String _plus = ("generating ProtocolClass 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);
- String _cppHeaderFileName_1 = this.stdExt.getCppHeaderFileName(pc);
- CharSequence _generateHeaderFile = this.generateHeaderFile(root, pc);
- this.fileAccess.generateFile(_cppHeaderFileName_1, _generateHeaderFile);
- String _cppSourceFileName = this.stdExt.getCppSourceFileName(pc);
- String _plus_4 = ("generating ProtocolClass 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);
- String _cppSourceFileName_1 = this.stdExt.getCppSourceFileName(pc);
- CharSequence _generateSourceFile = this.generateSourceFile(root, pc);
- this.fileAccess.generateFile(_cppSourceFileName_1, _generateSourceFile);
- }
- }
- }
-
- private CharSequence generateHeaderFile(final Root root, final ProtocolClass pc) {
- 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("* Header File of ProtocolClass ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("* ");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*/");
- _builder.newLine();
- _builder.newLine();
- String _name_1 = pc.getName();
- CharSequence _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
- _builder.append(_generateIncludeGuardBegin, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("#include \"platforms/generic/etDatatypes.h\"");
- _builder.newLine();
- _builder.append("#include \"common/messaging/IRTObject.h\"");
- _builder.newLine();
- _builder.append("#include \"common/modelbase/PortBase.h\"");
- _builder.newLine();
- _builder.append("#include \"common/modelbase/InterfaceItemBase.h\"");
- _builder.newLine();
- _builder.append("#include \"common/messaging/Address.h\"");
- _builder.newLine();
- _builder.append("#include \"common/messaging/Message.h\"");
- _builder.newLine();
- _builder.append("#include <vector>");
- _builder.newLine();
- _builder.append("#include <string>");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("namespace etRuntime {");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("class IEventReceiver;");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- DetailCode _userCode1 = pc.getUserCode1();
- CharSequence _userCode = this.helpers.userCode(_userCode1);
- _builder.append(_userCode, "");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- {
- HashSet<DataClass> _referencedDataClasses = root.getReferencedDataClasses(pc);
- for(final DataClass dataClass : _referencedDataClasses) {
- _builder.append("#include \"");
- String _path = this.roomExt.getPath(dataClass);
- _builder.append(_path, "");
- String _name_2 = dataClass.getName();
- _builder.append(_name_2, "");
- _builder.append(".h\"");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.newLine();
- _builder.append("class ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append(" ");
- _builder.append("public:");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
- if (_equals) {
- _builder.append("\t /* message IDs */");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- String _genMessageIDs = this.genMessageIDs(pc);
- _builder.append(_genMessageIDs, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("static bool isValidEvtID(int evtId) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return ((MSG_MIN < evtId) && (evtId < MSG_MAX));");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("};");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("static bool isValidOutgoingEvtID(int evtId) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return ((MSG_MIN < evtId) && (evtId < ");
- {
- EList<Message> _incomingMessages = pc.getIncomingMessages();
- int _size = _incomingMessages.size();
- boolean _equals_1 = (_size == 0);
- if (_equals_1) {
- _builder.append("MSG_MAX");
- } else {
- _builder.append("IN_");
- EList<Message> _incomingMessages_1 = pc.getIncomingMessages();
- Message _get = _incomingMessages_1.get(0);
- String _name_4 = _get.getName();
- _builder.append(_name_4, " ");
- }
- }
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("};");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("static bool isValidIncomingEvtID(int evtId) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("return ((");
- {
- EList<Message> _incomingMessages_2 = pc.getIncomingMessages();
- int _size_1 = _incomingMessages_2.size();
- boolean _equals_2 = (_size_1 == 0);
- if (_equals_2) {
- _builder.append("MSG_MAX");
- } else {
- _builder.append("IN_");
- EList<Message> _incomingMessages_3 = pc.getIncomingMessages();
- Message _get_1 = _incomingMessages_3.get(0);
- String _name_5 = _get_1.getName();
- _builder.append(_name_5, " ");
- }
- }
- _builder.append(" <= evtId) && (evtId < MSG_MAX));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("};");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("static std::string getMessageString(int msg_id);");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("private:");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("static std::string s_messageStrings[];");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- DetailCode _userCode2 = pc.getUserCode2();
- CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- CharSequence _portClassDeclaration = this.portClassDeclaration(pc, Boolean.valueOf(false));
- _builder.append(_portClassDeclaration, "");
- _builder.newLineIfNotEmpty();
- CharSequence _portClassDeclaration_1 = this.portClassDeclaration(pc, Boolean.valueOf(true));
- _builder.append(_portClassDeclaration_1, "");
- _builder.newLineIfNotEmpty();
- String _name_6 = pc.getName();
- CharSequence _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_6);
- _builder.append(_generateIncludeGuardEnd, "");
- _builder.newLineIfNotEmpty();
- return _builder;
- }
-
- public CharSequence portClassDeclaration(final ProtocolClass pc, final Boolean conj) {
- CharSequence _xblockexpression = null;
- {
- PortClass pclass = this.roomExt.getPortClass(pc, (conj).booleanValue());
- String portClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue());
- String replPortClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue(), true);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// ");
- {
- if ((conj).booleanValue()) {
- _builder.append("conjugated ");
- }
- }
- _builder.append("port class");
- _builder.newLineIfNotEmpty();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("class ");
- _builder.append(portClassName, "");
- _builder.append(" : public etRuntime::PortBase {");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals = (!Objects.equal(pclass, null));
- if (_notEquals) {
- _builder.append("\t");
- DetailCode _userCode = pclass.getUserCode();
- CharSequence _userCode_1 = this.helpers.userCode(_userCode);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append(" ");
- _builder.append("public:");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("// constructors");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append(portClassName, " ");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true); ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t ");
- _builder.append(portClassName, " ");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, etRuntime::Address addr, etRuntime::Address peerAddress, bool doRegistration = true);");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("virtual void receive(etRuntime::Message* m);");
- _builder.newLine();
- {
- boolean _notEquals_1 = (!Objects.equal(pclass, null));
- if (_notEquals_1) {
- _builder.append("\t");
- EList<Attribute> _attributes = pclass.getAttributes();
- CharSequence _attributes_1 = this.helpers.attributes(_attributes);
- _builder.append(_attributes_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- EList<PortOperation> _operations = pclass.getOperations();
- CharSequence _operationsDeclaration = this.helpers.operationsDeclaration(_operations, portClassName);
- _builder.append(_operationsDeclaration, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _outgoing = this.roomExt.getOutgoing(pc, (conj).booleanValue());
- for(final Message m : _outgoing) {
- _builder.append("\t");
- CharSequence _sendMessageDeclaration = this.sendMessageDeclaration(m, (conj).booleanValue());
- _builder.append(_sendMessageDeclaration, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// ");
- {
- if ((conj).booleanValue()) {
- _builder.append("conjugated ");
- }
- }
- _builder.append("replicated port class");
- _builder.newLineIfNotEmpty();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("class ");
- _builder.append(replPortClassName, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("private:");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append("int m_replication;");
- _builder.newLine();
- _builder.append("\t ");
- _builder.append(portClassName, " ");
- _builder.append("* m_ports; //dynamic array used instead of vector to avoid copy construction");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public:");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append(replPortClassName, " ");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<etRuntime::Address> addr, std::vector<etRuntime::Address> peerAddress);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("virtual ~");
- _builder.append(replPortClassName, " ");
- _builder.append("() {};");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("int getReplication() {\treturn m_replication; }");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("int getIndexOf(const etRuntime::InterfaceItemBase& ifitem){ return ifitem.getIdx();\t}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append(portClassName, " ");
- _builder.append(" get(int i) {return m_ports[i];}");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
- if (_equals) {
- _builder.append("\t\t");
- _builder.append(" ");
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _outgoing_1 = this.roomExt.getOutgoing(pc, (conj).booleanValue());
- for(final Message m_1 : _outgoing_1) {
- _builder.append("\t\t");
- CharSequence _sendMessageDeclaration_1 = this.sendMessageDeclaration(m_1, (conj).booleanValue());
- _builder.append(_sendMessageDeclaration_1, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- private CharSequence generateSourceFile(final Root root, final ProtocolClass pc) {
- 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("* Source File of ProtocolClass ");
- String _name = pc.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.stdExt.getCppHeaderFileName(pc);
- _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 <iostream>");
- _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.newLine();
- _builder.append("\t");
- _builder.append("using namespace etRuntime;");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- DetailCode _userCode3 = pc.getUserCode3();
- CharSequence _userCode = this.helpers.userCode(_userCode3);
- _builder.append(_userCode, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- {
- CommunicationType _commType = pc.getCommType();
- boolean _equals = Objects.equal(_commType, CommunicationType.EVENT_DRIVEN);
- if (_equals) {
- _builder.append("\t");
- DetailCode _userCode2 = pc.getUserCode2();
- CharSequence _userCode_1 = this.helpers.userCode(_userCode2);
- _builder.append(_userCode_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- CharSequence _portClassImplementation = this.portClassImplementation(pc, Boolean.valueOf(false));
- _builder.append(_portClassImplementation, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- CharSequence _portClassImplementation_1 = this.portClassImplementation(pc, Boolean.valueOf(true));
- _builder.append(_portClassImplementation_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/*--------------------- debug helpers */");
- _builder.newLine();
- _builder.append("\t");
- CharSequence _generateDebugHelpersImplementation = this.generateDebugHelpersImplementation(root, pc);
- _builder.append(_generateDebugHelpersImplementation, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence portClassImplementation(final ProtocolClass pc, final Boolean conj) {
- CharSequence _xblockexpression = null;
- {
- PortClass pclass = this.roomExt.getPortClass(pc, (conj).booleanValue());
- String portClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue());
- String replPortClassName = this.roomExt.getPortClassName(pc, (conj).booleanValue(), true);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// ");
- {
- if ((conj).booleanValue()) {
- _builder.append("conjugated ");
- }
- }
- _builder.append("port class");
- _builder.newLineIfNotEmpty();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.newLine();
- _builder.append(portClassName, "");
- _builder.append("::");
- _builder.append(portClassName, "");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, Address addr, Address peerAddress, bool doRegistration)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(": ");
- CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(pclass, "0");
- _builder.append(_generateConstructorInitalizerList, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- {
- boolean _notEquals = (!Objects.equal(pclass, null));
- if (_notEquals) {
- EList<Attribute> _attributes = pclass.getAttributes();
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes, false);
- _builder.append(_attributeInitialization, " ");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (doRegistration) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- _builder.append(portClassName, "");
- _builder.append("::");
- _builder.append(portClassName, "");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, int idx, Address addr, Address peerAddress, bool doRegistration)");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(": ");
- CharSequence _generateConstructorInitalizerList_1 = this.generateConstructorInitalizerList(pclass, "idx");
- _builder.append(_generateConstructorInitalizerList_1, " ");
- _builder.newLineIfNotEmpty();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- {
- boolean _notEquals_1 = (!Objects.equal(pclass, null));
- if (_notEquals_1) {
- EList<Attribute> _attributes_1 = pclass.getAttributes();
- CharSequence _attributeInitialization_1 = this._initialization.attributeInitialization(_attributes_1, false);
- _builder.append(_attributeInitialization_1, " ");
- }
- }
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (doRegistration) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("DebuggingService::getInstance().addPortInstance(*this);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("void ");
- _builder.append(portClassName, "");
- _builder.append("::receive(Message* msg) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (! ");
- String _name = pc.getName();
- _builder.append(_name, " ");
- _builder.append("::");
- {
- if ((conj).booleanValue()) {
- _builder.append("isValidOutgoingEvtID");
- } else {
- _builder.append("isValidIncomingEvtID");
- }
- }
- _builder.append("(msg->getEvtId())) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("std::cout << \"unknown\" << std::endl;");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("else {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("if (msg->hasDebugFlagSet()) {\t\t\t// TODO: model switch for activation of this flag");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), ");
- String _name_1 = pc.getName();
- _builder.append(_name_1, " ");
- _builder.append("::getMessageString(msg->getEvtId()));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.newLine();
- {
- boolean _handlesReceive = this.roomExt.handlesReceive(pc, (conj).booleanValue());
- if (_handlesReceive) {
- _builder.append("\t\t");
- _builder.append("switch (msg->getEvtId()) {");
- _builder.newLine();
- {
- List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(pc, (conj).booleanValue());
- for(final MessageHandler hdlr : _receiveHandlers) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("case ");
- String _name_2 = pc.getName();
- _builder.append(_name_2, " ");
- _builder.append("::");
- Message _msg = hdlr.getMsg();
- String _codeName = this.roomExt.getCodeName(_msg);
- _builder.append(_codeName, " ");
- _builder.append(":");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("{");
- _builder.newLine();
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("\t");
- _builder.append("break;");
- _builder.newLine();
- }
- }
- _builder.append("\t\t");
- _builder.append("\t");
- _builder.append("default:");
- _builder.newLine();
- }
- }
- _builder.append("\t\t\t\t");
- _builder.append("getActor().receiveEvent(this, msg->getEvtId(),\tmsg->getData());");
- _builder.newLine();
- {
- boolean _handlesReceive_1 = this.roomExt.handlesReceive(pc, (conj).booleanValue());
- if (_handlesReceive_1) {
- _builder.append("\t\t");
- _builder.append("\t\t");
- _builder.append("break;");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _notEquals_2 = (!Objects.equal(pclass, null));
- if (_notEquals_2) {
- EList<PortOperation> _operations = pclass.getOperations();
- CharSequence _operationsImplementation = this.helpers.operationsImplementation(_operations, portClassName);
- _builder.append(_operationsImplementation, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t");
- _builder.newLine();
- _builder.append("// sent messages");
- _builder.newLine();
- {
- List<Message> _outgoing = this.roomExt.getOutgoing(pc, (conj).booleanValue());
- for(final Message m : _outgoing) {
- String _name_3 = pc.getName();
- CharSequence _sendMessage = this.sendMessage(m, _name_3, portClassName, (conj).booleanValue());
- _builder.append(_sendMessage, "");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.newLine();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append("// ");
- {
- if ((conj).booleanValue()) {
- _builder.append("conjugated ");
- }
- }
- _builder.append("replicated port class");
- _builder.newLineIfNotEmpty();
- _builder.append("//------------------------------------------------------------------------------------------------------------");
- _builder.newLine();
- _builder.append(replPortClassName, "");
- _builder.append("::");
- _builder.append(replPortClassName, "");
- _builder.append("(etRuntime::IEventReceiver& actor, etRuntime::IRTObject* parent, std::string name, int localId, std::vector<Address> addr, std::vector<Address> peerAddress) ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append(": m_replication(addr.size()),");
- _builder.newLine();
- _builder.append(" \t ");
- _builder.append("m_ports()");
- _builder.newLine();
- _builder.append("{");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("char numstr[10]; // enough to hold all numbers up to 32-bits");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("m_ports = reinterpret_cast<");
- _builder.append(portClassName, " ");
- _builder.append("*> (new char[sizeof(");
- _builder.append(portClassName, " ");
- _builder.append(") * addr.size()]);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (int i = 0; i < m_replication; ++i) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("snprintf(numstr, sizeof(numstr), \"%d\", i);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("//placement new to avoid copy construction, therefore no vector is used");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("new (&m_ports[i]) ");
- _builder.append(portClassName, " ");
- _builder.append("(actor, parent, name + numstr, localId, i, addr[i], peerAddress[i]);");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- _builder.append("// outgoing messages");
- _builder.newLine();
- {
- List<Message> _outgoing_1 = this.roomExt.getOutgoing(pc, (conj).booleanValue());
- for(final Message m_1 : _outgoing_1) {
- CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m_1, replPortClassName);
- _builder.append(_messageSignatureDefinition, "");
- _builder.append("{");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("for (int i=0; i<m_replication; ++i) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("m_ports[i].");
- CharSequence _messageCall = this.messageCall(m_1);
- _builder.append(_messageCall, " ");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence generateConstructorInitalizerList(final PortClass pc, final String index) {
- ArrayList<CharSequence> _arrayList = new ArrayList<CharSequence>();
- ArrayList<CharSequence> initializerList = _arrayList;
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("PortBase(actor, parent, name, localId, ");
- _builder.append(index, "");
- _builder.append(", addr, peerAddress)");
- initializerList.add(_builder);
- boolean _notEquals = (!Objects.equal(pc, null));
- if (_notEquals) {
- EList<Attribute> _attributes = pc.getAttributes();
- for (final Attribute attrib : _attributes) {
- CharSequence _attributeInitialization = this._initialization.attributeInitialization(attrib, false);
- initializerList.add(_attributeInitialization);
- }
- }
- StringConcatenation _builder_1 = new StringConcatenation();
- String _join = IterableExtensions.join(initializerList, ",\n");
- _builder_1.append(_join, "");
- _builder_1.newLineIfNotEmpty();
- return _builder_1;
- }
-
- private CharSequence messageCall(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- if (_notEquals) {
- _builder.append(" ");
- VarDecl _data_1 = m.getData();
- String _name_1 = _data_1.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- private CharSequence generateDebugHelpersImplementation(final Root root, final ProtocolClass pc) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.newLine();
- _builder.append("/* message names as strings for debugging (generate MSC) */");
- _builder.newLine();
- _builder.append("std::string ");
- String _name = pc.getName();
- _builder.append(_name, "");
- _builder.append("::s_messageStrings[] ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("= {\"MIN\", ");
- _builder.newLine();
- {
- List<Message> _allOutgoingMessages = this.roomExt.getAllOutgoingMessages(pc);
- for(final Message m : _allOutgoingMessages) {
- _builder.append("\t\t ");
- _builder.append("\"");
- String _name_1 = m.getName();
- _builder.append(_name_1, " ");
- _builder.append("\",");
- _builder.newLineIfNotEmpty();
- }
- }
- {
- List<Message> _allIncomingMessages = this.roomExt.getAllIncomingMessages(pc);
- for(final Message m_1 : _allIncomingMessages) {
- _builder.append("\t\t ");
- _builder.append("\"");
- String _name_2 = m_1.getName();
- _builder.append(_name_2, " ");
- _builder.append("\",");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t\t ");
- _builder.append("\"MAX\"};");
- _builder.newLine();
- _builder.newLine();
- _builder.append("std::string ");
- String _name_3 = pc.getName();
- _builder.append(_name_3, "");
- _builder.append("::getMessageString(int msg_id) {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return s_messageStrings[msg_id];");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("} else {");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("// id out of range");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("return \"Message ID out of range\";");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- return _builder;
- }
-
- public CharSequence messageSignature(final Message m) {
- StringConcatenation _builder = new StringConcatenation();
- {
- boolean _isPriv = m.isPriv();
- if (_isPriv) {
- _builder.append("private:");
- } else {
- _builder.append("public:");
- }
- }
- _builder.append(" void ");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- if (_notEquals) {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- _builder.append(" ");
- VarDecl _data_2 = m.getData();
- String _name_1 = _data_2.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- public CharSequence messageSignatureExplicit(final Message m) {
- CharSequence _xblockexpression = null;
- {
- VarDecl _data = m.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- DataClass dc = ((DataClass) _type);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("public: void ");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- DataClass _base = dc.getBase();
- boolean _notEquals = (!Objects.equal(_base, null));
- if (_notEquals) {
- DataClass _base_1 = dc.getBase();
- String _typeName = this._typeHelpers.typeName(_base_1);
- _builder.append(_typeName, "");
- _builder.append(" _super, ");
- }
- }
- {
- EList<Attribute> _attributes = dc.getAttributes();
- boolean _hasElements = false;
- for(final Attribute a : _attributes) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- 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 = a.getSize();
- boolean _greaterThan = (_size > 1);
- if (_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_1 = a.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence messageSignatureDefinition(final Message m, final String classPrefix) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("void ");
- _builder.append(classPrefix, "");
- _builder.append("::");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- if (_notEquals) {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- _builder.append(" ");
- VarDecl _data_2 = m.getData();
- String _name_1 = _data_2.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- return _builder;
- }
-
- public CharSequence messageSignatureExplicitDefinition(final Message m, final String classPrefix) {
- CharSequence _xblockexpression = null;
- {
- VarDecl _data = m.getData();
- RefableType _refType = _data.getRefType();
- DataType _type = _refType.getType();
- DataClass dc = ((DataClass) _type);
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("void ");
- _builder.append(classPrefix, "");
- _builder.append("::");
- String _name = m.getName();
- _builder.append(_name, "");
- _builder.append("(");
- {
- DataClass _base = dc.getBase();
- boolean _notEquals = (!Objects.equal(_base, null));
- if (_notEquals) {
- DataClass _base_1 = dc.getBase();
- String _typeName = this._typeHelpers.typeName(_base_1);
- _builder.append(_typeName, "");
- _builder.append(" _super, ");
- }
- }
- {
- EList<Attribute> _attributes = dc.getAttributes();
- boolean _hasElements = false;
- for(final Attribute a : _attributes) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", "");
- }
- 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 = a.getSize();
- boolean _greaterThan = (_size > 1);
- if (_greaterThan) {
- _builder.append("[]");
- }
- }
- _builder.append(" ");
- String _name_1 = a.getName();
- _builder.append(_name_1, "");
- }
- }
- _builder.append(")");
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public CharSequence sendMessageDeclaration(final Message m, final boolean conj) {
- StringConcatenation _builder = new StringConcatenation();
- CharSequence _messageSignature = this.messageSignature(m);
- _builder.append(_messageSignature, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- {
- boolean _and = false;
- VarDecl _data = m.getData();
- boolean _notEquals = (!Objects.equal(_data, null));
- if (!_notEquals) {
- _and = false;
- } else {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- DataType _type = _refType.getType();
- _and = (_notEquals && (_type instanceof DataClass));
- }
- if (_and) {
- CharSequence _messageSignatureExplicit = this.messageSignatureExplicit(m);
- _builder.append(_messageSignatureExplicit, "");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
- }
- }
- return _builder;
- }
-
- public CharSequence sendMessage(final Message m, final String portClassName, final String classPrefix, final boolean conj) {
- CharSequence _xblockexpression = null;
- {
- String _xifexpression = null;
- if (conj) {
- _xifexpression = "IN";
- } else {
- _xifexpression = "OUT";
- }
- String dir = _xifexpression;
- MessageHandler hdlr = this.roomExt.getSendHandler(m, conj);
- StringConcatenation _builder = new StringConcatenation();
- CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m, classPrefix);
- _builder.append(_messageSignatureDefinition, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- {
- boolean _notEquals = (!Objects.equal(hdlr, null));
- if (_notEquals) {
- _builder.append("\t");
- {
- DetailCode _detailCode = hdlr.getDetailCode();
- EList<String> _commands = _detailCode.getCommands();
- for(final String command : _commands) {
- _builder.append("\t");
- _builder.append(command, " ");
- _builder.newLineIfNotEmpty();
- }
- }
- } else {
- _builder.append("\t");
- _builder.append("DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t\t\t\t\t\t\t\t\t\t\t\t ");
- _builder.append(portClassName, " ");
- _builder.append("::getMessageString(");
- _builder.append(portClassName, " ");
- _builder.append("::");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name = m.getName();
- _builder.append(_name, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("if (getPeerAddress().isValid()){");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("\t");
- {
- VarDecl _data = m.getData();
- boolean _equals = Objects.equal(_data, null);
- if (_equals) {
- _builder.append("getPeerMsgReceiver()->receive(new Message(getPeerAddress(), ");
- _builder.append(portClassName, " ");
- _builder.append("::");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name_1 = m.getName();
- _builder.append(_name_1, " ");
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- } else {
- _builder.append("getPeerMsgReceiver()->receive(new Message(getPeerAddress(),");
- _builder.append(portClassName, " ");
- _builder.append("::");
- _builder.append(dir, " ");
- _builder.append("_");
- String _name_2 = m.getName();
- _builder.append(_name_2, " ");
- _builder.append(", ");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(" ");
- _builder.append("reinterpret_cast<void*>(");
- {
- boolean _and = false;
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- boolean _isRef = _refType.isRef();
- boolean _not = (!_isRef);
- if (!_not) {
- _and = false;
- } else {
- VarDecl _data_2 = m.getData();
- RefableType _refType_1 = _data_2.getRefType();
- DataType _type = _refType_1.getType();
- boolean _not_1 = (!(_type instanceof PrimitiveType));
- _and = (_not && _not_1);
- }
- if (_and) {
- _builder.append("&");
- }
- }
- VarDecl _data_3 = m.getData();
- String _name_3 = _data_3.getName();
- _builder.append(_name_3, " ");
- _builder.append("),");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.append("\t");
- _builder.append(" ");
- _builder.append("sizeof(");
- VarDecl _data_4 = m.getData();
- RefableType _refType_2 = _data_4.getRefType();
- DataType _type_1 = _refType_2.getType();
- String _typeName = this._typeHelpers.typeName(_type_1);
- _builder.append(_typeName, " ");
- _builder.append(")));");
- _builder.newLineIfNotEmpty();
- }
- }
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
- }
- }
- _builder.append("}");
- _builder.newLine();
- _builder.newLine();
- {
- boolean _and_1 = false;
- VarDecl _data_5 = m.getData();
- boolean _notEquals_1 = (!Objects.equal(_data_5, null));
- if (!_notEquals_1) {
- _and_1 = false;
- } else {
- VarDecl _data_6 = m.getData();
- RefableType _refType_3 = _data_6.getRefType();
- DataType _type_2 = _refType_3.getType();
- _and_1 = (_notEquals_1 && (_type_2 instanceof DataClass));
- }
- if (_and_1) {
- CharSequence _messageSignatureExplicitDefinition = this.messageSignatureExplicitDefinition(m, classPrefix);
- _builder.append(_messageSignatureExplicitDefinition, "");
- _builder.append(" {");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- String _name_4 = m.getName();
- _builder.append(_name_4, " ");
- _builder.append("(");
- VarDecl _data_7 = m.getData();
- RefableType _refType_4 = _data_7.getRefType();
- DataType _type_3 = _refType_4.getType();
- String _name_5 = _type_3.getName();
- _builder.append(_name_5, " ");
- _builder.append("(");
- {
- VarDecl _data_8 = m.getData();
- RefableType _refType_5 = _data_8.getRefType();
- DataType _type_4 = _refType_5.getType();
- DataClass _base = ((DataClass) _type_4).getBase();
- boolean _notEquals_2 = (!Objects.equal(_base, null));
- if (_notEquals_2) {
- _builder.append("_super, ");
- }
- }
- {
- VarDecl _data_9 = m.getData();
- RefableType _refType_6 = _data_9.getRefType();
- DataType _type_5 = _refType_6.getType();
- EList<Attribute> _attributes = ((DataClass) _type_5).getAttributes();
- boolean _hasElements = false;
- for(final Attribute a : _attributes) {
- if (!_hasElements) {
- _hasElements = true;
- } else {
- _builder.appendImmediate(", ", " ");
- }
- String _name_6 = a.getName();
- _builder.append(_name_6, " ");
- }
- }
- _builder.append("));");
- _builder.newLineIfNotEmpty();
- _builder.append("}");
- _builder.newLine();
- }
- }
- _xblockexpression = (_builder);
- }
- return _xblockexpression;
- }
-
- public String getMessageID(final Message msg, final InterfaceItem item) {
- if ((item instanceof Port)) {
- Port p = ((Port) item);
- String _xifexpression = null;
- boolean _isConjugated = p.isConjugated();
- if (_isConjugated) {
- _xifexpression = "OUT_";
- } else {
- _xifexpression = "IN_";
- }
- String direction = _xifexpression;
- GeneralProtocolClass _protocol = p.getProtocol();
- String _name = _protocol.getName();
- String _name_1 = msg.getName();
- String _plus = (direction + _name_1);
- return this.enumInUse(_name, _plus);
- } else {
- if ((item instanceof SAPRef)) {
- SAPRef sap = ((SAPRef) item);
- ProtocolClass _protocol_1 = sap.getProtocol();
- String _name_2 = _protocol_1.getName();
- String _name_3 = msg.getName();
- String _plus_1 = ("OUT_" + _name_3);
- return this.enumInUse(_name_2, _plus_1);
- } else {
- if ((item instanceof SPPRef)) {
- SPPRef spp = ((SPPRef) item);
- ProtocolClass _protocol_2 = spp.getProtocol();
- String _name_4 = _protocol_2.getName();
- String _name_5 = msg.getName();
- String _plus_2 = ("IN_" + _name_5);
- return this.enumInUse(_name_4, _plus_2);
- }
- }
- }
- return "unknown interface item";
- }
-
- public String enumInUse(final String namespace, final String member) {
- String _plus = (namespace + "::");
- return (_plus + member);
- }
-}
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
deleted file mode 100644
index d0ea74d..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/StateMachineGen.java
+++ /dev/null
@@ -1,143 +0,0 @@
-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
deleted file mode 100644
index 368d980..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemClassGen.java
+++ /dev/null
@@ -1,930 +0,0 @@
-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
deleted file mode 100644
index b84ba20..0000000
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/SubSystemRunnerGen.java
+++ /dev/null
@@ -1,263 +0,0 @@
-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/runtime/org.eclipse.etrice.modellib.cpp/build.txt b/runtime/org.eclipse.etrice.modellib.cpp/build.txt
new file mode 100644
index 0000000..eb4e12e
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.cpp/build.txt
@@ -0,0 +1,6 @@
+../../src-gen/HandlerTest/HandlerUser.cpp: In member function 'int HandlerUser::executeTransitionChain(int, const etRuntime::InterfaceItemBase*, void*)':
+../../src-gen/HandlerTest/HandlerUser.cpp:324:10: warning: unused variable 'p1' [-Wunused-variable]
+../../src-gen/HandlerTest/Tester.cpp: In member function 'virtual void Tester::receiveEvent(etRuntime::InterfaceItemBase*, int, void*)':
+../../src-gen/HandlerTest/Tester.cpp:142:6: warning: unused variable 'trigger' [-Wunused-variable]
+../../src-gen/ChoicePointTest/CPTester.cpp: In member function 'virtual void CPTester::receiveEvent(etRuntime::InterfaceItemBase*, int, void*)':
+../../src-gen/ChoicePointTest/CPTester.cpp:135:6: warning: unused variable 'trigger' [-Wunused-variable]
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room b/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room
index 1c13eb3..79eebdb 100644
--- a/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room
+++ b/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room
@@ -277,7 +277,7 @@ RoomModel room.basic.service.timing {
status=0;
}
// msg to fsm
- getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
}
"
}
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp
index e8efe9e..4e306ec 100644
--- a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp
+++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp
@@ -20,6 +20,10 @@ tcbs(),
usedTcbsRoot(0),
freeTcbsRoot(0)
{
+ history = new int[s_numberOfStates];
+ for (int i = 0; i < s_numberOfStates; i++) {
+ history[i] = NO_STATE;
+ }
setClassName("ATimingService");
// initialize attributes
for (int i=0;i<10;i++){
@@ -47,8 +51,8 @@ void ATimingService::destroy(){
std::string ATimingService::s_stateStrings[] = {"<no state>","<top>","Operational"
};
+const int ATimingService::s_numberOfStates = 3;
-
void ATimingService::setState(int new_state) {
DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state]);
if (s_stateStrings[new_state]!="Idle") {
@@ -204,8 +208,8 @@ int ATimingService::enterHistory(int state, bool handler, bool skip_entry) {
void ATimingService::executeInitTransition() {
int chain = CHAIN_TRANS_INITIAL_TO__Operational;
- int next = executeTransitionChain(chain, 0, 0);
- next = enterHistory(next, false, false);
+ int next = ATimingService::executeTransitionChain(chain, 0, 0);
+ next = ATimingService::enterHistory(next, false, false);
setState(next);
}
@@ -247,9 +251,9 @@ void ATimingService::receiveEvent(InterfaceItemBase* ifitem, int evt, void* gene
}
}
if (chain != NOT_CAUGHT) {
- exitTo(getState(), catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
+ ATimingService::exitTo(getState(), catching_state, is_handler);
+ int next = ATimingService::executeTransitionChain(chain, ifitem, generic_data);
+ next = ATimingService::enterHistory(next, is_handler, skip_entry);
setState(next);
}
}
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h
index de34e57..035b8cd 100644
--- a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h
+++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h
@@ -203,8 +203,7 @@
protected:
static std::string s_stateStrings[];
-
- int history[];
+ static const int s_numberOfStates;
private:
void setState(int new_state);
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp
index 9b4aa26..4a8b04b 100644
--- a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp
+++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp
@@ -45,7 +45,7 @@
DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), PTimer::getMessageString(msg->getEvtId()));
}
- getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
}
};
@@ -128,12 +128,12 @@
status=0;
}
// msg to fsm
- getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
}
}
break;
default:
- getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
break;
}
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
index 1759303..dd17958 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/debugging/DebuggingService.cpp
@@ -26,26 +26,26 @@ DebuggingService::~DebuggingService() {
void DebuggingService::addMessageAsyncOut(Address source, Address target,
std::string msg) {
- asyncLogger.addMessageAsyncOut(portInstances.at(source)->getActorRTObject().getInstancePath(),
- portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
+ asyncLogger.addMessageAsyncOut(portInstances.at(source)->getActorPath(),
+ portInstances.at(target)->getActorPath(), msg);
}
void DebuggingService::addMessageAsyncIn(Address source, Address target,
std::string msg) {
- asyncLogger.addMessageAsyncIn(portInstances.at(source)->getActorRTObject().getInstancePath(),
- portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
+ asyncLogger.addMessageAsyncIn(portInstances.at(source)->getActorPath(),
+ portInstances.at(target)->getActorPath(), msg);
}
void DebuggingService::addMessageSyncCall(Address source, Address target,
std::string msg) {
- asyncLogger.addMessageSyncCall(portInstances.at(source)->getActorRTObject().getInstancePath(),
- portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
+ asyncLogger.addMessageSyncCall(portInstances.at(source)->getActorPath(),
+ portInstances.at(target)->getActorPath(), msg);
}
void DebuggingService::addMessageSyncReturn(Address source, Address target,
std::string msg) {
- asyncLogger.addMessageSyncReturn(portInstances.at(source)->getActorRTObject().getInstancePath(),
- portInstances.at(target)->getActorRTObject().getInstancePath(), msg);
+ asyncLogger.addMessageSyncReturn(portInstances.at(source)->getActorPath(),
+ portInstances.at(target)->getActorPath(), msg);
}
void DebuggingService::addActorState(const ActorClassBase& actor,
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
index 264b4fb..ae1a4ea 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp
@@ -6,9 +6,21 @@
*/
#include "MessageService.h"
+#include <iostream>
+#include <unistd.h>
namespace etRuntime {
+extern "C" {
+ void* threadStarter(void* arg) {
+ MessageService* thisPtr = static_cast<MessageService*>(arg);
+ std::cout << "Thread " << thisPtr->getName() << " is started." << std::endl;
+ thisPtr->run();
+ return arg;
+ // pthread_exit(NULL);
+ }
+}
+
MessageService::MessageService(IRTObject* parent, Address addr, std::string name, int priority)
: // super("MessageService "+name),
IMessageReceiver(),
@@ -16,6 +28,11 @@ MessageService::MessageService(IRTObject* parent, Address addr, std::string name
m_parent(parent),
m_name(name),
m_running(false),
+ m_thread(),
+ m_mutex(),
+ m_mutexAttr(),
+ m_conditionVar(),
+ m_threadAttr(),
m_messageQueue(this, "Queue"),
m_messageDispatcher( this,
Address(addr.m_nodeID, addr.m_threadID, addr.m_objectID + 1),
@@ -24,6 +41,12 @@ MessageService::MessageService(IRTObject* parent, Address addr, std::string name
m_lastMessageTimestamp(0),
m_asyncActors()
{
+ pthread_mutexattr_init(&m_mutexAttr);
+ pthread_mutexattr_settype(&m_mutexAttr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&m_mutex, &m_mutexAttr);
+ pthread_cond_init (&m_conditionVar, NULL);
+ pthread_attr_init(&m_threadAttr);
+ pthread_attr_setdetachstate(&m_threadAttr, PTHREAD_CREATE_JOINABLE);
// check and set priority
// assert priority >= Thread.MIN_PRIORITY : ("priority smaller than Thread.MIN_PRIORITY (1)");
@@ -34,29 +57,61 @@ MessageService::MessageService(IRTObject* parent, Address addr, std::string name
MessageService::~MessageService() {
m_parent = 0;
+ pthread_attr_destroy(&m_threadAttr);
+ pthread_mutex_destroy(&m_mutex);
+ pthread_cond_destroy(&m_conditionVar);
+ pthread_exit(NULL);
+
+}
+
+void MessageService::start(bool singlethreaded) {
+ if (singlethreaded) {
+ std::cout << "starting message service " << m_name << " singlethreaded" << std::endl;
+ }
+ else {
+ std::cout << "starting message service " << m_name << " on own thread" << std::endl;
+ int rc = pthread_create(&m_thread, &m_threadAttr, threadStarter, static_cast<void *>(this));
+ if (rc){
+ std::cout << "ERROR; return code from pthread_create() is " << rc << std::endl;
+ exit(-1);
+ }
+ }
}
+void MessageService::join() {
+ void *status;
+ int rc = pthread_join(m_thread, &status);
+ if (rc){
+ std::cout << "ERROR; return code from pthread_join() is " << rc << std::endl;
+ exit(-1);
+ }
+}
void MessageService::run() {
m_running = true;
while (m_running) {
pollOneMessage();
+ usleep(10000);
}
+ std::cout << "ending message service " << m_name << " on own thread" << std::endl;
}
void MessageService::runOnce() {
pollAsyncActors();
while (m_messageQueue.isNotEmpty()){
- pollOneMessage();
+ Message* msg = m_messageQueue.pop(); // get next Message from Queue
+ if (msg != 0) {
+ m_messageDispatcher.receive(msg);
+ }
}
}
-//TODO: synchronized
void MessageService::receive(Message* msg) {
+ pthread_mutex_lock(&m_mutex);
if (msg != 0) {
m_messageQueue.push(msg);
- //TODO
- //notifyAll(); // wake up thread to compute message
+ pthread_cond_signal(&m_conditionVar); // wake up thread to compute message
}
+ pthread_mutex_unlock(&m_mutex);
}
std::string MessageService::getInstancePath() const {
@@ -79,27 +134,26 @@ std::string MessageService::getInstancePathName() const {
// TODO: synchronized
void MessageService::terminate() {
+ pthread_mutex_lock(&m_mutex);
if (m_running) {
m_running = false;
- //TODO:
- // notifyAll();
+ pthread_cond_signal(&m_conditionVar); // wake up thread to terminate
}
+ pthread_mutex_unlock(&m_mutex);
}
-//TODO: synchronized
+
void MessageService::pollOneMessage() {
+ pthread_mutex_lock(&m_mutex);
Message* msg = m_messageQueue.pop(); // get next Message from Queue
if (msg == 0) {
- //TODO:
// no message in queue -> wait till Thread is notified
-// try {
-// wait();
-// } catch (InterruptedException e) {
-// }
+ pthread_cond_wait(&m_conditionVar, &m_mutex);
} else {
//TODO: set timestamp
// m_lastMessageTimestamp = System.currentTimeMillis();
m_messageDispatcher.receive(msg);
}
+ pthread_mutex_unlock(&m_mutex);
}
@@ -115,5 +169,4 @@ void MessageService::pollAsyncActors() {
}
}
-
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
index a9d25cb..6eb6ae6 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h
@@ -10,6 +10,7 @@
#include <string>
#include <vector>
+#include <pthread.h>
#include "common/messaging/MessageDispatcher.h"
#include "common/messaging/Address.h"
#include "common/modelbase/IEventReceiver.h"
@@ -17,7 +18,7 @@
namespace etRuntime {
-//TODO: implementation missing yet for threads
+//TODO: abstraction from posix threads missing
class MessageService: public IMessageReceiver, public IRTObject {
public:
@@ -25,16 +26,18 @@ public:
virtual ~MessageService();
Address getAddress() const { return m_address; } ;
+ std::string getName() const { return m_name; };
+
+ void start(bool singlethreaded);
void run();
- //TODO: for single threaded configuration only
+ // for single threaded configuration only
void runOnce();
- //TODO: synchronized
+ void join();
void terminate();
- //TODO: synchronized
void receive(Message* msg);
- //TODO: synchronized
+
virtual MessageDispatcher& getMessageDispatcher() { return m_messageDispatcher; }
virtual std::string getInstancePath() const ;
virtual std::string getInstancePathName() const ;
@@ -47,7 +50,6 @@ public:
// protected methods for sole use by test cases
protected:
MessageSeQueue& getMessageQueue() { return m_messageQueue; }
- //TODO: synchronized
long getLastMessageTimestamp() const { return m_lastMessageTimestamp; }
private:
@@ -57,6 +59,11 @@ private:
IRTObject* m_parent;
std::string m_name;
bool m_running;
+ pthread_t m_thread;
+ pthread_mutex_t m_mutex;
+ pthread_mutexattr_t m_mutexAttr;
+ pthread_cond_t m_conditionVar;
+ pthread_attr_t m_threadAttr;
// TODO: add internal message queue for less locks (faster thread internal
// messaging)
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
index e095ed0..ad6d7b1 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.cpp
@@ -43,31 +43,28 @@ void MessageServiceController::connectAll() {
}
}
-void MessageServiceController::start() {
+void MessageServiceController::start(bool singlethreaded) {
// start all message services
for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
it != m_messageServiceList.end(); ++it) {
- //TODO start thread
- //msgSvc.start();
+ (*it)->start(singlethreaded);
// TODOTS: start in order of priorities
}
m_running = true;
}
-void MessageServiceController::stop() {
+void MessageServiceController::stop(bool singlethreaded) {
//dumpThreads("org.eclipse.etrice.runtime.java.messaging.MessageServiceController.stop()");
- terminate();
- waitTerminate();
+ if (! singlethreaded) {
+ terminate();
+ waitTerminate();
+ }
}
void MessageServiceController::waitTerminate() {
for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
it != m_messageServiceList.end(); ++it) {
- //try {
- //TODO thread join
- //msgSvc.join();
- //} catch (InterruptedException e1) {
- //}
+ (*it)->join();
}
}
@@ -98,8 +95,7 @@ void MessageServiceController::terminate() {
// terminate all message services
for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
it != m_messageServiceList.end(); ++it) {
- //TODO: terminate thread
- //msgSvc.terminate();
+ (*it)->terminate();
// TODOTS: stop in order of priorities
}
}
@@ -108,9 +104,7 @@ void MessageServiceController::runOnce() {
if (!m_running) {
return;
}
- //m_running = false;
- // terminate all message services
for (std::vector<MessageService*>::iterator it = m_messageServiceList.begin();
it != m_messageServiceList.end(); ++it) {
(*it)->runOnce();
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
index a066883..8ea6bf3 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageServiceController.h
@@ -33,8 +33,8 @@ public:
//it is included for test purposes
//currently it is not called
void connectAll();
- void start();
- void stop();
+ void start(bool singlethreaded);
+ void stop(bool singlethreaded);
//TODO: this is only for single threaded configurations
void runOnce();
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
index 5b2bc9f..ea4520b 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/RTSystemServicesProtocol.cpp
@@ -69,7 +69,7 @@ void RTSystemServicesProtocolPort::receive(Message* msg) {
if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
}
- getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
}
};
@@ -147,7 +147,7 @@ void RTSystemServicesProtocolConjPort::receive(Message* msg) {
if (msg->hasDebugFlagSet()) { // TODO: model switch for activation of this flag
DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), RTSystemServicesProtocol::getMessageString(msg->getEvtId()));
}
- getActor().receiveEvent(this, msg->getEvtId(), msg->getData());
+ getEventReceiver().receiveEvent(this, msg->getEvtId(), msg->getData());
}
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
index 1a7879f..0020249 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.cpp
@@ -13,6 +13,7 @@ ActorClassBase::ActorClassBase(IRTObject* parent, std::string name, Address ownA
: EventReceiver(parent, name),
IMessageReceiver(),
m_state(0),
+ history(0), //to be instantiated by derived class
m_RTSystemPort(0),
m_className("noname"),
m_ownAddr(ownAddr),
@@ -26,6 +27,8 @@ ActorClassBase::ActorClassBase(IRTObject* parent, std::string name, Address ownA
ActorClassBase::~ActorClassBase() {
delete m_RTSystemPort;
m_RTSystemPort = 0;
+ delete history;
+ history = 0;
}
bool ActorClassBase::handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data) {
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
index 85cc8f1..947c54c 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ActorClassBase.h
@@ -59,6 +59,8 @@ protected:
* the current state
*/
int m_state;
+ int* history; //Todo pka: name is not prefixed by m_ because generic generator uses this member
+
RTSystemServicesProtocolPort* m_RTSystemPort;
virtual bool handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data);
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
index c5c2bc6..2331695 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.cpp
@@ -11,20 +11,24 @@
namespace etRuntime {
-InterfaceItemBase::InterfaceItemBase (IEventReceiver& actor, IRTObject* parent, std::string name, int localId, int idx, Address ownAddress, Address peerAddress)
+InterfaceItemBase::InterfaceItemBase (IEventReceiver& evtReceiver, IRTObject* parent, std::string name, int localId, int idx, Address ownAddress, Address peerAddress)
: AbstractMessageReceiver(parent, ownAddress, name),
m_idx(idx),
m_localId(localId),
+ m_actorPath(name),
m_peerAddress(peerAddress),
m_ownMsgReceiver(RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(ownAddress.m_threadID)),
m_peerMsgReceiver(peerAddress.isValid()? RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(peerAddress.m_threadID): 0),
- m_actor(&actor)
+ m_eventReceiver(&evtReceiver)
{
if (getAddress().isValid() && m_ownMsgReceiver->isMsgService()) {
MessageService* ms = static_cast<MessageService*>(m_ownMsgReceiver);
// register at the own dispatcher to receive messages
ms->getMessageDispatcher().addMessageReceiver(*this);
}
+ if (parent) {
+ m_actorPath = parent->getInstancePath();
+ }
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
index 7f144dc..857a026 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/InterfaceItemBase.h
@@ -20,12 +20,12 @@ class IEventReceiver;
class InterfaceItemBase : public AbstractMessageReceiver{
public:
- InterfaceItemBase (IEventReceiver& actor, IRTObject* parent, std::string name, int localId, int idx, Address ownAddress, Address peerAddress);
+ InterfaceItemBase (IEventReceiver& evtReceiver, IRTObject* parentActor, std::string name, int localId, int idx, Address ownAddress, Address peerAddress);
virtual ~InterfaceItemBase();
int getIdx() const { return m_idx; } ;
- IEventReceiver& getActor() { return *m_actor; };
- IRTObject& getActorRTObject() { return *this; };
+ IEventReceiver& getEventReceiver() { return *m_eventReceiver; };
+ std::string& getActorPath() { return m_actorPath; };
int getLocalId() const {return m_localId; };
void setMsgReceiver(IMessageReceiver& msgReceiver) { m_ownMsgReceiver = &msgReceiver; };
@@ -40,10 +40,12 @@ private:
int m_idx;
int m_localId;
+ std::string m_actorPath;
+
Address m_peerAddress;
IMessageReceiver* m_ownMsgReceiver;
IMessageReceiver* m_peerMsgReceiver;
- IEventReceiver* m_actor;
+ IEventReceiver* m_eventReceiver;
InterfaceItemBase();
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
index c94b814..9d39227 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.cpp
@@ -54,19 +54,19 @@ void SubSystemClassBase::init() {
}
}
-void SubSystemClassBase::start() {
+void SubSystemClassBase::start(bool singlethreaded) {
// start all actors instances
m_RTSystemPort->executeInitialTransition();
// start all message services
- RTServices::getInstance().getMsgSvcCtrl().start();
+ RTServices::getInstance().getMsgSvcCtrl().start(singlethreaded);
}
-void SubSystemClassBase::stop() {
+void SubSystemClassBase::stop(bool singlethreaded) {
std::cout << "*** MainComponent " << this->getInstancePath() << "::stop ***" << std::endl;
- RTServices::getInstance().getMsgSvcCtrl().stop();
+ RTServices::getInstance().getMsgSvcCtrl().stop(singlethreaded);
std::cout << "=== done stop MsgSvcCtrl" << std::endl;
// stop all actor instances
@@ -119,9 +119,9 @@ ActorClassBase* SubSystemClassBase::getInstance(std::string path) {
// this is to run integration tests
// TODO synchronized
-void SubSystemClassBase::setTestSemaphore(TestSemaphore* sem) {
+void SubSystemClassBase::setTestSemaphore(TestSemaphore& sem) {
m_testErrorCode = -1;
- m_testSem = sem;
+ m_testSem = &sem;
}
//TODO synchronized
@@ -132,15 +132,15 @@ int SubSystemClassBase::getTestErrorCode() const {
void SubSystemClassBase::testFinished(int errorCode) {
if (m_testSem != 0) {
std::cout
- << "org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase.testFinished(int): before releasing semaphore"
+ << "org.eclipse.etrice.runtime.cpp.modelbase.SubSystemClassBase.testFinished(int): before releasing semaphore"
<< std::endl;
//m_testSem.printWaitingThreads();
//TODO synchronized (this) {
m_testErrorCode = errorCode;
- m_testSem->release(1);
+ m_testSem->give();
//}
std::cout
- << "org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase.testFinished(int): semaphore released"
+ << "org.eclipse.etrice.runtime.cpp.modelbase.SubSystemClassBase.testFinished(int): semaphore released"
<< std::endl;
//m_testSem.printWaitingThreads();
//TODO
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
index f537bd3..e7609c7 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemClassBase.h
@@ -33,8 +33,8 @@ public:
virtual void instantiateMessageServices() = 0;
virtual void instantiateActors() = 0;
- void start();
- void stop();
+ void start(bool singlethreaded);
+ void stop(bool singlethreaded);
void runOnce();
void destroy();
@@ -48,7 +48,7 @@ public:
// this is to run integration tests
//---------------------------------------------
// TODO synchronized
- void setTestSemaphore(TestSemaphore* sem);
+ void setTestSemaphore(TestSemaphore& sem);
//TODO synchronized
int getTestErrorCode() const;
void testFinished(int errorCode);
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
index f3e91ad..996a3a9 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.cpp
@@ -5,20 +5,99 @@
* Author: karlitsc
*/
-#include "SubSystemRunnerBase.h"
-#include "SubSystemClassBase.h"
+#include "common/modelbase/SubSystemRunnerBase.h"
+#include "common/modelbase/SubSystemClassBase.h"
#include "common/platform/etTimer.h"
+#include <unistd.h>
+#include <iostream>
+#include <sstream>
namespace etRuntime {
+const std::string SubSystemRunnerBase::OPTION_RUN_AS_TEST = "-run_as_test";
+const std::string SubSystemRunnerBase::OPTION_RUN_AS_TEST_SINGLETHREADED = "-run_as_test_single_threaded";
+const std::string SubSystemRunnerBase::OPTION_RUN_SINGLETHREADED = "-run_single_threaded";
+
+TestSemaphore SubSystemRunnerBase::s_testSem;
+
SubSystemRunnerBase::SubSystemRunnerBase() {
}
SubSystemRunnerBase::~SubSystemRunnerBase() {
}
+void SubSystemRunnerBase::run(SubSystemClassBase& mainComponent, int argc, char* argv[] ) {
+
+ //etUserEntry(); /* platform specific */
+
+ std::cout << "*** T H E B E G I N ***" << std::endl;
+
+ bool test = false;
+ bool singleThreaded = false;
+ int cycles = 100;
+
+ for (int i=1; i<argc; ++i) { // omit first argument, which is the program name
+ if (SubSystemRunnerBase::OPTION_RUN_AS_TEST.compare(argv[i]) == 0) {
+ std::cout << "*** running as test" << std::endl;
+ test = true;
+ }
+ else if (SubSystemRunnerBase::OPTION_RUN_AS_TEST_SINGLETHREADED.compare(argv[i]) == 0) {
+
+ singleThreaded = true;
+ i++;
+ if (i < argc) {
+ std::stringstream sstr(argv[i]);
+ sstr >> cycles;
+ }
+ std::cout << "*** running as test singlethreaded " << cycles << " cycles" << std::endl;
+ }
+ else if (SubSystemRunnerBase::OPTION_RUN_SINGLETHREADED.compare(argv[i]) == 0) {
+
+ singleThreaded = true;
+ i++;
+ if (i < argc) {
+ std::stringstream sstr(argv[i]);
+ sstr >> cycles;
+ }
+ std::cout << "*** running singlethreaded " << cycles << " cycles" << std::endl;
+ }
+ else {
+ std::cout << "*** running multithreaded" << std::endl;
+ }
+ }
+
+ if (test)
+ mainComponent.setTestSemaphore(s_testSem);
-void SubSystemRunnerBase::waitMultiThreaded() {
+ mainComponent.init(); // lifecycle init
+ mainComponent.start(singleThreaded); // lifecycle start
+
+ // application runs until quit
+ if (test) {
+ waitForTestcase();
+ }
+ else if (singleThreaded){
+ waitAndPollSingleThreaded(mainComponent, cycles);
+ }
+ else {
+ waitForQuitMultiThreaded();
+ }
+ // end the lifecycle
+ mainComponent.stop(singleThreaded); // lifecycle stop
+ mainComponent.destroy(); // lifecycle destroy
+
+ std::cout << "*** T H E E N D ***" << std::endl;
+
+ //etUserExit(); /* platform specific */
+}
+
+void SubSystemRunnerBase::waitForTestcase() {
+ //std::cout << "=== waitForTestcase: before acq. semaphore, thread " << Thread.currentThread().getName() << std::endl;
+ s_testSem.take();
+ //std::cout << "=== waitForTestcase: after acq. semaphore, thread " << Thread.currentThread().getName() << std::endl;
+}
+
+void SubSystemRunnerBase::waitForQuitMultiThreaded() {
// waiting for command line input
std::string token = "";
std::cout << "type 'quit' to exit" << std::endl;
@@ -28,38 +107,12 @@ void SubSystemRunnerBase::waitMultiThreaded() {
}
}
-void SubSystemRunnerBase::waitAndPollSingleThreaded(SubSystemClassBase& mainComponent) {
- for (int i=0; i< 100; ++i) {
+void SubSystemRunnerBase::waitAndPollSingleThreaded(SubSystemClassBase& mainComponent, int cycles) {
+ for (int i=0; i< cycles; ++i) {
if (etTimer_executeNeeded()) {
mainComponent.runOnce();
}
- Sleep(100);
+ usleep(100000);
}
-
- std::string token = "";
- std::cout << "type 'quit' to exit" << std::endl;
- #ifndef WIN32
- pollfd cinfd[1];
- // Theoretically this should always be 0, but one fileno call isn't going to hurt, and if
- // we try to run somewhere that stdin isn't fd 0 then it will still just work
- cinfd[0].fd = fileno(stdin);
- cinfd[0].events = POLLIN;
- #else
- HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
- #endif
- while (token != "quit")
- {
- #ifndef WIN32
- if (poll(cinfd, 1, 1000))
- #else
- // doesn't work as expected:
- if (WaitForSingleObject(h, 100) == WAIT_OBJECT_0)
- #endif
- {
- std::getline(std::cin, token);
- std::cout << "echo: " << token << std::endl;
- }
- mainComponent.runOnce();
- }
}
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h
index d44131a..824bf2f 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/SubSystemRunnerBase.h
@@ -11,8 +11,10 @@
#define SUBSYSTEMRUNNERBASE_H_
#include <iostream>
+#include <string>
#ifdef WIN32
#include <windows.h>
+#include "common/modelbase/TestSemaphore.h"
#endif
namespace etRuntime {
@@ -23,18 +25,21 @@ class SubSystemRunnerBase {
public:
SubSystemRunnerBase();
~SubSystemRunnerBase();
+ static void run(SubSystemClassBase& mainComponent, int argc, char* argv[] );
+protected:
/**
* blocks until the String "quit" is entered on the console
*/
-protected:
- static void waitForQuit(SubSystemClassBase& mainComponent) {
- waitAndPollSingleThreaded(mainComponent);
- }
+ static void waitForTestcase();
+ static TestSemaphore s_testSem;
private:
- static void waitMultiThreaded();
- static void waitAndPollSingleThreaded(SubSystemClassBase& mainComponent);
+ static const std::string OPTION_RUN_AS_TEST;
+ static const std::string OPTION_RUN_AS_TEST_SINGLETHREADED;
+ static const std::string OPTION_RUN_SINGLETHREADED;
+ static void waitForQuitMultiThreaded();
+ static void waitAndPollSingleThreaded(SubSystemClassBase& mainComponent, int cycles);
};
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp
index e513816..c62f4c0 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.cpp
@@ -11,6 +11,23 @@ namespace etRuntime {
TestSemaphore::~TestSemaphore() {
+ sem_destroy(&m_sem);
+}
+
+void TestSemaphore::printWaitingThreads() {
+ std::cout << ">>> begin semaphore info >>>" << std::endl;
+ int value;
+ sem_getvalue(&m_sem, &value);
+ std::cout << "value of the semaphore:" << value << std::endl;
+// std::cout << "current thread is " + Thread.currentThread().getName() << std::endl;
+// Collection < Thread > threads = getQueuedThreads();
+// if (threads.isEmpty())
+// std::cout << " no waiting threads" << std::endl;
+// else
+// for (Thread thread : threads) {
+// std::cout << " blocked: " << thread.getName() << std::endl;
+// }
+ std::cout << "<<< end semaphore info <<<" << std::endl;
}
} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h
index e10b04d..6859e95 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/TestSemaphore.h
@@ -9,31 +9,28 @@
#define TESTSEMAPHORE_H_
#include <iostream>
+#include <semaphore.h>
namespace etRuntime {
class TestSemaphore { //extends Semaphore
public:
+ TestSemaphore(int permits = 1)
+ : m_sem()
+ {
+ sem_init(&m_sem, 0, permits);
+ }
+
virtual ~TestSemaphore();
- TestSemaphore(int permits) {
- }
- void release(int count) {};
-
- void printWaitingThreads() {
- std::cout << ">>> begin semaphore info >>>" << std::endl;
-// std::cout << "current thread is " + Thread.currentThread().getName() << std::endl;
-// Collection < Thread > threads = getQueuedThreads();
-// if (threads.isEmpty())
-// std::cout << " no waiting threads" << std::endl;
-// else
-// for (Thread thread : threads) {
-// std::cout << " blocked: " << thread.getName() << std::endl;
-// }
- std::cout << "<<< end semaphore info <<<" << std::endl;
- }
+ void give() { sem_post(&m_sem); };
+ void take() { sem_wait(&m_sem); };
+
+ void printWaitingThreads();
+
private:
- TestSemaphore();
+ sem_t m_sem;
+
TestSemaphore(const TestSemaphore& right);
TestSemaphore& operator=(const TestSemaphore& right);
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/.cproject b/tests/org.eclipse.etrice.generator.cpp.tests/.cproject
new file mode 100644
index 0000000..155fa0e
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.cpp.tests/.cproject
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002" moduleId="org.eclipse.cdt.core.settings" name="Debug">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.exe.debug">
+ <folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.242769122" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.2057244616" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/>
+ <builder buildPath="${workspace_loc:/org.eclipse.etrice.generator.cpp.tests/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.2069078114" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.1433668364" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug">
+ <option id="gnu.both.asm.option.include.paths.382244560" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/common/platform}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.55067378" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.567572926" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.177246759" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug">
+ <option id="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level.430807243" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level.1383669374" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.761725209" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/common/platform}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.346603627" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.220478217" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug">
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.exe.debug.option.optimization.level.395258590" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.debug.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.mingw.exe.debug.option.debugging.level.1189953766" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.c.compiler.option.include.paths.1403500428" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/common/platform}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1023039306" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.1145094544" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug.1671086433" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug">
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.940229505" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ <cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.release.1781534644">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.release.1781534644" moduleId="org.eclipse.cdt.core.settings" name="Release">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.release.1781534644" name="Release" parent="cdt.managedbuild.config.gnu.mingw.exe.release">
+ <folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.release.1781534644." name="/" resourcePath="">
+ <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.release.1858381959" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.release">
+ <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.release.922694920" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.release"/>
+ <builder buildPath="${workspace_loc:/org.eclipse.etrice.generator.cpp.tests/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.176559771" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release.551795651" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release">
+ <option id="gnu.both.asm.option.include.paths.704004951" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/common/platform}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1813992405" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1263735881" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release.534767751" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release">
+ <option id="gnu.cpp.compiler.mingw.exe.release.option.optimization.level.386438785" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.1289489549" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.option.include.paths.503000588" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/common/platform}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.521340645" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.1308261136" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release">
+ <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.exe.release.option.optimization.level.1790493807" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.release.option.optimization.level" valueType="enumerated"/>
+ <option id="gnu.c.compiler.mingw.exe.release.option.debugging.level.1970954673" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
+ <option id="gnu.c.compiler.option.include.paths.1950967305" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.modellib.cpp/src-gen}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.cpp/src/common/platform}&quot;"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1597770877" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release.186940136" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release.646213702" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release">
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.388077354" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="org.eclipse.etrice.generator.cpp.tests.cdt.managedbuild.target.gnu.mingw.exe.545973248" name="Executable" projectType="cdt.managedbuild.target.gnu.mingw.exe"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.release.1781534644;cdt.managedbuild.config.gnu.mingw.exe.release.1781534644.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release.534767751;cdt.managedbuild.tool.gnu.cpp.compiler.input.521340645">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002;cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.220478217;cdt.managedbuild.tool.gnu.c.compiler.input.1023039306">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.release.1781534644;cdt.managedbuild.config.gnu.mingw.exe.release.1781534644.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.1308261136;cdt.managedbuild.tool.gnu.c.compiler.input.1597770877">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002;cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002.;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.177246759;cdt.managedbuild.tool.gnu.cpp.compiler.input.346603627">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.pathentry"/>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+</cproject>
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/tests/org.eclipse.etrice.generator.cpp.tests/.settings/org.eclipse.cdt.managedbuilder.core.prefs
new file mode 100644
index 0000000..0027346
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.cpp.tests/.settings/org.eclipse.cdt.managedbuilder.core.prefs
@@ -0,0 +1,13 @@
+eclipse.preferences.version=1
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/CPATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/CPATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/CPLUS_INCLUDE_PATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/CPLUS_INCLUDE_PATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/C_INCLUDE_PATH/delimiter=;
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/C_INCLUDE_PATH/operation=remove
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/append=true
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/appendContributed=true
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/LIBRARY_PATH/delimiter=;
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/LIBRARY_PATH/operation=remove
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/append=true
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.1467322002/appendContributed=true
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_CPTest_Async.seq b/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_CPTest_Async.seq
new file mode 100644
index 0000000..c14ac22
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_CPTest_Async.seq
@@ -0,0 +1,27 @@
+#generated MSC for Trace2UML
+ /SubSystem_CPTest >-- /SubSystem_CPTest/ChoicePointTest_Top executeInitialTransition
+ /SubSystem_CPTest >-- /SubSystem_CPTest/ChoicePointTest_Top/cp_tester executeInitialTransition
+ /SubSystem_CPTest >-- /SubSystem_CPTest/ChoicePointTest_Top/cp_user executeInitialTransition
+ /SubSystem_CPTest --> /SubSystem_CPTest/ChoicePointTest_Top executeInitialTransition
+ /SubSystem_CPTest --> /SubSystem_CPTest/ChoicePointTest_Top/cp_tester executeInitialTransition
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester >-- /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester >-- /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester >-- /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester >-- /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester >-- /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester >-- /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester >>> state0
+ /SubSystem_CPTest --> /SubSystem_CPTest/ChoicePointTest_Top/cp_user executeInitialTransition
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_user >>> ENTRY3_EXIT4
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester --> /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_user >>> ENTRY3_EXIT4
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester --> /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_user >>> ENTRY8_EXIT9_ENTRY11_EXIT12
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester --> /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_user >>> ENTRY3_EXIT4
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester --> /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_user >>> ENTRY8_EXIT9_ENTRY11_EXIT12
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester --> /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_user >>> ENTRY8_EXIT9_ENTRY11_EXIT12
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_tester --> /SubSystem_CPTest/ChoicePointTest_Top/cp_user msg1
+ /SubSystem_CPTest/ChoicePointTest_Top/cp_user >>> testOk
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_CPTest_Sync.seq b/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_CPTest_Sync.seq
new file mode 100644
index 0000000..50058ec
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_CPTest_Sync.seq
@@ -0,0 +1 @@
+#generated MSC for Trace2UML
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_HandlerTest_Async.seq b/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_HandlerTest_Async.seq
new file mode 100644
index 0000000..aab3bbf
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_HandlerTest_Async.seq
@@ -0,0 +1,48 @@
+#generated MSC for Trace2UML
+ /SubSystem_HandlerTest >-- /SubSystem_HandlerTest/HandlerTest_Top executeInitialTransition
+ /SubSystem_HandlerTest >-- /SubSystem_HandlerTest/HandlerTest_Top/tester executeInitialTransition
+ /SubSystem_HandlerTest >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser executeInitialTransition
+ /SubSystem_HandlerTest --> /SubSystem_HandlerTest/HandlerTest_Top executeInitialTransition
+ /SubSystem_HandlerTest --> /SubSystem_HandlerTest/HandlerTest_Top/tester executeInitialTransition
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg2
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg2
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg3
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg4
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >-- /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg6
+ /SubSystem_HandlerTest/HandlerTest_Top/tester >>> state0
+ /SubSystem_HandlerTest --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser executeInitialTransition
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state1_state7
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state1_state7
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state1_state7
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state1_state7
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state1
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state1
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state1_state7
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg2
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state1_state7
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg2
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state2
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state2
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg3
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state2
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg4
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state2
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg1
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> state0_state2
+ /SubSystem_HandlerTest/HandlerTest_Top/tester --> /SubSystem_HandlerTest/HandlerTest_Top/handlerUser msg6
+ /SubSystem_HandlerTest/HandlerTest_Top/handlerUser >>> testOk
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_HandlerTest_Sync.seq b/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_HandlerTest_Sync.seq
new file mode 100644
index 0000000..50058ec
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.cpp.tests/SubSystem_HandlerTest_Sync.seq
@@ -0,0 +1 @@
+#generated MSC for Trace2UML
diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/make.xml b/tests/org.eclipse.etrice.generator.cpp.tests/make.xml
index 9913fc9..c1efbb7 100644
--- a/tests/org.eclipse.etrice.generator.cpp.tests/make.xml
+++ b/tests/org.eclipse.etrice.generator.cpp.tests/make.xml
@@ -267,6 +267,7 @@
<!-- library has to be in the last position -->
<arg value="-lorg.eclipse.etrice.runtime.cpp"/>
<arg value="-lorg.eclipse.etrice.runtime.c"/>
+ <arg value="-lpthread"/>
</exec>
<!-- compile and link ChoicepointTest -->
@@ -303,6 +304,7 @@
<!-- library has to be in the last position -->
<arg value="-lorg.eclipse.etrice.runtime.cpp"/>
<arg value="-lorg.eclipse.etrice.runtime.c"/>
+ <arg value="-lpthread"/>
</exec>
</target>
@@ -311,8 +313,14 @@
-->
<target name="run" depends="build">
<mkdir dir="tmp/log"/>
- <exec dir="./" resolveexecutable="true" executable="./bin/HandlerTest/HandlerTest.exe"/>
- <exec dir="./" resolveexecutable="true" executable="./bin/ChoicePointTest/ChoicePointTest.exe"/>
+ <exec dir="./" resolveexecutable="true" executable="./bin/HandlerTest/HandlerTest.exe">
+ <arg value="-run_as_test_single_threaded"/>
+ <arg value="200"/>
+ </exec>
+ <exec dir="./" resolveexecutable="true" executable="./bin/ChoicePointTest/ChoicePointTest.exe">
+ <arg value="-run_as_test_single_threaded"/>
+ <arg value="200"/>
+ </exec>
</target>
<!--