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