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