QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
DataRateTracker.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QElapsedTimer>
4#include <QtCore/QtGlobal>
5
14{
15public:
17
19 void recordBytes(qsizetype bytes);
20
22 quint64 totalBytes() const { return _totalBytes; }
23
26 double bytesPerSec() const { return _currentRate; }
27
29 double kBps() const { return _currentRate / 1024.0; }
30
33 bool rateUpdated() const { return _rateUpdated; }
34
36 void reset();
37
38private:
39 QElapsedTimer _timer;
40 quint64 _totalBytes = 0;
41 qsizetype _windowBytes = 0;
42 double _currentRate = 0.0;
43 bool _rateUpdated = false;
44
45 static constexpr qint64 kWindowMs = 1000;
46};
void reset()
Reset all counters and restart the elapsed timer.
double kBps() const
Current data rate in KB/s.
void recordBytes(qsizetype bytes)
Record incoming/outgoing bytes. Call whenever data passes through.
bool rateUpdated() const
double bytesPerSec() const
quint64 totalBytes() const
Total bytes recorded since construction or last reset.