-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersistentSendHeartbeats.cpp
More file actions
42 lines (35 loc) · 1.12 KB
/
PersistentSendHeartbeats.cpp
File metadata and controls
42 lines (35 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/** Command that sends Heartbeat messages to the Field Controller
* periodically. This command is persistent, and will never end
* @author Jordan Burklund
* @date Oct. 2015
**/
#include "PersistentSendHeartbeats.h"
/** Constructor **/
PersistentSendHeartbeats::PersistentSendHeartbeats() : Command("PersistentSendHeartbeats") {
}
/** Initialize the command by getting a reference to the reactor
* link and instantiating a new ElapsedTimer
**/
void PersistentSendHeartbeats::initialize() {
rLink = Robot::getInstance()->reactorLink;
hbTimer = *(new ElapsedTimer());
}
/** Continue to send heartbeat messages periodically with the
* time between each message set by the "period" member variable
**/
void PersistentSendHeartbeats::execute() {
//Send a heartbeat message after the set time has elapsed
if(hbTimer.getTimeMillis() > period) {
rLink->sendHeartbeat();
hbTimer.resetTimer();
}
}
/** Nothing to do for end, since this command never ends
**/
void PersistentSendHeartbeats::end() {
}
/** Always return false so that the command is persistent
**/
bool PersistentSendHeartbeats::isFinished() {
return false;
}