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 |
|
---|
27 | using namespace std;
|
---|
28 | using 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 */
|
---|
39 | static DataSaver *pDs = NULL;
|
---|
40 | static DataSaver *pDs2 = NULL;
|
---|
41 | static PCIEReaderChecker *pPcierc = NULL;
|
---|
42 | static PCIEReaderChecker *pPcierc2 = NULL;
|
---|
43 | static PCIEReader *pPcier = NULL;
|
---|
44 | static PCIEReader *pPcier2 = NULL;
|
---|
45 | static DataProc2C *pPr = NULL;
|
---|
46 | static DataProc2C *pPr2 = NULL;
|
---|
47 | static DataProcFFT2C *pPrfft = NULL;
|
---|
48 | static DataProcFFT2C *pPrfft2 = NULL;
|
---|
49 | static RAcqMemZoneMgr *pMmgr = NULL;
|
---|
50 | static RAcqMemZoneMgr *pMmgr2 = NULL;
|
---|
51 |
|
---|
52 | void 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 |
|
---|
72 | // Fonctions appelees par le main
|
---|
73 | void Usage(bool fgshort=true);
|
---|
74 | int DecodeArgs(int narg, char* arg[]);
|
---|
75 | void DecodeAcqMode();
|
---|
76 |
|
---|
77 | int MonoCardAcq();
|
---|
78 | int MultiCardAcq();
|
---|
79 |
|
---|
80 | //------------------ Parametres de controle ----------------------------
|
---|
81 | static string acqmode;
|
---|
82 | static bool savesigfits = true;
|
---|
83 | static BRDataFmtConv swapall = BR_Copy;
|
---|
84 | static bool monothr = false;
|
---|
85 | static string OutPathName;
|
---|
86 | static bool singlecard = true;
|
---|
87 | static int cardlist[4] = {1,1,1,1};
|
---|
88 | static int card = 1;
|
---|
89 | static unsigned int sizeFrame = 4096;
|
---|
90 | static unsigned int nbFrameDMA = 32;
|
---|
91 | static int NbFiles=1;
|
---|
92 | static int NBlocPerFile=10;
|
---|
93 | static int NMaxProc = 0; // Nombre de blocs traites par le thread de calcul
|
---|
94 | static uint_4 nZones = 4; // Nombre de zones memoires
|
---|
95 | static uint_4 nPaqZone = 128; // 128 Paquets / zone memoire - valeur par defaut
|
---|
96 | static bool fg_hard_ctrlc = false;
|
---|
97 | static uint_4 PaqSZ = 4096; // Taille de paquets
|
---|
98 | // uint_4 dmaSize = nbFrameDMA*PaqSZ ; // plantage
|
---|
99 | static uint_4 dmaSize = 32*1024 ;
|
---|
100 | static uint_4 patternSZ=0x400; // pas utilise avec la fibre
|
---|
101 | static bool activate_pattern=false; // true -> on active le pattern du firmware au lieu de la fibre
|
---|
102 | static uint_4 NMaxBloc = 10;
|
---|
103 | //---------------------------- FIN parametres de controle -----------------
|
---|
104 |
|
---|
105 | //-----------------------------------------------------------------------
|
---|
106 | //-------------------- le programme principal ---------------------------
|
---|
107 | //-----------------------------------------------------------------------
|
---|
108 | int main(int narg, char* arg[])
|
---|
109 | {
|
---|
110 |
|
---|
111 | int rc = 0;
|
---|
112 | cout << " ============ BAORadio / Acquisition : tmtacq =================" << endl;
|
---|
113 | cout << " ===============================================================" << endl;
|
---|
114 | cout << " ========= " <<BAOR_ACQ_VER_STR <<BAOR_ACQ_VER <<" ===========" << endl;
|
---|
115 | cout << " ===============================================================" << endl;
|
---|
116 |
|
---|
117 | int rcda = DecodeArgs(narg, arg);
|
---|
118 | if (rcda != 0) return 1;
|
---|
119 | InitTim();
|
---|
120 |
|
---|
121 | // Initialisation
|
---|
122 | TArrayInitiator _arri;
|
---|
123 | FitsIOServerInitiator _fiosi;
|
---|
124 |
|
---|
125 | try {
|
---|
126 | if (singlecard) rc = MonoCardAcq();
|
---|
127 | else rc = MultiCardAcq();
|
---|
128 | }
|
---|
129 | catch (MiniFITSException& exc) {
|
---|
130 | cerr << " tmtacq.cc catched MiniFITSException " << exc.Msg() << endl;
|
---|
131 | Stop(9765);
|
---|
132 | rc = 77;
|
---|
133 | }
|
---|
134 | catch (PCIEWException& exc) {
|
---|
135 | cerr << " tmtacq.cc catched MiniFITSException " << exc.Msg() << endl;
|
---|
136 | Stop(9765);
|
---|
137 | rc = 75;
|
---|
138 | }
|
---|
139 | catch (PThrowable& exc) {
|
---|
140 | cerr << " tmtacq.cc catched Exception " << exc.Msg() << endl;
|
---|
141 | Stop(9765);
|
---|
142 | rc = 76;
|
---|
143 | }
|
---|
144 | catch (std::exception& sex) {
|
---|
145 | cerr << "\n tmtacq.cc std::exception :"
|
---|
146 | << (string)typeid(sex).name() << "\n msg= "
|
---|
147 | << sex.what() << endl;
|
---|
148 | Stop(9765);
|
---|
149 | rc = 78;
|
---|
150 | }
|
---|
151 | catch (...) {
|
---|
152 | cerr << " tmtacq.cc : Catched ... exception " << endl;
|
---|
153 | Stop(9765);
|
---|
154 | rc = 79;
|
---|
155 | }
|
---|
156 | cout << "tmtacq[9] ----- END --- stopping acq program " << endl;
|
---|
157 | return rc;
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 | /* --Nouvelle-Fonction-- */
|
---|
162 | void Usage(bool fgshort)
|
---|
163 | {
|
---|
164 | if (fgshort) {
|
---|
165 | cout << " Usage: tmtacq CardNum PaquetSize NFrameDMA NFiles NBlocPerFile \n"
|
---|
166 | << " NMaxProc DataDirPath [AcqMode] [MemZoneMgr][HardCtlC]" << endl;
|
---|
167 | cout << " type tmtacq -h for detailed usage " << endl;
|
---|
168 | return;
|
---|
169 | }
|
---|
170 |
|
---|
171 | cout << "\n Usage: tmtacq CardNum PaquetSize NFrameDMA NFiles NBlocPerFile \n"
|
---|
172 | << " NMaxProc DataDirPath [AcqMode] [MemZoneMgr][HardCtlC]" << endl;
|
---|
173 | cout << " - CardNum : PCI-Express card number (=1 OR 2 OR 1,2)" << endl;
|
---|
174 | cout << " - PaquetSize or FrameSize (=DATA+HDR+TRL_Size) " << endl;
|
---|
175 | cout << " - NFrameDMA = DMASize= NFrameDMA*1024 , 4KO<=MaxDMASize<=64 ko " << endl;
|
---|
176 | cout << " - NFiles = Number of data files produced " << endl;
|
---|
177 | cout << " - NBlocPerFile = Number of memory data bloc in one file " << endl;
|
---|
178 | cout << " - NMaxProc = Max number of memory data blocs processed (FFT ...) " << endl;
|
---|
179 | cout << " NMaxProc=0 -> No Processing " << endl;
|
---|
180 | cout << " - DataDirPath : Subdirectory of /Raid " << endl;
|
---|
181 | cout << " - AcqMode: Acquisition mode for the firmware V=496 (manages 64bits-byteswap)"<<endl;
|
---|
182 | cout << " (V=496) AcqMode: std=nosw, fft1c, fft2c "<<endl;
|
---|
183 | cout << " std=nosw: Standard Acquisition, Raw data "<<endl;
|
---|
184 | cout << " fft1c,fft2c: Standard Acquisition, FFT data "<<endl;
|
---|
185 | cout << " (V=496) For debug/performance measurement "<<endl;
|
---|
186 | cout << " nof,fft1cnof,fft2nof: raw/fft data, dont write files "<<endl;
|
---|
187 | cout << " mono-> Single thread PCIEReaderChecker, copy packets" << endl;
|
---|
188 | cout << " pattern: activate pattern, and write fits files "<<endl;
|
---|
189 | cout << " pattnof: activate pattern, NO fits files written "<<endl;
|
---|
190 | cout << " pattmono: activate pattern, Single thread, copy packets "<<endl;
|
---|
191 | cout << " - MemZoneMgr: nZones,NPaq =Number of Zones and number of paquet \n"
|
---|
192 | << " in each zone (Default=4,128) "<< endl;
|
---|
193 | cout << " -HardCtlC : Y y (direct interrpution by CtrlC ) default (no) " << endl;
|
---|
194 | cout << endl;
|
---|
195 | cout << " - AcqMode for previous firmware with 32bits-byteswap"<<endl;
|
---|
196 | cout << " AcqMode : swap32, nof32, fft1c32 , fft2c32,fft1cnof32 , fft2cnof32 " <<endl;
|
---|
197 | cout << " - AcqMode for previous firmware without any byte-swap"<<endl;
|
---|
198 | cout << " AcqMode : swapall, fft1csw , fft2csw, swapallnof, swh, mxs, monosw" << endl;
|
---|
199 | return;
|
---|
200 | }
|
---|
201 |
|
---|
202 | /* --Nouvelle-Fonction-- */
|
---|
203 | int DecodeArgs(int narg, char* arg[])
|
---|
204 | {
|
---|
205 | if ((narg>1)&&(strcmp(arg[1],"-h")==0)) {
|
---|
206 | Usage(false);
|
---|
207 | return 1;
|
---|
208 | }
|
---|
209 | if (narg < 8) {
|
---|
210 | Usage(true);
|
---|
211 | return 1;
|
---|
212 | }
|
---|
213 |
|
---|
214 | acqmode = "std";
|
---|
215 | if (narg>8) acqmode = arg[8];
|
---|
216 | savesigfits = true;
|
---|
217 | // BRDataFmtConv swapall = BR_SwapAll;
|
---|
218 | swapall = BR_Copy;
|
---|
219 | monothr = false;
|
---|
220 | DecodeAcqMode();
|
---|
221 |
|
---|
222 | if (index(arg[1],',') != NULL) {
|
---|
223 | sscanf(arg[1],"%d,%d", cardlist, cardlist+1);
|
---|
224 | cout << " tmtacq[1]/MultiPCICard acquisition ... Cards= " << cardlist[0] << " ," << cardlist[1]
|
---|
225 | << " FrameSize=PaqSize=" << sizeFrame << endl;
|
---|
226 | singlecard = false;
|
---|
227 | }
|
---|
228 | else {
|
---|
229 | card = atoi(arg[1]);
|
---|
230 | cardlist[0] = cardlist[1] = card;
|
---|
231 | singlecard = true;
|
---|
232 | cout << "tmtacq[1]/MonoPCICard acquisition ... Card= " << card << " FrameSize=PaqSize=" << sizeFrame << endl;
|
---|
233 | }
|
---|
234 | sizeFrame = atoi(arg[2]);
|
---|
235 | nbFrameDMA = atoi(arg[3]);
|
---|
236 |
|
---|
237 |
|
---|
238 | NbFiles = atoi(arg[4]);
|
---|
239 | NBlocPerFile = atoi(arg[5]);
|
---|
240 | NMaxProc = atoi(arg[6]); // Nombre de blocs traites par le thread de calcul
|
---|
241 |
|
---|
242 | OutPathName = "./";
|
---|
243 | #ifdef NOPCIECARD
|
---|
244 | OutPathName = string(arg[7])+"/";
|
---|
245 | #else
|
---|
246 | OutPathName =string("/Raid/")+arg[7]+"/";
|
---|
247 | #endif
|
---|
248 | cout << " DataDirpath=" << OutPathName << " SwapMode=" << BRPaquet::FmtConvToString(swapall)
|
---|
249 | << " DataSaveMode=" << ((savesigfits)?"Yes/FitsFile":"NO") << endl;
|
---|
250 |
|
---|
251 | char cmd[512];
|
---|
252 | if (singlecard) {
|
---|
253 | sprintf(cmd,"mkdir %s",OutPathName.c_str());
|
---|
254 | if (system(cmd) < 0) {
|
---|
255 | cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl;
|
---|
256 | return 2;
|
---|
257 | }
|
---|
258 | else cout << " tmtacq[1] - Executed command " << cmd << endl;
|
---|
259 | }
|
---|
260 | else {
|
---|
261 | sprintf(cmd,"mkdir %s",OutPathName.c_str());
|
---|
262 | if (system(cmd) < 0) {
|
---|
263 | cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl;
|
---|
264 | return 2;
|
---|
265 | }
|
---|
266 | else cout << " tmtacq[1] - Executed command " << cmd << endl;
|
---|
267 | sprintf(cmd,"mkdir %s/Card1",OutPathName.c_str());
|
---|
268 | if (system(cmd) < 0) {
|
---|
269 | cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl;
|
---|
270 | return 2;
|
---|
271 | }
|
---|
272 | else cout << " tmtacq[1] - Executed command " << cmd << endl;
|
---|
273 | sprintf(cmd,"mkdir %s/Card2",OutPathName.c_str());
|
---|
274 | if (system(cmd) < 0) {
|
---|
275 | cout << "tmtacq/Error: Can not create subdirectory " << OutPathName << " -> exit" << endl;
|
---|
276 | return 2;
|
---|
277 | }
|
---|
278 | else cout << " tmtacq[1] - Executed command " << cmd << endl;
|
---|
279 | }
|
---|
280 | nZones = 8; // Nombre de zones memoires
|
---|
281 | nPaqZone = 128; // 128 Paquets / zone memoire - valeur par defaut
|
---|
282 | if (narg > 9) {
|
---|
283 | int ia1, ia2;
|
---|
284 | sscanf(arg[9],"%d,%d", &ia1, &ia2);
|
---|
285 | nZones = ia1; nPaqZone = ia2;
|
---|
286 | }
|
---|
287 |
|
---|
288 | fg_hard_ctrlc = false;
|
---|
289 |
|
---|
290 | struct sigaction act;
|
---|
291 |
|
---|
292 | if (narg > 10) // pour traiter eventuellement un arret brutal par CtlC mettre le 10eme arg a Y
|
---|
293 | if ((*arg[10]=='y')||(*arg[10]=='Y')) fg_hard_ctrlc=true;
|
---|
294 | if (!fg_hard_ctrlc) {
|
---|
295 | act.sa_handler=Stop;
|
---|
296 | sigaction(SIGINT,&act,NULL);
|
---|
297 | }
|
---|
298 |
|
---|
299 | PaqSZ =sizeFrame; // Taille de paquets
|
---|
300 | // uint_4 dmaSize = nbFrameDMA*PaqSZ ; // plantage
|
---|
301 | dmaSize = nbFrameDMA*1024 ;
|
---|
302 | patternSZ=(sizeFrame-40)/4; // pas utilise avec la fibre
|
---|
303 | NMaxBloc = NbFiles*NBlocPerFile;
|
---|
304 | cout << "tmtacq[2] - PaqSize = " << PaqSZ << " NbPaq/Zone=" << nPaqZone << " NZones=" << nZones << endl;
|
---|
305 | cout << " NbFiles=" << NbFiles << " NBloc/File=" << NBlocPerFile << " -> NMaxBloc=" << NMaxBloc << endl;
|
---|
306 | cout << "tmtacq[2] NbFrameDMA=" << nbFrameDMA << " DMASize=" << dmaSize << " bytes" << endl;
|
---|
307 | cout << "tmtacq[2] NMaxProc=" << NMaxProc << endl;
|
---|
308 |
|
---|
309 | return 0;
|
---|
310 | }
|
---|
311 |
|
---|
312 | /* --Nouvelle-Fonction-- */
|
---|
313 | void DecodeAcqMode()
|
---|
314 | {
|
---|
315 | if (acqmode == "nosw") swapall = BR_Copy ;
|
---|
316 | if (acqmode == "nof") { swapall = BR_Copy ; savesigfits = false; }
|
---|
317 | if (acqmode == "fft1c") swapall = BR_FFTOneChanNoSwap;
|
---|
318 | if (acqmode == "fft2c") swapall = BR_FFTTwoChanNoSwap;
|
---|
319 | if (acqmode == "fft1cnof") { swapall = BR_FFTOneChanNoSwap; savesigfits = false; }
|
---|
320 | if (acqmode == "fft2cnof") { swapall = BR_FFTTwoChanNoSwap; savesigfits = false; }
|
---|
321 | if (acqmode == "mono") { monothr = true; swapall = BR_Copy; }
|
---|
322 | if (acqmode == "patmono") { monothr = true; swapall = BR_Copy; activate_pattern=true; }
|
---|
323 | if (acqmode == "patnof") { savesigfits = false; swapall = BR_Copy; activate_pattern=true; }
|
---|
324 | if (acqmode == "pattern") { savesigfits = true; swapall = BR_Copy; activate_pattern=true; }
|
---|
325 |
|
---|
326 | if (acqmode == "swapall") swapall = BR_SwapAll;
|
---|
327 | if (acqmode == "fft1csw") swapall = BR_FFTOneChan;
|
---|
328 | if (acqmode == "fft2csw") swapall = BR_FFTTwoChan;
|
---|
329 | if (acqmode == "fft1cswnof") { swapall = BR_FFTOneChan; savesigfits = false; }
|
---|
330 | if (acqmode == "fft2cswnof") { swapall = BR_FFTTwoChan; savesigfits = false; }
|
---|
331 | if ((acqmode == "swh") || (acqmode == "mxs") || (acqmode == "monoswh") ) swapall = BR_SwapHDR;
|
---|
332 | if ((acqmode == "swapallnof") || (acqmode == "mxs") ) savesigfits = false;
|
---|
333 | if (acqmode == "monoswh") { monothr = true; swapall = BR_SwapHDR;; }
|
---|
334 | if (acqmode == "monosw") { monothr = true; swapall = BR_SwapAll; }
|
---|
335 |
|
---|
336 | if (acqmode == "swap32") swapall = BR_Swap32 ;
|
---|
337 | if (acqmode == "nof32") { swapall = BR_Swap32 ; savesigfits = false; }
|
---|
338 | if (acqmode == "fft1c32") swapall = BR_FFTOneChan32;
|
---|
339 | if (acqmode == "fft2c32") swapall = BR_FFTTwoChan32;
|
---|
340 | if (acqmode == "fft1cnof32") { swapall = BR_FFTOneChan32; savesigfits = false; }
|
---|
341 | if (acqmode == "fft2cnof32") { swapall = BR_FFTTwoChan32; savesigfits = false; }
|
---|
342 |
|
---|
343 | }
|
---|
344 |
|
---|
345 |
|
---|
346 | /* --Nouvelle-Fonction-- */
|
---|
347 | int MonoCardAcq()
|
---|
348 | {
|
---|
349 | Timer tm("tmtacq/MonoCard");
|
---|
350 |
|
---|
351 | cout << " ---- tmtacq/ MonoCardAcq() ------------- " << endl;
|
---|
352 | #ifdef NOPCIECARD
|
---|
353 | TestPCIWrapperNODMA pciw(PaqSZ);
|
---|
354 | #else
|
---|
355 | DMAMgr dma1(card,patternSZ,dmaSize,activate_pattern);
|
---|
356 | if (! dma1.StatusFibre() ) {
|
---|
357 | cout << " tmtacq[3] - fibre non accrochee -> exit " << endl;
|
---|
358 | throw PCIEWException(" Fibre non accrochee ");
|
---|
359 | }
|
---|
360 | else cout << " tmtacq[3] - fibre accrochee OK " << endl;
|
---|
361 | PCIEWrapper pciw(dma1);
|
---|
362 | #endif
|
---|
363 | RAcqMemZoneMgr mmgr(nZones, nPaqZone, PaqSZ);
|
---|
364 | pMmgr =&mmgr;
|
---|
365 |
|
---|
366 | if (monothr) {
|
---|
367 | cout << "tmtacq[4] single thread PCIE test PCIEReaderChecker ... ";
|
---|
368 | PCIEReaderChecker pcirc(pciw,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall);
|
---|
369 | pPcierc=&pcirc;
|
---|
370 | pcirc.start();
|
---|
371 | sleep(1);
|
---|
372 | pcirc.join();
|
---|
373 | cout << "tmtacq[5] - single thread PCIEReaderChecker finished " << endl;
|
---|
374 | tm.Split("Single Thread Finished");
|
---|
375 | mmgr.Print(cout);
|
---|
376 | return 0;
|
---|
377 | }
|
---|
378 | PCIEReader pcir(pciw,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall);
|
---|
379 | pPcier= &pcir;
|
---|
380 | DataSaver ds(mmgr, OutPathName, NbFiles, NBlocPerFile, savesigfits);
|
---|
381 | pDs= &ds;
|
---|
382 | //DataBinSaver ds(mmgr, OutPathName, NbFiles ,NBlocPerFile);
|
---|
383 | // DataProc1C pr(mmgr, OutPathName, nmean, stepproc, 100); Pour processer un canal
|
---|
384 | int stepproc = 2;
|
---|
385 | int nmean = nPaqZone*NBlocPerFile/stepproc;
|
---|
386 | DataProc2C pr(mmgr, OutPathName, nmean, stepproc, NMaxProc);
|
---|
387 | DataProcFFT2C prfft(mmgr, OutPathName, nmean, stepproc, NMaxProc);
|
---|
388 | tm.Split("Threads created");
|
---|
389 | cout << "tmtacq[4] - starting 3 threads pcir, ds, pr ... " << endl;
|
---|
390 | /*
|
---|
391 | char test[100];
|
---|
392 | cout << " <CR> to continue, x to exit ..." << endl;
|
---|
393 | gets(test); if (test[0] == 'x') return 9;
|
---|
394 | */
|
---|
395 | pcir.start();
|
---|
396 | ds.start();
|
---|
397 | if (NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0
|
---|
398 | if (acqmode.substr(0,5)=="fft2c") { prfft.start(); pPrfft=&prfft;}
|
---|
399 | else { pr.start(); pPr=≺}
|
---|
400 | }
|
---|
401 | cout << "tmtacq[5] - waiting for threads to finish ... " << endl;
|
---|
402 | sleep(1);
|
---|
403 | pcir.join();
|
---|
404 | ds.join();
|
---|
405 | sleep(1);
|
---|
406 | mmgr.Stop();
|
---|
407 | if (NMaxProc>0) {
|
---|
408 | if ( pPr != NULL) pr.join();
|
---|
409 | if ( pPrfft != NULL) prfft.join();
|
---|
410 | }
|
---|
411 | cout << "tmtacq[6] - threads finished " << endl;
|
---|
412 | tm.Split("Threads Finished");
|
---|
413 | mmgr.Print(cout);
|
---|
414 | return 0;
|
---|
415 | }
|
---|
416 |
|
---|
417 |
|
---|
418 | /* --Nouvelle-Fonction-- */
|
---|
419 | int MultiCardAcq()
|
---|
420 | {
|
---|
421 | Timer tm("tmtacq/MultiCard");
|
---|
422 |
|
---|
423 | cout << " ---- tmtacq/ MultiCardAcq() ------------- " << endl;
|
---|
424 |
|
---|
425 | #ifdef NOPCIECARD
|
---|
426 | TestPCIWrapperNODMA pciw1(PaqSZ);
|
---|
427 | TestPCIWrapperNODMA pciw2(PaqSZ);
|
---|
428 | #else
|
---|
429 | DMAMgr dma1(cardlist[0],patternSZ,dmaSize,activate_pattern);
|
---|
430 | if (! dma1.StatusFibre() ) {
|
---|
431 | cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[0] << " -> exit " << endl;
|
---|
432 | throw PCIEWException(" Fibre non accrochee 1");
|
---|
433 | }
|
---|
434 | else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[0] << endl;
|
---|
435 |
|
---|
436 | DMAMgr dma2(cardlist[1],patternSZ,dmaSize,activate_pattern);
|
---|
437 | if (! dma1.StatusFibre() ) {
|
---|
438 | cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[1] << " -> exit " << endl;
|
---|
439 | throw PCIEWException(" Fibre non accrochee 2");
|
---|
440 | }
|
---|
441 | else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[1] << endl;
|
---|
442 |
|
---|
443 | cout << " ---- S to stop , C continue ... " << endl;
|
---|
444 | char ans[64];
|
---|
445 | gets(ans);
|
---|
446 | if ((ans[0] == 'S') || (ans[0] == 's')) return 5;
|
---|
447 |
|
---|
448 | PCIEWrapper pciw1(dma1);
|
---|
449 | PCIEWrapper pciw2(dma2);
|
---|
450 | #endif
|
---|
451 | RAcqMemZoneMgr mmgr1(nZones, nPaqZone, PaqSZ);
|
---|
452 | RAcqMemZoneMgr mmgr2(nZones, nPaqZone, PaqSZ);
|
---|
453 | pMmgr =&mmgr1;
|
---|
454 | pMmgr2 =&mmgr2;
|
---|
455 |
|
---|
456 | if (monothr) {
|
---|
457 | cout << "tmtacq[4] single thread/Card PCIE test PCIEReaderChecker ... ";
|
---|
458 | PCIEReaderChecker pcirc1(pciw1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall);
|
---|
459 | PCIEReaderChecker pcirc2(pciw2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall);
|
---|
460 | pPcierc=&pcirc1;
|
---|
461 | pPcierc2=&pcirc2;
|
---|
462 | pcirc1.start();
|
---|
463 | pcirc2.start();
|
---|
464 |
|
---|
465 | sleep(1);
|
---|
466 | pcirc1.join();
|
---|
467 | pcirc2.join();
|
---|
468 |
|
---|
469 | cout << "tmtacq[5] - single thread/Card PCIEReaderChecker finished " << endl;
|
---|
470 | tm.Split("Single Thread Finished");
|
---|
471 | mmgr1.Print(cout);
|
---|
472 | mmgr2.Print(cout);
|
---|
473 | return 0;
|
---|
474 | }
|
---|
475 | PCIEReader pcir1(pciw1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall);
|
---|
476 | pPcier= &pcir1;
|
---|
477 | PCIEReader pcir2(pciw2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall);
|
---|
478 | pPcier2= &pcir2;
|
---|
479 | char buff[32];
|
---|
480 | sprintf(buff, "Card%d", cardlist[0]);
|
---|
481 | string path1 = OutPathName + buff;
|
---|
482 | DataSaver ds1(mmgr1, path1, NbFiles, NBlocPerFile, savesigfits);
|
---|
483 | pDs= &ds1;
|
---|
484 | sprintf(buff, "Card%d", cardlist[1]);
|
---|
485 | string path2 = OutPathName + buff;
|
---|
486 | DataSaver ds2(mmgr2, path2, NbFiles, NBlocPerFile, savesigfits);
|
---|
487 | pDs2= &ds2;
|
---|
488 | //DataBinSaver ds(mmgr, OutPathName, NbFiles ,NBlocPerFile);
|
---|
489 | // DataProc1C pr(mmgr, OutPathName, nmean, stepproc, 100); Pour processer un canal
|
---|
490 | int stepproc = 2;
|
---|
491 | int nmean = nPaqZone*NBlocPerFile/stepproc;
|
---|
492 | DataProc2C pr1(mmgr1, path1, nmean, stepproc, NMaxProc);
|
---|
493 | DataProcFFT2C prfft1(mmgr1, path1, nmean, stepproc, NMaxProc);
|
---|
494 | DataProc2C pr2(mmgr2, path2, nmean, stepproc, NMaxProc);
|
---|
495 | DataProcFFT2C prfft2(mmgr2, path2, nmean, stepproc, NMaxProc);
|
---|
496 |
|
---|
497 | tm.Split("Threads created");
|
---|
498 | cout << "tmtacq[4] - starting 3 threads pcir, ds, pr ... " << endl;
|
---|
499 | /*
|
---|
500 | char test[100];
|
---|
501 | cout << " <CR> to continue, x to exit ..." << endl;
|
---|
502 | gets(test); if (test[0] == 'x') return 9;
|
---|
503 | */
|
---|
504 | pcir1.start();
|
---|
505 | ds1.start();
|
---|
506 | pcir2.start();
|
---|
507 | ds2.start();
|
---|
508 | if (NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0
|
---|
509 | if (acqmode.substr(0,5)=="fft2c") {
|
---|
510 | prfft1.start(); pPrfft=&prfft1;
|
---|
511 | prfft2.start(); pPrfft2=&prfft2;
|
---|
512 | }
|
---|
513 | else {
|
---|
514 | pr1.start(); pPr=&pr1;
|
---|
515 | pr2.start(); pPr2=&pr2;
|
---|
516 | }
|
---|
517 | }
|
---|
518 | cout << "tmtacq[5] - waiting for threads to finish ... " << endl;
|
---|
519 | sleep(1);
|
---|
520 | pcir1.join();
|
---|
521 | ds1.join();
|
---|
522 | pcir2.join();
|
---|
523 | ds2.join();
|
---|
524 | sleep(1);
|
---|
525 | mmgr1.Stop();
|
---|
526 | mmgr2.Stop();
|
---|
527 | if (NMaxProc>0) {
|
---|
528 | if ( pPr != NULL) pr1.join();
|
---|
529 | if ( pPr2 != NULL) pr2.join();
|
---|
530 | if ( pPrfft != NULL) prfft1.join();
|
---|
531 | if ( pPrfft2 != NULL) prfft2.join();
|
---|
532 | }
|
---|
533 |
|
---|
534 | cout << "tmtacq[6] - threads finished " << endl;
|
---|
535 | tm.Split("Threads Finished");
|
---|
536 | mmgr1.Print(cout);
|
---|
537 | mmgr2.Print(cout);
|
---|
538 | return 0;
|
---|
539 | }
|
---|