Changeset 3681 in Sophya for trunk/AddOn/TAcq


Ignore:
Timestamp:
Nov 20, 2009, 12:46:54 PM (16 years ago)
Author:
ansari
Message:

Ajout classe de traitement en ligne (monitoring) MonitorProc , Reza 20/11/2009

Location:
trunk/AddOn/TAcq
Files:
7 edited

Legend:

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

    r3674 r3681  
    3434@memmgr  4,128
    3535#  Parametres traitement au vol optionnnel (monitoring)
    36 #  @monitor  NMaxBlocProc
    37 #  Par defaut  @monitor 0
    38 @monitor 0
     36#  @monitor  NMean  Step  NMaxBlocProc
     37#  Par defaut NoMonitoring   @monitor 512 10 0
     38@monitor 0  384 4
    3939#  Reduction des tailles de paquets si cle present
    4040#  @reducpaqsz ReducedSize Offset
    4141reducpaqsz 1024 0
     42#  Pour desactiver l'ecriture des fichiers FITS
     43#  @nosavesigfits
     44nosavesigfits
     45#  Taux de perte de paquets en simulation (Sans carte PCIExpress)
     46#  @nopcilossrate Perte     (0<=Perte<1)
     47#  Defaut @nopcilossrate 0.
  • trunk/AddOn/TAcq/brparam.cc

    r3674 r3681  
    9494
    9595/* --Methode-- */
    96 BRParList::BRParList(string fibres,unsigned int paqsz ,unsigned int dmaszkb,
    97                      int nfiles, string acqmod,int nblocfile,int nmxproc ,
    98                      string outpath, uint_4 nzon , uint_4 npaqzon, bool fgcntlc)
    99 {
     96BRParList::BRParList(string acqmod, string fibres,unsigned int paqsz,
     97                     unsigned int dmaszkb, int nfiles, int nblocfile,
     98                     string outpath, uint_4 nzon , uint_4 npaqzon)
     99{
     100  AcqMode=acqmod;
     101  fgdatafft=false;
     102  fgsinglechannel=false;
     103
    100104  FiberListS=fibres;
    101105  NbFibers=0;
     
    103107  PaqSize=paqsz;
    104108  dmasizekb=dmaszkb;
     109
    105110  NbFiles=nfiles;
    106   AcqMode=acqmod;
    107111  NBlocPerFile=nblocfile;
    108   NMaxProc=nmxproc;
    109112  OutPathName=outpath;
     113
    110114  nZones=nzon;
    111115  nPaqZone=npaqzon;
     116
    112117  swapall=BR_Copy;
    113118  savesigfits=true;
    114119  fgnulldev4fits=false;
    115120
    116   fg_hard_ctrlc=fgcntlc;
     121  fg_hard_ctrlc=false;
    117122
    118123  fgreducpsize=false;
     
    123128
    124129  skysource="";
     130
     131  fgdoProc=false;
     132  nmeanProc=512;
     133  stepProc=5;
     134  nmaxProc=0;
     135
    125136  monothr=false;
    126137  activate_pattern=false;
     138  nopciLossRate=0.;
    127139
    128140  Decode();    // On decode et on complete les parametres
     
    138150void BRParList::Set(BRParList const & p)
    139151{
     152  AcqMode=p.AcqMode;
     153  fgdatafft=p.fgdatafft;
     154  fgsinglechannel=p.fgsinglechannel;
     155
    140156  FiberListS=p.FiberListS;
    141157  NbFibers=p.NbFibers;
    142158  for (int fib=0; fib<PMAXNBFIBRES;fib++)  FiberNum[fib]=p.FiberNum[fib];
     159
    143160  PaqSize=p.PaqSize;
    144161  dmasizekb=p.dmasizekb;
     162
    145163  NbFiles=p.NbFiles;
    146   AcqMode=p.AcqMode;
    147164  NBlocPerFile=p.NBlocPerFile;
    148   NMaxProc=p.NMaxProc;
    149165  OutPathName=p.OutPathName;
     166
    150167  nZones=p.nZones;
    151168  nPaqZone=p.nPaqZone;
     169
    152170  swapall=p.swapall;
    153171  savesigfits=p.savesigfits;
     
    163181
    164182  skysource=p.skysource;
     183 
     184  fgdoProc=p.fgdoProc;
     185  nmeanProc=p.nmeanProc;
     186  stepProc=p.stepProc;
     187  nmaxProc=p.nmaxProc;
    165188
    166189  monothr=p.monothr;
    167190  activate_pattern=p.activate_pattern;
     191
     192  nopciLossRate=p.nopciLossRate;
    168193  return;
    169194}
     
    188213    reducoffset=(uint_4)conf.IParam("reducpaqsz",1,0);
    189214  }
    190   NMaxProc=conf.IParam("monitor",0,0);
     215  if (conf.HasKey("monitor")) {
     216    fgdoProc=true;
     217    nmeanProc=conf.IParam("monitor",0,512);
     218    stepProc=conf.IParam("monitor",1,10);
     219    nmaxProc=conf.IParam("monitor",2,0);
     220  }
     221  nopciLossRate=conf.DParam("nopcilossrate",0,0.);
     222
    191223  fg_hard_ctrlc=conf.HasKey("hard_ctrlc");
    192 
     224  if (conf.HasKey("nosavesigfits"))  savesigfits=false;
    193225  Decode();
    194226}
     
    212244  }
    213245  string acqmode = AcqMode;
     246  fgdatafft=false;  fgsinglechannel=false;
    214247  reducneedcopy=false;  pqreducmode=BR_TwoChanReduc;
    215   if (acqmode == "std")   swapall = BR_Copy ; 
     248  if ((acqmode == "std")||(acqmode=="raw2c"))   swapall = BR_Copy ; 
    216249  if (acqmode == "nosw")   swapall = BR_Copy ;
    217250  if (acqmode == "nof")  { swapall = BR_Copy ; savesigfits = false; }
     
    254287    { swapall = BR_FFTTwoChanSwap32;  savesigfits = false; reducneedcopy=true;  pqreducmode=BR_TwoChanReducK0; }
    255288
     289  if ((swapall==BR_FFTTwoChan)||(swapall==BR_FFTTwoChanSwapAll)||(swapall==BR_FFTTwoChanSwap32)) {
     290    fgdatafft=true; 
     291  }
     292  if ((swapall==BR_FFTOneChan)||(swapall==BR_FFTOneChanSwapAll)||(swapall==BR_FFTOneChanSwap32)) {
     293    fgdatafft=true;  fgsinglechannel=true;
     294  }
     295 
    256296  if (fgreducpsize) {
    257297    if (redpqsize>=PaqSize) fgreducpsize=false;
     
    280320    os << " PaquetSize Reduction, ReducedSize=" << redpqsize << " Offset=" << reducoffset << endl;
    281321  }
     322  if (fgdoProc>0)
     323    os << " Monitoring  NMeanProc=" << nmeanProc << " StepProc=" << stepProc << " NMaxProc=" << nmaxProc << endl;
     324  else os << " No monotoring thread " << endl;
    282325  os << " fg_hard_ctrlc=" << ((fg_hard_ctrlc)?"true":"false");
    283326  os << " Save to fits " << ((savesigfits)?"true":"false") << endl;
  • trunk/AddOn/TAcq/brparam.h

    r3680 r3681  
    7777class BRParList {
    7878public:
    79   BRParList (string fibres="1", unsigned int szframe= 16424, unsigned int dmaszkb = 32,
    80              int nfiles=1, string acqmode="fft2c", int nblocfile=10, 
    81              int nmaxpr = 0, string outpath="TstAcq",
    82              uint_4 nzon = 4, uint_4 npaqzon = 128, bool fgcntlc=false);
     79  BRParList (string acqmode="fft2c", string fibres="1", unsigned int paqsz= 16424,
     80             unsigned int dmaszkb = 32, int nfiles=1, int nblocfile=10, string outpath="TstAcq",
     81             uint_4 nzon = 4, uint_4 npaqzon = 128);
    8382
    8483  BRParList(BRParList const & p);
     
    118117
    119118  string AcqMode;  // Mode d'acquisition (conditionne la mise en ordre/conversion des donnees lues par DMA
     119  bool fgdatafft;  // true -> donnee FFT (provenant du firmware FFT)
     120  bool fgsinglechannel; // true -> un seul canal par fibre (par defaut=2 canaux/fibres)
     121
    120122  string FiberListS ;  // liste des fibres a utiliser 1,3,4 par exemple
    121123  int NbFibers;  // liste des fibres a utiliser 1,3,4 par exemple
     
    128130  int NbFiles; // nombre de fichier produits
    129131  int NBlocPerFile; // nombre de bloc par fichier
    130   int NMaxProc;  // Nombre de blocs traites par le thread de calcul
    131132  // Gestionnaire zones memoire
    132133  uint_4 nZones;  // Nombre de zones memoires
     
    149150  // Identification source observee dans le ciel
    150151  string skysource;
     152
     153  //  Variables pour le traitement/monitoring
     154  bool fgdoProc;    // false -> pas de thread de monitoring
     155  uint_4 nmeanProc;  // nombre de paquets moyennes par le thread de traitement/monitoring
     156  uint_4 stepProc;  // 1/stepProc zones traite - si =0 -> fraction de paquets traites depend de la puissance disponible
     157  uint_4 nmaxProc;  // Nombre de blocs traites par le thread de traitement/monitoring (0-> MaxNbBlocs())
     158 
    151159  // Pour des tests de performances ou sans carte ADC (pattern)
    152160  bool monothr ;           // pour les test mono thread
  • trunk/AddOn/TAcq/mfacq.cc

    r3680 r3681  
    124124  RAcqMemZoneMgr mmgr(acpar.nZones, bpar.NFibers(), acpar.nPaqZone, acpar.MMgrPaquetSize());
    125125  pMmgr=&mmgr; 
    126   int stepproc = 2; 
    127   int nmean = acpar.nPaqZone*acpar.NBlocPerFile/stepproc;
    128 
     126  if (acpar.fgdoProc && (acpar.stepProc>0)) {
     127    // Dans ce cas, toutes les zones doivent passer ds le thread de monitoring
     128    // pour etre au moins marque comme traite - seul 1/acpar.stepProc sont effectivement traite
     129    mmgr.SetFinalizedMask(((uint_4)MemZS_Saved) | ((uint_4)MemZS_Proc));
     130    cout << " mfacq[1.b]/Info: Mmgr.SetFinalizedMask( MemZS_Saved | MemZS_Proc )" << endl;
     131  }
     132 
    129133#ifndef NOPCIECARD 
    130 
    131134  for (int i=0 ;i <acpar.NFibers() ;i++) {
    132135    UINT32 card=(acpar.FiberNum[i]-1)/2+1;
     
    147150#endif
    148151
    149   cout <<"mfacq[3] Creating DataSaver and DataProc2C objects ... " << endl;
     152  cout <<"mfacq[2] Creating MultiDataSaver and  MonitorProc thread objects ... " << endl;
    150153  MultiDataSaver DsThr(mmgr);   //   Utilise les parametres globaux BRAcqConfig
    151154  string ppath=bpar.OutputDirectory();
    152   DataProc2C PrThr(mmgr, ppath, 1280, stepproc, acpar.NMaxProc);
     155  MonitorProc PrThr(mmgr);
    153156  vector<PCIEWrapperInterface*> vec_pciw;
    154157  for  (int i=0 ;i<bpar.NFibers();i++)  vec_pciw.push_back( pciwp[i]);
    155   cout << "mfacq[3] Creating   PCIEMultiReader       " << endl;
     158  cout << "mfacq[3] Creating   PCIEMultiReader thread object     " << endl;
    156159  PCIEMultiReader PcierThr(vec_pciw, mmgr, bpar.GetParams());
    157   usleep(200);  // attente au cas ou ...
     160  //  usleep(200); attente au cas ou ...
    158161  pPcierThr=&PcierThr;
    159162  tm.Split("Threads created"); 
    160   cout << "mfacq[4] - starting 3 threads pcir, ds, pr ... " << endl;
     163  if (acpar.fgdoProc>0)
     164    cout << "mfacq[4] - starting three threads: PCIEMultiReader, MultiDataSaver, MonitorProc ... " << endl;
     165  else
     166    cout << "mfacq[4] - starting two threads: PCIEMultiReader, MultiDataSaver  ... " << endl;
     167
    161168  PcierThr.start();
    162169  DsThr.start();
    163   if (acpar.NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0
     170  if (acpar.fgdoProc>0) { // On ne demarre que si au moins NMaxProc>0
    164171    PrThr.start();
    165172  }
    166173 
    167174  // On attend avant de declencher la terminaison des threads
    168   usleep(100000);
     175  usleep(200000);
    169176 
    170177  cout << "mfacq[5] -  Waiting for threads to finish ... " << endl; 
     
    172179  DsThr.join();
    173180  mmgr.Stop();
    174   if (acpar.NMaxProc>0) { // On ne demarre que si au moins NMaxProc>0
     181  if (acpar.fgdoProc) { // On n'attend la fin que si le thread a ete demarre (NMaxProc>0)
    175182    PrThr.join();
    176183  }
     
    179186  tm.Split("Threads Finished"); 
    180187 
     188  mmgr.Print(cout);
    181189#ifndef NOPCIECARD
    182190  for (int i=0 ;i <acpar.NbFibers ;i++) {
  • trunk/AddOn/TAcq/racquproc.cc

    r3671 r3681  
    11#include "racquproc.h"
     2
     3/* ----------------------------------------
     4     Projet BAORadio --- LAL
     5     2008 - 2010
     6-------------------------------------------  */
    27
    38#include <stdlib.h>
     
    1924#include "brpaqu.h"
    2025#include "minifits.h"
    21 struct sigaction act;
    22 
     26
     27/* Fonction, module^2 des nombres complexes */
     28static inline r_4 Zmod2(complex<r_4> z)
     29{ return (z.real()*z.real()+z.imag()*z.imag()); }
     30static inline r_8 Zmod2(complex<r_8> z)
     31{ return (z.real()*z.real()+z.imag()*z.imag()); }
     32static inline r_4 Zmod2(TwoByteComplex z)
     33{ return ((r_4)z.realB()*(r_4)z.realB()+(r_4)z.imagB()*(r_4)z.imagB()); }
     34
     35//---------------------------------------------------------------------
     36// Classe thread de traitement/monitoring multifibre Raw/FFT
     37//---------------------------------------------------------------------
     38/* --Methode-- */
     39MonitorProc::MonitorProc(RAcqMemZoneMgr& mem)
     40  :  memgr(mem)
     41{
     42  BRAcqConfig bpar;
     43  par_.Set(bpar.GetParams());
     44  nmax_ = par_.nmaxProc;
     45  if (nmax_==0) nmax_=par_.MaxNbBlocs();
     46  nmean_ = par_.nmeanProc;
     47  step_ = par_.stepProc;
     48  stop_ = false;       
     49  path_ = bpar.OutputDirectory();
     50  nfiles_ = 0;
     51  nblocproc_ = 0;
     52  nprocpaq_=0;
     53  npaqsamefc_=0;
     54  totnprocpaq_=0;
     55  totnpaqsamefc_=0;
     56  curfc_.SetSize(memgr.NbFibres(), memgr.NbPaquets());
     57  cpaqok_.SetSize(memgr.NbFibres(), memgr.NbPaquets());
     58}
     59
     60/* --Methode-- */
     61MonitorProc::~MonitorProc()
     62{
     63  //  cout << " **** DBG ***** MonitorProc::~MonitorProc() " << endl;
     64}
     65
     66/* --Methode-- */
     67void MonitorProc::Stop()
     68{
     69 stop_=true;
     70}
     71
     72/* --Methode-- */
     73void MonitorProc::run()
     74{
     75  setRC(1);     
     76  int rc=0;
     77  try {
     78    TimeStamp ts;
     79    cout << " MonitorProc::run() - Starting " << ts << " NMaxMemZones=" << nmax_
     80         << " NMean=" << nmean_ << " Step=" << step_ << endl;   
     81    cout << " MonitorProc::run()... - Output Data Path: " << path_ << endl;
     82    char fname[512];
     83    sprintf(fname,"%s/monproc.log",path_.c_str());
     84    ofstream filog(fname);
     85    filog << " MonitorProc::run() - starting log file " << ts << endl;                 
     86    filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl;
     87    uint_4 paqsz = memgr.PaqSize();
     88    BRPaquet pq(paqsz);
     89    if (par_.fgsinglechannel) {
     90      spectre_.SetSize(memgr.NbFibres(), pq.DataSize()/2);
     91      for(int kc=0; kc<memgr.NbFibres(); kc++)  nzm_.push_back(0);
     92      rc=procData1C(filog);
     93    }
     94    else {
     95      spectre_.SetSize(2*memgr.NbFibres(), pq.DataSize()/4);
     96      for(int kc=0; kc<2*memgr.NbFibres(); kc++)  nzm_.push_back(0);
     97      rc=procData2C(filog);
     98    }
     99    cout << " ---- MonitorProc::run()/End NBlocProcessed=" << nblocproc_
     100          << " NFiles=" << nfiles_ << " Rc=" << rc << endl;
     101    ts.SetNow();
     102    filog << " ---- MonitorProc::run()/End " << ts << endl;
     103    filog << " --------- MonitorProc::run()/End NBlocProcessed=" << nblocproc_
     104          << " NFiles=" << nfiles_ << " Rc=" << rc << endl;
     105  }
     106  catch (std::exception& exc) {
     107    cout << " MonitorProc::run()/catched std::exception " << exc.what() << endl;
     108    setRC(98); 
     109    return;
     110  }
     111  catch(...) {
     112    cout << " MonitorProc::run()/catched unknown ... exception " << endl;
     113    setRC(99); 
     114    return;
     115  }
     116
     117  setRC(rc);
     118  return;
     119}   
     120
     121/* --Methode-- */
     122int MonitorProc::procData1C(ofstream& logf)
     123{
     124  cout << " MonitorProc::procData1C() - NOT IMPLEMENTED -> Rc=67" << endl;
     125  logf << " MonitorProc::procData1C() - NOT IMPLEMENTED -> Rc=67" << endl;
     126  return 67; 
     127}
     128
     129/* --Methode-- */
     130int MonitorProc::procData2C(ofstream& filog)
     131{
     132  BRPaqChecker pcheck[MAXNBFIB];  // Verification/comptage des paquets
     133// Initialisation pour calcul FFT
     134  uint_4 paqsz = memgr.PaqSize();
     135  BRPaquet pq(paqsz);
     136  TVector<r_4> vx(pq.DataSize()/2);
     137  vx = (r_4)(0.);
     138  TVector< complex<r_4> > cfour(pq.DataSize()/4+1);  // composant TF
     139 
     140  fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(),
     141                                          (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE);
     142  TimeStamp ts;   
     143  char fname[512];
     144  nfiles_ = 0;                                 
     145  for (uint_4 kmz=0; kmz<nmax_; kmz++) {
     146    if (stop_) break;
     147    if (memgr.GetRunState() == MemZR_Stopped) break;
     148
     149    int mid = memgr.FindMemZoneId(MemZA_Proc);
     150    Byte* buffg = memgr.GetMemZone(mid);
     151    if (buffg == NULL) {
     152      cout << " MonitorProc::procData2C()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
     153      break;   
     154    }
     155    if ((step_>1)&&(kmz%step_ != 0))  {
     156      memgr.FreeMemZone(mid, MemZS_Proc);
     157      continue;
     158    }
     159    sa_size_t lc=0;
     160    Byte* fbuff[MAXNBFIB];
     161    for(uint_4 fib=0; fib<memgr.NbFibres(); fib++)  {  // Boucle sur les fibres
     162      fbuff[fib] = memgr.GetMemZone(mid,fib);
     163      if (fbuff[fib] == NULL) { // cela ne devrait pas arriver
     164        cout << " MonitorProc::procData2C()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl;
     165        return 9;       
     166      }
     167    }
     168   
     169    cpaqok_ = (uint_1)0;
     170    curfc_ = (uint_8)0;
     171    for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) {
     172      for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
     173        BRPaquet paq(fbuff[fib]+i*paqsz, paqsz);
     174        bool pqok=pcheck[fib].Check(paq,curfc_(fib,i));   // Verification du paquet / FrameCounter
     175        if (!pqok)  continue;
     176        cpaqok_(fib,i) = 1;
     177        sa_size_t lc=2*fib;
     178        if (par_.fgdatafft) {    // Traitement data de type FFT
     179          TwoByteComplex* tbcp=paq.Data1C();
     180          for(sa_size_t j=1; j<spectre_.NCols(); j++)
     181            spectre_(lc,j) += Zmod2(tbcp[j]);
     182          nzm_[lc]++;   
     183          tbcp=paq.Data2C();
     184          for(sa_size_t j=1; j<spectre_.NCols(); j++)
     185            spectre_(lc,j) += Zmod2(tbcp[j]);
     186          nzm_[lc+1]++;
     187        }
     188        else {   // Traitement RawData
     189          for(sa_size_t j=0; j<vx.Size(); j++)
     190            vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
     191          fftwf_execute(plan);
     192          //   ffts_.FFTForward(vx, cfour_);
     193          for(sa_size_t j=0; j<spectre_.NCols(); j++)
     194            spectre_(lc,j) += Zmod2(cfour(j+1));
     195          nzm_[lc]++;
     196          for(sa_size_t j=0; j<vx.Size(); j++)
     197            vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
     198          fftwf_execute(plan);
     199          //    ffts_.FFTForward(vx, cfour_);
     200          for(sa_size_t j=0; j<spectre_.NCols(); j++)
     201            spectre_(lc,j) += Zmod2(cfour(j+1));
     202          nzm_[lc+1]++;
     203        }       
     204      }  // FIN de la boucle sur les paquets
     205    }   // Boucle sur les fibres
     206    memgr.FreeMemZone(mid, MemZS_Proc);
     207    CheckFrameCounters();
     208
     209    nblocproc_ ++;   
     210    totnprocpaq_ += memgr.NbPaquets();  nprocpaq_ += memgr.NbPaquets();
     211    bool fgnzm=true;
     212    for(int lc=0; lc<2*memgr.NbFibres(); lc++) 
     213      if (nzm_[lc]<nmean_) fgnzm=false;
     214   
     215    if (fgnzm) {
     216      char buff[32];
     217      for(sa_size_t lc=0; lc<2*memgr.NbFibres(); lc++)  {
     218        spectre_.Row(lc) /= (r_4)nzm_[lc];
     219        sprintf(buff,"NPaqMoy%d",(int)lc);
     220        spectre_.Info()[buff] = nzm_[lc];
     221      }
     222      sprintf(fname,"%s/meanspec%d.ppf",path_.c_str(),(int)nfiles_);
     223      nfiles_++;
     224      POutPersist po(fname);
     225      po << PPFNameTag("spectre") << spectre_;       
     226      spectre_ = (r_4)(0.);
     227      for(int lc=0; lc<2*memgr.NbFibres(); lc++)  nzm_[lc]=0;
     228      ts.SetNow();
     229      // Calcul / impression fraction des paquets avec same-framecounter
     230      int fracsame=0;
     231      if (nprocpaq_>0)  fracsame=100*npaqsamefc_/nprocpaq_;
     232      int totfracsame=0;
     233      if (totnprocpaq_>0)  totfracsame=100*totnpaqsamefc_/totnprocpaq_;
     234      filog << ts << " :  proc file (meanspectra) " << fname << endl;
     235      filog << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
     236            << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_
     237            << " -> " << fracsame << " % )" << endl;
     238      cout << " MonitorProc::procData2C() " << ts << " : created file  " << fname << endl;
     239      cout << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
     240           << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_
     241           << " -> " << fracsame << " % )" << endl;
     242      nprocpaq_=npaqsamefc_=0;
     243    }
     244  }   // Fin de boucle sur les kmz ( bloc MemZoneMgr  a traiter )
     245
     246  bool fgnzm=false;
     247  for(int lc=0; lc<2*memgr.NbFibres(); lc++) 
     248    if (nzm_[lc]>0) fgnzm=true;
     249 
     250  if (fgnzm) {
     251    char buff[32];
     252    for(sa_size_t lc=0; lc<2*memgr.NbFibres(); lc++)  {
     253      if (nzm_[lc]>0)  spectre_.Row(lc) /= (r_4)nzm_[lc];
     254      sprintf(buff,"NPaqMoy%d",(int)lc);
     255      spectre_.Info()[buff] = nzm_[lc];
     256    }
     257    sprintf(fname,"%s/meanspec%d.ppf",path_.c_str(),(int)nfiles_);
     258    POutPersist po(fname);
     259    po << PPFNameTag("spectre") << spectre_;       
     260    spectre_ = (r_4)(0.);
     261    for(int lc=0; lc<2*memgr.NbFibres(); lc++)  nzm_[lc]=0;
     262    ts.SetNow();
     263    // Calcul / impression fraction des paquets avec same-framecounter
     264    int fracsame=0;
     265    if (nprocpaq_>0)  fracsame=100*npaqsamefc_/nprocpaq_;
     266    int totfracsame=0;
     267    if (totnprocpaq_>0)  totfracsame=100*totnpaqsamefc_/totnprocpaq_;
     268    filog << ts << " :  proc file (meanspectra) " << fname << endl;                   
     269    filog << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
     270          << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_
     271          << " -> " << fracsame << " % )" << endl;
     272    cout << " MonitorProc::procData2C() " << ts << " : created file  " << fname << endl;
     273    cout << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
     274         << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_
     275         << " -> " << fracsame << " % )" << endl;
     276  }
     277  return 0;
     278}
     279
     280/* --Methode-- */
     281int MonitorProc::CheckFrameCounters()
     282{
     283  if (memgr.NbFibres()<2)  {
     284    npaqsamefc_++;  totnpaqsamefc_++;
     285    return 99;
     286  }
     287  sa_size_t  pidx[MAXNBFIB];
     288  sa_size_t maxidx=curfc_.NCols();
     289  uint_8 cfc=0;
     290  for(uint_4 fib=0; fib<curfc_.NRows(); fib++) {
     291    pidx[fib]=0;
     292    while((pidx[fib]<maxidx)&&(cpaqok_(fib,pidx[fib])==0)) pidx[fib]++;
     293  }
     294
     295  bool fgsuite=true;
     296  while (fgsuite) {   // Boucle sur l'ensemble des paquets
     297    for(uint_4 fib=0; fib<curfc_.NRows(); fib++)  {
     298      if ((pidx[fib]>=maxidx)||(cpaqok_(fib,pidx[fib])==0))  { fgsuite=false; break; }
     299    }
     300    if (!fgsuite) break;
     301    cfc=curfc_(0,pidx[0]);
     302    bool fgsame=true;
     303    for(uint_4 fib=1; fib<curfc_.NRows(); fib++) {
     304      if (curfc_(fib,pidx[fib])!=cfc) {
     305        fgsame=false;
     306        if (curfc_(fib,pidx[fib]) > cfc)  cfc=curfc_(fib,pidx[fib]);
     307      }
     308    }
     309    if (fgsame) {
     310      npaqsamefc_++;  totnpaqsamefc_++;
     311      for(uint_4 fib=0; fib<curfc_.NRows(); fib++) {
     312        pidx[fib]++;
     313        while((pidx[fib]<maxidx)&&(cpaqok_(fib,pidx[fib])==0)) pidx[fib]++;
     314      }
     315    }   // fin if (fgsame)
     316    else {  // else !fgsame
     317      for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) {
     318        if (curfc_(fib,pidx[fib])<cfc) {
     319          pidx[fib]++;
     320          while((pidx[fib]<maxidx)&&(cpaqok_(fib,pidx[fib])==0)) pidx[fib]++;
     321        }
     322      }
     323    }   // fin de  else !fgsame
     324  }  // Fin de while sur l'ensemble des paquets
     325  return 0;
     326}
     327
     328
     329static struct sigaction act;
    23330//-------------------------------------------------------
    24331// Classe thread de traitement  avec 1 voie par frame
     
    42349}
    43350
    44 static inline r_4 Zmod2(complex<r_4> z)
    45 { return (z.real()*z.real()+z.imag()*z.imag()); }
    46351
    47352void DataProc::Stop()
  • trunk/AddOn/TAcq/racquproc.h

    r3623 r3681  
    44//----------------------------------------------------------------
    55// ---- classe de thread de traitememt  acquisition BAORadio -----
    6 // LAL -      R. Ansari - Juin/Juillet 2008
     6// LAL -      R. Ansari - 2008-2010
     7//  A/ Juin 2008 - Juin 2009
     8//       Classes DataProc, DataProc2C, DataProcFFT2C avec des
     9//       threads de traitement mono-fibre
     10//  B/ Novembre 2009
     11//    MonitorProc : Classe de traitement pour monitoring multifibres
    712//----------------------------------------------------------------
    813
     
    1419#include "sopnamsp.h"
    1520#include "zthread.h"
     21#include "tmatrix.h"
    1622
    1723#include "brtypes.h"
     24#include "brparam.h"
    1825
    1926using namespace std;
    2027
     28// Quelques definitions globales
     29// Nombre maximum de fibres geres par les classes MonitorProc
     30#ifndef MAXNBFIB
     31#define MAXNBFIB  4   
     32#endif
    2133
     34//---------------------------------------------------------------------
     35// Classe thread de traitement/monitoring multifibre Raw/FFT
     36//---------------------------------------------------------------------
     37class MonitorProc : public ZThread {
     38public:
     39  MonitorProc(RAcqMemZoneMgr& mem);
     40  virtual ~MonitorProc();
     41  virtual void run();
     42  void Stop();
     43  inline void STOP() { stop_ = true; } 
     44protected:
     45  int procData2C(ofstream& logf);
     46  int procData1C(ofstream& logf);
     47  int CheckFrameCounters();
     48
     49  RAcqMemZoneMgr& memgr;
     50  BRParList par_;
     51  bool stop_; 
     52  uint_4 nmax_;  // Nombre maxi de blocs MemZone traites
     53  uint_4 step_;  // 1/step_ paquet traite ds chaque bloc
     54  uint_4 nmean_;  // Nombre de blocs pour le calcul des moyennes
     55  string path_;
     56  uint_4 nfiles_;
     57  TMatrix<r_4> spectre_;
     58  vector<uint_4> nzm_;
     59  uint_4 nblocproc_;         // nombre total de bloc MemMgr traites
     60  uint_8 nprocpaq_;          // nombre de paquets traites entre deux mises a zero
     61  uint_8 npaqsamefc_;        // nombre de paquets avec meme framecounter  entre deux mises a zero
     62  uint_8 totnprocpaq_;       // nombre de paquets traites entre deux mises a zero
     63  uint_8 totnpaqsamefc_;     // nombre de paquets avec meme framecounter  entre deux mises a zero
     64  TMatrix<uint_8> curfc_;    // Numeros de FrameCounter dans le bloc
     65  TMatrix<uint_1> cpaqok_;   // Paquets OK ou pas dans le bloc
     66};
     67
     68
     69//-------------------------------------------------------------------
     70//--------  Premieres version - pour tmtacq.cc
     71//-------------------------------------------------------------------
    2272//-------------------------------------------------------------------
    2373// Classe thread de traitement avec 1 voie par frame (donnees brutes)
  • trunk/AddOn/TAcq/racqurw.h

    r3674 r3681  
    2525// Quelques definitions globales
    2626// Nombre maximum de fibres geres par les classes MultiReader / MultiDiskWriter
     27#ifndef MAXNBFIB
    2728#define MAXNBFIB  4   
     29#endif
    2830
    2931//-------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.