Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-05-03 07:55:03 +0000
committerHenrik Rentz-Reichert2013-05-03 07:55:03 +0000
commit89a0443663dfecb0aca9c22f024ab4b801466ba9 (patch)
treec4caeaf484c6b682d18146ce36db8d202aa89b1c /runtime/org.eclipse.etrice.runtime.c/src/platforms
parentd11661990c0f99c0c15ff85bce63642b1b5b0007 (diff)
downloadorg.eclipse.etrice-89a0443663dfecb0aca9c22f024ab4b801466ba9.tar.gz
org.eclipse.etrice-89a0443663dfecb0aca9c22f024ab4b801466ba9.tar.xz
org.eclipse.etrice-89a0443663dfecb0aca9c22f024ab4b801466ba9.zip
[runtime.c] bug 402275: Implementation of Codegenerator and C-Runtime for physical model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=402275 First working version with multiple threads and polling
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c22
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c59
3 files changed, 62 insertions, 23 deletions
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 b7cfa1077..03551675c 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
@@ -97,8 +97,4 @@ typedef HANDLE etOSSemaData;
typedef HANDLE etOSTimerData;
typedef DWORD etOSTimerId;
-typedef VOID(CALLBACK *etTimerFunction)(PVOID lpParam, BOOLEAN TimerOrWaitFired);
-#define etTimerFunction_RETURN_VALUE VOID CALLBACK
-#define etTimerFunction_ARGUMENT_LIST PVOID lpParam, BOOLEAN TimerOrWaitFired
-
#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c
index 61be3103d..9998d9b1a 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etThread.c
@@ -25,8 +25,28 @@
void etThread_execute(etThread* self);
-void etThread_construct(etThread* self){
+void etThread_construct(
+ etThread* self,
+ etStacksize stacksize,
+ etPriority priority,
+ etThreadname threadName,
+ etThreadFunction threadFunction,
+ void* threadFunctionData)
+{
ET_MSC_LOGGER_SYNC_ENTRY("etThread", "construct")
+
+ /* fill in data */
+ self->stacksize = stacksize;
+ self->priority = priority;
+ self->threadName = threadName;
+ self->threadFunction = threadFunction;
+ self->threadFunctionData = threadFunctionData;
+
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+void etThread_start(etThread* self) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etThread", "start")
self->osData = (HANDLE)_beginthread( (etThreadFunction)etThread_execute, self->stacksize, self );
SetThreadPriority(self->osData, self->priority);
ET_MSC_LOGGER_SYNC_EXIT
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c
index 7e98fc932..8d2adc797 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c
@@ -26,42 +26,65 @@
/** global handle for the Windows timer queue */
static HANDLE hTimerQueue = NULL;
-void etTimer_construct(etTimer* self, etTime* timerInterval, etTimerFunction timerFunction){
- self->osTimerData = NULL;
- self->timerInterval.sec = timerInterval->sec;
- self->timerInterval.nSec = timerInterval->nSec;
- self->timerFunction = timerFunction;
- if (hTimerQueue == NULL){
- /* the Windows timer queue is only needed once for all timers */
- hTimerQueue = CreateTimerQueue();
+VOID CALLBACK etTimer_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired);
+
+void etTimer_construct(etTimer* self, etTime* timerInterval, etTimerFunction timerFunction, void* timerFunctionData){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "construct")
+ {
+ self->osTimerData = NULL;
+ self->timerInterval.sec = timerInterval->sec;
+ self->timerInterval.nSec = timerInterval->nSec;
+ self->timerFunction = timerFunction;
+ self->timerFunctionData = timerFunctionData;
if (hTimerQueue == NULL){
- etLogger_logError("etTimer_construct: CreateTimerQueue failed");
+ /* the Windows timer queue is only needed once for all timers */
+ hTimerQueue = CreateTimerQueue();
+ if (hTimerQueue == NULL){
+ etLogger_logError("etTimer_construct: CreateTimerQueue failed");
+ }
}
}
+ ET_MSC_LOGGER_SYNC_EXIT
}
void etTimer_start(etTimer* self){
- UINT elapse;
- /* calculate the time in milliseconds -> accuracy will of nSec will get lost in windows! */
- elapse = etTimeHelpers_convertToMSec(&(self->timerInterval));
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "start")
+ {
+ /* calculate the time in milliseconds -> accuracy of nSec will get lost in windows! */
+ UINT elapse = etTimeHelpers_convertToMSec(&(self->timerInterval));
- if (hTimerQueue == NULL){
- etLogger_logError("etTimer_start: no Timer Queue to create timer (NULL)");
- }
- else {
- if (CreateTimerQueueTimer( &(self->osTimerData), hTimerQueue, self->timerFunction, NULL , 0, elapse, 0) == FALSE){
- etLogger_logError("etTimer_start: Timer could not be created");
+ if (hTimerQueue == NULL){
+ etLogger_logError("etTimer_start: no Timer Queue to create timer (NULL)");
+ }
+ else {
+ if (CreateTimerQueueTimer( &(self->osTimerData), hTimerQueue, etTimer_callback, self, 0, elapse, 0) == FALSE){
+ etLogger_logError("etTimer_start: Timer could not be created");
+ }
}
}
+ ET_MSC_LOGGER_SYNC_EXIT
}
void etTimer_stop(etTimer* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "stop")
if (DeleteTimerQueueTimer(hTimerQueue, self->osTimerData, NULL) == FALSE){
etLogger_logError("etTimer_stop: Timer could not be stopped");
}
+ ET_MSC_LOGGER_SYNC_EXIT
}
void etTimer_destruct(etTimer* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "destruct")
/* TODO: destroy hTimerQueue if last timer is destroyed */
/* DeleteTimerQueue(hTimerQueue); */
+ ET_MSC_LOGGER_SYNC_EXIT
+}
+
+VOID CALLBACK etTimer_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired) {
+ ET_MSC_LOGGER_SYNC_ENTRY("etTimer", "callback")
+ {
+ etTimer* self = (etTimer*) lpParameter;
+ self->timerFunction(self->timerFunctionData);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
}

Back to the top