Changeset 3674 in Sophya for trunk/AddOn/TAcq/racqurw.cc


Ignore:
Timestamp:
Nov 15, 2009, 1:27:00 AM (16 years ago)
Author:
ansari
Message:

version presque finale mfacq.cc avec reduction de taille de paquets - Reza 14/11/2009

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/racqurw.cc

    r3673 r3674  
    2121#include "datatable.h" // Pour sauver les entetes de paquet
    2222#include <sys/time.h>  // pour gettimeofday
     23
     24// Si on veut que MultiDataSaver cree des fichiers avec le numero des FrameCounters...
     25// define DEBUGPAQHDR 
     26
    2327//-------------------------------------------------------
    2428// Classe thread de lecture PCI-Express
     
    494498 
    495499  cout << " PCIEMultiReader::run() - Starting , NMaxMemZones=" << nmax_
    496        << " memgr.NbPaquets()=" << memgr.NbPaquets() << "Paqsize " << packSize_<< endl;
     500       << " memgr.NbPaquets()=" << memgr.NbPaquets() << "Paqsize " << packSize_
     501       << "  " << BRPaquet::FmtConvToString(swapall_) << endl; 
    497502  setRC(1);     
    498503
     
    507512  Byte* Datas[MAXNBFIB];
    508513  Byte* tampon[MAXNBFIB] ;
     514  Byte* predtampon=NULL;  // tampon de recopie pour la reduction des tailles de paquets
    509515  Byte* nextpaq=NULL;
    510516  uint_4 off_acheval=0;
     
    518524    tampon[i]=   new Byte[paqsz];
    519525  }
    520  
     526  bool fgredpaq=par_.fgreducpsize;
     527  if (fgredpaq) {
     528    cout << " PCIEMultiReader::run() - PaquetSizeReduction - RedSize=" << par_.redpqsize
     529         << " Offset=" << par_.reducoffset << " " << ((par_.reducneedcopy)?"NeedCopy":"NOCopy")
     530         << "  " << BRPaquet::ReducActionToString(par_.pqreducmode) << endl;
     531    predtampon = new Byte[paqsz];
     532  }
     533 
     534#ifdef DEBUGPAQHDR 
    521535  ofstream header[MAXNBFIB];
    522536  for(uint_4 fib=0; fib<nbDma_; fib++) {
     
    525539    header[fib].open(hfnm);
    526540  }
    527    
     541#endif   
    528542  uint_4 npaqfait[MAXNBFIB] ;
    529543  for (int i=0;i< (int)nbDma_ ;i++) npaqfait[i]=0;
     
    571585          }
    572586          // CHECK  S'il faut faire une reduction de taille de paquet
    573           if (par_.fgreducpsize) { // reduction taille de paquet
    574            
     587          if (fgredpaq) { // reduction taille de paquet
     588            if (par_.reducneedcopy) {
     589              BRPaquet paqc1(tampon[fib], predtampon, paqsz, swapall_);
     590              BRPaquet paqc2(nextpaq, par_.redpqsize);
     591              paqc2.CopyFrom(paqc1, par_.pqreducmode, par_.reducoffset);
     592            }
     593            else {
     594              BRPaquet paqc1(tampon[fib], paqsz);
     595              BRPaquet paqc2(nextpaq, par_.redpqsize);
     596              paqc2.CopyFrom(paqc1, par_.pqreducmode, par_.reducoffset);
     597            }
    575598          }
    576599          else  {
     
    581604          if (fib==nbDma_-1) npaqfaitg++;  // Ne pas oublier le compteur de paquets faits
    582605          pcheck[fib].Check(paq);   // Verification du paquet / FrameCounter
    583           header[fib] << dec << paq.FrameCounter()<< endl; ;
     606#ifdef DEBUGPAQHDR 
     607          header[fib] << dec << paq.FrameCounter()<< endl;
     608#endif
    584609        }
    585610      }
     
    607632        }
    608633        // CHECK  S'il faut faire une reduction de taille de paquet
    609         if (par_.fgreducpsize) { // reduction taille de paquet
    610          
     634        if (fgredpaq) { // reduction taille de paquet
     635          if (par_.reducneedcopy) {
     636            BRPaquet paqc1(Datas[fib]+curoff, predtampon, paqsz, swapall_);
     637            BRPaquet paqc2(nextpaq, par_.redpqsize);
     638            paqc2.CopyFrom(paqc1, par_.pqreducmode, par_.reducoffset);
     639          }
     640          else {
     641            BRPaquet paqc1(Datas[fib]+curoff, paqsz);
     642            BRPaquet paqc2(nextpaq, par_.redpqsize);
     643            paqc2.CopyFrom(paqc1, par_.pqreducmode, par_.reducoffset);
     644          }
    611645        }
    612646        else {
     
    617651        if (fib==nbDma_-1) npaqfaitg++;  // Ne pas oublier le compteur de paquets faits
    618652        pcheck[fib].Check(paq);   // Verification du paquet / FrameCounter
    619         header[fib] << dec << paq.FrameCounter()<< endl; ;
     653#ifdef DEBUGPAQHDR 
     654        header[fib] << dec << paq.FrameCounter()<< endl;
     655#endif
    620656      }
    621657      curoff += paqsz;  // On avance l'index dans le buffer du DMA
     
    647683  // //// Nettoyage final
    648684  MZoneManage(true);
     685  for (int i=0;i< (int)nbDma_ ;i++) delete[] tampon[i];
     686  if ((fgredpaq)&&predtampon) delete[] predtampon;
     687#ifdef DEBUGPAQHDR 
    649688  for(uint_4 fib=0; fib<nbDma_; fib++)  header[fib].close();
    650   for (int i=0;i< (int)nbDma_ ;i++) delete[] tampon[i];
     689#endif
     690
    651691  //DBG  cout << " fin thread ========================" <<endl; 
    652692  return;
     
    743783    uint_4 paqsz = memgr.PaqSize();
    744784    cout << " ============================ MultiDataSaver::run() PaqSize " << paqsz <<endl;
     785    bool fgfirstfctt=false;
    745786    bool fgnulldev = bpar.GetFileDevNull();
    746787    if (fgnulldev) {
     
    772813        // Sans TRAILER de paquet mff.setDTypeNaxis(MF_Byte, paq0.DataSize()+paq0.HeaderSize(), npaqperfile);
    773814        }
    774         // Ajout mots-cle additionnels a tous les fichiers FITS
    775         AddFitsKW(mff,bpar);
    776         fnum++;
     815        fnum++;   fgfirstfctt=true;
    777816      }
    778817      else sprintf(fname,"MemDataBloc[%d]-NoDataFile",(int)fnum++);
     
    797836          for(uint_4 i=0; i<memgr.NbPaquets(); i++) {  // boucle sur les paquets
    798837            BRPaquet paq(NULL, buff+i*paqsz, paqsz);
    799             pcheck[fib].Check(paq);   // Verification du paquet / FrameCounter
     838            bool cpaqok=pcheck[fib].Check(paq);   // Verification du paquet / FrameCounter
     839            if (cpaqok && fgfirstfctt) {
     840              framecnt_first_[fib] = pcheck[fib].LastFrameNum();
     841              timetag_first_[fib] = paq.TimeTag();
     842              fgfirstfctt=false;
     843            }
    800844            if (savesig_)
    801845              header[fib] << hex << paq.HDRMarker() << " " << paq.TRLMarker() << " "
     
    821865        cout  << "    Fib " << fib << " -> " << fname << " Stat:" << pcsum << endl;
    822866      }
    823       if (savesig_)
     867      if (savesig_)  {
     868        // Ajout mots-cle additionnels a tous les fichiers FITS
     869        for(uint_4 fib=0; fib<memgr.NbFibres(); fib++)
     870          framecnt_last_[fib] = pcheck[fib].LastFrameNum();
     871
     872        AddFitsKW(mff,bpar);
    824873        for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) {
    825874          header[fib].close();
    826875          mff[fib].Close();       
    827876        }
    828    
     877      }
    829878     
    830879    }  // Fin de boucle sur les fichiers
     
    861910  TimeStamp ts;
    862911  string cdtu=ts.ToString();
     912  string& skysrc=acpar.SkySource();
     913  bool hassrc=false;
     914  if (skysrc.length()>0)  hassrc=true;
    863915  for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) {
    864916    mff[fib].AddKeyS("DATE", cdtu.c_str(), " File Creation time(YYYY-MM-DDThh:mm:ss UT) ");       
     
    866918    mff[fib].AddKeyD("ACQVER", acpar.AcqVersion(), " BAORadio Acq Software version ") ;
    867919    mff[fib].AddKeyS("ACQCONF", acpar.GetParams().AcqMode, " BAORadio Acq run  mode" );
     920    if (hassrc)
     921      mff[fib].AddKeyS("SKYSOURC", skysrc, " Source identification" );
     922    mff[fib].AddKeyI("FCFIRST", framecnt_first_[fib], " First valid frame counter in file") ;
     923    mff[fib].AddKeyI("FCLAST", framecnt_last_[fib], " Last valid frame counter in file") ;
     924    mff[fib].AddKeyI("TTFIRST", timetag_first_[fib], " First valid timetag in file") ;
    868925  }
    869926  return 0;
Note: See TracChangeset for help on using the changeset viewer.