Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2012-02-19 12:59:31 +0000
committerThomas Schuetz2012-02-19 12:59:31 +0000
commitee42f0a62cd3443d25aab12f7a8703ae7d58e3b6 (patch)
treec17ab2284a5f73dfd6758f017a4c153276952a26
parente30f9cc595fb5d8ccbb4006b486dbbed7567085c (diff)
downloadorg.eclipse.etrice-ee42f0a62cd3443d25aab12f7a8703ae7d58e3b6.tar.gz
org.eclipse.etrice-ee42f0a62cd3443d25aab12f7a8703ae7d58e3b6.tar.xz
org.eclipse.etrice-ee42f0a62cd3443d25aab12f7a8703ae7d58e3b6.zip
[runtime] added LowWaterMark for Message Service
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.abin129592 -> 130350 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c6
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h5
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c69
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/tmp/msc.seq126
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml3
8 files changed, 206 insertions, 7 deletions
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 9ee693e9a..837d3c6c3 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/etMessageQueue.c b/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c
index 2e2e7edf6..639798bc6 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.c
@@ -92,7 +92,7 @@ etBool etMessageQueue_isNotEmpty(etMessageQueue* self){
return self->last != NULL;
}
-etInt16 etMessageQueue_getHightWaterMark(etMessageQueue* self) {
+etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self) {
ET_MSC_LOGGER_SYNC_ENTRY("etMessageQueue", "getHightWaterMark")
ET_MSC_LOGGER_SYNC_EXIT
return self->highWaterMark;
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.h b/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.h
index f08b19901..a303146ec 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMessageQueue.h
@@ -36,7 +36,7 @@ etMessage* etMessageQueue_getLast(etMessageQueue* self);
etBool etMessageQueue_isNotEmpty(etMessageQueue* self);
-etInt16 etMessageQueue_getHightWaterMark(etMessageQueue* self);
+etInt16 etMessageQueue_getHighWaterMark(etMessageQueue* self);
etInt16 etMessageQueue_getSize(etMessageQueue* self);
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c b/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c
index 7af1c4bf7..10e2fe00c 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.c
@@ -95,3 +95,9 @@ void etMessageService_execute(etMessageService* self){
ET_MSC_LOGGER_SYNC_EXIT
}
+etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etMessageService", "getMessagePoolLowWaterMark")
+ etInt16 lowWaterMark = self->messageBuffer.maxBlocks - etMessageQueue_getHighWaterMark(&self->messageQueue);
+ ET_MSC_LOGGER_SYNC_EXIT
+ return lowWaterMark;
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h b/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h
index b7c46060c..5997363d1 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMessageService.h
@@ -38,10 +38,13 @@ void etMessageService_initMessagePool(etMessageService* self);
void etMessageService_pushMessage(etMessageService* self, etMessage* msg);
etMessage* etMessageService_popMessage(etMessageService* self);
-
etMessage* etMessageService_getMessageBuffer(etMessageService* self, etUInt16 size);
void etMessageService_returnMessageBuffer(etMessageService* self, etMessage* buffer);
void etMessageService_execute(etMessageService* self);
+/* functions for debug and service information */
+etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self);
+
+
#endif /* RMESSAGESERVICE_H_ */
diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c
index c8b7fbf70..769612f84 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c
+++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c
@@ -44,9 +44,6 @@ void DummyMessageDispatcher(const etMessage* msg){
}
}
-
-
-
void TestEtMessageService_init(void){
etMessageService msgService;
@@ -168,11 +165,77 @@ void TestEtMessageService_execute(void){
EXPECT_EQUAL_INT16("deliverAllMessages receivedEventIDCounter", 2, receivedEventIDCounter);
}
+void TestEtMessageService_getMessagePoolLowWaterMark(void){
+ etMessageService msgService;
+ uint16 max = 6;
+ uint16 blockSize = 32;
+ uint8 msgBuffer[max*blockSize];
+
+ etMessageService_init(&msgService, msgBuffer, max, blockSize, DummyMessageDispatcher);
+
+ EXPECT_EQUAL_INT16("inital low water mark", max, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+ // get messages from pool
+ etMessage* msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessage* msg2 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+
+ // define content
+ msg1->address = 11;
+ msg1->evtID = 111;
+ msg2->address = 22;
+ msg2->evtID = 222;
+
+ // push messages to queue
+ etMessageService_pushMessage(&msgService, msg2);
+ etMessageService_pushMessage(&msgService, msg1);
+
+ EXPECT_EQUAL_INT16("low water mark 1", max-2, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+ // pop messages from queue
+ etMessage* rcvMsg1 = etMessageService_popMessage(&msgService);
+ etMessage* rcvMsg2 = etMessageService_popMessage(&msgService);
+
+ etMessageService_returnMessageBuffer(&msgService, rcvMsg1);
+ etMessageService_returnMessageBuffer(&msgService, rcvMsg2);
+
+ EXPECT_EQUAL_INT16("low water mark 2", max-2, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ msg2 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessageService_pushMessage(&msgService, msg2);
+ etMessageService_pushMessage(&msgService, msg1);
+
+ /*still the same*/
+ EXPECT_EQUAL_INT16("low water mark 3", max-2, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessageService_pushMessage(&msgService, msg2);
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessageService_pushMessage(&msgService, msg2);
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessageService_pushMessage(&msgService, msg2);
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessageService_pushMessage(&msgService, msg2);
+
+ /* no message left */
+ EXPECT_EQUAL_INT16("low water mark 4", 0, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ EXPECT_EQUAL_PTR("check message for NULL", NULL, msg1);
+
+ /* still no message left */
+ EXPECT_EQUAL_INT16("low water mark 6", 0, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+
+}
+
+
void TestEtMessageService_runSuite(void){
etUnit_openTestSuite("TestEtMessageService");
ADD_TESTCASE(TestEtMessageService_init);
ADD_TESTCASE(TestEtMessageService_GetPushPopReturn);
ADD_TESTCASE(TestEtMessageService_GetReturn);
ADD_TESTCASE(TestEtMessageService_execute);
+ ADD_TESTCASE(TestEtMessageService_getMessagePoolLowWaterMark)
etUnit_closeTestSuite();
}
diff --git a/tests/org.eclipse.etrice.generator.c.tests/tmp/msc.seq b/tests/org.eclipse.etrice.generator.c.tests/tmp/msc.seq
index 617db491a..d4cec0ba3 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/tmp/msc.seq
+++ b/tests/org.eclipse.etrice.generator.c.tests/tmp/msc.seq
@@ -12179,4 +12179,130 @@ etMessageService ==> etMessageQueue isNotEmpty
etMessageService <== etMessageQueue
etMessageService <== etMessageService
RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService init
+etMessageService ==> etMessageQueue init
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue init
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageService initMessagePool
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService <== etMessageService
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService popMessage
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService popMessage
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService returnMessageBuffer
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService returnMessageBuffer
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
RunAllTestcases <== RunAllTestcases
diff --git a/tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml b/tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml
index 5d2e44978..b32d29723 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml
+++ b/tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml
@@ -4,13 +4,14 @@
</testsuite>
<testsuite name="TestEtMessageQueue" tests="0" failures="0" errors="0" time="0">
<testcase name="TestEtMessageQueue_testPushPop" time="0"/>
- <testcase name="TestEtMessageQueue_testMassiveMessaging" time="9"/>
+ <testcase name="TestEtMessageQueue_testMassiveMessaging" time="0"/>
</testsuite>
<testsuite name="TestEtMessageService" tests="0" failures="0" errors="0" time="0">
<testcase name="TestEtMessageService_init" time="0"/>
<testcase name="TestEtMessageService_GetPushPopReturn" time="0"/>
<testcase name="TestEtMessageService_GetReturn" time="0"/>
<testcase name="TestEtMessageService_execute" time="0"/>
+ <testcase name="TestEtMessageService_getMessagePoolLowWaterMark" time="0"/>
</testsuite>
<testsuite name="TestEtUnit" tests="0" failures="0" errors="0" time="0">
<testcase name="TestEtUnit_Expect_Order" time="0"/>

Back to the top