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

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

Traitement 4 canaux ds brproc.cc, mcrd.cc , mais il reste des problemes - Reza 01/06/2009

File size: 22.0 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 (!activate_pattern) {
413 if (! dmap->StatusFibre() ) {
414 cout << " tmtacq[3] - fibre non accrochee -> exit " << endl;
415 throw PCIEWException(" Fibre non accrochee ");
416 }
417 else cout << " tmtacq[3] - fibre accrochee OK " << endl;
418 }
419 pciwp = new PCIEWrapper(*dmap);
420 }
421#endif
422 RAcqMemZoneMgr mmgr(nZones, nPaqZone, PaqSZ);
423 pMmgr =&mmgr;
424
425 if (monothr) {
426 cout << "tmtacq[4] single thread PCIE test PCIEReaderChecker ... ";
427 PCIEReaderChecker pcirc(*pciwp,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall);
428 pPcierc=&pcirc;
429 pcirc.start();
430 sleep(1);
431 pcirc.join();
432 cout << "tmtacq[5] - single thread PCIEReaderChecker finished " << endl;
433 tm.Split("Single Thread Finished");
434 mmgr.Print(cout);
435 return 0;
436 }
437 PCIEReader pcir(*pciwp,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall);
438 pPcier= &pcir;
439 DataSaver ds(mmgr, OutPathName, NbFiles, NBlocPerFile, savesigfits);
440 pDs= &ds;
441 //DataBinSaver ds(mmgr, OutPathName, NbFiles ,NBlocPerFile);
442 // DataProc1C pr(mmgr, OutPathName, nmean, stepproc, 100); Pour processer un canal
443 int stepproc = 2;
444 int nmean = nPaqZone*NBlocPerFile/stepproc;
445 DataProc2C pr(mmgr, ProcPathName, nmean, stepproc, NMaxProc);
446 DataProcFFT2C prfft(mmgr, ProcPathName, nmean, stepproc, NMaxProc);
447 tm.Split("Threads created");
448 cout << "tmtacq[4] - starting 3 threads pcir, ds, pr ... " << endl;
449 /*
450 char test[100];
451 cout << " <CR> to continue, x to exit ..." << endl;
452 gets(test); if (test[0] == 'x') return 9;
453 */
454 pcir.start();
455 ds.start();
456 if (NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0
457 if (acqmode.substr(0,5)=="fft2c") { prfft.start(); pPrfft=&prfft;}
458 else { pr.start(); pPr=&pr;}
459 }
460 cout << "tmtacq[5] - waiting for threads to finish ... " << endl;
461 sleep(1);
462 pcir.join();
463 ds.join();
464 sleep(1);
465 mmgr.Stop();
466 if (NMaxProc>0) {
467 if ( pPr != NULL) pr.join();
468 if ( pPrfft != NULL) prfft.join();
469 }
470 cout << "tmtacq[6] - threads finished " << endl;
471 tm.Split("Threads Finished");
472 mmgr.Print(cout);
473#ifndef NOPCIECARD
474 if (fibre==0) {
475 delete pciwp;
476 delete dmap;
477 }
478 if (fibre==1) DeletePCIEWrapperV5F1(card);
479 if (fibre==2) DeletePCIEWrapperV5F2(card);
480#endif
481 return 0;
482}
483
484
485/* --Nouvelle-Fonction-- */
486int MultiCardAcq()
487{
488 Timer tm("tmtacq/MultiCard");
489
490 cout << " ---- tmtacq/ MultiCardAcq() ------------- " << endl;
491
492 PCIEWrapperInterface* pciwp1=NULL;
493 PCIEWrapperInterface* pciwp2=NULL;
494
495#ifdef NOPCIECARD
496 TestPCIWrapperNODMA pciw1(PaqSZ);
497 TestPCIWrapperNODMA pciw2(PaqSZ);
498 pciwp1 = &pciw1;
499 pciwp2 = &pciw2;
500#else
501 DMAMgr* dmap1=NULL;
502 DMAMgr* dmap2=NULL;
503 if (fibre == 1) {
504 pciwp1 = CreatePCIEWrapperV5F1(cardlist[0],patternSZ,dmaSize,activate_pattern);
505 pciwp2 = CreatePCIEWrapperV5F1(cardlist[1],patternSZ,dmaSize,activate_pattern);
506 }
507 else if (fibre == 2) {
508 pciwp1 = CreatePCIEWrapperV5F2(cardlist[0],patternSZ,dmaSize,activate_pattern);
509 pciwp2 = CreatePCIEWrapperV5F2(cardlist[1],patternSZ,dmaSize,activate_pattern);
510 }
511 else {
512 dmap1 = new DMAMgr(cardlist[0],patternSZ,dmaSize,activate_pattern);
513 if (!activate_pattern) {
514 if (! dmap1->StatusFibre() ) {
515 cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[0] << " -> exit " << endl;
516 throw PCIEWException(" Fibre non accrochee 1");
517 }
518 else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[0] << endl;
519
520 dmap2 = new DMAMgr(cardlist[1],patternSZ,dmaSize,activate_pattern);
521 if (! dmap2->StatusFibre() ) {
522 cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[1] << " -> exit " << endl;
523 throw PCIEWException(" Fibre non accrochee 2");
524 }
525 else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[1] << endl;
526 }
527 pciwp1 = new PCIEWrapper(*dmap1);
528 pciwp2 = new PCIEWrapper(*dmap2);
529 }
530 /*
531 cout << " ---- S to stop , C continue ... " << endl;
532 char ans[64];
533 gets(ans);
534 if ((ans[0] == 'S') || (ans[0] == 's')) return 5;
535 */
536#endif
537 RAcqMemZoneMgr mmgr1(nZones, nPaqZone, PaqSZ);
538 RAcqMemZoneMgr mmgr2(nZones, nPaqZone, PaqSZ);
539 pMmgr =&mmgr1;
540 pMmgr2 =&mmgr2;
541
542 if (monothr) {
543 cout << "tmtacq[4] single thread/Card PCIE test PCIEReaderChecker ... ";
544 PCIEReaderChecker pcirc1(*pciwp1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall);
545 PCIEReaderChecker pcirc2(*pciwp2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall);
546 pPcierc=&pcirc1;
547 pPcierc2=&pcirc2;
548 pcirc1.start();
549 pcirc2.start();
550
551 sleep(1);
552 pcirc1.join();
553 pcirc2.join();
554
555 cout << "tmtacq[5] - single thread/Card PCIEReaderChecker finished " << endl;
556 tm.Split("Single Thread Finished");
557 mmgr1.Print(cout);
558 mmgr2.Print(cout);
559 return 0;
560 }
561 PCIEReader pcir1(*pciwp1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall);
562 pPcier= &pcir1;
563 PCIEReader pcir2(*pciwp2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall);
564 pPcier2= &pcir2;
565 char buff[32];
566 sprintf(buff, "Card%d", cardlist[0]);
567 string path1 = OutPathName + buff;
568 string ppath1 = ProcPathName + buff;
569 DataSaver ds1(mmgr1, path1, NbFiles, NBlocPerFile, savesigfits);
570 pDs= &ds1;
571 sprintf(buff, "Card%d", cardlist[1]);
572 string path2 = OutPathName + buff;
573 string ppath2 = ProcPathName + buff;
574 DataSaver ds2(mmgr2, path2, NbFiles, NBlocPerFile, savesigfits);
575 pDs2= &ds2;
576 //DataBinSaver ds(mmgr, OutPathName, NbFiles ,NBlocPerFile);
577 // DataProc1C pr(mmgr, OutPathName, nmean, stepproc, 100); Pour processer un canal
578 int stepproc = 2;
579
580 int nmean = nPaqZone*NBlocPerFile/stepproc;
581 DataProc2C pr1(mmgr1, ppath1, nmean, stepproc, NMaxProc);
582 DataProcFFT2C prfft1(mmgr1, ppath1, nmean, stepproc, NMaxProc);
583 DataProc2C pr2(mmgr2, ppath2, nmean, stepproc, NMaxProc);
584 DataProcFFT2C prfft2(mmgr2, ppath2, nmean, stepproc, NMaxProc);
585
586 tm.Split("Threads created");
587 cout << "tmtacq[4] - starting 3 threads pcir, ds, pr ... " << endl;
588 /*
589 char test[100];
590 cout << " <CR> to continue, x to exit ..." << endl;
591 gets(test); if (test[0] == 'x') return 9;
592 */
593 pcir1.start();
594 ds1.start();
595 pcir2.start();
596 ds2.start();
597 if (NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0
598 if (acqmode.substr(0,5)=="fft2c") {
599 prfft1.start(); pPrfft=&prfft1;
600 prfft2.start(); pPrfft2=&prfft2;
601 }
602 else {
603 pr1.start(); pPr=&pr1;
604 pr2.start(); pPr2=&pr2;
605 }
606 }
607 cout << "tmtacq[5] - waiting for threads to finish ... " << endl;
608 sleep(1);
609 pcir1.join();
610 ds1.join();
611 pcir2.join();
612 ds2.join();
613 sleep(1);
614 mmgr1.Stop();
615 mmgr2.Stop();
616 if (NMaxProc>0) {
617 if ( pPr != NULL) pr1.join();
618 if ( pPr2 != NULL) pr2.join();
619 if ( pPrfft != NULL) prfft1.join();
620 if ( pPrfft2 != NULL) prfft2.join();
621 }
622
623 cout << "tmtacq[6] - threads finished " << endl;
624 tm.Split("Threads Finished");
625 mmgr1.Print(cout);
626 mmgr2.Print(cout);
627#ifndef NOPCIECARD
628 if (fibre==0) {
629 delete pciwp1;
630 delete dmap1;
631 delete pciwp2;
632 delete dmap2;
633 }
634 if (fibre==1) {
635 DeletePCIEWrapperV5F1(cardlist[0]);
636 DeletePCIEWrapperV5F1(cardlist[1]);
637 }
638 if (fibre==2) {
639 DeletePCIEWrapperV5F2(cardlist[0]);
640 DeletePCIEWrapperV5F2(cardlist[1]);
641 }
642#endif
643 return 0;
644}
Note: See TracBrowser for help on using the repository browser.