mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-20 15:00:36 -04:00
improved RSGraph class. Not finished yet.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7609 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6e2df7e0de
commit
1757a85e57
6 changed files with 272 additions and 163 deletions
|
@ -168,13 +168,12 @@ class RttPlot
|
|||
};
|
||||
|
||||
RttStatistics::RttStatistics(QWidget *parent)
|
||||
: RsAutoUpdatePage(2000,parent)
|
||||
{
|
||||
setupUi(this) ;
|
||||
|
||||
m_bProcessSettings = false;
|
||||
|
||||
_tunnel_statistics_F->setWidget( _tst_CW = new RttStatisticsWidget() ) ;
|
||||
_tunnel_statistics_F->setWidget( _tst_CW = new RttStatisticsGraph() ) ;
|
||||
_tunnel_statistics_F->setWidgetResizable(true);
|
||||
_tunnel_statistics_F->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
_tunnel_statistics_F->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
|
@ -218,63 +217,78 @@ void RttStatistics::processSettings(bool bLoad)
|
|||
|
||||
}
|
||||
|
||||
|
||||
void RttStatistics::updateDisplay()
|
||||
void RttGraphSource::getValues(std::map<std::string,float>& vals)
|
||||
{
|
||||
std::map<RsPeerId, std::list<RsRttPongResult> > info;
|
||||
std::list<RsPeerId> idList;
|
||||
rsPeers->getOnlineList(idList);
|
||||
|
||||
if (!rsRtt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
vals.clear() ;
|
||||
std::list<RsRttPongResult> results ;
|
||||
|
||||
std::list<RsPeerId> idList;
|
||||
std::list<RsPeerId>::iterator it;
|
||||
for(std::list<RsPeerId>::const_iterator it(idList.begin());it!=idList.end();++it)
|
||||
{
|
||||
rsRtt->getPongResults(*it, 1, results);
|
||||
|
||||
rsPeers->getOnlineList(idList);
|
||||
|
||||
time_t now = time(NULL);
|
||||
time_t minTS = now;
|
||||
time_t maxTS = 0;
|
||||
double maxRTT = 0;
|
||||
|
||||
for(it = idList.begin(); it != idList.end(); it++)
|
||||
{
|
||||
std::list<RsRttPongResult> results;
|
||||
std::list<RsRttPongResult>::iterator rit;
|
||||
|
||||
#define MAX_RESULTS 60
|
||||
rsRtt->getPongResults(*it, MAX_RESULTS, results);
|
||||
|
||||
for(rit = results.begin(); rit != results.end(); rit++)
|
||||
{
|
||||
/* only want maxRTT to include plotted bit */
|
||||
double dt = now - rit->mTS;
|
||||
if (dt < MAX_DISPLAY_PERIOD)
|
||||
{
|
||||
if (maxRTT < rit->mRTT)
|
||||
{
|
||||
maxRTT = rit->mRTT;
|
||||
}
|
||||
}
|
||||
if (minTS > rit->mTS)
|
||||
{
|
||||
minTS = rit->mTS;
|
||||
}
|
||||
if (maxTS < rit->mTS)
|
||||
{
|
||||
maxTS = rit->mTS;
|
||||
}
|
||||
}
|
||||
|
||||
info[*it] = results;
|
||||
}
|
||||
|
||||
|
||||
_tst_CW->updateRttStatistics(info, maxRTT, minTS, maxTS);
|
||||
_tst_CW->update();
|
||||
vals[(*it).toStdString()] = results.front().mRTT ;
|
||||
}
|
||||
}
|
||||
|
||||
//void RttStatistics::updateDisplay()
|
||||
//{
|
||||
// std::map<RsPeerId, std::list<RsRttPongResult> > info;
|
||||
//
|
||||
// if (!rsRtt)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// std::list<RsPeerId> idList;
|
||||
// std::list<RsPeerId>::iterator it;
|
||||
//
|
||||
// rsPeers->getOnlineList(idList);
|
||||
//
|
||||
// time_t now = time(NULL);
|
||||
// time_t minTS = now;
|
||||
// time_t maxTS = 0;
|
||||
// double maxRTT = 0;
|
||||
//
|
||||
// for(it = idList.begin(); it != idList.end(); it++)
|
||||
// {
|
||||
// std::list<RsRttPongResult> results;
|
||||
// std::list<RsRttPongResult>::iterator rit;
|
||||
//
|
||||
//#define MAX_RESULTS 60
|
||||
// rsRtt->getPongResults(*it, MAX_RESULTS, results);
|
||||
//
|
||||
// for(rit = results.begin(); rit != results.end(); rit++)
|
||||
// {
|
||||
// /* only want maxRTT to include plotted bit */
|
||||
// double dt = now - rit->mTS;
|
||||
// if (dt < MAX_DISPLAY_PERIOD)
|
||||
// {
|
||||
// if (maxRTT < rit->mRTT)
|
||||
// {
|
||||
// maxRTT = rit->mRTT;
|
||||
// }
|
||||
// }
|
||||
// if (minTS > rit->mTS)
|
||||
// {
|
||||
// minTS = rit->mTS;
|
||||
// }
|
||||
// if (maxTS < rit->mTS)
|
||||
// {
|
||||
// maxTS = rit->mTS;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// info[*it] = results;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// _tst_CW->updateRttStatistics(info, maxRTT, minTS, maxTS);
|
||||
// _tst_CW->update();
|
||||
//}
|
||||
|
||||
QString RttStatistics::getPeerName(const RsPeerId& peer_id)
|
||||
{
|
||||
static std::map<RsPeerId, QString> names ;
|
||||
|
|
|
@ -25,10 +25,27 @@
|
|||
#include <retroshare/rsrtt.h>
|
||||
#include "ui_RttStatistics.h"
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include <gui/common/RSGraphWidget.h>
|
||||
|
||||
class RttStatisticsWidget ;
|
||||
|
||||
class RttStatistics: public RsAutoUpdatePage, public Ui::RttStatistics
|
||||
class RttGraphSource: public RSGraphSource
|
||||
{
|
||||
public:
|
||||
RttGraphSource() ;
|
||||
|
||||
virtual void getValues(std::map<std::string,float>& vals) ;
|
||||
};
|
||||
|
||||
class RttStatisticsGraph: public RSGraphWidget
|
||||
{
|
||||
public:
|
||||
RttStatisticsGraph()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class RttStatistics: public MainPage, public Ui::RttStatistics
|
||||
{
|
||||
public:
|
||||
RttStatistics(QWidget *parent = NULL) ;
|
||||
|
@ -42,9 +59,7 @@ class RttStatistics: public RsAutoUpdatePage, public Ui::RttStatistics
|
|||
void processSettings(bool bLoad);
|
||||
bool m_bProcessSettings;
|
||||
|
||||
virtual void updateDisplay() ;
|
||||
|
||||
RttStatisticsWidget *_tst_CW ;
|
||||
RttStatisticsGraph *_tst_CW ;
|
||||
} ;
|
||||
|
||||
class RttStatisticsWidget: public QWidget
|
||||
|
@ -66,3 +81,6 @@ class RttStatisticsWidget: public QWidget
|
|||
int maxWidth,maxHeight ;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -136,11 +136,8 @@ void StatisticsWindow::initStackedPage()
|
|||
ui->stackPages->add(grsdlg = new GlobalRouterStatistics(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_GLOBALROUTER), tr("Global Router"), grp));
|
||||
|
||||
#ifdef SHOW_RTT_STATISTICS
|
||||
|
||||
ui->stackPages->add(rttdlg = new RttStatistics(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_RTT), tr("RTT Statistics"), grp));
|
||||
#endif
|
||||
ui->stackPages->add(rttdlg = new RttStatistics(ui->stackPages),
|
||||
action = createPageAction(QIcon(IMAGE_RTT), tr("RTT Statistics"), grp));
|
||||
|
||||
/*std::cerr << "Looking for interfaces in existing plugins:" << std::endl;
|
||||
for(int i = 0;i<rsPlugins->nbPlugins();++i)
|
||||
|
|
|
@ -33,24 +33,26 @@ class DHTGraphSource: public RSGraphSource
|
|||
public:
|
||||
virtual int n_values() const
|
||||
{
|
||||
return 2 ;
|
||||
return 1 ;
|
||||
}
|
||||
virtual void getValues(std::vector<float>& values) const
|
||||
virtual void getValues(std::map<std::string,float>& values) const
|
||||
{
|
||||
RsConfigNetStatus config;
|
||||
rsConfig->getConfigNetStatus(config);
|
||||
|
||||
if (config.DHTActive && config.netDhtOk)
|
||||
{
|
||||
values.push_back(config.netDhtRsNetSize) ;
|
||||
values.push_back(config.netDhtNetSize) ;
|
||||
values.insert(std::make_pair(std::string("RS Net size"),(float)config.netDhtRsNetSize)) ;
|
||||
//values.insert(std::make_pair(std::string("GLobal Net size"),(float)config.netDhtNetSize)) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
values.push_back(0.0f) ;
|
||||
values.push_back(0.0f) ;
|
||||
values.insert(std::make_pair(std::string("RS Net size"),0.0f)) ;
|
||||
//values.insert(std::make_pair(std::string("GLobal Net size"),0.0f)) ;
|
||||
}
|
||||
}
|
||||
|
||||
virtual QString unitName() const { return tr("users"); }
|
||||
};
|
||||
|
||||
/** Default contructor */
|
||||
|
@ -65,7 +67,8 @@ DhtGraph::DhtGraph(QWidget *parent)
|
|||
|
||||
addSource(src) ;
|
||||
|
||||
setTimeScale(10.0f) ;
|
||||
setTimeScale(1.0f) ; // 1 pixels per second of time.
|
||||
resetFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue