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


Ignore:
Timestamp:
Jun 21, 2016, 3:48:18 PM (8 years ago)
Author:
Sanahuja Guillaume
Message:

show rx rate in GCS

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

Legend:

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

    r15 r30  
    1212
    1313#define COMPRESS_CHUNK 1024
     14#define RX_TIME 5000
    1415
    1516ConnectionLayout::ConnectionLayout(UdtSocket *socket, QString name)
     
    1718  isRemoteNameDefined = false;
    1819  this->socket = socket;
     20
     21  total_received=0;
     22  receive_timer = new QTimer(this);
     23  connect(receive_timer, SIGNAL(timeout()), this, SLOT(computeRxRate()));
     24  receive_timer->start(RX_TIME);
    1925}
    2026
    21 ConnectionLayout::~ConnectionLayout() {}
     27ConnectionLayout::~ConnectionLayout() {
     28  receive_timer->stop();
     29}
     30
     31void ConnectionLayout::computeRxRate(void) {
     32  float receive_rate=((float)total_received/(RX_TIME/1000))/1000;//in Ko/s
     33  total_received=0;
     34  computedRxRate(receive_rate);
     35}
    2236
    2337void ConnectionLayout::receive(char *buf, int size) {
     38  total_received+=size-1;
    2439  // printf("trame %x\n",buf[0]);
    2540  // for(int i=0; i<size;i++) printf("%x ",buf[i]);
  • trunk/tools/FlairGCS/src/ConnectionLayout.h

    r15 r30  
    66#define CONNECTIONLAYOUT_H
    77
     8#include <QTimer>
    89#include "Layout.h"
    910
     
    3334  UdtSocket *socket;
    3435  QList<DataRemote *> dataremotes;
     36  unsigned int total_received;
     37  QTimer *receive_timer;
    3538
    3639private slots:
    3740  void receive(char *buf, int size);
     41  void computeRxRate(void);
    3842
    3943signals:
    4044  void setRemoteName(QString name);
     45  void computedRxRate(float rxRate);
    4146};
    4247
  • trunk/tools/FlairGCS/src/Manager.cpp

    r15 r30  
    3838
    3939  setWindowTitle(name);
    40 
     40//statusBar()->showMessage(tr("Ready to serve"));
    4141  // manager layout
    4242  managerLayout = new QVBoxLayout;
     
    6969  connect(save_button, SIGNAL(clicked(bool)), this, SLOT(save()));
    7070
     71  status=new QStatusBar();
     72  status->setSizeGripEnabled(false);
     73  button_layout->addWidget(status, 1,0);
     74
    7175  UDT::startup();
    7276  serv = UDT::socket(AF_INET, SOCK_DGRAM, 0);
     
    155159  connect(newLayout, SIGNAL(setRemoteName(QString)), this,
    156160          SLOT(tabName(QString)));
     161  connect(newLayout, SIGNAL(computedRxRate(float)), this,
     162          SLOT(printRxRates(float)));
    157163  connect(socket, SIGNAL(dataReady(char *, int)), newLayout,
    158164          SLOT(receive(char *, int)));
     
    172178  } else { // add a tab for the new connection
    173179    tabBar->addTab("unknown");
     180  }
     181}
     182
     183void Manager::printRxRates(float rxRate) {
     184  int index = connectionsLayout.indexOf((ConnectionLayout *)sender());
     185
     186  if (tabBar->count() == 0) {
     187    status->showMessage(tr("rx rate %1 kB/s").arg(rxRate,0,'f',3));
     188  } else if (index==tabBar->currentIndex()) {
     189    status->showMessage(tr("%1 rx rate %2 kB/s").arg(tabBar->tabText(index)).arg(rxRate,0,'f',3));
    174190  }
    175191}
     
    209225    hiddenTabName = tabBar->tabText(0);
    210226    tabBar->removeTab(0);
     227  }
     228
     229  if (connectionsLayout.count() == 0) {
     230    status->showMessage("");
    211231  }
    212232}
  • trunk/tools/FlairGCS/src/Manager.h

    r15 r30  
    99#include <udt.h>
    1010#include <qdom.h>
     11#include <QStatusBar>
    1112
    1213class UdtSocket;
     
    3839  QPushButton *save_button;
    3940  QGridLayout *button_layout;
     41  QStatusBar *status;
    4042
    4143  void newConnection(UdtSocket *socket);
     
    5052  void tabBarCurrentChanged(int index);
    5153  void tabName(QString name);
     54  void printRxRates(float rxRate);
    5255
    5356signals:
  • trunk/tools/FlairGCS/src/UdtSocket.cpp

    r20 r30  
    7070    if (UDT::epoll_add_usock(eid, file_socket) < 0) {
    7171      if (UDT::getlasterror().getErrorCode() == 5004) {
    72         printf("epoll_add_usock\n");
     72        printf("epoll_add_usock error\n");
    7373        break;
    7474      } else {
     
    7979    if (UDT::epoll_add_usock(eid, com_socket) < 0) {
    8080      if (UDT::getlasterror().getErrorCode() == 5004) {
    81         printf("epoll_add_usock\n");
     81        printf("epoll_add_usock error\n");
    8282        break;
    8383      } else {
Note: See TracChangeset for help on using the changeset viewer.