Changeset 3672 in Sophya for trunk/AddOn
- Timestamp:
- Nov 13, 2009, 6:39:58 PM (16 years ago)
- Location:
- trunk/AddOn/TAcq
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/brparam.cc
r3671 r3672 3 3 #include "bracqvers.h" 4 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::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 } 5 84 6 85 // Classe qui memorise tous les parametres importants de l'acquisition … … 27 106 fgnulldev4fits=false; 28 107 fg_hard_ctrlc=fgcntlc; 29 fgnulldev4fits = (OutPathName == "/dev/null") ? true : false;30 31 108 fgreducpsize=false; 32 109 redpqsize=PaqSize; … … 102 179 for (int fib=0; fib<fiblist.size(); fib++) { 103 180 FiberNum[fib]=atoi(fiblist[fib].c_str()); 181 } 182 if (OutPathName == "/dev/null") { 183 fgnulldev4fits=true; 184 } 185 else { 186 size_t len = OutPathName.length(); 187 if ((len>1)&&(OutPathName[len-1]!='/')) OutPathName+='/'; 188 fgnulldev4fits=false; 104 189 } 105 190 string acqmode = AcqMode; … … 159 244 160 245 246 //-------------------- Classe BRAcqConfig ----------------------- 247 161 248 BRParList* BRAcqConfig::param_=NULL; 249 BRConfList* BRAcqConfig::config_=NULL; 162 250 163 251 /* --Methode-- */ … … 165 253 { 166 254 if (param_==NULL) param_ = new BRParList; 255 if (config_==NULL) config_ = new BRConfList; 256 } 257 258 /* --Methode-- */ 259 ostream& BRAcqConfig::Print(ostream& os) 260 { 261 os << " ------------ BAORadio Acq Run/Configuration -------- " << endl; 262 config_->Print(os); 263 param_->Print(os); 264 os << " ----------------------------------------------------- " << endl; 167 265 } 168 266 … … 170 268 int BRAcqConfig::CreateOutputDirectories() 171 269 { 172 char cmd[ 512];270 char cmd[1024]; 173 271 if (param_->fgnulldev4fits!=true) { 174 sprintf(cmd,"mkdir %s ",param_->OutPathName.c_str());272 sprintf(cmd,"mkdir %s%s",config_->BaseDirectory().c_str(), param_->OutPathName.c_str()); 175 273 if (system(cmd) < 0) { 176 cout << "CreateOutputDirectories()/Error: Can not create 177 << param_->OutPathName<< " -> stop" << endl;274 cout << "CreateOutputDirectories()/Error: Can not create subdirectory " 275 << cmd << " -> stop" << endl; 178 276 return 2; 179 277 } 180 278 cout << "CreateOutputDirectories() - Executed command " << cmd << endl; 181 279 182 memset(cmd,0, 512);280 memset(cmd,0,1024); 183 281 for (int i= 0; i< NFibers() ; i++) { 184 sprintf(cmd,"mkdir %s /Fibre%d",param_->OutPathName.c_str(),param_->FiberNum[i]);282 sprintf(cmd,"mkdir %s%s/Fiber%d",config_->BaseDirectory().c_str(), param_->OutPathName.c_str(),param_->FiberNum[i]); 185 283 if (system(cmd) < 0) { 186 284 cout << "CreateOutputDirectories()/Error: Can not create subdirectory " 187 << param_->OutPathName << "/FiberII-> stop" << endl;285 << cmd << " -> stop" << endl; 188 286 return 3; 189 287 } … … 202 300 } 203 301 else cout << "CreateOutputDirectories() - Executed command " << cmd << endl; 204 205 sprintf(cmd,"mkdir %s/Fibre1 %s/Fibre2",ProcPathName.c_str(),ProcPathName.c_str());206 if (system(cmd) < 0) {207 cout << "CreateOutputDirectories()/Error: Can not create subdirectory ./XZXZXZX/Fibre1,2"208 << "-> stop" << endl;209 return 4;210 }211 302 } 212 303 return 0; … … 217 308 { 218 309 char buff[24]; 219 sprintf(buff," /Fiber%d",param_->FiberNum[ifib]);220 return ( param_->OutPathName + buff );221 } 310 sprintf(buff,"Fiber%d/",param_->FiberNum[ifib]); 311 return ( config_->BaseDirectory() + param_->OutPathName + buff ); 312 } -
trunk/AddOn/TAcq/brparam.h
r3671 r3672 8 8 9 9 //--------------------------------------------------------------- 10 // Classes BRParList , BRConfList , BRAcqConfig 11 // BRParList : Liste de parametres pour un run d'acquisition 12 // BRConfList : Liste des parametres caracterisant une configuration 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 13 14 // (nombre de cartes, versions firwares ...) 14 // BRAcqConfig : Classe donnant acces a un objet global BRParList et15 // + BRAcqConfig : Classe donnant acces a un objet global BRParList et 15 16 // un objet global BRConfList 16 17 //--------------------------------------------------------------- … … 18 19 #include "machdefs.h" 19 20 #include <string> 21 #include <vector> 22 #include <iostream> 20 23 #include "brpaqu.h" 21 24 #include "datacards.h" … … 24 27 using namespace std; 25 28 using namespace SOPHYA; 29 30 //----------------------------------------------------------------------------- 31 //---- Classe Caracterisant un board ADC 32 class ADCBoardDesc { 33 public: 34 ADCBoardDesc(int id, string sbid, string cyc_firmw, string str1_firmw, string str2_firmw); 35 ADCBoardDesc(ADCBoardDesc const& bdes); 36 37 inline int& getId() { return id_; } 38 inline string& getSId() { return sbid_; } 39 inline string& CycloneFirmwareId() { return cyclone_firmware_; } 40 inline string& Stratix1FirmwareId() { return stratix1_firmware_; } 41 inline string& Stratix2FirmwareId() { return stratix2_firmware_; } 42 ostream& Print(ostream& os); 43 44 ADCBoardDesc& Set(ADCBoardDesc const & bdes); 45 inline ADCBoardDesc& operator = (ADCBoardDesc const & bdes) { return Set(bdes); } 46 protected: 47 int id_; 48 string sbid_; 49 string cyclone_firmware_; 50 string stratix1_firmware_; 51 string stratix2_firmware_; 52 }; 53 54 //----------------------------------------------------------------------------- 55 //---- Classe de liste des parametres de configuration BAORadio 56 class BRConfList { 57 public: 58 BRConfList(); 59 BRConfList(string basedir); 60 BRConfList(string basedir, vector<ADCBoardDesc> boards); 61 BRConfList(BRConfList const & cf); 62 void Set(BRConfList const & cf); 63 ostream& Print(ostream& os) ; 64 void ReadDCFile(string file); 65 inline string& BaseDirectory() { return basedir_; } 66 //....................................... 67 string basedir_; 68 vector<ADCBoardDesc> boards_; 69 }; 26 70 27 71 #define PMAXNBFIBRES 6 … … 110 154 BRAcqConfig(); 111 155 112 inline void Read DCFile(string file)156 inline void ReadParamFile(string file) 113 157 { param_->ReadDCFile(file); } 114 158 inline void Set(BRParList& par) 115 159 { param_->Set(par); } 116 inline ostream& Print(ostream& os) 117 { return param_->Print(os); } 160 inline void ReadConfigFile(string file) 161 { config_->ReadDCFile(file); } 162 inline void Set(BRConfList& conf) 163 { config_->Set(conf); } 164 165 ostream& Print(ostream& os); 118 166 119 167 int CreateOutputDirectories(); … … 121 169 static inline double AcqVersion() { return BAOR_ACQ_VER ; } 122 170 static inline const char* AcqVersionS() { return BAOR_ACQ_VER_STR ; } 123 171 124 172 inline BRParList& GetParams() { return (*param_) ;}; 173 inline BRConfList& GetConfig() { return (*config_) ;}; 174 125 175 inline BRDataFmtConv GetSwapall() { return param_->swapall; }; 126 176 inline bool GetPattern() { return param_->activate_pattern; }; … … 150 200 151 201 // repertoire d'acquisition 152 inline string & OutputDirectory() { param_->OutPathName; }202 inline string OutputDirectory() { return (config_->BaseDirectory()+param_->OutPathName); } 153 203 string OutputDirectoryFib(int fib); 154 204 155 205 protected: 156 206 static BRParList* param_; 207 static BRConfList* config_; 157 208 }; 158 209 -
trunk/AddOn/TAcq/mfacq.cc
r3671 r3672 49 49 // Creation/initialisation parametres Acq 50 50 BRAcqConfig acpar; 51 acpar.ReadDCFile(arg[1]); 51 acpar.ReadParamFile(arg[1]); 52 #ifndef NOPCIECARD 53 BRConfList conf("/Raid"); 54 #else 55 BRConfList conf("./"); 56 #endif 57 acpar.Set(conf); 52 58 // Creation des repertoires 53 59 if (acpar.CreateOutputDirectories()!=0) return 9; … … 139 145 140 146 cout <<"mfacq[3] Creating DataSaver and DataProc2C objects ... " << endl; 141 MultiDataSaver DsThr(mmgr, bpar.OutputDirectory(), bpar.MaxNbFiles(), 142 bpar.BlocPerFile(), bpar.GetSaveFits()); 147 MultiDataSaver DsThr(mmgr); // Utilise les parametres globaux BRAcqConfig 143 148 string ppath=bpar.OutputDirectory(); 144 149 DataProc2C PrThr(mmgr, ppath, 1280, stepproc, acpar.NMaxProc); … … 146 151 for (int i=0 ;i<bpar.NFibers();i++) vec_pciw.push_back( pciwp[i]); 147 152 cout << "mfacq[3] Creating PCIEMultiReader " << endl; 148 PCIEMultiReader PcierThr(vec_pciw,bpar.DMASizeBytes(),bpar.RecvPaquetSize(), 149 mmgr, bpar.MaxNbBlocs(), bpar.GetDataConvFg()); 153 PCIEMultiReader PcierThr(vec_pciw, mmgr, bpar.GetParams()); 150 154 usleep(200); // attente au cas ou ... 151 155 pPcierThr=&PcierThr; -
trunk/AddOn/TAcq/racqurw.cc
r3671 r3672 332 332 //---------------------------------------------------------------------------------------------------------- 333 333 334 PCIEReaderChecker::PCIEReaderChecker(PCIEWrapperInterface &pciw, uint_4 sizeFrame,uint_4 packSize ,RAcqMemZoneMgr& mem,335 uint_4 nmax, BRDataFmtConv swapall) 334 PCIEReaderChecker::PCIEReaderChecker(PCIEWrapperInterface &pciw, uint_4 sizeFrame,uint_4 packSize, RAcqMemZoneMgr& mem, 335 uint_4 nmax, BRDataFmtConv swapall) 336 336 : memgr(mem) , pciw_ (pciw) 337 337 { … … 464 464 465 465 /* --Methode-- */ 466 PCIEMultiReader::PCIEMultiReader(vector<PCIEWrapperInterface*> vec_pciw, uint_4 sizeFrame,uint_4 packSize ,RAcqMemZoneMgr& mem, uint_4 nmax, BRDataFmtConv swapall)467 : memgr(mem) 468 { 469 nmax_ = nmax;470 swapall_ = swapall; // select data swap/format conversion for BRPaquet466 PCIEMultiReader::PCIEMultiReader(vector<PCIEWrapperInterface*> vec_pciw, RAcqMemZoneMgr& mem, BRParList const& par) 467 : memgr(mem), par_(par), vec_pciw_ (vec_pciw) 468 { 469 nmax_ = par_.MaxNbBlocs(); 470 swapall_ = par_.GetDataConvFg(); // select data swap/format conversion for BRPaquet 471 471 stop_ = false; 472 packSize_ = pa ckSize;472 packSize_ = par_.RecvPaquetSize(); 473 473 packSizeInMgr_=memgr.PaqSize(); 474 sizeFr_ =sizeFrame;474 sizeFr_=par_.DMASizeBytes(); 475 475 if (vec_pciw.size() != memgr.NbFibres()) { 476 476 cout << " PCIEMultiReader()PbArgs: vec_pciw.size()= " << vec_pciw.size() << " memgr.NbFibres()=" <<memgr.NbFibres()<< endl; … … 688 688 //-------------------------------------------------------------------- 689 689 690 MultiDataSaver::MultiDataSaver(RAcqMemZoneMgr& mem, string path, uint_4 nfiles, uint_4 nblocperfile, bool savesig) 690 /* --Methode-- */ 691 MultiDataSaver::MultiDataSaver(RAcqMemZoneMgr& mem) 691 692 : memgr(mem) 692 { 693 nfiles_ = nfiles; 694 nblocperfile_ = nblocperfile; 693 { 694 BRAcqConfig bpar; 695 nfiles_ = bpar.MaxNbFiles(); 696 nblocperfile_ = bpar.BlocPerFile(); 695 697 nmax_ = nblocperfile_*nfiles_; 696 savesig_ = savesig; // Si false, pas d'ecriture des fichiers FITS du signal698 savesig_ = bpar.GetSaveFits(); // Si false, pas d'ecriture des fichiers FITS du signal 697 699 stop_ = false; 698 path_ = path; 699 } 700 } 701 702 /* --Methode-- */ 700 703 void MultiDataSaver::Stop() 701 704 { 702 705 // cout<< " MultiDataSaver:Stop ........ " << endl; 703 706 stop_=true; 704 705 } 707 } 708 709 /* --Methode-- */ 706 710 void MultiDataSaver::run() 707 711 { … … 715 719 char fname[512]; 716 720 717 sprintf(fname,"%s/msaver.log", path_.c_str());721 sprintf(fname,"%s/msaver.log",bpar.OutputDirectory().c_str()); 718 722 ofstream filog(fname); 719 723 filog << " MultiDataSaver::run() - starting log file " << ts << " NFibres= " << memgr.NbFibres() << endl; … … 727 731 uint_4 paqsz = memgr.PaqSize(); 728 732 cout << " ============================ MultiDataSaver::run() PaqSize " << paqsz <<endl; 729 bool fgnulldev = false;730 if ( path_ == "/dev/null") {733 bool fgnulldev = bpar.GetFileDevNull(); 734 if (fgnulldev) { 731 735 cout << " MultiDataSaver::run()/Warning /dev/null path specified, filenames=/dev/null" << endl; 732 736 fgnulldev = true; … … 740 744 for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) { 741 745 if (fgnulldev) strcpy(fname,"/dev/null"); 742 else sprintf(fname,"%s /Fibre%d/HDRfits%d.txt",path_.c_str(),fib+1,fnum);746 else sprintf(fname,"%sHDRfits%d.txt",bpar.OutputDirectoryFib(fib).c_str(),fnum); 743 747 header[fib].open(fname); 744 748 } … … 749 753 for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) { 750 754 if (fgnulldev) strcpy(fname,"/dev/null"); 751 else sprintf(fname,"%s/Fibre%d/signal%d.fits",path_.c_str(),fib+1,(int)fnum); 755 else sprintf(fname,"%ssignal%d.fits",bpar.OutputDirectoryFib(fib).c_str(),(int)fnum); 756 // cout << " ***DBG** Opening file " << fname << endl; 752 757 mff[fib].Open(fname,MF_Write); //Reza - Ouverture conditionnel fichier 753 758 // Entete correspondant a l'ecriture tout le paquet - trailer compris (modif Mai 2009) … … 797 802 if (savesig_) { 798 803 if (fgnulldev) strcpy(fname,"/dev/null"); 799 else sprintf(fname,"%s /Fibre%d/signal%d.fits",path_.c_str(),fib+1,(int)fnum-1);804 else sprintf(fname,"%ssignal%d.fits",bpar.OutputDirectoryFib(fib).c_str(),(int)fnum); 800 805 } 801 806 else sprintf(fname,"MemDataBloc[%d]-NoDataFile",(int)fnum-1); -
trunk/AddOn/TAcq/racqurw.h
r3671 r3672 114 114 class PCIEMultiReader : public ZThread { 115 115 public: 116 PCIEMultiReader( vector<PCIEWrapperInterface*> vec_pciw , uint_4 sizeFrame,uint_4 paqSize, RAcqMemZoneMgr& mem, 117 uint_4 nmax=100, BRDataFmtConv swapall=BR_SwapAll); 116 PCIEMultiReader(vector<PCIEWrapperInterface*> vec_pciw , RAcqMemZoneMgr& mem, BRParList const& par); 118 117 virtual void run(); 119 118 void Stop(); … … 134 133 } 135 134 bool MZoneManage(bool clean=false); // Renvoie true si probleme 135 136 RAcqMemZoneMgr& memgr; 137 BRParList par_; // Parametres divers d'acquisition 136 138 137 RAcqMemZoneMgr& memgr;138 139 uint_4 nmax_; // Nombre maxi de blocs MemZone traites 139 140 BRDataFmtConv swapall_; // select data swap/format conversion for BRPaquet … … 158 159 //---------------------------------------------------------------------------------------- 159 160 161 // --- Cette classe utilise les parametres globaux d'acquisition BRAcqConfig 160 162 class MultiDataSaver : public ZThread { 161 163 public: 162 MultiDataSaver(RAcqMemZoneMgr& mem , string path, uint_4 nfiles=100, uint_4 nblocperfile=1, bool savesig=true);164 MultiDataSaver(RAcqMemZoneMgr& mem); 163 165 164 166 virtual void run(); … … 169 171 170 172 RAcqMemZoneMgr& memgr; 173 171 174 uint_4 nfiles_; // Nombre maxi de fichiers cree 172 175 uint_4 nblocperfile_; // Nombre de bloc (zone memoire) mis dans un fichier … … 174 177 bool savesig_; // Si false, pas d'ecriture des fichiers FITS du signal 175 178 bool stop_; 176 string path_;177 struct sigaction act;178 179 }; 179 180
Note:
See TracChangeset
for help on using the changeset viewer.