Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Belle2016-10-26 14:36:33 +0000
committerHenrik Rentz-Reichert2016-11-07 08:47:26 +0000
commitcfec11455b4c5d2580af682a7712b55095a53bba (patch)
tree801787f79039398681c120398f591cd1a14aa359
parenta488ef8e6dd1be4f685c8284c4a2f45aa1cc21ef (diff)
downloadorg.eclipse.etrice-cfec11455b4c5d2580af682a7712b55095a53bba.tar.gz
org.eclipse.etrice-cfec11455b4c5d2580af682a7712b55095a53bba.tar.xz
org.eclipse.etrice-cfec11455b4c5d2580af682a7712b55095a53bba.zip
Refactored messaging to static message allocation
[runtime.cpp] Added StaticMessageMemory and IMemory class for static messaging. [generator.cpp] Adjusted generator to static messaging. [runtime.cpp.tests] Adjusted test cases to fit the runtime changes and added testcase for the StaticMessageMemory. [ui.runtime] updated zipped contents Change-Id: I92adb0c610555b0b954365611714a5a6f873605c
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeGen.xtend28
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.xtend57
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java133
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/ProtocolClassGen.java227
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zipbin16007 -> 15875 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zipbin68599 -> 69643 bytes
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/model/GenericPhysical.etphys6
-rw-r--r--runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room22
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.cpp59
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.h66
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageMemory.h34
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageService.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp16
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h17
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp6
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.cpp72
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageService.h23
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.cpp45
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.h45
-rw-r--r--runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.cpp8
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/PingPongThread.etphys12
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/RunAllTestCases.cpp4
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.cpp3
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.cpp35
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceControllerTest.cpp4
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceTest.cpp8
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageTest.cpp13
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/StaticMessageMemoryTest.cpp74
-rw-r--r--tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/StaticMessageMemoryTest.h29
29 files changed, 663 insertions, 386 deletions
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeGen.xtend
index 2635252f8..7ac206db5 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/NodeGen.xtend
@@ -83,6 +83,7 @@ class NodeGen {
«generateIncludeGuardBegin(cc, '')»
+ #include "common/messaging/IMessageService.h"
#include "common/modelbase/SubSystemClassBase.h"
«FOR ai : comp.actorInstances»
#include "«ai.actorClass.actorIncludePath»"
@@ -100,11 +101,10 @@ class NodeGen {
«cc.userCode2.userCode»
public:
-
«FOR thread : threads.indexed»
static const int «thread.value.threadId»;
«ENDFOR»
-
+
// sub actors
«FOR sub : cc.actorRefs»
«IF sub.multiplicity>1»
@@ -133,6 +133,10 @@ class NodeGen {
«ENDIF»
private:
+ // MessageServices
+ «FOR thread : threads»
+ IMessageService* msgSvc_«thread.name»;
+ «ENDFOR»
«clsname»();
«clsname»(«clsname» const&);
@@ -152,7 +156,7 @@ class NodeGen {
def private generateConstructorInitalizerList(SubSystemClass cc) {
val extension initHelper = initHelper
var initList = <CharSequence>newArrayList
-
+
// super class
initList += '''SubSystemClassBase(parent, name)'''
// own sub actors
@@ -184,6 +188,7 @@ class NodeGen {
#include "common/messaging/MessageService.h"
#include "common/messaging/MessageServiceController.h"
#include "common/messaging/RTServices.h"
+ #include "common/messaging/StaticMessageMemory.h"
#include "common/modelbase/InterfaceItemBase.h"
using namespace etRuntime;
@@ -196,6 +201,9 @@ class NodeGen {
«clsname»::«clsname»(IRTObject* parent, const std::string& name)
«cc.generateConstructorInitalizerList»
+ «FOR thread : threads»
+ , msgSvc_«thread.name»(NULL)
+ «ENDFOR»
{
«IF Main::settings.generateMSCInstrumentation»
MSCFunctionObject mscFunctionObject(getInstancePathName(), "Constructor");
@@ -211,6 +219,9 @@ class NodeGen {
«IF Main::settings.generateMSCInstrumentation»
MSCFunctionObject mscFunctionObject(getInstancePathName(), "Destructor");
«ENDIF»
+ «FOR thread : threads»
+ delete msgSvc_«thread.name»;
+ «ENDFOR»
}
void «clsname»::receiveEvent(InterfaceItemBase* ifitem, int evt, void* data){
@@ -222,19 +233,20 @@ class NodeGen {
MSCFunctionObject mscFunctionObject(getInstancePathName(), "instantiateMessageServices()");
«ENDIF»
- IMessageService* msgService;
+ IMessageMemory* msgMemory;
«FOR thread: threads»
{
+ msgMemory = new StaticMessageMemory(this, "MessageMemory_«thread.name»", «thread.msgblocksize», «thread.msgpoolsize»);
«IF thread.execmode==ExecMode::POLLED || thread.execmode==ExecMode::MIXED»
etTime interval;
interval.sec = «TimeConverter::split(thread.time, TimeConverter.SEC, true)»;
interval.nSec = «TimeConverter::split(thread.time, TimeConverter.MILLI_SEC, false)»L;
-
- msgService = new MessageService(this, IMessageService::«thread.execmode.getName», interval, 0, «thread.threadId», "MessageService_«thread.name»", «thread.prio»);
+
+ msgSvc_«thread.name» = new MessageService(this, IMessageService::«thread.execmode.getName», interval, 0, «thread.threadId», "MessageService_«thread.name»", msgMemory, «thread.prio»);
«ELSE»
- msgService = new MessageService(this, IMessageService::«thread.execmode.getName», 0, «thread.threadId», "MessageService_«thread.name»", «thread.prio»);
+ msgSvc_«thread.name» = new MessageService(this, IMessageService::«thread.execmode.getName», 0, «thread.threadId», "MessageService_«thread.name»", msgMemory, «thread.prio»);
«ENDIF»
- RTServices::getInstance().getMsgSvcCtrl().addMsgSvc(*msgService);
+ RTServices::getInstance().getMsgSvcCtrl().addMsgSvc(*msgSvc_«thread.name»);
}
«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 b588e276e..39a997cf6 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
@@ -151,7 +151,8 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
// sent messages
«FOR m : pc.getAllMessages(conj)»
- «messageSignature(m)»;
+ «messageSignature(m, false)»;
+ «messageSignature(m, true)»;
«ENDFOR»
};
@@ -170,12 +171,12 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«IF conj»
// incoming messages
«FOR m : pc.getAllIncomingMessages()»
- «messageSignature(m)»;
+ «messageSignature(m, false)»;
«ENDFOR»
«ELSE»
// outgoing messages
«FOR m : pc.getAllOutgoingMessages()»
- «messageSignature(m)»;
+ «messageSignature(m, false)»;
«ENDFOR»
«ENDIF»
@@ -312,18 +313,18 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«IF conj»
// incoming messages
«FOR m : pc.getAllIncomingMessages()»
- «messageSignatureDefinition(m, replPortClassName)»{
+ «messageSignatureDefinition(m, replPortClassName, false)»{
for (std::vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {
- (dynamic_cast<«portClassName»*>(*it))->«messageCall(m)»;
+ (dynamic_cast<«portClassName»*>(*it))->«messageCall(m, false)»;
}
}
«ENDFOR»
«ELSE»
// outgoing messages
«FOR m : pc.getAllOutgoingMessages()»
- «messageSignatureDefinition(m, replPortClassName)»{
+ «messageSignatureDefinition(m, replPortClassName, false)»{
for (std::vector<etRuntime::InterfaceItemBase*>::iterator it = getItems().begin(); it != getItems().end(); ++it) {
- (dynamic_cast<«portClassName»*>(*it))->«messageCall(m)»;
+ (dynamic_cast<«portClassName»*>(*it))->«messageCall(m, false)»;
}
}
«ENDFOR»
@@ -342,38 +343,48 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
initList.generateCtorInitializerList
}
- def protected messageCall(Message m) {
- '''«m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)'''
+ def protected messageCall(Message m, boolean impl) {
+ '''«m.name»«IF impl»_impl«ENDIF»(«IF m.data!=null» «m.data.name»«ENDIF»)'''
}
- def protected messageSignature(Message m) {
- '''«IF m.priv»private:«ELSE»public:«ENDIF» void «m.name»(«IF m.data!=null»«m.data.refType.signatureString» «m.data.name»«ENDIF»)'''
+ def protected messageSignature(Message m, boolean impl) {
+ '''«IF m.priv||impl»private:«ELSE»public:«ENDIF» void «m.name»«IF impl»_impl«ENDIF»(«IF m.data!=null»«m.data.refType.signatureString» «m.data.name»«ENDIF»)'''
}
- def protected messageSignatureDefinition(Message m, String classPrefix) {
- '''void «classPrefix»::«m.name»(«IF m.data!=null»«m.data.refType.signatureString» «m.data.name»«ENDIF»)'''
+ def protected messageSignatureDefinition(Message m, String classPrefix, boolean impl) {
+ '''void «classPrefix»::«m.name»«IF impl»_impl«ENDIF»(«IF m.data!=null»«m.data.refType.signatureString» «m.data.name»«ENDIF»)'''
}
def protected sendMessage(Message m, String portClassName, String classPrefix, boolean conj) {
var dir = if (conj) "IN" else "OUT"
var hdlr = m.getSendHandler(conj)
- val dataArg = if(m.data != null) ''', «IF m.data.refType.ref»«m.data.name»«ELSE»&«m.data.name», sizeof(«m.data.refType.type.typeName»)«ENDIF»'''
- val message = '''new Message(getPeerAddress(), «portClassName»::«dir»_«m.name»«dataArg?:''»)'''
+ val dataArg = if(m.data != null) ''', «m.data.name»'''
+ val messageType = if(m.data != null && !m.data.refType.ref) '''DataMessage<«m.data.refType.type.typeName»>''' else '''Message'''
+ val message = '''new (buffer) «messageType»(getPeerAddress(), «portClassName»::«dir»_«m.name»«dataArg?:''»)'''
'''
- «messageSignatureDefinition(m, classPrefix)» {
+ «messageSignatureDefinition(m, classPrefix, false)» {
«IF hdlr!=null»
«FOR command : hdlr.detailCode.lines» «command»
«ENDFOR»
«ELSE»
- «IF Main::settings.generateMSCInstrumentation»
- DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- «portClassName»::getMessageString(«portClassName»::«dir»_«m.name»));
- «ENDIF»
- if (getPeerAddress().isValid()){
+ «messageCall(m, true)»;
+ «ENDIF»
+ }
+
+ «messageSignatureDefinition(m, classPrefix, true)» {
+ «IF Main::settings.generateMSCInstrumentation»
+ DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
+ «portClassName»::getMessageString(«portClassName»::«dir»_«m.name»));
+ «ENDIF»
+ if (getPeerAddress().isValid()) {
+««« we have to use a dynamic cast here because we have a virtual base class
+ Message* buffer = dynamic_cast<IMessageService*>(getPeerMsgReceiver())->getMessageBuffer(sizeof(«messageType»));
+ if (buffer) {
getPeerMsgReceiver()->receive(«message»);
}
- «ENDIF»
+««« // TODO JB: Handle buffer == NULL
+ }
}
'''
}
@@ -381,7 +392,6 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
def protected generateDataDrivenHeaderFile(Root root, ProtocolClass pc) {
val sentMsgs = pc.allIncomingMessages.filter(m|m.data!=null)
- val models = root.getReferencedModels(pc)
'''
/**
* @author generated by eTrice
@@ -457,7 +467,6 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
def protected generateDataDrivenSourceFile(Root root, ProtocolClass pc) {
val sentMsgs = pc.allIncomingMessages.filter(m|m.data!=null)
- val models = root.getReferencedModels(pc)
'''
/**
* @author generated by eTrice
diff --git a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java
index ca29407dd..f93f1f980 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java
+++ b/plugins/org.eclipse.etrice.generator.cpp/xtend-gen/org/eclipse/etrice/generator/cpp/gen/NodeGen.java
@@ -165,6 +165,8 @@ public class NodeGen {
_builder.append(_generateIncludeGuardBegin, "");
_builder.newLineIfNotEmpty();
_builder.newLine();
+ _builder.append("#include \"common/messaging/IMessageService.h\"");
+ _builder.newLine();
_builder.append("#include \"common/modelbase/SubSystemClassBase.h\"");
_builder.newLine();
{
@@ -202,7 +204,6 @@ public class NodeGen {
_builder.append("\t");
_builder.append("public:");
_builder.newLine();
- _builder.newLine();
{
Iterable<Indexed<PhysicalThread>> _indexed = Indexed.<PhysicalThread>indexed(threads);
for(final Indexed<PhysicalThread> thread : _indexed) {
@@ -215,6 +216,7 @@ public class NodeGen {
_builder.newLineIfNotEmpty();
}
}
+ _builder.append("\t\t");
_builder.newLine();
_builder.append("\t\t");
_builder.append("// sub actors");
@@ -303,6 +305,19 @@ public class NodeGen {
_builder.append("\t");
_builder.append("private:");
_builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("// MessageServices");
+ _builder.newLine();
+ {
+ for(final PhysicalThread thread_1 : threads) {
+ _builder.append("\t\t");
+ _builder.append("IMessageService* msgSvc_");
+ String _name_2 = thread_1.getName();
+ _builder.append(_name_2, "\t\t");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.newLine();
_builder.append("\t\t");
_builder.append(clsname, "\t\t");
@@ -425,6 +440,8 @@ public class NodeGen {
_builder.newLine();
_builder.append("#include \"common/messaging/RTServices.h\"");
_builder.newLine();
+ _builder.append("#include \"common/messaging/StaticMessageMemory.h\"");
+ _builder.newLine();
_builder.append("#include \"common/modelbase/InterfaceItemBase.h\"");
_builder.newLine();
_builder.newLine();
@@ -461,6 +478,16 @@ public class NodeGen {
CharSequence _generateConstructorInitalizerList = this.generateConstructorInitalizerList(cc);
_builder.append(_generateConstructorInitalizerList, "\t\t");
_builder.newLineIfNotEmpty();
+ {
+ for(final PhysicalThread thread_1 : threads) {
+ _builder.append("\t\t");
+ _builder.append(", msgSvc_");
+ String _name = thread_1.getName();
+ _builder.append(_name, "\t\t");
+ _builder.append("(NULL)");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.append("{");
_builder.newLine();
{
@@ -480,8 +507,8 @@ public class NodeGen {
boolean _greaterThan = (_multiplicity > 1);
if (_greaterThan) {
_builder.append("\t");
- String _name = sub.getName();
- _builder.append(_name, "\t");
+ String _name_1 = sub.getName();
+ _builder.append(_name_1, "\t");
_builder.append(".createSubActors(");
int _multiplicity_1 = sub.getMultiplicity();
_builder.append(_multiplicity_1, "\t");
@@ -508,6 +535,16 @@ public class NodeGen {
_builder.newLine();
}
}
+ {
+ for(final PhysicalThread thread_2 : threads) {
+ _builder.append("\t");
+ _builder.append("delete msgSvc_");
+ String _name_2 = thread_2.getName();
+ _builder.append(_name_2, "\t");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.append("}");
_builder.newLine();
_builder.newLine();
@@ -534,15 +571,28 @@ public class NodeGen {
}
_builder.newLine();
_builder.append("\t");
- _builder.append("IMessageService* msgService;");
+ _builder.append("IMessageMemory* msgMemory;");
_builder.newLine();
{
- for(final PhysicalThread thread_1 : threads) {
+ for(final PhysicalThread thread_3 : threads) {
_builder.append("\t");
_builder.append("{");
_builder.newLine();
+ _builder.append("\t");
+ _builder.append("\t");
+ _builder.append("msgMemory = new StaticMessageMemory(this, \"MessageMemory_");
+ String _name_3 = thread_3.getName();
+ _builder.append(_name_3, "\t\t");
+ _builder.append("\", ");
+ int _msgblocksize = thread_3.getMsgblocksize();
+ _builder.append(_msgblocksize, "\t\t");
+ _builder.append(", ");
+ int _msgpoolsize = thread_3.getMsgpoolsize();
+ _builder.append(_msgpoolsize, "\t\t");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
{
- if ((Objects.equal(thread_1.getExecmode(), ExecMode.POLLED) || Objects.equal(thread_1.getExecmode(), ExecMode.MIXED))) {
+ if ((Objects.equal(thread_3.getExecmode(), ExecMode.POLLED) || Objects.equal(thread_3.getExecmode(), ExecMode.MIXED))) {
_builder.append("\t");
_builder.append("\t");
_builder.append("etTime interval;");
@@ -550,7 +600,7 @@ public class NodeGen {
_builder.append("\t");
_builder.append("\t");
_builder.append("interval.sec = ");
- long _time = thread_1.getTime();
+ long _time = thread_3.getTime();
long _split = TimeConverter.split(_time, TimeConverter.SEC, true);
_builder.append(_split, "\t\t");
_builder.append(";");
@@ -558,44 +608,52 @@ public class NodeGen {
_builder.append("\t");
_builder.append("\t");
_builder.append("interval.nSec = ");
- long _time_1 = thread_1.getTime();
+ long _time_1 = thread_3.getTime();
long _split_1 = TimeConverter.split(_time_1, TimeConverter.MILLI_SEC, false);
_builder.append(_split_1, "\t\t");
_builder.append("L;");
_builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
- _builder.append("msgService = new MessageService(this, IMessageService::");
- ExecMode _execmode = thread_1.getExecmode();
- String _name_1 = _execmode.getName();
- _builder.append(_name_1, "\t\t");
+ _builder.append("msgSvc_");
+ String _name_4 = thread_3.getName();
+ _builder.append(_name_4, "\t\t");
+ _builder.append(" = new MessageService(this, IMessageService::");
+ ExecMode _execmode = thread_3.getExecmode();
+ String _name_5 = _execmode.getName();
+ _builder.append(_name_5, "\t\t");
_builder.append(", interval, 0, ");
- String _threadId_1 = this.getThreadId(thread_1);
+ String _threadId_1 = this.getThreadId(thread_3);
_builder.append(_threadId_1, "\t\t");
_builder.append(", \"MessageService_");
- String _name_2 = thread_1.getName();
- _builder.append(_name_2, "\t\t");
- _builder.append("\", ");
- long _prio = thread_1.getPrio();
+ String _name_6 = thread_3.getName();
+ _builder.append(_name_6, "\t\t");
+ _builder.append("\", msgMemory, ");
+ long _prio = thread_3.getPrio();
_builder.append(_prio, "\t\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
_builder.append("\t");
- _builder.append("msgService = new MessageService(this, IMessageService::");
- ExecMode _execmode_1 = thread_1.getExecmode();
- String _name_3 = _execmode_1.getName();
- _builder.append(_name_3, "\t\t");
+ _builder.append("msgSvc_");
+ String _name_7 = thread_3.getName();
+ _builder.append(_name_7, "\t\t");
+ _builder.append(" = new MessageService(this, IMessageService::");
+ ExecMode _execmode_1 = thread_3.getExecmode();
+ String _name_8 = _execmode_1.getName();
+ _builder.append(_name_8, "\t\t");
_builder.append(", 0, ");
- String _threadId_2 = this.getThreadId(thread_1);
+ String _threadId_2 = this.getThreadId(thread_3);
_builder.append(_threadId_2, "\t\t");
_builder.append(", \"MessageService_");
- String _name_4 = thread_1.getName();
- _builder.append(_name_4, "\t\t");
- _builder.append("\", ");
- long _prio_1 = thread_1.getPrio();
+ String _name_9 = thread_3.getName();
+ _builder.append(_name_9, "\t\t");
+ _builder.append("\", msgMemory, ");
+ long _prio_1 = thread_3.getPrio();
_builder.append(_prio_1, "\t\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
@@ -603,8 +661,11 @@ public class NodeGen {
}
_builder.append("\t");
_builder.append("\t");
- _builder.append("RTServices::getInstance().getMsgSvcCtrl().addMsgSvc(*msgService);");
- _builder.newLine();
+ _builder.append("RTServices::getInstance().getMsgSvcCtrl().addMsgSvc(*msgSvc_");
+ String _name_10 = thread_3.getName();
+ _builder.append(_name_10, "\t\t");
+ _builder.append(");");
+ _builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
@@ -676,8 +737,8 @@ public class NodeGen {
_builder.append("\t");
_builder.append("\t");
_builder.append("DebuggingService::getInstance().addMessageActorCreate(*this, ");
- String _name_5 = sub_1.getName();
- _builder.append(_name_5, "\t\t");
+ String _name_11 = sub_1.getName();
+ _builder.append(_name_11, "\t\t");
_builder.append(".getSubActor(i)->getName());");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -686,8 +747,8 @@ public class NodeGen {
} else {
_builder.append("\t");
_builder.append("DebuggingService::getInstance().addMessageActorCreate(*this, \"");
- String _name_6 = sub_1.getName();
- _builder.append(_name_6, "\t");
+ String _name_12 = sub_1.getName();
+ _builder.append(_name_12, "\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
}
@@ -734,8 +795,8 @@ public class NodeGen {
EList<ActorRef> _actorRefs_2 = cc.getActorRefs();
for(final ActorRef sub_2 : _actorRefs_2) {
_builder.append("\t");
- String _name_7 = sub_2.getName();
- _builder.append(_name_7, "\t");
+ String _name_13 = sub_2.getName();
+ _builder.append(_name_13, "\t");
_builder.append(".initialize();");
_builder.newLineIfNotEmpty();
}
@@ -764,8 +825,8 @@ public class NodeGen {
EList<ActorRef> _actorRefs_3 = cc.getActorRefs();
for(final ActorRef sub_3 : _actorRefs_3) {
_builder.append("\t\t");
- String _name_8 = sub_3.getName();
- _builder.append(_name_8, "\t\t");
+ String _name_14 = sub_3.getName();
+ _builder.append(_name_14, "\t\t");
_builder.append(".setProbesActive(recursive, active);");
_builder.newLineIfNotEmpty();
}
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
index d50c52d1f..3da64299f 100644
--- 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
@@ -32,7 +32,6 @@ import org.eclipse.etrice.core.room.PortClass;
import org.eclipse.etrice.core.room.PortOperation;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RefableType;
-import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SAP;
import org.eclipse.etrice.core.room.SPP;
import org.eclipse.etrice.core.room.VarDecl;
@@ -382,10 +381,15 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, conj);
for(final Message m : _allMessages) {
_builder.append("\t");
- CharSequence _messageSignature = this.messageSignature(m);
+ CharSequence _messageSignature = this.messageSignature(m, false);
_builder.append(_messageSignature, "\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ CharSequence _messageSignature_1 = this.messageSignature(m, true);
+ _builder.append(_messageSignature_1, "\t");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
}
}
_builder.append("};");
@@ -438,8 +442,8 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
List<Message> _allIncomingMessages = this._roomHelpers.getAllIncomingMessages(pc);
for(final Message m_1 : _allIncomingMessages) {
_builder.append("\t\t");
- CharSequence _messageSignature_1 = this.messageSignature(m_1);
- _builder.append(_messageSignature_1, "\t\t");
+ CharSequence _messageSignature_2 = this.messageSignature(m_1, false);
+ _builder.append(_messageSignature_2, "\t\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
@@ -452,8 +456,8 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
List<Message> _allOutgoingMessages = this._roomHelpers.getAllOutgoingMessages(pc);
for(final Message m_2 : _allOutgoingMessages) {
_builder.append("\t\t");
- CharSequence _messageSignature_2 = this.messageSignature(m_2);
- _builder.append(_messageSignature_2, "\t\t");
+ CharSequence _messageSignature_3 = this.messageSignature(m_2, false);
+ _builder.append(_messageSignature_3, "\t\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
@@ -854,7 +858,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
{
List<Message> _allIncomingMessages = this._roomHelpers.getAllIncomingMessages(pc);
for(final Message m_1 : _allIncomingMessages) {
- CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m_1, replPortClassName);
+ CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m_1, replPortClassName, false);
_builder.append(_messageSignatureDefinition, "");
_builder.append("{");
_builder.newLineIfNotEmpty();
@@ -865,7 +869,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("(dynamic_cast<");
_builder.append(portClassName, "\t\t");
_builder.append("*>(*it))->");
- CharSequence _messageCall = this.messageCall(m_1);
+ CharSequence _messageCall = this.messageCall(m_1, false);
_builder.append(_messageCall, "\t\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
@@ -882,7 +886,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
{
List<Message> _allOutgoingMessages = this._roomHelpers.getAllOutgoingMessages(pc);
for(final Message m_2 : _allOutgoingMessages) {
- CharSequence _messageSignatureDefinition_1 = this.messageSignatureDefinition(m_2, replPortClassName);
+ CharSequence _messageSignatureDefinition_1 = this.messageSignatureDefinition(m_2, replPortClassName, false);
_builder.append(_messageSignatureDefinition_1, "");
_builder.append("{");
_builder.newLineIfNotEmpty();
@@ -893,7 +897,7 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("(dynamic_cast<");
_builder.append(portClassName, "\t\t");
_builder.append("*>(*it))->");
- CharSequence _messageCall_1 = this.messageCall(m_2);
+ CharSequence _messageCall_1 = this.messageCall(m_2, false);
_builder.append(_messageCall_1, "\t\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
@@ -946,10 +950,15 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
return _xblockexpression;
}
- protected CharSequence messageCall(final Message m) {
+ protected CharSequence messageCall(final Message m, final boolean impl) {
StringConcatenation _builder = new StringConcatenation();
String _name = m.getName();
_builder.append(_name, "");
+ {
+ if (impl) {
+ _builder.append("_impl");
+ }
+ }
_builder.append("(");
{
VarDecl _data = m.getData();
@@ -965,11 +974,10 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
return _builder;
}
- protected CharSequence messageSignature(final Message m) {
+ protected CharSequence messageSignature(final Message m, final boolean impl) {
StringConcatenation _builder = new StringConcatenation();
{
- boolean _isPriv = m.isPriv();
- if (_isPriv) {
+ if ((m.isPriv() || impl)) {
_builder.append("private:");
} else {
_builder.append("public:");
@@ -978,6 +986,11 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append(" void ");
String _name = m.getName();
_builder.append(_name, "");
+ {
+ if (impl) {
+ _builder.append("_impl");
+ }
+ }
_builder.append("(");
{
VarDecl _data = m.getData();
@@ -997,13 +1010,18 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
return _builder;
}
- protected CharSequence messageSignatureDefinition(final Message m, final String classPrefix) {
+ protected CharSequence messageSignatureDefinition(final Message m, final String classPrefix, final boolean impl) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("void ");
_builder.append(classPrefix, "");
_builder.append("::");
String _name = m.getName();
_builder.append(_name, "");
+ {
+ if (impl) {
+ _builder.append("_impl");
+ }
+ }
_builder.append("(");
{
VarDecl _data = m.getData();
@@ -1040,105 +1058,126 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
if (_notEquals) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(", ");
- {
- VarDecl _data_1 = m.getData();
- RefableType _refType = _data_1.getRefType();
- boolean _isRef = _refType.isRef();
- if (_isRef) {
- VarDecl _data_2 = m.getData();
- String _name = _data_2.getName();
- _builder.append(_name, "");
- } else {
- _builder.append("&");
- VarDecl _data_3 = m.getData();
- String _name_1 = _data_3.getName();
- _builder.append(_name_1, "");
- _builder.append(", sizeof(");
- VarDecl _data_4 = m.getData();
- RefableType _refType_1 = _data_4.getRefType();
- DataType _type = _refType_1.getType();
- String _typeName = this._typeHelpers.typeName(_type);
- _builder.append(_typeName, "");
- _builder.append(")");
- }
- }
+ VarDecl _data_1 = m.getData();
+ String _name = _data_1.getName();
+ _builder.append(_name, "");
_xifexpression_1 = _builder.toString();
}
final String dataArg = _xifexpression_1;
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append("new Message(getPeerAddress(), ");
- _builder_1.append(portClassName, "");
- _builder_1.append("::");
- _builder_1.append(dir, "");
- _builder_1.append("_");
- String _name_2 = m.getName();
- _builder_1.append(_name_2, "");
+ String _xifexpression_2 = null;
+ if (((!Objects.equal(m.getData(), null)) && (!m.getData().getRefType().isRef()))) {
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("DataMessage<");
+ VarDecl _data_2 = m.getData();
+ RefableType _refType = _data_2.getRefType();
+ DataType _type = _refType.getType();
+ String _typeName = this._typeHelpers.typeName(_type);
+ _builder_1.append(_typeName, "");
+ _builder_1.append(">");
+ _xifexpression_2 = _builder_1.toString();
+ } else {
+ StringConcatenation _builder_2 = new StringConcatenation();
+ _builder_2.append("Message");
+ _xifexpression_2 = _builder_2.toString();
+ }
+ final String messageType = _xifexpression_2;
+ StringConcatenation _builder_3 = new StringConcatenation();
+ _builder_3.append("new (buffer) ");
+ _builder_3.append(messageType, "");
+ _builder_3.append("(getPeerAddress(), ");
+ _builder_3.append(portClassName, "");
+ _builder_3.append("::");
+ _builder_3.append(dir, "");
+ _builder_3.append("_");
+ String _name_1 = m.getName();
+ _builder_3.append(_name_1, "");
String _elvis = null;
if (dataArg != null) {
_elvis = dataArg;
} else {
_elvis = "";
}
- _builder_1.append(_elvis, "");
- _builder_1.append(")");
- final String message = _builder_1.toString();
- StringConcatenation _builder_2 = new StringConcatenation();
- CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m, classPrefix);
- _builder_2.append(_messageSignatureDefinition, "");
- _builder_2.append(" {");
- _builder_2.newLineIfNotEmpty();
+ _builder_3.append(_elvis, "");
+ _builder_3.append(")");
+ final String message = _builder_3.toString();
+ StringConcatenation _builder_4 = new StringConcatenation();
+ CharSequence _messageSignatureDefinition = this.messageSignatureDefinition(m, classPrefix, false);
+ _builder_4.append(_messageSignatureDefinition, "");
+ _builder_4.append(" {");
+ _builder_4.newLineIfNotEmpty();
{
boolean _notEquals_1 = (!Objects.equal(hdlr, null));
if (_notEquals_1) {
- _builder_2.append("\t");
+ _builder_4.append("\t");
{
DetailCode _detailCode = hdlr.getDetailCode();
EList<String> _lines = _detailCode.getLines();
for(final String command : _lines) {
- _builder_2.append("\t");
- _builder_2.append(command, "\t");
- _builder_2.newLineIfNotEmpty();
+ _builder_4.append("\t");
+ _builder_4.append(command, "\t");
+ _builder_4.newLineIfNotEmpty();
}
}
} else {
- {
- GlobalGeneratorSettings _settings = Main.getSettings();
- boolean _isGenerateMSCInstrumentation = _settings.isGenerateMSCInstrumentation();
- if (_isGenerateMSCInstrumentation) {
- _builder_2.append("\t");
- _builder_2.append("DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),");
- _builder_2.newLine();
- _builder_2.append("\t");
- _builder_2.append("\t");
- _builder_2.append(portClassName, "\t\t");
- _builder_2.append("::getMessageString(");
- _builder_2.append(portClassName, "\t\t");
- _builder_2.append("::");
- _builder_2.append(dir, "\t\t");
- _builder_2.append("_");
- String _name_3 = m.getName();
- _builder_2.append(_name_3, "\t\t");
- _builder_2.append("));");
- _builder_2.newLineIfNotEmpty();
- }
- }
- _builder_2.append("\t");
- _builder_2.append("if (getPeerAddress().isValid()){");
- _builder_2.newLine();
- _builder_2.append("\t");
- _builder_2.append("\t");
- _builder_2.append("getPeerMsgReceiver()->receive(");
- _builder_2.append(message, "\t\t");
- _builder_2.append(");");
- _builder_2.newLineIfNotEmpty();
- _builder_2.append("\t");
- _builder_2.append("}");
- _builder_2.newLine();
+ _builder_4.append("\t");
+ CharSequence _messageCall = this.messageCall(m, true);
+ _builder_4.append(_messageCall, "\t");
+ _builder_4.append(";");
+ _builder_4.newLineIfNotEmpty();
+ }
+ }
+ _builder_4.append("}");
+ _builder_4.newLine();
+ _builder_4.newLine();
+ CharSequence _messageSignatureDefinition_1 = this.messageSignatureDefinition(m, classPrefix, true);
+ _builder_4.append(_messageSignatureDefinition_1, "");
+ _builder_4.append(" {");
+ _builder_4.newLineIfNotEmpty();
+ {
+ GlobalGeneratorSettings _settings = Main.getSettings();
+ boolean _isGenerateMSCInstrumentation = _settings.isGenerateMSCInstrumentation();
+ if (_isGenerateMSCInstrumentation) {
+ _builder_4.append("\t");
+ _builder_4.append("DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),");
+ _builder_4.newLine();
+ _builder_4.append("\t");
+ _builder_4.append(portClassName, "\t");
+ _builder_4.append("::getMessageString(");
+ _builder_4.append(portClassName, "\t");
+ _builder_4.append("::");
+ _builder_4.append(dir, "\t");
+ _builder_4.append("_");
+ String _name_2 = m.getName();
+ _builder_4.append(_name_2, "\t");
+ _builder_4.append("));");
+ _builder_4.newLineIfNotEmpty();
}
}
- _builder_2.append("}");
- _builder_2.newLine();
- _xblockexpression = _builder_2;
+ _builder_4.append("\t");
+ _builder_4.append("if (getPeerAddress().isValid()) {");
+ _builder_4.newLine();
+ _builder_4.append("\t\t");
+ _builder_4.append("Message* buffer = dynamic_cast<IMessageService*>(getPeerMsgReceiver())->getMessageBuffer(sizeof(");
+ _builder_4.append(messageType, "\t\t");
+ _builder_4.append("));");
+ _builder_4.newLineIfNotEmpty();
+ _builder_4.append("\t\t");
+ _builder_4.append("if (buffer) {");
+ _builder_4.newLine();
+ _builder_4.append("\t\t\t");
+ _builder_4.append("getPeerMsgReceiver()->receive(");
+ _builder_4.append(message, "\t\t\t");
+ _builder_4.append(");");
+ _builder_4.newLineIfNotEmpty();
+ _builder_4.append("\t\t");
+ _builder_4.append("}");
+ _builder_4.newLine();
+ _builder_4.append("\t");
+ _builder_4.append("}");
+ _builder_4.newLine();
+ _builder_4.append("}");
+ _builder_4.newLine();
+ _xblockexpression = _builder_4;
}
return _xblockexpression;
}
@@ -1155,7 +1194,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
}
};
final Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- final EList<RoomModel> models = root.getReferencedModels(pc);
StringConcatenation _builder = new StringConcatenation();
_builder.append("/**");
_builder.newLine();
@@ -1391,7 +1429,6 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
}
};
final Iterable<Message> sentMsgs = IterableExtensions.<Message>filter(_allIncomingMessages, _function);
- final EList<RoomModel> models = root.getReferencedModels(pc);
StringConcatenation _builder = new StringConcatenation();
_builder.append("/**");
_builder.newLine();
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip
index 462449c24..9692ea254 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip
index 659a475dd..3e301b4f8 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip
Binary files differ
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/model/GenericPhysical.etphys b/runtime/org.eclipse.etrice.modellib.cpp/model/GenericPhysical.etphys
index 27f442b9c..caec2ba71 100644
--- a/runtime/org.eclipse.etrice.modellib.cpp/model/GenericPhysical.etphys
+++ b/runtime/org.eclipse.etrice.modellib.cpp/model/GenericPhysical.etphys
@@ -14,7 +14,7 @@ PhysicalModel room.generic.physical {
interval = 100ms
prio = 0
stacksize = 1024
- msgblocksize = 64
+ msgblocksize = 128
msgpoolsize = 100
}
@@ -22,7 +22,7 @@ PhysicalModel room.generic.physical {
execmode = blocked
prio = 0
stacksize = 1024
- msgblocksize = 64
+ msgblocksize = 128
msgpoolsize = 100
}
@@ -31,7 +31,7 @@ PhysicalModel room.generic.physical {
interval = 100ms
prio = 0
stacksize = 1024
- msgblocksize = 64
+ msgblocksize = 128
msgpoolsize = 100
}
}
diff --git a/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room b/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room
index 4229d72c8..c1e56cd71 100644
--- a/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room
+++ b/runtime/org.eclipse.etrice.modellib.cpp/model/TimingService.room
@@ -248,13 +248,7 @@ RoomModel room.basic.service.timing {
incoming startTimer {
"if (status==0){
status=ET_TIMER_RUNNING | ET_TIMER_PERIODIC;
- DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- PTimer::getMessageString(PTimer::IN_startTimer));
- if (getPeerAddress().isValid()){
- getPeerMsgReceiver()->receive(new Message(getPeerAddress(),PTimer::IN_startTimer,
- &time,
- sizeof(uint32)));
- }
+ startTimer_impl(time);
}
"
}
@@ -262,13 +256,7 @@ RoomModel room.basic.service.timing {
incoming startTimeout {
"if (status==0){
status = ET_TIMER_RUNNING;
- DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- PTimer::getMessageString(PTimer::IN_startTimeout));
- if (getPeerAddress().isValid()){
- getPeerMsgReceiver()->receive(new Message(getPeerAddress(),PTimer::IN_startTimeout,
- &time,
- sizeof(uint32)));
- }
+ startTimeout_impl(time);
}
"
}
@@ -291,11 +279,7 @@ RoomModel room.basic.service.timing {
"
if (status!=0){
status=0;
- DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(),
- PTimer::getMessageString(PTimer::IN_kill));
- if (getPeerAddress().isValid()){
- getPeerMsgReceiver()->receive(new Message(getPeerAddress(),PTimer::IN_kill));
- }
+ kill_impl();
}
"
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.cpp
deleted file mode 100644
index a52351d1b..000000000
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Juergen Haug (initial contribution)
- *
- *******************************************************************************/
-
-#include "common/messaging/AbstractMessageService.h"
-#include <string>
-
-namespace etRuntime {
-
-AbstractMessageService::AbstractMessageService(IRTObject* parent, const std::string& name, int node, int thread) :
- RTObject(parent, name),
- m_address(node, thread, 0),
- m_messageQueue(this, "Queue"),
- m_messageDispatcher(this, m_address.createInc(), "Dispatcher") {
-}
-
-Address AbstractMessageService::getFreeAddress() {
- return m_messageDispatcher.getFreeAddress();
-}
-
-void AbstractMessageService::freeAddress(const Address& addr) {
- m_messageDispatcher.freeAddress(addr);
-}
-
-void AbstractMessageService::addMessageReceiver(IMessageReceiver& receiver) {
- m_messageDispatcher.addMessageReceiver(receiver);
-}
-
-void AbstractMessageService::removeMessageReceiver(IMessageReceiver& receiver) {
- m_messageDispatcher.removeMessageReceiver(receiver);
-}
-
-void AbstractMessageService::addPollingMessageReceiver(IMessageReceiver& receiver) {
- m_messageDispatcher.addPollingMessageReceiver(receiver);
-}
-
-void AbstractMessageService::removePollingMessageReceiver(IMessageReceiver& receiver) {
- m_messageDispatcher.removePollingMessageReceiver(receiver);
-}
-
-void AbstractMessageService::receive(const Message* msg) {
- if (msg != 0) {
- m_messageQueue.push(const_cast<Message*>(msg));
- }
-}
-
-std::string AbstractMessageService::toString() const {
- return getName() + " " + getAddress().toID();
-}
-
-}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.h
deleted file mode 100644
index 08032faf6..000000000
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/AbstractMessageService.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * CONTRIBUTORS:
- * Juergen Haug (initial contribution)
- *
- *******************************************************************************/
-#ifndef SRC_COMMON_MESSAGING_ABSTRACTMESSAGESERVICE_H_
-#define SRC_COMMON_MESSAGING_ABSTRACTMESSAGESERVICE_H_
-
-#include "common/messaging/Address.h"
-#include "common/messaging/IMessageService.h"
-#include "common/messaging/MessageDispatcher.h"
-#include "common/messaging/MessageSeQueue.h"
-#include <string>
-
-namespace etRuntime {
-
-class AbstractMessageService: public RTObject, public IMessageService {
-
-public:
- virtual ~AbstractMessageService() {}
-
- virtual const Address& getAddress() const { return m_address; }
-
- virtual Address getFreeAddress();
-
- virtual void freeAddress(const Address& addr);
-
- virtual void addMessageReceiver(IMessageReceiver& receiver);
- virtual void removeMessageReceiver(IMessageReceiver& receiver);
-
- virtual void addPollingMessageReceiver(IMessageReceiver& receiver);
- virtual void removePollingMessageReceiver(IMessageReceiver& receiver);
- virtual void receive(const Message* msg);
-
-protected:
- AbstractMessageService(IRTObject* parent, const std::string& name, int node, int thread);
-
- MessageSeQueue& getMessageQueue() {
- return m_messageQueue;
- }
- MessageDispatcher& getMessageDispatcher() {
- return m_messageDispatcher;
- }
-
- std::string toString() const;
-
-private:
- // TODO: add internal message queue for less locks (faster thread internal
- // messaging)
- Address m_address;
- MessageSeQueue m_messageQueue;
- MessageDispatcher m_messageDispatcher;
-
- AbstractMessageService();
- AbstractMessageService(AbstractMessageService const&);
- AbstractMessageService& operator=(AbstractMessageService const&);
-};
-
-}
-#endif /* SRC_COMMON_MESSAGING_ABSTRACTMESSAGESERVICE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageMemory.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageMemory.h
new file mode 100644
index 000000000..78656443a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageMemory.h
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2016 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Jan Belle (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef SRC_COMMON_MESSAGING_IMESSAGEMEMORY_H_
+#define SRC_COMMON_MESSAGING_IMESSAGEMEMORY_H_
+
+#include "common/messaging/Message.h"
+#include "common/messaging/IRTObject.h"
+
+namespace etRuntime {
+
+class IMessageMemory : virtual IRTObject {
+public:
+ virtual ~IMessageMemory() {}
+
+ // returns a buffer of the specified size in bytes
+ // use the placement constructor to create objects and call the destructor explicitly
+ virtual Message* getMessageBuffer(size_t size) = 0;
+ // frees the buffer
+ virtual void returnMessageBuffer(const Message* buffer) = 0;
+};
+
+} /* namespace etRuntime */
+
+#endif /* SRC_COMMON_MESSAGING_IMESSAGEMEMORY_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageService.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageService.h
index 145d767d7..a2871c0f4 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/IMessageService.h
@@ -39,6 +39,9 @@ public:
virtual void addPollingMessageReceiver(IMessageReceiver& receiver) = 0;
virtual void removePollingMessageReceiver(IMessageReceiver& receiver) = 0;
+ virtual Message* getMessageBuffer(int size) = 0;
+ virtual void returnMessageBuffer(const Message* buffer) = 0;
+
// TODO Thread
// void setThread(Thread thread);
//
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
index d9e5df646..69705f972 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.cpp
@@ -18,20 +18,6 @@
namespace etRuntime {
-Message::Message(const Address& addr, int evtId, const void* dataToCopy, std::size_t dataSize) :
- m_address(addr),
- m_evtId(evtId),
- m_next(0),
- m_dataSize(0),
- m_data(0){
- if(dataToCopy != 0 && dataSize > 0){
- m_data = std::malloc(dataSize);
- if(m_data != 0){
- m_dataSize = dataSize;
- std::memcpy(m_data, dataToCopy, dataSize);
- }
- }
-}
Message::Message(const Address& addr, int evtId, void* dataPtr) :
m_address(addr),
m_evtId(evtId),
@@ -49,8 +35,6 @@ Message::Message(const Address& addr, int evtId) :
Message::~Message() {
m_evtId = 0;
m_next = 0;
- if(m_dataSize > 0)
- std::free(m_data);
m_data = 0;
m_dataSize = 0;
}
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
index b97802808..e4564c41a 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/Message.h
@@ -25,12 +25,10 @@ class Message {
public:
- // Messages with data TODO MessageBuffer
- Message(const Address& addr, int evtId, const void* dataToCopy, std::size_t dataSize);
Message(const Address& addr, int evtId, void* dataPtr);
Message(const Address& addr, int evtId);
- ~Message();
+ virtual ~Message();
const Address& getAddress() const {
return m_address;
@@ -72,5 +70,18 @@ private:
};
+template<class T>
+class DataMessage : public Message {
+public:
+ DataMessage(const Address& addr, int evtId, const T& dataToCopy) :
+ Message(addr, evtId, &m_data), m_data(dataToCopy) {}
+private:
+ T m_data;
+
+ DataMessage(void);
+ DataMessage(DataMessage const&);
+ DataMessage& operator=(DataMessage const&);
+};
+
} /* namespace etRuntime */
#endif /* MESSAGE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
index e8035b12a..f5250be98 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/MessageDispatcher.cpp
@@ -12,6 +12,7 @@
#include "common/messaging/Message.h"
#include "common/messaging/MessageDispatcher.h"
+#include "common/messaging/IMessageService.h"
namespace etRuntime {
@@ -82,9 +83,10 @@ void MessageDispatcher::receive(const Message* msg) {
} else if (receiver != 0) {
receiver->receive(msg);
// TODO: error handling for not found addresses
-
- delete msg;
}
+
+ msg->~Message();
+ dynamic_cast<IMessageService*>(getParent())->returnMessageBuffer(msg);
}
std::string MessageDispatcher::toString() const {
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 e2d74934c..62d62d66f 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
@@ -10,7 +10,6 @@
*
*******************************************************************************/
-#include "common/messaging/MessageDispatcher.h"
#include "common/messaging/MessageSeQueue.h"
#include "common/messaging/MessageService.h"
#include "common/messaging/MessageServiceController.h"
@@ -21,12 +20,16 @@
namespace etRuntime {
-MessageService::MessageService(IRTObject* parent, IMessageService::ExecMode mode, int node, int thread, const std::string& name, int priority) :
- AbstractMessageService(parent, name, node, thread),
+MessageService::MessageService(IRTObject* parent, IMessageService::ExecMode mode, int node, int thread, const std::string& name,
+ IMessageMemory* memory, int priority) :
+ RTObject(parent, name),
m_running(false),
m_execMode(mode),
m_lastMessageTimestamp(0),
- m_pollingMessage(getMessageDispatcher().getAddress(), 0) {
+ m_address(node, thread, 0),
+ m_messageQueue(this, "Queue"),
+ m_messageDispatcher(this, m_address.createInc(), "Dispatcher"),
+ m_messageMemory(memory) {
etTime interval;
interval.sec = 0;
@@ -35,12 +38,15 @@ MessageService::MessageService(IRTObject* parent, IMessageService::ExecMode mode
}
MessageService::MessageService(IRTObject* parent, IMessageService::ExecMode mode, etTime interval, int node, int thread,
- const std::string& name, int priority) :
- AbstractMessageService(parent, name, node, thread),
+ const std::string& name, IMessageMemory* memory, int priority) :
+ RTObject(parent, name),
m_running(false),
m_execMode(mode),
m_lastMessageTimestamp(0),
- m_pollingMessage(getMessageDispatcher().getAddress(), 0) {
+ m_address(node, thread, 0),
+ m_messageQueue(this, "Queue"),
+ m_messageDispatcher(this, m_address.createInc(), "Dispatcher"),
+ m_messageMemory(memory) {
MessageService_init(interval, priority);
}
@@ -67,12 +73,18 @@ void MessageService::MessageService_init(etTime interval, int priority) {
}
MessageService::~MessageService() {
+ while(m_messageQueue.getSize() > 0) {
+ const Message* msg = m_messageQueue.pop();
+ msg->~Message();
+ returnMessageBuffer(msg);
+ }
etMutex_destruct(&m_mutex);
etSema_destruct(&m_executionSemaphore);
etThread_destruct(&m_thread);
if (m_execMode == IMessageService::POLLED || m_execMode == IMessageService::MIXED) {
etTimer_destruct(&m_timer);
}
+ delete m_messageMemory;
}
void MessageService::start() {
@@ -86,7 +98,7 @@ void MessageService::start() {
void MessageService::run() {
while (m_running) {
etMutex_enter(&m_mutex);
- const Message* msg = getMessageQueue().pop(); // get next Message from Queue
+ const Message* msg = m_messageQueue.pop(); // get next Message from Queue
etMutex_leave(&m_mutex);
if (msg == 0) {
// no message in queue -> wait till Thread is notified
@@ -94,7 +106,7 @@ void MessageService::run() {
} else {
//TODO: set timestamp
// m_lastMessageTimestamp = System.currentTimeMillis();
- getMessageDispatcher().receive(msg);
+ m_messageDispatcher.receive(msg);
}
}
@@ -103,14 +115,16 @@ void MessageService::run() {
void MessageService::receive(const Message* msg) {
etMutex_enter(&m_mutex);
- AbstractMessageService::receive(msg);
+ if (msg != 0) {
+ m_messageQueue.push(const_cast<Message*>(msg));
+ }
etSema_wakeup(&m_executionSemaphore);
etMutex_leave(&m_mutex);
}
Address MessageService::getFreeAddress() {
etMutex_enter(&m_mutex);
- Address address = AbstractMessageService::getFreeAddress();
+ Address address = m_messageDispatcher.getFreeAddress();
etMutex_leave(&m_mutex);
return address;
@@ -118,34 +132,51 @@ Address MessageService::getFreeAddress() {
void MessageService::freeAddress(const Address& addr) {
etMutex_enter(&m_mutex);
- AbstractMessageService::freeAddress(addr);
+ m_messageDispatcher.freeAddress(addr);
etMutex_leave(&m_mutex);
}
void MessageService::addMessageReceiver(IMessageReceiver& receiver) {
etMutex_enter(&m_mutex);
- AbstractMessageService::addMessageReceiver(receiver);
+ m_messageDispatcher.addMessageReceiver(receiver);
etMutex_leave(&m_mutex);
}
void MessageService::removeMessageReceiver(IMessageReceiver& receiver) {
etMutex_enter(&m_mutex);
- AbstractMessageService::removeMessageReceiver(receiver);
+ m_messageDispatcher.removeMessageReceiver(receiver);
etMutex_leave(&m_mutex);
}
void MessageService::addPollingMessageReceiver(IMessageReceiver& receiver) {
etMutex_enter(&m_mutex);
- AbstractMessageService::addPollingMessageReceiver(receiver);
+ m_messageDispatcher.addPollingMessageReceiver(receiver);
etMutex_leave(&m_mutex);
}
void MessageService::removePollingMessageReceiver(IMessageReceiver& receiver) {
etMutex_enter(&m_mutex);
- AbstractMessageService::removePollingMessageReceiver(receiver);
+ m_messageDispatcher.removePollingMessageReceiver(receiver);
+ etMutex_leave(&m_mutex);
+}
+
+Message* MessageService::getMessageBuffer(int size) {
+ etMutex_enter(&m_mutex);
+ Message* buffer = m_messageMemory->getMessageBuffer(size);
+ etMutex_leave(&m_mutex);
+ return buffer;
+}
+
+void MessageService::returnMessageBuffer(const Message* buffer) {
+ etMutex_enter(&m_mutex);
+ m_messageMemory->returnMessageBuffer(buffer);
etMutex_leave(&m_mutex);
}
+std::string MessageService::toString() const {
+ return getName() + " " + getAddress().toID();
+}
+
void MessageService::terminate() {
if (m_execMode == IMessageService::POLLED || m_execMode == IMessageService::MIXED) {
etTimer_stop(&m_timer);
@@ -160,7 +191,14 @@ void MessageService::terminate() {
// called by osal timer, thread ?
void MessageService::pollingTask() {
if (m_running) {
- receive(&m_pollingMessage);
+ Message* pollingMessage = getMessageBuffer(sizeof(Message));
+ if (pollingMessage) {
+ new (pollingMessage) Message(m_messageDispatcher.getAddress(), 0);
+ receive(pollingMessage);
+ }
+ else {
+ // TODO JB: error handling for pollingMessage == NULL
+ }
}
}
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 f27ce2e93..388226079 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
@@ -13,10 +13,11 @@
#ifndef MESSAGESERVICE_H_
#define MESSAGESERVICE_H_
-#include "common/messaging/AbstractMessageService.h"
-
#include "common/messaging/IMessageService.h"
#include "common/messaging/Message.h"
+#include "common/messaging/Address.h"
+#include "common/messaging/StaticMessageMemory.h"
+#include "common/messaging/MessageDispatcher.h"
#include "etDatatypes.h"
#include "osal/etMutex.h"
#include "osal/etSema.h"
@@ -26,7 +27,7 @@
namespace etRuntime {
-class MessageService: public AbstractMessageService {
+class MessageService: public RTObject, public IMessageService {
public:
@@ -34,8 +35,8 @@ public:
POLLED, BLOCKED, MIXED
};
- MessageService(IRTObject* parent, IMessageService::ExecMode mode, int node, int thread, const std::string& name, int priority = 0);
- MessageService(IRTObject* parent, IMessageService::ExecMode mode, etTime interval, int node, int thread, const std::string& name, int priority = 0);
+ MessageService(IRTObject* parent, IMessageService::ExecMode mode, int node, int thread, const std::string& name, IMessageMemory* memory, int priority = 0);
+ MessageService(IRTObject* parent, IMessageService::ExecMode mode, etTime interval, int node, int thread, const std::string& name, IMessageMemory* memory, int priority = 0);
virtual ~MessageService();
void run();
@@ -54,6 +55,12 @@ public:
virtual void removePollingMessageReceiver(IMessageReceiver& receiver);
virtual void receive(const Message* msg);
+ Message* getMessageBuffer(int size);
+ void returnMessageBuffer(const Message* buffer);
+
+ const Address& getAddress(void) const { return m_address; }
+ std::string toString() const;
+
protected:
long getLastMessageTimestamp() const {
@@ -75,13 +82,17 @@ private:
etBool m_running;
IMessageService::ExecMode m_execMode;
long m_lastMessageTimestamp;
- Message m_pollingMessage;
etMutex m_mutex;
etSema m_executionSemaphore;
etThread m_thread;
etTimer m_timer;
+ Address m_address;
+ MessageSeQueue m_messageQueue;
+ MessageDispatcher m_messageDispatcher;
+ IMessageMemory* m_messageMemory;
+
void MessageService_init(etTime interval, int priority); // common ctor
MessageService();
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.cpp
new file mode 100644
index 000000000..c7f73870d
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.cpp
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2016 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Jan Belle (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "common/messaging/StaticMessageMemory.h"
+
+namespace etRuntime {
+
+StaticMessageMemory::StaticMessageMemory(IRTObject* parent, const std::string& name, size_t size, int number) :
+ RTObject(parent, name), m_size(size), m_msgPool(NULL, "memory"), m_buffer(0) {
+ m_buffer = new uint8_t[m_size * number];
+ uint8_t* ptr = m_buffer;
+ for(int i = 0; i < number; ++i) {
+ Message* msg = new (ptr) Message(Address::EMPTY, 0);
+ m_msgPool.push(msg);
+ ptr += m_size;
+ }
+}
+
+StaticMessageMemory::~StaticMessageMemory() {
+ delete[] m_buffer;
+}
+
+Message* StaticMessageMemory::getMessageBuffer(size_t size) {
+ if(size <= m_size && m_msgPool.getSize() > 0) {
+ return const_cast<Message*>(m_msgPool.pop());
+ }
+ else {
+ return 0;
+ }
+}
+
+void StaticMessageMemory::returnMessageBuffer(const Message* buffer) {
+ m_msgPool.push(const_cast<Message*>(buffer));
+}
+
+} /* namespace etRuntime */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.h b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.h
new file mode 100644
index 000000000..56b5eabb1
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/messaging/StaticMessageMemory.h
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2016 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Jan Belle (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef SRC_COMMON_MESSAGING_STATICMESSAGEMEMORY_H_
+#define SRC_COMMON_MESSAGING_STATICMESSAGEMEMORY_H_
+
+#include "common/messaging/IMessageMemory.h"
+#include "common/messaging/RTObject.h"
+#include "common/messaging/MessageSeQueue.h"
+
+namespace etRuntime {
+
+class StaticMessageMemory : public IMessageMemory, public RTObject {
+public:
+ StaticMessageMemory(IRTObject* parent, const std::string& name, size_t size, int number);
+ virtual ~StaticMessageMemory();
+
+ // returns a buffer of the specified size in bytes
+ Message* getMessageBuffer(size_t size);
+ // frees the buffer
+ void returnMessageBuffer(const Message* buffer);
+
+ // return the size in bytes of one message buffer
+ int getBufferSize(void) { return m_size; }
+ // returns the number of free message buffers
+ int getMessagePoolSize(void) { return m_msgPool.getSize(); }
+
+private:
+ size_t m_size;
+ MessageSeQueue m_msgPool;
+ uint8_t* m_buffer;
+};
+
+} /* namespace etRuntime */
+
+#endif /* SRC_COMMON_MESSAGING_STATICMESSAGEMEMORY_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.cpp b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.cpp
index 52be7ecc7..fc9747cc0 100644
--- a/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.cpp
+++ b/runtime/org.eclipse.etrice.runtime.cpp/src/common/modelbase/ReplicatedActorClassBase.cpp
@@ -19,8 +19,9 @@ ReplicatedActorClassBase::ReplicatedActorClassBase(IRTObject* parent, const std:
}
ReplicatedActorClassBase::~ReplicatedActorClassBase() {
- for(std::vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); it++)
+ for(std::vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it) {
delete *it;
+ }
}
void ReplicatedActorClassBase::createSubActors(int number) {
@@ -33,12 +34,13 @@ void ReplicatedActorClassBase::createSubActors(int number) {
}
void ReplicatedActorClassBase::initialize() {
- for(std::vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); it++)
+ for(std::vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it) {
(*it)->initialize();
+ }
}
void ReplicatedActorClassBase::setProbesActive(bool recursive, bool active) {
- for(std::vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); it++)
+ for(std::vector<ActorClassBase*>::iterator it = m_items.begin(); it != m_items.end(); ++it)
(*it)->setProbesActive(recursive, active);
}
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/PingPongThread.etphys b/tests/org.eclipse.etrice.generator.common.tests/models/PingPongThread.etphys
index 5e533211e..1215b84c6 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/PingPongThread.etphys
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/PingPongThread.etphys
@@ -3,7 +3,7 @@ PhysicalModel PingPongThread {
PhysicalSystem Sys {
NodeRef node1: PC
}
-
+
NodeClass PC {
runtime = PC
priomin = 1
@@ -13,7 +13,7 @@ PhysicalModel PingPongThread {
execmode = blocked
prio = 5
stacksize = 1024
- msgblocksize = 64
+ msgblocksize = 128
msgpoolsize = 32
}
@@ -21,7 +21,7 @@ PhysicalModel PingPongThread {
execmode = blocked
prio = 5
stacksize = 1024
- msgblocksize = 64
+ msgblocksize = 128
msgpoolsize = 32
}
@@ -29,7 +29,7 @@ PhysicalModel PingPongThread {
execmode = blocked
prio = 5
stacksize = 1024
- msgblocksize = 64
+ msgblocksize = 128
msgpoolsize = 32
}
@@ -37,7 +37,7 @@ PhysicalModel PingPongThread {
execmode = blocked
prio = 5
stacksize = 1024
- msgblocksize = 64
+ msgblocksize = 128
msgpoolsize = 32
}
@@ -46,7 +46,7 @@ PhysicalModel PingPongThread {
interval = 100 ms
prio = 5
stacksize = 1024
- msgblocksize = 64
+ msgblocksize = 128
msgpoolsize = 32
}
}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/RunAllTestCases.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/RunAllTestCases.cpp
index 3d7695239..737754cc1 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/RunAllTestCases.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/RunAllTestCases.cpp
@@ -23,6 +23,7 @@
#include "messaging/MessageDispatcherTest.h"
#include "messaging/MessageServiceTest.h"
#include "messaging/MessageServiceControllerTest.h"
+#include "messaging/StaticMessageMemoryTest.h"
#include "etUnit/etUnit.h"
@@ -72,6 +73,9 @@ int main() {
MessageServiceControllerTest msgSvcCtrlTest;
msgSvcCtrlTest.run();
+ StaticMessageMemoryTest staticMsgMemTest;
+ staticMsgMemTest.run();
+
etUnit_close();
return 0;
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.cpp
index 9b489d9eb..7a53e2fc9 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/debugging/DebuggingServiceTest.cpp
@@ -14,6 +14,7 @@
#include "common/debugging/DebuggingService.h"
#include "common/messaging/MessageService.h"
#include "common/messaging/RTServices.h"
+#include "common/messaging/StaticMessageMemory.h"
#include "etUnit/etUnit.h"
using namespace etRuntime;
@@ -21,7 +22,7 @@ using namespace etRuntime;
void DebuggingServiceTest::testLogging() {
MessageService msgSvc(NULL, IMessageService::BLOCKED, 0, 0,
- "TestMessageService");
+ "TestMessageService", new StaticMessageMemory(NULL, "TestMemory", 64, 100));
RTServices::getInstance().getMsgSvcCtrl().addMsgSvc(msgSvc);
RTServices::getInstance().getMsgSvcCtrl().start();
SubSystemClass subSystem(NULL, "TestSubSystem");
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.cpp
index f81c3aee9..730a3a7d9 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageDispatcherTest.cpp
@@ -13,6 +13,8 @@
#include "messaging/MessageDispatcherTest.h"
#include "etUnit/etUnit.h"
#include "common/messaging/MessageDispatcher.h"
+#include "common/messaging/MessageService.h"
+#include "common/messaging/StaticMessageMemory.h"
using namespace etRuntime;
@@ -58,19 +60,27 @@ void MessageDispatcherTest::testDispatching() {
const char *failMsg = "MessageDispatcher dispatching test failed";
// Test dispatching Messages
- MessageDispatcher msgDisp(NULL, Address(1, 2, 0), "TestMessageDispatcher");
+ MessageService msgSvc(NULL, IMessageService::BLOCKED, 1, 2,
+ "Test MessageService", new StaticMessageMemory(NULL, "TestMemory", 64, 100));
+ MessageDispatcher msgDisp(&msgSvc, Address(1, 2, 0), "TestMessageDispatcher");
Address addr1 = msgDisp.getFreeAddress();
Address addr2 = msgDisp.getFreeAddress();
Address addr3 = msgDisp.getFreeAddress();
SimpleMessageReceiver recv1(NULL, "Test receiver1", addr1);
SimpleMessageReceiver recv2(NULL, "Test receiver2", addr2);
SimpleMessageReceiver recv3(NULL, "Test receiver3", addr3);
- Message *msg1 = new Message(addr1, 1, NULL);
- Message *msg2 = new Message(addr2, 2, NULL);
- Message *msg3 = new Message(addr3, 3, NULL);
- Message *msg4 = new Message(addr1, 4, NULL);
- Message *msg5 = new Message(addr2, 5, NULL);
- Message *msg6 = new Message(addr3, 6, NULL);
+ Message *msg1 = msgSvc.getMessageBuffer(sizeof(Message));
+ Message *msg2 = msgSvc.getMessageBuffer(sizeof(Message));
+ Message *msg3 = msgSvc.getMessageBuffer(sizeof(Message));
+ Message *msg4 = msgSvc.getMessageBuffer(sizeof(Message));
+ Message *msg5 = msgSvc.getMessageBuffer(sizeof(Message));
+ Message *msg6 = msgSvc.getMessageBuffer(sizeof(Message));
+ msg1 = new (msg1) Message(addr1, 1);
+ msg2 = new (msg2) Message(addr2, 2);
+ msg3 = new (msg3) Message(addr3, 3);
+ msg4 = new (msg4) Message(addr1, 4);
+ msg5 = new (msg5) Message(addr2, 5);
+ msg6 = new (msg6) Message(addr3, 6);
msgDisp.addMessageReceiver(recv1);
msgDisp.receive(msg1);
@@ -98,16 +108,17 @@ void MessageDispatcherTest::testDispatching() {
msgDisp.removeMessageReceiver(recv3);
// Test polling Messages
- Message pollMsg(Address(1, 2, 0), 0, NULL);
+ Message *pollMsg = msgSvc.getMessageBuffer(sizeof(Message));
+ pollMsg = new (pollMsg) Message(Address(1, 2, 0), 0);
msgDisp.addPollingMessageReceiver(recv1);
msgDisp.addPollingMessageReceiver(recv2);
msgDisp.addPollingMessageReceiver(recv3);
- msgDisp.receive(&pollMsg);
- EXPECT_EQUAL_PTR(m_caseId, failMsg, &pollMsg,
+ msgDisp.receive(pollMsg);
+ EXPECT_EQUAL_PTR(m_caseId, failMsg, pollMsg,
recv1.getLastReceivedMessagePtr());
- EXPECT_EQUAL_PTR(m_caseId, failMsg, &pollMsg,
+ EXPECT_EQUAL_PTR(m_caseId, failMsg, pollMsg,
recv2.getLastReceivedMessagePtr());
- EXPECT_EQUAL_PTR(m_caseId, failMsg, &pollMsg,
+ EXPECT_EQUAL_PTR(m_caseId, failMsg, pollMsg,
recv3.getLastReceivedMessagePtr());
msgDisp.removePollingMessageReceiver(recv1);
msgDisp.removePollingMessageReceiver(recv2);
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceControllerTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceControllerTest.cpp
index 374aaba79..439d9c079 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceControllerTest.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceControllerTest.cpp
@@ -61,9 +61,9 @@ void MessageServiceControllerTest::testMsgSvcManagement() {
MessageServiceController& msgSvcController =
RTServices::getInstance().getMsgSvcCtrl();
MessageService msgSvc1(NULL, IMessageService::BLOCKED, 1,
- msgSvcController.getNewID(), "MessageService1");
+ msgSvcController.getNewID(), "MessageService1", new StaticMessageMemory(NULL, "TestMemory", 64, 100));
MessageService msgSvc2(NULL, IMessageService::POLLED, 1,
- msgSvcController.getNewID(), "MessageService2");
+ msgSvcController.getNewID(), "MessageService2", new StaticMessageMemory(NULL, "TestMemory", 64, 100));
msgSvcController.addMsgSvc(msgSvc1);
msgSvcController.addMsgSvc(msgSvc2);
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceTest.cpp
index e777b405f..728b8efff 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceTest.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageServiceTest.cpp
@@ -66,7 +66,7 @@ void MessageServiceTest::testBlocked() {
MessageServiceController& msgSvcCtrl =
RTServices::getInstance().getMsgSvcCtrl();
MessageService msgService(NULL, IMessageService::BLOCKED, 1, 2,
- "Test MessageService");
+ "Test MessageService", new StaticMessageMemory(NULL, "TestMemory", sizeof(Message), 10000000));
msgSvcCtrl.addMsgSvc(msgService);
MessageCounter msgCounter(NULL, "MessageCounter", addr);
msgService.addMessageReceiver(msgCounter);
@@ -110,7 +110,7 @@ void MessageServiceTest::testPolled() {
MessageServiceController& msgSvcCtrl =
RTServices::getInstance().getMsgSvcCtrl();
MessageService msgService(NULL, IMessageService::POLLED, interval, 1, 2,
- "Test MessageService");
+ "Test MessageService", new StaticMessageMemory(NULL, "TestMemory", 64, 100));
msgSvcCtrl.addMsgSvc(msgService);
MessageCounter msgCounter(NULL, "Message Counter",
msgService.getFreeAddress());
@@ -162,7 +162,9 @@ void Sender::terminate() {
void Sender::run() {
while (m_running) {
- m_msgService.receive(new Message(m_addr, 0));
+ Message* msg = m_msgService.getMessageBuffer(sizeof(Message));
+ msg = new (msg) Message(m_addr, 0);
+ m_msgService.receive(msg);
m_messagesSent++;
}
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageTest.cpp
index db8c29d03..549d31485 100644
--- a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageTest.cpp
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/MessageTest.cpp
@@ -36,12 +36,15 @@ void MessageTest::testConstructors() {
EXPECT_EQUAL_INT16(m_caseId, failMsg, 1, msg2.getEvtId());
EXPECT_EQUAL_PTR(m_caseId, failMsg, &data, msg2.getData());
- // Test constructor Message(const Address& addr, int evtm_caseId, const void* dataToCopy, std::size_t dataSize)
- Message msg3(addr, 1, &data, sizeof(int));
- EXPECT_TRUE(m_caseId, failMsg, msg3.getAddress() == addr);
- EXPECT_EQUAL_INT16(m_caseId, failMsg, 1, msg3.getEvtId());
+ // Test constructor DataMessage(const Address& addr, int evtm_caseId, const T& dataToCopy)
+ Message* msg3 = (Message*) new uint8_t[sizeof(DataMessage<int>)];
+ new (msg3) DataMessage<int>(addr, 1, data);
+ EXPECT_TRUE(m_caseId, failMsg, msg3->getAddress() == addr);
+ EXPECT_EQUAL_INT16(m_caseId, failMsg, 1, msg3->getEvtId());
EXPECT_TRUE(m_caseId, failMsg,
- *(static_cast<int*>(msg3.getData())) == data);
+ *(static_cast<int*>(msg3->getData())) == data);
+ msg3->~Message();
+ delete[] (uint8_t*) msg3;
}
void MessageTest::testGetters() {
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/StaticMessageMemoryTest.cpp b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/StaticMessageMemoryTest.cpp
new file mode 100644
index 000000000..0ad73b81c
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/StaticMessageMemoryTest.cpp
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2016 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Jan Belle (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "StaticMessageMemoryTest.h"
+#include "common/messaging/Message.h"
+#include "common/messaging/StaticMessageMemory.h"
+#include "etUnit/etUnit.h"
+
+using namespace etRuntime;
+
+void StaticMessageMemoryTest::test() {
+ const char* failMsg = "StaticMessageMemoryTest failed";
+
+ StaticMessageMemory mem(NULL, "TestMemory", sizeof(DataMessage<uint32_t>), 10);
+
+ EXPECT_EQUAL_INT32(m_caseId, failMsg, sizeof(DataMessage<uint32_t>), mem.getBufferSize());
+ EXPECT_EQUAL_INT32(m_caseId, failMsg, 10, mem.getMessagePoolSize());
+
+ Message* msg[10];
+
+ for (int i = 0; i < 10; ++i) {
+ msg[i] = mem.getMessageBuffer(0);
+ EXPECT_TRUE(m_caseId, failMsg, msg[i] != NULL);
+ EXPECT_EQUAL_INT32(m_caseId, failMsg, 9 - i, mem.getMessagePoolSize());
+ new (msg[i]) Message(Address::EMPTY, 0, NULL);
+ }
+ EXPECT_EQUAL_PTR(m_caseId, failMsg, NULL, mem.getMessageBuffer(0));
+ for (int i = 0; i < 10; ++i) {
+ mem.returnMessageBuffer(msg[i]);
+ EXPECT_EQUAL_INT32(m_caseId, failMsg, i + 1, mem.getMessagePoolSize());
+ }
+
+ msg[0] = mem.getMessageBuffer(4);
+ EXPECT_TRUE(m_caseId, failMsg, msg[0] != NULL);
+ msg[1] = mem.getMessageBuffer(2);
+ EXPECT_TRUE(m_caseId, failMsg, msg[1] != NULL);
+ msg[2] = mem.getMessageBuffer(1);
+ EXPECT_TRUE(m_caseId, failMsg, msg[2] != NULL);
+ uint32_t* ui32 = new uint32_t(32);
+ uint16_t* ui16 = new uint16_t(16);
+ uint8_t* ui8 = new uint8_t(8);
+ new (msg[0]) DataMessage<uint32_t>(Address::EMPTY, 1, *ui32);
+ new (msg[1]) DataMessage<uint16_t>(Address::EMPTY, 1, *ui16);
+ new (msg[2]) DataMessage<uint8_t>(Address::EMPTY, 1, *ui8);
+ delete ui32;
+ delete ui16;
+ delete ui8;
+ ui32 = (uint32_t*) msg[0]->getData();
+ ui16 = (uint16_t*) msg[1]->getData();
+ ui8 = (uint8_t*) msg[2]->getData();
+ EXPECT_EQUAL_UINT32(m_caseId, failMsg, 32, *ui32);
+ EXPECT_EQUAL_UINT16(m_caseId, failMsg, 16, *ui16);
+ EXPECT_EQUAL_UINT8(m_caseId, failMsg, 8, *ui8);
+ msg[0]->~Message();
+ msg[1]->~Message();
+ msg[2]->~Message();
+ mem.returnMessageBuffer(msg[2]);
+ mem.returnMessageBuffer(msg[1]);
+ mem.returnMessageBuffer(msg[0]);
+}
+
+void StaticMessageMemoryTest::runAllTestCases() {
+ ADD_TESTCASE_CPP(test)
+}
+
diff --git a/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/StaticMessageMemoryTest.h b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/StaticMessageMemoryTest.h
new file mode 100644
index 000000000..44b74d060
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.cpp.tests/src/messaging/StaticMessageMemoryTest.h
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2016 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Jan Belle (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef SRC_MESSAGING_STATICMESSAGEMEMORYTEST_H_
+#define SRC_MESSAGING_STATICMESSAGEMEMORYTEST_H_
+
+#include "util/etTestSuite.h"
+
+class StaticMessageMemoryTest: public etTestSuite {
+public:
+ StaticMessageMemoryTest(void) :
+ etTestSuite("StaticMessageMemoryTest") {
+ }
+
+protected:
+ void runAllTestCases(void);
+ void test(void);
+};
+
+#endif /* SRC_MESSAGING_STATICMESSAGEMEMORYTEST_H_ */

Back to the top