Merge pull request #4213 from sethalves/rework-bandwidth-meter

Rework bandwidth meter
This commit is contained in:
Brad Hefta-Gaub 2015-02-03 13:53:24 -08:00
commit fa608477b2
2 changed files with 9 additions and 9 deletions

View file

@ -315,6 +315,11 @@ void Stats::display(
verticalOffset = 0; verticalOffset = 0;
horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + 1; horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + 1;
if (columnOneWidth == _generalStatsWidth) {
drawBackground(backgroundColor, horizontalOffset, 0, _bandwidthStatsWidth, lines * STATS_PELS_PER_LINE + 10);
}
horizontalOffset += 5;
char packetsPerSecondString[30]; char packetsPerSecondString[30];
sprintf(packetsPerSecondString, "Packets In/Out: %d/%d", inPacketsPerSecond, outPacketsPerSecond); sprintf(packetsPerSecondString, "Packets In/Out: %d/%d", inPacketsPerSecond, outPacketsPerSecond);
char averageMegabitsPerSecond[30]; char averageMegabitsPerSecond[30];

View file

@ -11,7 +11,6 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <QDebug>
#include <QDateTime> #include <QDateTime>
#include "BandwidthRecorder.h" #include "BandwidthRecorder.h"
@ -53,17 +52,18 @@ void BandwidthRecorder::Channel::updateOutputAverage(const float sample) {
} }
BandwidthRecorder::BandwidthRecorder() { BandwidthRecorder::BandwidthRecorder() {
for (uint i=0; i<CHANNEL_COUNT; i++) for (uint i=0; i<CHANNEL_COUNT; i++) {
_channels[ i ] = NULL; _channels[ i ] = NULL;
}
} }
BandwidthRecorder::~BandwidthRecorder() { BandwidthRecorder::~BandwidthRecorder() {
for (uint i=0; i<CHANNEL_COUNT; i++) for (uint i=0; i<CHANNEL_COUNT; i++) {
delete _channels[ i ]; delete _channels[ i ];
}
} }
void BandwidthRecorder::updateInboundData(const quint8 channelType, const int sample) { void BandwidthRecorder::updateInboundData(const quint8 channelType, const int sample) {
Q_ASSERT(channelType < CHANNEL_COUNT);
if (! _channels[channelType]) { if (! _channels[channelType]) {
_channels[channelType] = new Channel(); _channels[channelType] = new Channel();
} }
@ -71,7 +71,6 @@ void BandwidthRecorder::updateInboundData(const quint8 channelType, const int sa
} }
void BandwidthRecorder::updateOutboundData(const quint8 channelType, const int sample) { void BandwidthRecorder::updateOutboundData(const quint8 channelType, const int sample) {
Q_ASSERT(channelType < CHANNEL_COUNT);
if (! _channels[channelType]) { if (! _channels[channelType]) {
_channels[channelType] = new Channel(); _channels[channelType] = new Channel();
} }
@ -79,7 +78,6 @@ void BandwidthRecorder::updateOutboundData(const quint8 channelType, const int s
} }
float BandwidthRecorder::getAverageInputPacketsPerSecond(const quint8 channelType) { float BandwidthRecorder::getAverageInputPacketsPerSecond(const quint8 channelType) {
Q_ASSERT(channelType < CHANNEL_COUNT);
if (! _channels[channelType]) { if (! _channels[channelType]) {
return 0.0f; return 0.0f;
} }
@ -87,7 +85,6 @@ float BandwidthRecorder::getAverageInputPacketsPerSecond(const quint8 channelTyp
} }
float BandwidthRecorder::getAverageOutputPacketsPerSecond(const quint8 channelType) { float BandwidthRecorder::getAverageOutputPacketsPerSecond(const quint8 channelType) {
Q_ASSERT(channelType < CHANNEL_COUNT);
if (! _channels[channelType]) { if (! _channels[channelType]) {
return 0.0f; return 0.0f;
} }
@ -95,7 +92,6 @@ float BandwidthRecorder::getAverageOutputPacketsPerSecond(const quint8 channelTy
} }
float BandwidthRecorder::getAverageInputKilobitsPerSecond(const quint8 channelType) { float BandwidthRecorder::getAverageInputKilobitsPerSecond(const quint8 channelType) {
Q_ASSERT(channelType < CHANNEL_COUNT);
if (! _channels[channelType]) { if (! _channels[channelType]) {
return 0.0f; return 0.0f;
} }
@ -103,7 +99,6 @@ float BandwidthRecorder::getAverageInputKilobitsPerSecond(const quint8 channelTy
} }
float BandwidthRecorder::getAverageOutputKilobitsPerSecond(const quint8 channelType) { float BandwidthRecorder::getAverageOutputKilobitsPerSecond(const quint8 channelType) {
Q_ASSERT(channelType < CHANNEL_COUNT);
if (! _channels[channelType]) { if (! _channels[channelType]) {
return 0.0f; return 0.0f;
} }