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