Changeset 399 in flair-src for trunk/tools/FlairGCS/src


Ignore:
Timestamp:
Mar 16, 2021, 5:50:25 PM (4 years ago)
Author:
Sanahuja Guillaume
Message:

change color of status bar in gcs if high bandwidth usage is detected

Location:
trunk/tools/FlairGCS/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/FlairGCS/src/ConnectionLayout.h

    r269 r399  
    3636
    3737signals:
    38   void UDTStats(QString stats,bool loosingPackets); 
     38  void UDTStats(QString stats,QString stylesheet,bool loosingPackets); 
    3939};
    4040
  • trunk/tools/FlairGCS/src/Manager.cpp

    r269 r399  
    7373  status=new QStatusBar();
    7474  status->setSizeGripEnabled(false);
    75   button_layout->addWidget(status, 1,0);
     75  managerLayout->addWidget(status);
    7676
    7777  UDT::startup();
     
    100100  icon_red = QIcon(":red.png");
    101101  icon_orange = QIcon(":orange.png");
    102  
    103102 
    104103  QTimer *timer = new QTimer(this);
     
    149148 
    150149  ConnectionLayout *newLayout = new ConnectionLayout(udtSocket, name);
    151   connect(udtSocket, SIGNAL(UDTStats(QString,bool)), newLayout, SIGNAL(UDTStats(QString,bool)));//connection in 2 steps to get udtsocket as sender
    152   connect(newLayout, SIGNAL(UDTStats(QString,bool)), this, SLOT(printUDTStats(QString,bool)));
     150  connect(udtSocket, SIGNAL(UDTStats(QString,QString,bool)), newLayout, SIGNAL(UDTStats(QString,QString,bool)));//connection in 2 steps to get udtsocket as sender
     151  connect(newLayout, SIGNAL(UDTStats(QString,QString,bool)), this, SLOT(printUDTStats(QString,QString,bool)));
    153152  connect(udtSocket, SIGNAL(dataReady(char *, int)), newLayout,SLOT(receive(char *, int)),Qt::BlockingQueuedConnection);
    154153  connect(newLayout, SIGNAL(destroyed(QObject *)), this, SLOT(layoutDestroyed(QObject *)));
     
    246245}
    247246
    248 void Manager::printUDTStats(QString stats,bool loosingPackets) {
     247void Manager::printUDTStats(QString stats,QString stylesheet,bool loosingPackets) {
    249248  int index = -1;
    250249  for(int i=0;i<connections.count();i++) {
     
    264263 
    265264  if (tabBar->count() == 0) {
     265    status->setStyleSheet(stylesheet);
    266266    status->showMessage(stats);
    267267  } else if (index==tabBar->currentIndex()) {
     268    status->setStyleSheet(stylesheet);
    268269    status->showMessage(QString("%1: %2").arg(tabBar->tabText(index)).arg(stats));
    269270  }
  • trunk/tools/FlairGCS/src/Manager.h

    r248 r399  
    5656  void reset(void);
    5757  void tabBarCurrentChanged(int index);
    58   void printUDTStats(QString stats,bool loosingPackets);
     58  void printUDTStats(QString stats,QString stylesheet,bool loosingPackets);
    5959  void newFileUI(UDTSOCKET socket);
    6060  void deleteFileUI(void);
  • trunk/tools/FlairGCS/src/UdtSocket.cpp

    r307 r399  
    1515#include <assert.h>
    1616#include <QThread>
     17
    1718#define COMPRESS_CHUNK 1024*100
    1819
     
    3738  total_received=0;
    3839  pktSndLossTotal=0;
    39  
     40  lastpktRecvTotal=0;
     41 
    4042  bool blocking = false;
    4143  if (UDT::setsockopt(socket, 0, UDT_RCVSYN, &blocking, sizeof(bool)) != 0)
     
    9496    fprintf(stderr,"total number of received NAK packets: %i\n",perf.pktRecvNAKTotal);
    9597    fprintf(stderr,"round trip time: %fms\n",perf.msRTT);
    96      
    9798  }*/
    9899  bool loosingPackets=false;
    99100  if(perf.pktSndLossTotal>pktSndLossTotal) loosingPackets=true;
    100101  pktSndLossTotal=perf.pktSndLossTotal;
    101   stats=QString("rx rate %1kB/s, round trip %2ms, lost packets %3").arg(rxRate,0,'f',3).arg(perf.msRTT,0,'f',3).arg(perf.pktSndLossTotal);
    102   UDTStats(stats,loosingPackets);
     102  unsigned int pktPerSec=(perf.pktRecvTotal-lastpktRecvTotal)*1000/COMPUTE_UDT_STATS_TIMER;
     103  QString stylesheet="color: black";
     104  if(pktPerSec>=100) {
     105    stylesheet="color: red";
     106  }
     107  else if(pktPerSec>=50) {
     108    stylesheet="color: orange";
     109  }
     110  stats=QString("rx rate %1kB/s, %2 rx packets/s, round trip %3ms, lost packets %4").arg(rxRate,0,'f',3).arg(pktPerSec).arg(perf.msRTT,0,'f',3).arg(perf.pktSndLossTotal);
     111  lastpktRecvTotal=perf.pktRecvTotal;
     112  UDTStats(stats,stylesheet,loosingPackets);
    103113}
    104114
  • trunk/tools/FlairGCS/src/UdtSocket.h

    r248 r399  
    3131  unsigned int total_received;
    3232  QString stats;
    33   int pktSndLossTotal;
     33  unsigned int pktSndLossTotal;
     34  unsigned int lastpktRecvTotal;
     35 
    3436
    3537signals:
     
    3739  void newFileUI(UDTSOCKET socket);
    3840  void newConnectionLayout(QString name);
    39   void UDTStats(QString stats,bool loosingPackets);
     41  void UDTStats(QString stats,QString stylesheet,bool loosingPackets);
    4042
    4143public slots:
Note: See TracChangeset for help on using the changeset viewer.