Changeset 3913 in Sophya for trunk/AddOn/TAcq/mfacq.cc


Ignore:
Timestamp:
Nov 26, 2010, 2:45:39 PM (15 years ago)
Author:
ansari
Message:

1/ Correction de gestion de changement de timeout DMA ( racqueth.cc , racqurw.cc)
2/ Amelioration de la gestion des arguments de ligne de commande et

datacard - introduction de variables d'environnement
BRACQ_TMPDIR TMPDIR BRACQ_BASEDIR BRACQ_FIBERIDS

3/ possibilite de specifier des cibles ethernet pour chaque fibre

Reza 26/11/2010

File:
1 edited

Legend:

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

    r3909 r3913  
    5353 
    5454  const char* desact[4] = {"PCIE_To_Ethernet", "Ethernet_To_Disk", "Ethernet_To_Visibilities","PCIE_DMA_To_Disk"};
    55   string action=arg[1];
    56   int act = 0;
    57   if ((action != "-pci2eth")&&(action != "-pci2disk")&&(action != "-eth2disk")&&(action != "-eth2visib")) {
    58     cout << " mfacq/Error , Bad action argument : " << action << endl;
    59     return 2;
    60   }
    61   if (action == "-pci2eth")  act=0;
    62   else if (action == "-eth2disk") act=1; 
    63   else if (action == "-eth2visib") act=2;
    64   else if (action == "-pci2disk")  act=3;
    65 
    66   string pardcfile=arg[2];
    67 #ifndef NOPCIECARD 
    68   string basedir="/Raid";
    69 #else
    70   string basedir="./";
    71 #endif
    72   vector<string> oargs;
    73   if (narg>3)  {
    74     basedir=arg[2];
    75     for(int jj=3; jj<narg; jj++)  oargs.push_back(arg[jj]);
    76   }
    7755  try {
    7856    // Creation/initialisation parametres Acq
    79     BRAcqConfig acpar;
    80     acpar.ReadParamFile(pardcfile);
    81     acpar.GetConfig().SetBaseDirectory(basedir);
    82     if ((act==0)&&(oargs.size()>0))
    83       acpar.GetParams().SetEthTargets(oargs);
    84     // Creation des repertoires
    85     if (act > 0)
    86       if (acpar.CreateOutputDirectories()!=0)  return 9;
    87     acpar.GetParams().fgdoVisiC=false;
    88     if (act == 2)  acpar.GetParams().fgdoVisiC=true;
    89 
    90     acpar.Print(cout);
    91     struct sigaction siact; 
    92     if (!acpar.GetParams().fg_hard_ctrlc) {
    93       siact.sa_handler=Stop;
    94       sigaction(SIGINT,&siact,NULL);       
     57    int act = DecodeArgs(narg,arg);
     58    if ((act < 0)||(act>3))  {
     59      cout << "mfacq/ERROR decoding arguments act=" << act << " -> exit -5" << endl;
     60      return -5;
    9561    }
     62    cout << " mfacq/INFO action: " << desact[act] << endl;
    9663    switch (act) {
    9764    case 0:
     
    139106void Usage(bool fgshort)
    140107{
    141   cout << " Usage: mfacq Action DataCardFile [BaseDirectory / TargetMachines]" << endl;
     108  cout << " Usage: mfacq Action DataCardFileName [-dc DataCard -dc DataCard] [TargetMachines]" << endl;
    142109  if (fgshort) return;
    143110  cout << " o Action = -pci2disk , -pci2eth , -eth2disk , -eth2visib \n "
     
    145112       << "     fibres outpathname skysource paqsize dmasizekb nbfiles \n"
    146113       << "     nblocperfile acqmode memmgr monitor reducpaqsz ... "<< endl;
    147   cout << " o BaseDirectory (default= /Raid ) for -pci2disk , -eth2disk" << endl;
     114  cout << " o -dc DataCard : datacard appended for DataCardFileName" << endl;
    148115  cout << " o TargetMachines : List of target machines for PCIe2Ethernet (-pci2eth) \n " << endl;
    149116  return;
    150117}
    151  
     118
     119/* --Nouvelle-Fonction-- */
     120int DecodeArgs(int narg, char* arg[])
     121{
     122  string action=arg[1];
     123  int act = 0;
     124  if ((action != "-pci2eth")&&(action != "-pci2disk")&&(action != "-eth2disk")&&(action != "-eth2visib")) {
     125    cout << " mfacq/Error , Bad action argument : " << action << endl;
     126    return -2;
     127  }
     128  if (action == "-pci2eth")  act=0;
     129  else if (action == "-eth2disk") act=1; 
     130  else if (action == "-eth2visib") act=2;
     131  else if (action == "-pci2disk")  act=3;
     132
     133  BRAcqConfig acpar;
     134  char tmpdcname[128];
     135  sprintf(tmpdcname,"%s/dc_XXXXXX",acpar.TmpDirectory().c_str());
     136  mktemp(tmpdcname);
     137  string dcardfile=tmpdcname;
     138  dcardfile+=".d";
     139  string pardcfile=arg[2];
     140  char cmd[512];
     141  sprintf(cmd,"cp %s %s",pardcfile.c_str(),dcardfile.c_str());
     142  cout << " mfacq/DecodeArgs() executing command: " << cmd << endl;
     143  int rc;
     144  rc=system(cmd);
     145  if (rc!=0) {
     146    cout << " mfacq/ERROR system(cmd) , Rc=" << rc << endl;
     147    return -3;
     148  }
     149 
     150  vector<string> oargs;
     151  int aoff=3;
     152  {
     153    ofstream dcf( dcardfile.c_str(), ios_base::out|ios_base::app);
     154    dcf << "#### Appended datacards from command line " << endl;
     155    while (aoff<(narg-1)) {
     156      if (strcmp(arg[aoff],"-dc") != 0) break;
     157      dcf << arg[aoff+1] << endl;
     158    }
     159    if ((act==0)&&(aoff<narg)) {  // default ethernet target destinations
     160      dcf << "@ethrtargets  ";
     161      for(int jj=aoff; jj<narg; jj++)  dcf << arg[jj] << " ";
     162      dcf << endl;
     163    }
     164  }
     165
     166  acpar.GetParams().fgdoVisiC=false;
     167  if (act == 2)  acpar.GetParams().fgdoVisiC=true;
     168 
     169  acpar.ReadParamFile(dcardfile);
     170  acpar.CreateOutputDirectories();
     171
     172  sprintf(cmd,"cp %s %s/acqparm.d",dcardfile.c_str(),acpar.OutputDirectory().c_str());
     173  cout << " mfacq/DecodeArgs() executing command: " << cmd << endl;
     174  rc=system(cmd);
     175  if (rc!=0) {
     176    cout << " mfacq/ERROR system(cmd) , Rc=" << rc << endl;
     177    return -3;
     178  }
     179
     180  acpar.Print(cout);
     181  string pflnm=acpar.OutputDirectory();
     182  pflnm+="/params.log";
     183  ofstream pfile(pflnm.c_str());
     184  acpar.Print(pfile);
     185
     186  struct sigaction siact; 
     187  if (!acpar.GetParams().fg_hard_ctrlc) {
     188    siact.sa_handler=Stop;
     189    sigaction(SIGINT,&siact,NULL);       
     190  }
     191
     192  return act;
     193}
    152194 
    153195/* --Nouvelle-Fonction-- */
     
    210252  vector<PCIEWrapperInterface*> vec_pciw;
    211253  for  (size_t i=0 ;i<bpar.NFibers();i++)  {
    212     pciwp[i]->SetFiberNumId(acpar.FiberNum[i], acpar.FiberIds[i]);
     254    pciwp[i]->SetFiberNumId(bpar.FiberNum(i), bpar.FiberId(i));
    213255    vec_pciw.push_back( pciwp[i]);
    214256    //    cout << " mfacq[3.b]/Debug - pciwp[" << i << "] " << hex << pciwp[i] << dec << endl;
     
    299341  vector<PCIEWrapperInterface*> vec_pciw;
    300342  for  (size_t i=0 ;i<bpar.NFibers();i++)  {
    301     pciwp[i]->SetFiberNumId(acpar.FiberNum[i], acpar.FiberIds[i]);
     343    pciwp[i]->SetFiberNumId(bpar.FiberNum(i), bpar.FiberId(i));
    302344    vec_pciw.push_back( pciwp[i]);
    303345  }
     
    329371}
    330372
    331 
    332 /* Fonction-Utilitaire : Voir en fin de fichier  */
    333 MemZaction ConvertMemZ_Status2Action( MemZStatus st );
    334373
    335374/* --Nouvelle-Fonction-- */
     
    385424  string ppath=bpar.OutputDirectory();
    386425  MonitorProc PrThr(mmgr);
    387   PrThr.SetMemZAction( ConvertMemZ_Status2Action( mskmon ) );
     426  PrThr.SetMemZAction( RAcqMemZoneMgr::Convert_Status2Action( mskmon ) );
    388427  BRVisCalcGroup VCGThr(acpar.nbcalgrpVisiC, mmgr, bpar.OutputDirectory(), acpar.nmeanVisiC, acpar.nthrVisiC);
    389428  VCGThr.SelectFreqBinning(acpar.freqminVisiC, acpar.freqmaxVisiC, acpar.nbinfreqVisiC);
     
    436475
    437476
    438 /* --Nouvelle-Fonction-Utilitaire */
    439 MemZaction ConvertMemZ_Status2Action( MemZStatus st )
    440 {
    441   MemZaction ra=MemZA_None;
    442   switch (st) {
    443   case MemZS_Filled:
    444     ra=MemZA_Fill;
    445     break;
    446   case MemZS_Saved:
    447     ra=MemZA_Save;
    448     break;
    449   case MemZS_Proc:
    450     ra=MemZA_Proc;
    451     break;
    452   case MemZS_ProcA:
    453     ra=MemZA_ProcA;
    454     break;
    455   case MemZS_ProcB:
    456     ra=MemZA_ProcB;
    457     break;
    458   case MemZS_ProcC:
    459     ra=MemZA_ProcC;
    460     break;
    461   case MemZS_ProcD:
    462     ra=MemZA_ProcD;
    463     break;
    464   case MemZS_ProcE:
    465     ra=MemZA_ProcE;
    466     break;
    467   case MemZS_ProcF:
    468     ra=MemZA_ProcF;
    469     break;
    470   default:
    471     ra=MemZA_None;
    472     break;
    473   }
    474   return ra;
    475 }
Note: See TracChangeset for help on using the changeset viewer.