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