mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 07:59:35 -05:00
removed unused method for OutQueue statistics; improved BW curve display; fixed a few display bugs
This commit is contained in:
parent
bdad800509
commit
2a47095599
@ -94,7 +94,6 @@ virtual void getRates(RsBwRates &rates)
|
||||
return;
|
||||
}
|
||||
|
||||
virtual int gatherOutQueueStatistics(std::vector<uint32_t>& /*per_service_count*/,std::vector<uint32_t>& /*per_priority_count*/) { return 0;}
|
||||
virtual int gatherStatistics(std::list<RSTrafficClue>& /* outqueue_lst */,std::list<RSTrafficClue>& /* inqueue_lst */) { return 0;}
|
||||
|
||||
virtual int getQueueSize(bool /* in */) { return 0;}
|
||||
|
@ -387,33 +387,20 @@ RsRawItem *pqihandler::GetRsRawItem()
|
||||
|
||||
static const float MIN_RATE = 0.01; // 10 B/s
|
||||
|
||||
int pqihandler::ExtractOutQueueStatistics(OutQueueStatistics& stats)
|
||||
{
|
||||
stats.per_service_item_count.clear() ;
|
||||
|
||||
std::vector<uint32_t> item_counts(65536,0) ;
|
||||
stats.per_priority_item_count.clear() ;
|
||||
stats.per_priority_item_count.resize(10,0) ;
|
||||
|
||||
std::map<RsPeerId, SearchModule *>::iterator it;
|
||||
|
||||
for(it = mods.begin(); it != mods.end(); ++it)
|
||||
(it -> second)->pqi->gatherOutQueueStatistics(item_counts,stats.per_priority_item_count) ;
|
||||
|
||||
for(int i=0;i<65536;++i)
|
||||
if(item_counts[i] > 0)
|
||||
stats.per_service_item_count[i] = item_counts[i] ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
int pqihandler::ExtractTrafficInfo(std::list<RSTrafficClue>& out_lst,std::list<RSTrafficClue>& in_lst)
|
||||
{
|
||||
in_lst.clear() ;
|
||||
out_lst.clear() ;
|
||||
|
||||
for( std::map<RsPeerId, SearchModule *>::iterator it = mods.begin(); it != mods.end(); ++it)
|
||||
(it -> second)->pqi->gatherStatistics(out_lst,in_lst) ;
|
||||
{
|
||||
std::list<RSTrafficClue> ilst,olst ;
|
||||
|
||||
(it -> second)->pqi->gatherStatistics(olst,ilst) ;
|
||||
|
||||
for(std::list<RSTrafficClue>::const_iterator it(ilst.begin());it!=ilst.end();++it) in_lst.push_back(*it) ;
|
||||
for(std::list<RSTrafficClue>::const_iterator it(olst.begin());it!=olst.end();++it) out_lst.push_back(*it) ;
|
||||
}
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ class pqihandler: public P3Interface, public pqiPublisher
|
||||
|
||||
// TESTING INTERFACE.
|
||||
int ExtractRates(std::map<RsPeerId, RsBwRates> &ratemap, RsBwRates &totals);
|
||||
int ExtractOutQueueStatistics(OutQueueStatistics& stats) ;
|
||||
int ExtractTrafficInfo(std::list<RSTrafficClue> &out_lst, std::list<RSTrafficClue> &in_lst);
|
||||
|
||||
protected:
|
||||
|
@ -592,16 +592,6 @@ void pqiperson::getRates(RsBwRates &rates)
|
||||
return;
|
||||
activepqi -> getRates(rates);
|
||||
}
|
||||
int pqiperson::gatherOutQueueStatistics(std::vector<uint32_t>& per_service,std::vector<uint32_t>& per_priority)
|
||||
{
|
||||
RsStackMutex stack(mPersonMtx); /**** LOCK MUTEX ****/
|
||||
|
||||
// get the rate from the active one.
|
||||
if ((!active) || (activepqi == NULL))
|
||||
return 0;
|
||||
return activepqi -> gatherOutQueueStatistics(per_service,per_priority);
|
||||
}
|
||||
|
||||
int pqiperson::gatherStatistics(std::list<RSTrafficClue>& out_lst,std::list<RSTrafficClue>& in_lst)
|
||||
{
|
||||
RsStackMutex stack(mPersonMtx); /**** LOCK MUTEX ****/
|
||||
|
@ -170,7 +170,6 @@ virtual void getRates(RsBwRates &rates);
|
||||
virtual float getRate(bool in);
|
||||
virtual void setMaxRate(bool in, float val);
|
||||
virtual void setRateCap(float val_in, float val_out);
|
||||
virtual int gatherOutQueueStatistics(std::vector<uint32_t>& per_service,std::vector<uint32_t>& per_priority);
|
||||
virtual int gatherStatistics(std::list<RSTrafficClue>& outqueue_lst,std::list<RSTrafficClue>& inqueue_lst) ;
|
||||
|
||||
|
||||
|
@ -1024,15 +1024,6 @@ void pqistreamer::free_rpend_locked()
|
||||
mPkt_rpend_size = 0;
|
||||
}
|
||||
|
||||
int pqistreamer::gatherOutQueueStatistics(std::vector<uint32_t>& per_service_count,std::vector<uint32_t>& per_priority_count)
|
||||
{
|
||||
#ifdef TO_REMOVE
|
||||
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||
|
||||
return locked_gatherStatistics(per_service_count,per_priority_count);
|
||||
#endif
|
||||
}
|
||||
|
||||
int pqistreamer::gatherStatistics(std::list<RSTrafficClue>& outqueue_lst,std::list<RSTrafficClue>& inqueue_lst)
|
||||
{
|
||||
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||
|
@ -62,7 +62,6 @@ class pqistreamer: public PQInterface
|
||||
time_t getLastIncomingTS(); // Time of last data packet, for checking a connection is alive.
|
||||
virtual void getRates(RsBwRates &rates);
|
||||
virtual int getQueueSize(bool in); // extracting data.
|
||||
virtual int gatherOutQueueStatistics(std::vector<uint32_t>& per_service_count,std::vector<uint32_t>& per_priority_count); // extracting data.
|
||||
virtual int gatherStatistics(std::list<RSTrafficClue>& outqueue_stats,std::list<RSTrafficClue>& inqueue_stats); // extracting data.
|
||||
protected:
|
||||
|
||||
|
@ -186,13 +186,6 @@ public:
|
||||
RSTrafficClue& operator+=(const RSTrafficClue& tc) { size += tc.size; count += tc.count ; return *this ;}
|
||||
};
|
||||
|
||||
class OutQueueStatistics
|
||||
{
|
||||
public:
|
||||
std::map<uint16_t,uint32_t> per_service_item_count ;
|
||||
std::vector<uint32_t> per_priority_item_count ;
|
||||
};
|
||||
|
||||
class RsConfigNetStatus
|
||||
{
|
||||
public:
|
||||
@ -261,7 +254,6 @@ public:
|
||||
|
||||
virtual int getTotalBandwidthRates(RsConfigDataRates &rates) = 0;
|
||||
virtual int getAllBandwidthRates(std::map<RsPeerId, RsConfigDataRates> &ratemap) = 0;
|
||||
virtual int getOutQueueStatistics(OutQueueStatistics& stats) = 0 ;
|
||||
virtual int getTrafficInfo(std::list<RSTrafficClue>& out_lst,std::list<RSTrafficClue>& in_lst) = 0 ;
|
||||
|
||||
/* From RsInit */
|
||||
|
@ -207,13 +207,6 @@ int p3ServerConfig::getTotalBandwidthRates(RsConfigDataRates &rates)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int p3ServerConfig::getOutQueueStatistics(OutQueueStatistics& stats)
|
||||
{
|
||||
if (rsBandwidthControl)
|
||||
return rsBandwidthControl->ExtractOutQueueStatistics(stats);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
int p3ServerConfig::getAllBandwidthRates(std::map<RsPeerId, RsConfigDataRates> &ratemap)
|
||||
{
|
||||
if (rsBandwidthControl)
|
||||
|
@ -58,7 +58,6 @@ virtual int getConfigStartup(RsConfigStartup ¶ms);
|
||||
|
||||
virtual int getTotalBandwidthRates(RsConfigDataRates &rates);
|
||||
virtual int getAllBandwidthRates(std::map<RsPeerId, RsConfigDataRates> &ratemap);
|
||||
virtual int getOutQueueStatistics(OutQueueStatistics& stats) ;
|
||||
virtual int getTrafficInfo(std::list<RSTrafficClue>& out_lst, std::list<RSTrafficClue> &in_lst) ;
|
||||
|
||||
/* From RsInit */
|
||||
|
@ -280,11 +280,6 @@ int p3BandwidthControl::getAllBandwidthRates(std::map<RsPeerId, RsConfigDataRate
|
||||
|
||||
}
|
||||
|
||||
int p3BandwidthControl::ExtractOutQueueStatistics(OutQueueStatistics& stats)
|
||||
{
|
||||
return mPg->ExtractOutQueueStatistics(stats) ;
|
||||
}
|
||||
|
||||
int p3BandwidthControl::ExtractTrafficInfo(std::list<RSTrafficClue>& in_stats,std::list<RSTrafficClue>& out_stats)
|
||||
{
|
||||
return mPg->ExtractTrafficInfo(out_stats,in_stats) ;
|
||||
|
@ -414,6 +414,8 @@ void RSGraphWidget::pointsFromData(const std::vector<QPointF>& values,QVector<QP
|
||||
float last_px = SCALE_WIDTH*fact ;
|
||||
float last_py = 0.0f ;
|
||||
|
||||
// float min_x_no_data_threshold = 1.5 ; // 1.5 sec.
|
||||
|
||||
for (uint i = 0; i < values.size(); ++i)
|
||||
{
|
||||
//std::cerr << "Value: (" << values[i].x() << " , " << values[i].y() << ")" << std::endl;
|
||||
@ -423,7 +425,7 @@ void RSGraphWidget::pointsFromData(const std::vector<QPointF>& values,QVector<QP
|
||||
qreal px = x - (values[i].x()-last)*_time_scale ;
|
||||
qreal py = y - valueToPixels(values[i].y()) ;
|
||||
|
||||
if(px >= SCALE_WIDTH *fact&& last_px < SCALE_WIDTH*fact)
|
||||
if(px >= SCALE_WIDTH*fact && last_px < SCALE_WIDTH*fact)
|
||||
{
|
||||
float alpha = (SCALE_WIDTH*fact - last_px)/(px - last_px) ;
|
||||
float ipx = SCALE_WIDTH*fact ;
|
||||
@ -433,10 +435,12 @@ void RSGraphWidget::pointsFromData(const std::vector<QPointF>& values,QVector<QP
|
||||
points << QPointF(ipx,ipy) ;
|
||||
}
|
||||
else if(i==0)
|
||||
{
|
||||
if(px < SCALE_WIDTH*fact)
|
||||
points << QPointF(SCALE_WIDTH*fact,py) ;
|
||||
else
|
||||
points << QPointF(px,y) ;
|
||||
|
||||
last_px = px ;
|
||||
last_py = py ;
|
||||
}
|
||||
|
||||
if(px < SCALE_WIDTH*fact)
|
||||
continue ;
|
||||
@ -448,10 +452,20 @@ void RSGraphWidget::pointsFromData(const std::vector<QPointF>& values,QVector<QP
|
||||
if(points.size() > 1 && points[points.size()-2].y() == points.back().y() && points.back().y() == py)
|
||||
points.pop_back() ;
|
||||
|
||||
// if(fabs(px - last_px)/_time_scale > min_x_no_data_threshold)
|
||||
// {
|
||||
// points << QPointF(last_px,y) ;
|
||||
// points << QPointF(px,y) ;
|
||||
// }
|
||||
|
||||
points << QPointF(px,py) ;
|
||||
|
||||
if(i==values.size()-1)
|
||||
points << QPointF(px,y) ;
|
||||
|
||||
last_px = px ;
|
||||
last_py = py ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
#include "BWGraph.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include "retroshare/rsservicecontrol.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
//#define BWGRAPH_DEBUG 1
|
||||
|
||||
@ -23,20 +26,35 @@ void BWGraphSource::update()
|
||||
thc.time_stamp = getTime() ;
|
||||
mTrafficHistory.push_back(thc) ;
|
||||
|
||||
std::set<RsPeerId> fds ;
|
||||
|
||||
// add visible friends/services
|
||||
|
||||
for(std::list<RSTrafficClue>::const_iterator it(thc.out_rstcl.begin());it!=thc.out_rstcl.end();++it)
|
||||
{
|
||||
mVisibleFriends.insert(it->peer_id) ;
|
||||
fds.insert(it->peer_id) ;
|
||||
mVisibleServices.insert(it->service_id) ;
|
||||
}
|
||||
|
||||
for(std::list<RSTrafficClue>::const_iterator it(thc.in_rstcl.begin());it!=thc.in_rstcl.end();++it)
|
||||
{
|
||||
mVisibleFriends.insert(it->peer_id) ;
|
||||
fds.insert(it->peer_id) ;
|
||||
mVisibleServices.insert(it->service_id) ;
|
||||
}
|
||||
|
||||
for(std::set<RsPeerId>::const_iterator it(fds.begin());it!=fds.end();++it)
|
||||
{
|
||||
std::string& s(mVisibleFriends[*it]) ;
|
||||
|
||||
if(s.empty())
|
||||
{
|
||||
RsPeerDetails pd ;
|
||||
rsPeers->getPeerDetails(*it,pd) ;
|
||||
|
||||
s = pd.name + " (" + pd.location + ")" ;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BWGRAPH_DEBUG
|
||||
std::cerr << " visible friends: " << std::dec << mVisibleFriends.size() << std::endl;
|
||||
std::cerr << " visible service: " << std::dec << mVisibleServices.size() << std::endl;
|
||||
@ -49,12 +67,25 @@ void BWGraphSource::update()
|
||||
|
||||
qint64 ms = getTime() ;
|
||||
|
||||
std::set<std::string> unused_vals ;
|
||||
|
||||
for(std::map<std::string,std::list<std::pair<qint64,float> > >::const_iterator it=_points.begin();it!=_points.end();++it)
|
||||
unused_vals.insert(it->first) ;
|
||||
|
||||
for(std::map<std::string,float>::iterator it=vals.begin();it!=vals.end();++it)
|
||||
{
|
||||
std::list<std::pair<qint64,float> >& lst(_points[it->first]) ;
|
||||
|
||||
if(!lst.empty() && fabsf(lst.back().first - ms) > _update_period_msecs*1.2 )
|
||||
{
|
||||
lst.push_back(std::make_pair(lst.back().first,0)) ;
|
||||
lst.push_back(std::make_pair( ms,0)) ;
|
||||
}
|
||||
|
||||
lst.push_back(std::make_pair(ms,it->second)) ;
|
||||
|
||||
unused_vals.erase(it->first) ;
|
||||
|
||||
for(std::list<std::pair<qint64,float> >::iterator it2=lst.begin();it2!=lst.end();)
|
||||
if( ms - (*it2).first > _time_limit_msecs)
|
||||
{
|
||||
@ -65,6 +96,11 @@ void BWGraphSource::update()
|
||||
break ;
|
||||
}
|
||||
|
||||
// make sure that all values are fed.
|
||||
|
||||
for(std::set<std::string>::const_iterator it(unused_vals.begin());it!=unused_vals.end();++it)
|
||||
_points[*it].push_back(std::make_pair(ms,0)) ;
|
||||
|
||||
// remove empty lists
|
||||
|
||||
for(std::map<std::string,std::list<std::pair<qint64,float> > >::iterator it=_points.begin();it!=_points.end();)
|
||||
@ -122,7 +158,7 @@ void BWGraphSource::convertTrafficClueToValues(const std::list<RSTrafficClue>& l
|
||||
|
||||
for(uint32_t i=0;i<256;++i)
|
||||
if(clue_per_sub_id[i].count > 0)
|
||||
vals[QString::number(i,16).toStdString()] = (_current_unit == UNIT_KILOBYTES)?(clue_per_sub_id[i].size/1000.0f):(clue_per_sub_id[i].count) ;
|
||||
vals["item #"+QString::number(i,16).toStdString()] = (_current_unit == UNIT_KILOBYTES)?(clue_per_sub_id[i].size):(clue_per_sub_id[i].count) ;
|
||||
}
|
||||
break ;
|
||||
|
||||
@ -135,7 +171,7 @@ void BWGraphSource::convertTrafficClueToValues(const std::list<RSTrafficClue>& l
|
||||
clue_per_id[it->service_id] += *it ;
|
||||
|
||||
for(std::map<uint16_t,RSTrafficClue>::const_iterator it(clue_per_id.begin());it!=clue_per_id.end();++it)
|
||||
vals[QString::number(it->first,16).toStdString()] = (_current_unit == UNIT_KILOBYTES)?(it->second.size/1000.0f):(it->second.count) ;
|
||||
vals[mServiceInfoMap[it->first].mServiceName] = (_current_unit == UNIT_KILOBYTES)?(it->second.size):(it->second.count) ;
|
||||
}
|
||||
break ;
|
||||
case GRAPH_TYPE_SUM: // single friend, sum services => one curve
|
||||
@ -147,7 +183,7 @@ void BWGraphSource::convertTrafficClueToValues(const std::list<RSTrafficClue>& l
|
||||
if(it->peer_id == _current_selected_friend)
|
||||
total += *it ;
|
||||
|
||||
vals[_current_selected_friend_name] = (_current_unit == UNIT_KILOBYTES)?(total.size/1000.0f):(total.count) ;
|
||||
vals[visibleFriendName(_current_selected_friend)] = (_current_unit == UNIT_KILOBYTES)?(total.size):(total.count) ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
@ -164,7 +200,7 @@ void BWGraphSource::convertTrafficClueToValues(const std::list<RSTrafficClue>& l
|
||||
clue_per_peer_id[it->peer_id] += *it ;
|
||||
|
||||
for(std::map<RsPeerId,RSTrafficClue>::const_iterator it(clue_per_peer_id.begin());it!=clue_per_peer_id.end();++it)
|
||||
vals[it->first.toStdString()] = (_current_unit == UNIT_KILOBYTES)?(it->second.size/1000.0f):(it->second.count) ;
|
||||
vals[visibleFriendName(it->first)] = (_current_unit == UNIT_KILOBYTES)?(it->second.size):(it->second.count) ;
|
||||
}
|
||||
break ;
|
||||
|
||||
@ -178,7 +214,7 @@ void BWGraphSource::convertTrafficClueToValues(const std::list<RSTrafficClue>& l
|
||||
clue_per_peer_id[it->peer_id] += *it;
|
||||
|
||||
for(std::map<RsPeerId,RSTrafficClue>::const_iterator it(clue_per_peer_id.begin());it!=clue_per_peer_id.end();++it)
|
||||
vals[it->first.toStdString()] = (_current_unit == UNIT_KILOBYTES)?(it->second.size/1000.0f):(it->second.count) ;
|
||||
vals[visibleFriendName(it->first)] = (_current_unit == UNIT_KILOBYTES)?(it->second.size):(it->second.count) ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
@ -197,7 +233,7 @@ void BWGraphSource::convertTrafficClueToValues(const std::list<RSTrafficClue>& l
|
||||
|
||||
for(uint32_t i=0;i<256;++i)
|
||||
if(clue_per_sub_id[i].count > 0)
|
||||
vals[QString::number(i,16).toStdString()] = (_current_unit == UNIT_KILOBYTES)?(clue_per_sub_id[i].size/1000.0f):(clue_per_sub_id[i].count) ;
|
||||
vals["item #"+QString::number(i,16).toStdString()] = (_current_unit == UNIT_KILOBYTES)?(clue_per_sub_id[i].size):(clue_per_sub_id[i].count) ;
|
||||
}
|
||||
break ;
|
||||
|
||||
@ -209,7 +245,7 @@ void BWGraphSource::convertTrafficClueToValues(const std::list<RSTrafficClue>& l
|
||||
clue_per_service[it->service_id] += *it;
|
||||
|
||||
for(std::map<uint16_t,RSTrafficClue>::const_iterator it(clue_per_service.begin());it!=clue_per_service.end();++it)
|
||||
vals[QString::number(it->first,16).toStdString()] = (_current_unit == UNIT_KILOBYTES)?(it->second.size/1000.0f):(it->second.count) ;
|
||||
vals[mServiceInfoMap[it->first].mServiceName] = (_current_unit == UNIT_KILOBYTES)?(it->second.size):(it->second.count) ;
|
||||
}
|
||||
break ;
|
||||
|
||||
@ -220,7 +256,7 @@ void BWGraphSource::convertTrafficClueToValues(const std::list<RSTrafficClue>& l
|
||||
for(std::list<RSTrafficClue>::const_iterator it(lst.begin());it!=lst.end();++it)
|
||||
total += *it;
|
||||
|
||||
vals[QString("Total").toStdString()] = (_current_unit == UNIT_KILOBYTES)?(total.size/1000.0f):(total.count) ;
|
||||
vals[QString("Total").toStdString()] = (_current_unit == UNIT_KILOBYTES)?(total.size):(total.count) ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
@ -228,6 +264,16 @@ void BWGraphSource::convertTrafficClueToValues(const std::list<RSTrafficClue>& l
|
||||
}
|
||||
}
|
||||
|
||||
std::string BWGraphSource::visibleFriendName(const RsPeerId& pid) const
|
||||
{
|
||||
std::map<RsPeerId,std::string>::const_iterator it = mVisibleFriends.find(pid) ;
|
||||
|
||||
if(it != mVisibleFriends.end())
|
||||
return it->second;
|
||||
else
|
||||
return std::string("[unknown]") ;
|
||||
}
|
||||
|
||||
BWGraphSource::BWGraphSource()
|
||||
: RSGraphSource()
|
||||
{
|
||||
@ -243,6 +289,11 @@ BWGraphSource::BWGraphSource()
|
||||
_current_unit = UNIT_KILOBYTES;
|
||||
_current_direction = DIRECTION_UP;
|
||||
|
||||
RsPeerServiceInfo rspsi ;
|
||||
rsServiceControl->getOwnServices(rspsi) ;
|
||||
|
||||
for(std::map<uint32_t,RsServiceInfo>::const_iterator it(rspsi.mServiceList.begin());it!=rspsi.mServiceList.end();++it)
|
||||
mServiceInfoMap[ (it->first >> 8) & 0xffff ] = it->second ;
|
||||
}
|
||||
|
||||
void BWGraphSource::getValues(std::map<std::string,float>& values) const
|
||||
@ -259,6 +310,27 @@ void BWGraphSource::getValues(std::map<std::string,float>& values) const
|
||||
|
||||
QString BWGraphSource::unitName() const { return (_current_unit == UNIT_KILOBYTES)?tr("KB/s"):QString(); }
|
||||
|
||||
//QString BWGraphSource::displayName(int i) const
|
||||
//{
|
||||
// int n=0;
|
||||
// for(std::map<std::string,std::list<std::pair<qint64,float> > >::const_iterator it = _points.begin();it!=_points.end() ;++it)
|
||||
// if(n++ == i)
|
||||
// {
|
||||
// // find out what is displayed
|
||||
//
|
||||
// if(_service_graph_type == GRAPH_TYPE_SINGLE )
|
||||
// if(_friend_graph_type != GRAPH_TYPE_ALL)
|
||||
// return QString::fromStdString(it->first) ;// sub item
|
||||
// else
|
||||
// return QString::fromStdString(mVisibleFriends[RsPeerId(it->first)]) ;// peer id item
|
||||
// else
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// return QString("[error]");
|
||||
//}
|
||||
|
||||
QString BWGraphSource::displayValue(float v) const
|
||||
{
|
||||
if(_current_unit == UNIT_KILOBYTES)
|
||||
@ -285,10 +357,7 @@ QString BWGraphSource::displayValue(float v) const
|
||||
|
||||
QString BWGraphSource::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) ;
|
||||
return RSGraphSource::legend(i,v) ;//+ " Total: " + niceNumber(_total_recv) ;
|
||||
}
|
||||
QString BWGraphSource::niceNumber(float v) const
|
||||
{
|
||||
@ -304,7 +373,9 @@ QString BWGraphSource::niceNumber(float v) const
|
||||
|
||||
void BWGraphSource::setSelector(int selector_type,int graph_type,const std::string& selector_client_string)
|
||||
{
|
||||
#ifdef BWGRAPH_DEBUG
|
||||
std::cerr << "Setting Graph Source selector to " << selector_type << " - " << graph_type << " - " << selector_client_string << std::endl;
|
||||
#endif
|
||||
|
||||
bool changed = false ;
|
||||
|
||||
@ -382,27 +453,42 @@ void BWGraphSource::setDirection(int dir)
|
||||
}
|
||||
void BWGraphSource::recomputeCurrentCurves()
|
||||
{
|
||||
#ifdef BWGRAPH_DEBUG
|
||||
std::cerr << "BWGraphSource: recomputing current curves." << std::endl;
|
||||
#endif
|
||||
|
||||
_points.clear() ;
|
||||
|
||||
// now, convert data to current curve points.
|
||||
|
||||
std::set<std::string> used_values_ref ;
|
||||
|
||||
for(std::list<TrafficHistoryChunk>::const_iterator it(mTrafficHistory.begin());it!=mTrafficHistory.end();++it)
|
||||
{
|
||||
std::map<std::string,float> vals ;
|
||||
qint64 ms = (*it).time_stamp ;
|
||||
|
||||
std::set<std::string> unused_values = used_values_ref ;
|
||||
|
||||
if(_current_direction==DIRECTION_UP)
|
||||
convertTrafficClueToValues((*it).out_rstcl,vals) ;
|
||||
else
|
||||
convertTrafficClueToValues((*it).in_rstcl,vals) ;
|
||||
|
||||
for(std::map<std::string,float>::iterator it2=vals.begin();it2!=vals.end();++it2)
|
||||
{
|
||||
_points[it2->first].push_back(std::make_pair(ms,it2->second)) ;
|
||||
used_values_ref.insert(it2->first) ;
|
||||
unused_values.erase(it2->first) ;
|
||||
}
|
||||
|
||||
for(std::set<std::string>::const_iterator it(unused_values.begin());it!=unused_values.end();++it)
|
||||
_points[*it].push_back(std::make_pair(ms,0)) ;
|
||||
}
|
||||
|
||||
#ifdef BWGRAPH_DEBUG
|
||||
std::cerr << " points() contains " << _points.size() << " curves." << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
BWGraph::BWGraph(QWidget *parent) : RSGraphWidget(parent)
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "retroshare/rsconfig.h"
|
||||
#include "retroshare/rsservicecontrol.h"
|
||||
#include <gui/common/RSGraphWidget.h>
|
||||
|
||||
class BWGraphSource: public RSGraphSource
|
||||
@ -24,6 +25,7 @@ public:
|
||||
|
||||
virtual void getValues(std::map<std::string,float>& values) const;
|
||||
virtual QString displayValue(float v) const;
|
||||
// virtual QString displayName(int i) const;
|
||||
virtual QString legend(int i,float v) const;
|
||||
virtual void update();
|
||||
QString unitName() const ;
|
||||
@ -39,12 +41,13 @@ public:
|
||||
int friendGraphType() const { return _friend_graph_type ;}
|
||||
int serviceGraphType() const { return _service_graph_type ;}
|
||||
|
||||
const std::set<RsPeerId>& visibleFriends() const { return mVisibleFriends; }
|
||||
const std::map<RsPeerId,std::string>& visibleFriends() const { return mVisibleFriends; }
|
||||
const std::set<uint16_t>& visibleServices() const { return mVisibleServices; }
|
||||
|
||||
protected:
|
||||
void convertTrafficClueToValues(const std::list<RSTrafficClue> &lst, std::map<std::string, float> &vals) const;
|
||||
void recomputeCurrentCurves() ;
|
||||
std::string visibleFriendName(const RsPeerId &pid) const ;
|
||||
|
||||
private:
|
||||
QString niceNumber(float v) const;
|
||||
@ -56,15 +59,16 @@ private:
|
||||
int _service_graph_type ;
|
||||
|
||||
RsPeerId _current_selected_friend ;
|
||||
std::string _current_selected_friend_name ;
|
||||
uint16_t _current_selected_service ;
|
||||
int _current_unit ;
|
||||
int _current_direction ;
|
||||
|
||||
std::list<TrafficHistoryChunk> mTrafficHistory ;
|
||||
|
||||
std::set<RsPeerId> mVisibleFriends ;
|
||||
std::map<RsPeerId,std::string> mVisibleFriends ;
|
||||
std::set<uint16_t> mVisibleServices ;
|
||||
|
||||
mutable std::map<uint16_t,RsServiceInfo> mServiceInfoMap ;
|
||||
};
|
||||
|
||||
class BWGraph: public RSGraphWidget
|
||||
@ -74,7 +78,7 @@ class BWGraph: public RSGraphWidget
|
||||
|
||||
BWGraphSource *source() ;
|
||||
|
||||
const std::set<RsPeerId>& visibleFriends() const { return _local_source->visibleFriends(); }
|
||||
const std::map<RsPeerId,std::string>& visibleFriends() const { return _local_source->visibleFriends(); }
|
||||
const std::set<uint16_t>& visibleServices() const { return _local_source->visibleServices(); }
|
||||
protected:
|
||||
BWGraphSource *_local_source ;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "retroshare/rsservicecontrol.h"
|
||||
#include "util/RsProtectedTimer.h"
|
||||
#include "retroshare-gui/RsAutoUpdatePage.h"
|
||||
#include "BandwidthStatsWidget.h"
|
||||
@ -52,23 +53,23 @@ void BandwidthStatsWidget::updateComboBoxes()
|
||||
// Setup button/combobox info
|
||||
|
||||
uint32_t indx = 2 ;
|
||||
RsPeerDetails details ;
|
||||
//RsPeerDetails details ;
|
||||
RsPeerId current_friend_id(ui.friend_CB->itemData(ui.friend_CB->currentIndex()).toString().toStdString()) ;
|
||||
|
||||
for(std::set<RsPeerId>::const_iterator it(ui.bwgraph_BW->visibleFriends().begin());it!=ui.bwgraph_BW->visibleFriends().end();++it)
|
||||
for(std::map<RsPeerId,std::string>::const_iterator it(ui.bwgraph_BW->visibleFriends().begin());it!=ui.bwgraph_BW->visibleFriends().end();++it)
|
||||
{
|
||||
if( (*it).toStdString() != ui.friend_CB->itemData(indx).toString().toStdString())
|
||||
if( it->first.toStdString() != ui.friend_CB->itemData(indx).toString().toStdString())
|
||||
{
|
||||
std::cerr << " friends: " << *it << " not in combo at place " << indx << ". Adding it." << std::endl;
|
||||
std::cerr << " friends: " << it->first << " not in combo at place " << indx << ". Adding it." << std::endl;
|
||||
|
||||
QString name = "[Unknown]" ;
|
||||
QString name = QString::fromUtf8(it->second.c_str()) ;
|
||||
QVariant data ;
|
||||
|
||||
if(rsPeers->getPeerDetails(*it,details))
|
||||
{
|
||||
name = QString::fromUtf8(details.name.c_str())+" ("+QString::fromUtf8(details.location.c_str())+")" ;
|
||||
data = QVariant(QString::fromStdString( (*it).toStdString())) ;
|
||||
}
|
||||
//if(rsPeers->getPeerDetails(*it,details))
|
||||
//{
|
||||
// name = QString::fromUtf8(details.name.c_str())+" ("+QString::fromUtf8(details.location.c_str())+")" ;
|
||||
data = QVariant(QString::fromStdString( (it->first).toStdString())) ;
|
||||
//}
|
||||
|
||||
if(ui.friend_CB->count() <= indx)
|
||||
ui.friend_CB->addItem(name,data) ;
|
||||
@ -78,7 +79,7 @@ void BandwidthStatsWidget::updateComboBoxes()
|
||||
ui.friend_CB->setItemData(indx,data) ;
|
||||
}
|
||||
|
||||
if(current_friend_id == *it && ui.friend_CB->currentIndex() != indx)
|
||||
if(current_friend_id == it->first && ui.friend_CB->currentIndex() != indx)
|
||||
ui.friend_CB->setCurrentIndex(indx) ;
|
||||
}
|
||||
++indx ;
|
||||
@ -92,6 +93,9 @@ void BandwidthStatsWidget::updateComboBoxes()
|
||||
|
||||
// now one entry per service
|
||||
|
||||
RsPeerServiceInfo service_info_map ;
|
||||
rsServiceControl->getOwnServices(service_info_map) ;
|
||||
|
||||
indx = 2 ;
|
||||
uint16_t current_service_id = ui.service_CB->itemData(ui.service_CB->currentIndex()).toInt() ;
|
||||
|
||||
@ -99,13 +103,13 @@ void BandwidthStatsWidget::updateComboBoxes()
|
||||
{
|
||||
if(*it != ui.service_CB->itemData(indx).toInt())
|
||||
{
|
||||
std::cerr << " services: " << std::hex << *it << std::dec << " not in combo at place " << indx << ". Adding it." << std::endl;
|
||||
QString sname = QString::fromUtf8(service_info_map.mServiceList[ ((*it)<<8) + 0x02000000].mServiceName.c_str()) ;
|
||||
|
||||
if(ui.service_CB->count() <= indx)
|
||||
ui.service_CB->addItem(QString::number(*it,16),QVariant(*it)) ;
|
||||
ui.service_CB->addItem(sname + " (0x"+QString::number(*it,16)+")",QVariant(*it)) ;
|
||||
else
|
||||
{
|
||||
ui.service_CB->setItemText(indx,QString::number(*it,16)) ;
|
||||
ui.service_CB->setItemText(indx,sname + " (0x"+QString::number(*it,16)+")") ;
|
||||
ui.service_CB->setItemData(indx,QVariant(*it)) ;
|
||||
}
|
||||
|
||||
|
@ -220,11 +220,6 @@ void BwCtrlWindow::updateDisplay()
|
||||
}
|
||||
|
||||
updateBandwidth();
|
||||
|
||||
OutQueueStatistics stats ;
|
||||
rsConfig->getOutQueueStatistics(stats) ;
|
||||
|
||||
//_outqueue_stats_W->updateStatistics(stats) ;
|
||||
}
|
||||
|
||||
void BwCtrlWindow::updateBandwidth()
|
||||
|
@ -35,7 +35,7 @@ static QString serviceName(uint16_t s)
|
||||
case /* RS_SERVICE_TYPE_BWCTRL */ 0x0021: return QString("BdwCtrl") ;
|
||||
case /* RS_SERVICE_TYPE_BANLIST */ 0x0101: return QString("BanList") ;
|
||||
case /* RS_SERVICE_TYPE_STATUS */ 0x0102: return QString("Status") ;
|
||||
case /* RS_SERVICE_TYPE_NXS */ 0x0200: return QString("Nxs") ;
|
||||
case /* RS_SERVICE_TYPE_NXS */ 0x0200: return QString("Nxs") ;
|
||||
case /* RS_SERVICE_GXS_TYPE_GXSID */ 0x0211: return QString("Gxs Ids") ;
|
||||
case /* RS_SERVICE_GXS_TYPE_PHOTO */ 0x0212: return QString("Gxs Photo") ;
|
||||
case /* RS_SERVICE_GXS_TYPE_WIKI */ 0x0213: return QString("Gxs Wiki") ;
|
||||
|
@ -363,7 +363,6 @@ HEADERS += rshare.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 \
|
||||
@ -892,7 +891,6 @@ SOURCES += main.cpp \
|
||||
gui/statistics/TurtleRouterDialog.cpp \
|
||||
gui/statistics/TurtleRouterStatistics.cpp \
|
||||
gui/statistics/GlobalRouterStatistics.cpp \
|
||||
gui/statistics/OutQueueStatistics.cpp \
|
||||
gui/statistics/StatisticsWindow.cpp \
|
||||
gui/statistics/BwCtrlWindow.cpp \
|
||||
gui/statistics/RttStatistics.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user