From ea5b9234287a1408d28bbe82b54c0111035889c1 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 31 Oct 2014 21:24:42 +0000 Subject: [PATCH] added very basic display of outqueue statistics in BwCtrlWindow. Removed unnecessary list::size() calls in pqistreamer git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7652 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/pqi_base.h | 1 + libretroshare/src/pqi/pqihandler.cc | 46 +++++++- libretroshare/src/pqi/pqihandler.h | 2 + libretroshare/src/pqi/pqiperson.cc | 8 ++ libretroshare/src/pqi/pqiperson.h | 2 + libretroshare/src/pqi/pqiqos.cc | 25 ++++ libretroshare/src/pqi/pqiqos.h | 24 +++- libretroshare/src/pqi/pqiqosstreamer.cc | 5 + libretroshare/src/pqi/pqiqosstreamer.h | 4 +- libretroshare/src/pqi/pqistreamer.cc | 43 +++++-- libretroshare/src/pqi/pqistreamer.h | 6 +- libretroshare/src/retroshare/rsconfig.h | 8 +- libretroshare/src/rsserver/p3serverconfig.cc | 8 +- libretroshare/src/rsserver/p3serverconfig.h | 1 + libretroshare/src/services/p3bwctrl.cc | 5 + libretroshare/src/services/p3bwctrl.h | 1 + .../src/gui/statistics/BwCtrlWindow.cpp | 7 +- .../src/gui/statistics/BwCtrlWindow.ui | 46 +++++--- .../src/gui/statistics/OutQueueStatistics.cpp | 109 ++++++++++++++++++ .../src/gui/statistics/OutQueueStatistics.h | 22 ++++ retroshare-gui/src/retroshare-gui.pro | 20 ++-- 21 files changed, 345 insertions(+), 48 deletions(-) create mode 100644 retroshare-gui/src/gui/statistics/OutQueueStatistics.cpp create mode 100644 retroshare-gui/src/gui/statistics/OutQueueStatistics.h diff --git a/libretroshare/src/pqi/pqi_base.h b/libretroshare/src/pqi/pqi_base.h index b0d9eceb8..aaed4a77c 100644 --- a/libretroshare/src/pqi/pqi_base.h +++ b/libretroshare/src/pqi/pqi_base.h @@ -91,6 +91,7 @@ virtual void getRates(RsBwRates &rates) return; } + virtual int gatherOutQueueStatistics(std::vector& per_service_count,std::vector& per_priority_count) { return 0;} virtual int getQueueSize(bool /* in */) { return 0;} virtual float getRate(bool in) { diff --git a/libretroshare/src/pqi/pqihandler.cc b/libretroshare/src/pqi/pqihandler.cc index 16ea9d387..133f5ae34 100644 --- a/libretroshare/src/pqi/pqihandler.cc +++ b/libretroshare/src/pqi/pqihandler.cc @@ -88,7 +88,27 @@ int pqihandler::tick() #endif moreToTick = 1; } - } + } + +// static time_t last_print_time = 0 ; +// time_t now = time(NULL) ; +// if(now > last_print_time + 3) +// { +// std::map per_service_count ; +// std::vector per_priority_count ; +// +// ExtractOutQueueStatistics(per_service_count,per_priority_count) ; +// +// std::cerr << "PQIHandler outqueues: " << std::endl; +// +// for(std::map::const_iterator it=per_service_count.begin();it!=per_service_count.end();++it) +// std::cerr << " " << std::hex << it->first << std::dec << " " << it->second << std::endl; +// +// for(int i=0;i pqi) -> GetItem()) != NULL) { + static int ntimes =0 ; + if(++ntimes < 20) + { std::cerr << "pqihandler::locked_GetItems() pqi->GetItem()"; std::cerr << " should never happen anymore!"; std::cerr << std::endl; + } #ifdef RSITEM_DEBUG std::string out; @@ -427,6 +451,26 @@ 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 item_counts(65536,0) ; + stats.per_priority_item_count.clear() ; + stats.per_priority_item_count.resize(10,0) ; + + std::map::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 ; +} + // NEW extern fn to extract rates. int pqihandler::ExtractRates(std::map &ratemap, RsBwRates &total) { diff --git a/libretroshare/src/pqi/pqihandler.h b/libretroshare/src/pqi/pqihandler.h index bc5043738..ffa5a3156 100644 --- a/libretroshare/src/pqi/pqihandler.h +++ b/libretroshare/src/pqi/pqihandler.h @@ -32,6 +32,7 @@ #include "util/rsthreads.h" #include "retroshare/rstypes.h" +#include "retroshare/rsconfig.h" #include #include @@ -77,6 +78,7 @@ class pqihandler: public P3Interface, public pqiPublisher // TESTING INTERFACE. int ExtractRates(std::map &ratemap, RsBwRates &totals); + int ExtractOutQueueStatistics(OutQueueStatistics& stats) ; protected: /* check to be overloaded by those that can diff --git a/libretroshare/src/pqi/pqiperson.cc b/libretroshare/src/pqi/pqiperson.cc index 0971cb370..eab8753f0 100644 --- a/libretroshare/src/pqi/pqiperson.cc +++ b/libretroshare/src/pqi/pqiperson.cc @@ -573,7 +573,15 @@ void pqiperson::getRates(RsBwRates &rates) return; activepqi -> getRates(rates); } +int pqiperson::gatherOutQueueStatistics(std::vector& per_service,std::vector& 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::getQueueSize(bool in) { RsStackMutex stack(mPersonMtx); /**** LOCK MUTEX ****/ diff --git a/libretroshare/src/pqi/pqiperson.h b/libretroshare/src/pqi/pqiperson.h index fe4bd0700..e84646d48 100644 --- a/libretroshare/src/pqi/pqiperson.h +++ b/libretroshare/src/pqi/pqiperson.h @@ -170,6 +170,8 @@ 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& per_service,std::vector& per_priority); + private: diff --git a/libretroshare/src/pqi/pqiqos.cc b/libretroshare/src/pqi/pqiqos.cc index ef8e3448e..e3377fea1 100644 --- a/libretroshare/src/pqi/pqiqos.cc +++ b/libretroshare/src/pqi/pqiqos.cc @@ -2,6 +2,7 @@ #include #include #include +#include #include "pqiqos.h" @@ -55,6 +56,30 @@ void pqiQoS::in_rsItem(void *ptr,int priority) ++_nb_items ; } +int pqiQoS::gatherStatistics(std::vector& per_service_count,std::vector& per_priority_count) const +{ + assert(per_priority_count.size() == 10) ; + assert(per_service_count.size() == 65536) ; + + for(uint32_t i=0;i<_item_queues.size();++i) + { + per_priority_count[i] += _item_queues[i].size() ; + + for(std::list::const_iterator it(_item_queues[i]._items.begin());it!=_item_queues[i]._items.end();++it) + { + uint32_t type = 0; + uint32_t offset = 0; + getRawUInt32((uint8_t*)(*it), 4, &offset, &type); + + uint16_t service_id = (type >> 8) & 0xffff ; + + ++per_service_count[service_id] ; + } + } + return 1 ; +} + + void *pqiQoS::out_rsItem() { // Go through the queues. Increment counters. diff --git a/libretroshare/src/pqi/pqiqos.h b/libretroshare/src/pqi/pqiqos.h index 3eaa4e863..a902501b8 100644 --- a/libretroshare/src/pqi/pqiqos.h +++ b/libretroshare/src/pqi/pqiqos.h @@ -46,26 +46,35 @@ class pqiQoS class ItemQueue { - public: + public: + ItemQueue() + { + _item_count =0 ; + } void *pop() { if(_items.empty()) return NULL ; void *item = _items.front() ; - _items.pop_front() ; + _items.pop_front() ; + --_item_count ; return item ; } void push(void *item) { - _items.push_back(item) ; - } + _items.push_back(item) ; + ++_item_count ; + } + + uint32_t size() const { return _item_count ; } float _threshold ; float _counter ; - float _inc ; + float _inc ; + uint32_t _item_count ; std::list _items ; }; @@ -83,6 +92,11 @@ class pqiQoS // kills all waiting items. void clear() ; + // get some stats about what's going on. service_packets will contain the number of + // packets per service, and queue_sizes will contain the size of the different priority queues. + + int gatherStatistics(std::vector& per_service_count,std::vector& per_priority_count) const ; + void computeTotalItemSize() const ; int debug_computeTotalItemSize() const ; private: diff --git a/libretroshare/src/pqi/pqiqosstreamer.cc b/libretroshare/src/pqi/pqiqosstreamer.cc index d7797a7ee..7f46fbef9 100644 --- a/libretroshare/src/pqi/pqiqosstreamer.cc +++ b/libretroshare/src/pqi/pqiqosstreamer.cc @@ -43,6 +43,11 @@ int pqiQoSstreamer::getQueueSize(bool in) } } +int pqiQoSstreamer::locked_gatherStatistics(std::vector& per_service_count,std::vector& per_priority_count) const // extracting data. +{ + return pqiQoS::gatherStatistics(per_service_count,per_priority_count) ; +} + void pqiQoSstreamer::locked_storeInOutputQueue(void *ptr,int priority) { _total_item_size += getRsItemSize(ptr) ; diff --git a/libretroshare/src/pqi/pqiqosstreamer.h b/libretroshare/src/pqi/pqiqosstreamer.h index 3ae09a202..c4ba734f0 100644 --- a/libretroshare/src/pqi/pqiqosstreamer.h +++ b/libretroshare/src/pqi/pqiqosstreamer.h @@ -40,7 +40,9 @@ class pqiQoSstreamer: public pqithreadstreamer, public pqiQoS virtual int locked_out_queue_size() const { return _total_item_count ; } virtual void locked_clear_out_queue() ; virtual int locked_compute_out_pkt_size() const { return _total_item_size ; } - virtual void *locked_pop_out_data() ; + virtual void *locked_pop_out_data() ; + virtual int locked_gatherStatistics(std::vector& per_service_count,std::vector& per_priority_count) const; // extracting data. + virtual int getQueueSize(bool in) ; diff --git a/libretroshare/src/pqi/pqistreamer.cc b/libretroshare/src/pqi/pqistreamer.cc index dc1d438a7..d39ab4b77 100644 --- a/libretroshare/src/pqi/pqistreamer.cc +++ b/libretroshare/src/pqi/pqistreamer.cc @@ -61,7 +61,8 @@ pqistreamer::pqistreamer(RsSerialiser *rss, const RsPeerId& id, BinInterface *bi { RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/ - mAvgLastUpdate = mCurrReadTS = mCurrSentTS = time(NULL); + mAvgLastUpdate = mCurrReadTS = mCurrSentTS = time(NULL); + mIncomingSize = 0 ; /* allocated once */ mPkt_rpend_size = getRsPktMaxSize(); @@ -123,12 +124,16 @@ pqistreamer::~pqistreamer() free(mPkt_rpending); // clean up incoming. - while(mIncoming.size() > 0) + while(!mIncoming.empty()) { RsItem *i = mIncoming.front(); - mIncoming.pop_front(); + mIncoming.pop_front(); + --mIncomingSize ; delete i; - } + } + + if(mIncomingSize != 0) + std::cerr << "(EE) inconsistency after deleting pqistreamer queue. Remaining items: " << mIncomingSize << std::endl; return; } @@ -162,7 +167,8 @@ RsItem *pqistreamer::GetItem() return NULL; RsItem *osr = mIncoming.front() ; - mIncoming.pop_front() ; + mIncoming.pop_front() ; + --mIncomingSize; return osr; } @@ -211,7 +217,7 @@ int pqistreamer::tick() int total = locked_compute_out_pkt_size() ; rs_sprintf_append(out, "\t Out Packets [%d] => %d bytes\n", locked_out_queue_size(), total); - rs_sprintf_append(out, "\t Incoming [%d]\n", mIncoming.size()); + rs_sprintf_append(out, "\t Incoming [%d]\n", mIncomingSize); } pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out); @@ -219,7 +225,7 @@ int pqistreamer::tick() #endif /* if there is more stuff in the queues */ - if ((mIncoming.size() > 0) || (locked_out_queue_size() > 0)) + if ((!mIncoming.empty()) || (locked_out_queue_size() > 0)) { return 1; } @@ -349,7 +355,8 @@ int pqistreamer::handleincomingitem_locked(RsItem *pqi) // Use overloaded Contact function pqi -> PeerId(PeerId()); - mIncoming.push_back(pqi); + mIncoming.push_back(pqi); + ++mIncomingSize ; return 1; } @@ -953,13 +960,21 @@ void pqistreamer::inReadBytes_locked(int inb) return; } +int pqistreamer::gatherOutQueueStatistics(std::vector& per_service_count,std::vector& per_priority_count) +{ + RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/ + + return locked_gatherStatistics(per_service_count,per_priority_count); +} + int pqistreamer::getQueueSize(bool in) { RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/ if (in) - return mIncoming.size(); - return locked_out_queue_size(); + return mIncomingSize; + else + return locked_out_queue_size(); } void pqistreamer::getRates(RsBwRates &rates) @@ -968,7 +983,7 @@ void pqistreamer::getRates(RsBwRates &rates) RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/ - rates.mQueueIn = mIncoming.size(); + rates.mQueueIn = mIncomingSize; rates.mQueueOut = locked_out_queue_size(); } @@ -1005,6 +1020,12 @@ int pqistreamer::locked_compute_out_pkt_size() const return total ; } +int pqistreamer::locked_gatherStatistics(std::vector&,std::vector&) const +{ + std::cerr << "(II) called overloaded function locked_gatherStatistics(). This is probably an error" << std::endl; + return 1 ; +} + void *pqistreamer::locked_pop_out_data() { void *res = NULL ; diff --git a/libretroshare/src/pqi/pqistreamer.h b/libretroshare/src/pqi/pqistreamer.h index b957f7de4..589d5de7c 100644 --- a/libretroshare/src/pqi/pqistreamer.h +++ b/libretroshare/src/pqi/pqistreamer.h @@ -62,7 +62,8 @@ 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. - protected: + virtual int gatherOutQueueStatistics(std::vector& per_service_count,std::vector& per_priority_count); // extracting data. + protected: int tick_bio(); int tick_send(uint32_t timeout); @@ -77,6 +78,7 @@ class pqistreamer: public PQInterface virtual void locked_clear_out_queue() ; virtual int locked_compute_out_pkt_size() const ; virtual void *locked_pop_out_data() ; + virtual int locked_gatherStatistics(std::vector& per_service_count,std::vector& per_priority_count) const; // extracting data. protected: @@ -123,6 +125,8 @@ class pqistreamer: public PQInterface std::list mOutPkts; // Cntrl / Search / Results queue std::list mIncoming; + uint32_t mIncomingSize; // size of mIncoming. To avoid calling linear cost std::list::size() + // data for network stats. int mTotalRead; int mTotalSent; diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index 1a5eca28d..21d4bdbf2 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -171,6 +171,12 @@ class RsConfigDataRates int mQueueOut; }; +class OutQueueStatistics +{ + public: + std::map per_service_item_count ; + std::vector per_priority_item_count ; +}; class RsConfigNetStatus { @@ -240,7 +246,7 @@ virtual int getConfigNetStatus(RsConfigNetStatus &status) = 0; virtual int getTotalBandwidthRates(RsConfigDataRates &rates) = 0; virtual int getAllBandwidthRates(std::map &ratemap) = 0; - +virtual int getOutQueueStatistics(OutQueueStatistics& stats) = 0 ; /* From RsInit */ // NOT IMPLEMENTED YET! diff --git a/libretroshare/src/rsserver/p3serverconfig.cc b/libretroshare/src/rsserver/p3serverconfig.cc index c535e68d0..8148578e6 100644 --- a/libretroshare/src/rsserver/p3serverconfig.cc +++ b/libretroshare/src/rsserver/p3serverconfig.cc @@ -205,7 +205,13 @@ 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 &ratemap) { if (rsBandwidthControl) diff --git a/libretroshare/src/rsserver/p3serverconfig.h b/libretroshare/src/rsserver/p3serverconfig.h index 530fcd009..11f73b4ec 100644 --- a/libretroshare/src/rsserver/p3serverconfig.h +++ b/libretroshare/src/rsserver/p3serverconfig.h @@ -58,6 +58,7 @@ virtual int getConfigStartup(RsConfigStartup ¶ms); virtual int getTotalBandwidthRates(RsConfigDataRates &rates); virtual int getAllBandwidthRates(std::map &ratemap); + virtual int getOutQueueStatistics(OutQueueStatistics& stats) ; /* From RsInit */ diff --git a/libretroshare/src/services/p3bwctrl.cc b/libretroshare/src/services/p3bwctrl.cc index 100b3446a..5b7a0a786 100644 --- a/libretroshare/src/services/p3bwctrl.cc +++ b/libretroshare/src/services/p3bwctrl.cc @@ -280,6 +280,11 @@ int p3BandwidthControl::getAllBandwidthRates(std::mapExtractOutQueueStatistics(stats) ; +} + diff --git a/libretroshare/src/services/p3bwctrl.h b/libretroshare/src/services/p3bwctrl.h index 152cbb8a9..de39f6f58 100644 --- a/libretroshare/src/services/p3bwctrl.h +++ b/libretroshare/src/services/p3bwctrl.h @@ -94,6 +94,7 @@ class p3BandwidthControl: public p3Service, public pqiServiceMonitor virtual int getAllBandwidthRates(std::map &ratemap); + virtual int ExtractOutQueueStatistics(OutQueueStatistics& stats) ; /*! * Interface stuff. diff --git a/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp b/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp index 490efee80..c514f9234 100644 --- a/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp +++ b/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp @@ -207,7 +207,12 @@ void BwCtrlWindow::updateDisplay() return; } - updateBandwidth(); + updateBandwidth(); + + OutQueueStatistics stats ; + rsConfig->getOutQueueStatistics(stats) ; + + _outqueue_stats_W->updateStatistics(stats) ; } void BwCtrlWindow::updateBandwidth() diff --git a/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui b/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui index f0d9abc70..d4d26b9cc 100644 --- a/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui +++ b/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui @@ -13,9 +13,9 @@ Form - - - + + + Qt::Vertical @@ -84,21 +84,27 @@ - - - - 120 - 80 - - - - - 10 - - - - Qt::NoContextMenu + + + Qt::Vertical + + + + + 120 + 80 + + + + + 10 + + + + Qt::NoContextMenu + + @@ -111,6 +117,12 @@
gui/statistics/bwgraph.h
1 + + OutQueueStatisticsWidget + QWidget +
gui/statistics/OutQueueStatistics.h
+ 1 +
diff --git a/retroshare-gui/src/gui/statistics/OutQueueStatistics.cpp b/retroshare-gui/src/gui/statistics/OutQueueStatistics.cpp new file mode 100644 index 000000000..d3e464742 --- /dev/null +++ b/retroshare-gui/src/gui/statistics/OutQueueStatistics.cpp @@ -0,0 +1,109 @@ +#include +#include +#include + +#include +#include + +#include +#include "OutQueueStatistics.h" + +OutQueueStatisticsWidget::OutQueueStatisticsWidget(QWidget *parent) + : QWidget(parent) +{ + maxWidth = 200 ; + maxHeight = 0 ; +} + +static QString serviceName(uint16_t s) +{ + switch(s) + { + case /* RS_SERVICE_TYPE_FILE_INDEX */ 0x0001: return QString("File index") ; + case /* RS_SERVICE_TYPE_DISC */ 0x0011: return QString("Disc") ; + case /* RS_SERVICE_TYPE_CHAT */ 0x0012: return QString("Chat") ; + case /* RS_SERVICE_TYPE_MSG */ 0x0013: return QString("Msg") ; + case /* RS_SERVICE_TYPE_TURTLE */ 0x0014: return QString("Turtle") ; + case /* RS_SERVICE_TYPE_TUNNEL */ 0x0015: return QString("Tunnel") ; + case /* RS_SERVICE_TYPE_HEARTBEAT */ 0x0016: return QString("Heart Beat") ; + case /* RS_SERVICE_TYPE_FILE_TRANSFER */ 0x0017: return QString("FT") ; + case /* RS_SERVICE_TYPE_GROUTER */ 0x0018: return QString("GRouter") ; + case /* RS_SERVICE_TYPE_SERVICEINFO */ 0x0020: return QString("Service Info") ; + 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_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") ; + case /* RS_SERVICE_GXS_TYPE_WIRE */ 0x0214: return QString("Gxs Wire") ; + case /* RS_SERVICE_GXS_TYPE_FORUMS */ 0x0215: return QString("Gxs Forums") ; + case /* RS_SERVICE_GXS_TYPE_POSTED */ 0x0216: return QString("Gxs Posted") ; + case /* RS_SERVICE_GXS_TYPE_CHANNELS */ 0x0217: return QString("Gxs Channels") ; + case /* RS_SERVICE_GXS_TYPE_GXSCIRCLE */ 0x0218: return QString("Gxs Circle") ; + case /* RS_SERVICE_GXS_TYPE_REPUTATION */ 0x0219: return QString("Gxs Reput.") ; + case /* RS_SERVICE_TYPE_GXS_RECOGN */ 0x0220: return QString("Gxs Recog.") ; + case /* RS_SERVICE_TYPE_DSDV */ 0x1010: return QString("Dsdv") ; + case /* RS_SERVICE_TYPE_RTT */ 0x1011: return QString("RTT") ; + + default: return QString("Unknown") ; + } +} + +void OutQueueStatisticsWidget::updateStatistics(OutQueueStatistics& stats) +{ + static const int cellx = 6 ; + static const int celly = 10+4 ; + + QPixmap tmppixmap(maxWidth, maxHeight); + tmppixmap.fill(this, 0, 0); + setFixedHeight(maxHeight); + + QPainter painter(&tmppixmap); + painter.initFrom(this); + + maxHeight = 500 ; + + // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; + // draw... + int ox=5,oy=5 ; + + painter.setPen(QColor::fromRgb(70,70,70)) ; + //painter.drawLine(0,oy,maxWidth,oy) ; + //oy += celly ; + + QString by_priority_string,by_service_string ; + + for(int i=1;i::const_iterator it(stats.per_service_item_count.begin());it!=stats.per_service_item_count.end();++it) + by_service_string += QString::number(it->second) + " (" + serviceName(it->first) + ") " ; + + painter.drawText(ox,oy+celly,tr("Outqueue statistics")+":") ; oy += celly*2 ; + painter.drawText(ox+2*cellx,oy+celly,tr("By priority: ") + by_priority_string); oy += celly ; + painter.drawText(ox+2*cellx,oy+celly,tr("By service : ") + by_service_string); oy += celly ; + + oy += celly ; + + // update the pixmap + // + pixmap = tmppixmap; + maxHeight = oy ; +} + +void OutQueueStatisticsWidget::paintEvent(QPaintEvent */*event*/) +{ + QStylePainter(this).drawPixmap(0, 0, pixmap); +} + +void OutQueueStatisticsWidget::resizeEvent(QResizeEvent *event) +{ + QRect TaskGraphRect = geometry(); + maxWidth = TaskGraphRect.width(); + maxHeight = TaskGraphRect.height() ; + + QWidget::resizeEvent(event); + update(); + +} diff --git a/retroshare-gui/src/gui/statistics/OutQueueStatistics.h b/retroshare-gui/src/gui/statistics/OutQueueStatistics.h new file mode 100644 index 000000000..93e571819 --- /dev/null +++ b/retroshare-gui/src/gui/statistics/OutQueueStatistics.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +class OutQueueStatistics ; + +class OutQueueStatisticsWidget: public QWidget +{ + Q_OBJECT + + public: + OutQueueStatisticsWidget(QWidget *parent = NULL) ; + + virtual void paintEvent(QPaintEvent *event) ; + virtual void resizeEvent(QResizeEvent *event); + + void updateStatistics(OutQueueStatistics&) ; + + private: + QPixmap pixmap ; + int maxWidth,maxHeight ; +}; diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 6e9ab3ce2..f978b6868 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -401,7 +401,6 @@ HEADERS += rshare.h \ gui/msgs/MessageUserNotify.h \ gui/images/retroshare_win.rc.h \ gui/settings/rsharesettings.h \ - gui/statistics/GlobalRouterStatistics.h \ gui/settings/RsharePeerSettings.h \ gui/settings/rsettings.h \ gui/settings/rsettingswin.h \ @@ -513,11 +512,13 @@ HEADERS += rshare.h \ gui/connect/ConnectFriendWizard.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/GetStartedDialog.h \ gui/statistics/RttStatistics.h \ + gui/statistics/OutQueueStatistics.h \ # gui/ForumsDialog.h \ # gui/forums/ForumDetails.h \ @@ -542,9 +543,6 @@ FORMS += gui/StartDialog.ui \ gui/QuickStartWizard.ui \ gui/NetworkDialog.ui \ gui/FileTransfer/TransfersDialog.ui \ - gui/statistics/TurtleRouterDialog.ui \ - gui/statistics/TurtleRouterStatistics.ui \ - gui/statistics/GlobalRouterStatistics.ui \ gui/FileTransfer/DetailsDialog.ui \ gui/MainWindow.ui \ gui/NetworkView.ui \ @@ -625,6 +623,9 @@ FORMS += gui/StartDialog.ui \ gui/common/RSFeedWidget.ui \ gui/style/StyleDialog.ui \ gui/statistics/DhtWindow.ui \ + gui/statistics/TurtleRouterDialog.ui \ + gui/statistics/TurtleRouterStatistics.ui \ + gui/statistics/GlobalRouterStatistics.ui \ gui/statistics/StatisticsWindow.ui \ gui/statistics/BwCtrlWindow.ui \ gui/statistics/RttStatistics.ui \ @@ -680,9 +681,6 @@ SOURCES += main.cpp \ gui/FileTransfer/DLListDelegate.cpp \ gui/FileTransfer/ULListDelegate.cpp \ gui/FileTransfer/xprogressbar.cpp \ - gui/statistics/TurtleRouterDialog.cpp \ - gui/statistics/TurtleRouterStatistics.cpp \ - gui/statistics/GlobalRouterStatistics.cpp \ gui/FileTransfer/DetailsDialog.cpp \ gui/FileTransfer/TransferUserNotify.cpp \ gui/MainPage.cpp \ @@ -839,10 +837,14 @@ SOURCES += main.cpp \ gui/connect/ConnectFriendWizard.cpp \ gui/connect/ConnectProgressDialog.cpp \ gui/groups/CreateGroup.cpp \ + gui/GetStartedDialog.cpp \ gui/statistics/DhtWindow.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/GetStartedDialog.cpp \ gui/statistics/RttStatistics.cpp \ # gui/ForumsDialog.cpp \