[3671] | 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 | //---------------------------------------------------------------
|
---|
[3672] | 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
|
---|
[3671] | 14 | // (nombre de cartes, versions firwares ...)
|
---|
[3672] | 15 | // + BRAcqConfig : Classe donnant acces a un objet global BRParList et
|
---|
[3671] | 16 | // un objet global BRConfList
|
---|
| 17 | //---------------------------------------------------------------
|
---|
| 18 |
|
---|
| 19 | #include "machdefs.h"
|
---|
| 20 | #include <string>
|
---|
[3672] | 21 | #include <vector>
|
---|
[3913] | 22 | #include <map>
|
---|
[3672] | 23 | #include <iostream>
|
---|
[3671] | 24 | #include "brpaqu.h"
|
---|
| 25 | #include "datacards.h"
|
---|
| 26 | #include "bracqvers.h"
|
---|
| 27 |
|
---|
| 28 | using namespace std;
|
---|
| 29 | using namespace SOPHYA;
|
---|
| 30 |
|
---|
[3672] | 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);
|
---|
[3674] | 63 |
|
---|
[3913] | 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 |
|
---|
[3672] | 70 | ostream& Print(ostream& os) ;
|
---|
| 71 | void ReadDCFile(string file);
|
---|
[3674] | 72 | inline const string& BaseDirectory() const { return basedir_; }
|
---|
[3913] | 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
|
---|
[3672] | 79 | //.......................................
|
---|
| 80 | string basedir_;
|
---|
| 81 | vector<ADCBoardDesc> boards_;
|
---|
[3913] | 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
|
---|
[3672] | 85 | };
|
---|
| 86 |
|
---|
[3671] | 87 |
|
---|
| 88 | //-----------------------------------------------------------------------------
|
---|
| 89 | //---- Classe de liste des parametres d'acquisition BAORadio
|
---|
| 90 | class BRParList {
|
---|
| 91 | public:
|
---|
[3681] | 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);
|
---|
[3671] | 95 |
|
---|
| 96 | BRParList(BRParList const & p);
|
---|
| 97 |
|
---|
| 98 | void Set(BRParList const & p);
|
---|
| 99 | ostream& Print(ostream& os) ;
|
---|
| 100 | void ReadDCFile(string file);
|
---|
| 101 |
|
---|
[3913] | 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; }
|
---|
[3671] | 108 | // Taille des operations DMA (en octets)
|
---|
[3674] | 109 | inline uint_4 DMASizeBytes() { return dmasizekb*1024; }
|
---|
[3671] | 110 | // Taille des operations DMA (en KB=1024 bytes)
|
---|
[3674] | 111 | inline uint_4 DMASizeKB() { return dmasizekb; }
|
---|
[3671] | 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; }
|
---|
[3757] | 116 | // Nombre de paquets dans chaque bloc de MMgr
|
---|
| 117 | inline uint_4 MMgrNbPaquet() { return nPaqZone; }
|
---|
[3671] | 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
|
---|
[3757] | 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; }
|
---|
[3671] | 129 |
|
---|
[3680] | 130 | // Taille des paquets recus sur PCIExpress
|
---|
| 131 | inline uint_4 PatternSize() { return ((PaqSize-(BRHDRSIZE+BRTRLSIZE))/4); }
|
---|
| 132 |
|
---|
[3913] | 133 | inline vector< vector<string> >& GetEthTargets() { return eths_targets; }
|
---|
[3757] | 134 | // Nombre de liens ethernet comme source de donnees (paquets)
|
---|
| 135 | inline int NbEthLinks() { return ethr_nlink; }
|
---|
| 136 |
|
---|
[3674] | 137 | // Identification source ciel
|
---|
| 138 | inline string& SkySource() { return skysource; }
|
---|
| 139 |
|
---|
[3671] | 140 | //..........................................
|
---|
| 141 | void Decode();
|
---|
| 142 |
|
---|
| 143 | string AcqMode; // Mode d'acquisition (conditionne la mise en ordre/conversion des donnees lues par DMA
|
---|
[3681] | 144 | bool fgdatafft; // true -> donnee FFT (provenant du firmware FFT)
|
---|
[3918] | 145 | bool fgfftshrink; // true -> donnee FFT tronquee [NumFreq=2048...3072] (provenant du firmware FFT)
|
---|
[3681] | 146 | bool fgsinglechannel; // true -> un seul canal par fibre (par defaut=2 canaux/fibres)
|
---|
| 147 |
|
---|
[3913] | 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
|
---|
[3671] | 150 |
|
---|
| 151 | string OutPathName; // directory de base
|
---|
| 152 | string ProcPathName;
|
---|
[3674] | 153 | uint_4 PaqSize ; // taille des paquets ou sizeFrame
|
---|
[3909] | 154 |
|
---|
| 155 | // Controle/gestion du DMA
|
---|
[3674] | 156 | uint_4 dmasizekb ; // taille du dma en multiple de 2 (2 a 56)
|
---|
[3909] | 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 |
|
---|
[3671] | 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
|
---|
[3674] | 177 | bool reducneedcopy; // true -> besoin de copie intermediaire pour la reduction de taille de paquets
|
---|
[3673] | 178 | BRPaqReducAction pqreducmode;
|
---|
[3671] | 179 | uint_4 redpqsize;
|
---|
| 180 | uint_4 reducoffset;
|
---|
| 181 |
|
---|
[3757] | 182 | // ---- Variables specifiques em mode transfert DMA vers Ethernet
|
---|
[3760] | 183 | int tcpportid; // No de port TCP/IP
|
---|
[3757] | 184 | // Cote Send DMA -> Ethernet
|
---|
| 185 | bool pci2eth_fgdirect; // true -> direct transfer DMA to Ethernet
|
---|
[3913] | 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
|
---|
[3757] | 189 | // Cote reception
|
---|
[3913] | 190 | int ethr_nlink; // Nombre total de source d'envoi (= nb total de fibres = nb total liens ethernet)
|
---|
[3883] | 191 | bool ethr_forcesamefc_; // true -> on force receptions de paquets avec SAME FrameCounter sur tous les liens
|
---|
[3897] | 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
|
---|
[3899] | 194 | bool ethr_waitendmsg_; // true -> EthernetReader attend le message END avant de s'arreter
|
---|
| 195 |
|
---|
[3674] | 196 | // Identification source observee dans le ciel
|
---|
| 197 | string skysource;
|
---|
[3681] | 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 |
|
---|
[3876] | 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 | uint_4 nbcalgrpVisiC; // Nb d'objets/threads dans BRVisCalcGroup
|
---|
| 209 | uint_4 nthrVisiC; // Nb de threads pour l'execution parallele ds BRVisibilityCalculator
|
---|
[3920] | 210 | bool fgfdtVisiC; // true -> fill visibility data tables
|
---|
[3915] | 211 | uint_4 firstpairVisiC, nbpairsVisiC; // Numero premiere visibilites, nombre de visibilites a calculer
|
---|
| 212 | bool fgpimpVisiC; // true -> calcul visibilite pair-impair + autocorrel
|
---|
[3876] | 213 | uint_4 freqminVisiC, freqmaxVisiC, nbinfreqVisiC; // si zone de frequence/rebinning pour visibilites
|
---|
| 214 |
|
---|
| 215 |
|
---|
[3671] | 216 | // Pour des tests de performances ou sans carte ADC (pattern)
|
---|
| 217 | bool monothr ; // pour les test mono thread
|
---|
| 218 | bool activate_pattern; // true -> on active le pattern du firmware au lieu de la fibre
|
---|
| 219 |
|
---|
| 220 | double nopciLossRate; // Utilise avec pour les tests sans carte pciexpress TestPCIWrapperNODMA
|
---|
[3883] | 221 |
|
---|
| 222 | // Niveau d'impression/debug ...
|
---|
| 223 | int prtlevel_;
|
---|
| 224 | long int prtmodulo_;
|
---|
[3671] | 225 | };
|
---|
| 226 |
|
---|
| 227 | //-----------------------------------------------------------------------------
|
---|
| 228 | //---- Classe de gestion des parametres d'acquisition -
|
---|
| 229 | //---- Utilise l'instance global de BRParList
|
---|
| 230 | //-----------------------------------------------------------------------------
|
---|
| 231 |
|
---|
| 232 | class BRAcqConfig {
|
---|
| 233 | public:
|
---|
| 234 |
|
---|
| 235 | BRAcqConfig();
|
---|
| 236 |
|
---|
[3672] | 237 | inline void ReadParamFile(string file)
|
---|
[3671] | 238 | { param_->ReadDCFile(file); }
|
---|
| 239 | inline void Set(BRParList& par)
|
---|
| 240 | { param_->Set(par); }
|
---|
[3672] | 241 | inline void ReadConfigFile(string file)
|
---|
| 242 | { config_->ReadDCFile(file); }
|
---|
| 243 | inline void Set(BRConfList& conf)
|
---|
| 244 | { config_->Set(conf); }
|
---|
[3671] | 245 |
|
---|
[3672] | 246 | ostream& Print(ostream& os);
|
---|
| 247 |
|
---|
[3671] | 248 | int CreateOutputDirectories();
|
---|
| 249 |
|
---|
| 250 | static inline double AcqVersion() { return BAOR_ACQ_VER ; }
|
---|
| 251 | static inline const char* AcqVersionS() { return BAOR_ACQ_VER_STR ; }
|
---|
[3672] | 252 |
|
---|
[3671] | 253 | inline BRParList& GetParams() { return (*param_) ;};
|
---|
[3672] | 254 | inline BRConfList& GetConfig() { return (*config_) ;};
|
---|
| 255 |
|
---|
[3671] | 256 | inline BRDataFmtConv GetSwapall() { return param_->swapall; };
|
---|
| 257 | inline bool GetPattern() { return param_->activate_pattern; };
|
---|
| 258 | inline bool GetMonothr() { return param_->monothr; };
|
---|
| 259 | inline bool GetSaveFits() { return param_->savesigfits; };
|
---|
| 260 | inline bool GetFileDevNull() { return param_->fgnulldev4fits; };
|
---|
| 261 |
|
---|
[3913] | 262 | // Nombre de fibres pour l'acquisition
|
---|
[3909] | 263 | inline int NFibers() { return param_->NbFibers(); }
|
---|
| 264 | inline int NbFibers() { return param_->NbFibers(); }
|
---|
[3913] | 265 | // Numeros des fibres pour l'acquisition
|
---|
| 266 | inline int FiberNum(size_t fib) { return param_->FiberNum(fib); }
|
---|
| 267 | // Identificateurs des fibres
|
---|
| 268 | inline int FiberId(size_t fib) { return config_->FiberId( param_->FiberNum(fib) ); }
|
---|
[3909] | 269 |
|
---|
[3671] | 270 | // Taille des operations DMA (en octets)
|
---|
| 271 | inline uint_4 DMASizeBytes() { return param_->DMASizeBytes(); }
|
---|
| 272 | // Taille des operations DMA (en KB=1024 bytes)
|
---|
| 273 | inline uint_4 DMASizeKB() { return param_->DMASizeKB(); }
|
---|
| 274 | // Taille des paquets recus sur PCIExpress
|
---|
| 275 | inline uint_4 RecvPaquetSize() { return param_->RecvPaquetSize(); }
|
---|
| 276 | // Taille des paquets apres reduction eventuelle (donc ds memory manager)
|
---|
| 277 | inline uint_4 MMgrPaquetSize() { return param_->MMgrPaquetSize(); }
|
---|
[3757] | 278 | // Nombre de paquets dans chaque bloc de MMgr
|
---|
| 279 | inline uint_4 MMgrNbPaquet() { return param_->MMgrNbPaquet(); }
|
---|
[3671] | 280 | // Operation de conversion/mise en ordre des donnees a la reception
|
---|
| 281 | inline BRDataFmtConv GetDataConvFg() { return param_->GetDataConvFg(); };
|
---|
| 282 |
|
---|
| 283 | // Nombre maximum de fichiers enregistres
|
---|
| 284 | inline uint_4 MaxNbFiles() { return param_->MaxNbFiles(); }
|
---|
| 285 | // Nombre de blocs MMgr dans chaque fichiers
|
---|
| 286 | inline uint_4 BlocPerFile() { return param_->BlocPerFile(); }
|
---|
| 287 | // Nombre maximum de blocs MMgr traites
|
---|
[3757] | 288 | inline uint_8 MaxNbBlocs() { return param_->MaxNbBlocs(); }
|
---|
| 289 | // Nombre maximum paquets traites
|
---|
| 290 | inline uint_8 MaxNbPaquets() { return param_->MaxNbPaquets(); }
|
---|
[3671] | 291 |
|
---|
[3674] | 292 | // Identification source ciel
|
---|
| 293 | inline string& SkySource() { return param_->SkySource(); }
|
---|
| 294 |
|
---|
[3671] | 295 | // repertoire d'acquisition
|
---|
[3672] | 296 | inline string OutputDirectory() { return (config_->BaseDirectory()+param_->OutPathName); }
|
---|
[3671] | 297 | string OutputDirectoryFib(int fib);
|
---|
[3913] | 298 | // repertoire temporaire
|
---|
| 299 | inline const string& TmpDirectory() const { return config_->TmpDirectory(); }
|
---|
[3671] | 300 |
|
---|
| 301 | protected:
|
---|
| 302 | static BRParList* param_;
|
---|
[3672] | 303 | static BRConfList* config_;
|
---|
[3671] | 304 | };
|
---|
| 305 |
|
---|
| 306 |
|
---|
| 307 | #endif
|
---|