Unverified Commit c5aa2ab6 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #6586 from acfloria/fix/link_active

Split constructor of HeartbeatTimer up in two functions
parents bb40dd6c c89404d9
...@@ -17,7 +17,11 @@ HeartbeatTimer::HeartbeatTimer(int vehicle_id, bool high_latency) : ...@@ -17,7 +17,11 @@ HeartbeatTimer::HeartbeatTimer(int vehicle_id, bool high_latency) :
_vehicleID(vehicle_id), _vehicleID(vehicle_id),
_high_latency(high_latency) _high_latency(high_latency)
{ {
if (!high_latency) { }
void HeartbeatTimer::init()
{
if (!_high_latency) {
_timer->setInterval(_heartbeatReceivedTimeoutMSecs); _timer->setInterval(_heartbeatReceivedTimeoutMSecs);
_timer->setSingleShot(true); _timer->setSingleShot(true);
_timer->start(); _timer->start();
...@@ -26,7 +30,9 @@ HeartbeatTimer::HeartbeatTimer(int vehicle_id, bool high_latency) : ...@@ -26,7 +30,9 @@ HeartbeatTimer::HeartbeatTimer(int vehicle_id, bool high_latency) :
QObject::connect(_timer, &QTimer::timeout, this, &HeartbeatTimer::timerTimeout); QObject::connect(_timer, &QTimer::timeout, this, &HeartbeatTimer::timerTimeout);
} }
HeartbeatTimer::~HeartbeatTimer() {
HeartbeatTimer::~HeartbeatTimer()
{
if (_timer) { if (_timer) {
QObject::disconnect(_timer, &QTimer::timeout, this, &HeartbeatTimer::timerTimeout); QObject::disconnect(_timer, &QTimer::timeout, this, &HeartbeatTimer::timerTimeout);
_timer->stop(); _timer->stop();
......
...@@ -36,6 +36,13 @@ public: ...@@ -36,6 +36,13 @@ public:
*/ */
HeartbeatTimer(int vehicle_id, bool high_latency); HeartbeatTimer(int vehicle_id, bool high_latency);
/**
* @brief init
*
* Starts the timer and emits the signal that the link is active for this vehicle ID
*/
void init();
~HeartbeatTimer(); ~HeartbeatTimer();
/** /**
......
...@@ -195,6 +195,7 @@ void LinkInterface::startHeartbeatTimer(int vehicle_id) { ...@@ -195,6 +195,7 @@ void LinkInterface::startHeartbeatTimer(int vehicle_id) {
} else { } else {
_heartbeatTimers.insert(vehicle_id, new HeartbeatTimer(vehicle_id, _highLatency)); _heartbeatTimers.insert(vehicle_id, new HeartbeatTimer(vehicle_id, _highLatency));
QObject::connect(_heartbeatTimers.value(vehicle_id), &HeartbeatTimer::activeChanged, this, &LinkInterface::_activeChanged); QObject::connect(_heartbeatTimers.value(vehicle_id), &HeartbeatTimer::activeChanged, this, &LinkInterface::_activeChanged);
_heartbeatTimers.value(vehicle_id)->init();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment