F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Timer.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Timer.cpp
3 // \author Brian Campuzano
4 // \brief cpp file for the Timer class implementation
5 // ======================================================================
6 
8 
9 #include <Fw/Types/Assert.hpp>
10 
11 namespace Svc {
12 namespace Ccsds {
13 namespace Cfdp {
14 
15 // ----------------------------------------------------------------------
16 // Class construction and destruction
17 // ----------------------------------------------------------------------
18 
19 Timer ::Timer() : timerStatus(UNINITIALIZED), secondsRemaining(0) {}
20 
22 
23 // ----------------------------------------------------------------------
24 // Class interfaces
25 // ----------------------------------------------------------------------
26 
27 void Timer ::setTimer(U32 timerDuration) {
28  this->timerStatus = RUNNING;
29  this->secondsRemaining = timerDuration;
30 }
31 
33  this->timerStatus = EXPIRED;
34  this->secondsRemaining = 0;
35 }
36 
38  return this->timerStatus;
39 }
40 
41 void Timer ::run(void) {
42  if (this->timerStatus == RUNNING) {
43  FW_ASSERT(this->secondsRemaining > 0);
44  this->secondsRemaining--;
45 
46  if (this->secondsRemaining == 0) {
47  this->timerStatus = EXPIRED;
48  }
49  }
50 }
51 
52 } // namespace Cfdp
53 } // namespace Ccsds
54 } // namespace Svc
void disableTimer(void)
Disables a CFDP timer.
Definition: Timer.cpp:32
Timer()
Construct Timer object.
Definition: Timer.cpp:19
Status getStatus(void)
Get the status of a CFDP timer.
Definition: Timer.cpp:37
void setTimer(U32 timerDuration)
Initialize a CFDP timer and start its execution.
Definition: Timer.cpp:27
~Timer()
Destroy Timer object.
Definition: Timer.cpp:21
void run(void)
Runs a one second increment of the CFDP timers.
Definition: Timer.cpp:41
RateGroupDivider component implementation.
#define FW_ASSERT(...)
Definition: Assert.hpp:14