//---------------------------------------------------------------- // ---- classes de threads pour lecture fichiers minifits // LAL - R. Ansari - Mai 2009 //---------------------------------------------------------------- #include "brfitsrd.h" #include #include #include #include #include "pexceptions.h" #include "timestamp.h" #include "ctimer.h" #include "brpaqu.h" #include "minifits.h" #include "resusage.h" // Pour mesure temps elapsed/CPU ... #include "datatable.h" // Pour sauver les entetes de paquet #include // pour gettimeofday //------------------------------------------------------- // Classe thread de sauvegarde sur fichiers //------------------------------------------------------- BRFitsReader::BRFitsReader(RAcqMemZoneMgr& mem, vector& infiles, bool fgnotrl) : memgr(mem), infiles_(infiles), fgnotrl_(fgnotrl) { } void BRFitsReader::Stop() { // cout<< " BRFitsReader:Stop ........ " << endl; stop_=true; } void BRFitsReader::run() { setRC(1); try { TimeStamp ts; Timer tm("BRFitsReader", false); BRPaqChecker pcheck(!fgnotrl_); // Verification/comptage des paquets size_t totnbytesrd = 0; cout << " BRFitsReader::run() - Starting " << ts << " NbFiles=" << infiles_.size() << " memgr.PaqSize() = " << memgr.PaqSize() << endl; uint_4 nfileok = 0; uint_8 nbytesrd = 0; /* Variables pour la logique des zones memoire et numeros de paquets dans la zone memoire */ int mid = -2; Byte* buff = NULL; int kmp = 0; int kmpmax=memgr.NbPaquets(); int paqsz = 0; for(int ifile=0; ifile skipping " << endl; continue; } // Les fichier FITS contiennent l'entet (24 bytes), mais pas le trailer (16 bytes) si fgnotrl=true int incpaqsz=0; if (fgnotrl_) { incpaqsz=16; if (ifile==0) cout << " Warning : FITS files without frame trailers ..." << endl; } if (paqsz == 0) { // premier passage, on fixe la taille de paquet et on verifie compatibilite avec memgr paqsz = mff.NAxis1()+incpaqsz; if (paqsz != memgr.PaqSize()) { cout << "BRFitsReader::run() mff.NAxis1() incompatible with memgr.PaqSize() -> exception " << endl; throw SzMismatchError(" fits file size incompatible with memgr.PaqSize()"); } } else { if (paqsz != mff.NAxis1()+incpaqsz) { cout << " PB : paqsz=" << paqsz << " != mff.NAxis1()+" << incpaqsz << " --> skipping " << endl; continue; } } if (mid < 0) { mid = memgr.FindMemZoneId(MemZA_Fill); buff = memgr.GetMemZone(mid); if (buff == NULL) { cout << " BRFitsReader::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl; setRC(2); return; } kmp=0; } size_t sx = mff.NAxis1(); size_t sy = mff.NAxis2(); int nprt=0; for(int j=0; j NULL" << endl; setRC(2); return; } kmp=0; } } } nfileok++; size_t nbytesrd = sx*sy; totnbytesrd += nbytesrd; } // Fin de la boucle sur les fichiers // Gestion d'une zone partiellement remplie if (mid>=0) { for(int k=kmp;k