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