| 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 fgsinglechannel; // true -> un seul canal par fibre (par defaut=2 canaux/fibres)
 | 
|---|
| 146 | 
 | 
|---|
| 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
 | 
|---|
| 149 | 
 | 
|---|
| 150 |   string OutPathName;  // directory de base
 | 
|---|
| 151 |   string ProcPathName; 
 | 
|---|
| 152 |   uint_4 PaqSize ; // taille des paquets ou sizeFrame 
 | 
|---|
| 153 | 
 | 
|---|
| 154 |   // Controle/gestion  du DMA 
 | 
|---|
| 155 |   uint_4 dmasizekb ; // taille du dma en multiple de 2 (2 a 56)
 | 
|---|
| 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 | 
 | 
|---|
| 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 
 | 
|---|
| 176 |   bool reducneedcopy;   // true -> besoin de copie intermediaire pour la reduction de taille de paquets
 | 
|---|
| 177 |   BRPaqReducAction pqreducmode; 
 | 
|---|
| 178 |   uint_4 redpqsize; 
 | 
|---|
| 179 |   uint_4 reducoffset; 
 | 
|---|
| 180 | 
 | 
|---|
| 181 |   // ---- Variables specifiques em mode transfert DMA vers Ethernet 
 | 
|---|
| 182 |   int tcpportid;     // No de port TCP/IP
 | 
|---|
| 183 |   // Cote Send DMA -> Ethernet 
 | 
|---|
| 184 |   bool pci2eth_fgdirect;   // true -> direct transfer DMA to Ethernet  
 | 
|---|
| 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
 | 
|---|
| 188 |   // Cote reception 
 | 
|---|
| 189 |   int ethr_nlink;    // Nombre total de source d'envoi (= nb total de fibres = nb total liens ethernet) 
 | 
|---|
| 190 |   bool ethr_forcesamefc_;   // true -> on force receptions de paquets avec SAME FrameCounter sur tous les liens 
 | 
|---|
| 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
 | 
|---|
| 193 |   bool ethr_waitendmsg_;   // true -> EthernetReader attend le message END avant de s'arreter 
 | 
|---|
| 194 | 
 | 
|---|
| 195 |   // Identification source observee dans le ciel
 | 
|---|
| 196 |   string skysource;
 | 
|---|
| 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 |  
 | 
|---|
| 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
 | 
|---|
| 209 |   uint_4 freqminVisiC, freqmaxVisiC, nbinfreqVisiC;  // si zone de frequence/rebinning pour visibilites
 | 
|---|
| 210 | 
 | 
|---|
| 211 |    
 | 
|---|
| 212 |   // Pour des tests de performances ou sans carte ADC (pattern) 
 | 
|---|
| 213 |   bool monothr ;           // pour les test mono thread 
 | 
|---|
| 214 |   bool activate_pattern;  // true -> on active le pattern du firmware au lieu de la fibre
 | 
|---|
| 215 | 
 | 
|---|
| 216 |   double nopciLossRate;   // Utilise avec pour les tests sans carte pciexpress TestPCIWrapperNODMA
 | 
|---|
| 217 | 
 | 
|---|
| 218 |   // Niveau d'impression/debug ...
 | 
|---|
| 219 |   int prtlevel_;
 | 
|---|
| 220 |   long int prtmodulo_; 
 | 
|---|
| 221 | };
 | 
|---|
| 222 | 
 | 
|---|
| 223 | //-----------------------------------------------------------------------------
 | 
|---|
| 224 | //---- Classe de gestion des parametres d'acquisition - 
 | 
|---|
| 225 | //---- Utilise l'instance global de BRParList
 | 
|---|
| 226 | //-----------------------------------------------------------------------------
 | 
|---|
| 227 | 
 | 
|---|
| 228 | class BRAcqConfig {
 | 
|---|
| 229 |  public:  
 | 
|---|
| 230 |   
 | 
|---|
| 231 |   BRAcqConfig();
 | 
|---|
| 232 | 
 | 
|---|
| 233 |   inline void ReadParamFile(string file) 
 | 
|---|
| 234 |     { param_->ReadDCFile(file); }
 | 
|---|
| 235 |   inline void Set(BRParList& par)
 | 
|---|
| 236 |     { param_->Set(par); }
 | 
|---|
| 237 |   inline void ReadConfigFile(string file) 
 | 
|---|
| 238 |     { config_->ReadDCFile(file); }
 | 
|---|
| 239 |   inline void Set(BRConfList& conf)
 | 
|---|
| 240 |     { config_->Set(conf); }
 | 
|---|
| 241 | 
 | 
|---|
| 242 |   ostream& Print(ostream& os);
 | 
|---|
| 243 | 
 | 
|---|
| 244 |   int CreateOutputDirectories();
 | 
|---|
| 245 | 
 | 
|---|
| 246 |   static inline double AcqVersion()  { return BAOR_ACQ_VER ; }
 | 
|---|
| 247 |   static inline const char* AcqVersionS() { return BAOR_ACQ_VER_STR ; } 
 | 
|---|
| 248 | 
 | 
|---|
| 249 |   inline BRParList&  GetParams() { return (*param_) ;};
 | 
|---|
| 250 |   inline BRConfList&  GetConfig() { return (*config_) ;};
 | 
|---|
| 251 |   
 | 
|---|
| 252 |   inline BRDataFmtConv GetSwapall() { return param_->swapall; };
 | 
|---|
| 253 |   inline bool GetPattern() { return param_->activate_pattern; };
 | 
|---|
| 254 |   inline bool GetMonothr() { return param_->monothr; };
 | 
|---|
| 255 |   inline bool GetSaveFits() { return param_->savesigfits; };
 | 
|---|
| 256 |   inline bool GetFileDevNull() { return param_->fgnulldev4fits; };
 | 
|---|
| 257 | 
 | 
|---|
| 258 |   // Nombre de fibres pour l'acquisition 
 | 
|---|
| 259 |   inline int  NFibers() { return param_->NbFibers(); } 
 | 
|---|
| 260 |   inline int  NbFibers() { return param_->NbFibers(); } 
 | 
|---|
| 261 |   // Numeros des fibres pour l'acquisition 
 | 
|---|
| 262 |   inline int FiberNum(size_t fib) { return param_->FiberNum(fib); } 
 | 
|---|
| 263 |   // Identificateurs des fibres 
 | 
|---|
| 264 |   inline int FiberId(size_t fib) { return config_->FiberId( param_->FiberNum(fib) ); }
 | 
|---|
| 265 | 
 | 
|---|
| 266 |   // Taille des operations DMA (en octets) 
 | 
|---|
| 267 |   inline uint_4 DMASizeBytes() { return param_->DMASizeBytes(); }
 | 
|---|
| 268 |   // Taille des operations DMA (en KB=1024 bytes) 
 | 
|---|
| 269 |   inline uint_4 DMASizeKB() { return param_->DMASizeKB(); }
 | 
|---|
| 270 |   // Taille des paquets recus sur PCIExpress 
 | 
|---|
| 271 |   inline uint_4 RecvPaquetSize() { return param_->RecvPaquetSize();  }
 | 
|---|
| 272 |   // Taille des paquets apres reduction eventuelle (donc ds memory manager)
 | 
|---|
| 273 |   inline uint_4 MMgrPaquetSize() { return param_->MMgrPaquetSize(); }
 | 
|---|
| 274 |   // Nombre de paquets dans chaque bloc de MMgr 
 | 
|---|
| 275 |   inline uint_4 MMgrNbPaquet() { return param_->MMgrNbPaquet(); }
 | 
|---|
| 276 |   // Operation de conversion/mise en ordre des donnees a la reception 
 | 
|---|
| 277 |   inline BRDataFmtConv GetDataConvFg() { return param_->GetDataConvFg(); };
 | 
|---|
| 278 | 
 | 
|---|
| 279 |   // Nombre maximum de fichiers enregistres 
 | 
|---|
| 280 |   inline uint_4 MaxNbFiles() { return param_->MaxNbFiles(); }
 | 
|---|
| 281 |   // Nombre de blocs MMgr dans chaque fichiers 
 | 
|---|
| 282 |   inline uint_4 BlocPerFile() { return param_->BlocPerFile(); }
 | 
|---|
| 283 |   // Nombre maximum de blocs MMgr traites 
 | 
|---|
| 284 |   inline uint_8 MaxNbBlocs() { return param_->MaxNbBlocs(); }
 | 
|---|
| 285 |   // Nombre maximum paquets traites 
 | 
|---|
| 286 |   inline uint_8 MaxNbPaquets() { return param_->MaxNbPaquets(); }
 | 
|---|
| 287 | 
 | 
|---|
| 288 |   // Identification source ciel 
 | 
|---|
| 289 |   inline string& SkySource() { return param_->SkySource(); }
 | 
|---|
| 290 | 
 | 
|---|
| 291 |   // repertoire d'acquisition 
 | 
|---|
| 292 |   inline string OutputDirectory() { return (config_->BaseDirectory()+param_->OutPathName); }
 | 
|---|
| 293 |   string OutputDirectoryFib(int fib);
 | 
|---|
| 294 |   // repertoire temporaire
 | 
|---|
| 295 |   inline const string& TmpDirectory() const { return config_->TmpDirectory(); }
 | 
|---|
| 296 | 
 | 
|---|
| 297 |  protected:
 | 
|---|
| 298 |   static BRParList* param_;
 | 
|---|
| 299 |   static BRConfList* config_;
 | 
|---|
| 300 | };
 | 
|---|
| 301 | 
 | 
|---|
| 302 | 
 | 
|---|
| 303 | #endif
 | 
|---|