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 namespace Svc {
10 namespace Ccsds {
11 namespace Cfdp {
12 
13 // ----------------------------------------------------------------------
14 // Class construction and destruction
15 // ----------------------------------------------------------------------
16 
17 Timer ::Timer() : timerStatus(UNINITIALIZED), secondsRemaining(0) {}
18 
20 
21 // ----------------------------------------------------------------------
22 // Class interfaces
23 // ----------------------------------------------------------------------
24 
25 void Timer ::setTimer(U32 timerDuration) {
26  this->timerStatus = RUNNING;
27  this->secondsRemaining = timerDuration;
28 }
29 
31  this->timerStatus = EXPIRED;
32  this->secondsRemaining = 0;
33 }
34 
36  return this->timerStatus;
37 }
38 
39 void Timer ::run(void) {
40  if (this->timerStatus == RUNNING) {
41  // A zero duration (e.g. a ground-set timer parameter of 0) is treated as
42  // immediately expired on the first tick rather than asserting.
43  if (this->secondsRemaining > 0) {
44  this->secondsRemaining--;
45  }
46 
47  if (this->secondsRemaining == 0) {
48  this->timerStatus = EXPIRED;
49  }
50  }
51 }
52 
53 } // namespace Cfdp
54 } // namespace Ccsds
55 } // namespace Svc
void disableTimer(void)
Disables a CFDP timer.
Definition: Timer.cpp:30
Timer()
Construct Timer object.
Definition: Timer.cpp:17
Status getStatus(void)
Get the status of a CFDP timer.
Definition: Timer.cpp:35
void setTimer(U32 timerDuration)
Definition: Timer.cpp:25
~Timer()
Destroy Timer object.
Definition: Timer.cpp:19
void run(void)
Runs a one second increment of the CFDP timers.
Definition: Timer.cpp:39
RateGroupDivider component implementation.