Changeset 3757 in Sophya for trunk/AddOn/TAcq/mfacq.cc
- Timestamp:
- Apr 30, 2010, 12:54:25 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/mfacq.cc
r3683 r3757 9 9 static RAcqMemZoneMgr* pMmgr=NULL; 10 10 static PCIEMultiReader* pPcierThr=NULL; 11 static PCIEToEthernet* pPcie2Eth=NULL; 12 static EthernetReader* pEthRdr=NULL; 11 13 12 14 void Stop(int s) … … 15 17 else printf("............. MAIN ... receive signal %d \n",s); 16 18 if (pMmgr != NULL) pMmgr->Stop(); 19 if (pPcie2Eth !=NULL) pPcie2Eth->Stop(); 17 20 if (pPcierThr !=NULL) pPcierThr->Stop(); 18 21 if (pEthRdr !=NULL) pEthRdr->Stop(); 19 22 } 20 23 … … 40 43 41 44 42 if ((narg < 2)||(strcmp(arg[1],"-h"))==0) {45 if ((narg > 1)&&(strcmp(arg[1],"-h"))==0) { 43 46 Usage(false); 44 47 return 1; 45 48 } 46 47 string pardcfile=arg[1]; 49 if (narg < 3) { 50 Usage(true); 51 return 3; 52 } 53 54 const char* desact[3] = {"PCIE_To_Ethernet", "Ethernet_To_Disk", "PCIE_DMA_To_Disk"}; 55 string action=arg[1]; 56 int act = 0; 57 if ((action != "-pci2eth")&&(action != "-pci2disk")&&(action != "-eth2disk")) { 58 cout << " mfacq/Error , Bad action argument : " << action << endl; 59 return 2; 60 } 61 if (action == "-pci2eth") act=0; 62 else if (action == "-eth2disk") act=1; 63 else if (action == "-pci2disk") act=2; 64 65 string pardcfile=arg[2]; 48 66 #ifndef NOPCIECARD 49 67 string basedir="/Raid"; … … 51 69 string basedir="./"; 52 70 #endif 53 if (narg>2) basedir=arg[2]; 71 vector<string> oargs; 72 if (narg>3) { 73 basedir=arg[2]; 74 for(int jj=2; jj<narg; jj++) oargs.push_back(arg[jj]); 75 } 54 76 try { 55 77 // Creation/initialisation parametres Acq 56 78 BRAcqConfig acpar; 57 acpar.ReadParamFile( arg[1]);79 acpar.ReadParamFile(pardcfile); 58 80 acpar.GetConfig().SetBaseDirectory(basedir); 81 if ((act==0)&&(oargs.size()>0)) 82 acpar.GetParams().SetEthTargets(oargs); 59 83 // Creation des repertoires 60 if (acpar.CreateOutputDirectories()!=0) return 9; 84 if (act > 0) 85 if (acpar.CreateOutputDirectories()!=0) return 9; 61 86 acpar.Print(cout); 62 struct sigaction act;87 struct sigaction siact; 63 88 if (!acpar.GetParams().fg_hard_ctrlc) { 64 act.sa_handler=Stop;65 sigaction(SIGINT,& act,NULL);89 siact.sa_handler=Stop; 90 sigaction(SIGINT,&siact,NULL); 66 91 } 67 rc = MultiFibreAcq(); 92 switch (act) { 93 case 0: 94 rc = PCIEToEthernetTransfer(); 95 break; 96 case 1: 97 rc = EthernetToMemoryAcq(); 98 break; 99 case 2: 100 rc = MultiFibreAcq(); 101 break; 102 } 68 103 } 69 104 catch (MiniFITSException& exc) { … … 97 132 void Usage(bool fgshort) 98 133 { 99 if (fgshort) {100 cout << " Usage: mfacq DataCardFile [BaseDirectory] \n" << endl;101 cout << " Parameters in DataCard : \n"102 << " fibres outpathname skysource paqsize dmasizekb nbfiles \n" 103 << " nblocperfile acqmode memmgr monitor reducpaqsz "<< endl; 104 cout << " BaseDirectory (default= /Raid ) "<< endl;105 return;106 }134 cout << " Usage: mfacq Action DataCardFile [BaseDirectory / TargetMachines] \n" << endl; 135 if (fgshort) return; 136 cout << " Action = -pci2disk , -pci2mem -eth2disk \n " 137 << " Parameters in DataCard : \n" 138 << " fibres outpathname skysource paqsize dmasizekb nbfiles \n" 139 << " nblocperfile acqmode memmgr monitor reducpaqsz "<< endl; 140 cout << " BaseDirectory (default= /Raid ) " << endl; 141 cout << " TargetMachines : List of target machines for PCIe2Ethernet " << endl; 107 142 return; 108 143 } … … 114 149 Timer tm("mfacq/MultiFibre"); 115 150 cout << " ---------- mfacq/ MultiFibreAcq() ------------- " << endl; 116 PCIEWrapperInterface* pciwp[4]={NULL,NULL,NULL,NULL}; 151 PCIEWrapperInterface* pciwp[16]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, 152 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; 117 153 118 154 BRAcqConfig bpar; … … 144 180 TestPCIWrapperNODMA pciw3(bpar.RecvPaquetSize(), acpar.nopciLossRate); 145 181 TestPCIWrapperNODMA pciw4(bpar.RecvPaquetSize(), acpar.nopciLossRate); 182 TestPCIWrapperNODMA pciw5(bpar.RecvPaquetSize(), acpar.nopciLossRate); 183 TestPCIWrapperNODMA pciw6(bpar.RecvPaquetSize(), acpar.nopciLossRate); 184 TestPCIWrapperNODMA pciw7(bpar.RecvPaquetSize(), acpar.nopciLossRate); 185 TestPCIWrapperNODMA pciw8(bpar.RecvPaquetSize(), acpar.nopciLossRate); 146 186 pciwp[0] = &pciw1; 147 187 pciwp[1] = &pciw2; 148 188 pciwp[2] = &pciw3; 149 pciwp[3] = &pciw4; 189 pciwp[3] = &pciw4; 190 pciwp[4] = &pciw5; 191 pciwp[5] = &pciw6; 192 pciwp[6] = &pciw7; 193 pciwp[7] = &pciw8; 150 194 #endif 151 195 … … 197 241 198 242 } 243 244 /* --Nouvelle-Fonction-- */ 245 int PCIEToEthernetTransfer() 246 { 247 Timer tm("mfacq/PCIEToEthernetTransfer"); 248 cout << " ---------- mfacq/ PCIEToEthernetTransfer() ------------- " << endl; 249 PCIEWrapperInterface* pciwp[16]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, 250 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; 251 252 pMmgr=NULL; 253 BRAcqConfig bpar; 254 BRParList& acpar=bpar.GetParams(); 255 256 cout << " mfacq[1]/Info: PCIEToEthernet for" << acpar.NbFibers << " fibers , nZones=" 257 << acpar.nZones << " NbPaquet/Zone=" << acpar.nPaqZone 258 << " MmgrPaqSize=" << acpar.MMgrPaquetSize() << endl; 259 260 #ifndef NOPCIECARD 261 for (int i=0 ;i <acpar.NFibers() ;i++) { 262 UINT32 card=(acpar.FiberNum[i]-1)/2+1; 263 UINT32 cardfiber=(acpar.FiberNum[i]-1)%2; 264 cout <<"mfacq[2] CreatePCIEWrapperV6- indice " << i << "INIT card " << card 265 << " fibre " << cardfiber << endl; 266 pciwp[i] = CreatePCIEWrapperV6(card,acpar.PatternSize(),acpar.DMASizeBytes(),acpar.activate_pattern,cardfiber); 267 } 268 #else 269 TestPCIWrapperNODMA pciw1(bpar.RecvPaquetSize(), acpar.nopciLossRate); 270 TestPCIWrapperNODMA pciw2(bpar.RecvPaquetSize(), acpar.nopciLossRate); 271 TestPCIWrapperNODMA pciw3(bpar.RecvPaquetSize(), acpar.nopciLossRate); 272 TestPCIWrapperNODMA pciw4(bpar.RecvPaquetSize(), acpar.nopciLossRate); 273 TestPCIWrapperNODMA pciw5(bpar.RecvPaquetSize(), acpar.nopciLossRate); 274 TestPCIWrapperNODMA pciw6(bpar.RecvPaquetSize(), acpar.nopciLossRate); 275 TestPCIWrapperNODMA pciw7(bpar.RecvPaquetSize(), acpar.nopciLossRate); 276 TestPCIWrapperNODMA pciw8(bpar.RecvPaquetSize(), acpar.nopciLossRate); 277 pciwp[0] = &pciw1; 278 pciwp[1] = &pciw2; 279 pciwp[2] = &pciw3; 280 pciwp[3] = &pciw4; 281 pciwp[4] = &pciw5; 282 pciwp[5] = &pciw6; 283 pciwp[6] = &pciw7; 284 pciwp[7] = &pciw8; 285 #endif 286 287 vector<PCIEWrapperInterface*> vec_pciw; 288 for (int i=0 ;i<bpar.NFibers();i++) vec_pciw.push_back( pciwp[i]); 289 cout <<"mfacq[2] Creating PCIEToEthernet thread object " << endl; 290 PCIEToEthernet pci2eth(vec_pciw, bpar.GetParams().GetEthTargets(), bpar.GetParams()); 291 // usleep(200); attente au cas ou ... 292 pPcie2Eth=&pci2eth; 293 tm.Split("Threads created"); 294 cout << "mfacq[3] - starting one threads: PCIEToEthernet... " << endl; 295 pci2eth.start(); 296 297 // On attend avant de declencher la terminaison des threads 298 usleep(200000); 299 300 cout << "mfacq[5] - Waiting for threads to finish ... " << endl; 301 pci2eth.join(); 302 cout << "mfacq[6] ---------- threads finished ---------------- " << endl; 303 tm.Split("Threads Finished"); 304 305 #ifndef NOPCIECARD 306 for (int i=0 ;i <acpar.NbFibers ;i++) { 307 UINT32 card=(acpar.FiberNum[i]-1)/2+1; 308 UINT32 cardfiber=(acpar.FiberNum[i]-1)%2; 309 DeletePCIEWrapperV6(card,cardfiber); 310 } 311 #endif 312 return 0; 313 } 314 315 /* --Nouvelle-Fonction-- */ 316 int EthernetToMemoryAcq() 317 { 318 Timer tm("mfacq/EthernetToMemoryAcq"); 319 cout << " ---------- mfacq/ EthernetToMemoryAcq() ------------- " << endl; 320 321 BRAcqConfig bpar; 322 BRParList& acpar=bpar.GetParams(); 323 324 cout << " mfacq[1]/Info: Creating RAcqMemZoneMgr for" << acpar.NbEthLinks() << " Eth-links , nZones=" 325 << acpar.nZones << " NbPaquet/Zone=" << acpar.nPaqZone 326 << " MmgrPaqSize=" << acpar.MMgrPaquetSize() << endl; 327 RAcqMemZoneMgr mmgr(acpar.nZones, acpar.NbEthLinks(), acpar.nPaqZone, acpar.MMgrPaquetSize()); 328 pMmgr=&mmgr; 329 if (acpar.fgdoProc && (acpar.stepProc>0)) { 330 // Dans ce cas, toutes les zones doivent passer ds le thread de monitoring 331 // pour etre au moins marque comme traite - seul 1/acpar.stepProc sont effectivement traite 332 mmgr.SetFinalizedMask(((uint_4)MemZS_Saved) | ((uint_4)MemZS_Proc)); 333 cout << " mfacq[1.b]/Info: Mmgr.SetFinalizedMask( MemZS_Saved | MemZS_Proc )" << endl; 334 } 335 336 337 cout <<"mfacq[2] Creating MultiDataSaver and MonitorProc thread objects ... " << endl; 338 MultiDataSaver DsThr(mmgr); // Utilise les parametres globaux BRAcqConfig 339 string ppath=bpar.OutputDirectory(); 340 MonitorProc PrThr(mmgr); 341 cout << "mfacq[3] Creating EthernetReader thread object " << endl; 342 EthernetReader ethrdr(mmgr, bpar.GetParams(), bpar.GetParams().tcpportid, false); 343 // usleep(200); attente au cas ou ... 344 pEthRdr=ðrdr; 345 tm.Split("Threads created"); 346 if (acpar.fgdoProc>0) 347 cout << "mfacq[4] - starting three threads: EthernetReader, MultiDataSaver, MonitorProc ... " << endl; 348 else 349 cout << "mfacq[4] - starting two threads: EthernetReader, MultiDataSaver ... " << endl; 350 351 ethrdr.start(); 352 DsThr.start(); 353 if (acpar.fgdoProc>0) { // On ne demarre que si au moins NMaxProc>0 354 PrThr.start(); 355 } 356 357 // On attend avant de declencher la terminaison des threads 358 usleep(200000); 359 360 cout << "mfacq[5] - Waiting for threads to finish ... " << endl; 361 ethrdr.join(); 362 DsThr.join(); 363 mmgr.Stop(); 364 if (acpar.fgdoProc) { // On n'attend la fin que si le thread a ete demarre (NMaxProc>0) 365 PrThr.join(); 366 } 367 pMmgr=NULL; 368 cout << "mfacq[6] ---------- threads finished ---------------- " << endl; 369 tm.Split("Threads Finished"); 370 371 mmgr.Print(cout); 372 373 return 0; 374 375 }
Note:
See TracChangeset
for help on using the changeset viewer.