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
3
DataRateTracker::DataRateTracker
()
4
{
5
_timer.start();
6
}
7
8
void
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
24
void
DataRateTracker::reset
()
25
{
26
_totalBytes = 0;
27
_windowBytes = 0;
28
_currentRate = 0.0;
29
_rateUpdated =
false
;
30
_timer.restart();
31
}
DataRateTracker.h
DataRateTracker::reset
void reset()
Reset all counters and restart the elapsed timer.
Definition
DataRateTracker.cc:24
DataRateTracker::recordBytes
void recordBytes(qsizetype bytes)
Record incoming/outgoing bytes. Call whenever data passes through.
Definition
DataRateTracker.cc:8
DataRateTracker::DataRateTracker
DataRateTracker()
Definition
DataRateTracker.cc:3
src
Utilities
DataRateTracker.cc
Generated by
1.9.8