Changeset 3633 in Sophya for trunk/AddOn
- Timestamp:
- May 25, 2009, 6:58:30 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/tmtacq.cc
r3629 r3633 24 24 using namespace std; 25 25 using namespace SOPHYA; 26 27 static DataSaver *pDs; 28 static PCIEReaderChecker *pPcierc; 29 static PCIEReader *pPcier; 30 static DataProcFFT2C *pPrfft; 31 static DataProc2C *pPr; 32 static RAcqMemZoneMgr *pMmgr; 26 27 33 28 //-------------------------------------------------------- 34 29 // Programme test acquisition BAORadio multi-thread 35 30 // LAL - R. Ansari Juillet - 2008 31 // M.Taurigna 2009 36 32 //-------------------------------------------------------- 33 34 35 /* Fonction d'arret par Ctl<C> et ses pointeurs globaux */ 36 static DataSaver *pDs = NULL; 37 static DataSaver *pDs2 = NULL; 38 static PCIEReaderChecker *pPcierc = NULL; 39 static PCIEReaderChecker *pPcierc2 = NULL; 40 static PCIEReader *pPcier = NULL; 41 static PCIEReader *pPcier2 = NULL; 42 static DataProc2C *pPr = NULL; 43 static DataProc2C *pPr2 = NULL; 44 static DataProcFFT2C *pPrfft = NULL; 45 static DataProcFFT2C *pPrfft2 = NULL; 46 static RAcqMemZoneMgr *pMmgr = NULL; 47 static RAcqMemZoneMgr *pMmgr2 = NULL; 48 37 49 void Stop(int s) 38 50 { 39 printf("............. MAIN ... receive signal %d \n",s); 51 if (s == 9765) cout << " Stop after exception ..." << endl; 52 else printf("............. MAIN ... receive signal %d \n",s); 40 53 if (pPcierc != NULL) pPcierc->Stop(); 54 if (pPcierc2 != NULL) pPcierc2->Stop(); 41 55 if (pPcier != NULL) pPcier->Stop(); 56 if (pPcier2 != NULL) pPcier2->Stop(); 42 57 if (pPr !=NULL) pPr->Stop(); 58 if (pPr2 !=NULL) pPr2->Stop(); 43 59 if (pPrfft !=NULL) pPrfft->Stop(); 60 if (pPrfft2 !=NULL) pPrfft2->Stop(); 44 61 if (pDs != NULL) pDs->Stop(); 62 if (pDs2 != NULL) pDs2->Stop(); 45 63 if (pMmgr !=NULL) pMmgr->Stop(); 64 if (pMmgr2 !=NULL) pMmgr2->Stop(); 46 65 47 66 } 48 67 /* -------------------------------------------------------- */ 68 69 // Fonctions appelees par le main 70 void Usage(); 71 int DecodeArgs(int narg, char* arg[]); 72 void DecodeAcqMode(); 73 74 int MonoCardAcq(); 75 int MultiCardAcq(); 76 77 //------------------ Parametres de controle ---------------------------- 78 static string acqmode; 79 static bool savesigfits = true; 80 static BRDataFmtConv swapall = BR_Copy; 81 static bool monothr = false; 82 static string OutPathName; 83 static bool singlecard = true; 84 static int cardlist[4] = {1,1,1,1}; 85 static int card = 1; 86 static unsigned int sizeFrame = 4096; 87 static unsigned int nbFrameDMA = 32; 88 static int NbFiles=1; 89 static int NBlocPerFile=10; 90 static int NMaxProc = 0; // Nombre de blocs traites par le thread de calcul 91 static uint_4 nZones = 4; // Nombre de zones memoires 92 static uint_4 nPaqZone = 128; // 128 Paquets / zone memoire - valeur par defaut 93 static bool fg_hard_ctrlc = false; 94 static uint_4 PaqSZ = 4096; // Taille de paquets 95 // uint_4 dmaSize = nbFrameDMA*PaqSZ ; // plantage 96 static uint_4 dmaSize = 32*1024 ; 97 static uint_4 patternSZ=0x400; // pas utilise avec la fibre 98 static uint_4 NMaxBloc = 10; 99 //---------------------------- FIN parametres de controle ----------------- 100 101 //----------------------------------------------------------------------- 102 //-------------------- le programme principal --------------------------- 103 //----------------------------------------------------------------------- 49 104 int main(int narg, char* arg[]) 50 105 { 51 106 52 struct sigaction act;53 54 107 int rc = 0; 55 cout << " ===============================================================" << endl; 108 cout << " ============ BAORadio / Acquisition : tmtacq =================" << endl; 109 cout << " ===============================================================" << endl; 56 110 cout << " ========= " <<BAOR_ACQ_VER_STR <<BAOR_ACQ_VER <<" ===========" << endl; 57 111 cout << " ===============================================================" << endl; 58 112 59 if (narg < 8) { 60 cout << "\n Usage: tmtacq CardNum PaquetSize NFrameDMA NFiles NBlocPerFile NMaxProc DataDirPath [AcqMode] [MemZoneMgr][HardCtlC]" << endl; 61 cout << " - CardNum : PCI-Express card number (=1,2)" << endl; 113 int rcda = DecodeArgs(narg, arg); 114 if (rcda != 0) return 1; 115 InitTim(); 116 117 // Initialisation 118 TArrayInitiator _arri; 119 FitsIOServerInitiator _fiosi; 120 121 try { 122 if (singlecard) rc = MonoCardAcq(); 123 else rc = MultiCardAcq(); 124 } 125 catch (MiniFITSException& exc) { 126 cerr << " tmtacq.cc catched MiniFITSException " << exc.Msg() << endl; 127 Stop(9765); 128 rc = 77; 129 } 130 catch (PCIEWException& exc) { 131 cerr << " tmtacq.cc catched MiniFITSException " << exc.Msg() << endl; 132 Stop(9765); 133 rc = 75; 134 } 135 catch (PThrowable& exc) { 136 cerr << " tmtacq.cc catched Exception " << exc.Msg() << endl; 137 Stop(9765); 138 rc = 76; 139 } 140 catch (std::exception& sex) { 141 cerr << "\n tmtacq.cc std::exception :" 142 << (string)typeid(sex).name() << "\n msg= " 143 << sex.what() << endl; 144 Stop(9765); 145 rc = 78; 146 } 147 catch (...) { 148 cerr << " tmtacq.cc : Catched ... exception " << endl; 149 Stop(9765); 150 rc = 79; 151 } 152 cout << "tmtacq[9] ----- END --- stopping acq program " << endl; 153 return rc; 154 } 155 156 157 /* --Nouvelle-Fonction-- */ 158 void Usage() 159 { 160 cout << "\n Usage: tmtacq CardNum PaquetSize NFrameDMA NFiles NBlocPerFile \n" 161 << " NMaxProc DataDirPath [AcqMode] [MemZoneMgr][HardCtlC]" << endl; 162 cout << " - CardNum : PCI-Express card number (=1 OR 2 OR 1,2)" << endl; 62 163 cout << " - PaquetSize or FrameSize (=DATA+HDR+TRL_Size) " << endl; 63 164 cout << " - NFrameDMA = DMASize= NFrameDMA*1024 , 4KO<=MaxDMASize<=64 ko " << endl; … … 91 192 cout << " mononsw->Test with a single thread PCIEReaderChecker, But no swap paquet " << endl; 92 193 cout << endl; 93 cout << " - MemZoneMgr: nZones,NPaq =Number of Zones and number of paquet in each zone (Default=8,128) " << endl; 194 cout << " - MemZoneMgr: nZones,NPaq =Number of Zones and number of paquet in each zone (Default=8,128) " 195 << endl; 94 196 cout << " -HardCtlC : Y y (direct interrpution by CtrlC ) default (no) " << endl; 95 return 1; 96 } 97 98 InitTim(); 197 } 198 199 /* --Nouvelle-Fonction-- */ 200 int DecodeArgs(int narg, char* arg[]) 201 { 202 if (narg < 8) { 203 Usage(); 204 return 1; 205 } 206 acqmode = "std"; 207 acqmode = arg[8]; 208 savesigfits = true; 209 // BRDataFmtConv swapall = BR_SwapAll; 210 swapall = BR_Copy; 211 monothr = false; 212 DecodeAcqMode(); 213 214 if (index(arg[1],',') != NULL) { 215 sscanf(arg[1],"%d,%d", cardlist, cardlist+1); 216 cout << " tmtacq[1]/MultiPCICard acquisition ... Cards= " << cardlist[0] << " ," << cardlist[1] 217 << " FrameSize=PaqSize=" << sizeFrame << endl; 218 singlecard = false; 219 } 220 else { 221 card = atoi(arg[1]); 222 cardlist[0] = cardlist[1] = card; 223 singlecard = true; 224 cout << "tmtacq[1]/MonoPCICard acquisition ... Card= " << card << " FrameSize=PaqSize=" << sizeFrame << endl; 225 } 226 sizeFrame = atoi(arg[2]); 227 nbFrameDMA = atoi(arg[3]); 228 229 230 NbFiles = atoi(arg[4]); 231 NBlocPerFile = atoi(arg[5]); 232 NMaxProc = atoi(arg[6]); // Nombre de blocs traites par le thread de calcul 233 234 #ifdef NOPCIECARD 235 string OutPathName = string(arg[7])+"/"; 236 #else 237 string OutPathName =string("/Raid/")+arg[7]+"/"; 238 #endif 239 cout << " DataDirpath=" << OutPathName << " SwapMode=" << BRPaquet::FmtConvToString(swapall) 240 << " DataSaveMode=" << ((savesigfits)?"Yes/FitsFile":"NO") << endl; 241 242 char cmd[512]; 243 if (singlecard) { 244 sprintf(cmd,"mkdir %s",OutPathName.c_str()); 245 if (system(cmd) < 0) { 246 cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl; 247 return 2; 248 } 249 else cout << " tmtacq[1] - Executed command " << cmd << endl; 250 } 251 else { 252 sprintf(cmd,"mkdir %s",OutPathName.c_str()); 253 if (system(cmd) < 0) { 254 cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl; 255 return 2; 256 } 257 else cout << " tmtacq[1] - Executed command " << cmd << endl; 258 sprintf(cmd,"mkdir %s/Card1",OutPathName.c_str()); 259 if (system(cmd) < 0) { 260 cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl; 261 return 2; 262 } 263 else cout << " tmtacq[1] - Executed command " << cmd << endl; 264 sprintf(cmd,"mkdir %s/Card2",OutPathName.c_str()); 265 if (system(cmd) < 0) { 266 cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl; 267 return 2; 268 } 269 else cout << " tmtacq[1] - Executed command " << cmd << endl; 270 } 271 nZones = 8; // Nombre de zones memoires 272 nPaqZone = 128; // 128 Paquets / zone memoire - valeur par defaut 273 if (narg > 9) { 274 int ia1, ia2; 275 sscanf(arg[9],"%d,%d", &ia1, &ia2); 276 nZones = ia1; nPaqZone = ia2; 277 } 278 279 fg_hard_ctrlc = false; 280 281 struct sigaction act; 99 282 100 // Initialisation 101 TArrayInitiator _arri; 102 FitsIOServerInitiator _fiosi; 103 Timer tm("tmtacq"); 104 105 string acqmode = "std"; 106 if (narg > 8) acqmode = arg[8]; 107 bool savesigfits = true; 108 // BRDataFmtConv swapall = BR_SwapAll; 109 BRDataFmtConv swapall = BR_Copy; 110 bool monothr = false; 283 if (narg > 10) // pour traiter eventuellement un arret brutal par CtlC mettre le 10eme arg a Y 284 if ((*arg[10]=='y')||(*arg[10]=='Y')) fg_hard_ctrlc=true; 285 if (!fg_hard_ctrlc) { 286 act.sa_handler=Stop; 287 sigaction(SIGINT,&act,NULL); 288 } 289 290 PaqSZ =sizeFrame; // Taille de paquets 291 // uint_4 dmaSize = nbFrameDMA*PaqSZ ; // plantage 292 dmaSize = nbFrameDMA*1024 ; 293 patternSZ=0x400; // pas utilise avec la fibre 294 NMaxBloc = NbFiles*NBlocPerFile; 295 cout << "tmtacq[2] - PaqSize = " << PaqSZ << " NbPaq/Zone=" << nPaqZone << " NZones=" << nZones << endl; 296 cout << " NbFiles=" << NbFiles << " NBloc/File=" << NBlocPerFile << " -> NMaxBloc=" << NMaxBloc << endl; 297 cout << "tmtacq[2] NbFrameDMA=" << nbFrameDMA << " DMASize=" << dmaSize << " bytes" << endl; 298 cout << "tmtacq[2] NMaxProc=" << NMaxProc << endl; 299 300 return 0; 301 } 302 303 /* --Nouvelle-Fonction-- */ 304 void DecodeAcqMode() 305 { 111 306 if (acqmode == "swapall") swapall = BR_SwapAll; 112 307 if (acqmode == "fft1c") swapall = BR_FFTOneChan; … … 131 326 if (acqmode == "fft1cnofnosw") { swapall = BR_FFTOneChanNoSwap; savesigfits = false; } 132 327 if (acqmode == "fft2cnofnosw") { swapall = BR_FFTTwoChanNoSwap; savesigfits = false; } 133 328 } 329 330 331 /* --Nouvelle-Fonction-- */ 332 int MonoCardAcq() 333 { 334 Timer tm("tmtacq/MonoCard"); 335 336 cout << " ---- tmtacq/ MonoCardAcq() ------------- " << endl; 134 337 #ifdef NOPCIECARD 135 string dir = string(arg[7])+"/"; 136 #else 137 string dir =string("/Raid/")+arg[7]+"/"; 138 #endif 139 cout << " DataDirpath=" << dir << " SwapMode=" << BRPaquet::FmtConvToString(swapall) 140 << " DataSaveMode=" << ((savesigfits)?"Yes/FitsFile":"NO") << endl; 141 142 char cmd[192]; 143 sprintf(cmd,"mkdir %s",dir.c_str()); 144 if (system(cmd) < 0) { 145 cout << "tmtacq/Error: Can not create subdirectory " << dir << " -> exit" << endl; 146 return 2; 147 } 148 int card = atoi(arg[1]); 149 unsigned int sizeFrame = atoi(arg[2]); 150 unsigned int nbFrameDMA = atoi(arg[3]); 151 int NbFiles = atoi(arg[4]); 152 int NBlocPerFile = atoi(arg[5]); 153 int NMaxProc = atoi(arg[6]); // Nombre de blocs traites par le thread de calcul 154 cout << "tmtacq[1] - starting acq program under card " << card << " FrameSize= " << sizeFrame << endl; 155 156 uint_4 nZones = 8; // Nombre de zones memoires 157 uint_4 nPaqZone = 128; // 128 Paquets / zone memoire - valeur par defaut 158 if (narg > 9) { 159 int ia1, ia2; 160 sscanf(arg[9],"%d,%d", &ia1, &ia2); 161 nZones = ia1; nPaqZone = ia2; 162 } 163 164 bool fg_hard_ctrlc = false; 165 if (narg > 10) // pour traiter eventuellement un arret brutal par CtlC mettre le 10eme arg a Y 166 if ((*arg[10]=='y')||(*arg[10]=='Y')) fg_hard_ctrlc=true; 167 if (!fg_hard_ctrlc) { 168 act.sa_handler=Stop; 169 sigaction(SIGINT,&act,NULL); 170 } 171 172 uint_4 PaqSZ =sizeFrame; // Taille de paquets 173 // uint_4 dmaSize = nbFrameDMA*PaqSZ ; // plantage 174 uint_4 dmaSize = nbFrameDMA*1024 ; 175 uint_4 patternSZ=0x400; // pas utilise avec la fibre 176 uint_4 NMaxBloc = NbFiles*NBlocPerFile; 177 cout << "tmtacq[0] - PaqSize = " << PaqSZ << " NbPaq/Zone=" << nPaqZone << " NZones=" << nZones << endl; 178 cout << " NbFiles=" << NbFiles << " NBloc/File=" << NBlocPerFile << " -> NMaxBloc=" << NMaxBloc << endl; 179 cout << "tmtacq[1] NbFrameDMA=" << nbFrameDMA << " DMASize=" << dmaSize << " bytes" << endl; 180 cout << "tmtacq[1] NMaxProc=" << NMaxProc << endl; 181 try { 338 TestPCIWrapperNODMA pciw(PaqSZ); 339 #else 340 DMAMgr dma1(card,patternSZ,dmaSize ); 341 if (! dma1.StatusFibre() ) { 342 cout << " tmtacq[3] - fibre non accrochee -> exit " << endl; 343 throw PCIEWException(" Fibre non accrochee "); 344 } 345 else cout << " tmtacq[3] - fibre accrochee OK " << endl; 346 PCIEWrapper pciw(dma1); 347 #endif 348 RAcqMemZoneMgr mmgr(nZones, nPaqZone, PaqSZ); 349 pMmgr =&mmgr; 350 351 if (monothr) { 352 cout << "tmtacq[4] single thread PCIE test PCIEReaderChecker ... "; 353 PCIEReaderChecker pcirc(pciw,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall); 354 pPcierc=&pcirc; 355 pcirc.start(); 356 sleep(1); 357 pcirc.join(); 358 cout << "tmtacq[5] - single thread PCIEReaderChecker finished " << endl; 359 tm.Split("Single Thread Finished"); 360 mmgr.Print(cout); 361 return 0; 362 } 363 PCIEReader pcir(pciw,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall); 364 pPcier= &pcir; 365 DataSaver ds(mmgr, OutPathName, NbFiles, NBlocPerFile, savesigfits); 366 pDs= &ds; 367 //DataBinSaver ds(mmgr, OutPathName, NbFiles ,NBlocPerFile); 368 // DataProc1C pr(mmgr, OutPathName, nmean, stepproc, 100); Pour processer un canal 369 int stepproc = 2; 370 int nmean = nPaqZone*NBlocPerFile/stepproc; 371 DataProc2C pr(mmgr, OutPathName, nmean, stepproc, NMaxProc); 372 DataProcFFT2C prfft(mmgr, OutPathName, nmean, stepproc, NMaxProc); 373 tm.Split("Threads created"); 374 cout << "tmtacq[4] - starting 3 threads pcir, ds, pr ... " << endl; 375 /* 376 char test[100]; 377 cout << " <CR> to continue, x to exit ..." << endl; 378 gets(test); if (test[0] == 'x') return 9; 379 */ 380 pcir.start(); 381 ds.start(); 382 if (NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0 383 if (acqmode.substr(0,5)=="fft2c") { prfft.start(); pPrfft=&prfft;} 384 else { pr.start(); pPr=≺} 385 } 386 cout << "tmtacq[5] - waiting for threads to finish ... " << endl; 387 sleep(1); 388 pcir.join(); 389 ds.join(); 390 sleep(1); 391 mmgr.Stop(); 392 if (NMaxProc>0) if ( pPr != NULL) pr.join(); 393 if (NMaxProc>0) if ( pPrfft != NULL) prfft.join(); 394 cout << "tmtacq[6] - threads finished " << endl; 395 tm.Split("Threads Finished"); 396 mmgr.Print(cout); 397 return 0; 398 } 399 400 401 /* --Nouvelle-Fonction-- */ 402 int MultiCardAcq() 403 { 404 Timer tm("tmtacq/MultiCard"); 405 406 cout << " ---- tmtacq/ MultiCardAcq() ------------- " << endl; 182 407 183 408 #ifdef NOPCIECARD 184 TestPCIWrapperNODMA pciw(PaqSZ); 409 TestPCIWrapperNODMA pciw1(PaqSZ); 410 TestPCIWrapperNODMA pciw2(PaqSZ); 185 411 #else 186 DMAMgr dma1(card,patternSZ,dmaSize ); 187 if (! dma1.StatusFibre() ) { 188 cout << " tmtacq[0] - fibre non accrochee -> exit " << endl; 189 throw PCIEWException(" Fibre non accrochee "); 412 DMAMgr dma1(cardlist[0],patternSZ,dmaSize ); 413 if (! dma1.StatusFibre() ) { 414 cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[0] << " -> exit " << endl; 415 throw PCIEWException(" Fibre non accrochee 1"); 416 } 417 else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[0] << endl; 418 419 DMAMgr dma2(cardlist[1],patternSZ,dmaSize ); 420 if (! dma1.StatusFibre() ) { 421 cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[1] << " -> exit " << endl; 422 throw PCIEWException(" Fibre non accrochee 2"); 423 } 424 else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[1] << endl; 425 426 PCIEWrapper pciw1(dma1); 427 PCIEWrapper pciw2(dma2); 428 #endif 429 RAcqMemZoneMgr mmgr1(nZones, nPaqZone, PaqSZ); 430 RAcqMemZoneMgr mmgr2(nZones, nPaqZone, PaqSZ); 431 pMmgr =&mmgr1; 432 pMmgr2 =&mmgr2; 433 434 if (monothr) { 435 cout << "tmtacq[4] single thread/Card PCIE test PCIEReaderChecker ... "; 436 PCIEReaderChecker pcirc1(pciw1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall); 437 PCIEReaderChecker pcirc2(pciw1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall); 438 pPcierc=&pcirc1; 439 pPcierc2=&pcirc2; 440 pcirc1.start(); 441 442 sleep(1); 443 pcirc1.join(); 444 pcirc2.join(); 445 446 cout << "tmtacq[5] - single thread/Card PCIEReaderChecker finished " << endl; 447 tm.Split("Single Thread Finished"); 448 mmgr1.Print(cout); 449 mmgr2.Print(cout); 450 return 0; 451 } 452 PCIEReader pcir1(pciw1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall); 453 pPcier= &pcir1; 454 PCIEReader pcir2(pciw2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall); 455 pPcier2= &pcir2; 456 char buff[32]; 457 sprintf(buff, "Card%d", cardlist[0]); 458 string path1 = OutPathName + buff; 459 DataSaver ds1(mmgr1, path1, NbFiles, NBlocPerFile, savesigfits); 460 pDs= &ds1; 461 sprintf(buff, "Card%d", cardlist[1]); 462 string path2 = OutPathName + buff; 463 DataSaver ds2(mmgr2, path2, NbFiles, NBlocPerFile, savesigfits); 464 pDs2= &ds2; 465 //DataBinSaver ds(mmgr, OutPathName, NbFiles ,NBlocPerFile); 466 // DataProc1C pr(mmgr, OutPathName, nmean, stepproc, 100); Pour processer un canal 467 int stepproc = 2; 468 int nmean = nPaqZone*NBlocPerFile/stepproc; 469 DataProc2C pr1(mmgr1, path1, nmean, stepproc, NMaxProc); 470 DataProcFFT2C prfft1(mmgr1, path1, nmean, stepproc, NMaxProc); 471 DataProc2C pr2(mmgr2, path2, nmean, stepproc, NMaxProc); 472 DataProcFFT2C prfft2(mmgr2, path2, nmean, stepproc, NMaxProc); 473 474 tm.Split("Threads created"); 475 cout << "tmtacq[4] - starting 3 threads pcir, ds, pr ... " << endl; 476 /* 477 char test[100]; 478 cout << " <CR> to continue, x to exit ..." << endl; 479 gets(test); if (test[0] == 'x') return 9; 480 */ 481 pcir1.start(); 482 ds1.start(); 483 pcir2.start(); 484 ds2.start(); 485 if (NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0 486 if (acqmode.substr(0,5)=="fft2c") { 487 prfft1.start(); pPrfft=&prfft1; 488 prfft2.start(); pPrfft2=&prfft2; 190 489 } 191 else cout << " tmtacq[0] - fibre accrochee OK " << endl; 192 PCIEWrapper pciw(dma1); 193 #endif 194 RAcqMemZoneMgr mmgr(nZones, nPaqZone, PaqSZ); 195 pMmgr =&mmgr; 196 197 if (monothr) { 198 cout << "tmtacq[1] single thread PCIE test PCIEReaderChecker ... "; 199 PCIEReaderChecker pcirc(pciw,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall); 200 pPcierc=&pcirc; 201 pcirc.start(); 202 sleep(1); 203 pcirc.join(); 204 cout << "tmtacq[2] - single thread PCIEReaderChecker finished " << endl; 205 tm.Split("Single Thread Finished"); 206 mmgr.Print(cout); 207 return 0; 490 else { 491 pr1.start(); pPr=&pr1; 492 pr2.start(); pPr2=&pr2; 208 493 } 209 PCIEReader pcir(pciw,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall); 210 pPcier= &pcir; 211 DataSaver ds(mmgr, dir, NbFiles, NBlocPerFile, savesigfits); 212 pDs= &ds; 213 //DataBinSaver ds(mmgr, dir, NbFiles ,NBlocPerFile); 214 // DataProc1C pr(mmgr, dir, nmean, stepproc, 100); Pour processer un canal 215 int stepproc = 2; 216 int nmean = nPaqZone*NBlocPerFile/stepproc; 217 DataProc2C pr(mmgr, dir, nmean, stepproc, NMaxProc); 218 DataProcFFT2C prfft(mmgr, dir, nmean, stepproc, NMaxProc); 219 tm.Split("Threads created"); 220 cout << "tmtacq[2] - starting 3 threads pcir, ds, pr ... " << endl; 221 /* 222 char test[100]; 223 cout << " <CR> to continue, x to exit ..." << endl; 224 gets(test); if (test[0] == 'x') return 9; 225 */ 226 pcir.start(); 227 ds.start(); 228 if (NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0 229 if (acqmode.substr(0,5)=="fft2c") { prfft.start(); pPrfft=&prfft;} 230 else { pr.start(); pPr=≺} 231 } 232 cout << "tmtacq[3] - waiting for threads to finish ... " << endl; 233 sleep(1); 234 pcir.join(); 235 ds.join(); 236 sleep(1); 237 mmgr.Stop(); 238 if (NMaxProc>0) if ( pPr != NULL) pr.join(); 239 if (NMaxProc>0) if ( pPrfft != NULL) prfft.join(); 240 cout << "tmtacq[4] - threads finished " << endl; 241 tm.Split("Threads Finished"); 242 mmgr.Print(cout); 243 rc = 0; 244 } 245 catch (MiniFITSException& exc) { 246 cerr << " tmtacq.cc catched MiniFITSException " << exc.Msg() << endl; 247 rc = 77; 248 } 249 catch (PCIEWException& exc) { 250 cerr << "\7 tmtacq.cc catched MiniFITSException " << exc.Msg() << endl; 251 rc = 75; 252 } 253 catch (PThrowable& exc) { 254 cerr << " tmtacq.cc catched Exception " << exc.Msg() << endl; 255 rc = 76; 256 } 257 catch (std::exception& sex) { 258 cerr << "\n tmtacq.cc std::exception :" 259 << (string)typeid(sex).name() << "\n msg= " 260 << sex.what() << endl; 261 rc = 78; 262 } 263 catch (...) { 264 cerr << " tmtacq.cc : Catched ... exception " << endl; 265 rc = 79; 266 } 267 cout << "tmtacq[9] - stopping acq program " << endl; 268 return rc; 269 } 270 494 } 495 cout << "tmtacq[5] - waiting for threads to finish ... " << endl; 496 sleep(1); 497 pcir1.join(); 498 ds1.join(); 499 sleep(1); 500 mmgr1.Stop(); 501 mmgr2.Stop(); 502 if (NMaxProc>0) { 503 if ( pPr != NULL) pr1.join(); 504 if ( pPr2 != NULL) pr2.join(); 505 if ( pPrfft != NULL) prfft1.join(); 506 if ( pPrfft2 != NULL) prfft2.join(); 507 } 508 509 cout << "tmtacq[6] - threads finished " << endl; 510 tm.Split("Threads Finished"); 511 mmgr1.Print(cout); 512 mmgr2.Print(cout); 513 return 0; 514 }
Note:
See TracChangeset
for help on using the changeset viewer.