Changeset 444 in flair-src


Ignore:
Timestamp:
Sep 10, 2021, 2:37:55 PM (6 weeks ago)
Author:
Sanahuja Guillaume
Message:

update buffering (gcs part)
seems to work!

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/ui_com.cpp

    r443 r444  
    389389  dataToSend->CopyDatas(ptr->buf+ptr->actual_size);
    390390  ptr->actual_size+=dataToSend->SendSize();
    391   Printf("nb buffered %i/%i\n",ptr->actual_size,ptr->final_size);
    392   Printf("pushed size %i period %i nb buffering %i\n",dataToSend->SendSize(),dataToSend->SendPeriod(),dataToSend->NbBuffering());
     391  //Printf("nb buffered %i/%i\n",ptr->actual_size,ptr->final_size);
     392  //Printf("pushed size %i period %i nb buffering %i\n",dataToSend->SendSize(),dataToSend->SendPeriod(),dataToSend->NbBuffering());
    393393  if(ptr->actual_size>=ptr->final_size) {//par securité on test aussi le cas ou supérieur
    394       Printf("ready to send\n");
     394      //Printf("ready to send\n");
    395395      SendNRT(ptr->buf, ptr->actual_size,ptr->period);
    396396      //clean
     
    615615        if(bufSize!=0) bufSize+=sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t);//header+period+nb_buffering
    616616        if(bufSize!=(*pushedDatasIterator).final_size && bufSize!=0) {
    617             Printf("change buf size %i->%i\n",(*pushedDatasIterator).final_size,bufSize);
     617            //Printf("change buf size %i->%i\n",(*pushedDatasIterator).final_size,bufSize);
    618618            (*pushedDatasIterator).actual_size=0;
    619619            (*pushedDatasIterator).final_size=bufSize;
     
    622622        }
    623623        if(bufSize==0) {
    624             Printf("delete buf\n");
     624            //Printf("delete buf\n");
    625625            free((*pushedDatasIterator).buf);
    626626            pushedDatasIterator = pushedDatas.erase(pushedDatasIterator);
     
    635635      for (size_t i = 0; i < pushedDatas.size(); i++) {
    636636          if (pushedDatas.at(i).period==obj->SendPeriod() && pushedDatas.at(i).nb_buffering==obj->NbBuffering()) {
    637               Printf("match item %i, period %i nb buff %i\n",i,obj->SendPeriod(),obj->NbBuffering());
     637              //Printf("match item %i, period %i nb buff %i\n",i,obj->SendPeriod(),obj->NbBuffering());
    638638              match=true;
    639639            }
     
    641641      //create new one
    642642      if(!match) {
    643         printf("no match\n");
     643        //printf("no match\n");
    644644        PushedData_t tmp;
    645645        tmp.period=obj->SendPeriod();
     
    648648        tmp.final_size=0;
    649649        for (size_t i = 0; i < datasToSend.size(); i++) {
    650             Printf("data %i/%i %i %i\n",i,datasToSend.size(),datasToSend.at(i)->SendPeriod() ,datasToSend.at(i)->NbBuffering());
     650            //Printf("data %i/%i %i %i\n",i,datasToSend.size(),datasToSend.at(i)->SendPeriod() ,datasToSend.at(i)->NbBuffering());
    651651            if (datasToSend.at(i)->IsEnabled() && datasToSend.at(i)->SendPeriod() == obj->SendPeriod() && datasToSend.at(i)->NbBuffering()==obj->NbBuffering()) {
    652652              tmp.final_size+=datasToSend.at(i)->SendSize();
    653               Printf("add %i\n",datasToSend.at(i)->SendSize());
     653              //Printf("add %i\n",datasToSend.at(i)->SendSize());
    654654            }
    655655        }
    656656        tmp.final_size*=obj->NbBuffering();
    657657        tmp.final_size+=sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t);//header+period+nb_buffering
    658         printf("final size %i\n",tmp.final_size);
     658        //printf("final size %i\n",tmp.final_size);
    659659        tmp.buf=(char*)malloc(tmp.final_size);
    660660        if(tmp.buf!=NULL) {
     
    665665      }
    666666  }
    667   Printf("nb buf %i\n",pushedDatas.size());
     667  //Printf("nb buf %i\n",pushedDatas.size());
    668668  return;
    669669}
     
    688688
    689689void ui_com::UpdateDataToSendBufferSize(const SendData *obj) {
     690    if(!obj->IsEnabled()) return;
     691   
    690692    send_mutex->GetMutex();
    691693   
  • trunk/tools/FlairGCS/src/ConnectionLayout.cpp

    r443 r444  
    6060    break;
    6161  }
     62  case MULTIPLE_DATA_BIG_ENDIAN: {
     63    uint16_t period;
     64    uint16_t nb_buffering;
     65    memcpy(&period, buf+sizeof(char), sizeof(uint16_t));
     66    period = qFromBigEndian(period);
     67    memcpy(&nb_buffering,buf+sizeof(char)+sizeof(uint16_t), sizeof(uint16_t));
     68    nb_buffering = qFromBigEndian(nb_buffering);
     69    //fprintf(stderr,"recu %i, period %i, nb_buff %i\n",size,period,nb_buffering);
     70    drawDatas(buf+sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t), size - sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t), period, nb_buffering,true);
     71    break;
     72  }
    6273  case MULTIPLE_DATA_LITTLE_ENDIAN: {
    6374    uint16_t period;
     
    6576    memcpy(&period, buf+sizeof(char), sizeof(uint16_t));
    6677    memcpy(&nb_buffering,buf+sizeof(char)+sizeof(uint16_t), sizeof(uint16_t));
    67     fprintf(stderr,"recu %i, period %i, nb_buff %i\n",size,period,nb_buffering);
     78    //fprintf(stderr,"recu %i, period %i, nb_buff %i\n",size,period,nb_buffering);
    6879    drawDatas(buf+sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t), size - sizeof(char)+sizeof(uint16_t)+sizeof(uint16_t), period, nb_buffering);
    6980    break;
     
    118129    for (int i = 0; i < nb_buffering; i++) {
    119130        for (int j = 0; j < dataremotes.count(); j++) {
    120             dataremotes.at(j)->BufEvent(&buf, &buf_size, period, nb_buffering, big_endian);
     131            dataremotes.at(j)->BufEvent(&buf, &buf_size, period, nb_buffering,big_endian);
    121132        }
    122133    }
  • trunk/tools/FlairGCS/src/DataPlot1D.cpp

    r443 r444  
    7676}
    7777
    78 void DataPlot1D::BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,
    79                           bool big_endian) {
     78void DataPlot1D::BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian) {
    8079  setEnabled(IsEnabled());
    81   if (IsEnabled() == false || RefreshRate_ms() != period) return;
     80  if (IsEnabled() == false || RefreshRate_ms() != period || NbBuffering()!=nb_buffering) return;
    8281  double *datas = (double *)malloc(datas_type.count() * sizeof(double));
    8382
  • trunk/tools/FlairGCS/src/DataPlot1D.h

    r443 r444  
    2121  void XmlEvent(QDomElement *dom);
    2222  bool eventFilter(QObject *, QEvent *);
    23   void BufEvent(char **buf, int *buf_size, uint16_t period, uint16_t nb_buffering,bool big_endian);
     23  void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian);
    2424  bool mouseEvent(QMouseEvent *event);
    2525  QList<QString> datas_type;
  • trunk/tools/FlairGCS/src/DataPlot2D.cpp

    r443 r444  
    251251}
    252252
    253 void DataPlot2D::BufEvent(char **buf, int *buf_size, uint16_t period, uint16_t nb_buffering,bool big_endian) {
     253void DataPlot2D::BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian) {
    254254 
    255   if (IsEnabled() == false || RefreshRate_ms() != period)
    256     return;
     255  if (IsEnabled() == false || RefreshRate_ms() != period || NbBuffering()!=nb_buffering) return;
    257256
    258257  for (int i = 0; i < datas->count(); i++) {
  • trunk/tools/FlairGCS/src/DataPlot2D.h

    r443 r444  
    4646  void setYAxisScale(float ymin, float ymax);
    4747  void setXAxisScale(float xmin, float xmax);
    48   void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering, bool big_endian);
     48  void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian);
    4949  void showCurve(QwtPlotItem *item, bool on);
    5050
  • trunk/tools/FlairGCS/src/DataRemote.cpp

    r437 r444  
    8787}
    8888
     89uint16_t DataRemote::NbBuffering(void) {
     90   return nb_buffering;
     91}
     92
    8993bool DataRemote::IsEnabled(void) { return auto_refresh; }
    9094
     
    107111}
    108112
    109 int DataRemote::ReceiveSize(void) { return receivesize; }
    110 
    111113void DataRemote::XmlSetup(QDomElement *dom) {
    112114  refresh_rate = dom->attribute("period").toUShort() / 1000.;
  • trunk/tools/FlairGCS/src/DataRemote.h

    r443 r444  
    1818             uint16_t period, uint16_t nb_buffering=1);
    1919  ~DataRemote();
     20  virtual void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian) = 0;
     21
     22protected:
     23  int receivesize;
     24  double refresh_rate; // en s
     25 
     26  void XmlSetup(QDomElement *dom);
    2027  uint16_t RefreshRate_ms(void);
     28  uint16_t NbBuffering(void);
    2129  bool IsEnabled(void);
    22   int ReceiveSize(void);
    23   virtual void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering, bool big_endian) = 0;
    2430  void appendmenu(QMenu *menu);
    2531  QAction *execmenu(QWidget *parent, QMenu *menu, QPoint point);
    26 
    27 protected:
    28   bool auto_refresh;
    29   bool is_logging;
    30   double refresh_rate; // en s
    31   int receivesize;
    32   uint16_t nb_buffering;
    33 
    34   void XmlSetup(QDomElement *dom);
    3532
    3633private:
    3734  void SendPeriod(uint16_t period, bool auto_refresh);
    3835  void SendNbBuffering(uint16_t nb_buffering);
     36  bool is_logging;
     37  bool auto_refresh;
     38  uint16_t nb_buffering;
    3939  QAction *SetAutoRefresh, *setRefreshRate,*setNbBuffering;
    4040  //QAction **log;//todo implement this feature (log directly in gcs, in case of uav program crash)
  • trunk/tools/FlairGCS/src/Map.cpp

    r443 r444  
    287287}
    288288
    289 void Map::BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,
    290                    bool big_endian) {
    291   if (IsEnabled() == false || RefreshRate_ms() != period)
    292     return;
     289void Map::BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian) {
     290  if (IsEnabled() == false || RefreshRate_ms() != period || NbBuffering()!=nb_buffering) return;
    293291
    294292  for (int i = 0; i < points.count(); i++) {
  • trunk/tools/FlairGCS/src/Map.h

    r443 r444  
    5757  void Reset(void);
    5858  void XmlEvent(QDomElement *dom);
    59   void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering, bool big_endian);
     59  void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian);
    6060
    6161  void RemovePoints(void);
  • trunk/tools/FlairGCS/src/Picture.cpp

    r443 r444  
    4545Picture::~Picture() { delete layout; }
    4646
    47 void Picture::BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,
    48                        bool big_endian) {
     47void Picture::BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian) {
    4948  if (big_endian)
    5049    fprintf(stderr,"Picture::BufEvent, big endian not handled\n");
    5150
    52   if (IsEnabled() == false || RefreshRate_ms() != period)
    53     return;
     51  if (IsEnabled() == false || RefreshRate_ms() != period || NbBuffering()!=nb_buffering) return;
    5452
    5553  if ((*buf_size) >= im_width * im_height) {
     
    8987
    9088    a = menu->addAction("get frame");
    91     a->setEnabled(!auto_refresh);
     89    a->setEnabled(!IsEnabled());
    9290
    9391    appendmenu(menu);
  • trunk/tools/FlairGCS/src/Picture.h

    r443 r444  
    3737
    3838  bool eventFilter(QObject *, QEvent *);
    39   void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering, bool big_endian);
     39  void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian);
    4040  void XmlEvent(QDomElement *dom);
    4141};
  • trunk/tools/FlairGCS/src/RangeFinderPlot.cpp

    r443 r444  
    148148}
    149149
    150 void RangeFinderPlot::BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,
    151                                bool big_endian) {
     150void RangeFinderPlot::BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian) {
    152151  plot->setEnabled(IsEnabled());
    153   if (IsEnabled() == false || RefreshRate_ms() != period)
    154     return;
     152 if (IsEnabled() == false || RefreshRate_ms() != period || NbBuffering()!=nb_buffering) return;
    155153
    156154  for (uint32_t i = 0; i < nb_samples; i++) {
  • trunk/tools/FlairGCS/src/RangeFinderPlot.h

    r443 r444  
    4444
    4545  bool eventFilter(QObject *, QEvent *);
    46   void BufEvent(char **buf, int *buf_size, uint16_t period, uint16_t nb_buffering,bool big_endian);
     46  void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian);
    4747};
    4848
  • trunk/tools/FlairGCS/src/UsSensorPlot.cpp

    r443 r444  
    186186void UsSensorPlot::BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian) {
    187187  plot->setEnabled(IsEnabled());
    188   if (IsEnabled() == false || RefreshRate_ms() != period)
    189     return;
     188  if (IsEnabled() == false || RefreshRate_ms() != period || NbBuffering()!=nb_buffering) return;
    190189   
    191190  measure_t measure;
  • trunk/tools/FlairGCS/src/UsSensorPlot.h

    r443 r444  
    5757  void setYAxisScale(float ymin, float ymax);
    5858  void setXAxisScale(float xmin, float xmax);
    59   void BufEvent(char **buf, int *buf_size, uint16_t period, uint16_t nb_buffering,bool big_endian);
     59  void BufEvent(char **buf, int *buf_size, uint16_t period,uint16_t nb_buffering,bool big_endian);
    6060  void plotMeasure(int index);
    6161 
Note: See TracChangeset for help on using the changeset viewer.