Changeset 3623 in Sophya for trunk/AddOn/TAcq/tmtacq.cc
- Timestamp:
- May 22, 2009, 9:59:38 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/tmtacq.cc
r3538 r3623 1 1 #include <iostream> 2 2 3 #include "tmtacq.h" 3 4 #include "racqumem.h" 4 5 #include "racqurw.h" 6 #ifndef NOPCIECARD 7 #include "racquwbin.h" 8 #endif 5 9 #include "racquproc.h" 10 6 11 7 12 #include "pciewrap.h" … … 18 23 using namespace std; 19 24 using namespace SOPHYA; 20 25 26 static DataSaver *pDs; 27 static PCIEReaderChecker *pPcierc; 28 static PCIEReader *pPcier; 29 static DataProcFFT2C *pPrfft; 30 static DataProc2C *pPr; 31 static RAcqMemZoneMgr *pMmgr; 21 32 //-------------------------------------------------------- 22 // Programme test acquisition BAORadio multi-thread 33 // Programme test acquisition BAORadio multi-thread 23 34 // LAL - R. Ansari Juillet - 2008 24 35 //-------------------------------------------------------- 36 void Stop(int s) 37 { 38 printf("............. MAIN ... receive signal %d \n",s); 39 if (pPcierc != NULL) pPcierc->Stop(); 40 if (pPcier != NULL) pPcier->Stop(); 41 if (pPr !=NULL) pPr->Stop(); 42 if (pPrfft !=NULL) pPrfft->Stop(); 43 if (pDs != NULL) pDs->Stop(); 44 if (pMmgr !=NULL) pMmgr->Stop(); 45 46 } 25 47 26 48 int main(int narg, char* arg[]) 27 { 49 { 50 51 struct sigaction act; 28 52 29 53 int rc = 0; 54 cout << " ===============================================================" << endl; 55 cout << " ========= " <<BAOR_ACQ_VER_STR <<BAOR_ACQ_VER <<" ===========" << endl; 56 cout << " ===============================================================" << endl; 57 58 if (narg < 8) { 59 cout << "\n Usage: tmtacq CardNum PaquetSize NFrameDMA NFiles NBlocPerFile NMaxProc DataDirPath [AcqMode] [NPaqMemZone][HardCtlC]" << endl; 60 cout << " - CardNum : PCI-Express card number (=1,2)" << endl; 61 cout << " - PaquetSize or FrameSize (=DATA+HDR+TRL_Size) " << endl; 62 cout << " - NFrameDMA = DMASize= NFrameDMA*1024 , 4KO<=MaxDMASize<=64 ko " << endl; 63 cout << " - NFiles = Number of data files produced " << endl; 64 cout << " - NBlocPerFile = Number of memory data bloc in one file " << endl; 65 cout << " - NMaxProc = Max number of memory data blocs processed (FFT ...) " << endl; 66 cout << " NMaxProc=0 -> No Processing " << endl; 67 cout << " - DataDirPath : Subdirectory of /Raid " << endl; 68 cout << " Pour la version du firmware qui ne swappe pas les paquets" << endl; 69 cout << " - AcqMode: = swapall , fft1c , fft2c, swh , nof , mxs , mono , monosw (default=std)" << endl; 70 cout << " swapall -> SwapAll+SaveData , swh->swap header only " << endl; 71 cout << " fft1c , ff2c -> reorder data for 1 channel/2channel FFT " << endl; 72 cout << " fft1cnof , ff2cnof -> reorder FFT data, but DONT write files " << endl; 73 cout << endl; 74 cout << " Pour la version du firmware qui swappe partiellement " << endl; 75 cout << " -AcqMode : swap32 ,fft1c32 , fft2c32,fft1cnof32 , fft2cnof32 " <<endl; 76 cout << " fft1c32 , fft2c32 -> reorder data for 1 channel/2channel FFT " << endl; 77 cout << " fft1cnof32 , ff2cnof32 -> reorder FFT data, but DONT write files " << endl << endl; 78 cout << endl; 79 cout << " Pour la version du firmware qui ne swappe plus " << endl; 80 cout << " -AcqMode : nosw,fft1cnosw , fft2cnosw" <<endl; 81 cout << " fft1cnosw , fft2cnosw -> reorder data for 1 channel/2channel FFT " << endl; 82 cout << " fft1cnofnosw , ff2cnofnosw -> reorder FFT data, but DONT write files " << endl << endl; 83 84 85 cout << " Option pour debug ou test performance swapp initial (std)" << endl ; 86 cout << " nof->Don't write signal fits files , mxs->swh+nof: swap header only + no fits " << endl; 87 cout << " mono->Test with a single thread PCIEReaderChecker " << endl; 88 cout << " monosw->Test with a single thread PCIEReaderChecker, But swap all packet " << endl; 89 cout << endl; 90 cout << " mononsw->Test with a single thread PCIEReaderChecker, But no swap paquet " << endl; 91 cout << endl; 92 cout << " - NPaqMemZone : Number of paquets in one memory data bloc (Default=128) " << endl; 93 cout << " -HardCtlC : Y y (direct interrpution by CtrlC ) default (no) " << endl; 94 return 1; 95 } 96 30 97 InitTim(); 31 98 … … 33 100 TArrayInitiator _arri; 34 101 FitsIOServerInitiator _fiosi; 35 36 102 Timer tm("tmtacq"); 37 string dir = "ExA"; 38 cout << "tmtacq[1] - starting acq program " << endl; 39 103 104 string acqmode = "std"; 105 if (narg > 8) acqmode = arg[8]; 106 bool savesigfits = true; 107 // BRDataFmtConv swapall = BR_SwapAll; 108 BRDataFmtConv swapall = BR_Copy; 109 bool monothr = false; 110 if (acqmode == "swapall") swapall = BR_SwapAll; 111 if (acqmode == "fft1c") swapall = BR_FFTOneChan; 112 if (acqmode == "fft2c") swapall = BR_FFTTwoChan; 113 if (acqmode == "fft1cnof") { swapall = BR_FFTOneChan; savesigfits = false; } 114 if (acqmode == "fft2cnof") { swapall = BR_FFTTwoChan; savesigfits = false; } 115 if ((acqmode == "swh") || (acqmode == "mxs") || (acqmode == "mono") ) swapall = BR_SwapHDR; 116 if ((acqmode == "nof") || (acqmode == "mxs") || (acqmode == "mono")) savesigfits = false; 117 if (acqmode == "mono") { monothr = true; swapall = BR_SwapHDR;; } 118 if (acqmode == "monosw") { monothr = true; swapall = BR_SwapAll; } 119 if (acqmode == "mononsw") { monothr = true; swapall = BR_Copy; } 120 121 if (acqmode == "swap32") swapall = BR_Swap32 ; 122 if (acqmode == "fft1c32") swapall = BR_FFTOneChan32; 123 if (acqmode == "fft2c32") swapall = BR_FFTTwoChan32; 124 if (acqmode == "fft1cnof32") { swapall = BR_FFTOneChan32; savesigfits = false; } 125 if (acqmode == "fft2cnof32") { swapall = BR_FFTTwoChan32; savesigfits = false; } 126 127 if (acqmode == "nosw") swapall = BR_Copy ; 128 if (acqmode == "fft1cnosw") swapall = BR_FFTOneChanNoSwap; 129 if (acqmode == "fft2cnosw") swapall = BR_FFTTwoChanNoSwap; 130 if (acqmode == "fft1cnofnosw") { swapall = BR_FFTOneChanNoSwap; savesigfits = false; } 131 if (acqmode == "fft2cnofnosw") { swapall = BR_FFTTwoChanNoSwap; savesigfits = false; } 132 133 #ifdef NOPCIECARD 134 string dir = string(arg[7])+"/"; 135 #else 136 string dir =string("/Raid/")+arg[7]+"/"; 137 #endif 138 cout << " DataDirpath=" << dir << " SwapMode=" << BRPaquet::FmtConvToString(swapall) 139 << " DataSaveMode=" << ((savesigfits)?"Yes/FitsFile":"NO") << endl; 140 141 char cmd[192]; 142 sprintf(cmd,"mkdir %s",dir.c_str()); 143 if (system(cmd) < 0) { 144 cout << "tmtacq/Error: Can not create subdirectory " << dir << " -> exit" << endl; 145 return 2; 146 } 147 int card = atoi(arg[1]); 148 unsigned int sizeFrame = atoi(arg[2]); 149 unsigned int nbFrameDMA = atoi(arg[3]); 150 int NbFiles = atoi(arg[4]); 151 int NBlocPerFile = atoi(arg[5]); 152 int NMaxProc = atoi(arg[6]); // Nombre de blocs traites par le thread de calcul 153 cout << "tmtacq[1] - starting acq program under card " << card << " FrameSize= " << sizeFrame << endl; 154 155 uint_4 nZones = 10; // Nombre de zones memoires 156 uint_4 nPaqZone = 128; // 128 Paquets / zone memoire - valeur par defaut 157 if (narg > 9) // pour traiter eventuellement un arret brutal par CtlC mettre le 9eme arg a Y 158 { string val = arg[9]; 159 if ( ( val == "Y")||( val == "y")) ; 160 else { 161 act.sa_handler=Stop; 162 sigaction(SIGINT,&act,NULL); 163 if ( atoi(arg[9]) > 0) nPaqZone=atoi(arg[9]); 164 } 165 } 166 else { 167 act.sa_handler=Stop; 168 sigaction(SIGINT,&act,NULL); 169 } 170 uint_4 PaqSZ =sizeFrame; // Taille de paquets 171 // uint_4 dmaSize = nbFrameDMA*PaqSZ ; // plantage 172 uint_4 dmaSize = nbFrameDMA*1024 ; 173 uint_4 patternSZ=0x400; // pas utilise avec la fibre 174 uint_4 NMaxBloc = NbFiles*NBlocPerFile; 175 cout << "tmtacq[0] - PaqSize = " << PaqSZ << " NbPaq/Zone=" << nPaqZone << " NZones=" << nZones << endl; 176 cout << " NbFiles=" << NbFiles << " NBloc/File=" << NBlocPerFile << " -> NMaxBloc=" << NMaxBloc << endl; 177 cout << "tmtacq[1] NbFrameDMA=" << nbFrameDMA << " DMASize=" << dmaSize << " bytes" << endl; 178 cout << "tmtacq[1] NMaxProc=" << NMaxProc << endl; 40 179 try { 41 RAcqMemZoneMgr mmgr(3,100,4096); 42 PCIEReader pcir(mmgr, 10); 43 DataSaver ds(mmgr, dir, 10); 44 DataProc pr(mmgr, dir, 1, 10); 180 181 #ifdef NOPCIECARD 182 TestPCIWrapperNODMA pciw(PaqSZ); 183 #else 184 DMAMgr dma1(card,patternSZ,dmaSize ); 185 if (! dma1.StatusFibre() ) { 186 cout << " tmtacq[0] - fibre non accrochee -> exit " << endl; 187 throw PCIEWException(" Fibre non accrochee "); 188 } 189 else cout << " tmtacq[0] - fibre accrochee OK " << endl; 190 #endif 191 RAcqMemZoneMgr mmgr(nZones, nPaqZone, PaqSZ); 192 pMmgr =&mmgr; 193 194 if (monothr) { 195 cout << "tmtacq[1] single thread PCIE test PCIEReaderChecker ... "; 196 PCIEReaderChecker pcirc(pciw,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall); 197 pPcierc=&pcirc; 198 pcirc.start(); 199 sleep(1); 200 pcirc.join(); 201 cout << "tmtacq[2] - single thread PCIEReaderChecker finished " << endl; 202 tm.Split("Single Thread Finished"); 203 mmgr.Print(cout); 204 return 0; 205 } 206 PCIEReader pcir(pciw,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall); 207 pPcier= &pcir; 208 DataSaver ds(mmgr, dir, NbFiles, NBlocPerFile, savesigfits); 209 pDs= &ds; 210 //DataBinSaver ds(mmgr, dir, NbFiles ,NBlocPerFile); 211 // DataProc1C pr(mmgr, dir, nmean, stepproc, 100); Pour processer un canal 212 int stepproc = 2; 213 int nmean = nPaqZone*NBlocPerFile/stepproc; 214 DataProc2C pr(mmgr, dir, nmean, stepproc, NMaxProc); 215 DataProcFFT2C prfft(mmgr, dir, nmean, stepproc, NMaxProc); 45 216 tm.Split("Threads created"); 46 217 cout << "tmtacq[2] - starting 3 threads pcir, ds, pr ... " << endl; 218 /* 219 char test[100]; 220 cout << " <CR> to continue, x to exit ..." << endl; 221 gets(test); if (test[0] == 'x') return 9; 222 */ 47 223 pcir.start(); 48 224 ds.start(); 49 pr.start(); 225 if (NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0 226 if (acqmode.substr(0,5)=="fft2c") { prfft.start(); pPrfft=&prfft;} 227 else { pr.start(); pPr=≺} 228 } 50 229 cout << "tmtacq[3] - waiting for threads to finish ... " << endl; 51 230 sleep(1); … … 54 233 sleep(1); 55 234 mmgr.Stop(); 56 pr.join(); 235 if (NMaxProc>0) if ( pPr != NULL) pr.join(); 236 if (NMaxProc>0) if ( pPrfft != NULL) prfft.join(); 57 237 cout << "tmtacq[4] - threads finished " << endl; 58 238 tm.Split("Threads Finished"); … … 63 243 cerr << " tmtacq.cc catched MiniFITSException " << exc.Msg() << endl; 64 244 rc = 77; 245 } 246 catch (PCIEWException& exc) { 247 cerr << "\7 tmtacq.cc catched MiniFITSException " << exc.Msg() << endl; 248 rc = 75; 65 249 } 66 250 catch (PThrowable& exc) { … … 75 259 } 76 260 catch (...) { 77 cerr << " tmtacq.cc : Catched ... exception " << endl;261 cerr << " tmtacq.cc : Catched ... exception " << endl; 78 262 rc = 79; 79 263 } … … 81 265 return rc; 82 266 } 267
Note:
See TracChangeset
for help on using the changeset viewer.