| 1 | #ifndef RARDFITS_H_SEEN
|
|---|
| 2 | #define RARDFITS_H_SEEN
|
|---|
| 3 |
|
|---|
| 4 | //----------------------------------------------------------------
|
|---|
| 5 | // Projet BAORadio - (C) LAL/IRFU 2008-2011
|
|---|
| 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 | #include "timestamp.h"
|
|---|
| 17 |
|
|---|
| 18 | using namespace std;
|
|---|
| 19 |
|
|---|
| 20 | // ATTENTION cette definition (MAXANAFIB) se trouve dans plusieurs fichiers
|
|---|
| 21 | #ifndef MAXANAFIB
|
|---|
| 22 | #define MAXANAFIB 32
|
|---|
| 23 | #endif
|
|---|
| 24 |
|
|---|
| 25 | //-------------------------------------------------------
|
|---|
| 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 |
|
|---|
| 39 | inline int SetPrintLevel(int lev=0, uint_8 prtmodulo=50000)
|
|---|
| 40 | { prtlev_=lev; prtmodulo_=prtmodulo; return 0; }
|
|---|
| 41 |
|
|---|
| 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_;
|
|---|
| 64 | uint_8 totnbytesrd_;
|
|---|
| 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 |
|
|---|
| 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
|
|---|
| 85 |
|
|---|
| 86 | int prtlev_; // print level
|
|---|
| 87 | uint_8 prtmodulo_; // print periodicity (modulo)
|
|---|
| 88 | };
|
|---|
| 89 |
|
|---|
| 90 | //-------------------------------------------------------
|
|---|
| 91 | // Classe thread de lecture des fichiers (mini)fits
|
|---|
| 92 | //-------------------------------------------------------
|
|---|
| 93 |
|
|---|
| 94 | class BRFitsReader : public SOPHYA::ZThread {
|
|---|
| 95 | public:
|
|---|
| 96 | BRFitsReader(RAcqMemZoneMgr& mem, vector<string>& infiles, bool fgnotrl=false);
|
|---|
| 97 |
|
|---|
| 98 | virtual void run();
|
|---|
| 99 | inline void Stop() { stop_ = true; }
|
|---|
| 100 | inline void STOP() { stop_ = true; }
|
|---|
| 101 |
|
|---|
| 102 | protected:
|
|---|
| 103 | RAcqMemZoneMgr& memgr;
|
|---|
| 104 | vector<string> infiles_;
|
|---|
| 105 | bool fgnotrl_;
|
|---|
| 106 | bool stop_;
|
|---|
| 107 | };
|
|---|
| 108 |
|
|---|
| 109 | #endif
|
|---|