Changeset 3644 in Sophya


Ignore:
Timestamp:
May 28, 2009, 10:48:36 PM (16 years ago)
Author:
ansari
Message:

Ajout possibilite de mettre /dev/null pour les fichiers fits , cmv+reza

Location:
trunk/AddOn/TAcq
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/racqurw.cc

    r3643 r3644  
    216216    sprintf(fname,"%s/saver.log",path_.c_str());
    217217    ofstream filog(fname);
    218     filog << " DataProc::run() - starting log file " << ts << endl;                   
     218    filog << " DataSaver::run() - starting log file " << ts << endl;                   
    219219    filog << " NbFiles=" << nfiles_ << " NBloc/File="  << nblocperfile_ << " NMaxMemZones=" << nmax_ << endl;
    220220       
     
    232232    uint_4 fnum=0;
    233233    uint_4 paqsz = memgr.PaqSize();
     234    bool fgnulldev = false;
     235    if (path_ == "/dev/null") {
     236      cout << " DataSaver::run()/Warning /dev/null path specified, filenames=/dev/null" << endl;
     237      fgnulldev = true;
     238    }
    234239    for (uint_4 nbFile=0;nbFile<nfiles_ ;nbFile++) {
    235240      if (stop_ )   break;
    236       sprintf(fname,"%s/HDRfits%d.txt",path_.c_str(),fnum);
     241      if (fgnulldev) strcpy(fname,"/dev/null");
     242      else sprintf(fname,"%s/HDRfits%d.txt",path_.c_str(),fnum);
    237243      ofstream header(fname);
    238244
     
    242248      MiniFITSFile mff;
    243249      if (savesig_) { //Reza - Ouverture conditionnel fichier
    244         sprintf(fname,"%s/signal%d.fits",path_.c_str(),(int)fnum++);
     250        if (fgnulldev) strcpy(fname,"/dev/null");
     251        else sprintf(fname,"%s/signal%d.fits",path_.c_str(),(int)fnum++);
    245252        mff.Open(fname,MF_Write);  //Reza - Ouverture conditionnel fichier
    246253        // Entete correspondant a l'ecriture tout le paquet - trailer compris (modif Mai 2009)
  • trunk/AddOn/TAcq/tmtacq.cc

    r3643 r3644  
    6868 
    6969}
     70
     71#ifndef NOPCIECARD
     72// Declaration des fonctions pour DMAMgr... firmware V51
     73PCIEWrapperInterface* CreatePCIEWrapperV5F1( UINT32 numcard , UINT32 patternsize,
     74                                             UINT32 dmasz, bool activpatt=false);
     75void DeletePCIEWrapperV5F1(UINT32 numcard);
     76PCIEWrapperInterface* CreatePCIEWrapperV5F2( UINT32 numcard , UINT32 patternsize,
     77                                             UINT32 dmasz, bool activpatt=false);
     78void DeletePCIEWrapperV5F2(UINT32 numcard);
     79#endif
     80
    7081/* -------------------------------------------------------- */
    7182
     
    8091//------------------ Parametres de controle ----------------------------
    8192static string acqmode;
     93static int fibre = 0;  // =0 firmware pciexpress V496, =1 V51, fibre 1, =2 V51, fibre 2
    8294static  bool savesigfits = true;
     95static bool fgnulldev4fits = false;
    8396static  BRDataFmtConv swapall = BR_Copy;
    8497static  bool monothr = false;
    8598static string OutPathName;
     99static string ProcPathName;
    86100static bool singlecard = true;
    87101static int cardlist[4] = {1,1,1,1};
     
    179193   cout << "      NMaxProc=0 -> No Processing " << endl;
    180194   cout << " - DataDirPath : Subdirectory of /Raid " << endl;
     195   cout << "    specify /dev/null for performance tests ( ./XZXZXZX/ then used for other files)" << endl;
    181196   cout << " - AcqMode: Acquisition mode for the firmware V=496 (manages 64bits-byteswap)"<<endl;
    182197   cout << "     (V=496) AcqMode: std=nosw, fft1c, fft2c "<<endl;
     
    189204   cout << "     pattnof: activate pattern, NO fits files written "<<endl;
    190205   cout << "     pattmono: activate pattern, Single thread, copy packets "<<endl;
     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;
    191209   cout << " - MemZoneMgr: nZones,NPaq =Number of Zones and number of paquet \n"
    192210        << "               in each zone (Default=4,128) "<< endl;
     
    213231
    214232  acqmode = "std";
     233  fibre = 0; // firmware V496
    215234  if (narg>8) acqmode = arg[8];
    216235  savesigfits = true;
     
    240259  NMaxProc = atoi(arg[6]);  // Nombre de blocs traites par le thread de calcul
    241260
    242   OutPathName = "./";
     261  OutPathName = arg[7];
     262  fgnulldev4fits = (OutPathName == "/dev/null") ? true : false;
     263  if (!fgnulldev4fits) {
    243264#ifdef NOPCIECARD
    244   OutPathName = string(arg[7])+"/";
     265    OutPathName = OutPathName+"/";
    245266#else 
    246   OutPathName =string("/Raid/")+arg[7]+"/";
     267    OutPathName =string("/Raid/")+OutPathName+"/";
    247268#endif
     269  ProcPathName =  OutPathName;
     270  }
    248271  cout << "  DataDirpath=" << OutPathName << " SwapMode=" << BRPaquet::FmtConvToString(swapall)
    249272       << "  DataSaveMode=" << ((savesigfits)?"Yes/FitsFile":"NO") << endl;
    250273 
    251   char cmd[512];
    252   if (singlecard) {
    253     sprintf(cmd,"mkdir %s",OutPathName.c_str());
    254     if (system(cmd) < 0) {
    255       cout << "tmtacq/Error: Can not create  subdirectory " << OutPathName << " -> exit" << endl;
    256       return 2;
     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;
    257283    }
    258     else cout << " tmtacq[1] - Executed command " << cmd << endl;
     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    }
    259304  }
    260305  else {
    261     sprintf(cmd,"mkdir %s",OutPathName.c_str());
    262     if (system(cmd) < 0) {
    263       cout << "tmtacq/Error: Can not create  subdirectory " << OutPathName << " -> exit" << endl;
    264       return 2;
    265     }
    266     else cout << " tmtacq[1] - Executed command " << cmd << endl;
    267     sprintf(cmd,"mkdir %s/Card1",OutPathName.c_str());
    268     if (system(cmd) < 0) {
    269       cout << "tmtacq/Error: Can not create  subdirectory " << OutPathName << " -> exit" << endl;
    270       return 2;
    271     }
    272     else cout << " tmtacq[1] - Executed command " << cmd << endl;
    273     sprintf(cmd,"mkdir %s/Card2",OutPathName.c_str());
    274     if (system(cmd) < 0) {
    275       cout << "tmtacq/Error: Can not create  subdirectory " << OutPathName << " -> exit" << endl;
    276       return 2;
    277     }
    278     else cout << " tmtacq[1] - Executed command " << cmd << endl;
    279   }
     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    }
     315  }
     316
    280317  nZones = 8;  // Nombre de zones memoires
    281318  nPaqZone = 128;  // 128 Paquets / zone memoire - valeur par defaut
     
    313350void DecodeAcqMode()
    314351{
     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  }
    315360  if (acqmode == "nosw")   swapall = BR_Copy ;
    316361  if (acqmode == "nof")  { swapall = BR_Copy ; savesigfits = false; }
     
    350395
    351396  cout << " ---- tmtacq/ MonoCardAcq()  ------------- " << endl;
     397
     398  PCIEWrapperInterface* pciwp=NULL;
    352399#ifdef NOPCIECARD
    353400  TestPCIWrapperNODMA pciw(PaqSZ);
     401  pciwp = &pciw;
    354402#else
    355   DMAMgr dma1(card,patternSZ,dmaSize,activate_pattern);
    356   if (! dma1.StatusFibre() ) {
    357     cout << " tmtacq[3] - fibre non accrochee -> exit " << endl;
    358     throw PCIEWException(" Fibre non accrochee ");
    359   }
    360   else cout << " tmtacq[3] - fibre accrochee OK " << endl;
    361   PCIEWrapper pciw(dma1);
     403  DMAMgr* dmap=NULL;
     404  if (fibre == 1) {
     405    pciwp = CreatePCIEWrapperV5F1(card,patternSZ,dmaSize,activate_pattern);
     406  }
     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  }
    362419#endif   
    363420  RAcqMemZoneMgr mmgr(nZones, nPaqZone, PaqSZ);
     
    366423  if (monothr) {
    367424    cout << "tmtacq[4] single thread PCIE test PCIEReaderChecker ... ";
    368     PCIEReaderChecker pcirc(pciw,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall);
     425    PCIEReaderChecker pcirc(*pciwp,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall);
    369426    pPcierc=&pcirc;
    370427    pcirc.start();
     
    376433    return 0;
    377434  }
    378   PCIEReader pcir(pciw,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall);
     435  PCIEReader pcir(*pciwp,dmaSize,PaqSZ ,mmgr, NMaxBloc, swapall);
    379436  pPcier= &pcir;
    380437  DataSaver ds(mmgr, OutPathName, NbFiles, NBlocPerFile, savesigfits);
     
    384441  int stepproc = 2;
    385442  int nmean = nPaqZone*NBlocPerFile/stepproc;
    386   DataProc2C pr(mmgr, OutPathName, nmean, stepproc, NMaxProc);
    387   DataProcFFT2C prfft(mmgr, OutPathName, nmean, stepproc, NMaxProc);
     443  DataProc2C pr(mmgr, ProcPathName, nmean, stepproc, NMaxProc);
     444  DataProcFFT2C prfft(mmgr, ProcPathName, nmean, stepproc, NMaxProc);
    388445  tm.Split("Threads created"); 
    389446  cout << "tmtacq[4] - starting 3 threads pcir, ds, pr ... " << endl;
     
    412469  tm.Split("Threads Finished"); 
    413470  mmgr.Print(cout);
     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   
    414479  return 0;
    415480}
     
    423488  cout << " ---- tmtacq/ MultiCardAcq()  ------------- " << endl;
    424489
     490  PCIEWrapperInterface* pciwp1=NULL;
     491  PCIEWrapperInterface* pciwp2=NULL;
     492
    425493#ifdef NOPCIECARD
    426494  TestPCIWrapperNODMA pciw1(PaqSZ);
    427495  TestPCIWrapperNODMA pciw2(PaqSZ);
     496  pciwp1 = &pciw1;
     497  pciwp2 = &pciw2;
    428498#else
    429   DMAMgr dma1(cardlist[0],patternSZ,dmaSize,activate_pattern);
    430   if (! dma1.StatusFibre() ) {
    431     cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[0] << " -> exit " << endl;
    432     throw PCIEWException(" Fibre non accrochee 1");
    433   }
    434   else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[0] << endl;
    435 
    436   DMAMgr dma2(cardlist[1],patternSZ,dmaSize,activate_pattern);
    437   if (! dma1.StatusFibre() ) {
    438     cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[1] << " -> exit " << endl;
    439     throw PCIEWException(" Fibre non accrochee 2");
    440   }
    441   else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[1] << endl;
    442 
     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);
     504  }
     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;
     516
     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);
     525  }
     526  /*
    443527  cout << "  ---- S to stop , C continue ... " << endl;
    444528  char ans[64];
    445529  gets(ans);
    446530  if ((ans[0] == 'S') || (ans[0] == 's'))  return 5;
    447 
    448   PCIEWrapper pciw1(dma1);
    449   PCIEWrapper pciw2(dma2);
     531  */
    450532#endif   
    451533  RAcqMemZoneMgr mmgr1(nZones, nPaqZone, PaqSZ);
     
    456538  if (monothr) {
    457539    cout << "tmtacq[4] single thread/Card PCIE test PCIEReaderChecker ... ";
    458     PCIEReaderChecker pcirc1(pciw1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall);
    459     PCIEReaderChecker pcirc2(pciw2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall);
     540    PCIEReaderChecker pcirc1(*pciwp1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall);
     541    PCIEReaderChecker pcirc2(*pciwp2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall);
    460542    pPcierc=&pcirc1;
    461543    pPcierc2=&pcirc2;
     
    473555    return 0;
    474556  }
    475   PCIEReader pcir1(pciw1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall);
     557  PCIEReader pcir1(*pciwp1,dmaSize,PaqSZ ,mmgr1, NMaxBloc, swapall);
    476558  pPcier= &pcir1;
    477   PCIEReader pcir2(pciw2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall);
     559  PCIEReader pcir2(*pciwp2,dmaSize,PaqSZ ,mmgr2, NMaxBloc, swapall);
    478560  pPcier2= &pcir2;
    479561  char buff[32];
    480562  sprintf(buff, "Card%d", cardlist[0]);
    481563  string path1 = OutPathName + buff;
     564  string ppath1 = ProcPathName + buff;
    482565  DataSaver ds1(mmgr1, path1, NbFiles, NBlocPerFile, savesigfits);
    483566  pDs= &ds1;
    484567  sprintf(buff, "Card%d", cardlist[1]);
    485568  string path2 = OutPathName + buff;
     569  string ppath2 = ProcPathName + buff;
    486570  DataSaver ds2(mmgr2, path2, NbFiles, NBlocPerFile, savesigfits);
    487571  pDs2= &ds2;
     
    489573  //     DataProc1C pr(mmgr, OutPathName, nmean, stepproc, 100);     Pour processer un canal
    490574  int stepproc = 2;
     575 
    491576  int nmean = nPaqZone*NBlocPerFile/stepproc;
    492   DataProc2C pr1(mmgr1, path1, nmean, stepproc, NMaxProc);
    493   DataProcFFT2C prfft1(mmgr1, path1, nmean, stepproc, NMaxProc);
    494   DataProc2C pr2(mmgr2, path2, nmean, stepproc, NMaxProc);
    495   DataProcFFT2C prfft2(mmgr2, path2, nmean, stepproc, NMaxProc);
     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);
    496581
    497582  tm.Split("Threads created"); 
     
    536621  mmgr1.Print(cout);
    537622  mmgr2.Print(cout);
     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   
    538639  return 0;
    539640}
Note: See TracChangeset for help on using the changeset viewer.