Changeset 3913 in Sophya


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

Location:
trunk/AddOn/TAcq
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/acqparam_exemple.d

    r3909 r3913  
    44#          2009 - 2010
    55#################################################################
     6#####      Variables d'environnement de configuration
     7## BRACQ_TMPDIR , TMPDIR  : Repertoire de fichiers temporaires (defaut=/tmp/)
     8## BRACQ_BASEDIR : Base directory (/Raid)
     9## BRACQ_FIBERIDS : FiberIds   (defaut 1,2,3,4,5,6,7,8)
     10#################################################################
     11
    612#   Liste des fibres  - @fibres I[,J,K...]  ou @fibers
    713#   @fibers 1,2,3   OU   @fibres 1,2,3
     
    5864#  @ethrtargets Target1 [ Target2 ... ]
    5965ethrtargets machine1 machine2 ...
     66##  Liste de cible pour chaque machine
     67#  @ethrtargetsf1 targ1 [targ2 ...]
     68#  @ethrtargetsf8 targ1 [targ2 ...]
     69ethrtargetsf1 machine1 machine2 ...
     70ethrtargetsf2 machine1 machine2 ...
     71##
    6072#  Activation du mode transfert direct DMA -> Ethernet , sans decoupage/verification en paquet a la source
    6173#  @pci2ethdirect
  • trunk/AddOn/TAcq/brparam.cc

    r3911 r3913  
    4242}
    4343
     44#define PMAXNBFIBRES 64
    4445/* --Methode-- */
    4546BRConfList::BRConfList()
    46   : basedir_("./")
    47 {
     47  : basedir_("./"), fiberIds_(PMAXNBFIBRES), tmpdir_("/tmp")
     48{
     49  InitFromEnv();
    4850}
    4951
    5052/* --Methode-- */
    5153BRConfList::BRConfList(string basedir)
    52   : basedir_(basedir)
    53 {
     54  : basedir_("./"), fiberIds_(PMAXNBFIBRES), tmpdir_("/tmp")
     55{
     56  InitFromEnv();
     57  SetBaseDirectory(basedir);
    5458}
    5559
    5660/* --Methode-- */
    5761BRConfList::BRConfList(string basedir, vector<ADCBoardDesc> boards)
    58   : basedir_(basedir), boards_(boards)
    59 {
    60   size_t len = basedir_.length();
    61   if ((len>1)&&(basedir_[len-1]!='/')) basedir_ += '/';
     62  : basedir_("./"), fiberIds_(PMAXNBFIBRES), tmpdir_("/tmp")
     63{
     64  InitFromEnv();
     65  SetBaseDirectory(basedir);
     66  boards_=boards;
    6267}
    6368
    6469/* --Methode-- */
    6570BRConfList::BRConfList(BRConfList const & cf)
    66   : basedir_(cf.basedir_), boards_(cf.boards_)
    67 {
    68 }
    69 
    70 /* --Methode-- */
    71 void BRConfList::SetBaseDirectory(string basedir)
    72 {
     71  : basedir_(cf.basedir_), boards_(cf.boards_), fiberIdsS_(cf.fiberIdsS_), fiberIds_(cf.fiberIds_), tmpdir_(cf.tmpdir_)
     72{
     73}
     74
     75/* --Methode-- */
     76void BRConfList::InitFromEnv()
     77{
     78  const char* venvp = NULL;
     79  venvp=getenv("BRACQ_TMPDIR");
     80  if (venvp!=NULL) tmpdir_=venvp;
     81  else {
     82    if (venvp!=NULL) tmpdir_=venvp;
     83    venvp = getenv("TMPDIR");
     84  }
     85  venvp=getenv("BRACQ_BASEDIR");
     86  if (venvp!=NULL) {
     87    string ebd=venvp;
     88    SetBaseDirectory(ebd);
     89  }
     90  string fibids="1,2,3,4,5,6,7,8";
     91  venvp=getenv("BRACQ_FIBERIDS");
     92  if (venvp!=NULL)  fibids=venvp;
     93  SetFiberIds(fibids);
     94}
     95
     96/* --Methode-- */
     97int BRConfList::SetFiberIds(string& sfids)
     98{
     99  fiberIdsS_=sfids;
     100  vector<string> fibids;
     101  FillVStringFrString(sfids, fibids, ',');
     102  int rc=0;
     103  for (size_t fib=0; fib<fibids.size(); fib++) {
     104    if (fib>fiberIds_.size())  break;
     105    fiberIds_[fib]=atoi(fibids[fib].c_str());
     106    rc++;
     107  }
     108  return rc;
     109}
     110
     111/* --Methode-- */
     112void BRConfList::SetBaseDirectory(string& basedir)
     113{
     114  if (basedir.length()<1)  return;
    73115  basedir_=basedir;
    74116  size_t len = basedir_.length();
     
    77119
    78120/* --Methode-- */
    79 void BRConfList::Set(BRConfList const & cf)
     121BRConfList& BRConfList::Set(BRConfList const & cf)
    80122{
    81123  basedir_=cf.basedir_;
    82124  boards_=cf.boards_;
     125  fiberIdsS_=cf.fiberIdsS_;
     126  fiberIds_=cf.fiberIds_;
     127  tmpdir_=cf.tmpdir_;
     128  return (*this);
    83129}
    84130
     
    86132ostream& BRConfList::Print(ostream& os)
    87133{
    88   os << " ----- BRConfList:: BaseDir:" << basedir_ << " NBoards= " << boards_.size() << endl;
     134  os << " ----- BRConfList:: BaseDir=" << basedir_ << " TmpDir=" << tmpdir_
     135     << " NBoards= " << boards_.size() << endl;
    89136  for(size_t k=0; k<boards_.size(); k++)  boards_[k].Print(os);
     137  os << " FiberIdString=" << fiberIdsS_ << endl;
    90138  return os;
    91139}
     
    98146
    99147// Classe qui memorise tous les parametres importants de l'acquisition
    100 #define PMAXNBFIBRES 64
    101148
    102149/* --Methode-- */
     
    110157
    111158  FiberListS=fibres;
    112   FiberIdsS="1,2,3,4,5,6,7,8";
    113   for (int ii=0; ii<PMAXNBFIBRES; ii++)  FiberIds.push_back(ii+1);
    114159
    115160  PaqSize=paqsz;
     
    188233
    189234  FiberListS=p.FiberListS;
    190   FiberNum=p.FiberNum;
    191   FiberIdsS=p.FiberIdsS;
    192   FiberIds=p.FiberIds;
     235  fiberNum_=p.fiberNum_;
    193236
    194237  PaqSize=p.PaqSize;
     
    222265  pci2eth_fgdirect=p.pci2eth_fgdirect;
    223266  eths_targets=p.eths_targets;
     267  eths_stargs=p.eths_stargs;
     268  eths_fibtargs=p.eths_fibtargs;
     269
    224270  ethr_nlink=p.ethr_nlink;
    225271  ethr_forcesamefc_=p.ethr_forcesamefc_;
     
    254300  else if(conf.HasKey("fibers"))
    255301    FiberListS= conf.SParam("fibers",0,"1");
    256   if(conf.HasKey("fiberids"))   
    257     FiberIdsS= conf.SParam("fiberids",0,"1");
    258302
    259303  OutPathName= conf.SParam("outpathname",0,"TstAcq");
     
    280324  tcpportid=conf.IParam("tcpportid",0,BRSPORTID);
    281325  if (conf.HasKey("pci2ethdirect"))  pci2eth_fgdirect = true;   // Transfer direct DMA -> Ethernet
    282   if (conf.HasKey("ethrtargets")) {    // Machines destinations des paquets
     326  if (conf.HasKey("ethrtargets")) {    // Machines destinations des paquets - memes destinations pour toutes les fibres
    283327    for(int it=0; it<conf.NbParam("ethrtargets"); it++)
    284       eths_targets.push_back(conf.SParam("ethrtargets",it));
    285   }
     328      eths_stargs.push_back(conf.SParam("ethrtargets",it));
     329  }
     330
     331  const char* ethtf[9]={"ethrtargetsf1","ethrtargetsf2","ethrtargetsf3","ethrtargetsf4",
     332                        "ethrtargetsf5","ethrtargetsf6","ethrtargetsf7","ethrtargetsf8"};
     333  for(int jj=0;jj<8;jj++) {
     334    if (conf.HasKey( ethtf[jj] )) {
     335      vector<string> ftargs;
     336      int fid=jj+1;
     337      for(int it=0; it<conf.NbParam( ethtf[jj] ); it++)
     338        ftargs.push_back(conf.SParam( ethtf[jj] ,it));
     339      eths_fibtargs[fid]=ftargs;     
     340    }
     341  }
     342
    286343  ethr_nlink=conf.IParam("ethrnlink",0,0);   // Nombre de sources de paquets en reception ethernet
    287344  if (conf.HasKey("ethrforcesamefc"))  {
     
    328385  vector<string> fiblist;
    329386  FillVStringFrString(FiberListS, fiblist, ',');
    330   FiberNum.resize(fiblist.size());
     387  fiberNum_.resize(fiblist.size());
    331388  for (int fib=0; fib<fiblist.size(); fib++) {
    332     FiberNum[fib]=atoi(fiblist[fib].c_str());
    333   }
    334   vector<string> fibids;
    335   FillVStringFrString(FiberIdsS, fibids, ',');
    336   for (int fib=0; fib<fibids.size(); fib++) {
    337     FiberIds[fib]=atoi(fibids[fib].c_str());
     389    fiberNum_[fib]=atoi(fiblist[fib].c_str());
     390  }
     391
     392  eths_targets.resize(fiberNum_.size());
     393  for (int fib=0; fib<fiberNum_.size(); fib++) {
     394    map< int, vector<string> >::const_iterator itm=eths_fibtargs.find(fiberNum_[fib]);
     395    if (itm != eths_fibtargs.end())   eths_targets[fib]=itm->second;
     396    else eths_targets[fib]=eths_stargs;
    338397  }
    339398
     
    414473  os << " ------ BRParList::Print() ----- " << endl;
    415474  os << " FiberListS=" << FiberListS ;
    416   os << " FiberIdsS=" << FiberIdsS ;
    417   os << " Fibers (Num->Id): ";
    418   for(size_t f=0; f<NbFibers(); f++)   cout << FiberNum[f] << " -> " << FiberIds[f] << " ; " ;
    419   os << endl;
    420475  os << " PaqSize=" <<PaqSize;
    421476  os << " DMA_Size_kb=" <<dmasizekb << " (EndDMA: Maxkw=" << maxkwedma_ << " NRetry=" << nretrydma_
     
    432487    os << " PaquetSize Reduction, ReducedSize=" << redpqsize << " Offset=" << reducoffset << endl;
    433488  }
    434   if (eths_targets.size()>0)   {
    435     cout << " DMA->Ethernet NbTargets=" << eths_targets.size()
    436          << ((pci2eth_fgdirect)?" (DirectTransferMode) " : " " ) << " :";
    437     for(size_t it=0; it<eths_targets.size(); it++) cout << eths_targets[it] << " , ";
    438     cout << endl;
    439   }
    440   cout << " TCP-PortId=" << tcpportid << " EthernetRead NbSources (=NbLinks)= " << ethr_nlink << endl;
     489  if ((eths_stargs.size()>0)||(eths_fibtargs.size()>0))   {
     490    os << " DMA->Ethernet Targets=" << eths_targets.size()
     491         << ((pci2eth_fgdirect)?" (DirectTransferMode) " : " " ) << endl;
     492   
     493    for(size_t fib=0; fib<eths_targets.size(); fib++) {
     494      os << " Fiber Num=" << fiberNum_[fib] << " --> eth_targets: ";
     495      for(size_t it=0; it<eths_targets[fib].size(); it++)
     496        os << eths_targets[fib][it] << " ; ";
     497    os << endl;
     498    }
     499  }
     500  os << " TCP-PortId=" << tcpportid << " EthernetRead NbSources (=NbLinks)= " << ethr_nlink << endl;
    441501  if (ethr_forcesamefc_)
    442     cout << "EthernetReader mode: ForceSameFrameCounter read mode with Max_PaquetCounterDiff= "
     502    os << "EthernetReader mode: ForceSameFrameCounter read mode with Max_PaquetCounterDiff= "
    443503         << ethr_sfc_maxdpc_ << " MaxNbResync=" << ethr_sfc_maxresync_
    444504         << ((ethr_waitendmsg_)?" Wait_For_END_Message_Before_Terminate ":" ") << endl;
    445505  else
    446     cout << "EthernetReader mode: AllOKPaquets read mode "
     506    os << "EthernetReader mode: AllOKPaquets read mode "
    447507         << ((ethr_waitendmsg_)?" Wait_For_END_Message_Before_Terminate ":" ") << endl;
    448508
     
    483543  config_->Print(os);
    484544  param_->Print(os);
     545  os << " Fibers f: Num->Id  ";
     546  for(size_t f=0; f<NbFibers(); f++)   
     547    os << f << ": " << FiberNum(f) << " -> " << FiberId(f) << " ; " ;
     548  os << endl;
    485549  os << " ----------------------------------------------------- " << endl;
    486550}
     
    501565    memset(cmd,0,1024);
    502566    for (int  i= 0; i< NFibers() ; i++)  {
    503       sprintf(cmd,"mkdir %s%s/Fiber%d",config_->BaseDirectory().c_str(), param_->OutPathName.c_str(),param_->FiberNum[i]);
     567      sprintf(cmd,"mkdir %s%s/Fiber%d",config_->BaseDirectory().c_str(), param_->OutPathName.c_str(),param_->fiberNum_[i]);
    504568      if (system(cmd) < 0) {
    505569        cout << "CreateOutputDirectories()/Error: Can not create subdirectory "
     
    529593{
    530594  char buff[24];
    531   sprintf(buff,"Fiber%d/",param_->FiberNum[ifib]);
     595  sprintf(buff,"Fiber%d/",param_->fiberNum_[ifib]);
    532596  return ( config_->BaseDirectory() + param_->OutPathName + buff );
    533597}
  • trunk/AddOn/TAcq/brparam.h

    r3909 r3913  
    2020#include <string>
    2121#include <vector>
     22#include <map>
    2223#include <iostream>
    2324#include "brpaqu.h"
     
    6162  BRConfList(BRConfList const & cf);
    6263
    63   void SetBaseDirectory(string basedir);
    64   void Set(BRConfList const & cf);
     64  void SetBaseDirectory(string& basedir);
     65  BRConfList& Set(BRConfList const & cf);
     66  inline BRConfList& operator = (BRConfList const & cf) { return Set(cf); }
     67
     68  int SetFiberIds(string& sfids);  // Identification absolue des fibres sous forme de 3,5,8
     69
    6570  ostream& Print(ostream& os) ;
    6671  void ReadDCFile(string file);
    6772  inline const string& BaseDirectory() const { return basedir_; }
     73  inline const string& TmpDirectory() const { return tmpdir_; }
     74
     75  inline int FiberId(int numfib)
     76  { size_t ff=numfib-1; if (ff<fiberIds_.size())  return fiberIds_[ff]; else return 0; }
     77
     78  void InitFromEnv();  // initialisation a partir de variables d'environnement
    6879//.......................................
    6980  string basedir_;
    7081  vector<ADCBoardDesc> boards_;
     82  string fiberIdsS_;     // String_liste des numeros 'absolu' des fibres 12,13,14,15 par exemple
     83  vector<int> fiberIds_;  // liste des numero d'identification 'absolu' des fibres {12,13,14,15} par ex.
     84  string tmpdir_;       // repertoire pour fichiers temporaires
    7185};
    7286
     
    86100  void ReadDCFile(string file);
    87101
    88   // Nombre de fibres
    89   inline size_t NFibers() { return FiberNum.size(); }
    90   inline size_t NbFibers() { return FiberNum.size(); }
     102  // Nombre de fibres pour acquisition
     103  inline size_t NFibers() { return fiberNum_.size(); }
     104  inline size_t NbFibers() { return fiberNum_.size(); }
     105  // Numeros des fibres pour acquisition
     106  inline int FiberNum(size_t fib)
     107    { if (fib<fiberNum_.size())  return fiberNum_[fib]; else return 0; }
    91108  // Taille des operations DMA (en octets)
    92109  inline uint_4 DMASizeBytes() { return dmasizekb*1024; }
     
    114131  inline uint_4 PatternSize() { return ((PaqSize-(BRHDRSIZE+BRTRLSIZE))/4); }
    115132
    116   // Liste des machines cibles pour transfert sur ethernet
    117   inline void SetEthTargets(vector<string>& targs) { eths_targets=targs; return; }
    118   inline vector<string>& GetEthTargets() { return eths_targets; }
     133  inline vector< vector<string> >& GetEthTargets() { return eths_targets; }
    119134  // Nombre de liens ethernet comme source de donnees (paquets)
    120135  inline int NbEthLinks() { return ethr_nlink; }
     
    130145  bool fgsinglechannel; // true -> un seul canal par fibre (par defaut=2 canaux/fibres)
    131146
    132   string FiberListS ;    // String_liste des fibres a utiliser 1,3,4 par exemple
    133   vector<int> FiberNum;  // liste des fibres a utiliser {1,3,4} par exemple
    134   string FiberIdsS ;     // String_liste des numeros 'absolu' des fibres 12,13,14,15 par exemple
    135   vector<int> FiberIds;  // liste des numero d'identification 'absolu' des fibres {12,13,14,15} par ex.
     147  string FiberListS ;    // String_liste des numeros de fibres a utiliser 1,3,4 par exemple
     148  vector<int> fiberNum_;  // liste des numeros fibres a utiliser {1,3,4} par exemple
    136149
    137150  string OutPathName;  // directory de base
     
    170183  // Cote Send DMA -> Ethernet
    171184  bool pci2eth_fgdirect;   // true -> direct transfer DMA to Ethernet 
    172   vector< string > eths_targets;   // Liste des machines cibles pour les transferts DMA -> ethernet
     185  vector< vector<string> > eths_targets;   // Liste des machines cibles pour les transferts DMA -> ethernet pour chaque fibre
     186  vector<string> eths_stargs;    // cibles communes pour toutes les fibres
     187  map< int, vector<string> > eths_fibtargs;  // Cibles specifiees pour les differentes fibres ds les datacards
    173188  // Cote reception
    174   int ethr_nlink;    // Nombre total de source d'envoi (= nb total de fibre de fibre)
     189  int ethr_nlink;    // Nombre total de source d'envoi (= nb total de fibres = nb total liens ethernet)
    175190  bool ethr_forcesamefc_;   // true -> on force receptions de paquets avec SAME FrameCounter sur tous les liens
    176191  uint_4 ethr_sfc_maxdpc_;   // valeur maximum de difference tolere entre compteurs de paquets de differentes fibres
     
    241256  inline bool GetFileDevNull() { return param_->fgnulldev4fits; };
    242257
    243   // Nombre de fibres
     258  // Nombre de fibres pour l'acquisition
    244259  inline int  NFibers() { return param_->NbFibers(); }
    245260  inline int  NbFibers() { return param_->NbFibers(); }
     261  // Numeros des fibres pour l'acquisition
     262  inline int FiberNum(size_t fib) { return param_->FiberNum(fib); }
     263  // Identificateurs des fibres
     264  inline int FiberId(size_t fib) { return config_->FiberId( param_->FiberNum(fib) ); }
    246265
    247266  // Taille des operations DMA (en octets)
     
    273292  inline string OutputDirectory() { return (config_->BaseDirectory()+param_->OutPathName); }
    274293  string OutputDirectoryFib(int fib);
     294  // repertoire temporaire
     295  inline const string& TmpDirectory() const { return config_->TmpDirectory(); }
    275296
    276297 protected:
  • 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 }
  • trunk/AddOn/TAcq/mfacq.h

    r3876 r3913  
    33#include <signal.h>
    44#include <iostream>
     5#include <fstream>
     6
    57#include <stdlib.h>
    68#include <string.h>
     
    4042// Fonctions appelees par le main
    4143void Usage(bool fgshort=true);
    42 int DecodeArgs(string Fibres);
    43 
     44int DecodeArgs(int narg, char* arg[]);
    4445
    4546int PCIEToEthernetTransfer();
  • trunk/AddOn/TAcq/racqueth.cc

    r3911 r3913  
    3232/* --Methode-- */
    3333PCIEToEthernet::PCIEToEthernet(vector<PCIEWrapperInterface*> vec_pciw, vector<string>& destname, BRParList const& par, int portid)
    34   :   par_(par), vec_pciw_ (vec_pciw), destname_(destname), tcpportid_(portid)
     34  :   par_(par), vec_pciw_ (vec_pciw), tcpportid_(portid)
     35{
     36  if (vec_pciw_.size() > MAXNBFIB)
     37    throw ParmError("PCIEToEthernet:ERROR/  vec_pciw.size() > MAXNBFIB ");
     38  for(size_t i=0; i<vec_pciw_.size(); i++) destname_.push_back(destname);
     39  InitConnections();
     40}
     41
     42/* --Methode-- */
     43PCIEToEthernet::PCIEToEthernet(vector<PCIEWrapperInterface*> vec_pciw, vector< vector<string> >& destname, BRParList const& par, int portid)
     44  :   par_(par), vec_pciw_ (vec_pciw), tcpportid_(portid)
     45{
     46  if (vec_pciw_.size() > MAXNBFIB)
     47    throw ParmError("PCIEToEthernet:ERROR/  vec_pciw.size() > MAXNBFIB ");
     48  if (destname.size()!=vec_pciw.size())
     49    throw ParmError("PCIEToEthernet:ERROR/  vec_pciw.size() != destname_.size() ");
     50  destname_= destname;
     51  InitConnections();
     52}
     53
     54/* --Methode-- */
     55void PCIEToEthernet::InitConnections()
    3556{
    3657  nmaxpaq_ = par_.MaxNbPaquets();       
     
    4061  packSizeInMgr_=par_.MMgrPaquetSize();
    4162  sizeFr_=par_.DMASizeBytes();
    42   if (vec_pciw.size() > MAXNBFIB)
    43     throw ParmError("PCIEToEthernet:ERROR/  vec_pciw.size() > MAXNBFIB ");
    44   nbDma_= vec_pciw.size();
     63 
     64  nbDma_= vec_pciw_.size();
    4565
    4666 //  true -> direct transfer of data to ethernet
     
    5171    vector<ClientSocket> vskt;
    5272    vector<uint_8> verrcnt;
    53     for(size_t j=0; j<destname_.size(); j++) {
    54       ClientSocket sok(destname_[j], tcpportid_);
     73    vector<string>& sdestnm=destname_[i];
     74    for(size_t j=0; j<sdestnm.size(); j++) {
     75      ClientSocket sok(sdestnm[j], tcpportid_);
    5576      for(int ii=0; ii<BRTCPMSGLEN; ii++) msg[ii]='\0';
    5677      uint_4 dmasz = (fgdirectsend_)  ? vec_pciw_[0]->TransferSize() : 0;
     
    6687        throw SocketException("PCIEToEthernet:ERROR/  Connection to EthernetReader not established ");
    6788      }
    68       cout << " PCIEToEthernet: Ethernet connection established for DMA/fiber" << i << " with " << destname_[j] << endl;
     89      cout << " PCIEToEthernet: Ethernet connection established for DMA/fiber" << i << " with " << sdestnm[j] << endl;
    6990      vskt.push_back(sok);
    7091      verrcnt.push_back(0);
     
    7899  totrdsnd_ = 0;
    79100  stopreason_="??Unknown??";
    80   SetPrintLevel(par.prtlevel_,par.prtmodulo_);
     101  SetPrintLevel(par_.prtlevel_,par_.prtmodulo_);
    81102}
    82103
     
    87108    vector<ClientSocket>& vskt = vvec_skt_[i];
    88109    vector<uint_8>& verrcnt = vvec_errorcnt_[i];
    89     for(size_t j=0; j<destname_.size(); j++) {
     110    for(size_t j=0; j<vskt.size(); j++) {
    90111      cout << " ~PCIEToEthernet() closing socket, fiber/pcieNum=" << i << " ethernet_destNum=" << j
    91112           << " ErrorCount=" << verrcnt[j] << endl;
     
    162183        throw SocketException("PCIEToEthernet:ERROR/  BAD Go message from EthernetReader ");
    163184      }
    164     cout << " PCIEToEthernet::run() Received GO message for Fiber/DMA " << i << " from " << destname_[j] << endl;
     185    cout << " PCIEToEthernet::run() Received GO message for Fiber/DMA " << i << " from " << destname_[i][j] << endl;
    165186    }
    166187  }
     
    175196    vec_pciw_[i]->SetMaxWaitEndDMA(par_.first_maxkwedma_,par_.first_nretrydma_);
    176197
     198  bool fg_change_timeout=true;
    177199  while (npaqfaitg < nmaxpaq_) {  // Boucle global G
    178200    if (fgarret) break;
     
    184206    // Lancement des DMA
    185207    for (int dma=0; dma < (int)nbDma_ ;dma++) vec_pciw_[dma]->StartTransfers();
    186     if (npaqfaitg==1)  {
     208    if ((npaqfaitg>1)&&fg_change_timeout)  {
    187209      for (int i=0;i< (int)nbDma_ ;i++)
    188210        vec_pciw_[i]->SetMaxWaitEndDMA(par_.maxkwedma_,par_.nretrydma_);
     211      fg_change_timeout=false;
    189212    }
    190213   
  • trunk/AddOn/TAcq/racqueth.h

    r3911 r3913  
    5151class PCIEToEthernet : public ZThread {
    5252public:
    53   PCIEToEthernet(vector<PCIEWrapperInterface*> vec_pciw , vector<string>& destname, BRParList const& par, int portid=BRSPORTID);
     53  // Specification de destinations : nom_de_machine ou numero IP (192.168.55.2 ...)
     54  //  Meme series de destination pour toutes les fibres (DMA)
     55  PCIEToEthernet(vector<PCIEWrapperInterface*> vec_pciw, vector<string>& destname, BRParList const& par, int portid=BRSPORTID);
     56  //  Une serie  de destinations pour chaque fibres
     57  PCIEToEthernet(vector<PCIEWrapperInterface*> vec_pciw, vector< vector<string> >& destname, BRParList const& par, int portid=BRSPORTID);
    5458  virtual ~PCIEToEthernet();
    5559  virtual void run();
     
    6165
    6266protected:
     67  virtual void InitConnections();
    6368  virtual size_t SendToTargets(int fib, Byte* data, size_t len, bool fgfin=false);
    6469  virtual void CleanUpEndSendAllLinks();
     
    7176  unsigned int sizeFr_ ;
    7277  vector<PCIEWrapperInterface *> vec_pciw_;
    73   vector<string> destname_;
     78  vector< vector<string> > destname_;
    7479  int tcpportid_;
    7580  vector< vector<ClientSocket> > vvec_skt_;
  • trunk/AddOn/TAcq/racqumem.cc

    r3909 r3913  
    263263}
    264264
     265/* --Methode-- */
    265266ostream& RAcqMemZoneMgr::Print(ostream& os)
    266267{
     
    280281}
    281282
     283/* --Methode-- */
    282284void RAcqMemZoneMgr::Stop()
    283285{
     
    287289  mex.broadcast();
    288290}
     291
     292/* --Methode-- */
     293MemZaction RAcqMemZoneMgr::Convert_Status2Action(MemZStatus st)
     294// methode statique
     295{
     296  MemZaction ra=MemZA_None;
     297  switch (st) {
     298  case MemZS_Filled:
     299    ra=MemZA_Fill;
     300    break;
     301  case MemZS_Saved:
     302    ra=MemZA_Save;
     303    break;
     304  case MemZS_Proc:
     305    ra=MemZA_Proc;
     306    break;
     307  case MemZS_ProcA:
     308    ra=MemZA_ProcA;
     309    break;
     310  case MemZS_ProcB:
     311    ra=MemZA_ProcB;
     312    break;
     313  case MemZS_ProcC:
     314    ra=MemZA_ProcC;
     315    break;
     316  case MemZS_ProcD:
     317    ra=MemZA_ProcD;
     318    break;
     319  case MemZS_ProcE:
     320    ra=MemZA_ProcE;
     321    break;
     322  case MemZS_ProcF:
     323    ra=MemZA_ProcF;
     324    break;
     325  default:
     326    ra=MemZA_None;
     327    break;
     328  }
     329  return ra;
     330}
  • trunk/AddOn/TAcq/racqumem.h

    r3909 r3913  
    169169    { runstate_ = st; return runstate_; }
    170170
     171  // Conversion Status -> action
     172  static MemZaction Convert_Status2Action(MemZStatus st);
     173
    171174protected:
    172175  void Init();  // Fait l'allocation des differents buffers - est appele par les constructeurs
  • trunk/AddOn/TAcq/racqurw.cc

    r3911 r3913  
    546546  for (int i=0;i< (int)nbDma_ ;i++) npaqfait[i]=0;
    547547    // Byte* nextdma = locdata+((kmz%memgr.NbZones())*(paqsz*memgr.NbPaquets()));
    548   uint_4 npaqfaitg = 0;     
     548  uint_4 npaqfaitg = 0;
     549  bool fg_change_timeout=true;     
    549550  //      for (uint_4 i=0; i<memgr.NbPaquets(); i += pktInDMATr) {  // attention pktInDMATr paquets dans 1 seul DMA
    550551  while (npaqfaitg < nmax_*memgr.NbPaquets()) {  // Boucle global G
     
    554555    // Lancement des DMA
    555556    for (int dma=0; dma < (int)nbDma_ ;dma++) vec_pciw_[dma]->StartTransfers();
    556     if (npaqfaitg==1)  {
     557    if ((npaqfaitg>1)&&fg_change_timeout)  {
    557558      for (int i=0;i< (int)nbDma_ ;i++)
    558559        vec_pciw_[i]->SetMaxWaitEndDMA(par_.maxkwedma_,par_.nretrydma_);
     560      fg_change_timeout=false;
    559561    }
    560562    // On pointe vers le debut de la zone a remplir aver le prochain DMA
     
    938940    mff[fib].AddKeyS("BRPAQCFMT", BRPaquet::FmtConvToString(acpar.GetParams().GetDataConvFg()),
    939941                         " BAORadio BRPaquet DataFormatConversion" );
    940     mff[fib].AddKeyI("FIBERNUM", acpar.GetParams().FiberNum[fib], " Fiber number") ;
     942    mff[fib].AddKeyI("FIBERNUM", acpar.FiberNum(fib), " Fiber number") ;
    941943    mff[fib].AddKeyI("FIBERID",memgr.FiberId(fib), " Fiber identifier (absolute id)");
    942944    if (hassrc)
Note: See TracChangeset for help on using the changeset viewer.