[3671] | 1 | #include "brparam.h"
|
---|
| 2 | #include "strutilxx.h"
|
---|
| 3 | #include "bracqvers.h"
|
---|
| 4 |
|
---|
[3672] | 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 | }
|
---|
[3671] | 11 |
|
---|
[3672] | 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::Set(BRConfList const & cf)
|
---|
| 66 | {
|
---|
| 67 | basedir_=cf.basedir_;
|
---|
| 68 | boards_=cf.boards_;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | /* --Methode-- */
|
---|
| 72 | ostream& BRConfList::Print(ostream& os)
|
---|
| 73 | {
|
---|
| 74 | os << " ----- BRConfList:: BaseDir:" << basedir_ << " NBoards= " << boards_.size() << endl;
|
---|
| 75 | for(size_t k=0; k<boards_.size(); k++) boards_[k].Print(os);
|
---|
| 76 | return os;
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | /* --Methode-- */
|
---|
| 80 | void BRConfList::ReadDCFile(string file)
|
---|
| 81 | {
|
---|
| 82 | // A FAIRE
|
---|
| 83 | }
|
---|
| 84 |
|
---|
[3671] | 85 | // Classe qui memorise tous les parametres importants de l'acquisition
|
---|
| 86 |
|
---|
| 87 | /* --Methode-- */
|
---|
| 88 | BRParList::BRParList(string fibres,unsigned int paqsz ,unsigned int nframeDMA,
|
---|
| 89 | int nfiles, string acqmod,int nblocfile,int nmxproc ,
|
---|
| 90 | string outpath, uint_4 nzon , uint_4 npaqzon, bool fgcntlc)
|
---|
| 91 | {
|
---|
| 92 | FiberListS=fibres;
|
---|
| 93 | NbFibers=0;
|
---|
| 94 | for (int fib=0; fib<PMAXNBFIBRES;fib++) FiberNum[fib]=0;
|
---|
| 95 | PaqSize=paqsz;
|
---|
| 96 | nbFrameDMA=nframeDMA;
|
---|
| 97 | NbFiles=nfiles;
|
---|
| 98 | AcqMode=acqmod;
|
---|
| 99 | NBlocPerFile=nblocfile;
|
---|
| 100 | NMaxProc=nmxproc;
|
---|
| 101 | OutPathName=outpath;
|
---|
| 102 | nZones=nzon;
|
---|
| 103 | nPaqZone=npaqzon;
|
---|
| 104 | swapall=BR_Copy;
|
---|
| 105 | savesigfits=true;
|
---|
| 106 | fgnulldev4fits=false;
|
---|
| 107 | fg_hard_ctrlc=fgcntlc;
|
---|
| 108 | fgreducpsize=false;
|
---|
[3673] | 109 | pqreducmode=BR_CopyRA;
|
---|
[3671] | 110 | redpqsize=PaqSize;
|
---|
| 111 | reducoffset=0;
|
---|
| 112 |
|
---|
| 113 | monothr=false;
|
---|
| 114 | activate_pattern=false;
|
---|
| 115 |
|
---|
| 116 | Decode(); // On decode et on complete les parametres
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | /* --Methode-- */
|
---|
| 120 | BRParList::BRParList(BRParList const & p)
|
---|
| 121 | {
|
---|
| 122 | Set(p);
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | /* --Methode-- */
|
---|
| 126 | void BRParList::Set(BRParList const & p)
|
---|
| 127 | {
|
---|
| 128 | FiberListS=p.FiberListS;
|
---|
| 129 | NbFibers=p.NbFibers;
|
---|
| 130 | for (int fib=0; fib<PMAXNBFIBRES;fib++) FiberNum[fib]=p.FiberNum[fib];
|
---|
| 131 | PaqSize=p.PaqSize;
|
---|
| 132 | nbFrameDMA=p.nbFrameDMA;
|
---|
| 133 | NbFiles=p.NbFiles;
|
---|
| 134 | AcqMode=p.AcqMode;
|
---|
| 135 | NBlocPerFile=p.NBlocPerFile;
|
---|
| 136 | NMaxProc=p.NMaxProc;
|
---|
| 137 | OutPathName=p.OutPathName;
|
---|
| 138 | nZones=p.nZones;
|
---|
| 139 | nPaqZone=p.nPaqZone;
|
---|
| 140 | swapall=p.swapall;
|
---|
| 141 | savesigfits=p.savesigfits;
|
---|
| 142 | fgnulldev4fits=p.fgnulldev4fits;
|
---|
| 143 | fg_hard_ctrlc=p.fg_hard_ctrlc;
|
---|
| 144 | fgnulldev4fits=p.fgnulldev4fits;
|
---|
| 145 |
|
---|
| 146 | fgreducpsize=p.fgreducpsize;
|
---|
[3673] | 147 | pqreducmode=p.pqreducmode;
|
---|
[3671] | 148 | redpqsize=p.redpqsize;
|
---|
| 149 | reducoffset=p.reducoffset;
|
---|
| 150 |
|
---|
| 151 | monothr=p.monothr;
|
---|
| 152 | activate_pattern=p.activate_pattern;
|
---|
| 153 | return;
|
---|
| 154 | }
|
---|
| 155 |
|
---|
| 156 | /* --Methode-- */
|
---|
| 157 | void BRParList::ReadDCFile(string file)
|
---|
| 158 | {
|
---|
| 159 | DataCards conf(file);
|
---|
| 160 | FiberListS= conf.SParam("Fibres",0,"1");
|
---|
| 161 | PaqSize=(unsigned int)conf.IParam("PaqSZ",0,16424);
|
---|
| 162 | nbFrameDMA =(unsigned int) conf.IParam("nbFrameDma",0,32);
|
---|
| 163 | NbFiles=conf.IParam("NbFiles",0,1);
|
---|
| 164 | NBlocPerFile=conf.IParam("NBlocPerFile",0,10);
|
---|
| 165 | NMaxProc=conf.IParam("NMaxProc",0,0);
|
---|
| 166 | OutPathName= conf.SParam("OutPathName",0,"TstAcq");
|
---|
| 167 | AcqMode =conf.SParam("acqmode",0,"std");
|
---|
| 168 | nZones=(unsigned int)conf.IParam("nZones",0,4);
|
---|
| 169 | nPaqZone=(uint_4)conf.IParam("nPaqZone",0,128);
|
---|
| 170 | fg_hard_ctrlc=conf.HasKey("fg_hard_ctrlc");
|
---|
| 171 |
|
---|
| 172 | Decode();
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | /* --Methode-- */
|
---|
| 176 | void BRParList::Decode()
|
---|
| 177 | {
|
---|
| 178 | vector<string> fiblist;
|
---|
| 179 | FillVStringFrString(FiberListS, fiblist, ',');
|
---|
| 180 | NbFibers=fiblist.size();
|
---|
| 181 | for (int fib=0; fib<fiblist.size(); fib++) {
|
---|
| 182 | FiberNum[fib]=atoi(fiblist[fib].c_str());
|
---|
| 183 | }
|
---|
[3672] | 184 | if (OutPathName == "/dev/null") {
|
---|
| 185 | fgnulldev4fits=true;
|
---|
| 186 | }
|
---|
| 187 | else {
|
---|
| 188 | size_t len = OutPathName.length();
|
---|
| 189 | if ((len>1)&&(OutPathName[len-1]!='/')) OutPathName+='/';
|
---|
| 190 | fgnulldev4fits=false;
|
---|
| 191 | }
|
---|
[3671] | 192 | string acqmode = AcqMode;
|
---|
| 193 | if (acqmode == "std") swapall = BR_Copy ;
|
---|
| 194 | if (acqmode == "nosw") swapall = BR_Copy ;
|
---|
| 195 | if (acqmode == "nof") { swapall = BR_Copy ; savesigfits = false; }
|
---|
| 196 | if (acqmode == "fft1c") swapall = BR_FFTOneChan;
|
---|
| 197 | if (acqmode == "fft2c") swapall = BR_FFTTwoChan;
|
---|
| 198 | if (acqmode == "fft1cnof") { swapall = BR_FFTOneChan; savesigfits = false; }
|
---|
| 199 | if (acqmode == "fft2cnof") { swapall = BR_FFTTwoChan; savesigfits = false; }
|
---|
| 200 | if (acqmode == "mono") { monothr = true; swapall = BR_Copy; }
|
---|
| 201 | if (acqmode == "monodirect") { monothr = true; swapall = BR_CopyHDR;}
|
---|
| 202 | if (acqmode == "patmonodirect") { monothr = true; swapall = BR_CopyHDR; activate_pattern=true; }
|
---|
| 203 | if (acqmode == "patmono") { monothr = true; swapall = BR_Copy; activate_pattern=true; }
|
---|
| 204 | if (acqmode == "patnof") { savesigfits = false; swapall = BR_Copy; activate_pattern=true; }
|
---|
| 205 | if (acqmode == "pattern") { savesigfits = true; swapall = BR_Copy; activate_pattern=true; }
|
---|
| 206 |
|
---|
| 207 | if (acqmode == "swapall") swapall = BR_SwapAll;
|
---|
| 208 | if (acqmode == "fft1csw") swapall = BR_FFTOneChanSwapAll;
|
---|
| 209 | if (acqmode == "fft2csw") swapall = BR_FFTTwoChanSwapAll;
|
---|
| 210 | if (acqmode == "fft1cswnof") { swapall = BR_FFTOneChanSwapAll; savesigfits = false; }
|
---|
| 211 | if (acqmode == "fft2cswnof") { swapall = BR_FFTTwoChanSwapAll; savesigfits = false; }
|
---|
| 212 | if ((acqmode == "swh") || (acqmode == "mxs") || (acqmode == "monoswh") ) swapall = BR_SwapHDR;
|
---|
| 213 | if ((acqmode == "swapallnof") || (acqmode == "mxs") ) savesigfits = false;
|
---|
| 214 | if (acqmode == "monoswh") { monothr = true; swapall = BR_SwapHDR;; }
|
---|
| 215 | if (acqmode == "monosw") { monothr = true; swapall = BR_SwapAll; }
|
---|
| 216 |
|
---|
| 217 | if (acqmode == "swap32") swapall = BR_Swap32 ;
|
---|
| 218 | if (acqmode == "nof32") { swapall = BR_Swap32 ; savesigfits = false; }
|
---|
| 219 | if (acqmode == "fft1c32") swapall = BR_FFTOneChanSwap32;
|
---|
| 220 | if (acqmode == "fft2c32") swapall = BR_FFTTwoChanSwap32;
|
---|
| 221 | if (acqmode == "fft1cnof32") { swapall = BR_FFTOneChanSwap32; savesigfits = false; }
|
---|
| 222 | if (acqmode == "fft2cnof32") { swapall = BR_FFTTwoChanSwap32; savesigfits = false; }
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | /* --Methode-- */
|
---|
| 226 | ostream& BRParList::Print(ostream& os)
|
---|
| 227 | {
|
---|
| 228 | os << " ------ BRParList::Print() ----- " << endl;
|
---|
| 229 | os << " FiberListS=" << FiberListS ;
|
---|
| 230 | os << " PaqSize=" <<PaqSize;
|
---|
| 231 | os << " nbFrameDMA=" <<nbFrameDMA << endl;
|
---|
| 232 | os << " AcqMode="<<AcqMode;
|
---|
| 233 | os << " Type of acquisition :" << BRPaquet::FmtConvToString( swapall) << endl;
|
---|
| 234 | os << " NbFiles="<<NbFiles;
|
---|
| 235 | os << " NBlocPerFile="<<NBlocPerFile;
|
---|
| 236 | os << " OutPathName="<<OutPathName << endl;
|
---|
| 237 | os << " MemMgr: nZones="<<nZones;
|
---|
| 238 | os << " nPaqZone="<<nPaqZone;
|
---|
| 239 | os << " fg_hard_ctrlc=" << ((fg_hard_ctrlc)?"true":"false");
|
---|
| 240 | os << " Save to fits " << ((savesigfits)?"true":"false") << endl;
|
---|
| 241 | os << " monothr y(1)/n(0) " << ((monothr)?"true":"false");
|
---|
| 242 | os << " ActivatePattern " << ((activate_pattern)?"true":"false") << endl;
|
---|
| 243 |
|
---|
| 244 | return os;
|
---|
| 245 | }
|
---|
| 246 |
|
---|
| 247 |
|
---|
[3672] | 248 | //-------------------- Classe BRAcqConfig -----------------------
|
---|
| 249 |
|
---|
[3671] | 250 | BRParList* BRAcqConfig::param_=NULL;
|
---|
[3672] | 251 | BRConfList* BRAcqConfig::config_=NULL;
|
---|
[3671] | 252 |
|
---|
| 253 | /* --Methode-- */
|
---|
| 254 | BRAcqConfig::BRAcqConfig()
|
---|
| 255 | {
|
---|
| 256 | if (param_==NULL) param_ = new BRParList;
|
---|
[3672] | 257 | if (config_==NULL) config_ = new BRConfList;
|
---|
[3671] | 258 | }
|
---|
| 259 |
|
---|
| 260 | /* --Methode-- */
|
---|
[3672] | 261 | ostream& BRAcqConfig::Print(ostream& os)
|
---|
| 262 | {
|
---|
| 263 | os << " ------------ BAORadio Acq Run/Configuration -------- " << endl;
|
---|
| 264 | config_->Print(os);
|
---|
| 265 | param_->Print(os);
|
---|
| 266 | os << " ----------------------------------------------------- " << endl;
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 | /* --Methode-- */
|
---|
[3671] | 270 | int BRAcqConfig::CreateOutputDirectories()
|
---|
| 271 | {
|
---|
[3672] | 272 | char cmd[1024];
|
---|
[3671] | 273 | if (param_->fgnulldev4fits!=true) {
|
---|
[3672] | 274 | sprintf(cmd,"mkdir %s%s",config_->BaseDirectory().c_str(), param_->OutPathName.c_str());
|
---|
[3671] | 275 | if (system(cmd) < 0) {
|
---|
[3672] | 276 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
|
---|
| 277 | << cmd << " -> stop" << endl;
|
---|
[3671] | 278 | return 2;
|
---|
| 279 | }
|
---|
| 280 | cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
---|
| 281 |
|
---|
[3672] | 282 | memset(cmd,0,1024);
|
---|
[3671] | 283 | for (int i= 0; i< NFibers() ; i++) {
|
---|
[3672] | 284 | sprintf(cmd,"mkdir %s%s/Fiber%d",config_->BaseDirectory().c_str(), param_->OutPathName.c_str(),param_->FiberNum[i]);
|
---|
[3671] | 285 | if (system(cmd) < 0) {
|
---|
| 286 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
|
---|
[3672] | 287 | << cmd << " -> stop" << endl;
|
---|
[3671] | 288 | return 3;
|
---|
| 289 | }
|
---|
| 290 | else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
---|
| 291 | }
|
---|
| 292 | }
|
---|
| 293 | else {
|
---|
| 294 | string ProcPathName = "./XZXZXZX/";
|
---|
| 295 | cout << " Using " << ProcPathName << " for other processed files ... " << endl;
|
---|
| 296 | char cmd[512];
|
---|
| 297 | sprintf(cmd,"mkdir %s",ProcPathName.c_str());
|
---|
| 298 | if (system(cmd) < 0) {
|
---|
| 299 | cout << "CreateOutputDirectories()/Error: Can not create subdirectory ./XZXZXZX/"
|
---|
| 300 | << "-> stop" << endl;
|
---|
| 301 | return 3;
|
---|
| 302 | }
|
---|
| 303 | else cout << "CreateOutputDirectories() - Executed command " << cmd << endl;
|
---|
| 304 | }
|
---|
| 305 | return 0;
|
---|
| 306 | }
|
---|
| 307 |
|
---|
| 308 | /* --Methode-- */
|
---|
| 309 | string BRAcqConfig::OutputDirectoryFib(int ifib)
|
---|
| 310 | {
|
---|
| 311 | char buff[24];
|
---|
[3672] | 312 | sprintf(buff,"Fiber%d/",param_->FiberNum[ifib]);
|
---|
| 313 | return ( config_->BaseDirectory() + param_->OutPathName + buff );
|
---|
[3671] | 314 | }
|
---|