moved all bw graph files in statistics. Removed outqueue info widget. Created new cpp files to host the bw graph code. Started minimal UI to display bw information. The goal is to create a widget for displaying selective bw info [work in progress]

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8586 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-07-10 03:24:39 +00:00
parent 621abee8da
commit 975b2d8783
14 changed files with 69 additions and 118 deletions

View File

@ -52,7 +52,7 @@
#include "ChatLobbyWidget.h"
#include "HelpDialog.h"
#include "AboutDialog.h"
#include "bwgraph/BandwidthGraphWindow.h"
#include "gui/statistics/BandwidthGraphWindow.h"
#include "help/browser/helpbrowser.h"
#include "chat/ChatDialog.h"
#include "RetroShareLink.h"

View File

@ -142,7 +142,7 @@ void RSGraphWidget::setShowEntry(uint32_t entry,bool b)
_masked_entries.insert(_source->displayName(entry).toStdString()) ;
}
void RSGraphWidget::addSource(RSGraphSource *gs)
void RSGraphWidget::setSource(RSGraphSource *gs)
{
if(_source != NULL)
delete _source ;

View File

@ -134,7 +134,7 @@ class RSGraphWidget: public QFrame
// sets the update interval period.
//
void setTimerPeriod(int miliseconds) ;
void addSource(RSGraphSource *gs) ;
void setSource(RSGraphSource *gs) ;
void setTimeScale(float pixels_per_second) ;
/** Add data points. */

View File

@ -0,0 +1,39 @@
#pragma once
#include "retroshare/rsconfig.h"
#include <gui/common/RSGraphWidget.h>
class BWGraphSource: public RSGraphSource
{
public:
enum { SELECTOR_TYPE_FRIEND=0x00, SELECTOR_TYPE_SERVICE=0x01 };
enum { GRAPH_TYPE_SINGLE=0x00, GRAPH_TYPE_ALL=0x01, GRAPH_TYPE_SUM };
// re-derived from RSGraphSource
virtual void getValues(std::map<std::string,float>& values) const;
virtual QString displayValue(float v) const;
virtual QString legend(int i,float v) const;
QString unitName() const ;
// own methdods to control what's used to create displayed info
void setSelector(int selector_class,int selector_type,const std::string& selector_client_string = std::string()) ;
private:
QString niceNumber(float v) const;
mutable float _total_sent ;
mutable float _total_recv ;
};
class BWGraph: public RSGraphWidget
{
public:
BWGraph(QWidget *parent);
BWGraphSource *source() ;
protected:
BWGraphSource *_local_source ;
};

View File

@ -23,7 +23,7 @@
#include <rshare.h>
#include <control/bandwidthevent.h>
#include <gui/bwgraph/BandwidthGraphWindow.h>
#include <gui/statistics/BandwidthGraphWindow.h>
#include <retroshare-gui/RsAutoUpdatePage.h>
#include <retroshare/rsconfig.h>

View File

@ -27,7 +27,7 @@
#include <QTimer>
#include <gui/common/rwindow.h>
#include <gui/statistics/bwgraph.h>
#include <gui/statistics/BWGraph.h>
#include "ui_BandwidthGraphWindow.h"

View File

@ -224,7 +224,7 @@ void BwCtrlWindow::updateDisplay()
OutQueueStatistics stats ;
rsConfig->getOutQueueStatistics(stats) ;
_outqueue_stats_W->updateStatistics(stats) ;
//_outqueue_stats_W->updateStatistics(stats) ;
}
void BwCtrlWindow::updateBandwidth()

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>597</width>
<height>469</height>
<width>1447</width>
<height>911</height>
</rect>
</property>
<property name="windowTitle">
@ -88,28 +88,17 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="OutQueueStatisticsWidget" name="_outqueue_stats_W" native="true"/>
<widget class="BWGraph" name="frmGraph" native="true">
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
</widget>
</widget>
<widget class="BandwidthStatsWidget" name="widget" native="true"/>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BWGraph</class>
<class>BandwidthStatsWidget</class>
<extends>QWidget</extends>
<header>gui/statistics/bwgraph.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>OutQueueStatisticsWidget</class>
<extends>QWidget</extends>
<header>gui/statistics/OutQueueStatistics.h</header>
<header>gui/statistics/BandwidthStatsWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>

View File

@ -125,7 +125,7 @@ RttStatisticsGraph::RttStatisticsGraph(QWidget *parent)
src->setDigits(1) ;
src->start() ;
addSource(src) ;
setSource(src) ;
setTimeScale(2.0f) ; // 1 pixels per second of time.

View File

@ -1,81 +0,0 @@
#pragma once
#include "retroshare/rsconfig.h"
#include <gui/common/RSGraphWidget.h>
class BWGraphSource: public RSGraphSource
{
public:
virtual void getValues(std::map<std::string,float>& values) const
{
RsConfigDataRates totalRates;
rsConfig->getTotalBandwidthRates(totalRates);
values.insert(std::make_pair(std::string("Bytes in"),1024 * (float)totalRates.mRateIn)) ;
values.insert(std::make_pair(std::string("Bytes out"),1024 * (float)totalRates.mRateOut)) ;
_total_sent += 1024 * totalRates.mRateOut * _update_period_msecs/1000.0f ;
_total_recv += 1024 * totalRates.mRateIn * _update_period_msecs/1000.0f ;
}
virtual QString unitName() const { return tr("KB/s"); }
virtual QString displayValue(float v) const
{
if(v < 1000)
return QString::number(v,'f',2) + " B/s" ;
else if(v < 1000*1024)
return QString::number(v/1024.0,'f',2) + " KB/s" ;
else
return QString::number(v/(1024.0*1024),'f',2) + " MB/s" ;
}
virtual QString legend(int i,float v) const
{
if(i==0)
return RSGraphSource::legend(i,v) + " Total: " + niceNumber(_total_recv) ;
else
return RSGraphSource::legend(i,v) + " Total: " + niceNumber(_total_sent) ;
}
private:
QString niceNumber(float v) const
{
if(v < 1000)
return QString::number(v,'f',2) + " B" ;
else if(v < 1000*1024)
return QString::number(v/1024.0,'f',2) + " KB" ;
else if(v < 1000*1024*1024)
return QString::number(v/(1024*1024.0),'f',2) + " MB" ;
else
return QString::number(v/(1024*1024.0*1024),'f',2) + " GB";
}
mutable float _total_sent ;
mutable float _total_recv ;
};
class BWGraph: public RSGraphWidget
{
public:
BWGraph(QWidget *parent)
: RSGraphWidget(parent)
{
BWGraphSource *src = new BWGraphSource() ;
src->setCollectionTimeLimit(30*60*1000) ; // 30 mins
src->setCollectionTimePeriod(1000) ; // collect every second
src->setDigits(2) ;
src->start() ;
addSource(src) ;
setTimeScale(1.0f) ; // 1 pixels per second of time.
resetFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ;
resetFlags(RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;
setFlags(RSGRAPH_FLAGS_SHOW_LEGEND) ;
}
};

View File

@ -67,7 +67,7 @@ class DhtGraph : public RSGraphWidget
src->setDigits(0) ;
src->start() ;
addSource(src) ;
setSource(src) ;
setTimeScale(1.0f) ; // 1 pixels per second of time.

View File

@ -42,7 +42,7 @@ class TurtleGraph: public RSGraphWidget
src->setDigits(2) ;
src->start() ;
addSource(src) ;
setSource(src) ;
setTimeScale(1.0f) ; // 1 pixels per second of time.

View File

@ -355,8 +355,15 @@ HEADERS += rshare.h \
gui/statistics/TurtleRouterDialog.h \
gui/statistics/TurtleRouterStatistics.h \
gui/statistics/dhtgraph.h \
gui/statistics/bwgraph.h \
gui/statistics/BandwidthGraphWindow.h \
gui/statistics/turtlegraph.h \
gui/statistics/BandwidthStatsWidget.h \
gui/statistics/DhtWindow.h \
gui/statistics/GlobalRouterStatistics.h \
gui/statistics/StatisticsWindow.h \
gui/statistics/BwCtrlWindow.h \
gui/statistics/RttStatistics.h \
gui/statistics/OutQueueStatistics.h \
gui/FileTransfer/TransferUserNotify.h \
gui/plugins/PluginInterface.h \
gui/im_history/ImHistoryBrowser.h \
@ -390,7 +397,6 @@ HEADERS += rshare.h \
util/ObjectPainter.h \
util/QtVersion.h \
util/RsFile.h \
gui/bwgraph/BandwidthGraphWindow.h \
gui/profile/ProfileWidget.h \
gui/profile/ProfileManager.h \
gui/profile/StatusMessage.h \
@ -540,13 +546,8 @@ HEADERS += rshare.h \
gui/connect/ConnectProgressDialog.h \
gui/groups/CreateGroup.h \
gui/GetStartedDialog.h \
gui/statistics/DhtWindow.h \
gui/statistics/GlobalRouterStatistics.h \
gui/statistics/StatisticsWindow.h \
gui/statistics/BwCtrlWindow.h \
gui/statistics/RttStatistics.h \
gui/statistics/OutQueueStatistics.h \
gui/settings/WebuiPage.h
gui/settings/WebuiPage.h \
gui/statistics/BWGraph.h
# gui/ForumsDialog.h \
# gui/forums/ForumDetails.h \
@ -585,7 +586,6 @@ FORMS += gui/StartDialog.ui \
gui/help/browser/helpbrowser.ui \
gui/HelpDialog.ui \
gui/ServicePermissionDialog.ui \
gui/bwgraph/BandwidthGraphWindow.ui \
gui/profile/ProfileWidget.ui \
gui/profile/StatusMessage.ui \
gui/profile/ProfileManager.ui \
@ -653,6 +653,8 @@ FORMS += gui/StartDialog.ui \
gui/common/HeaderFrame.ui \
gui/common/RSFeedWidget.ui \
gui/style/StyleDialog.ui \
gui/statistics/BandwidthGraphWindow.ui \
gui/statistics/BandwidthStatsWidget.ui \
gui/statistics/DhtWindow.ui \
gui/statistics/TurtleRouterDialog.ui \
gui/statistics/TurtleRouterStatistics.ui \
@ -739,7 +741,6 @@ SOURCES += main.cpp \
util/HandleRichText.cpp \
util/ObjectPainter.cpp \
util/RsFile.cpp \
gui/bwgraph/BandwidthGraphWindow.cpp \
gui/profile/ProfileWidget.cpp \
gui/profile/StatusMessage.cpp \
gui/profile/ProfileManager.cpp \
@ -844,6 +845,7 @@ SOURCES += main.cpp \
gui/settings/ServicePermissionsPage.cpp \
gui/settings/AddFileAssociationDialog.cpp \
gui/settings/GroupFrameSettingsWidget.cpp \
gui/settings/WebuiPage.cpp \
gui/statusbar/peerstatus.cpp \
gui/statusbar/natstatus.cpp \
gui/statusbar/dhtstatus.cpp \
@ -884,6 +886,8 @@ SOURCES += main.cpp \
gui/connect/ConnectProgressDialog.cpp \
gui/groups/CreateGroup.cpp \
gui/GetStartedDialog.cpp \
gui/statistics/BandwidthGraphWindow.cpp \
gui/statistics/BandwidthStatsWidget.cpp \
gui/statistics/DhtWindow.cpp \
gui/statistics/TurtleRouterDialog.cpp \
gui/statistics/TurtleRouterStatistics.cpp \
@ -892,7 +896,7 @@ SOURCES += main.cpp \
gui/statistics/StatisticsWindow.cpp \
gui/statistics/BwCtrlWindow.cpp \
gui/statistics/RttStatistics.cpp \
gui/settings/WebuiPage.cpp
gui/statistics/BWGraph.cpp
# gui/ForumsDialog.cpp \
# gui/forums/ForumDetails.cpp \