From d41acf1b5f34a1baba8016f1eb4b7e98b541a815 Mon Sep 17 00:00:00 2001 From: Henrik Rentz-Reichert Date: Wed, 8 May 2013 09:19:09 +0200 Subject: [runtime.c] bug 402275: Implementation of Codegenerator and C-Runtime for physical model https://bugs.eclipse.org/bugs/show_bug.cgi?id=402275 --- runtime/org.eclipse.etrice.runtime.c/.cproject | 16 ++++------------ .../src/common/etUnit/etUnit.c | 8 +++++++- .../src/common/helpers/etTimeHelpers.c | 8 ++++++++ .../src/common/helpers/etTimeHelpers.h | 2 ++ .../src/common/messaging/etSystemProtocol.c | 4 ++-- .../src/common/osal/etThread.h | 2 +- .../src/common/runtime/etRuntime.c | 11 +++++++++++ .../src/common/runtime/etRuntime.h | 2 ++ .../src/platforms/MT_WIN_MinGW/etSema.c | 2 +- 9 files changed, 38 insertions(+), 17 deletions(-) (limited to 'runtime') diff --git a/runtime/org.eclipse.etrice.runtime.c/.cproject b/runtime/org.eclipse.etrice.runtime.c/.cproject index 252bd2165..7fae49897 100644 --- a/runtime/org.eclipse.etrice.runtime.c/.cproject +++ b/runtime/org.eclipse.etrice.runtime.c/.cproject @@ -1,5 +1,7 @@ - + + + @@ -49,19 +51,9 @@ - - - - - - - - - - - + diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c b/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c index 9df61df98..8fe509f55 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c @@ -15,6 +15,8 @@ #include #include #include "debugging/etLogger.h" +#include "osal/etSema.h" +#include "runtime/etRuntime.h" /*** member variables */ @@ -95,7 +97,10 @@ void etUnit_close(void) { etUnit_reportfile = NULL; } etLogger_logInfoF("End Time: %ld", clock()); - etLogger_logErrorF("Error Counter: %ld", etUnit_errorCounter); + if (etUnit_errorCounter==0) + etLogger_logInfoF("Error Counter: %ld", etUnit_errorCounter); + else + etLogger_logErrorF("Error Counter: %ld", etUnit_errorCounter); etLogger_logInfoF("************* TEST END **************"); } @@ -145,6 +150,7 @@ void etUnit_closeAll(etInt16 id){ } void etUnit_testFinished(etInt16 id) { + etSema_wakeup(etRuntime_getTerminateSemaphore()); } void expectTrue(etInt16 id, const char* message, etBool condition, const char* file, int line) { 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 82ada3166..6de407a30 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 @@ -12,6 +12,14 @@ #include "helpers/etTimeHelpers.h" +void etTimeHelpers_subtract(etTime *first, etTime* second){ + /* TODO: implement */ +} + +void etTimeHelpers_add(etTime *first, etTime* second){ + /* TODO: implement */ +} + etInt32 etTimeHelpers_convertToMSec(etTime *time){ return time->sec * 1000 + time->nSec / 1000000; } 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 c7aa1a49a..e04a5a755 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 @@ -15,6 +15,8 @@ #include "osal/etTime.h" +void etTime_subtract(etTime *self, etTime* subtractValue); +void etTime_add(etTime *self, etTime* addValue); etInt32 etTimeHelpers_convertToMSec(etTime *time); void etTimeHelpers_convertToEtTime(etTime *result, etInt32 milliSeconds); diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c index d13520335..40be5342a 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.c @@ -12,7 +12,7 @@ /*--------------------- port methods */ -// getReplication +/* getReplication */ etInt32 etSystemProtocolReplPort_getReplication(const etSystemProtocolReplPort* self) { return ((etReplPort*)self)->size; } @@ -66,7 +66,7 @@ void etSystemProtocolConjReplPort_terminate(const etSystemProtocolConjReplPort* } -// getReplication +/* getReplication */ etInt32 etSystemProtocolConjReplPort_getReplication(const etSystemProtocolConjReplPort* self) { return ((etReplPort*)self)->size; } diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etThread.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etThread.h index 0355f0160..172723db6 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etThread.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etThread.h @@ -44,7 +44,7 @@ typedef struct etThread{ void* threadFunctionData; /**< data for call back function to be called by thread -> has to be filled in by caller of etThread_construct **/ } etThread; -// TODO: add return values for error handling +/* TODO: add return values for error handling */ /** * initialize the thread data 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 a92a36c49..bca6ecd44 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 @@ -14,4 +14,15 @@ #include "runtime/etRuntime.h" +static etSema terminateSemaphore; +etSema* etRuntime_getTerminateSemaphore() { + static etBool initialized = FALSE; + + if (!initialized) { + initialized = TRUE; + etSema_construct(&terminateSemaphore); + } + + return &terminateSemaphore; +} 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 229e2e5e6..83877fa6e 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 @@ -13,6 +13,8 @@ #ifndef _ETRUNTIME_H_ #define _ETRUNTIME_H_ +#include "osal/etSema.h" +etSema* etRuntime_getTerminateSemaphore(); #endif /* _ETRUNTIME_H_ */ diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c index 13f8daca8..0f537a9fd 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c +++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSema.c @@ -29,7 +29,7 @@ void etSema_construct(etSema* self){ } void etSema_destruct(etSema* self){ ET_MSC_LOGGER_SYNC_ENTRY("etSema", "destruct") - // TODO: implement this function + /* TODO: implement this function */ ET_MSC_LOGGER_SYNC_EXIT } -- cgit v1.2.3