Changeset 3640 in Sophya for trunk/AddOn/TAcq/brfitsrd.cc


Ignore:
Timestamp:
May 27, 2009, 5:15:45 PM (16 years ago)
Author:
ansari
Message:

Correction et ameliorations multiples - en particulier mcrd.cc, brproc.cc et brfitsrd.cc, Reza 27/05/2009

File:
1 edited

Legend:

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

    r3635 r3640  
    3838{
    3939  setRC(1);     
    40   BRPaqChecker pcheck;  // Verification/comptage des paquets
    4140
    4241  try {
    4342    TimeStamp ts;
    44     Timer tm("BRFitsReader");
     43    Timer tm("BRFitsReader", false);
     44    BRPaqChecker pcheck(~fgnotrl_);  // Verification/comptage des paquets
     45   
    4546    size_t totnbytesrd = 0;
    4647    cout << " BRFitsReader::run() - Starting " << ts << " NbFiles=" << infiles_.size()
     
    4950    uint_4  nfileok = 0;
    5051    uint_8 nbytesrd = 0; 
     52    /*  Variables pour la logique des zones memoire et numeros de paquets dans la zone memoire */
     53    int mid = -2;
     54    Byte* buff = NULL; 
     55    int kmp = 0;   
     56    int kmpmax=memgr.NbPaquets();
     57
     58    int paqsz = 0;
    5159    for(int ifile=0; ifile<infiles_.size(); ifile++) {
    5260      string ffname = infiles_[ifile];
     
    6270// Les fichier FITS contiennent l'entet (24 bytes), mais pas le trailer (16 bytes) si fgnotrl=true
    6371      int incpaqsz=0;
    64       int paqsz = 0;
    6572      if (fgnotrl_) {
    6673        incpaqsz=16;
    6774        cout << " Warning : FITS files without frame trailers ..." << endl;
    6875      }
    69       if (paqsz == 0)  {  // premier passage, on fixe la taille de paquet et on alloue le buffer
     76      if (paqsz == 0)  {  // premier passage, on fixe la taille de paquet et on verifie compatibilite avec memgr
    7077        paqsz = mff.NAxis1()+incpaqsz;
    7178        if (paqsz != memgr.PaqSize()) {
    7279         cout << "BRFitsReader::run() mff.NAxis1() incompatible with memgr.PaqSize() -> exception " << endl;
    7380         throw SzMismatchError(" fits file size incompatible with memgr.PaqSize()");
    74         }
    75        if (mff.NAxis2() != memgr.NbPaquets())  {
    76          cout << "BRFitsReader::run() mff.NAxis2() <> memgr.NbPaquets() -> exception " << endl;
    77          throw SzMismatchError(" fits file NAxies2() <> memgr.NbPaquets()");
    7881        }
    7982      }
     
    8386        continue;
    8487        }
    85         if (memgr.NbPaquets() != mff.NAxis2()) {
    86         cout << " PB memgr.NbPaquets() != mff.NAxis2()  --> skipping " << endl;
    87         continue;
    88         }
    89       }
    90       int mid = memgr.FindMemZoneId(MemZA_Fill); 
    91       Byte* buff = memgr.GetMemZone(mid);
    92       if (buff == NULL) {
    93         cout << " BRFitsReader::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
    94         setRC(2);       
    95         return;
     88      }   
     89      if (mid < 0) {
     90        mid = memgr.FindMemZoneId(MemZA_Fill); 
     91        buff = memgr.GetMemZone(mid);
     92        if (buff == NULL) {
     93              cout << " BRFitsReader::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
     94              setRC(2);
     95               return; 
     96         }
     97         kmp=0;
    9698      }
    9799      size_t sx = mff.NAxis1();
    98       size_t sy = mff.NAxis2();
    99      
    100       for(int j=0; j<mff.NAxis2(); j++) {
    101         mff.ReadB(buff+j*paqsz, sx, j*sx);
    102         BRPaquet paq(NULL, buff+j*paqsz, paqsz);
    103         pcheck.Check(paq);   // Verification du paquet / FrameCounter
    104 
     100      size_t sy = mff.NAxis2();     
     101      int nprt=0;
     102      for(int j=0; j<sy; j++) {
     103        mff.ReadB(buff+kmp*paqsz, sx, j*sx);
     104        BRPaquet paq(NULL, buff+kmp*paqsz, paqsz);
     105        bool pqok = pcheck.Check(paq);   // Verification du paquet / FrameCounter
     106        if (!pqok && (nprt < 10)) {
     107          cout << "--BUG-- i=" << ifile << " mid=" << mid << " j=" << j << " kmp=" << kmp
     108               << " paqsz=" << paqsz << endl;
     109          nprt++;
     110          paq.Print(); 
     111        }
     112        kmp++;
     113        if (kmp >= kmpmax)  {   // Zone memoire rempli !
     114          memgr.FreeMemZone(mid, MemZS_Filled);
     115              mid = -2;
     116          if (j<sy) {
     117            mid = memgr.FindMemZoneId(MemZA_Fill); 
     118            buff = memgr.GetMemZone(mid);
     119            if (buff == NULL) {
     120                  cout << " BRFitsReader::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
     121                  setRC(2);     
     122                   return;     
     123             }
     124             kmp=0;
     125          }
     126        }
    105127      }
    106128      nfileok++;   
    107129      size_t nbytesrd = sx*sy;
    108130      totnbytesrd += nbytesrd;
     131    }   // Fin de la boucle sur les fichiers
     132// Gestion d'une zone partiellement remplie
     133    if (mid>=0) {
     134      for(int k=kmp;k<kmpmax;k++) {
     135        Byte* bp=buff+k*paqsz;
     136        for(int l=0;l<paqsz;l++) bp[l]=0;
     137      }
    109138      memgr.FreeMemZone(mid, MemZS_Filled);
    110     }   // Fin de la boucle sur les fichiers
    111 
     139    }
    112140
    113141//    sprintf(fname,"%s/.log",path_.c_str());
     
    120148    cout << " ------------------  BRFitsReader::run() END ----------------- " << endl;
    121149    ts.SetNow();
    122     tm.Split();
     150    tm.SplitQ();
    123151    cout << "  END reading " << ts << " NFileOK=" << nfileok << endl;
    124152    cout << "  TotalDiskRead= " << totnbytesrd/(1024*1024) << " MBytes Disk-Read rate= "
    125153         << (double)(totnbytesrd)/1024./tm.PartialElapsedTimems() << " MB/s" << endl;   
    126154    pcheck.Print(cout);
     155    cout << " BRFitsReader::run()/Timing: \n";
     156    tm.Print();
    127157    cout << " ---------------------------------------------------------- " << endl;
    128158
Note: See TracChangeset for help on using the changeset viewer.