1 | #ifndef RACQURW_H_SEEN
|
---|
2 | #define RACQURW_H_SEEN
|
---|
3 |
|
---|
4 | //----------------------------------------------------------------
|
---|
5 | // ---- classes de threads pour lecture (transfert DMA)
|
---|
6 | // et ecriture disque pour acquisition BAORadio -----
|
---|
7 | // LAL - R. Ansari - Juin/Juillet 2008
|
---|
8 | //----------------------------------------------------------------
|
---|
9 |
|
---|
10 | #include "racqumem.h"
|
---|
11 | #include <string>
|
---|
12 | #include <vector>
|
---|
13 | #include <iostream>
|
---|
14 | #include "sopnamsp.h"
|
---|
15 | #include "zthread.h"
|
---|
16 | #include "pciewrap.h"
|
---|
17 | #include "brtypes.h"
|
---|
18 | #include "brpaqu.h"
|
---|
19 | #include "brparam.h"
|
---|
20 | #include "minifits.h"
|
---|
21 |
|
---|
22 | using namespace std;
|
---|
23 |
|
---|
24 |
|
---|
25 | // Quelques definitions globales
|
---|
26 | // Nombre maximum de fibres geres par les classes MultiReader / MultiDiskWriter
|
---|
27 | #define MAXNBFIB 4
|
---|
28 |
|
---|
29 | //-------------------------------------------------------
|
---|
30 | // Classe thread de lecture PCI-Express
|
---|
31 | //-------------------------------------------------------
|
---|
32 |
|
---|
33 | class PCIEReader : public ZThread {
|
---|
34 | public:
|
---|
35 | PCIEReader( PCIEWrapperInterface &pciw , uint_4 sizeFrame,uint_4 paqSize ,RAcqMemZoneMgr& mem,
|
---|
36 | uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll);
|
---|
37 | virtual void run();
|
---|
38 | void Stop();
|
---|
39 | inline void STOP() { stop_ = true; }
|
---|
40 |
|
---|
41 | protected:
|
---|
42 | // Pour recuperer un pointeur sur la prochaine zone memoire devant recevoir un paquet
|
---|
43 | inline Byte* NextPaqTarget() {
|
---|
44 | if ((mmbuf_ == NULL )||(targ_npaq_ >= max_targ_npaq))
|
---|
45 | if (MZoneManage()) return NULL;
|
---|
46 | Byte* rb=mmbuf_+targ_npaq_*packSize_;
|
---|
47 | targ_npaq_++;
|
---|
48 | return rb;
|
---|
49 | }
|
---|
50 | bool MZoneManage(bool clean=false); // Renvoie true si probleme
|
---|
51 |
|
---|
52 | RAcqMemZoneMgr& memgr;
|
---|
53 | uint_4 nmax_; // Nombre maxi de blocs MemZone traites
|
---|
54 | BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
|
---|
55 | bool stop_;
|
---|
56 | unsigned int sizeFr_ ;
|
---|
57 | PCIEWrapperInterface& pciw_;
|
---|
58 | uint_4 packSize_;
|
---|
59 | // Variables pour gerer la logique de NextPaqTarget() qui cache l'acces a RAcqMemZoneMgr
|
---|
60 | int mid_; // Identificateur zone memoire
|
---|
61 | uint_4 targ_npaq_; // Numero de paquet dans une seule zone memoire
|
---|
62 | uint_4 max_targ_npaq; // = mmgr.NbPaquets() = Max de targ_npaq_
|
---|
63 | Byte* mmbuf_; // Pointeur zone memoire rendu par RAcqMemZoneMgr
|
---|
64 |
|
---|
65 | };
|
---|
66 |
|
---|
67 | //-------------------------------------------------------
|
---|
68 | // Classe thread de sauvegarde sur fichiers
|
---|
69 | //-------------------------------------------------------
|
---|
70 |
|
---|
71 | class DataSaver : public ZThread {
|
---|
72 | public:
|
---|
73 | DataSaver(RAcqMemZoneMgr& mem, string& path, uint_4 nfiles=100, uint_4 nblocperfile=1, bool savesig=true);
|
---|
74 |
|
---|
75 | virtual void run();
|
---|
76 | void Stop();
|
---|
77 | inline void STOP() { stop_ = true; }
|
---|
78 | protected:
|
---|
79 | RAcqMemZoneMgr& memgr;
|
---|
80 | uint_4 nfiles_; // Nombre maxi de fichiers cree
|
---|
81 | uint_4 nblocperfile_; // Nombre de bloc (zone memoire) mis dans un fichier
|
---|
82 | uint_4 nmax_; // Nombre maxi de blocs MemZone traites = nfiles * nblocperfile_
|
---|
83 | bool savesig_; // Si false, pas d'ecriture des fichiers FITS du signal
|
---|
84 | bool stop_;
|
---|
85 | string path_;
|
---|
86 | struct sigaction act;
|
---|
87 |
|
---|
88 | };
|
---|
89 |
|
---|
90 | //-------------------------------------------------------
|
---|
91 | // Classe thread de lecture PCI-Express + Check
|
---|
92 | //-------------------------------------------------------
|
---|
93 |
|
---|
94 | class PCIEReaderChecker : public ZThread {
|
---|
95 | public:
|
---|
96 | PCIEReaderChecker( PCIEWrapperInterface &pciw , uint_4 sizeFrame,uint_4 paqSize, RAcqMemZoneMgr& mem,
|
---|
97 | uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll);
|
---|
98 | virtual void run();
|
---|
99 | void Stop();
|
---|
100 | inline void STOP() { stop_ = true; }
|
---|
101 | protected:
|
---|
102 | RAcqMemZoneMgr& memgr;
|
---|
103 | uint_4 nmax_; // Nombre maxi de blocs MemZone traites
|
---|
104 | BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
|
---|
105 | bool stop_;
|
---|
106 | unsigned int sizeFr_ ;
|
---|
107 | PCIEWrapperInterface& pciw_;
|
---|
108 | uint_4 packSize_;
|
---|
109 | };
|
---|
110 | //------------------------------------------------------------------
|
---|
111 | // Classe thread de lecture PCI-Express multi fibre (ou multi DMA)
|
---|
112 | //------------------------------------------------------------------
|
---|
113 |
|
---|
114 | class PCIEMultiReader : public ZThread {
|
---|
115 | public:
|
---|
116 | PCIEMultiReader(vector<PCIEWrapperInterface*> vec_pciw , RAcqMemZoneMgr& mem, BRParList const& par);
|
---|
117 | virtual void run();
|
---|
118 | void Stop();
|
---|
119 | inline void STOP() { stop_ = true; }
|
---|
120 |
|
---|
121 | protected:
|
---|
122 | // Permet d'avancer d'un paquet dans la zone - renvoie true si probleme
|
---|
123 | inline bool MoveToNextTarget() {
|
---|
124 | if ((mmbuf_ == NULL )||(targ_npaq_ >= max_targ_npaq))
|
---|
125 | if (MZoneManage()) return true;
|
---|
126 | targ_npaq_++;
|
---|
127 | return false;
|
---|
128 | }
|
---|
129 | inline Byte* GetPaquetTarget(int numfib) {
|
---|
130 | if ((mmbufib_[numfib] == NULL )||(targ_npaq_ > max_targ_npaq)||(targ_npaq_ == 0)) return NULL;
|
---|
131 | Byte* rb=mmbufib_[numfib]+(targ_npaq_-1)*packSizeInMgr_;
|
---|
132 | return rb;
|
---|
133 | }
|
---|
134 | bool MZoneManage(bool clean=false); // Renvoie true si probleme
|
---|
135 |
|
---|
136 | RAcqMemZoneMgr& memgr;
|
---|
137 | BRParList par_; // Parametres divers d'acquisition
|
---|
138 |
|
---|
139 | uint_4 nmax_; // Nombre maxi de blocs MemZone traites
|
---|
140 | BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet
|
---|
141 | bool stop_;
|
---|
142 | unsigned int sizeFr_ ;
|
---|
143 | vector<PCIEWrapperInterface *> vec_pciw_;
|
---|
144 | uint_4 packSize_;
|
---|
145 | uint_4 packSizeInMgr_;
|
---|
146 | uint_4 nbDma_;
|
---|
147 | int mid_; // Identificateur zone memoire
|
---|
148 | uint_4 targ_npaq_; // Numero de paquet dans une seule zone memoire
|
---|
149 | uint_4 max_targ_npaq; // = mmgr.NbPaquets() = Max de targ_npaq_
|
---|
150 | Byte* mmbuf_; // Pointeur zone memoire rendu par RAcqMemZoneMgr
|
---|
151 | Byte* mmbufib_[MAXNBFIB]; // Pointeurs zone memoire de chaque fibre rendu par RAcqMemZoneMgr
|
---|
152 |
|
---|
153 | };
|
---|
154 |
|
---|
155 |
|
---|
156 |
|
---|
157 | //----------------------------------------------------------------------------------------
|
---|
158 | // Classe thread de sauvegarde sur fichiers - gerant plusieurs fibres dans RAcqMemZoneMgr
|
---|
159 | //----------------------------------------------------------------------------------------
|
---|
160 |
|
---|
161 | // --- Cette classe utilise les parametres globaux d'acquisition BRAcqConfig
|
---|
162 | class MultiDataSaver : public ZThread {
|
---|
163 | public:
|
---|
164 | MultiDataSaver(RAcqMemZoneMgr& mem);
|
---|
165 |
|
---|
166 | virtual void run();
|
---|
167 | void Stop();
|
---|
168 | inline void STOP() { stop_ = true; }
|
---|
169 | protected:
|
---|
170 | int AddFitsKW(MiniFITSFile* mff, BRAcqConfig& acpar);
|
---|
171 |
|
---|
172 | RAcqMemZoneMgr& memgr;
|
---|
173 |
|
---|
174 | uint_4 nfiles_; // Nombre maxi de fichiers cree
|
---|
175 | uint_4 nblocperfile_; // Nombre de bloc (zone memoire) mis dans un fichier
|
---|
176 | uint_4 nmax_; // Nombre maxi de blocs MemZone traites = nfiles * nblocperfile_
|
---|
177 | bool savesig_; // Si false, pas d'ecriture des fichiers FITS du signal
|
---|
178 | bool stop_;
|
---|
179 | uint_8 framecnt_first_[MAXNBFIB]; // Numero de framecounter first
|
---|
180 | uint_8 framecnt_last_[MAXNBFIB]; // Numero de framecounter last
|
---|
181 | uint_8 timetag_first_[MAXNBFIB]; // TimeTag first
|
---|
182 |
|
---|
183 | };
|
---|
184 |
|
---|
185 | #endif
|
---|