1 | #ifndef BRPARAM_H
|
---|
2 | #define BRPARAM_H
|
---|
3 |
|
---|
4 | //---------------------------------------------------------------
|
---|
5 | // Logiciels d'acquisition BAORadio
|
---|
6 | // LAL - 2009 - 2010 , R. Ansari, M.Taurigna
|
---|
7 | //---------------------------------------------------------------
|
---|
8 |
|
---|
9 | //---------------------------------------------------------------
|
---|
10 | // Classes ADCBoardDesc , BRParList , BRConfList , BRAcqConfig
|
---|
11 | // + ADCBoardDesc : Description d'une carte ADC
|
---|
12 | // + BRParList : Liste de parametres pour un run d'acquisition
|
---|
13 | // + BRConfList : Liste des parametres caracterisant une configuration
|
---|
14 | // (nombre de cartes, versions firwares ...)
|
---|
15 | // + BRAcqConfig : Classe donnant acces a un objet global BRParList et
|
---|
16 | // un objet global BRConfList
|
---|
17 | //---------------------------------------------------------------
|
---|
18 |
|
---|
19 | #include "machdefs.h"
|
---|
20 | #include <string>
|
---|
21 | #include <vector>
|
---|
22 | #include <map>
|
---|
23 | #include <iostream>
|
---|
24 | #include "brpaqu.h"
|
---|
25 | #include "datacards.h"
|
---|
26 | #include "bracqvers.h"
|
---|
27 |
|
---|
28 | using namespace std;
|
---|
29 | using namespace SOPHYA;
|
---|
30 |
|
---|
31 | //-----------------------------------------------------------------------------
|
---|
32 | //---- Classe Caracterisant un board ADC
|
---|
33 | class ADCBoardDesc {
|
---|
34 | public:
|
---|
35 | ADCBoardDesc(int id, string sbid, string cyc_firmw, string str1_firmw, string str2_firmw);
|
---|
36 | ADCBoardDesc(ADCBoardDesc const& bdes);
|
---|
37 |
|
---|
38 | inline int& getId() { return id_; }
|
---|
39 | inline string& getSId() { return sbid_; }
|
---|
40 | inline string& CycloneFirmwareId() { return cyclone_firmware_; }
|
---|
41 | inline string& Stratix1FirmwareId() { return stratix1_firmware_; }
|
---|
42 | inline string& Stratix2FirmwareId() { return stratix2_firmware_; }
|
---|
43 | ostream& Print(ostream& os);
|
---|
44 |
|
---|
45 | ADCBoardDesc& Set(ADCBoardDesc const & bdes);
|
---|
46 | inline ADCBoardDesc& operator = (ADCBoardDesc const & bdes) { return Set(bdes); }
|
---|
47 | protected:
|
---|
48 | int id_;
|
---|
49 | string sbid_;
|
---|
50 | string cyclone_firmware_;
|
---|
51 | string stratix1_firmware_;
|
---|
52 | string stratix2_firmware_;
|
---|
53 | };
|
---|
54 |
|
---|
55 | //-----------------------------------------------------------------------------
|
---|
56 | //---- Classe de liste des parametres de configuration BAORadio
|
---|
57 | class BRConfList {
|
---|
58 | public:
|
---|
59 | BRConfList();
|
---|
60 | BRConfList(string basedir);
|
---|
61 | BRConfList(string basedir, vector<ADCBoardDesc> boards);
|
---|
62 | BRConfList(BRConfList const & cf);
|
---|
63 |
|
---|
64 | void SetBaseDirectory(string& basedir);
|
---|
65 | BRConfList& Set(BRConfList const & cf);
|
---|
66 | inline BRConfList& operator = (BRConfList const & cf) { return Set(cf); }
|
---|
67 |
|
---|
68 | int SetFiberIds(string& sfids); // Identification absolue des fibres sous forme de 3,5,8
|
---|
69 |
|
---|
70 | ostream& Print(ostream& os) ;
|
---|
71 | void ReadDCFile(string file);
|
---|
72 | inline const string& BaseDirectory() const { return basedir_; }
|
---|
73 | inline const string& TmpDirectory() const { return tmpdir_; }
|
---|
74 |
|
---|
75 | inline int FiberId(int numfib)
|
---|
76 | { size_t ff=numfib-1; if (ff<fiberIds_.size()) return fiberIds_[ff]; else return 0; }
|
---|
77 |
|
---|
78 | void InitFromEnv(); // initialisation a partir de variables d'environnement
|
---|
79 | //.......................................
|
---|
80 | string basedir_;
|
---|
81 | vector<ADCBoardDesc> boards_;
|
---|
82 | string fiberIdsS_; // String_liste des numeros 'absolu' des fibres 12,13,14,15 par exemple
|
---|
83 | vector<int> fiberIds_; // liste des numero d'identification 'absolu' des fibres {12,13,14,15} par ex.
|
---|
84 | string tmpdir_; // repertoire pour fichiers temporaires
|
---|
85 | };
|
---|
86 |
|
---|
87 |
|
---|
88 | //-----------------------------------------------------------------------------
|
---|
89 | //---- Classe de liste des parametres d'acquisition BAORadio
|
---|
90 | class BRParList {
|
---|
91 | public:
|
---|
92 | BRParList (string acqmode="fft2c", string fibres="1", unsigned int paqsz= 16424,
|
---|
93 | unsigned int dmaszkb = 32, int nfiles=1, int nblocfile=10, string outpath="TstAcq",
|
---|
94 | uint_4 nzon = 4, uint_4 npaqzon = 128);
|
---|
95 |
|
---|
96 | BRParList(BRParList const & p);
|
---|
97 |
|
---|
98 | void Set(BRParList const & p);
|
---|
99 | ostream& Print(ostream& os) ;
|
---|
100 | void ReadDCFile(string file);
|
---|
101 |
|
---|
102 | // Nombre de fibres pour acquisition
|
---|
103 | inline size_t NFibers() { return fiberNum_.size(); }
|
---|
104 | inline size_t NbFibers() { return fiberNum_.size(); }
|
---|
105 | // Numeros des fibres pour acquisition
|
---|
106 | inline int FiberNum(size_t fib)
|
---|
107 | { if (fib<fiberNum_.size()) return fiberNum_[fib]; else return 0; }
|
---|
108 | // Taille des operations DMA (en octets)
|
---|
109 | inline uint_4 DMASizeBytes() { return dmasizekb*1024; }
|
---|
110 | // Taille des operations DMA (en KB=1024 bytes)
|
---|
111 | inline uint_4 DMASizeKB() { return dmasizekb; }
|
---|
112 | // Taille des paquets recus sur PCIExpress
|
---|
113 | inline uint_4 RecvPaquetSize() { return PaqSize; }
|
---|
114 | // Taille des paquets apres reduction eventuelle (donc ds memory manager)
|
---|
115 | inline uint_4 MMgrPaquetSize() { return (fgreducpsize)?redpqsize:PaqSize; }
|
---|
116 | // Nombre de paquets dans chaque bloc de MMgr
|
---|
117 | inline uint_4 MMgrNbPaquet() { return nPaqZone; }
|
---|
118 | // Operation de conversion/mise en ordre des donnees a la reception
|
---|
119 | inline BRDataFmtConv GetDataConvFg() { return swapall; };
|
---|
120 |
|
---|
121 | // Nombre maximum de fichiers enregistres
|
---|
122 | inline uint_4 MaxNbFiles() { return NbFiles; }
|
---|
123 | // Nombre de blocs MMgr dans chaque fichiers
|
---|
124 | inline uint_4 BlocPerFile() { return NBlocPerFile; }
|
---|
125 | // Nombre maximum de blocs MMgr traites
|
---|
126 | inline uint_8 MaxNbBlocs() { return (uint_8)NbFiles*(uint_8)NBlocPerFile; }
|
---|
127 | // Nombre maximum paquets traites
|
---|
128 | inline uint_8 MaxNbPaquets() { return MaxNbBlocs()*(uint_8)nPaqZone; }
|
---|
129 |
|
---|
130 | // Taille des paquets recus sur PCIExpress
|
---|
131 | inline uint_4 PatternSize() { return ((PaqSize-(BRHDRSIZE+BRTRLSIZE))/4); }
|
---|
132 |
|
---|
133 | inline vector< vector<string> >& GetEthTargets() { return eths_targets; }
|
---|
134 | // Nombre de liens ethernet comme source de donnees (paquets)
|
---|
135 | inline int NbEthLinks() { return ethr_nlink; }
|
---|
136 |
|
---|
137 | // Identification source ciel
|
---|
138 | inline string& SkySource() { return skysource; }
|
---|
139 |
|
---|
140 | //..........................................
|
---|
141 | void Decode();
|
---|
142 |
|
---|
143 | string AcqMode; // Mode d'acquisition (conditionne la mise en ordre/conversion des donnees lues par DMA
|
---|
144 | bool fgdatafft; // true -> donnee FFT (provenant du firmware FFT)
|
---|
145 | bool fgfftshrink; // true -> donnee FFT tronquee [NumFreq=2048...3072] (provenant du firmware FFT)
|
---|
146 | bool fgsinglechannel; // true -> un seul canal par fibre (par defaut=2 canaux/fibres)
|
---|
147 |
|
---|
148 | string FiberListS ; // String_liste des numeros de fibres a utiliser 1,3,4 par exemple
|
---|
149 | vector<int> fiberNum_; // liste des numeros fibres a utiliser {1,3,4} par exemple
|
---|
150 |
|
---|
151 | string OutPathName; // directory de base
|
---|
152 | string ProcPathName;
|
---|
153 | uint_4 PaqSize ; // taille des paquets ou sizeFrame
|
---|
154 |
|
---|
155 | // Controle/gestion du DMA
|
---|
156 | uint_4 dmasizekb ; // taille du dma en multiple de 2 (2 a 56)
|
---|
157 | unsigned int maxkwedma_; // Nombre d'iterations de la boucle d'attente de fin de DMA (en unite de 1000)
|
---|
158 | unsigned int nretrydma_; // nombre maxi de tentatives pour terminer le DMA
|
---|
159 | unsigned int first_maxkwedma_; // Nombre d'iterations de la boucle d'attente de fin du PREMIER DMA (u 1000)
|
---|
160 | unsigned int first_nretrydma_; // nombre maxi de tentatives pour terminer le PREMIER DMA
|
---|
161 |
|
---|
162 | int NbFiles; // nombre de fichier produits
|
---|
163 | int NBlocPerFile; // nombre de bloc par fichier
|
---|
164 | // Gestionnaire zones memoire
|
---|
165 | uint_4 nZones; // Nombre de zones memoires
|
---|
166 | uint_4 nPaqZone; // 128 Paquets / zone memoire - valeur par defaut
|
---|
167 |
|
---|
168 | bool fg_hard_ctrlc ; // autorise le CtrlC si true
|
---|
169 |
|
---|
170 | bool savesigfits ; // si true on prduit de sfichier fits
|
---|
171 | bool fgnulldev4fits ;
|
---|
172 |
|
---|
173 | BRDataFmtConv swapall ; // type de l'acquisition voir brpaqu.h
|
---|
174 |
|
---|
175 | // ---- Pour gerer la reduction des tailles de paquets
|
---|
176 | bool fgreducpsize; // true -> reduction taille des paquets
|
---|
177 | bool reducneedcopy; // true -> besoin de copie intermediaire pour la reduction de taille de paquets
|
---|
178 | BRPaqReducAction pqreducmode;
|
---|
179 | uint_4 redpqsize;
|
---|
180 | uint_4 reducoffset;
|
---|
181 |
|
---|
182 | // ---- Variables specifiques em mode transfert DMA vers Ethernet
|
---|
183 | int tcpportid; // No de port TCP/IP
|
---|
184 | // Cote Send DMA -> Ethernet
|
---|
185 | bool pci2eth_fgdirect; // true -> direct transfer DMA to Ethernet
|
---|
186 | vector< vector<string> > eths_targets; // Liste des machines cibles pour les transferts DMA -> ethernet pour chaque fibre
|
---|
187 | vector<string> eths_stargs; // cibles communes pour toutes les fibres
|
---|
188 | map< int, vector<string> > eths_fibtargs; // Cibles specifiees pour les differentes fibres ds les datacards
|
---|
189 | // Cote reception
|
---|
190 | int ethr_nlink; // Nombre total de source d'envoi (= nb total de fibres = nb total liens ethernet)
|
---|
191 | bool ethr_forcesamefc_; // true -> on force receptions de paquets avec SAME FrameCounter sur tous les liens
|
---|
192 | uint_4 ethr_sfc_maxdpc_; // valeur maximum de difference tolere entre compteurs de paquets de differentes fibres
|
---|
193 | uint_4 ethr_sfc_maxresync_; // Nombre maximum de tentative de resynchronisation avant echec
|
---|
194 | bool ethr_waitendmsg_; // true -> EthernetReader attend le message END avant de s'arreter
|
---|
195 |
|
---|
196 | // Identification source observee dans le ciel
|
---|
197 | string skysource;
|
---|
198 |
|
---|
199 | // Variables pour le traitement/monitoring
|
---|
200 | bool fgdoProc; // false -> pas de thread de monitoring
|
---|
201 | uint_4 nmeanProc; // nombre de paquets moyennes par le thread de traitement/monitoring
|
---|
202 | uint_4 stepProc; // 1/stepProc zones traite - si =0 -> fraction de paquets traites depend de la puissance disponible
|
---|
203 | uint_4 nmaxProc; // Nombre de blocs traites par le thread de traitement/monitoring (0-> MaxNbBlocs())
|
---|
204 |
|
---|
205 | // Variables pour le calcul de visibilites
|
---|
206 | bool fgdoVisiC; // true -> calcul des visibilites
|
---|
207 | uint_4 nmeanVisiC; // nombre de paquets moyennes pour les calculs de visibilites
|
---|
208 | bool fgtimeintervalVisiC; // true : sauvegarde matrice de visibilites par intervalle de temps
|
---|
209 | double timeintervalVisiC; // definition de l'intervalle de temps en secondes pour suvegarde de la matrice de visibilites
|
---|
210 | uint_4 nbcalgrpVisiC; // Nb d'objets/threads dans BRVisCalcGroup
|
---|
211 | uint_4 nthrVisiC; // Nb de threads pour l'execution parallele ds BRVisibilityCalculator
|
---|
212 | bool fgfdtVisiC; // true -> fill visibility data tables
|
---|
213 | uint_4 firstpairVisiC, nbpairsVisiC; // Numero premiere visibilites, nombre de visibilites a calculer
|
---|
214 | bool fgpimpVisiC; // true -> calcul visibilite pair-impair + autocorrel
|
---|
215 | uint_4 freqminVisiC, freqmaxVisiC, nbinfreqVisiC; // si zone de frequence/rebinning pour visibilites
|
---|
216 | bool fgfitsVisiC; // true -> sauvegarde des visibilites au format FITS
|
---|
217 |
|
---|
218 | // Pour des tests de performances ou sans carte ADC (pattern)
|
---|
219 | bool monothr ; // pour les test mono thread
|
---|
220 | bool activate_pattern; // true -> on active le pattern du firmware au lieu de la fibre
|
---|
221 |
|
---|
222 | double nopciLossRate; // Utilise avec pour les tests sans carte pciexpress TestPCIWrapperNODMA
|
---|
223 |
|
---|
224 | // Niveau d'impression/debug ...
|
---|
225 | int prtlevel_;
|
---|
226 | long int prtmodulo_;
|
---|
227 | long int prtmodulo2_;
|
---|
228 | };
|
---|
229 |
|
---|
230 | //-----------------------------------------------------------------------------
|
---|
231 | //---- Classe de gestion des parametres d'acquisition -
|
---|
232 | //---- Utilise l'instance global de BRParList
|
---|
233 | //-----------------------------------------------------------------------------
|
---|
234 |
|
---|
235 | class BRAcqConfig {
|
---|
236 | public:
|
---|
237 |
|
---|
238 | BRAcqConfig();
|
---|
239 |
|
---|
240 | inline void ReadParamFile(string file)
|
---|
241 | { param_->ReadDCFile(file); }
|
---|
242 | inline void Set(BRParList& par)
|
---|
243 | { param_->Set(par); }
|
---|
244 | inline void ReadConfigFile(string file)
|
---|
245 | { config_->ReadDCFile(file); }
|
---|
246 | inline void Set(BRConfList& conf)
|
---|
247 | { config_->Set(conf); }
|
---|
248 |
|
---|
249 | ostream& Print(ostream& os);
|
---|
250 |
|
---|
251 | int CreateOutputDirectories();
|
---|
252 |
|
---|
253 | static inline double AcqVersion() { return BAOR_ACQ_VER ; }
|
---|
254 | static inline const char* AcqVersionS() { return BAOR_ACQ_VER_STR ; }
|
---|
255 |
|
---|
256 | inline BRParList& GetParams() { return (*param_) ;};
|
---|
257 | inline BRConfList& GetConfig() { return (*config_) ;};
|
---|
258 |
|
---|
259 | inline BRDataFmtConv GetSwapall() { return param_->swapall; };
|
---|
260 | inline bool GetPattern() { return param_->activate_pattern; };
|
---|
261 | inline bool GetMonothr() { return param_->monothr; };
|
---|
262 | inline bool GetSaveFits() { return param_->savesigfits; };
|
---|
263 | inline bool GetFileDevNull() { return param_->fgnulldev4fits; };
|
---|
264 |
|
---|
265 | // Nombre de fibres pour l'acquisition
|
---|
266 | inline int NFibers() { return param_->NbFibers(); }
|
---|
267 | inline int NbFibers() { return param_->NbFibers(); }
|
---|
268 | // Numeros des fibres pour l'acquisition
|
---|
269 | inline int FiberNum(size_t fib) { return param_->FiberNum(fib); }
|
---|
270 | // Identificateurs des fibres
|
---|
271 | inline int FiberId(size_t fib) { return config_->FiberId( param_->FiberNum(fib) ); }
|
---|
272 |
|
---|
273 | // Taille des operations DMA (en octets)
|
---|
274 | inline uint_4 DMASizeBytes() { return param_->DMASizeBytes(); }
|
---|
275 | // Taille des operations DMA (en KB=1024 bytes)
|
---|
276 | inline uint_4 DMASizeKB() { return param_->DMASizeKB(); }
|
---|
277 | // Taille des paquets recus sur PCIExpress
|
---|
278 | inline uint_4 RecvPaquetSize() { return param_->RecvPaquetSize(); }
|
---|
279 | // Taille des paquets apres reduction eventuelle (donc ds memory manager)
|
---|
280 | inline uint_4 MMgrPaquetSize() { return param_->MMgrPaquetSize(); }
|
---|
281 | // Nombre de paquets dans chaque bloc de MMgr
|
---|
282 | inline uint_4 MMgrNbPaquet() { return param_->MMgrNbPaquet(); }
|
---|
283 | // Operation de conversion/mise en ordre des donnees a la reception
|
---|
284 | inline BRDataFmtConv GetDataConvFg() { return param_->GetDataConvFg(); };
|
---|
285 |
|
---|
286 | // Nombre maximum de fichiers enregistres
|
---|
287 | inline uint_4 MaxNbFiles() { return param_->MaxNbFiles(); }
|
---|
288 | // Nombre de blocs MMgr dans chaque fichiers
|
---|
289 | inline uint_4 BlocPerFile() { return param_->BlocPerFile(); }
|
---|
290 | // Nombre maximum de blocs MMgr traites
|
---|
291 | inline uint_8 MaxNbBlocs() { return param_->MaxNbBlocs(); }
|
---|
292 | // Nombre maximum paquets traites
|
---|
293 | inline uint_8 MaxNbPaquets() { return param_->MaxNbPaquets(); }
|
---|
294 |
|
---|
295 | // Identification source ciel
|
---|
296 | inline string& SkySource() { return param_->SkySource(); }
|
---|
297 |
|
---|
298 | // repertoire d'acquisition
|
---|
299 | inline string OutputDirectory() { return (config_->BaseDirectory()+param_->OutPathName); }
|
---|
300 | string OutputDirectoryFib(int fib);
|
---|
301 | // repertoire temporaire
|
---|
302 | inline const string& TmpDirectory() const { return config_->TmpDirectory(); }
|
---|
303 |
|
---|
304 | protected:
|
---|
305 | static BRParList* param_;
|
---|
306 | static BRConfList* config_;
|
---|
307 | };
|
---|
308 |
|
---|
309 |
|
---|
310 | #endif
|
---|