|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <DataRateTracker.h>
Public Types | |
| using | Clock = std::function< quint64()> |
| Monotonic microseconds, injectable for deterministic window tests. | |
Public Member Functions | |
| DataRateTracker (Clock clock=MonotonicClock::nowUs) | |
| void | recordBytes (qsizetype bytes) |
| Record incoming/outgoing bytes. Call whenever data passes through. | |
| void | refresh () |
| Advance the rate window without changing cumulative bytes. | |
| quint64 | totalBytes () const |
| Total bytes recorded since construction or last reset. | |
| double | bytesPerSec () const |
| Rate of the last completed window, in bytes/sec. | |
| double | kBps () const |
| Current data rate in KB/s. | |
| bool | rateUpdated () const |
| void | reset () |
| Reset all counters and restart the rate window. | |
| void | resetRate () |
| Zero the rate and restart its window; cumulative bytes are kept. | |
Lightweight, non-QObject helper that tracks a windowed data rate.
Call recordBytes() whenever data passes through and refresh() from a periodic UI timer to expire the rate during silence. Completed windows retain their rate until the next refresh or recordBytes call crosses a window boundary.
Thread safety: none — use from a single thread.
Definition at line 16 of file DataRateTracker.h.
| using DataRateTracker::Clock = std::function<quint64()> |
Monotonic microseconds, injectable for deterministic window tests.
Definition at line 20 of file DataRateTracker.h.
|
explicit |
Definition at line 5 of file DataRateTracker.cc.
|
inline |
Rate of the last completed window, in bytes/sec.
Definition at line 33 of file DataRateTracker.h.
Referenced by NTRIPConnectionStats::dataRateBytesPerSec().
|
inline |
Current data rate in KB/s.
Definition at line 36 of file DataRateTracker.h.
|
inline |
Whether the rate was recalculated on the last recordBytes()/refresh() call. Useful for the caller to know when to emit signals.
Definition at line 40 of file DataRateTracker.h.
| void DataRateTracker::recordBytes | ( | qsizetype | bytes | ) |
Record incoming/outgoing bytes. Call whenever data passes through.
Definition at line 11 of file DataRateTracker.cc.
References refresh().
Referenced by NTRIPConnectionStats::recordMessage().
| void DataRateTracker::refresh | ( | ) |
Advance the rate window without changing cumulative bytes.
Definition at line 19 of file DataRateTracker.cc.
Referenced by recordBytes(), and NTRIPConnectionStats::start().
| void DataRateTracker::reset | ( | ) |
Reset all counters and restart the rate window.
Definition at line 33 of file DataRateTracker.cc.
References resetRate().
Referenced by NTRIPConnectionStats::reset().
| void DataRateTracker::resetRate | ( | ) |
Zero the rate and restart its window; cumulative bytes are kept.
Definition at line 39 of file DataRateTracker.cc.
Referenced by reset(), and NTRIPConnectionStats::stop().
|
inline |
Total bytes recorded since construction or last reset.
Definition at line 30 of file DataRateTracker.h.
Referenced by NTRIPConnectionStats::bytesReceived().