[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)
|
---|
| 145 | bool fgsinglechannel; // true -> un seul canal par fibre (par defaut=2 canaux/fibres)
|
---|
| 146 |
|
---|
[3913] | 147 | string FiberListS ; // String_liste des numeros de fibres a utiliser 1,3,4 par exemple
|
---|
| 148 | vector<int> fiberNum_; // liste des numeros fibres a utiliser {1,3,4} par exemple
|
---|
[3671] | 149 |
|
---|
| 150 | string OutPathName; // directory de base
|
---|
| 151 | string ProcPathName;
|
---|
[3674] | 152 | uint_4 PaqSize ; // taille des paquets ou sizeFrame
|
---|
[3909] | 153 |
|
---|
| 154 | // Controle/gestion du DMA
|
---|
[3674] | 155 | uint_4 dmasizekb ; // taille du dma en multiple de 2 (2 a 56)
|
---|
[3909] | 156 | unsigned int maxkwedma_; // Nombre d'iterations de la boucle d'attente de fin de DMA (en unite de 1000)
|
---|
| 157 | unsigned int nretrydma_; // nombre maxi de tentatives pour terminer le DMA
|
---|
| 158 | unsigned int first_maxkwedma_; // Nombre d'iterations de la boucle d'attente de fin du PREMIER DMA (u 1000)
|
---|
| 159 | unsigned int first_nretrydma_; // nombre maxi de tentatives pour terminer le PREMIER DMA
|
---|
| 160 |
|
---|
[3671] | 161 | int NbFiles; // nombre de fichier produits
|
---|
| 162 | int NBlocPerFile; // nombre de bloc par fichier
|
---|
| 163 | // Gestionnaire zones memoire
|
---|
| 164 | uint_4 nZones; // Nombre de zones memoires
|
---|
| 165 | uint_4 nPaqZone; // 128 Paquets / zone memoire - valeur par defaut
|
---|
| 166 |
|
---|
| 167 | bool fg_hard_ctrlc ; // autorise le CtrlC si true
|
---|
| 168 |
|
---|
| 169 | bool savesigfits ; // si true on prduit de sfichier fits
|
---|
| 170 | bool fgnulldev4fits ;
|
---|
| 171 |
|
---|
| 172 | BRDataFmtConv swapall ; // type de l'acquisition voir brpaqu.h
|
---|
| 173 |
|
---|
| 174 | // ---- Pour gerer la reduction des tailles de paquets
|
---|
| 175 | bool fgreducpsize; // true -> reduction taille des paquets
|
---|
[3674] | 176 | bool reducneedcopy; // true -> besoin de copie intermediaire pour la reduction de taille de paquets
|
---|
[3673] | 177 | BRPaqReducAction pqreducmode;
|
---|
[3671] | 178 | uint_4 redpqsize;
|
---|
| 179 | uint_4 reducoffset;
|
---|
| 180 |
|
---|
[3757] | 181 | // ---- Variables specifiques em mode transfert DMA vers Ethernet
|
---|
[3760] | 182 | int tcpportid; // No de port TCP/IP
|
---|
[3757] | 183 | // Cote Send DMA -> Ethernet
|
---|
| 184 | bool pci2eth_fgdirect; // true -> direct transfer DMA to Ethernet
|
---|
[3913] | 185 | vector< vector<string> > eths_targets; // Liste des machines cibles pour les transferts DMA -> ethernet pour chaque fibre
|
---|
| 186 | vector<string> eths_stargs; // cibles communes pour toutes les fibres
|
---|
| 187 | map< int, vector<string> > eths_fibtargs; // Cibles specifiees pour les differentes fibres ds les datacards
|
---|
[3757] | 188 | // Cote reception
|
---|
[3913] | 189 | int ethr_nlink; // Nombre total de source d'envoi (= nb total de fibres = nb total liens ethernet)
|
---|
[3883] | 190 | bool ethr_forcesamefc_; // true -> on force receptions de paquets avec SAME FrameCounter sur tous les liens
|
---|
[3897] | 191 | uint_4 ethr_sfc_maxdpc_; // valeur maximum de difference tolere entre compteurs de paquets de differentes fibres
|
---|
| 192 | uint_4 ethr_sfc_maxresync_; // Nombre maximum de tentative de resynchronisation avant echec
|
---|
[3899] | 193 | bool ethr_waitendmsg_; // true -> EthernetReader attend le message END avant de s'arreter
|
---|
| 194 |
|
---|
[3674] | 195 | // Identification source observee dans le ciel
|
---|
| 196 | string skysource;
|
---|
[3681] | 197 |
|
---|
| 198 | // Variables pour le traitement/monitoring
|
---|
| 199 | bool fgdoProc; // false -> pas de thread de monitoring
|
---|
| 200 | uint_4 nmeanProc; // nombre de paquets moyennes par le thread de traitement/monitoring
|
---|
| 201 | uint_4 stepProc; // 1/stepProc zones traite - si =0 -> fraction de paquets traites depend de la puissance disponible
|
---|
| 202 | uint_4 nmaxProc; // Nombre de blocs traites par le thread de traitement/monitoring (0-> MaxNbBlocs())
|
---|
| 203 |
|
---|
[3876] | 204 | // Variables pour le calcul de visibilites
|
---|
| 205 | bool fgdoVisiC; // true -> calcul des visibilites
|
---|
| 206 | uint_4 nmeanVisiC; // nombre de paquets moyennes pour les calculs de visibilites
|
---|
| 207 | uint_4 nbcalgrpVisiC; // Nb d'objets/threads dans BRVisCalcGroup
|
---|
| 208 | uint_4 nthrVisiC; // Nb de threads pour l'execution parallele ds BRVisibilityCalculator
|
---|
[3915] | 209 | uint_4 firstpairVisiC, nbpairsVisiC; // Numero premiere visibilites, nombre de visibilites a calculer
|
---|
| 210 | bool fgpimpVisiC; // true -> calcul visibilite pair-impair + autocorrel
|
---|
[3876] | 211 | uint_4 freqminVisiC, freqmaxVisiC, nbinfreqVisiC; // si zone de frequence/rebinning pour visibilites
|
---|
| 212 |
|
---|
| 213 |
|
---|
[3671] | 214 | // Pour des tests de performances ou sans carte ADC (pattern)
|
---|
| 215 | bool monothr ; // pour les test mono thread
|
---|
| 216 | bool activate_pattern; // true -> on active le pattern du firmware au lieu de la fibre
|
---|
| 217 |
|
---|
| 218 | double nopciLossRate; // Utilise avec pour les tests sans carte pciexpress TestPCIWrapperNODMA
|
---|
[3883] | 219 |
|
---|
| 220 | // Niveau d'impression/debug ...
|
---|
| 221 | int prtlevel_;
|
---|
| 222 | long int prtmodulo_;
|
---|
[3671] | 223 | };
|
---|
| 224 |
|
---|
| 225 | //-----------------------------------------------------------------------------
|
---|
| 226 | //---- Classe de gestion des parametres d'acquisition -
|
---|
| 227 | //---- Utilise l'instance global de BRParList
|
---|
| 228 | //-----------------------------------------------------------------------------
|
---|
| 229 |
|
---|
| 230 | class BRAcqConfig {
|
---|
| 231 | public:
|
---|
| 232 |
|
---|
| 233 | BRAcqConfig();
|
---|
| 234 |
|
---|
[3672] | 235 | inline void ReadParamFile(string file)
|
---|
[3671] | 236 | { param_->ReadDCFile(file); }
|
---|
| 237 | inline void Set(BRParList& par)
|
---|
| 238 | { param_->Set(par); }
|
---|
[3672] | 239 | inline void ReadConfigFile(string file)
|
---|
| 240 | { config_->ReadDCFile(file); }
|
---|
| 241 | inline void Set(BRConfList& conf)
|
---|
| 242 | { config_->Set(conf); }
|
---|
[3671] | 243 |
|
---|
[3672] | 244 | ostream& Print(ostream& os);
|
---|
| 245 |
|
---|
[3671] | 246 | int CreateOutputDirectories();
|
---|
| 247 |
|
---|
| 248 | static inline double AcqVersion() { return BAOR_ACQ_VER ; }
|
---|
| 249 | static inline const char* AcqVersionS() { return BAOR_ACQ_VER_STR ; }
|
---|
[3672] | 250 |
|
---|
[3671] | 251 | inline BRParList& GetParams() { return (*param_) ;};
|
---|
[3672] | 252 | inline BRConfList& GetConfig() { return (*config_) ;};
|
---|
| 253 |
|
---|
[3671] | 254 | inline BRDataFmtConv GetSwapall() { return param_->swapall; };
|
---|
| 255 | inline bool GetPattern() { return param_->activate_pattern; };
|
---|
| 256 | inline bool GetMonothr() { return param_->monothr; };
|
---|
| 257 | inline bool GetSaveFits() { return param_->savesigfits; };
|
---|
| 258 | inline bool GetFileDevNull() { return param_->fgnulldev4fits; };
|
---|
| 259 |
|
---|
[3913] | 260 | // Nombre de fibres pour l'acquisition
|
---|
[3909] | 261 | inline int NFibers() { return param_->NbFibers(); }
|
---|
| 262 | inline int NbFibers() { return param_->NbFibers(); }
|
---|
[3913] | 263 | // Numeros des fibres pour l'acquisition
|
---|
| 264 | inline int FiberNum(size_t fib) { return param_->FiberNum(fib); }
|
---|
| 265 | // Identificateurs des fibres
|
---|
| 266 | inline int FiberId(size_t fib) { return config_->FiberId( param_->FiberNum(fib) ); }
|
---|
[3909] | 267 |
|
---|
[3671] | 268 | // Taille des operations DMA (en octets)
|
---|
| 269 | inline uint_4 DMASizeBytes() { return param_->DMASizeBytes(); }
|
---|
| 270 | // Taille des operations DMA (en KB=1024 bytes)
|
---|
| 271 | inline uint_4 DMASizeKB() { return param_->DMASizeKB(); }
|
---|
| 272 | // Taille des paquets recus sur PCIExpress
|
---|
| 273 | inline uint_4 RecvPaquetSize() { return param_->RecvPaquetSize(); }
|
---|
| 274 | // Taille des paquets apres reduction eventuelle (donc ds memory manager)
|
---|
| 275 | inline uint_4 MMgrPaquetSize() { return param_->MMgrPaquetSize(); }
|
---|
[3757] | 276 | // Nombre de paquets dans chaque bloc de MMgr
|
---|
| 277 | inline uint_4 MMgrNbPaquet() { return param_->MMgrNbPaquet(); }
|
---|
[3671] | 278 | // Operation de conversion/mise en ordre des donnees a la reception
|
---|
| 279 | inline BRDataFmtConv GetDataConvFg() { return param_->GetDataConvFg(); };
|
---|
| 280 |
|
---|
| 281 | // Nombre maximum de fichiers enregistres
|
---|
| 282 | inline uint_4 MaxNbFiles() { return param_->MaxNbFiles(); }
|
---|
| 283 | // Nombre de blocs MMgr dans chaque fichiers
|
---|
| 284 | inline uint_4 BlocPerFile() { return param_->BlocPerFile(); }
|
---|
| 285 | // Nombre maximum de blocs MMgr traites
|
---|
[3757] | 286 | inline uint_8 MaxNbBlocs() { return param_->MaxNbBlocs(); }
|
---|
| 287 | // Nombre maximum paquets traites
|
---|
| 288 | inline uint_8 MaxNbPaquets() { return param_->MaxNbPaquets(); }
|
---|
[3671] | 289 |
|
---|
[3674] | 290 | // Identification source ciel
|
---|
| 291 | inline string& SkySource() { return param_->SkySource(); }
|
---|
| 292 |
|
---|
[3671] | 293 | // repertoire d'acquisition
|
---|
[3672] | 294 | inline string OutputDirectory() { return (config_->BaseDirectory()+param_->OutPathName); }
|
---|
[3671] | 295 | string OutputDirectoryFib(int fib);
|
---|
[3913] | 296 | // repertoire temporaire
|
---|
| 297 | inline const string& TmpDirectory() const { return config_->TmpDirectory(); }
|
---|
[3671] | 298 |
|
---|
| 299 | protected:
|
---|
| 300 | static BRParList* param_;
|
---|
[3672] | 301 | static BRConfList* config_;
|
---|
[3671] | 302 | };
|
---|
| 303 |
|
---|
| 304 |
|
---|
| 305 | #endif
|
---|