| 1 | #include "brparam.h"
|
|---|
| 2 | #include "strutilxx.h"
|
|---|
| 3 | #include "bracqvers.h"
|
|---|
| 4 |
|
|---|
| 5 | /* --Methode-- */
|
|---|
| 6 | ADCBoardDesc::ADCBoardDesc(int id, string sbid, string cyc_firmw, string str1_firmw, string str2_firmw)
|
|---|
| 7 | : id_(id), sbid_(sbid), cyclone_firmware_(cyc_firmw), stratix1_firmware_(str1_firmw), stratix2_firmware_(str2_firmw)
|
|---|
| 8 | {
|
|---|
| 9 |
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | /* --Methode-- */
|
|---|
| 13 | ADCBoardDesc::ADCBoardDesc(ADCBoardDesc const& bdes)
|
|---|
| 14 | : id_(bdes.id_), sbid_(bdes.sbid_), cyclone_firmware_(bdes.cyclone_firmware_),
|
|---|
| 15 | stratix1_firmware_(bdes.stratix1_firmware_), stratix2_firmware_(bdes.stratix2_firmware_)
|
|---|
| 16 | {
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | /* --Methode-- */
|
|---|
| 20 | ADCBoardDesc& ADCBoardDesc::Set(ADCBoardDesc const & bdes)
|
|---|
| 21 | {
|
|---|
| 22 | id_ = bdes.id_;
|
|---|
| 23 | sbid_ = bdes.sbid_;
|
|---|
| 24 | cyclone_firmware_ = bdes.cyclone_firmware_;
|
|---|
| 25 | stratix1_firmware_ = bdes.stratix1_firmware_;
|
|---|
| 26 | stratix2_firmware_ = bdes.stratix2_firmware_;
|
|---|
| 27 | return(*this);
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | /* --Methode-- */
|
|---|
| 31 | ostream& ADCBoardDesc::Print(ostream& os)
|
|---|
| 32 | {
|
|---|
| 33 | os << "ADCBoard#" << id_ << "(" << sbid_ << ") Cyclone:" << cyclone_firmware_
|
|---|
| 34 | << " Stratix1: " << stratix1_firmware_ << " Stratix2: " << stratix2_firmware_ << endl;
|
|---|
| 35 | return os;
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | /* --Methode-- */
|
|---|
| 39 | BRConfList::BRConfList()
|
|---|
| 40 | : basedir_("./")
|
|---|
| 41 | {
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | /* --Methode-- */
|
|---|
| 45 | BRConfList::BRConfList(string basedir)
|
|---|
| 46 | : basedir_(basedir)
|
|---|
| 47 | {
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | /* --Methode-- */
|
|---|
| 51 | BRConfList::BRConfList(string basedir, vector<ADCBoardDesc> boards)
|
|---|
| 52 | : basedir_(basedir), boards_(boards)
|
|---|
| 53 | {
|
|---|
| 54 | size_t len = basedir_.length();
|
|---|
| 55 | if ((len>1)&&(basedir_[len-1]!='/')) basedir_ += '/';
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | /* --Methode-- */
|
|---|
| 59 | BRConfList::BRConfList(BRConfList const & cf)
|
|---|
| 60 | : basedir_(cf.basedir_), boards_(cf.boards_)
|
|---|
| 61 | {
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | /* --Methode-- */
|
|---|
| 65 | void BRConfList::SetBaseDirectory(string basedir)
|
|---|
| 66 | {
|
|---|
| 67 | basedir_=basedir;
|
|---|
| 68 | size_t len = basedir_.length();
|
|---|
| 69 | if ((len>1)&&(basedir_[len-1]!='/')) basedir_ += '/';
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | /* --Methode-- */
|
|---|
| 73 | void BRConfList::Set(BRConfList const & cf)
|
|---|
| 74 | {
|
|---|
| 75 | basedir_=cf.basedir_;
|
|---|
| 76 | boards_=cf.boards_;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | /* --Methode-- */
|
|---|
| 80 | ostream& BRConfList::Print(ostream& os)
|
|---|
| 81 | {
|
|---|
| 82 | os << " ----- BRConfList:: BaseDir:" << basedir_ << " NBoards= " << boards_.size() << endl;
|
|---|
| 83 | for(size_t k=0; k<boards_.size(); k++) boards_[k].Print(os);
|
|---|
| 84 | return os;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | /* --Methode-- */
|
|---|
| 88 | void BRConfList::ReadDCFile(string file)
|
|---|
| 89 | {
|
|---|
| 90 | // A FAIRE
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | // Classe qui memorise tous les parametres importants de l'acquisition
|
|---|
| 94 |
|
|---|
| 95 | /* --Methode-- */
|
|---|
| 96 | BRParList::BRParList(string fibres,unsigned int paqsz ,unsigned int dmaszkb,
|
|---|
| 97 | int nfiles, string acqmod,int nblocfile,int nmxproc ,
|
|---|
| 98 | string outpath, uint_4 nzon , uint_4 npaqzon, bool fgcntlc)
|
|---|
| 99 | {
|
|---|
| 100 | FiberListS=fibres;
|
|---|
| 101 | NbFibers=0;
|
|---|
| 102 | for (int fib=0; fib<PMAXNBFIBRES;fib++) FiberNum[fib]=0;
|
|---|
| 103 | PaqSize=paqsz;
|
|---|
| 104 | dmasizekb=dmaszkb;
|
|---|
| 105 | NbFiles=nfiles;
|
|---|
| 106 | AcqMode=acqmod;
|
|---|
| 107 | NBlocPerFile=nblocfile;
|
|---|
| 108 | NMaxProc=nmxproc;
|
|---|
| 109 | OutPathName=outpath;
|
|---|
| 110 | nZones=nzon;
|
|---|
| 111 | nPaqZone=npaqzon;
|
|---|
| 112 | swapall=BR_Copy;
|
|---|
| 113 | savesigfits=true;
|
|---|
| 114 | fgnulldev4fits=false;
|
|---|
| 115 |
|
|---|
| 116 | fg_hard_ctrlc=fgcntlc;
|
|---|
| 117 |
|
|---|
| 118 | fgreducpsize=false;
|
|---|
| 119 | reducneedcopy=false;
|
|---|
| 120 | pqreducmode=BR_CopyRA;
|
|---|
| 121 | redpqsize=PaqSize;
|
|---|
| 122 | reducoffset=0;
|
|---|
| 123 |
|
|---|
| 124 | skysource="";
|
|---|
| 125 | monothr=false;
|
|---|
| 126 | activate_pattern=false;
|
|---|
| 127 |
|
|---|
| 128 | Decode(); // On decode et on complete les parametres
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | /* --Methode-- */
|
|---|
| 132 | BRParList::BRParList(BRParList const & p)
|
|---|
| 133 | {
|
|---|
| 134 | Set(p);
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | /* --Methode-- */
|
|---|
| 138 | void BRParList::Set(BRParList const & p)
|
|---|
| 139 | {
|
|---|
| 140 | FiberListS=p.FiberListS;
|
|---|
| 141 | NbFibers=p.NbFibers;
|
|---|
| 142 | for (int fib=0; fib<PMAXNBFIBRES;fib++) FiberNum[fib]=p.FiberNum[fib];
|
|---|
| 143 | PaqSize=p.PaqSize;
|
|---|
| 144 | dmasizekb=p.dmasizekb;
|
|---|
| 145 | NbFiles=p.NbFiles;
|
|---|
| 146 | AcqMode=p.AcqMode;
|
|---|
| 147 | NBlocPerFile=p.NBlocPerFile;
|
|---|
| 148 | NMaxProc=p.NMaxProc;
|
|---|
| 149 | OutPathName=p.OutPathName;
|
|---|
| 150 | nZones=p.nZones;
|
|---|
| 151 | nPaqZone=p.nPaqZone;
|
|---|
| 152 | swapall=p.swapall;
|
|---|
| 153 | savesigfits=p.savesigfits;
|
|---|
| 154 | fgnulldev4fits=p.fgnulldev4fits;
|
|---|
| 155 | fg_hard_ctrlc=p.fg_hard_ctrlc;
|
|---|
| 156 | fgnulldev4fits=p.fgnulldev4fits;
|
|---|
| 157 |
|
|---|
| 158 | fgreducpsize=p.fgreducpsize;
|
|---|
| 159 | reducneedcopy=p.reducneedcopy;
|
|---|
| 160 | pqreducmode=p.pqreducmode;
|
|---|
| 161 | redpqsize=p.redpqsize;
|
|---|
| 162 | reducoffset=p.reducoffset;
|
|---|
| 163 |
|
|---|
| 164 | skysource=p.skysource;
|
|---|
| 165 |
|
|---|
| 166 | monothr=p.monothr;
|
|---|
| 167 | activate_pattern=p.activate_pattern;
|
|---|
| 168 | return;
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | /* --Methode-- */
|
|---|
| 172 | void BRParList::ReadDCFile(string file)
|
|---|
| 173 | {
|
|---|
| 174 | DataCards conf(file);
|
|---|
| 175 | FiberListS= conf.SParam("fibres",0,"1");
|
|---|
| 176 | OutPathName= conf.SParam("outpathname",0,"TstAcq");
|
|---|
| 177 | skysource= conf.SParam("skysource",0,"");
|
|---|
| 178 | PaqSize=(uint_4)conf.IParam("paqsize",0,16424);
|
|---|
| 179 | dmasizekb =(uint_4) conf.IParam("dmasizekb",0,32);
|
|---|
| 180 | NbFiles=conf.IParam("nbfiles",0,1);
|
|---|
| 181 | NBlocPerFile=conf.IParam("nblocperfile",0,10);
|
|---|
| 182 | AcqMode =conf.SParam("acqmode",0,"std");
|
|---|
| 183 | nZones=(uint_4)conf.IParam("memmgr",0,4);
|
|---|
| 184 | nPaqZone=(uint_4)conf.IParam("memmgr",1,128);
|
|---|
| 185 | if (conf.HasKey("reducpaqsz")) { // reduction des tailles de paquets
|
|---|
| 186 | fgreducpsize=true;
|
|---|
| 187 | redpqsize=(uint_4)conf.IParam("reducpaqsz",0,PaqSize/4);
|
|---|
| 188 | reducoffset=(uint_4)conf.IParam("reducpaqsz",1,0);
|
|---|
| 189 | }
|
|---|
| 190 | NMaxProc=conf.IParam("monitor",0,0);
|
|---|
| 191 | fg_hard_ctrlc=conf.HasKey("hard_ctrlc");
|
|---|
| 192 |
|
|---|
| 193 | Decode();
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | /* --Methode-- */
|
|---|
| 197 | void BRParList::Decode()
|
|---|
| 198 | {
|
|---|
| 199 | vector<string> fiblist;
|
|---|
| 200 | FillVStringFrString(FiberListS, fiblist, ',');
|
|---|
| 201 | NbFibers=fiblist.size();
|
|---|
| 202 | for (int fib=0; fib<fiblist.size(); fib++) {
|
|---|
| 203 | FiberNum[fib]=atoi(fiblist[fib].c_str());
|
|---|
| 204 | }
|
|---|
| 205 | if (OutPathName == "/dev/null") {
|
|---|
| 206 | fgnulldev4fits=true;
|
|---|
| 207 | }
|
|---|
| 208 | else {
|
|---|
| 209 | size_t len = OutPathName.length();
|
|---|
| 210 | if ((len>1)&&(OutPathName[len-1]!='/')) OutPathName+='/';
|
|---|
| 211 | fgnulldev4fits=false;
|
|---|
| 212 | }
|
|---|
| 213 | string acqmode = AcqMode;
|
|---|
| 214 | reducneedcopy=false; pqreducmode=BR_TwoChanReduc;
|
|---|
| 215 | if (acqmode == "std") swapall = BR_Copy ;
|
|---|
| 216 | if (acqmode == "nosw") swapall = BR_Copy ;
|
|---|
| 217 | if (acqmode == "nof") { swapall = BR_Copy ; savesigfits = false; }
|
|---|
| 218 | if (acqmode == "fft1c") { swapall = BR_FFTOneChan; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 219 | if (acqmode == "fft2c") { swapall = BR_FFTTwoChan; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 220 | if (acqmode == "fft1cnof")
|
|---|
| 221 | { swapall = BR_FFTOneChan; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 222 | if (acqmode == "fft2cnof")
|
|---|
| 223 | { swapall = BR_FFTTwoChan; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 224 | if (acqmode == "mono") { monothr = true; swapall = BR_Copy; }
|
|---|
| 225 | if (acqmode == "monodirect") { monothr = true; swapall = BR_CopyHDR;}
|
|---|
| 226 | if (acqmode == "patmonodirect") { monothr = true; swapall = BR_CopyHDR; activate_pattern=true; }
|
|---|
| 227 | if (acqmode == "patmono") { monothr = true; swapall = BR_Copy; activate_pattern=true; }
|
|---|
| 228 | if (acqmode == "patnof") { savesigfits = false; swapall = BR_Copy; activate_pattern=true; }
|
|---|
| 229 | if (acqmode == "pattern") { savesigfits = true; swapall = BR_Copy; activate_pattern=true; }
|
|---|
| 230 |
|
|---|
| 231 | if (acqmode == "swapall") swapall = BR_SwapAll;
|
|---|
| 232 | if (acqmode == "fft1csw")
|
|---|
| 233 | { swapall = BR_FFTOneChanSwapAll; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 234 | if (acqmode == "fft2csw")
|
|---|
| 235 | { swapall = BR_FFTTwoChanSwapAll; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 236 | if (acqmode == "fft1cswnof")
|
|---|
| 237 | { swapall = BR_FFTOneChanSwapAll; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 238 | if (acqmode == "fft2cswnof")
|
|---|
| 239 | { swapall = BR_FFTTwoChanSwapAll; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 240 | if ((acqmode == "swh") || (acqmode == "mxs") || (acqmode == "monoswh") ) swapall = BR_SwapHDR;
|
|---|
| 241 | if ((acqmode == "swapallnof") || (acqmode == "mxs") ) savesigfits = false;
|
|---|
| 242 | if (acqmode == "monoswh") { monothr = true; swapall = BR_SwapHDR;; }
|
|---|
| 243 | if (acqmode == "monosw") { monothr = true; swapall = BR_SwapAll; }
|
|---|
| 244 |
|
|---|
| 245 | if (acqmode == "swap32") swapall = BR_Swap32 ;
|
|---|
| 246 | if (acqmode == "nof32") { swapall = BR_Swap32 ; savesigfits = false; }
|
|---|
| 247 | if (acqmode == "fft1c32")
|
|---|
| 248 | { swapall = BR_FFTOneChanSwap32; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 249 | if (acqmode == "fft2c32")
|
|---|
| 250 | { swapall = BR_FFTTwoChanSwap32; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 251 | if (acqmode == "fft1cnof32")
|
|---|
| 252 | { swapall = BR_FFTOneChanSwap32; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; }
|
|---|
| 253 | if (acqmode == "fft2cnof32")
|
|---|
| 254 | { swapall = BR_FFTTwoChanSwap32; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; }
|
|---|
| 255 |
|
|---|
| 256 | if (fgreducpsize) {
|
|---|
| 257 | if (redpqsize>=PaqSize) fgreducpsize=false;
|
|---|
| 258 | else {
|
|---|
| 259 | if(reducoffset>(PaqSize-redpqsize)/2) reducoffset=(PaqSize-redpqsize)/2;
|
|---|
| 260 | }
|
|---|
| 261 | }
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | /* --Methode-- */
|
|---|
| 265 | ostream& BRParList::Print(ostream& os)
|
|---|
| 266 | {
|
|---|
| 267 | os << " ------ BRParList::Print() ----- " << endl;
|
|---|
| 268 | os << " FiberListS=" << FiberListS ;
|
|---|
| 269 | os << " PaqSize=" <<PaqSize;
|
|---|
| 270 | os << " DMA_Size_kb=" <<dmasizekb << endl;
|
|---|
| 271 | os << " AcqMode="<<AcqMode;
|
|---|
| 272 | os << " Type of acquisition :" << BRPaquet::FmtConvToString( swapall) << endl;
|
|---|
| 273 | os << " SkySource=" << skysource;
|
|---|
| 274 | os << " NbFiles="<<NbFiles;
|
|---|
| 275 | os << " NBlocPerFile="<<NBlocPerFile;
|
|---|
| 276 | os << " OutPathName="<<OutPathName << endl;
|
|---|
| 277 | os << " MemMgr: nZones="<<nZones;
|
|---|
| 278 | os << " nPaqZone="<<nPaqZone<<endl;
|
|---|
| 279 | if (fgreducpsize) {
|
|---|
| 280 | os << " PaquetSize Reduction, ReducedSize=" << redpqsize << " Offset=" << reducoffset << endl;
|
|---|
| 281 | }
|
|---|
| 282 | os << " fg_hard_ctrlc=" << ((fg_hard_ctrlc)?"true":"false");
|
|---|
| 283 | os << " Save to fits " << ((savesigfits)?"true":"false") << endl;
|
|---|
| 284 | os << " monothr y(1)/n(0) " << ((monothr)?"true":"false");
|
|---|
| 285 | os << " ActivatePattern " << ((activate_pattern)?"true":"false") << endl;
|
|---|
| 286 |
|
|---|
| 287 | return os;
|
|---|
| 288 | }
|
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 | //-------------------- Classe BRAcqConfig -----------------------
|
|---|
| 292 |
|
|---|
| 293 | BRParList* BRAcqConfig::param_=NULL;
|
|---|
| 294 | BRConfList* BRAcqConfig::config_=NULL;
|
|---|
| 295 |
|
|---|
| 296 | /* --Methode-- */
|
|---|
| 297 | BRAcqConfig::BRAcqConfig()
|
|---|
| 298 | {
|
|---|
| 299 | if (param_==NULL) param_ = new BRParList;
|
|---|
| 300 | if (config_==NULL) config_ = new BRConfList;
|
|---|
| 301 | }
|
|---|
| 302 |
|
|---|
| 303 | /* --Methode-- */
|
|---|
| 304 | ostream& BRAcqConfig::Print(ostream& os)
|
|---|
| 305 | {
|
|---|
| 306 | os << " ------------ BAORadio Acq Run/Configuration -------- " << endl;
|
|---|
| 307 | config_->Print(os);
|
|---|
| 308 | param_->Print(os);
|
|---|
| 309 | os << " ----------------------------------------------------- " << endl;
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | /* --Methode-- */
|
|---|
| 313 | int BRAcqConfig::CreateOutputDirectories()
|
|---|
| 314 | {
|
|---|
| 315 | char cmd[1024];
|
|---|
| 316 | if (param_->fgnulldev4fits!=true) {
|
|---|
| 317 | sprintf(cmd,"mkdir %s%s",config_->BaseDirectory().c_str(), param_->OutPathName.c_str());
|
|---|
| 318 | if (system(cmd) < 0) {
|
|---|
| 319 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
|
|---|
| 320 | << cmd << " -> stop" << endl;
|
|---|
| 321 | return 2;
|
|---|
| 322 | }
|
|---|
| 323 | cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
|---|
| 324 |
|
|---|
| 325 | memset(cmd,0,1024);
|
|---|
| 326 | for (int i= 0; i< NFibers() ; i++) {
|
|---|
| 327 | sprintf(cmd,"mkdir %s%s/Fiber%d",config_->BaseDirectory().c_str(), param_->OutPathName.c_str(),param_->FiberNum[i]);
|
|---|
| 328 | if (system(cmd) < 0) {
|
|---|
| 329 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
|
|---|
| 330 | << cmd << " -> stop" << endl;
|
|---|
| 331 | return 3;
|
|---|
| 332 | }
|
|---|
| 333 | else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
|---|
| 334 | }
|
|---|
| 335 | }
|
|---|
| 336 | else {
|
|---|
| 337 | string ProcPathName = "./XZXZXZX/";
|
|---|
| 338 | cout << " Using " << ProcPathName << " for other processed files ... " << endl;
|
|---|
| 339 | char cmd[512];
|
|---|
| 340 | sprintf(cmd,"mkdir %s",ProcPathName.c_str());
|
|---|
| 341 | if (system(cmd) < 0) {
|
|---|
| 342 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory ./XZXZXZX/"
|
|---|
| 343 | << "-> stop" << endl;
|
|---|
| 344 | return 3;
|
|---|
| 345 | }
|
|---|
| 346 | else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
|---|
| 347 | }
|
|---|
| 348 | return 0;
|
|---|
| 349 | }
|
|---|
| 350 |
|
|---|
| 351 | /* --Methode-- */
|
|---|
| 352 | string BRAcqConfig::OutputDirectoryFib(int ifib)
|
|---|
| 353 | {
|
|---|
| 354 | char buff[24];
|
|---|
| 355 | sprintf(buff,"Fiber%d/",param_->FiberNum[ifib]);
|
|---|
| 356 | return ( config_->BaseDirectory() + param_->OutPathName + buff );
|
|---|
| 357 | }
|
|---|