| [3635] | 1 | #ifndef  RARDFITS_H_SEEN | 
|---|
|  | 2 | #define  RARDFITS_H_SEEN | 
|---|
|  | 3 |  | 
|---|
|  | 4 | //---------------------------------------------------------------- | 
|---|
| [3939] | 5 | // Projet BAORadio - (C) LAL/IRFU  2008-2011 | 
|---|
| [3683] | 6 | // Classes de threads pour lecture fichiers fits BAORadio | 
|---|
| [3635] | 7 | //---------------------------------------------------------------- | 
|---|
|  | 8 |  | 
|---|
|  | 9 | #include "racqumem.h" | 
|---|
|  | 10 | #include <string> | 
|---|
|  | 11 | #include <vector> | 
|---|
|  | 12 | #include <iostream> | 
|---|
|  | 13 |  | 
|---|
|  | 14 | #include "brpaqu.h" | 
|---|
| [3683] | 15 | #include "minifits.h" | 
|---|
| [3909] | 16 | #include "timestamp.h" | 
|---|
| [3635] | 17 |  | 
|---|
|  | 18 | using namespace std; | 
|---|
|  | 19 |  | 
|---|
| [3688] | 20 | //  ATTENTION cette definition (MAXANAFIB) se trouve dans plusieurs fichiers | 
|---|
| [3683] | 21 | #ifndef MAXANAFIB | 
|---|
|  | 22 | #define MAXANAFIB  32 | 
|---|
|  | 23 | #endif | 
|---|
| [3635] | 24 |  | 
|---|
|  | 25 | //------------------------------------------------------- | 
|---|
| [3683] | 26 | // Classe thread de lecture des fichiers data BAORadio | 
|---|
|  | 27 | //  BRMultiFitsReader : Lecture multi-fibres | 
|---|
|  | 28 | //------------------------------------------------------- | 
|---|
|  | 29 |  | 
|---|
|  | 30 | class BRMultiFitsReader : public SOPHYA::ZThread { | 
|---|
|  | 31 | public: | 
|---|
|  | 32 | BRMultiFitsReader(RAcqMemZoneMgr& mem, vector<string>& dirs, | 
|---|
|  | 33 | bool rdsamefc=true, uint_4 imin=0, uint_4 imax=0, uint_4 istep=1); | 
|---|
|  | 34 |  | 
|---|
|  | 35 | virtual void run(); | 
|---|
|  | 36 | inline void Stop() { stop_ = true; } | 
|---|
|  | 37 | inline void STOP() { stop_ = true; } | 
|---|
|  | 38 |  | 
|---|
| [3883] | 39 | inline int SetPrintLevel(int lev=0, uint_8 prtmodulo=50000) | 
|---|
|  | 40 | { prtlev_=lev;   prtmodulo_=prtmodulo;  return 0; } | 
|---|
|  | 41 |  | 
|---|
| [3683] | 42 | protected: | 
|---|
|  | 43 | bool ReadNextAllFibers();      // Renvoie true si probleme | 
|---|
|  | 44 | bool ReadNext(int fib);   // Renvoie true si probleme | 
|---|
|  | 45 | // Permet d'avancer d'un paquet dans la zone - renvoie true si probleme | 
|---|
|  | 46 | inline bool MoveToNextTarget()  { | 
|---|
|  | 47 | if ((mmbuf_ == NULL )||(targ_npaq_ >= max_targ_npaq)) | 
|---|
|  | 48 | if (MZoneManage()) return true; | 
|---|
|  | 49 | targ_npaq_++; | 
|---|
|  | 50 | return false; | 
|---|
|  | 51 | } | 
|---|
|  | 52 | inline Byte* GetPaquetTarget(int numfib)  { | 
|---|
|  | 53 | if ((mmbufib_[numfib] == NULL )||(targ_npaq_ > max_targ_npaq)||(targ_npaq_ == 0))  return NULL; | 
|---|
|  | 54 | Byte* rb=mmbufib_[numfib]+(targ_npaq_-1)*packsize_; | 
|---|
|  | 55 | return rb; | 
|---|
|  | 56 | } | 
|---|
|  | 57 | bool MZoneManage(bool clean=false);  // Renvoie true si probleme | 
|---|
|  | 58 |  | 
|---|
|  | 59 | RAcqMemZoneMgr& memgr_; | 
|---|
|  | 60 | vector<string> dirs_;  //  repertoires donnees chaque fibre | 
|---|
|  | 61 | bool stop_; | 
|---|
|  | 62 | bool rdsamefc_;  // if true, read paquets with same value of FrameCounter on different fibers | 
|---|
|  | 63 | uint_4 imin_, imax_, istep_; | 
|---|
| [3705] | 64 | uint_8 totnbytesrd_; | 
|---|
| [3683] | 65 | uint_8 totsamefc_;   // nombre total de paquets avec meme framecounter | 
|---|
|  | 66 | MiniFITSFile mff_[MAXANAFIB]; | 
|---|
|  | 67 | vector<uint_4> vfilenum_; | 
|---|
|  | 68 | vector<uint_4> vfpos_; | 
|---|
|  | 69 | vector<BRPaquet> vpaq_; | 
|---|
|  | 70 | vector<BRPaqChecker> vpchk_; | 
|---|
|  | 71 | vector<uint_8> curfc_;       // Numeros des FrameCounter des paquets courants | 
|---|
|  | 72 | vector<uint_8> totnpqrd_;    // nombre total de paquets lus / fibre | 
|---|
|  | 73 | vector<uint_8> totnpqok_;    // nombre total de paquets OK / fibre | 
|---|
|  | 74 |  | 
|---|
|  | 75 | uint_4 packsize_; | 
|---|
|  | 76 | int mid_;  // Identificateur zone memoire | 
|---|
|  | 77 | uint_4 targ_npaq_;  // Numero de paquet dans une seule zone memoire | 
|---|
|  | 78 | uint_4 max_targ_npaq; // =  mmgr.NbPaquets() = Max de targ_npaq_ | 
|---|
|  | 79 | Byte* mmbuf_;  // Pointeur zone memoire rendu par RAcqMemZoneMgr | 
|---|
|  | 80 | Byte* mmbufib_[MAXANAFIB];  // Pointeurs zone memoire de chaque fibre rendu par RAcqMemZoneMgr | 
|---|
|  | 81 |  | 
|---|
| [3938] | 82 | SOPHYA::TimeStamp cdateobs_;    // current file time/date  (from DATEOBS keyword in fits file) | 
|---|
|  | 83 | SOPHYA::TimeStamp ctmstart_;    // current time/date read from file (from TMSTART keyword in fits file) | 
|---|
|  | 84 | double cpaqdeltatime_;          // current time laps between two paquets in file = (TMEND-TMSTART)/NAXIS2 | 
|---|
| [3909] | 85 |  | 
|---|
| [3883] | 86 | int prtlev_;         // print level | 
|---|
|  | 87 | uint_8 prtmodulo_;   // print periodicity (modulo) | 
|---|
| [3683] | 88 | }; | 
|---|
|  | 89 |  | 
|---|
|  | 90 | //------------------------------------------------------- | 
|---|
| [3635] | 91 | // Classe thread de lecture des fichiers (mini)fits | 
|---|
|  | 92 | //------------------------------------------------------- | 
|---|
|  | 93 |  | 
|---|
| [3683] | 94 | class BRFitsReader : public SOPHYA::ZThread { | 
|---|
| [3635] | 95 | public: | 
|---|
|  | 96 | BRFitsReader(RAcqMemZoneMgr& mem, vector<string>& infiles, bool fgnotrl=false); | 
|---|
|  | 97 |  | 
|---|
|  | 98 | virtual void run(); | 
|---|
| [3683] | 99 | inline void Stop() { stop_ = true; } | 
|---|
| [3635] | 100 | inline void STOP() { stop_ = true; } | 
|---|
|  | 101 |  | 
|---|
|  | 102 | protected: | 
|---|
|  | 103 | RAcqMemZoneMgr& memgr; | 
|---|
|  | 104 | vector<string> infiles_; | 
|---|
|  | 105 | bool fgnotrl_; | 
|---|
|  | 106 | bool stop_; | 
|---|
|  | 107 | }; | 
|---|
|  | 108 |  | 
|---|
| [3646] | 109 | #endif | 
|---|