Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zipbin102851 -> 102851 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zipbin210050 -> 210671 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zipbin52039 -> 52516 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zipbin24907 -> 24906 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zipbin45031 -> 45031 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zipbin205346 -> 206685 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zipbin84424 -> 84422 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zipbin71828 -> 71848 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zipbin12318 -> 11563 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zipbin14005 -> 13204 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zipbin20927 -> 20201 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zipbin22175 -> 21449 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zipbin17857 -> 17857 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.c7
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h9
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c30
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h28
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c64
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h39
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTime.h6
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.c82
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h40
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h1
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etLogger.c2
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMessageQueue.c4
25 files changed, 294 insertions, 18 deletions
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip
index 130fa594f..eb11ab54b 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip
index 9e60947f9..ddc4c28b2 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
index 75e82abe3..caf38c209 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip
Binary files differ
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 143b51a59..2e0f2494d 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.modellib.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
index 5f7e2b6e3..42d3ed4ab 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
index 7f91657e1..68eb67bd9 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.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 7a89fee80..77181bb40 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/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
index b65e659ee..2058a9b57 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip
index 74011ea40..df9bc1b99 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip
index 73aa8f6e1..af9fd26fa 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip
index 8b4fbf839..f9397e01d 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip
index d634b7af2..0f65881f0 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip
Binary files differ
diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
index d040fc4b1..3fdf7ec49 100644
--- a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
+++ b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.c b/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.c
index 7149058f3..1290ba9dc 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.c
@@ -40,6 +40,13 @@ void etTimeHelpers_subtract(etTime *first, const etTime* second){
etTimeHelpers_normalize(first);
}
+etTimeDiff etTimeHelpers_delta(const etTime* first, const etTime* second) {
+ etTime result = { first->sec-second->sec, first->nSec-second->nSec };
+ etTimeHelpers_normalize(&result);
+
+ return result.nSec + _1E9 * result.sec;
+}
+
void etTimeHelpers_add(etTime *first, const etTime* second){
first->sec += second->sec;
first->nSec += second->nSec;
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h b/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h
index b08839d86..183de8938 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h
@@ -39,6 +39,15 @@ void etTimeHelpers_normalize(etTime* self);
void etTimeHelpers_subtract(etTime *self, const etTime* subtractValue);
/**
+ * computes the difference of two times
+ *
+ * \param first the first operand
+ * \param second the second operand
+ * \return the result as a time diff
+ */
+etTimeDiff etTimeHelpers_delta(const etTime* first, const etTime* second);
+
+/**
* computes the sum of two times
*
* \param self the this pointer
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
index 59dcb5ed4..d8cff4026 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.c
@@ -18,8 +18,8 @@ void etMessageQueue_init(etMessageQueue* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "init")
self->first = NULL;
self->last = NULL;
- self->highWaterMark = 0;
- self->lowWaterMark = 0;
+ self->statistics.highWaterMark = 0;
+ self->statistics.lowWaterMark = 0;
self->size = 0;
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -39,8 +39,8 @@ void etMessageQueue_push(etMessageQueue* self, etMessage* msg){
}
msg->next = NULL; /*TODO: optimization: this line could be removed if we assume that all messages are initialized*/
- if (++self->size > self->highWaterMark)
- self->highWaterMark++;
+ if (++self->size > self->statistics.highWaterMark)
+ self->statistics.highWaterMark++;
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -65,8 +65,8 @@ etMessage* etMessageQueue_pop(etMessageQueue* self){
pop_msg->next=NULL;
self->size--;
- if (self->size < self->lowWaterMark)
- self->lowWaterMark--;
+ if (self->size < self->statistics.lowWaterMark)
+ self->statistics.lowWaterMark--;
ET_MSC_LOGGER_SYNC_EXIT
return pop_msg;
@@ -96,20 +96,32 @@ etBool etMessageQueue_isNotEmpty(etMessageQueue* self){
return self->last != NULL;
}
+const etQueueStatistics* etMessageQueue_getStatistics(etMessageQueue* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHighWaterMark")
+ ET_MSC_LOGGER_SYNC_EXIT
+ return &self->statistics;
+}
+
etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self) {
ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHighWaterMark")
ET_MSC_LOGGER_SYNC_EXIT
- return self->highWaterMark;
+ return self->statistics.highWaterMark;
+}
+
+void etMessageQueue_resetHighWaterMark(etMessageQueue* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "resetHighWaterMark")
+ self->statistics.highWaterMark = 0;
+ ET_MSC_LOGGER_SYNC_EXIT
}
etInt16 etMessageQueue_getLowWaterMark(etMessageQueue* self) {
ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getLowWaterMark")
ET_MSC_LOGGER_SYNC_EXIT
- return self->lowWaterMark;
+ return self->statistics.lowWaterMark;
}
void etMessageQueue_resetLowWaterMark(etMessageQueue* self) {
ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "resetLowWaterMark")
- self->lowWaterMark = self->size;
+ self->statistics.lowWaterMark = self->size;
ET_MSC_LOGGER_SYNC_EXIT
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
index 3765f39d3..32e19023e 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
@@ -25,16 +25,24 @@
#include <stddef.h>
/**
+ * a data structure for the queue statistics
+ */
+typedef struct etQueueStatistics {
+ etInt16 highWaterMark; /**< high water mark */
+ etInt16 lowWaterMark; /**< low water mark */
+}
+etQueueStatistics;
+
+/**
* the message queue data structure
*/
typedef struct etMessageQueue {
etMessage* first; /**< the head of the list */
etMessage* last; /**< the tail of the list */
- etInt16 highWaterMark; /**< high water mark for statistical purposes */
- etInt16 lowWaterMark; /**< low water mark for statistical purposes */
etInt16 size; /**< the size of the list */
-
-} etMessageQueue;
+ etQueueStatistics statistics; /**< high water mark for statistical purposes */
+}
+etMessageQueue;
/**
* initializes the queue data fields ("constructor")
@@ -88,6 +96,12 @@ etBool etMessageQueue_isNotEmpty(etMessageQueue* self);
*/
etInt16 etMessageQueue_getSize(etMessageQueue* self);
/**
+ * returns the statistics of the queue
+ * \param self the this pointer
+ * \return the statistics of the queue (immutable)
+ */
+const etQueueStatistics* etMessageQueue_getStatistics(etMessageQueue* self);
+/**
* returns the high water mark of the message queue
*
* \param self the this pointer
@@ -95,6 +109,12 @@ etInt16 etMessageQueue_getSize(etMessageQueue* self);
*/
etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self);
/**
+ * resets the high water mark of the message queue to 0
+ *
+ * \param self the this pointer
+ */
+void etMessageQueue_resetHighWaterMark(etMessageQueue* self);
+/**
* returns the low water mark of the message queue
*
* \param self the this pointer
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
index 98940d81d..71e3df127 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.c
@@ -17,6 +17,8 @@
#include "etSystemProtocol.h"
#include "debugging/etLogger.h"
#include "debugging/etMSCLogger.h"
+#include "runtime/etRuntime.h"
+#include "helpers/etTimeHelpers.h"
static void etMessageService_timerCallback(void* data);
static void etMessageService_deliverAllMessages(etMessageService* self);
@@ -35,9 +37,28 @@ void etMessageService_init(
etTime interval,
etDispatcherReceiveMessage msgDispatcher,
etMessageService_execmode execmode){
+ etMessageService_initx(self, NULL, buffer, maxBlocks, blockSize, stacksize, priority, interval, msgDispatcher, execmode);
+}
+
+/*
+ * initialize message service with all needed data and initialize message queue and message pool
+ *
+ */
+void etMessageService_initx(
+ etMessageService* self,
+ const char* name,
+ etUInt8* buffer,
+ etUInt16 maxBlocks,
+ etUInt16 blockSize,
+ etStacksize stacksize,
+ etPriority priority,
+ etTime interval,
+ etDispatcherReceiveMessage msgDispatcher,
+ etMessageService_execmode execmode){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "init")
/* copy init data to self */
+ self->name = name;
self->messageBuffer.buffer = buffer;
self->messageBuffer.maxBlocks = maxBlocks;
self->messageBuffer.blockSize = blockSize;
@@ -65,6 +86,14 @@ void etMessageService_init(
etTimer_construct(&self->timer, &interval, etMessageService_timerCallback, self);
}
+ /* init statistics */
+ self->statistics.highWaterMark = 0;
+ self->statistics.queueStatistics = &self->messageQueue.statistics;
+ self->resetStatistics = ET_FALSE;
+
+ /* register with runtime */
+ etRuntime_registerMessageService(self);
+
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -96,6 +125,10 @@ void etMessageService_stop(etMessageService* self){
void etMessageService_destroy(etMessageService* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "destroy")
+
+ /* unregister from runtime */
+ etRuntime_unregisterMessageService(self);
+
etMutex_destruct( &(self->poolMutex) );
etMutex_destruct( &(self->queueMutex) );
etSema_destruct( &(self->executionSemaphore) );
@@ -206,16 +239,43 @@ static void etMessageService_callHighPrioFunc(etMessageService* self){
ET_MSC_LOGGER_SYNC_EXIT
}
+static etBool etMessageService_dispatchMessage(etMessageService* self, const etMessage* msg) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "dispatchMessages")
+ etBool success;
+ etTime startTime, endTime;
+ etTimeDiff delta;
+
+ getTimeFromTarget(&startTime);
+ success = self->msgDispatcher(msg);
+ getTimeFromTarget(&endTime);
+ delta = etTimeHelpers_delta(&endTime, &startTime);
+
+ if (delta > self->statistics.highWaterMark) {
+ self->statistics.highWaterMark = delta;
+ }
+
+ ET_MSC_LOGGER_SYNC_EXIT
+ return success;
+}
+
static void etMessageService_deliverAllMessages(etMessageService* self){
ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "deliverAllMessages")
{
etBool cont = ET_TRUE;
while (cont){
etMessageService_callHighPrioFunc(self);
+
+ if (self->resetStatistics) {
+ self->resetStatistics = ET_FALSE;
+
+ self->statistics.highWaterMark = 0;
+ etMessageQueue_resetHighWaterMark(&self->messageQueue);
+ etMessageQueue_resetLowWaterMark(&self->messageQueue);
+ }
+
while (etMessageQueue_isNotEmpty(&self->messageQueue) && cont){
etMessage* msg = etMessageService_popMessage(self);
- if (!self->msgDispatcher(msg))
- cont = ET_FALSE;
+ cont &= etMessageService_dispatchMessage(self, msg);
etMessageService_returnMessageBuffer(self, msg);
etMessageService_callHighPrioFunc(self);
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
index a00e2b561..cb6ff2319 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
@@ -62,7 +62,18 @@ struct etHighPrioFunc{
etHighPrioFunc *next;
};
+/**
+ * a data structure for the performance statistics
+ */
+typedef struct etMessageServiceStatistics {
+ etTimeDiff highWaterMark; /** high water mark */
+ etQueueStatistics* queueStatistics; /** a pointer to the queue statistics */
+}
+etMessageServiceStatistics;
+
typedef struct etMessageService {
+ const char* name; /** (unique) name */
+ struct etMessageService* next; /** linked list */
etMessageQueue messageQueue; /** message queue that holds all used messages */
etMessageQueue messagePool; /** message pool that holds all free messages */
etBuffer messageBuffer; /** information about the message buffer that holds information about the actual memory position and size for the message pool */
@@ -74,12 +85,40 @@ typedef struct etMessageService {
etTimer timer; /** timer for cyclic calls */
etMessageService_execmode execmode; /** execution mode*/
etHighPrioFunc *highPrioFuncRoot;
+ etMessageServiceStatistics statistics; /** statistical data */
+ etBool resetStatistics; /** flag that tells the message service to reset all statistics values */
} etMessageService;
/**
* initialization (construction)
*
* \param self the this pointer
+ * \param name the name of the message service
+ * \param buffer the buffer for the message pool
+ * \param maxBlocks the number of (equal sized) message blocks in the buffer
+ * \param blockSize the size of each message block
+ * \param stackSize the stack size for the thread in which this service will run
+ * \param priority the thread priority
+ * \param interval the polling interval
+ * \param msgDispatcher the dispatcher method
+ * \param execmdoe the execution mode for this message service
+ */
+void etMessageService_initx(
+ etMessageService* self,
+ const char* name,
+ etUInt8* buffer,
+ etUInt16 maxBlocks,
+ etUInt16 blockSize,
+ etStacksize stacksize,
+ etPriority priority,
+ etTime interval,
+ etDispatcherReceiveMessage msgDispatcher,
+ etMessageService_execmode execmode);
+
+/**
+ * initialization (construction)
+ *
+ * \param self the this pointer
* \param buffer the buffer for the message pool
* \param maxBlocks the number of (equal sized) message blocks in the buffer
* \param blockSize the size of each message block
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTime.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTime.h
index 75dab0edd..1df9f3b2f 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTime.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTime.h
@@ -39,6 +39,12 @@ typedef struct etTime {
} etTime;
/**
+ * small time difference, typically as difference of etTime that only differ by a small amount of time.
+ * Unit is nano seconds
+ */
+typedef etInt32 etTimeDiff;
+
+/**
* get current time from target hardware
* this is no real world clock time and date
* should be used only for relative time measurement
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.c b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.c
index b2c54d9ee..4bc54e6e8 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.c
@@ -15,6 +15,7 @@
static etSema terminateSemaphore;
+static etMessageService* head = NULL;
etSema* etRuntime_getTerminateSemaphore() {
static etBool initialized = ET_FALSE;
@@ -26,3 +27,84 @@ etSema* etRuntime_getTerminateSemaphore() {
return &terminateSemaphore;
}
+
+int etRuntime_getMessageServiceCount() {
+ etMessageService* p = head;
+
+ int count = 0;
+ while (p!=null) {
+ ++count;
+ p = p->next;
+ }
+ return count;
+}
+
+int etRuntime_getMessageServiceByName(const char* name) {
+ etMessageService* p = head;
+
+ int idx = 0;
+ while (p!=null) {
+ if (strcmp(p->name, name)==0) {
+ return idx;
+ }
+ ++idx;
+ p = p->next;
+ }
+
+ return -1;
+}
+
+const etMessageServiceStatistics* etRuntime_getMessageServiceStatistics(unsigned int i) {
+ etMessageService* p = head;
+
+ int count = 0;
+ while (p!=null) {
+ if (count==i) {
+ return &p->statistics;
+ }
+ ++count;
+ p = p->next;
+ }
+
+ return NULL;
+}
+
+void etRuntime_resetAllMessageServiceStatistics() {
+ etMessageService* p = head;
+
+ while (p!=null) {
+ p->resetStatistics = ET_TRUE;
+ p = p->next;
+ }
+}
+
+void etRuntime_registerMessageService(etMessageService* msgService) {
+ msgService->next = head;
+ head = msgService;
+
+ if (msgService->name==NULL) {
+ void* p = malloc(16);
+ sprintf(p, "MsgSvc_%d", etRuntime_getMessageServiceCount());
+ msgService->name = (const char*) p;
+ }
+}
+
+void etRuntime_unregisterMessageService(etMessageService* msgService) {
+ etMessageService* p = head;
+ etMessageService* last = NULL;
+
+ while (p!=null) {
+ if (p==msgService) {
+ if (last==NULL) {
+ /* remove the first one */
+ head = p->next;
+ }
+ else {
+ last->next = p->next;
+ }
+ break;
+ }
+ last = p;
+ p = p->next;
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h
index d5b23e25c..5c5ff3d0b 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h
@@ -17,6 +17,8 @@ extern "C" {
#ifndef _ETRUNTIME_H_
#define _ETRUNTIME_H_
+#include "messaging/etMessageService.h"
+
/**
* \file etRuntime.h
*
@@ -28,6 +30,44 @@ extern "C" {
#include "osal/etSema.h"
/**
+ * returns the number of message services in this process
+ *
+ * \return the number of message services in this process
+ */
+int etRuntime_getMessageServiceCount();
+
+/**
+ * returns the statistics of a message service
+ *
+ * \param i the message service instance number
+ * \return the statistics of this message service
+ */
+const etMessageServiceStatistics* etRuntime_getMessageServiceStatistics(unsigned int i);
+
+/**
+ * finds a message service by its name and returns its index or -1 if not found
+ *
+ * \param name the name of the message service
+ * \return the index of the message service or -1
+ */
+int etRuntime_getMessageServiceByName(const char* name);
+
+/**
+ * sets a flag in all message service structs that tells the message services to reset their statistics
+ */
+void etRuntime_resetAllMessageServiceStatistics();
+
+/**
+ * registers the message service by hooking it into a linked list
+ */
+void etRuntime_registerMessageService(etMessageService* msgService);
+
+/**
+ * unregisters the message service by removing it from the linked list
+ */
+void etRuntime_unregisterMessageService(etMessageService* msgService);
+
+/**
* a global semaphore used to terminate the application in headless mode
*
* \return the semaphore
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h
index 9910144ac..5f5446a2d 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h
@@ -30,6 +30,7 @@ extern "C" {
#include <stdio.h>
+#undef WINVER
#define WINVER 0x0500
#include <windows.h>
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etLogger.c
index e77de8e17..243a25688 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etLogger.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etLogger.c
@@ -76,5 +76,5 @@ void etLogger_fprintf(etFileHandle file, const char* format, ... ){
va_start( arglist, format );
vfprintf(file, format, arglist );
va_end( arglist );
- fflush(stdout);
+ fflush(file);
}
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMessageQueue.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMessageQueue.c
index a2deeb162..e95a95e4f 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMessageQueue.c
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMessageQueue.c
@@ -26,13 +26,13 @@ void TestEtMessageQueue_testPushPop(etInt16 id){
etMessageQueue_push(&queue1, &msg2);
EXPECT_EQUAL_INT16(id, "etMessageQueue.size before", 2, queue1.size);
- EXPECT_EQUAL_INT16(id, "etMessageQueue.highWaterMark before", 2, queue1.highWaterMark);
+ EXPECT_EQUAL_INT16(id, "etMessageQueue.statistics.highWaterMark before", 2, queue1.statistics.highWaterMark);
etMessage* rcvMsg1 = etMessageQueue_pop(&queue1);
etMessage* rcvMsg2 = etMessageQueue_pop(&queue1);
EXPECT_EQUAL_INT16(id, "etMessageQueue.size after", 0, queue1.size);
- EXPECT_EQUAL_INT16(id, "etMessageQueue.highWaterMark after", 2, queue1.highWaterMark);
+ EXPECT_EQUAL_INT16(id, "etMessageQueue.statistics.highWaterMark after", 2, queue1.statistics.highWaterMark);
EXPECT_EQUAL_INT16(id, "rcvMsg1->address", 123, rcvMsg1->address);
EXPECT_EQUAL_INT16(id, "rcvMsg1->evtID", 456, rcvMsg1->evtID);

Back to the top