#include #include "brparam.h" #include "strutilxx.h" #include "bracqvers.h" #ifndef BRSPORTID #define BRSPORTID 6912 #endif /*! \class ADCBoardDesc \ingroup TAcq \brief ADC board description (board Id, firmware type, version ...) */ /* --Methode-- */ ADCBoardDesc::ADCBoardDesc(int id, string sbid, string cyc_firmw, string str1_firmw, string str2_firmw) : id_(id), sbid_(sbid), cyclone_firmware_(cyc_firmw), stratix1_firmware_(str1_firmw), stratix2_firmware_(str2_firmw) { } /* --Methode-- */ ADCBoardDesc::ADCBoardDesc(ADCBoardDesc const& bdes) : id_(bdes.id_), sbid_(bdes.sbid_), cyclone_firmware_(bdes.cyclone_firmware_), stratix1_firmware_(bdes.stratix1_firmware_), stratix2_firmware_(bdes.stratix2_firmware_) { } /* --Methode-- */ ADCBoardDesc& ADCBoardDesc::Set(ADCBoardDesc const & bdes) { id_ = bdes.id_; sbid_ = bdes.sbid_; cyclone_firmware_ = bdes.cyclone_firmware_; stratix1_firmware_ = bdes.stratix1_firmware_; stratix2_firmware_ = bdes.stratix2_firmware_; return(*this); } /* --Methode-- */ ostream& ADCBoardDesc::Print(ostream& os) { os << "ADCBoard#" << id_ << "(" << sbid_ << ") Cyclone:" << cyclone_firmware_ << " Stratix1: " << stratix1_firmware_ << " Stratix2: " << stratix2_firmware_ << endl; return os; } /*! \class BRConfList \ingroup TAcq \brief Acquisition system configuration. Environment variables: BRACQ_TMPDIR / TMPDIR BRACQ_BASEDIR BRACQ_FIBERIDS */ #define PMAXNBFIBRES 64 /* --Methode-- */ BRConfList::BRConfList() : basedir_("./"), fiberIds_(PMAXNBFIBRES), tmpdir_("/tmp") { InitFromEnv(); } /* --Methode-- */ BRConfList::BRConfList(string basedir) : basedir_("./"), fiberIds_(PMAXNBFIBRES), tmpdir_("/tmp") { InitFromEnv(); SetBaseDirectory(basedir); } /* --Methode-- */ BRConfList::BRConfList(string basedir, vector boards) : basedir_("./"), fiberIds_(PMAXNBFIBRES), tmpdir_("/tmp") { InitFromEnv(); SetBaseDirectory(basedir); boards_=boards; } /* --Methode-- */ BRConfList::BRConfList(BRConfList const & cf) : basedir_(cf.basedir_), boards_(cf.boards_), fiberIdsS_(cf.fiberIdsS_), fiberIds_(cf.fiberIds_), tmpdir_(cf.tmpdir_) { } /* --Methode-- */ void BRConfList::InitFromEnv() { const char* venvp = NULL; venvp=getenv("BRACQ_TMPDIR"); if (venvp!=NULL) tmpdir_=venvp; else { if (venvp!=NULL) tmpdir_=venvp; venvp = getenv("TMPDIR"); } venvp=getenv("BRACQ_BASEDIR"); if (venvp!=NULL) { string ebd=venvp; SetBaseDirectory(ebd); } string fibids="1,2,3,4,5,6,7,8"; venvp=getenv("BRACQ_FIBERIDS"); if (venvp!=NULL) fibids=venvp; SetFiberIds(fibids); } /* --Methode-- */ int BRConfList::SetFiberIds(string& sfids) { fiberIdsS_=sfids; vector fibids; FillVStringFrString(sfids, fibids, ','); int rc=0; for (size_t fib=0; fibfiberIds_.size()) break; fiberIds_[fib]=atoi(fibids[fib].c_str()); rc++; } return rc; } /* --Methode-- */ void BRConfList::SetBaseDirectory(string& basedir) { if (basedir.length()<1) return; basedir_=basedir; size_t len = basedir_.length(); if ((len>1)&&(basedir_[len-1]!='/')) basedir_ += '/'; } /* --Methode-- */ BRConfList& BRConfList::Set(BRConfList const & cf) { basedir_=cf.basedir_; boards_=cf.boards_; fiberIdsS_=cf.fiberIdsS_; fiberIds_=cf.fiberIds_; tmpdir_=cf.tmpdir_; return (*this); } /* --Methode-- */ ostream& BRConfList::Print(ostream& os) { os << " ----- BRConfList:: BaseDir=" << basedir_ << " TmpDir=" << tmpdir_ << " NBoards= " << boards_.size() << endl; for(size_t k=0; k Ethernet if (conf.HasKey("ethrtargets")) { // Machines destinations des paquets - memes destinations pour toutes les fibres for(int it=0; it ftargs; int fid=jj+1; for(int it=0; it0)?true:false; } if (conf.HasKey("visifreq")) { freqminVisiC=conf.IParam("visifreq",0,0); freqmaxVisiC=conf.IParam("visifreq",1,0); nbinfreqVisiC=conf.IParam("visifreq",2,1); } if (conf.HasKey("visifitsout")) fgfitsVisiC=true; if (conf.HasKey("visippfout")) fgfitsVisiC=false; nopciLossRate=conf.DParam("nopcilossrate",0,0.); fg_hard_ctrlc=conf.HasKey("hard_ctrlc"); if (conf.HasKey("nosavesigfits")) savesigfits=false; if (conf.HasKey("prtlev")) { prtlevel_=conf.IParam("prtlev",0,0); prtmodulo_=conf.IParam("prtlev",1,50000); prtmodulo2_=conf.IParam("prtlev",2,50); } Decode(); } /* --Methode-- */ void BRParList::Decode() { vector fiblist; FillVStringFrString(FiberListS, fiblist, ','); fiberNum_.resize(fiblist.size()); for (int fib=0; fib >::const_iterator itm=eths_fibtargs.find(fiberNum_[fib]); if (itm != eths_fibtargs.end()) eths_targets[fib]=itm->second; else eths_targets[fib]=eths_stargs; } if (OutPathName == "/dev/null") { fgnulldev4fits=true; } else { size_t len = OutPathName.length(); if ((len>1)&&(OutPathName[len-1]!='/')) OutPathName+='/'; fgnulldev4fits=false; } string acqmode = AcqMode; fgdatafft=false; fgfftshrink=false; fgsinglechannel=false; reducneedcopy=false; pqreducmode=BR_TwoChanReduc; if ((acqmode == "std")||(acqmode=="raw2c")) swapall = BR_Copy ; if (acqmode=="raw1c") { swapall = BR_Copy ; fgsinglechannel=true; pqreducmode=BR_OneChanReduc; } if (acqmode=="fft2c") { swapall = BR_Copy; fgdatafft=true; } if ((acqmode=="fft2cshrink")||(acqmode=="fftshrink")) { swapall = BR_Copy; fgdatafft=true; fgfftshrink=true; } if (acqmode=="fft1c") { swapall = BR_Copy; fgdatafft=true; fgsinglechannel=true; } if (acqmode=="fft1cshrink") { swapall = BR_Copy; fgdatafft=true; fgfftshrink=true; fgfftshrink=true; } if (acqmode == "nosw") swapall = BR_Copy ; if (acqmode == "nof") { swapall = BR_Copy ; savesigfits = false; } if (acqmode == "ordfft1c") { swapall = BR_FFTOneChan; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; } if (acqmode == "ordfft2c") { swapall = BR_FFTTwoChan; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; } if (acqmode == "fft1cnof") { swapall = BR_FFTOneChan; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; } if (acqmode == "fft2cnof") { swapall = BR_FFTTwoChan; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; } if (acqmode == "mono") { monothr = true; swapall = BR_Copy; } if (acqmode == "monodirect") { monothr = true; swapall = BR_CopyHDR;} if (acqmode == "patmonodirect") { monothr = true; swapall = BR_CopyHDR; activate_pattern=true; } if (acqmode == "patmono") { monothr = true; swapall = BR_Copy; activate_pattern=true; } if (acqmode == "patnof") { savesigfits = false; swapall = BR_Copy; activate_pattern=true; } if (acqmode == "pattern") { savesigfits = true; swapall = BR_Copy; activate_pattern=true; } if (acqmode == "swapall") swapall = BR_SwapAll; if (acqmode == "fft1csw") { swapall = BR_FFTOneChanSwapAll; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; } if (acqmode == "fft2csw") { swapall = BR_FFTTwoChanSwapAll; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; } if (acqmode == "fft1cswnof") { swapall = BR_FFTOneChanSwapAll; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; } if (acqmode == "fft2cswnof") { swapall = BR_FFTTwoChanSwapAll; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; } if ((acqmode == "swh") || (acqmode == "mxs") || (acqmode == "monoswh") ) swapall = BR_SwapHDR; if ((acqmode == "swapallnof") || (acqmode == "mxs") ) savesigfits = false; if (acqmode == "monoswh") { monothr = true; swapall = BR_SwapHDR;; } if (acqmode == "monosw") { monothr = true; swapall = BR_SwapAll; } if (acqmode == "swap32") swapall = BR_Swap32 ; if (acqmode == "nof32") { swapall = BR_Swap32 ; savesigfits = false; } if (acqmode == "fft1c32") { swapall = BR_FFTOneChanSwap32; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; } if (acqmode == "fft2c32") { swapall = BR_FFTTwoChanSwap32; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; } if (acqmode == "fft1cnof32") { swapall = BR_FFTOneChanSwap32; savesigfits = false; reducneedcopy=true; pqreducmode=BR_OneChanReducK0; } if (acqmode == "fft2cnof32") { swapall = BR_FFTTwoChanSwap32; savesigfits = false; reducneedcopy=true; pqreducmode=BR_TwoChanReducK0; } if ((swapall==BR_FFTTwoChan)||(swapall==BR_FFTTwoChanSwapAll)||(swapall==BR_FFTTwoChanSwap32)) { fgdatafft=true; } if ((swapall==BR_FFTOneChan)||(swapall==BR_FFTOneChanSwapAll)||(swapall==BR_FFTOneChanSwap32)) { fgdatafft=true; fgsinglechannel=true; } if (fgreducpsize) { if (redpqsize>=PaqSize) fgreducpsize=false; else { if(reducoffset>(PaqSize-redpqsize)/2) reducoffset=(PaqSize-redpqsize)/2; } } } /* --Methode-- */ ostream& BRParList::Print(ostream& os) { os << " ------ BRParList::Print() ----- " << endl; os << " FiberListS=" << FiberListS ; os << " PaqSize=" <Ethernet Targets=" << eths_targets.size() << ((pci2eth_fgdirect)?" (DirectTransferMode) " : " " ) << endl; for(size_t fib=0; fib eth_targets: "; for(size_t it=0; it0) os << " Monitoring NMeanProc=" << nmeanProc << " StepProc=" << stepProc << " NMaxProc=" << nmaxProc << endl; else os << " No monotoring thread " << endl; if (fgdoVisiC) { os << " Visibility calculation, nbCalGrp=" << nbcalgrpVisiC << " NThr/VisCal=" << nthrVisiC << ((fgfdtVisiC)?" Fill_VisiDTable":" ") << endl; if (fgtimeintervalVisiC) os << " ... VisiCalc TimeIntervalMode : " << timeintervalVisiC << " seconds " << endl; else os << " ... VisiCalc NPaq=" << nmeanVisiC << " IntervalMode " << endl; os << " ... VisiCalc FirstPair= " << firstpairVisiC << " NbPairs= " << nbpairsVisiC << ((fgpimpVisiC)?" (Odd-Even visibilities+AutoCorrel only) ":"") << endl; os << " ... VisiCalc FrequencyBinning FreqMin= " << freqminVisiC << " FreqMax= " << freqmaxVisiC << " NBinFreq= " << nbinfreqVisiC<< endl; os << (fgfitsVisiC?" FITS output format for visibility files":" PPF output format for visibility files") << endl; } os << " fg_hard_ctrlc=" << ((fg_hard_ctrlc)?"true":"false"); os << " Save to fits " << ((savesigfits)?"true":"false") << endl; os << " monothr y(1)/n(0) " << ((monothr)?"true":"false"); os << " ActivatePattern " << ((activate_pattern)?"true":"false") << endl; os << " PrtLevel=" << prtlevel_ << " PrtCntModulo=" << prtmodulo_ << " PrtCntModulo2=" << prtmodulo2_ << endl; return os; } //-------------------- Classe BRAcqConfig ----------------------- /*! \class BRAcqConfig \ingroup TAcq \brief Defines acquisition (mfacq.cc) configuration and parameters. See BRParList and BRConfList classes. */ BRParList* BRAcqConfig::param_=NULL; BRConfList* BRAcqConfig::config_=NULL; /* --Methode-- */ BRAcqConfig::BRAcqConfig() { if (param_==NULL) param_ = new BRParList; if (config_==NULL) config_ = new BRConfList; } /* --Methode-- */ ostream& BRAcqConfig::Print(ostream& os) { os << " ------------ BAORadio Acq Run/Configuration -------- " << endl; config_->Print(os); param_->Print(os); os << " Fibers f: Num->Id "; for(size_t f=0; f " << FiberId(f) << " ; " ; os << endl; os << " ----------------------------------------------------- " << endl; } /* --Methode-- */ int BRAcqConfig::CreateOutputDirectories() { char cmd[1024]; if (param_->fgnulldev4fits!=true) { sprintf(cmd,"mkdir %s%s",config_->BaseDirectory().c_str(), param_->OutPathName.c_str()); if (system(cmd) < 0) { cout << "CreateOutputDirectories()/Error: Can not create subdirectory " << cmd << " -> stop" << endl; return 2; } cout << "CreateOutputDirectories() - Executed command " << cmd << endl; memset(cmd,0,1024); for (int i= 0; i< NFibers() ; i++) { sprintf(cmd,"mkdir %s%s/Fiber%d",config_->BaseDirectory().c_str(), param_->OutPathName.c_str(),param_->fiberNum_[i]); if (system(cmd) < 0) { cout << "CreateOutputDirectories()/Error: Can not create subdirectory " << cmd << " -> stop" << endl; return 3; } else cout << "CreateOutputDirectories() - Executed command " << cmd << endl; } } else { string ProcPathName = "./XZXZXZX/"; cout << " Using " << ProcPathName << " for other processed files ... " << endl; char cmd[512]; sprintf(cmd,"mkdir %s",ProcPathName.c_str()); if (system(cmd) < 0) { cout << "CreateOutputDirectories()/Error: Can not create subdirectory ./XZXZXZX/" << "-> stop" << endl; return 3; } else cout << "CreateOutputDirectories() - Executed command " << cmd << endl; } return 0; } /* --Methode-- */ string BRAcqConfig::OutputDirectoryFib(int ifib) { char buff[24]; sprintf(buff,"Fiber%d/",param_->fiberNum_[ifib]); return ( config_->BaseDirectory() + param_->OutPathName + buff ); }