| 1 | #include <stdlib.h>
|
|---|
| 2 |
|
|---|
| 3 | #include "brparam.h"
|
|---|
| 4 | #include "strutilxx.h"
|
|---|
| 5 | #include "bracqvers.h"
|
|---|
| 6 |
|
|---|
| 7 | #ifndef BRSPORTID
|
|---|
| 8 | #define BRSPORTID 6912
|
|---|
| 9 | #endif
|
|---|
| 10 |
|
|---|
| 11 | /*!
|
|---|
| 12 | \class ADCBoardDesc
|
|---|
| 13 | \ingroup TAcq
|
|---|
| 14 |
|
|---|
| 15 | \brief ADC board description (board Id, firmware type, version ...)
|
|---|
| 16 | */
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | /* --Methode-- */
|
|---|
| 20 | ADCBoardDesc::ADCBoardDesc(int id, string sbid, string cyc_firmw, string str1_firmw, string str2_firmw)
|
|---|
| 21 | : id_(id), sbid_(sbid), cyclone_firmware_(cyc_firmw), stratix1_firmware_(str1_firmw), stratix2_firmware_(str2_firmw)
|
|---|
| 22 | {
|
|---|
| 23 |
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | /* --Methode-- */
|
|---|
| 27 | ADCBoardDesc::ADCBoardDesc(ADCBoardDesc const& bdes)
|
|---|
| 28 | : id_(bdes.id_), sbid_(bdes.sbid_), cyclone_firmware_(bdes.cyclone_firmware_),
|
|---|
| 29 | stratix1_firmware_(bdes.stratix1_firmware_), stratix2_firmware_(bdes.stratix2_firmware_)
|
|---|
| 30 | {
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | /* --Methode-- */
|
|---|
| 34 | ADCBoardDesc& ADCBoardDesc::Set(ADCBoardDesc const & bdes)
|
|---|
| 35 | {
|
|---|
| 36 | id_ = bdes.id_;
|
|---|
| 37 | sbid_ = bdes.sbid_;
|
|---|
| 38 | cyclone_firmware_ = bdes.cyclone_firmware_;
|
|---|
| 39 | stratix1_firmware_ = bdes.stratix1_firmware_;
|
|---|
| 40 | stratix2_firmware_ = bdes.stratix2_firmware_;
|
|---|
| 41 | return(*this);
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | /* --Methode-- */
|
|---|
| 45 | ostream& ADCBoardDesc::Print(ostream& os)
|
|---|
| 46 | {
|
|---|
| 47 | os << "ADCBoard#" << id_ << "(" << sbid_ << ") Cyclone:" << cyclone_firmware_
|
|---|
| 48 | << " Stratix1: " << stratix1_firmware_ << " Stratix2: " << stratix2_firmware_ << endl;
|
|---|
| 49 | return os;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | /*!
|
|---|
| 53 | \class BRConfList
|
|---|
| 54 | \ingroup TAcq
|
|---|
| 55 |
|
|---|
| 56 | \brief Acquisition system configuration.
|
|---|
| 57 |
|
|---|
| 58 | Environment variables:
|
|---|
| 59 | BRACQ_TMPDIR / TMPDIR
|
|---|
| 60 | BRACQ_BASEDIR
|
|---|
| 61 | BRACQ_FIBERIDS
|
|---|
| 62 | */
|
|---|
| 63 |
|
|---|
| 64 | #define PMAXNBFIBRES 64
|
|---|
| 65 | /* --Methode-- */
|
|---|
| 66 | BRConfList::BRConfList()
|
|---|
| 67 | : basedir_("./"), fiberIds_(PMAXNBFIBRES), tmpdir_("/tmp")
|
|---|
| 68 | {
|
|---|
| 69 | InitFromEnv();
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | /* --Methode-- */
|
|---|
| 73 | BRConfList::BRConfList(string basedir)
|
|---|
| 74 | : basedir_("./"), fiberIds_(PMAXNBFIBRES), tmpdir_("/tmp")
|
|---|
| 75 | {
|
|---|
| 76 | InitFromEnv();
|
|---|
| 77 | SetBaseDirectory(basedir);
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | /* --Methode-- */
|
|---|
| 81 | BRConfList::BRConfList(string basedir, vector<ADCBoardDesc> boards)
|
|---|
| 82 | : basedir_("./"), fiberIds_(PMAXNBFIBRES), tmpdir_("/tmp")
|
|---|
| 83 | {
|
|---|
| 84 | InitFromEnv();
|
|---|
| 85 | SetBaseDirectory(basedir);
|
|---|
| 86 | boards_=boards;
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | /* --Methode-- */
|
|---|
| 90 | BRConfList::BRConfList(BRConfList const & cf)
|
|---|
| 91 | : basedir_(cf.basedir_), boards_(cf.boards_), fiberIdsS_(cf.fiberIdsS_), fiberIds_(cf.fiberIds_), tmpdir_(cf.tmpdir_)
|
|---|
| 92 | {
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | /* --Methode-- */
|
|---|
| 96 | void BRConfList::InitFromEnv()
|
|---|
| 97 | {
|
|---|
| 98 | const char* venvp = NULL;
|
|---|
| 99 | venvp=getenv("BRACQ_TMPDIR");
|
|---|
| 100 | if (venvp!=NULL) tmpdir_=venvp;
|
|---|
| 101 | else {
|
|---|
| 102 | if (venvp!=NULL) tmpdir_=venvp;
|
|---|
| 103 | venvp = getenv("TMPDIR");
|
|---|
| 104 | }
|
|---|
| 105 | venvp=getenv("BRACQ_BASEDIR");
|
|---|
| 106 | if (venvp!=NULL) {
|
|---|
| 107 | string ebd=venvp;
|
|---|
| 108 | SetBaseDirectory(ebd);
|
|---|
| 109 | }
|
|---|
| 110 | string fibids="1,2,3,4,5,6,7,8";
|
|---|
| 111 | venvp=getenv("BRACQ_FIBERIDS");
|
|---|
| 112 | if (venvp!=NULL) fibids=venvp;
|
|---|
| 113 | SetFiberIds(fibids);
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | /* --Methode-- */
|
|---|
| 117 | int BRConfList::SetFiberIds(string& sfids)
|
|---|
| 118 | {
|
|---|
| 119 | fiberIdsS_=sfids;
|
|---|
| 120 | vector<string> fibids;
|
|---|
| 121 | FillVStringFrString(sfids, fibids, ',');
|
|---|
| 122 | int rc=0;
|
|---|
| 123 | for (size_t fib=0; fib<fibids.size(); fib++) {
|
|---|
| 124 | if (fib>fiberIds_.size()) break;
|
|---|
| 125 | fiberIds_[fib]=atoi(fibids[fib].c_str());
|
|---|
| 126 | rc++;
|
|---|
| 127 | }
|
|---|
| 128 | return rc;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | /* --Methode-- */
|
|---|
| 132 | void BRConfList::SetBaseDirectory(string& basedir)
|
|---|
| 133 | {
|
|---|
| 134 | if (basedir.length()<1) return;
|
|---|
| 135 | basedir_=basedir;
|
|---|
| 136 | size_t len = basedir_.length();
|
|---|
| 137 | if ((len>1)&&(basedir_[len-1]!='/')) basedir_ += '/';
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | /* --Methode-- */
|
|---|
| 141 | BRConfList& BRConfList::Set(BRConfList const & cf)
|
|---|
| 142 | {
|
|---|
| 143 | basedir_=cf.basedir_;
|
|---|
| 144 | boards_=cf.boards_;
|
|---|
| 145 | fiberIdsS_=cf.fiberIdsS_;
|
|---|
| 146 | fiberIds_=cf.fiberIds_;
|
|---|
| 147 | tmpdir_=cf.tmpdir_;
|
|---|
| 148 | return (*this);
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | /* --Methode-- */
|
|---|
| 152 | ostream& BRConfList::Print(ostream& os)
|
|---|
| 153 | {
|
|---|
| 154 | os << " ----- BRConfList:: BaseDir=" << basedir_ << " TmpDir=" << tmpdir_
|
|---|
| 155 | << " NBoards= " << boards_.size() << endl;
|
|---|
| 156 | for(size_t k=0; k<boards_.size(); k++) boards_[k].Print(os);
|
|---|
| 157 | os << " FiberIdString=" << fiberIdsS_ << endl;
|
|---|
| 158 | return os;
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | /* --Methode-- */
|
|---|
| 162 | void BRConfList::ReadDCFile(string file)
|
|---|
| 163 | {
|
|---|
| 164 | // A FAIRE
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | // Classe qui memorise tous les parametres importants de l'acquisition
|
|---|
| 168 | /*!
|
|---|
| 169 | \class BRParList
|
|---|
| 170 | \ingroup TAcq
|
|---|
| 171 |
|
|---|
| 172 | \brief Acquisition parameters ( see acqparam_exemple.d datacard file )
|
|---|
| 173 | */
|
|---|
| 174 |
|
|---|
| 175 | /* --Methode-- */
|
|---|
| 176 | BRParList::BRParList(string acqmod, string fibres,unsigned int paqsz,
|
|---|
| 177 | unsigned int dmaszkb, int nfiles, int nblocfile,
|
|---|
| 178 | string outpath, uint_4 nzon , uint_4 npaqzon)
|
|---|
| 179 | {
|
|---|
| 180 | AcqMode=acqmod;
|
|---|
| 181 | fgdatafft=false;
|
|---|
| 182 | fgfftshrink=false;
|
|---|
| 183 | fgsinglechannel=false;
|
|---|
| 184 |
|
|---|
| 185 | FiberListS=fibres;
|
|---|
| 186 |
|
|---|
| 187 | PaqSize=paqsz;
|
|---|
| 188 |
|
|---|
| 189 | dmasizekb=dmaszkb;
|
|---|
| 190 | maxkwedma_=1000;
|
|---|
| 191 | nretrydma_=3;
|
|---|
| 192 | first_maxkwedma_=20000;
|
|---|
| 193 | first_nretrydma_=9;
|
|---|
| 194 |
|
|---|
| 195 | NbFiles=nfiles;
|
|---|
| 196 | NBlocPerFile=nblocfile;
|
|---|
| 197 | OutPathName=outpath;
|
|---|
| 198 |
|
|---|
| 199 | nZones=nzon;
|
|---|
| 200 | nPaqZone=npaqzon;
|
|---|
| 201 |
|
|---|
| 202 | swapall=BR_Copy;
|
|---|
| 203 | savesigfits=true;
|
|---|
| 204 | fgnulldev4fits=false;
|
|---|
| 205 |
|
|---|
| 206 | fg_hard_ctrlc=false;
|
|---|
| 207 |
|
|---|
| 208 | fgreducpsize=false;
|
|---|
| 209 | reducneedcopy=false;
|
|---|
| 210 | pqreducmode=BR_CopyRA;
|
|---|
| 211 | redpqsize=PaqSize;
|
|---|
| 212 | reducoffset=0;
|
|---|
| 213 |
|
|---|
| 214 | tcpportid=BRSPORTID;
|
|---|
| 215 | pci2eth_fgdirect=false;
|
|---|
| 216 | ethr_nlink=0;
|
|---|
| 217 | ethr_forcesamefc_=false;
|
|---|
| 218 | ethr_sfc_maxdpc_=0;
|
|---|
| 219 | ethr_sfc_maxresync_=0;
|
|---|
| 220 | ethr_waitendmsg_=false;
|
|---|
| 221 |
|
|---|
| 222 | skysource="";
|
|---|
| 223 |
|
|---|
| 224 | // --- variables de controle pour le monitoring
|
|---|
| 225 | fgdoProc=false;
|
|---|
| 226 | nmeanProc=512;
|
|---|
| 227 | stepProc=5;
|
|---|
| 228 | nmaxProc=0;
|
|---|
| 229 | // --- variables de controle pour le calcul des visibilites
|
|---|
| 230 | fgdoVisiC=false;
|
|---|
| 231 | nmeanVisiC=1024;
|
|---|
| 232 | fgtimeintervalVisiC=false;
|
|---|
| 233 | timeintervalVisiC=1.;
|
|---|
| 234 | nbcalgrpVisiC=1;
|
|---|
| 235 | nthrVisiC=1;
|
|---|
| 236 | fgfdtVisiC=false;
|
|---|
| 237 | firstpairVisiC=0;
|
|---|
| 238 | nbpairsVisiC=999999999;
|
|---|
| 239 | fgpimpVisiC=false;
|
|---|
| 240 | freqminVisiC=freqmaxVisiC=0;
|
|---|
| 241 | nbinfreqVisiC=1;
|
|---|
| 242 | fgfitsVisiC=false;
|
|---|
| 243 |
|
|---|
| 244 | // Autres variables / variables speciales
|
|---|
| 245 | monothr=false;
|
|---|
| 246 | activate_pattern=false;
|
|---|
| 247 | nopciLossRate=0.;
|
|---|
| 248 |
|
|---|
| 249 | // niveau d'impression,debug ...
|
|---|
| 250 | prtlevel_=0;
|
|---|
| 251 | prtmodulo_=50000;
|
|---|
| 252 | prtmodulo2_=50;
|
|---|
| 253 | Decode(); // On decode et on complete les parametres
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|
| 256 | /* --Methode-- */
|
|---|
| 257 | BRParList::BRParList(BRParList const & p)
|
|---|
| 258 | {
|
|---|
| 259 | Set(p);
|
|---|
| 260 | }
|
|---|
| 261 |
|
|---|
| 262 | /* --Methode-- */
|
|---|
| 263 | void BRParList::Set(BRParList const & p)
|
|---|
| 264 | {
|
|---|
| 265 | AcqMode=p.AcqMode;
|
|---|
| 266 | fgdatafft=p.fgdatafft;
|
|---|
| 267 | fgfftshrink=p.fgfftshrink;
|
|---|
| 268 | fgsinglechannel=p.fgsinglechannel;
|
|---|
| 269 |
|
|---|
| 270 | FiberListS=p.FiberListS;
|
|---|
| 271 | fiberNum_=p.fiberNum_;
|
|---|
| 272 |
|
|---|
| 273 | PaqSize=p.PaqSize;
|
|---|
| 274 |
|
|---|
| 275 | dmasizekb=p.dmasizekb;
|
|---|
| 276 | maxkwedma_=p.maxkwedma_;
|
|---|
| 277 | nretrydma_=p.nretrydma_;
|
|---|
| 278 | first_maxkwedma_=p.first_maxkwedma_;
|
|---|
| 279 | first_nretrydma_=p.first_nretrydma_;
|
|---|
| 280 |
|
|---|
| 281 | NbFiles=p.NbFiles;
|
|---|
| 282 | NBlocPerFile=p.NBlocPerFile;
|
|---|
| 283 | OutPathName=p.OutPathName;
|
|---|
| 284 |
|
|---|
| 285 | nZones=p.nZones;
|
|---|
| 286 | nPaqZone=p.nPaqZone;
|
|---|
| 287 |
|
|---|
| 288 | swapall=p.swapall;
|
|---|
| 289 | savesigfits=p.savesigfits;
|
|---|
| 290 | fgnulldev4fits=p.fgnulldev4fits;
|
|---|
| 291 | fg_hard_ctrlc=p.fg_hard_ctrlc;
|
|---|
| 292 | fgnulldev4fits=p.fgnulldev4fits;
|
|---|
| 293 |
|
|---|
| 294 | fgreducpsize=p.fgreducpsize;
|
|---|
| 295 | reducneedcopy=p.reducneedcopy;
|
|---|
| 296 | pqreducmode=p.pqreducmode;
|
|---|
| 297 | redpqsize=p.redpqsize;
|
|---|
| 298 | reducoffset=p.reducoffset;
|
|---|
| 299 |
|
|---|
| 300 | tcpportid=p.tcpportid;
|
|---|
| 301 | pci2eth_fgdirect=p.pci2eth_fgdirect;
|
|---|
| 302 | eths_targets=p.eths_targets;
|
|---|
| 303 | eths_stargs=p.eths_stargs;
|
|---|
| 304 | eths_fibtargs=p.eths_fibtargs;
|
|---|
| 305 |
|
|---|
| 306 | ethr_nlink=p.ethr_nlink;
|
|---|
| 307 | ethr_forcesamefc_=p.ethr_forcesamefc_;
|
|---|
| 308 | ethr_sfc_maxdpc_=p.ethr_sfc_maxdpc_;
|
|---|
| 309 | ethr_sfc_maxresync_=p.ethr_sfc_maxresync_;
|
|---|
| 310 | ethr_waitendmsg_=p.ethr_waitendmsg_;
|
|---|
| 311 |
|
|---|
| 312 | skysource=p.skysource;
|
|---|
| 313 |
|
|---|
| 314 | fgdoProc=p.fgdoProc;
|
|---|
| 315 | nmeanProc=p.nmeanProc;
|
|---|
| 316 | stepProc=p.stepProc;
|
|---|
| 317 | nmaxProc=p.nmaxProc;
|
|---|
| 318 |
|
|---|
| 319 | fgdoVisiC=p.fgdoVisiC;
|
|---|
| 320 | nmeanVisiC=p.nmeanVisiC;
|
|---|
| 321 | fgtimeintervalVisiC=p.fgtimeintervalVisiC;
|
|---|
| 322 | timeintervalVisiC=p.timeintervalVisiC;
|
|---|
| 323 | nbcalgrpVisiC=p.nbcalgrpVisiC;
|
|---|
| 324 | nthrVisiC=p.nthrVisiC;
|
|---|
| 325 | fgfdtVisiC=p.fgfdtVisiC;
|
|---|
| 326 | firstpairVisiC=p.firstpairVisiC;
|
|---|
| 327 | nbpairsVisiC=p.nbpairsVisiC;
|
|---|
| 328 | fgpimpVisiC=p.fgpimpVisiC;
|
|---|
| 329 | freqminVisiC=p.freqminVisiC;
|
|---|
| 330 | freqmaxVisiC=p.freqmaxVisiC;
|
|---|
| 331 | nbinfreqVisiC=p.nbinfreqVisiC;
|
|---|
| 332 | fgfitsVisiC=p.fgfitsVisiC;
|
|---|
| 333 |
|
|---|
| 334 | monothr=p.monothr;
|
|---|
| 335 | activate_pattern=p.activate_pattern;
|
|---|
| 336 |
|
|---|
| 337 | nopciLossRate=p.nopciLossRate;
|
|---|
| 338 |
|
|---|
| 339 | prtlevel_=p.prtlevel_;
|
|---|
| 340 | prtmodulo_=p.prtmodulo_;
|
|---|
| 341 | prtmodulo2_=p.prtmodulo2_;
|
|---|
| 342 |
|
|---|
| 343 | return;
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | /* --Methode-- */
|
|---|
| 347 | void BRParList::ReadDCFile(string file)
|
|---|
| 348 | {
|
|---|
| 349 | DataCards conf(file);
|
|---|
| 350 | if(conf.HasKey("fibres"))
|
|---|
| 351 | FiberListS= conf.SParam("fibres",0,"1");
|
|---|
| 352 | else if(conf.HasKey("fibers"))
|
|---|
| 353 | FiberListS= conf.SParam("fibers",0,"1");
|
|---|
| 354 |
|
|---|
| 355 | OutPathName= conf.SParam("outpathname",0,"TstAcq");
|
|---|
| 356 | skysource= conf.SParam("skysource",0,"");
|
|---|
| 357 | PaqSize=(uint_4)conf.IParam("paqsize",0,16424);
|
|---|
| 358 |
|
|---|
| 359 | dmasizekb =(uint_4) conf.IParam("dmasizekb",0,32);
|
|---|
| 360 | maxkwedma_=(unsigned int)conf.IParam("waitenddma",0,1000);
|
|---|
| 361 | nretrydma_=(unsigned int)conf.IParam("waitenddma",1,3);
|
|---|
| 362 | first_maxkwedma_=(unsigned int)conf.IParam("waitenddma",2,20*maxkwedma_);
|
|---|
| 363 | first_nretrydma_=(unsigned int)conf.IParam("waitenddma",3,3*nretrydma_);
|
|---|
| 364 |
|
|---|
| 365 | NbFiles=conf.IParam("nbfiles",0,1);
|
|---|
| 366 | NBlocPerFile=conf.IParam("nblocperfile",0,10);
|
|---|
| 367 | AcqMode =conf.SParam("acqmode",0,"std");
|
|---|
| 368 | nZones=(uint_4)conf.IParam("memmgr",0,4);
|
|---|
| 369 | nPaqZone=(uint_4)conf.IParam("memmgr",1,128);
|
|---|
| 370 | if (conf.HasKey("reducpaqsz")) { // reduction des tailles de paquets
|
|---|
| 371 | fgreducpsize=true;
|
|---|
| 372 | redpqsize=(uint_4)conf.IParam("reducpaqsz",0,PaqSize/4);
|
|---|
| 373 | reducoffset=(uint_4)conf.IParam("reducpaqsz",1,0);
|
|---|
| 374 | }
|
|---|
| 375 | // Mot cle pour le mode envoi-reception sur ethernet
|
|---|
| 376 | tcpportid=conf.IParam("tcpportid",0,BRSPORTID);
|
|---|
| 377 | if (conf.HasKey("pci2ethdirect")) pci2eth_fgdirect = true; // Transfer direct DMA -> Ethernet
|
|---|
| 378 | if (conf.HasKey("ethrtargets")) { // Machines destinations des paquets - memes destinations pour toutes les fibres
|
|---|
| 379 | for(int it=0; it<conf.NbParam("ethrtargets"); it++)
|
|---|
| 380 | eths_stargs.push_back(conf.SParam("ethrtargets",it));
|
|---|
| 381 | }
|
|---|
| 382 |
|
|---|
| 383 | const char* ethtf[9]={"ethrtargetsf1","ethrtargetsf2","ethrtargetsf3","ethrtargetsf4",
|
|---|
| 384 | "ethrtargetsf5","ethrtargetsf6","ethrtargetsf7","ethrtargetsf8"};
|
|---|
| 385 | for(int jj=0;jj<8;jj++) {
|
|---|
| 386 | if (conf.HasKey( ethtf[jj] )) {
|
|---|
| 387 | vector<string> ftargs;
|
|---|
| 388 | int fid=jj+1;
|
|---|
| 389 | for(int it=0; it<conf.NbParam( ethtf[jj] ); it++)
|
|---|
| 390 | ftargs.push_back(conf.SParam( ethtf[jj] ,it));
|
|---|
| 391 | eths_fibtargs[fid]=ftargs;
|
|---|
| 392 | }
|
|---|
| 393 | }
|
|---|
| 394 |
|
|---|
| 395 | ethr_nlink=conf.IParam("ethrnlink",0,0); // Nombre de sources de paquets en reception ethernet
|
|---|
| 396 | if (conf.HasKey("ethrforcesamefc")) {
|
|---|
| 397 | ethr_forcesamefc_=true; // force SAME FrameCounter on all links
|
|---|
| 398 | ethr_sfc_maxdpc_=conf.IParam("ethrforcesamefc",0,0);
|
|---|
| 399 | ethr_sfc_maxresync_=conf.IParam("ethrforcesamefc",1,0);
|
|---|
| 400 | }
|
|---|
| 401 | if (conf.HasKey("ethrwaitendmsg")) ethr_waitendmsg_=true;
|
|---|
| 402 |
|
|---|
| 403 | // Parametre de controle du monitoring
|
|---|
| 404 | if (conf.HasKey("monitor")) {
|
|---|
| 405 | fgdoProc=true;
|
|---|
| 406 | nmeanProc=conf.IParam("monitor",0,512);
|
|---|
| 407 | stepProc=conf.IParam("monitor",1,10);
|
|---|
| 408 | nmaxProc=conf.IParam("monitor",2,0);
|
|---|
| 409 | }
|
|---|
| 410 | // Parametres pour le calcul des visibilites - le flag fgdoVisiC ne peut etre active
|
|---|
| 411 | // qu'avec l'option de ligne de commande de mfacq
|
|---|
| 412 | if (conf.HasKey("visicalc")) {
|
|---|
| 413 | nmeanVisiC=conf.IParam("visicalc",0,1024);
|
|---|
| 414 | nbcalgrpVisiC=conf.IParam("visicalc",1,1);
|
|---|
| 415 | nthrVisiC=conf.IParam("visicalc",2,1);
|
|---|
| 416 | }
|
|---|
| 417 | if (conf.HasKey("visitimeint")) {
|
|---|
| 418 | fgtimeintervalVisiC=true;
|
|---|
| 419 | timeintervalVisiC=conf.DParam("visitimeint",0,1.);
|
|---|
| 420 | }
|
|---|
| 421 | if (conf.HasKey("visidtable")) fgfdtVisiC=true;
|
|---|
| 422 | if (conf.HasKey("visipairs")) {
|
|---|
| 423 | firstpairVisiC=conf.IParam("visipairs",0,0);
|
|---|
| 424 | nbpairsVisiC=conf.IParam("visipairs",1,999999999);
|
|---|
| 425 | fgpimpVisiC=(conf.IParam("visipairs",2,0)>0)?true:false;
|
|---|
| 426 | }
|
|---|
| 427 | if (conf.HasKey("visifreq")) {
|
|---|
| 428 | freqminVisiC=conf.IParam("visifreq",0,0);
|
|---|
| 429 | freqmaxVisiC=conf.IParam("visifreq",1,0);
|
|---|
| 430 | nbinfreqVisiC=conf.IParam("visifreq",2,1);
|
|---|
| 431 | }
|
|---|
| 432 | if (conf.HasKey("visifitsout")) fgfitsVisiC=true;
|
|---|
| 433 | if (conf.HasKey("visippfout")) fgfitsVisiC=false;
|
|---|
| 434 |
|
|---|
| 435 | nopciLossRate=conf.DParam("nopcilossrate",0,0.);
|
|---|
| 436 | fg_hard_ctrlc=conf.HasKey("hard_ctrlc");
|
|---|
| 437 | if (conf.HasKey("nosavesigfits")) savesigfits=false;
|
|---|
| 438 | if (conf.HasKey("prtlev")) {
|
|---|
| 439 | prtlevel_=conf.IParam("prtlev",0,0);
|
|---|
| 440 | prtmodulo_=conf.IParam("prtlev",1,50000);
|
|---|
| 441 | prtmodulo2_=conf.IParam("prtlev",2,50);
|
|---|
| 442 | }
|
|---|
| 443 |
|
|---|
| 444 | Decode();
|
|---|
| 445 | }
|
|---|
| 446 |
|
|---|
| 447 | /* --Methode-- */
|
|---|
| 448 | void BRParList::Decode()
|
|---|
| 449 | {
|
|---|
| 450 | vector<string> fiblist;
|
|---|
| 451 | FillVStringFrString(FiberListS, fiblist, ',');
|
|---|
| 452 | fiberNum_.resize(fiblist.size());
|
|---|
| 453 | for (int fib=0; fib<fiblist.size(); fib++) {
|
|---|
| 454 | fiberNum_[fib]=atoi(fiblist[fib].c_str());
|
|---|
| 455 | }
|
|---|
| 456 |
|
|---|
| 457 | eths_targets.resize(fiberNum_.size());
|
|---|
| 458 | for (int fib=0; fib<fiberNum_.size(); fib++) {
|
|---|
| 459 | map< int, vector<string> >::const_iterator itm=eths_fibtargs.find(fiberNum_[fib]);
|
|---|
| 460 | if (itm != eths_fibtargs.end()) eths_targets[fib]=itm->second;
|
|---|
| 461 | else eths_targets[fib]=eths_stargs;
|
|---|
| 462 | }
|
|---|
| 463 |
|
|---|
| 464 | if (OutPathName == "/dev/null") {
|
|---|
| 465 | fgnulldev4fits=true;
|
|---|
| 466 | }
|
|---|
| 467 | else {
|
|---|
| 468 | size_t len = OutPathName.length();
|
|---|
| 469 | if ((len>1)&&(OutPathName[len-1]!='/')) OutPathName+='/';
|
|---|
| 470 | fgnulldev4fits=false;
|
|---|
| 471 | }
|
|---|
| 472 | string acqmode = AcqMode;
|
|---|
| 473 | fgdatafft=false; fgfftshrink=false; fgsinglechannel=false;
|
|---|
| 474 | reducneedcopy=false; pqreducmode=BR_TwoChanReduc;
|
|---|
| 475 | if ((acqmode == "std")||(acqmode=="raw2c")) swapall = BR_Copy ;
|
|---|
| 476 | if (acqmode=="raw1c") { swapall = BR_Copy ; fgsinglechannel=true; pqreducmode=BR_OneChanReduc; }
|
|---|
| 477 |
|
|---|
| 478 | if (acqmode=="fft2c") { swapall = BR_Copy; fgdatafft=true; }
|
|---|
| 479 | if ((acqmode=="fft2cshrink")||(acqmode=="fftshrink")) { swapall = BR_Copy; fgdatafft=true; fgfftshrink=true; }
|
|---|
| 480 | if (acqmode=="fft1c") { swapall = BR_Copy; fgdatafft=true; fgsinglechannel=true; }
|
|---|
| 481 | if (acqmode=="fft1cshrink") { swapall = BR_Copy; fgdatafft=true; fgfftshrink=true; fgfftshrink=true; }
|
|---|
| 482 |
|
|---|
| 483 | if (acqmode == "nosw") swapall = BR_Copy ;
|
|---|
| 484 | if (acqmode == "nof") { swapall = BR_Copy ; savesigfits = false; }
|
|---|
| 485 | if (acqmode == "ordfft1c") { swapall = BR_FFTOneChan; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 486 | if (acqmode == "ordfft2c") { swapall = BR_FFTTwoChan; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 487 |
|
|---|
| 488 | if (acqmode == "fft1cnof")
|
|---|
| 489 | { swapall = BR_FFTOneChan; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 490 | if (acqmode == "fft2cnof")
|
|---|
| 491 | { swapall = BR_FFTTwoChan; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 492 | if (acqmode == "mono") { monothr = true; swapall = BR_Copy; }
|
|---|
| 493 | if (acqmode == "monodirect") { monothr = true; swapall = BR_CopyHDR;}
|
|---|
| 494 | if (acqmode == "patmonodirect") { monothr = true; swapall = BR_CopyHDR; activate_pattern=true; }
|
|---|
| 495 | if (acqmode == "patmono") { monothr = true; swapall = BR_Copy; activate_pattern=true; }
|
|---|
| 496 | if (acqmode == "patnof") { savesigfits = false; swapall = BR_Copy; activate_pattern=true; }
|
|---|
| 497 | if (acqmode == "pattern") { savesigfits = true; swapall = BR_Copy; activate_pattern=true; }
|
|---|
| 498 |
|
|---|
| 499 | if (acqmode == "swapall") swapall = BR_SwapAll;
|
|---|
| 500 | if (acqmode == "fft1csw")
|
|---|
| 501 | { swapall = BR_FFTOneChanSwapAll; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 502 | if (acqmode == "fft2csw")
|
|---|
| 503 | { swapall = BR_FFTTwoChanSwapAll; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 504 | if (acqmode == "fft1cswnof")
|
|---|
| 505 | { swapall = BR_FFTOneChanSwapAll; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 506 | if (acqmode == "fft2cswnof")
|
|---|
| 507 | { swapall = BR_FFTTwoChanSwapAll; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 508 | if ((acqmode == "swh") || (acqmode == "mxs") || (acqmode == "monoswh") ) swapall = BR_SwapHDR;
|
|---|
| 509 | if ((acqmode == "swapallnof") || (acqmode == "mxs") ) savesigfits = false;
|
|---|
| 510 | if (acqmode == "monoswh") { monothr = true; swapall = BR_SwapHDR;; }
|
|---|
| 511 | if (acqmode == "monosw") { monothr = true; swapall = BR_SwapAll; }
|
|---|
| 512 |
|
|---|
| 513 | if (acqmode == "swap32") swapall = BR_Swap32 ;
|
|---|
| 514 | if (acqmode == "nof32") { swapall = BR_Swap32 ; savesigfits = false; }
|
|---|
| 515 | if (acqmode == "fft1c32")
|
|---|
| 516 | { swapall = BR_FFTOneChanSwap32; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 517 | if (acqmode == "fft2c32")
|
|---|
| 518 | { swapall = BR_FFTTwoChanSwap32; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 519 | if (acqmode == "fft1cnof32")
|
|---|
| 520 | { swapall = BR_FFTOneChanSwap32; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 521 | if (acqmode == "fft2cnof32")
|
|---|
| 522 | { swapall = BR_FFTTwoChanSwap32; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 523 |
|
|---|
| 524 | if ((swapall==BR_FFTTwoChan)||(swapall==BR_FFTTwoChanSwapAll)||(swapall==BR_FFTTwoChanSwap32)) {
|
|---|
| 525 | fgdatafft=true;
|
|---|
| 526 | }
|
|---|
| 527 | if ((swapall==BR_FFTOneChan)||(swapall==BR_FFTOneChanSwapAll)||(swapall==BR_FFTOneChanSwap32)) {
|
|---|
| 528 | fgdatafft=true; fgsinglechannel=true;
|
|---|
| 529 | }
|
|---|
| 530 |
|
|---|
| 531 | if (fgreducpsize) {
|
|---|
| 532 | if (redpqsize>=PaqSize) fgreducpsize=false;
|
|---|
| 533 | else {
|
|---|
| 534 | if(reducoffset>(PaqSize-redpqsize)/2) reducoffset=(PaqSize-redpqsize)/2;
|
|---|
| 535 | }
|
|---|
| 536 | }
|
|---|
| 537 | }
|
|---|
| 538 |
|
|---|
| 539 | /* --Methode-- */
|
|---|
| 540 | ostream& BRParList::Print(ostream& os)
|
|---|
| 541 | {
|
|---|
| 542 | os << " ------ BRParList::Print() ----- " << endl;
|
|---|
| 543 | os << " FiberListS=" << FiberListS ;
|
|---|
| 544 | os << " PaqSize=" <<PaqSize;
|
|---|
| 545 | os << " DMA_Size_kb=" <<dmasizekb << " (EndDMA: Maxkw=" << maxkwedma_ << " NRetry=" << nretrydma_
|
|---|
| 546 | << " FirstDMA: Maxkw=" << first_maxkwedma_ << " NRetry=" << first_nretrydma_ << ")" << endl;
|
|---|
| 547 | os << " AcqMode="<<AcqMode;
|
|---|
| 548 | os << " Type of acquisition :" << BRPaquet::FmtConvToString( swapall) << endl;
|
|---|
| 549 | os << " Firmware: " << ((fgdatafft)?" FFT_Data ":" RawData ");
|
|---|
| 550 | os << ((fgfftshrink)?" ShrinkFFT ":" FULLFFT ");
|
|---|
| 551 | os << ((fgsinglechannel)?" SingleChannel":" TwoChannels") << endl;
|
|---|
| 552 | os << " SkySource=" << skysource;
|
|---|
| 553 | os << " NbFiles="<<NbFiles;
|
|---|
| 554 | os << " NBlocPerFile="<<NBlocPerFile;
|
|---|
| 555 | os << " OutPathName="<<OutPathName << endl;
|
|---|
| 556 | os << " MemMgr: nZones="<<nZones;
|
|---|
| 557 | os << " nPaqZone="<<nPaqZone<<endl;
|
|---|
| 558 | if (fgreducpsize) {
|
|---|
| 559 | os << " PaquetSize Reduction, ReducedSize=" << redpqsize << " Offset=" << reducoffset << endl;
|
|---|
| 560 | }
|
|---|
| 561 | if ((eths_stargs.size()>0)||(eths_fibtargs.size()>0)) {
|
|---|
| 562 | os << " DMA->Ethernet Targets=" << eths_targets.size()
|
|---|
| 563 | << ((pci2eth_fgdirect)?" (DirectTransferMode) " : " " ) << endl;
|
|---|
| 564 |
|
|---|
| 565 | for(size_t fib=0; fib<eths_targets.size(); fib++) {
|
|---|
| 566 | os << " Fiber Num=" << fiberNum_[fib] << " --> eth_targets: ";
|
|---|
| 567 | for(size_t it=0; it<eths_targets[fib].size(); it++)
|
|---|
| 568 | os << eths_targets[fib][it] << " ; ";
|
|---|
| 569 | os << endl;
|
|---|
| 570 | }
|
|---|
| 571 | }
|
|---|
| 572 | os << " TCP-PortId=" << tcpportid << " EthernetRead NbSources (=NbLinks)= " << ethr_nlink << endl;
|
|---|
| 573 | if (ethr_forcesamefc_)
|
|---|
| 574 | os << "EthernetReader mode: ForceSameFrameCounter read mode with Max_PaquetCounterDiff= "
|
|---|
| 575 | << ethr_sfc_maxdpc_ << " MaxNbResync=" << ethr_sfc_maxresync_
|
|---|
| 576 | << ((ethr_waitendmsg_)?" Wait_For_END_Message_Before_Terminate ":" ") << endl;
|
|---|
| 577 | else
|
|---|
| 578 | os << "EthernetReader mode: AllOKPaquets read mode "
|
|---|
| 579 | << ((ethr_waitendmsg_)?" Wait_For_END_Message_Before_Terminate ":" ") << endl;
|
|---|
| 580 |
|
|---|
| 581 | if (fgdoProc>0)
|
|---|
| 582 | os << " Monitoring NMeanProc=" << nmeanProc << " StepProc=" << stepProc << " NMaxProc=" << nmaxProc << endl;
|
|---|
| 583 | else os << " No monotoring thread " << endl;
|
|---|
| 584 | if (fgdoVisiC) {
|
|---|
| 585 | os << " Visibility calculation, nbCalGrp=" << nbcalgrpVisiC << " NThr/VisCal=" << nthrVisiC
|
|---|
| 586 | << ((fgfdtVisiC)?" Fill_VisiDTable":" ") << endl;
|
|---|
| 587 | if (fgtimeintervalVisiC) os << " ... VisiCalc TimeIntervalMode : " << timeintervalVisiC << " seconds " << endl;
|
|---|
| 588 | else os << " ... VisiCalc NPaq=" << nmeanVisiC << " IntervalMode " << endl;
|
|---|
| 589 | os << " ... VisiCalc FirstPair= " << firstpairVisiC << " NbPairs= " << nbpairsVisiC
|
|---|
| 590 | << ((fgpimpVisiC)?" (Odd-Even visibilities+AutoCorrel only) ":"") << endl;
|
|---|
| 591 | os << " ... VisiCalc FrequencyBinning FreqMin= " << freqminVisiC << " FreqMax= " << freqmaxVisiC
|
|---|
| 592 | << " NBinFreq= " << nbinfreqVisiC<< endl;
|
|---|
| 593 | os << (fgfitsVisiC?" FITS output format for visibility files":" PPF output format for visibility files") << endl;
|
|---|
| 594 | }
|
|---|
| 595 | os << " fg_hard_ctrlc=" << ((fg_hard_ctrlc)?"true":"false");
|
|---|
| 596 | os << " Save to fits " << ((savesigfits)?"true":"false") << endl;
|
|---|
| 597 | os << " monothr y(1)/n(0) " << ((monothr)?"true":"false");
|
|---|
| 598 | os << " ActivatePattern " << ((activate_pattern)?"true":"false") << endl;
|
|---|
| 599 | os << " PrtLevel=" << prtlevel_ << " PrtCntModulo=" << prtmodulo_ << " PrtCntModulo2=" << prtmodulo2_ << endl;
|
|---|
| 600 |
|
|---|
| 601 | return os;
|
|---|
| 602 | }
|
|---|
| 603 |
|
|---|
| 604 |
|
|---|
| 605 | //-------------------- Classe BRAcqConfig -----------------------
|
|---|
| 606 | /*!
|
|---|
| 607 | \class BRAcqConfig
|
|---|
| 608 | \ingroup TAcq
|
|---|
| 609 |
|
|---|
| 610 | \brief Defines acquisition (mfacq.cc) configuration and parameters.
|
|---|
| 611 |
|
|---|
| 612 | See BRParList and BRConfList classes.
|
|---|
| 613 | */
|
|---|
| 614 |
|
|---|
| 615 | BRParList* BRAcqConfig::param_=NULL;
|
|---|
| 616 | BRConfList* BRAcqConfig::config_=NULL;
|
|---|
| 617 |
|
|---|
| 618 | /* --Methode-- */
|
|---|
| 619 | BRAcqConfig::BRAcqConfig()
|
|---|
| 620 | {
|
|---|
| 621 | if (param_==NULL) param_ = new BRParList;
|
|---|
| 622 | if (config_==NULL) config_ = new BRConfList;
|
|---|
| 623 | }
|
|---|
| 624 |
|
|---|
| 625 | /* --Methode-- */
|
|---|
| 626 | ostream& BRAcqConfig::Print(ostream& os)
|
|---|
| 627 | {
|
|---|
| 628 | os << " ------------ BAORadio Acq Run/Configuration -------- " << endl;
|
|---|
| 629 | config_->Print(os);
|
|---|
| 630 | param_->Print(os);
|
|---|
| 631 | os << " Fibers f: Num->Id ";
|
|---|
| 632 | for(size_t f=0; f<NbFibers(); f++)
|
|---|
| 633 | os << f << ": " << FiberNum(f) << " -> " << FiberId(f) << " ; " ;
|
|---|
| 634 | os << endl;
|
|---|
| 635 | os << " ----------------------------------------------------- " << endl;
|
|---|
| 636 | }
|
|---|
| 637 |
|
|---|
| 638 | /* --Methode-- */
|
|---|
| 639 | int BRAcqConfig::CreateOutputDirectories()
|
|---|
| 640 | {
|
|---|
| 641 | char cmd[1024];
|
|---|
| 642 | if (param_->fgnulldev4fits!=true) {
|
|---|
| 643 | sprintf(cmd,"mkdir %s%s",config_->BaseDirectory().c_str(), param_->OutPathName.c_str());
|
|---|
| 644 | if (system(cmd) < 0) {
|
|---|
| 645 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
|
|---|
| 646 | << cmd << " -> stop" << endl;
|
|---|
| 647 | return 2;
|
|---|
| 648 | }
|
|---|
| 649 | cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
|---|
| 650 |
|
|---|
| 651 | memset(cmd,0,1024);
|
|---|
| 652 | for (int i= 0; i< NFibers() ; i++) {
|
|---|
| 653 | sprintf(cmd,"mkdir %s%s/Fiber%d",config_->BaseDirectory().c_str(), param_->OutPathName.c_str(),param_->fiberNum_[i]);
|
|---|
| 654 | if (system(cmd) < 0) {
|
|---|
| 655 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
|
|---|
| 656 | << cmd << " -> stop" << endl;
|
|---|
| 657 | return 3;
|
|---|
| 658 | }
|
|---|
| 659 | else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
|---|
| 660 | }
|
|---|
| 661 | }
|
|---|
| 662 | else {
|
|---|
| 663 | string ProcPathName = "./XZXZXZX/";
|
|---|
| 664 | cout << " Using " << ProcPathName << " for other processed files ... " << endl;
|
|---|
| 665 | char cmd[512];
|
|---|
| 666 | sprintf(cmd,"mkdir %s",ProcPathName.c_str());
|
|---|
| 667 | if (system(cmd) < 0) {
|
|---|
| 668 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory ./XZXZXZX/"
|
|---|
| 669 | << "-> stop" << endl;
|
|---|
| 670 | return 3;
|
|---|
| 671 | }
|
|---|
| 672 | else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
|---|
| 673 | }
|
|---|
| 674 | return 0;
|
|---|
| 675 | }
|
|---|
| 676 |
|
|---|
| 677 | /* --Methode-- */
|
|---|
| 678 | string BRAcqConfig::OutputDirectoryFib(int ifib)
|
|---|
| 679 | {
|
|---|
| 680 | char buff[24];
|
|---|
| 681 | sprintf(buff,"Fiber%d/",param_->fiberNum_[ifib]);
|
|---|
| 682 | return ( config_->BaseDirectory() + param_->OutPathName + buff );
|
|---|
| 683 | }
|
|---|