QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
DataRateTracker.cc
Go to the documentation of this file.
1#include "DataRateTracker.h"
2
4{
5 _timer.start();
6}
7
8void DataRateTracker::recordBytes(qsizetype bytes)
9{
10 _windowBytes += bytes;
11 _totalBytes += static_cast<quint64>(bytes);
12
13 const qint64 elapsed = _timer.elapsed();
14 if (elapsed >= kWindowMs) {
15 _currentRate = static_cast<double>(_windowBytes) / static_cast<double>(elapsed) * 1000.0;
16 _windowBytes = 0;
17 _rateUpdated = true;
18 (void) _timer.restart();
19 } else {
20 _rateUpdated = false;
21 }
22}
23
25{
26 _totalBytes = 0;
27 _windowBytes = 0;
28 _currentRate = 0.0;
29 _rateUpdated = false;
30 _timer.restart();
31}
void reset()
Reset all counters and restart the elapsed timer.
void recordBytes(qsizetype bytes)
Record incoming/outgoing bytes. Call whenever data passes through.