Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2012-02-02 00:18:47 +0000
committerThomas Schuetz2012-02-02 00:18:47 +0000
commitcfe46b9799947e484ed42a2eefded0db55d43904 (patch)
treed9bc3a1da58f07a53405c35cc698716db4e8fcf2 /runtime
parent68374559c8cf752b62ef9215dafda1c5f891b09e (diff)
downloadorg.eclipse.etrice-cfe46b9799947e484ed42a2eefded0db55d43904.tar.gz
org.eclipse.etrice-cfe46b9799947e484ed42a2eefded0db55d43904.tar.xz
org.eclipse.etrice-cfe46b9799947e484ed42a2eefded0db55d43904.zip
[generator.c] implementation of port to MessageService communication
Diffstat (limited to 'runtime')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/.cproject2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.abin120968 -> 129190 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMSCLogger.h7
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMessage.c4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c20
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c41
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etPort.c4
8 files changed, 76 insertions, 5 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/.cproject b/runtime/org.eclipse.etrice.runtime.c/.cproject
index 76fd63aca..7912bcab3 100644
--- a/runtime/org.eclipse.etrice.runtime.c/.cproject
+++ b/runtime/org.eclipse.etrice.runtime.c/.cproject
@@ -34,7 +34,7 @@
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug.1185604346" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.lib.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.lib.debug.option.optimization.level.157947957" name="Optimization Level" superClass="gnu.c.compiler.mingw.lib.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.lib.debug.option.debugging.level.1083191317" name="Debug Level" superClass="gnu.c.compiler.mingw.lib.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
- <option id="gnu.c.compiler.option.include.paths.790097072" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"/>
+ <option id="gnu.c.compiler.option.include.paths.790097072" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.361048721" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.597146923" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/>
diff --git a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
index 81c945ba4..529620e5e 100644
--- a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
+++ b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMSCLogger.h b/runtime/org.eclipse.etrice.runtime.c/src/etMSCLogger.h
index 71e2dfe74..8fc3847fd 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etMSCLogger.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMSCLogger.h
@@ -40,11 +40,16 @@ void etMSCLogger_asyncIn(char* sourceName, char* messageName, char* targetName);
etMSCLogger_syncCall(sourceName, message, targetName); \
etMSCLogger_setObjectName(targetName);
- #define ET_MSC_LOGGER_SYNC_EXIT() \
+ #define ET_MSC_LOGGER_SYNC_EXIT \
etMSCLogger_syncReturn(sourceName, targetName); \
etMSCLogger_setObjectName(sourceName);
#else
+ #define ET_MSC_LOGGER_OPEN
+ #define ET_MSC_LOGGER_CLOSE
+
+ #define ET_MSC_LOGGER_SYNC_ENTRY(object, message)
+ #define ET_MSC_LOGGER_SYNC_EXIT
#endif
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessage.c b/runtime/org.eclipse.etrice.runtime.c/src/etMessage.c
index 940dc61c2..f2db6e2e3 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etMessage.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMessage.c
@@ -12,10 +12,14 @@
#include "etMessage.h"
+#include "etMSCLogger.h"
+
#include <stddef.h>
void etMessage_init(etMessage* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessage", "init")
self->next = NULL;
self->address = 0;
self->evtID = 0;
+ ET_MSC_LOGGER_SYNC_EXIT
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c b/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c
index 2575d1a1d..3f00515a5 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c
@@ -12,16 +12,21 @@
#include "etMessageQueue.h"
+#include "etMSCLogger.h"
+
void etMessageQueue_init(etMessageQueue* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
self->first = NULL;
self->last = NULL;
self->highWaterMark = 0;
self->size = 0;
+ ET_MSC_LOGGER_SYNC_EXIT
}
void etMessageQueue_push(etMessageQueue* self, etMessage* msg){
// TODO: optimize queue for concurrent push / pop
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "push")
if (self->first == NULL) {
/*no message in queue*/
self->first = self->last = msg;
@@ -35,12 +40,16 @@ void etMessageQueue_push(etMessageQueue* self, etMessage* msg){
if (++self->size > self->highWaterMark)
self->highWaterMark++;
+
+ ET_MSC_LOGGER_SYNC_EXIT
}
etMessage* etMessageQueue_pop(etMessageQueue* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "pop")
etMessage* pop_msg = self->first;
if(self->first == NULL){
/*no message in queue*/
+ ET_MSC_LOGGER_SYNC_EXIT
return NULL;
}
if (self->first->next==NULL){
@@ -55,25 +64,36 @@ etMessage* etMessageQueue_pop(etMessageQueue* self){
pop_msg->next=NULL;
self->size--;
+ ET_MSC_LOGGER_SYNC_EXIT
return pop_msg;
}
etInt16 etMessageQueue_getSize(etMessageQueue* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
+ ET_MSC_LOGGER_SYNC_EXIT
return self->size;
}
etMessage* etMessageQueue_getFirst(etMessageQueue* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
+ ET_MSC_LOGGER_SYNC_EXIT
return self->first;
}
etMessage* etMessageQueue_getLast(etMessageQueue* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
+ ET_MSC_LOGGER_SYNC_EXIT
return self->last;
}
etBool etMessageQueue_isNotEmpty(etMessageQueue* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
+ ET_MSC_LOGGER_SYNC_EXIT
return self->last != NULL;
}
etInt16 etMessageQueue_getHightWaterMark(etMessageQueue* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
+ ET_MSC_LOGGER_SYNC_EXIT
return self->highWaterMark;
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c b/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c
index dcf04e0ba..dc40642a7 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c
@@ -13,7 +13,12 @@
#include "etMessageService.h"
+
+#include "etLogger.h"
+#include "etMSCLogger.h"
+
void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 maxBlocks, etUInt16 blockSize){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "init")
self->messageBuffer.buffer = buffer;
self->messageBuffer.maxBlocks = maxBlocks;
self->messageBuffer.blockSize = blockSize;
@@ -21,6 +26,7 @@ void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 max
etMessageQueue_init(&self->messageQueue);
etMessageService_initMessagePool(self);
+ ET_MSC_LOGGER_SYNC_EXIT
}
/*
@@ -28,33 +34,62 @@ void etMessageService_init(etMessageService* self, etUInt8* buffer, etUInt16 max
* all blocks are added to pool
*/
void etMessageService_initMessagePool(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "initMessagePool")
etInt16 i;
for (i=0; i<self->messageBuffer.maxBlocks; i++){
etMessage* block = (etMessage*) &self->messageBuffer.buffer[i*self->messageBuffer.blockSize];
etMessageQueue_push(&self->messagePool, block);
}
+ ET_MSC_LOGGER_SYNC_EXIT
}
void etMessageService_pushMessage(etMessageService* self, etMessage* msg){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "pushMessage")
etMessageQueue_push(&self->messageQueue, msg);
-
+ ET_MSC_LOGGER_SYNC_EXIT
}
etMessage* etMessageService_popMessage(etMessageService* self){
- return etMessageQueue_pop(&self->messageQueue);
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "popMessage")
+ etMessage* msg = etMessageQueue_pop(&self->messageQueue);
+ ET_MSC_LOGGER_SYNC_EXIT
+ return msg;
}
etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessageBuffer")
if (size<=self->messageBuffer.blockSize){
if (self->messagePool.size>0){
- return etMessageQueue_pop(&self->messagePool);
+ etMessage* msg = etMessageQueue_pop(&self->messagePool);
+ ET_MSC_LOGGER_SYNC_EXIT
+ return msg;
}
}
+ ET_MSC_LOGGER_SYNC_EXIT
return NULL;
}
void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "returnMessageBuffer")
etMessageQueue_push(&self->messagePool, buffer);
+ ET_MSC_LOGGER_SYNC_EXIT
}
+
+void etMessageService_deliverAllMessages(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "deliverAllMessages")
+ while (self->messageQueue.size > 0){
+ etMessage* msg = etMessageService_popMessage(self);
+ etLogger_logInfoF("Message ID=%d, Address=%d", msg->evtID, msg->address);
+ etMessageService_returnMessageBuffer(self, msg);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etMessageService_execute(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "execute")
+ etMessageService_deliverAllMessages(self);
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h b/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h
index 12f02885b..a5b0f0285 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h
@@ -41,4 +41,7 @@ etMessage* etMessageService_popMessage(etMessageService* self);
etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size);
void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer);
+void etMessageService_execute(etMessageService* self);
+
+
#endif /* RMESSAGESERVICE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etPort.c b/runtime/org.eclipse.etrice.runtime.c/src/etPort.c
index 6f122c15b..d5df6acfb 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etPort.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etPort.c
@@ -12,7 +12,11 @@
#include "etPort.h"
+#include "etMSCLogger.h"
+
void etPort_receive(etPort* self, etMessage* msg) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etPort", "receive")
(self->receiveMessageFunc)(self->myActor, self->localId, msg);
+ ET_MSC_LOGGER_SYNC_EXIT
}

Back to the top