1
0
forked from fsfw/fsfw
Files
action
container
contrib
controller
coordinates
datalinklayer
datapool
devicehandlers
events
fdir
globalfunctions
health
internalError
ipc
memory
modes
monitoring
objectmanager
osal
parameters
power
returnvalues
rmap
serialize
serviceinterface
storagemanager
subsystem
tasks
tcdistribution
thermal
timemanager
CCSDSTime.cpp
CCSDSTime.h
Clock.h
Countdown.cpp
Countdown.h
ReceivesTimeInfoIF.h
TimeMessage.cpp
TimeMessage.h
TimeStamperIF.h
tmstorage
tmtcpacket
tmtcservices
.gitignore
LICENSE
NOTICE
framework.mk
fsfw/timemanager/Countdown.cpp
Ulrich Mohr 575f70ba03 updating code from Flying Laptop
This is the framework of Flying Laptop OBSW version A.13.0.
2018-07-12 16:29:32 +02:00

46 lines
915 B
C++

/**
* @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 = Clock::getUptime( &startTime );
timeout = miliseconds;
return return_value;
}
bool Countdown::hasTimedOut() const {
uint32_t current_time;
Clock::getUptime( &current_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);
}
void Countdown::timeOut() {
uint32_t current_time;
Clock::getUptime( &current_time );
startTime= current_time - timeout;
}