source: Sophya/trunk/AddOn/TAcq/tmtacq.cc@ 3644

Last change on this file since 3644 was 3644, checked in by ansari, 16 years ago

Ajout possibilite de mettre /dev/null pour les fichiers fits , cmv+reza

File size: 21.9 KB
Line 
1#include <iostream>
2#include <stdlib.h>
3#include <string.h>
4#include <typeinfo>
5
6#include "tmtacq.h"
7#include "racqumem.h"
8#include "racqurw.h"
9#ifndef NOPCIECARD
10#include "racquwbin.h"
11#include "dmamgrv3.h"
12#endif
13#include "racquproc.h"
14
15
16#include "pciewrap.h"
17#include "brpaqu.h"
18#include "minifits.h"
19
20#include "resusage.h"
21#include "ctimer.h"
22#include "timing.h"
23
24#include "tarrinit.h"
25#include "fiosinit.h"
26
27using namespace std;
28using namespace SOPHYA;
29
30
31//--------------------------------------------------------
32// Programme test acquisition BAORadio multi-thread
33// LAL - R. Ansari Juillet - 2008
34// M.Taurigna 2009
35//--------------------------------------------------------
36
37
38/* Fonction d'arret par Ctl<C> et ses pointeurs globaux */
39static DataSaver *pDs = NULL;
40static DataSaver *pDs2 = NULL;
41static PCIEReaderChecker *pPcierc = NULL;
42static PCIEReaderChecker *pPcierc2 = NULL;
43static PCIEReader *pPcier = NULL;
44static PCIEReader *pPcier2 = NULL;
45static DataProc2C *pPr = NULL;
46static DataProc2C *pPr2 = NULL;
47static DataProcFFT2C *pPrfft = NULL;
48static DataProcFFT2C *pPrfft2 = NULL;
49static RAcqMemZoneMgr *pMmgr = NULL;
50static RAcqMemZoneMgr *pMmgr2 = NULL;
51
52void Stop(int s)
53{
54 if (s == 9765) cout << " Stop after exception ..." << endl;
55 else printf("............. MAIN ... receive signal %d \n",s);
56 if (pPcierc != NULL) pPcierc->Stop();
57 if (pPcierc2 != NULL) pPcierc2->Stop();
58 if (pPcier != NULL) pPcier->Stop();
59 if (pPcier2 != NULL) pPcier2->Stop();
60 if (pPr !=NULL) pPr->Stop();
61 if (pPr2 !=NULL) pPr2->Stop();
62 if (pPrfft !=NULL) pPrfft->Stop();
63 if (pPrfft2 !=NULL) pPrfft2->Stop();
64 if (pDs != NULL) pDs->Stop();
65 if (pDs2 != NULL) pDs2->Stop();
66 if (pMmgr !=NULL) pMmgr->Stop();
67 if (pMmgr2 !=NULL) pMmgr2->Stop();
68
69}
70
71#ifndef NOPCIECARD
72// Declaration des fonctions pour DMAMgr... firmware V51
73PCIEWrapperInterface* CreatePCIEWrapperV5F1( UINT32 numcard , UINT32 patternsize,
74 UINT32 dmasz, bool activpatt=false);
75void DeletePCIEWrapperV5F1(UINT32 numcard);
76PCIEWrapperInterface* CreatePCIEWrapperV5F2( UINT32 numcard , UINT32 patternsize,
77 UINT32 dmasz, bool activpatt=false);
78void DeletePCIEWrapperV5F2(UINT32 numcard);
79#endif
80
81/* -------------------------------------------------------- */
82
83// Fonctions appelees par le main
84void Usage(bool fgshort=true);
85int DecodeArgs(int narg, char* arg[]);
86void DecodeAcqMode();
87
88int MonoCardAcq();
89int MultiCardAcq();
90
91//------------------ Parametres de controle ----------------------------
92static string acqmode;
93static int fibre = 0; // =0 firmware pciexpress V496, =1 V51, fibre 1, =2 V51, fibre 2
94static bool savesigfits = true;
95static bool fgnulldev4fits = false;
96static BRDataFmtConv swapall = BR_Copy;
97static bool monothr = false;
98static string OutPathName;
99static string ProcPathName;
100static bool singlecard = true;
101static int cardlist[4] = {1,1,1,1};
102static int card = 1;
103static unsigned int sizeFrame = 4096;
104static unsigned int nbFrameDMA = 32;
105static int NbFiles=1;
106static int NBlocPerFile=10;
107static int NMaxProc = 0; // Nombre de blocs traites par le thread de calcul
108static uint_4 nZones = 4; // Nombre de zones memoires
109static uint_4 nPaqZone = 128; // 128 Paquets / zone memoire - valeur par defaut
110static bool fg_hard_ctrlc = false;
111static uint_4 PaqSZ = 4096; // Taille de paquets
112 // uint_4 dmaSize = nbFrameDMA*PaqSZ ; // plantage
113static uint_4 dmaSize = 32*1024 ;
114static uint_4 patternSZ=0x400; // pas utilise avec la fibre
115static bool activate_pattern=false; // true -> on active le pattern du firmware au lieu de la fibre
116static uint_4 NMaxBloc = 10;
117//---------------------------- FIN parametres de controle -----------------
118
119//-----------------------------------------------------------------------
120//-------------------- le programme principal ---------------------------
121//-----------------------------------------------------------------------
122int main(int narg, char* arg[])
123{
124
125 int rc = 0;
126 cout << " ============ BAORadio / Acquisition : tmtacq =================" << endl;
127 cout << " ===============================================================" << endl;
128 cout << " ========= " <<BAOR_ACQ_VER_STR <<BAOR_ACQ_VER <<" ===========" << endl;
129 cout << " ===============================================================" << endl;
130
131 int rcda = DecodeArgs(narg, arg);
132 if (rcda != 0) return 1;
133 InitTim();
134
135 // Initialisation
136 TArrayInitiator _arri;
137 FitsIOServerInitiator _fiosi;
138
139 try {
140 if (singlecard) rc = MonoCardAcq();
141 else rc = MultiCardAcq();
142 }
143 catch (MiniFITSException& exc) {
144 cerr << " tmtacq.cc catched MiniFITSException " << exc.Msg() << endl;
145 Stop(9765);
146 rc = 77;
147 }
148 catch (PCIEWException& exc) {
149 cerr << " tmtacq.cc catched MiniFITSException " << exc.Msg() << endl;
150 Stop(9765);
151 rc = 75;
152 }
153 catch (PThrowable& exc) {
154 cerr << " tmtacq.cc catched Exception " << exc.Msg() << endl;
155 Stop(9765);
156 rc = 76;
157 }
158 catch (std::exception& sex) {
159 cerr << "\n tmtacq.cc std::exception :"
160 << (string)typeid(sex).name() << "\n msg= "
161 << sex.what() << endl;
162 Stop(9765);
163 rc = 78;
164 }
165 catch (...) {
166 cerr << " tmtacq.cc : Catched ... exception " << endl;
167 Stop(9765);
168 rc = 79;
169 }
170 cout << "tmtacq[9] ----- END --- stopping acq program " << endl;
171 return rc;
172}
173
174
175/* --Nouvelle-Fonction-- */
176void Usage(bool fgshort)
177{
178 if (fgshort) {
179 cout << " Usage: tmtacq CardNum PaquetSize NFrameDMA NFiles NBlocPerFile \n"
180 << " NMaxProc DataDirPath [AcqMode] [MemZoneMgr][HardCtlC]" << endl;
181 cout << " type tmtacq -h for detailed usage " << endl;
182 return;
183 }
184
185 cout << "\n Usage: tmtacq CardNum PaquetSize NFrameDMA NFiles NBlocPerFile \n"
186 << " NMaxProc DataDirPath [AcqMode] [MemZoneMgr][HardCtlC]" << endl;
187 cout << " - CardNum : PCI-Express card number (=1 OR 2 OR 1,2)" << endl;
188 cout << " - PaquetSize or FrameSize (=DATA+HDR+TRL_Size) " << endl;
189 cout << " - NFrameDMA = DMASize= NFrameDMA*1024 , 4KO<=MaxDMASize<=64 ko " << endl;
190 cout << " - NFiles = Number of data files produced " << endl;
191 cout << " - NBlocPerFile = Number of memory data bloc in one file " << endl;
192 cout << " - NMaxProc = Max number of memory data blocs processed (FFT ...) " << endl;
193 cout << " NMaxProc=0 -> No Processing " << endl;
194 cout << " - DataDirPath : Subdirectory of /Raid " << endl;
195 cout << " specify /dev/null for performance tests ( ./XZXZXZX/ then used for other files)" << endl;
196 cout << " - AcqMode: Acquisition mode for the firmware V=496 (manages 64bits-byteswap)"<<endl;
197 cout << " (V=496) AcqMode: std=nosw, fft1c, fft2c "<<endl;
198 cout << " std=nosw: Standard Acquisition, Raw data "<<endl;
199 cout << " fft1c,fft2c: Standard Acquisition, FFT data "<<endl;
200 cout << " (V=496) For debug/performance measurement "<<endl;
201 cout << " nof,fft1cnof,fft2nof: raw/fft data, dont write files "<<endl;
202 cout << " mono-> Single thread PCIEReaderChecker, copy packets" << endl;
203 cout << " pattern: activate pattern, and write fits files "<<endl;
204 cout << " pattnof: activate pattern, NO fits files written "<<endl;
205 cout << " pattmono: activate pattern, Single thread, copy packets "<<endl;
206 cout << " - AcqMode: Acquisition mode for the firmware V=51 (2 fibers)"<<endl;
207 cout << " (V=51) f1.std,f2.std, f1.fft1c, f2.fft1c, f1.fft2c f2.fft2c"<<endl;
208 cout << " (V=51) f1.nof,f2.nof,f1.mono,f2.mon fft1cnof,fft2nof "<<endl;
209 cout << " - MemZoneMgr: nZones,NPaq =Number of Zones and number of paquet \n"
210 << " in each zone (Default=4,128) "<< endl;
211 cout << " -HardCtlC : Y y (direct interrpution by CtrlC ) default (no) " << endl;
212 cout << endl;
213 cout << " - AcqMode for previous firmware with 32bits-byteswap"<<endl;
214 cout << " AcqMode : swap32, nof32, fft1c32 , fft2c32,fft1cnof32 , fft2cnof32 " <<endl;
215 cout << " - AcqMode for previous firmware without any byte-swap"<<endl;
216 cout << " AcqMode : swapall, fft1csw , fft2csw, swapallnof, swh, mxs, monosw" << endl;
217 return;
218}
219
220/* --Nouvelle-Fonction-- */
221int DecodeArgs(int narg, char* arg[])
222{
223 if ((narg>1)&&(strcmp(arg[1],"-h")==0)) {
224 Usage(false);
225 return 1;
226 }
227 if (narg < 8) {
228 Usage(true);
229 return 1;
230 }
231
232 acqmode = "std";
233 fibre = 0; // firmware V496
234 if (narg>8) acqmode = arg[8];
235 savesigfits = true;
236 // BRDataFmtConv swapall = BR_SwapAll;
237 swapall = BR_Copy;
238 monothr = false;
239 DecodeAcqMode();
240
241 if (index(arg[1],',') != NULL) {
242 sscanf(arg[1],"%d,%d", cardlist, cardlist+1);
243 cout << " tmtacq[1]/MultiPCICard acquisition ... Cards= " << cardlist[0] << " ," << cardlist[1]
244 << " FrameSize=PaqSize=" << sizeFrame << endl;
245 singlecard = false;
246 }
247 else {
248 card = atoi(arg[1]);
249 cardlist[0] = cardlist[1] = card;
250 singlecard = true;
251 cout << "tmtacq[1]/MonoPCICard acquisition ... Card= " << card << " FrameSize=PaqSize=" << sizeFrame << endl;
252 }
253 sizeFrame = atoi(arg[2]);
254 nbFrameDMA = atoi(arg[3]);
255
256
257 NbFiles = atoi(arg[4]);
258 NBlocPerFile = atoi(arg[5]);
259 NMaxProc = atoi(arg[6]); // Nombre de blocs traites par le thread de calcul
260
261 OutPathName = arg[7];
262 fgnulldev4fits = (OutPathName == "/dev/null") ? true : false;
263 if (!fgnulldev4fits) {
264#ifdef NOPCIECARD
265 OutPathName = OutPathName+"/";
266#else
267 OutPathName =string("/Raid/")+OutPathName+"/";
268#endif
269 ProcPathName = OutPathName;
270 }
271 cout << " DataDirpath=" << OutPathName << " SwapMode=" << BRPaquet::FmtConvToString(swapall)
272 << " DataSaveMode=" << ((savesigfits)?"Yes/FitsFile":"NO") << endl;
273
274 if (!fgnulldev4fits) {
275 char cmd[512];
276 if (singlecard) {
277 sprintf(cmd,"mkdir %s",OutPathName.c_str());
278 if (system(cmd) < 0) {
279 cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl;
280 return 2;
281 }
282 else cout << " tmtacq[1] - Executed command " << cmd << endl;
283 }
284 else {
285 sprintf(cmd,"mkdir %s",OutPathName.c_str());
286 if (system(cmd) < 0) {
287 cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl;
288 return 2;
289 }
290 else cout << " tmtacq[1] - Executed command " << cmd << endl;
291 sprintf(cmd,"mkdir %s/Card1",OutPathName.c_str());
292 if (system(cmd) < 0) {
293 cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl;
294 return 2;
295 }
296 else cout << " tmtacq[1] - Executed command " << cmd << endl;
297 sprintf(cmd,"mkdir %s/Card2",OutPathName.c_str());
298 if (system(cmd) < 0) {
299 cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl;
300 return 2;
301 }
302 else cout << " tmtacq[1] - Executed command " << cmd << endl;
303 }
304 }
305 else {
306 ProcPathName = "./XZXZXZX/";
307 cout << " Using " << ProcPathName << " for other processed files ... " << endl;
308 char cmd[512];
309 sprintf(cmd,"mkdir %s",ProcPathName.c_str());
310 system(cmd);
311 if (!singlecard) {
312 sprintf(cmd,"mkdir %s/Card1 %s/Card2",ProcPathName.c_str(),ProcPathName.c_str());
313 system(cmd);
314 }
315 }
316
317 nZones = 8; // Nombre de zones memoires
318 nPaqZone = 128; // 128 Paquets / zone memoire - valeur par defaut
319 if (narg > 9) {
320 int ia1, ia2;
321 sscanf(arg[9],"%d,%d", &ia1, &ia2);
322 nZones = ia1; nPaqZone = ia2;
323 }
324
325 fg_hard_ctrlc = false;
326
327 struct sigaction act;
328
329 if (narg > 10) // pour traiter eventuellement un arret brutal par CtlC mettre le 10eme arg a Y
330 if ((*arg[10]=='y')||(*arg[10]=='Y')) fg_hard_ctrlc=true;
331 if (!fg_hard_ctrlc) {
332 act.sa_handler=Stop;
333 sigaction(SIGINT,&act,NULL);
334 }
335
336 PaqSZ =sizeFrame; // Taille de paquets
337 // uint_4 dmaSize = nbFrameDMA*PaqSZ ; // plantage
338 dmaSize = nbFrameDMA*1024 ;
339 patternSZ=(sizeFrame-40)/4; // pas utilise avec la fibre
340 NMaxBloc = NbFiles*NBlocPerFile;
341 cout << "tmtacq[2] - PaqSize = " << PaqSZ << " NbPaq/Zone=" << nPaqZone << " NZones=" << nZones << endl;
342 cout << " NbFiles=" << NbFiles << " NBloc/File=" << NBlocPerFile << " -> NMaxBloc=" << NMaxBloc << endl;
343 cout << "tmtacq[2] NbFrameDMA=" << nbFrameDMA << " DMASize=" << dmaSize << " bytes" << endl;
344 cout << "tmtacq[2] NMaxProc=" << NMaxProc << endl;
345
346 return 0;
347}
348
349/* --Nouvelle-Fonction-- */
350void DecodeAcqMode()
351{
352 if (acqmode.substr(0,3)=="f1.") {
353 fibre=1, acqmode=acqmode.substr(3);
354 cout << " DecodeAcqMode() -> firmware pci-express V51, fibre 1" << endl;
355 }
356 if (acqmode.substr(0,3)=="f2.") {
357 fibre=2, acqmode=acqmode.substr(3);
358 cout << " DecodeAcqMode() -> firmware pci-express V51, fibre 2" << endl;
359 }
360 if (acqmode == "nosw") swapall = BR_Copy ;
361 if (acqmode == "nof") { swapall = BR_Copy ; savesigfits = false; }
362 if (acqmode == "fft1c") swapall = BR_FFTOneChanNoSwap;
363 if (acqmode == "fft2c") swapall = BR_FFTTwoChanNoSwap;
364 if (acqmode == "fft1cnof") { swapall = BR_FFTOneChanNoSwap; savesigfits = false; }
365 if (acqmode == "fft2cnof") { swapall = BR_FFTTwoChanNoSwap; savesigfits = false; }
366 if (acqmode == "mono") { monothr = true; swapall = BR_Copy; }
367 if (acqmode == "patmono") { monothr = true; swapall = BR_Copy; activate_pattern=true; }
368 if (acqmode == "patnof") { savesigfits = false; swapall = BR_Copy; activate_pattern=true; }
369 if (acqmode == "pattern") { savesigfits = true; swapall = BR_Copy; activate_pattern=true; }
370
371 if (acqmode == "swapall") swapall = BR_SwapAll;
372 if (acqmode == "fft1csw") swapall = BR_FFTOneChan;
373 if (acqmode == "fft2csw") swapall = BR_FFTTwoChan;
374 if (acqmode == "fft1cswnof") { swapall = BR_FFTOneChan; savesigfits = false; }
375 if (acqmode == "fft2cswnof") { swapall = BR_FFTTwoChan; savesigfits = false; }
376 if ((acqmode == "swh") || (acqmode == "mxs") || (acqmode == "monoswh") ) swapall = BR_SwapHDR;
377 if ((acqmode == "swapallnof") || (acqmode == "mxs") ) savesigfits = false;
378 if (acqmode == "monoswh") { monothr = true; swapall = BR_SwapHDR;; }
379 if (acqmode == "monosw") { monothr = true; swapall = BR_SwapAll; }
380
381 if (acqmode == "swap32") swapall = BR_Swap32 ;
382 if (acqmode == "nof32") { swapall = BR_Swap32 ; savesigfits = false; }
383 if (acqmode == "fft1c32") swapall = BR_FFTOneChan32;
384 if (acqmode == "fft2c32") swapall = BR_FFTTwoChan32;
385 if (acqmode == "fft1cnof32") { swapall = BR_FFTOneChan32; savesigfits = false; }
386 if (acqmode == "fft2cnof32") { swapall = BR_FFTTwoChan32; savesigfits = false; }
387
388}
389
390
391/* --Nouvelle-Fonction-- */
392int MonoCardAcq()
393{
394 Timer tm("tmtacq/MonoCard");
395
396 cout << " ---- tmtacq/ MonoCardAcq() ------------- " << endl;
397
398 PCIEWrapperInterface* pciwp=NULL;
399#ifdef NOPCIECARD
400 TestPCIWrapperNODMA pciw(PaqSZ);
401 pciwp = &pciw;
402#else
403 DMAMgr* dmap=NULL;
404 if (fibre == 1) {
405 pciwp = CreatePCIEWrapperV5F1(card,patternSZ,dmaSize,activate_pattern);
406 }
407 else if (fibre == 2) {
408 pciwp = CreatePCIEWrapperV5F2(card,patternSZ,dmaSize,activate_pattern);
409 }
410 else {
411 dmap = new DMAMgr(card,patternSZ,dmaSize,activate_pattern);
412 if (! dmap->StatusFibre() ) {
413 cout << " tmtacq[3] - fibre non accrochee -> exit " << endl;
414 throw PCIEWException(" Fibre non accrochee ");
415 }
416 else cout << " tmtacq[3] - fibre accrochee OK " << endl;
417 pciwp = new PCIEWrapper(*dmap);
418 }
419#endif
420 RAcqMemZoneMgr mmgr(nZones, nPaqZone, PaqSZ);
421 pMmgr =&mmgr;
422
423 if (monothr) {
424 cout << "tmtacq[4] single thread PCIE test PCIEReaderChecker ... ";
425 PCIEReaderChecker pcirc(*pciwp,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall);
426 pPcierc=&pcirc;
427 pcirc.start();
428 sleep(1);
429 pcirc.join();
430 cout << "tmtacq[5] - single thread PCIEReaderChecker finished " << endl;
431 tm.Split("Single Thread Finished");
432 mmgr.Print(cout);
433 return 0;
434 }
435 PCIEReader pcir(*pciwp,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall);
436 pPcier= &pcir;
437 DataSaver ds(mmgr, OutPathName, NbFiles, NBlocPerFile, savesigfits);
438 pDs= &ds;
439 //DataBinSaver ds(mmgr, OutPathName, NbFiles ,NBlocPerFile);
440 // DataProc1C pr(mmgr, OutPathName, nmean, stepproc, 100); Pour processer un canal
441 int stepproc = 2;
442 int nmean = nPaqZone*NBlocPerFile/stepproc;
443 DataProc2C pr(mmgr, ProcPathName, nmean, stepproc, NMaxProc);
444 DataProcFFT2C prfft(mmgr, ProcPathName, nmean, stepproc, NMaxProc);
445 tm.Split("Threads created");
446 cout << "tmtacq[4] - starting 3 threads pcir, ds, pr ... " << endl;
447 /*
448 char test[100];
449 cout << " <CR> to continue, x to exit ..." << endl;
450 gets(test); if (test[0] == 'x') return 9;
451 */
452 pcir.start();
453 ds.start();
454 if (NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0
455 if (acqmode.substr(0,5)=="fft2c") { prfft.start(); pPrfft=&prfft;}
456 else { pr.start(); pPr=&pr;}
457 }
458 cout << "tmtacq[5] - waiting for threads to finish ... " << endl;
459 sleep(1);
460 pcir.join();
461 ds.join();
462 sleep(1);
463 mmgr.Stop();
464 if (NMaxProc>0) {
465 if ( pPr != NULL) pr.join();
466 if ( pPrfft != NULL) prfft.join();
467 }
468 cout << "tmtacq[6] - threads finished " << endl;
469 tm.Split("Threads Finished");
470 mmgr.Print(cout);
471#ifndef NOPCIECARD
472 if (fibre==0) {
473 delete pciwp;
474 delete dmap;
475 }
476 if (fibre==1) DeletePCIEWrapperV5F1(card);
477 if (fibre==2) DeletePCIEWrapperV5F2(card);
478#endif
479 return 0;
480}
481
482
483/* --Nouvelle-Fonction-- */
484int MultiCardAcq()
485{
486 Timer tm("tmtacq/MultiCard");
487
488 cout << " ---- tmtacq/ MultiCardAcq() ------------- " << endl;
489
490 PCIEWrapperInterface* pciwp1=NULL;
491 PCIEWrapperInterface* pciwp2=NULL;
492
493#ifdef NOPCIECARD
494 TestPCIWrapperNODMA pciw1(PaqSZ);
495 TestPCIWrapperNODMA pciw2(PaqSZ);
496 pciwp1 = &pciw1;
497 pciwp2 = &pciw2;
498#else
499 DMAMgr* dmap1=NULL;
500 DMAMgr* dmap2=NULL;
501 if (fibre == 1) {
502 pciwp1 = CreatePCIEWrapperV5F1(cardlist[0],patternSZ,dmaSize,activate_pattern);
503 pciwp2 = CreatePCIEWrapperV5F1(cardlist[1],patternSZ,dmaSize,activate_pattern);
504 }
505 else if (fibre == 2) {
506 pciwp1 = CreatePCIEWrapperV5F2(cardlist[0],patternSZ,dmaSize,activate_pattern);
507 pciwp2 = CreatePCIEWrapperV5F2(cardlist[1],patternSZ,dmaSize,activate_pattern);
508 }
509 else {
510 dmap1 = new DMAMgr(cardlist[0],patternSZ,dmaSize,activate_pattern);
511 if (! dmap1->StatusFibre() ) {
512 cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[0] << " -> exit " << endl;
513 throw PCIEWException(" Fibre non accrochee 1");
514 }
515 else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[0] << endl;
516
517 dmap2 = new DMAMgr(cardlist[1],patternSZ,dmaSize,activate_pattern);
518 if (! dmap2->StatusFibre() ) {
519 cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[1] << " -> exit " << endl;
520 throw PCIEWException(" Fibre non accrochee 2");
521 }
522 else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[1] << endl;
523 pciwp1 = new PCIEWrapper(*dmap1);
524 pciwp2 = new PCIEWrapper(*dmap2);
525 }
526 /*
527 cout << " ---- S to stop , C continue ... " << endl;
528 char ans[64];
529 gets(ans);
530 if ((ans[0] == 'S') || (ans[0] == 's')) return 5;
531 */
532#endif
533 RAcqMemZoneMgr mmgr1(nZones, nPaqZone, PaqSZ);
534 RAcqMemZoneMgr mmgr2(nZones, nPaqZone, PaqSZ);
535 pMmgr =&mmgr1;
536 pMmgr2 =&mmgr2;
537
538 if (monothr) {
539 cout << "tmtacq[4] single thread/Card PCIE test PCIEReaderChecker ... ";
540 PCIEReaderChecker pcirc1(*pciwp1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall);
541 PCIEReaderChecker pcirc2(*pciwp2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall);
542 pPcierc=&pcirc1;
543 pPcierc2=&pcirc2;
544 pcirc1.start();
545 pcirc2.start();
546
547 sleep(1);
548 pcirc1.join();
549 pcirc2.join();
550
551 cout << "tmtacq[5] - single thread/Card PCIEReaderChecker finished " << endl;
552 tm.Split("Single Thread Finished");
553 mmgr1.Print(cout);
554 mmgr2.Print(cout);
555 return 0;
556 }
557 PCIEReader pcir1(*pciwp1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall);
558 pPcier= &pcir1;
559 PCIEReader pcir2(*pciwp2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall);
560 pPcier2= &pcir2;
561 char buff[32];
562 sprintf(buff, "Card%d", cardlist[0]);
563 string path1 = OutPathName + buff;
564 string ppath1 = ProcPathName + buff;
565 DataSaver ds1(mmgr1, path1, NbFiles, NBlocPerFile, savesigfits);
566 pDs= &ds1;
567 sprintf(buff, "Card%d", cardlist[1]);
568 string path2 = OutPathName + buff;
569 string ppath2 = ProcPathName + buff;
570 DataSaver ds2(mmgr2, path2, NbFiles, NBlocPerFile, savesigfits);
571 pDs2= &ds2;
572 //DataBinSaver ds(mmgr, OutPathName, NbFiles ,NBlocPerFile);
573 // DataProc1C pr(mmgr, OutPathName, nmean, stepproc, 100); Pour processer un canal
574 int stepproc = 2;
575
576 int nmean = nPaqZone*NBlocPerFile/stepproc;
577 DataProc2C pr1(mmgr1, ppath1, nmean, stepproc, NMaxProc);
578 DataProcFFT2C prfft1(mmgr1, ppath1, nmean, stepproc, NMaxProc);
579 DataProc2C pr2(mmgr2, ppath2, nmean, stepproc, NMaxProc);
580 DataProcFFT2C prfft2(mmgr2, ppath2, nmean, stepproc, NMaxProc);
581
582 tm.Split("Threads created");
583 cout << "tmtacq[4] - starting 3 threads pcir, ds, pr ... " << endl;
584 /*
585 char test[100];
586 cout << " <CR> to continue, x to exit ..." << endl;
587 gets(test); if (test[0] == 'x') return 9;
588 */
589 pcir1.start();
590 ds1.start();
591 pcir2.start();
592 ds2.start();
593 if (NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0
594 if (acqmode.substr(0,5)=="fft2c") {
595 prfft1.start(); pPrfft=&prfft1;
596 prfft2.start(); pPrfft2=&prfft2;
597 }
598 else {
599 pr1.start(); pPr=&pr1;
600 pr2.start(); pPr2=&pr2;
601 }
602 }
603 cout << "tmtacq[5] - waiting for threads to finish ... " << endl;
604 sleep(1);
605 pcir1.join();
606 ds1.join();
607 pcir2.join();
608 ds2.join();
609 sleep(1);
610 mmgr1.Stop();
611 mmgr2.Stop();
612 if (NMaxProc>0) {
613 if ( pPr != NULL) pr1.join();
614 if ( pPr2 != NULL) pr2.join();
615 if ( pPrfft != NULL) prfft1.join();
616 if ( pPrfft2 != NULL) prfft2.join();
617 }
618
619 cout << "tmtacq[6] - threads finished " << endl;
620 tm.Split("Threads Finished");
621 mmgr1.Print(cout);
622 mmgr2.Print(cout);
623#ifndef NOPCIECARD
624 if (fibre==0) {
625 delete pciwp1;
626 delete dmap1;
627 delete pciwp2;
628 delete dmap2;
629 }
630 if (fibre==1) {
631 DeletePCIEWrapperV5F1(cardlist[0]);
632 DeletePCIEWrapperV5F1(cardlist[1]);
633 }
634 if (fibre==2) {
635 DeletePCIEWrapperV5F2(cardlist[0]);
636 DeletePCIEWrapperV5F2(cardlist[1]);
637 }
638#endif
639 return 0;
640}
Note: See TracBrowser for help on using the repository browser.