Today's the day. Renamed platform to framework.
This commit is contained in:
39
timemanager/Countdown.cpp
Normal file
39
timemanager/Countdown.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file Countdown.cpp
|
||||
* @brief This file defines the Countdown class.
|
||||
* @date 21.03.2013
|
||||
* @author baetz
|
||||
*/
|
||||
|
||||
|
||||
#include <framework/timemanager/Countdown.h>
|
||||
|
||||
Countdown::Countdown(uint32_t initialTimeout) : startTime(0), timeout(initialTimeout) {
|
||||
}
|
||||
|
||||
Countdown::~Countdown() {
|
||||
}
|
||||
|
||||
ReturnValue_t Countdown::setTimeout(uint32_t miliseconds) {
|
||||
ReturnValue_t return_value = OSAL::getUptime( &startTime );
|
||||
timeout = miliseconds;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
bool Countdown::hasTimedOut() const {
|
||||
uint32_t current_time;
|
||||
OSAL::getUptime( ¤t_time );
|
||||
if ( uint32_t(current_time - startTime) >= timeout) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Countdown::isBusy() const {
|
||||
return !hasTimedOut();
|
||||
}
|
||||
|
||||
ReturnValue_t Countdown::resetTimer() {
|
||||
return setTimeout(timeout);
|
||||
}
|
Reference in New Issue
Block a user