diff options
author | Henrik Rentz-Reichert | 2013-05-03 07:55:03 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2013-05-03 07:55:03 +0000 |
commit | 89a0443663dfecb0aca9c22f024ab4b801466ba9 (patch) | |
tree | c4caeaf484c6b682d18146ce36db8d202aa89b1c /runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c | |
parent | d11661990c0f99c0c15ff85bce63642b1b5b0007 (diff) | |
download | org.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/MT_WIN_MinGW/etTimer.c')
-rw-r--r-- | runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etTimer.c | 59 |
1 files changed, 41 insertions, 18 deletions
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 } |