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, uint_8 prtmodulo=50000)
|
---|
39 | { prtlev_=lev; prtmodulo_=prtmodulo; return 0; }
|
---|
40 |
|
---|
41 | protected:
|
---|
42 | bool ReadNextAllFibers(); // Renvoie true si probleme
|
---|
43 | bool ReadNext(int fib); // Renvoie true si probleme
|
---|
44 | // Permet d'avancer d'un paquet dans la zone - renvoie true si probleme
|
---|
45 | inline bool MoveToNextTarget() {
|
---|
46 | if ((mmbuf_ == NULL )||(targ_npaq_ >= max_targ_npaq))
|
---|
47 | if (MZoneManage()) return true;
|
---|
48 | targ_npaq_++;
|
---|
49 | return false;
|
---|
50 | }
|
---|
51 | inline Byte* GetPaquetTarget(int numfib) {
|
---|
52 | if ((mmbufib_[numfib] == NULL )||(targ_npaq_ > max_targ_npaq)||(targ_npaq_ == 0)) return NULL;
|
---|
53 | Byte* rb=mmbufib_[numfib]+(targ_npaq_-1)*packsize_;
|
---|
54 | return rb;
|
---|
55 | }
|
---|
56 | bool MZoneManage(bool clean=false); // Renvoie true si probleme
|
---|
57 |
|
---|
58 | RAcqMemZoneMgr& memgr_;
|
---|
59 | vector<string> dirs_; // repertoires donnees chaque fibre
|
---|
60 | bool stop_;
|
---|
61 | bool rdsamefc_; // if true, read paquets with same value of FrameCounter on different fibers
|
---|
62 | uint_4 imin_, imax_, istep_;
|
---|
63 | uint_8 totnbytesrd_;
|
---|
64 | uint_8 totsamefc_; // nombre total de paquets avec meme framecounter
|
---|
65 | MiniFITSFile mff_[MAXANAFIB];
|
---|
66 | vector<uint_4> vfilenum_;
|
---|
67 | vector<uint_4> vfpos_;
|
---|
68 | vector<BRPaquet> vpaq_;
|
---|
69 | vector<BRPaqChecker> vpchk_;
|
---|
70 | vector<uint_8> curfc_; // Numeros des FrameCounter des paquets courants
|
---|
71 | vector<uint_8> totnpqrd_; // nombre total de paquets lus / fibre
|
---|
72 | vector<uint_8> totnpqok_; // nombre total de paquets OK / fibre
|
---|
73 |
|
---|
74 | uint_4 packsize_;
|
---|
75 | int mid_; // Identificateur zone memoire
|
---|
76 | uint_4 targ_npaq_; // Numero de paquet dans une seule zone memoire
|
---|
77 | uint_4 max_targ_npaq; // = mmgr.NbPaquets() = Max de targ_npaq_
|
---|
78 | Byte* mmbuf_; // Pointeur zone memoire rendu par RAcqMemZoneMgr
|
---|
79 | Byte* mmbufib_[MAXANAFIB]; // Pointeurs zone memoire de chaque fibre rendu par RAcqMemZoneMgr
|
---|
80 |
|
---|
81 | int prtlev_; // print level
|
---|
82 | uint_8 prtmodulo_; // print periodicity (modulo)
|
---|
83 | };
|
---|
84 |
|
---|
85 | //-------------------------------------------------------
|
---|
86 | // Classe thread de lecture des fichiers (mini)fits
|
---|
87 | //-------------------------------------------------------
|
---|
88 |
|
---|
89 | class BRFitsReader : public SOPHYA::ZThread {
|
---|
90 | public:
|
---|
91 | BRFitsReader(RAcqMemZoneMgr& mem, vector<string>& infiles, bool fgnotrl=false);
|
---|
92 |
|
---|
93 | virtual void run();
|
---|
94 | inline void Stop() { stop_ = true; }
|
---|
95 | inline void STOP() { stop_ = true; }
|
---|
96 |
|
---|
97 | protected:
|
---|
98 | RAcqMemZoneMgr& memgr;
|
---|
99 | vector<string> infiles_;
|
---|
100 | bool fgnotrl_;
|
---|
101 | bool stop_;
|
---|
102 | };
|
---|
103 |
|
---|
104 | #endif
|
---|