Changeset 3645 in Sophya


Ignore:
Timestamp:
Jun 1, 2009, 10:24:41 PM (16 years ago)
Author:
ansari
Message:

Traitement 4 canaux ds brproc.cc, mcrd.cc , mais il reste des problemes - Reza 01/06/2009

Location:
trunk/AddOn/TAcq
Files:
7 edited

Legend:

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

    r3642 r3645  
    2727//---------------------------------------------------------------
    2828
     29/* --Methode-- */
    2930BRProcARaw2C::BRProcARaw2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean,
    30                            uint_4 step, uint_4 nmax, bool fgnotrl)
     31                           uint_4 nmax, bool fgnotrl, int card)
    3132  :  memgr(mem)
    3233{
    3334  nmax_ = nmax;
    3435  nmean_ = nmean;
    35   step_ = step;
    3636  stop_ = false;       
    3737  path_ = path;
    3838  fgnotrl_ = fgnotrl;
    39 }
    40 
     39  card_ = card;
     40}
     41
     42/* --Methode-- */
    4143void BRProcARaw2C::Stop()
    4244{
     
    4951{ return (z.real()*z.real()+z.imag()*z.imag()); }
    5052
     53static inline string card2name_(int card)
     54{
     55  if (card==2) return " (Chan3,4) ";
     56  else return " (Chan1,2) ";
     57}
     58/* --Methode-- */
    5159void BRProcARaw2C::run()
    5260{
     
    6169
    6270    cout << " BRProcARaw2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_
    63          << " NMean=" << nmean_ << " Step=" << step_ << endl;   
     71         << " NMean=" << nmean_ << card2name_(card_) << endl;   
    6472    cout << " BRProcARaw2C::run()... - Output Data Path: " << path_ << endl;
    6573    char fname[512];
     
    106114      }
    107115
    108       for(uint_4 i=0; i<memgr.NbPaquets(); i+=step_) {
     116      for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
    109117            BRPaquet paq(NULL, buff+i*paqsz, paqsz);
    110118        if (!pcheck.Check(paq)) continue;   // on ne traite que les paquets OK
    111119
    112120// Traitement voie 1       
    113             for(sa_size_t j=0; j<vx.Size(); j++)
    114               vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
     121          for(sa_size_t j=0; j<vx.Size(); j++)
     122            vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
    115123//        fftwf_complex* coeff1 = (fftwf_complex*)(procbuff+i*procpaqsz);
    116             fftwf_execute(plan1);
     124          fftwf_execute(plan1);
    117125//        complex<r_4>* zp1 = (complex<r_4>*)(coeff1);
    118126//        ffts.FFTForward(vx, cfour1);
     
    121129        memcpy(procbuff+i*procpaqsz, cfour1.Data(), sizeof(complex<r_4>)*cfour1.Size());
    122130// Traitement voie 2       
    123             for(sa_size_t j=0; j<vx.Size(); j++)
    124               vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
    125 
    126             fftwf_execute(plan2);
     131        for(sa_size_t j=0; j<vx.Size(); j++)
     132          vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
     133
     134        fftwf_execute(plan2);
    127135
    128136        for(sa_size_t j=0; j<spectreV2.Size(); j++)
     
    151159        sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile);
    152160        POutPersist po(fname);
    153         po << PPFNameTag("specV1") << spectreV1;
    154         po << PPFNameTag("specV2") << spectreV2;
    155         po << PPFNameTag("visiV12") << visiV12;
     161        string tag1="specV1";
     162        string tag2="specV2";
     163        string tag12="visiV12";
     164        if (card_==2) {
     165          tag1 = "specV3";
     166          tag2 = "specV4";
     167          tag12="visiV34";
     168        }
     169        po << PPFNameTag(tag1) << spectreV1;
     170        po << PPFNameTag(tag2) << spectreV2;
     171        po << PPFNameTag(tag12) << visiV12;
    156172            }
    157173        spectreV1 = (r_4)(0.);
     
    161177//        ts.SetNow();
    162178//        filog << ts << " :  proc file  " << fname << endl;                   
    163         cout << " BRProcARaw2C::run() created file  " << fname << endl;
     179        cout << " BRProcARaw2C::run() created file  " << fname << card2name_(card_) << endl;
    164180      }   
    165181     
    166182      memgr.FreeMemZone(mid, MemZS_ProcA);
    167183    }  // Fin de boucle sur les zones a traiter
    168   cout << " ------------------  BRProcARaw2C::run() END ----------------- " << endl;
     184  cout << " ------------  BRProcARaw2C::run() END " << card2name_(card_)
     185       << " ------------ " << endl;
    169186  ts.SetNow();
    170187  tm.SplitQ();
     
    173190       << " ProcDataOut=" <<  totnbytesout/(1024*1024) << " MB" << endl;   
    174191  cout << pcheck;
    175   cout << " BRProcARaw2C::run()/Timing: \n";
     192  cout << " BRProcARaw2C::run()/Timing: " << card2name_(card_) << endl;
    176193  tm.Print();
    177194  cout << " ---------------------------------------------------------- " << endl;
     
    192209}   
    193210
    194 
    195 
    196 
     211//---------------------------------------------------------------------
     212// Classe thread de traitement 2 x 2 voies/frames (Apres BRProcARaw2C)
     213//---------------------------------------------------------------------
     214
     215/* --Methode-- */
     216BRProcBRaw4C::BRProcBRaw4C(RAcqMemZoneMgr& mem1, RAcqMemZoneMgr& mem2,
     217                           string& path, uint_4 nmean, uint_4 nmax, bool fgnotrl)
     218  :  memgr1(mem1), memgr2(mem2)
     219{
     220  nmax_ = nmax;
     221  nmean_ = nmean;
     222  stop_ = false;       
     223  path_ = path;
     224  fgnotrl_ = fgnotrl;
     225}
     226
     227/* --Methode-- */
     228void BRProcBRaw4C::Stop()
     229{
     230 stop_=true;
     231 // cout <<" BRProcBRaw4C::Stop ... > STOP " << endl;
     232}
     233
     234
     235/* --Methode-- */
     236void BRProcBRaw4C::run()
     237{
     238  setRC(1);     
     239  try {
     240    Timer tm("BRProcBRaw4C", false);
     241    TimeStamp ts;
     242    BRPaqChecker pcheck1(~fgnotrl_);  // Verification/comptage des paquets
     243    BRPaqChecker pcheck2(~fgnotrl_);  // Verification/comptage des paquets
     244
     245    size_t totnbytesout = 0;
     246    size_t totnbytesproc = 0;
     247
     248    cout << " BRProcBRaw4C::run() - Starting " << ts << " NMaxMemZones=" << nmax_
     249         << " NMean=" << nmean_ << endl;       
     250    cout << " BRProcBRaw4C::run()... - Output Data Path: " << path_ << endl;
     251
     252    uint_4 paqsz = memgr1.PaqSize();
     253    uint_4 procpaqsz = memgr1.ProcPaqSize();
     254    if ((paqsz != memgr2.PaqSize())||(procpaqsz!= memgr2.ProcPaqSize())) {
     255      cout << "BRProcBRaw4C::run()/ERROR : different paquet size -> stop \n ...(PaqSz1="
     256           << paqsz << " Sz2=" << memgr2.PaqSize() << " ProcPaqSz1="
     257           << procpaqsz << " Sz2=" << memgr2.ProcPaqSize() << " )" << endl;
     258      setRC(9);
     259      return;   
     260    }
     261
     262    TVector< complex<r_4> > cfour;  // composant TF
     263    BRPaquet pq(NULL, NULL, paqsz);
     264    TVector<r_4> vx(pq.DataSize()/2);
     265    vx = (r_4)(0.);
     266    FFTPackServer ffts;
     267    ffts.FFTForward(vx, cfour);
     268   
     269    TVector< complex<r_4> > visiV13( cfour.Size() );
     270    TVector< complex<r_4> > visiV14( cfour.Size() );
     271    TVector< complex<r_4> > visiV23( cfour.Size() );
     272    TVector< complex<r_4> > visiV24( cfour.Size() );
     273
     274    uint_4 nzm = 0;
     275    uint_4 totnoksfc = 0;
     276    uint_4 totnokpaq = 0;
     277    uint_4 totnpaq = 0;
     278    uint_4 ifile = 0;
     279    for (uint_4 kmz=0; kmz<nmax_; kmz++) {
     280      uint_4 noksfc = 0;
     281      uint_4 nokpaq = 0;
     282      if (stop_) break;
     283      int mid1 = memgr1.FindMemZoneId(MemZA_ProcB);
     284      Byte* buff1 = memgr1.GetMemZone(mid1);
     285      if (buff1 == NULL) {
     286         cout << " BRProcBRaw4C::run()/ERROR memgr.GetMemZone(" << mid1 << ") -> NULL" << endl;
     287             break;             
     288      }
     289      Byte* procbuff1 = memgr1.GetProcMemZone(mid1);
     290      if (procbuff1 == NULL) {
     291            cout << " BRProcBRaw4C::run()/ERROR memgr.GetProcMemZone(" << mid1 << ") -> NULL" << endl;
     292        break; 
     293      }
     294      int mid2 = memgr2.FindMemZoneId(MemZA_ProcB);
     295      Byte* buff2 = memgr2.GetMemZone(mid2);
     296      if (buff1 == NULL) {
     297         cout << " BRProcBRaw4C::run()/ERROR memgr.GetMemZone(" << mid2 << ") -> NULL" << endl;
     298             break;             
     299      }
     300      Byte* procbuff2 = memgr2.GetProcMemZone(mid2);
     301      if (procbuff2 == NULL) {
     302            cout << " BRProcBRaw4C::run()/ERROR memgr.GetProcMemZone(" << mid2 << ") -> NULL" << endl;
     303        break; 
     304      }
     305      uint_4 i1,i2;
     306      i1=i2=0;
     307      while((i1<memgr1.NbPaquets())&&(i2<memgr2.NbPaquets())) {
     308        BRPaquet paq1(NULL, buff1+i1*paqsz, paqsz);
     309        BRPaquet paq2(NULL, buff2+i2*paqsz, paqsz);
     310        totnpaq++;
     311//        cout << " DBG["<<kmz<<"] i1,i2=" << i1 <<","<<i2<<" FC1,FC2=" <<paq1.FrameCounter()
     312//<<","<<paq2.FrameCounter()<<endl;
     313        // on ne traite que les paquets OK
     314        if (!pcheck1.Check(paq1)) { i1++; continue; }
     315        if (!pcheck2.Check(paq2)) { i2++; continue; }
     316        nokpaq++;
     317        if (paq1.FrameCounter()<paq2.FrameCounter()) { i1++; continue; } 
     318        if (paq2.FrameCounter()<paq1.FrameCounter()) { i2++; continue; } 
     319//        cout << " DBG["<<kmz<<"]OKOK i1,i2=" << i1 <<","<<i2<<" FC1,FC2=" <<paq1.FrameCounter()
     320// <<","<<paq2.FrameCounter()<<endl;
     321
     322        // Les deux framecounters sont identiques ...
     323        noksfc++;
     324        complex<r_4>* zp1 = (complex<r_4>*)(procbuff1+i1*procpaqsz);
     325        complex<r_4>* zp2 = (complex<r_4>*)(procbuff1+i1*procpaqsz+procpaqsz/2);
     326        complex<r_4>* zp3 = (complex<r_4>*)(procbuff2+i2*procpaqsz);
     327        complex<r_4>* zp4 = (complex<r_4>*)(procbuff2+i2*procpaqsz+procpaqsz/2);
     328        for(sa_size_t j=0; j<visiV13.Size(); j++) {
     329          visiV13(j)+=zp1[j]*conj(zp3[j]);
     330          visiV14(j)+=zp1[j]*conj(zp4[j]);
     331          visiV23(j)+=zp2[j]*conj(zp3[j]);
     332          visiV24(j)+=zp2[j]*conj(zp4[j]);
     333        }
     334        nzm++;  i1++; i2++;
     335        totnbytesproc += 2*paq1.DataSize();
     336      } // Fin de boucle sur les paquets d'une zone
     337      if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) {
     338        visiV13 /= complex<r_4>((r_4)nzm, 0.);
     339        visiV14 /= complex<r_4>((r_4)nzm, 0.);
     340        visiV23 /= complex<r_4>((r_4)nzm, 0.);
     341        visiV24 /= complex<r_4>((r_4)nzm, 0.);
     342        visiV13.Info()["NPaqMoy"] = nzm;
     343        visiV14.Info()["NPaqMoy"] = nzm;
     344        visiV23.Info()["NPaqMoy"] = nzm;
     345        visiV24.Info()["NPaqMoy"] = nzm;
     346        char fname[512];
     347        {
     348        sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile);
     349        POutPersist po(fname);
     350        po << PPFNameTag("visiV13") << visiV13;
     351        po << PPFNameTag("visiV14") << visiV14;
     352        po << PPFNameTag("visiV23") << visiV23;
     353        po << PPFNameTag("visiV24") << visiV24;
     354        }
     355        visiV13 = complex<r_4>(0., 0.);
     356        visiV14 = complex<r_4>(0., 0.);
     357        visiV23 = complex<r_4>(0., 0.);
     358        visiV24 = complex<r_4>(0., 0.);
     359        nzm = 0; 
     360//        ts.SetNow();
     361//        filog << ts << " :  proc file  " << fname << endl;                   
     362        cout << " BRProcBRaw4C::run() created file  " << fname << endl;
     363      }   
     364      memgr1.FreeMemZone(mid1, MemZS_ProcB);
     365      memgr2.FreeMemZone(mid2, MemZS_ProcB);
     366      double okfrac = (nokpaq>1)?((double)noksfc/(double)nokpaq*100.):0.;
     367      cout << "BRProcBRaw2C ["<<kmz<<"] NOKPaq=" << nokpaq << " NSameFC=" << noksfc
     368           << " (" << okfrac << " %)" << endl;
     369      totnokpaq += nokpaq;
     370      totnoksfc += noksfc;
     371    }  // Fin de boucle sur les zones a traiter
     372    cout << " ------------------  BRProcBRaw4C::run() END ----------------- " << endl;
     373    ts.SetNow();
     374    tm.SplitQ();
     375    cout << "  TotalProc= " << totnbytesproc/(1024*1024) << " MBytes, rate= "
     376         << (double)(totnbytesproc)/1024./tm.PartialElapsedTimems() << " MB/s" << endl;
     377    double totokfrac = (totnokpaq>1)?((double)totnoksfc/(double)totnokpaq*100.):0.;
     378    cout << " NOkPaq1,2=" << totnokpaq << " /TotNPaq=" << totnpaq << " TotNSameFC="
     379         << totnoksfc << " (" << totokfrac << " %)" << endl;
     380//  cout << pcheck1;
     381//  cout << pcheck2;
     382    cout << " BRProcBRaw4C::run()/Timing: \n";
     383    tm.Print();
     384    cout << " ---------------------------------------------------------- " << endl;
     385}
     386  catch (PException& exc) {
     387    cout << " BRProcBRaw4C::run()/catched PException " << exc.Msg() << endl;
     388    setRC(3);   
     389    return;
     390  }
     391  catch(...) {
     392    cout << " BRProcBRaw4C::run()/catched unknown ... exception " << endl;
     393    setRC(4);   
     394    return;
     395  }
     396  setRC(0);
     397  return;
     398}   
     399
     400
  • trunk/AddOn/TAcq/brproc.h

    r3640 r3645  
    2525class BRProcARaw2C : public ZThread {
    2626public:
    27   BRProcARaw2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean=1,
    28                uint_4 step=1, uint_4 nmax=100, bool fgnotrl=false);
     27  BRProcARaw2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean=10,
     28               uint_4 nmax=100, bool fgnotrl=false, int card=1);
    2929  virtual void run();
    3030  void Stop();
     
    3434  bool stop_; 
    3535  uint_4 nmax_;  // Nombre maxi de blocs MemZone traites
    36   uint_4 step_;  // 1/step_ frame traite ds chaque bloc
     36  uint_4 nmean_;  // Nombre de blocs pour le calcul des moyennes
     37  string path_; 
     38  bool fgnotrl_;   // if true, don't check packet trailer - when using pre-june fits files
     39  int card_;   // Numeros de voies 2*card_-1, 2*card_
     40};
     41
     42//---------------------------------------------------------------------
     43// Classe thread de traitement 2 x 2 voies/frames (Apres BRProcARaw2C)
     44//---------------------------------------------------------------------
     45class BRProcBRaw4C : public ZThread {
     46public:
     47  BRProcBRaw4C(RAcqMemZoneMgr& mem1, RAcqMemZoneMgr& mem2, string& path,
     48               uint_4 nmean=10, uint_4 nmax=100, bool fgnotrl=false);
     49  virtual void run();
     50  void Stop();
     51  inline void STOP() { stop_ = true; } 
     52protected:
     53  RAcqMemZoneMgr& memgr1;
     54  RAcqMemZoneMgr& memgr2;
     55  bool stop_; 
     56  uint_4 nmax_;  // Nombre maxi de blocs MemZone traites
    3757  uint_4 nmean_;  // Nombre de blocs pour le calcul des moyennes
    3858  string path_; 
     
    4161
    4262
     63
    4364#endif
  • trunk/AddOn/TAcq/makefile

    r3639 r3645  
    2828## Lecture / traitement minifits multi-thread
    2929##   --------------
    30 mcrd : mcrd.o  racqumem.o brfitsrd.o brproc.o racquproc.o brpaqu.o pciewrap.o minifits.o
    31         $(CXXLINK) -o mcrd mcrd.o  racqumem.o brfitsrd.o brproc.o racquproc.o brpaqu.o minifits.o $(SOPHYAALLSLBLIST)
     30mcrd : mcrd.o  racqumem.o brfitsrd.o brproc.o racquproc.o brpaqu.o racqurw.o pciewrap.o minifits.o
     31        $(CXXLINK) -o mcrd mcrd.o  racqumem.o brfitsrd.o brproc.o racquproc.o brpaqu.o racqurw.o pciewrap.o minifits.o $(SOPHYAALLSLBLIST)
    3232
    33 mcrd.o : mcrd.cc brfitsrd.h racqumem.h brproc.h
     33mcrd.o : mcrd.cc brfitsrd.h racqumem.h brproc.h racqurw.h
    3434        $(CXXCOMPILE) -c  -o mcrd.o mcrd.cc
    3535
  • trunk/AddOn/TAcq/mcrd.cc

    r3640 r3645  
    3939#include "brfitsrd.h"
    4040#include "brproc.h"
     41#include "racqurw.h"
    4142
    4243
     
    5354}
    5455
     56//--  Parametres globaux
     57static int NZones=4;
     58static int NPaqinZone=128;
     59static int NMean=1024;
     60static int NGenZ=100;
     61static int GPaqSz=16424;
     62static double LossRate=0.1;
     63// ----
     64int Usage(bool fgshort=true);
     65// Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW)
     66int Proc1FRawA(string& outname, string& inpath, int jf1, int jf2, bool fgnotrl=false,
     67               bool fgrdfile=true);
     68// Pour traitement (calcul FFT et visibilites (ProcA,ProcB) 2 fibre, 4 voies RAW)
     69int Proc2FRawAB(string& outname, string& path1, string& path2, int jf1, int jf2,
     70                bool fgnotrl=false, bool fgrdfile=true);
     71
    5572//----------------------------------------------------
    5673//----------------------------------------------------
    5774int main(int narg, char* arg[])
    5875{
    59   if (narg < 4) {
    60     cout << " --- Reading/Processing BAORadio FITS files" << endl;
    61     cout << " Usage:  mcrd ACT OutPPF -infits DirName Imin Imax [NZones,NbPaqinZone] " << endl;
    62     cout << " ACT= notrl FITS files without frame trailer \n"
    63          << " OutPPF : Output PPF file name (without .ppf)" << endl;
    64     cout << " -infiles DirName Imin Imax : Input fits directory and sequence numbers \n"
    65          << "    FileNames=DirName/signalII.fits Imin<=II<=Imax \n"
    66          << " - NZones,NbPaqinZone : Number of Zones and number of paquets in one zone\n"
    67          << "     of the RAcqMemZoneMgr memory manager (default = 4,128) " << endl;
    68     return 1;
    69   }
     76  if ((narg>1)&&(strcmp(arg[1],"-h")==0))  return Usage(false);
     77  if (narg<5) return Usage(true);
    7078
    7179  TArrayInitiator  _inia;
     
    7482  try {
    7583    string act = arg[1];
    76     string outname = arg[2];
    77     vector<string> infiles;
    78     if ((strcmp(arg[3],"-infits")!=0) || (narg<7)) {
    79         cout << " mcrd/Error arguments - type mcrd for help" << endl;
    80         return 2;
    81     }
    82     char nbuff[1024];
    83     char* dirname = arg[4];
    84     int imin = atoi(arg[5]);
    85     int imax = atoi(arg[6]);
    86     for(int ii=imin; ii<=imax; ii++) {
    87       sprintf(nbuff,"%s/signal%d.fits",dirname,ii);
    88       infiles.push_back(nbuff);
    89     }
    90     int nzones = 4;
    91     int npaqz = 128;
    92     if (narg>7) sscanf(arg[7],"%d,%d",&nzones,&npaqz); 
     84    bool fg4c=false;  // true -> 4 channels (2 fibers)
     85    bool fgrdfits=false;  // false -> Don't read fits files, generate paquets
     86    bool fgnotrl=false;   // true -> fichier fits SANS Trailer de frame (< mai 2009)
     87    if (act.substr(0,2)=="-4") fg4c=true;
     88    if (act.substr(2)=="g")  fgrdfits=false;
     89    else if (act.substr(2)=="nt")  fgnotrl=true;
     90    if (fg4c && (narg<6)) return Usage(true);
     91
     92    string outname = arg[2];   
     93    string inpath2;
     94    string inpath = arg[3];
     95    int offa=4;
     96    if(fg4c) {
     97      inpath2=arg[4];    offa=5;
     98    }
     99    int imin=0;
     100    int imax=0;
     101    sscanf(arg[offa],"%d,%d",&imin,&imax);
     102    if (narg>offa+1) sscanf(arg[offa+1],"%d,%d",&NZones,&NPaqinZone);   
     103    if (narg>offa+2) NMean=atoi(arg[offa+2]);
     104    if (narg>offa+3) sscanf(arg[offa+3],"%d,%d,%lg",&GPaqSz,&NGenZ,&LossRate); 
    93105
    94106    cout << " ---------- mcrd.cc Start - ACT= " << act << " ------------- " << endl;
    95107    ResourceUsage resu;
    96     bool fgnotrl=false;   // fichier fits avec Trailer de frame (> mai 2009)
    97     if (act=="notrl") fgnotrl=true;  // fichier fits SANS trailer
    98 
    99     uint_4 paqsz, npaqf;
    100     DecodeMiniFitsHeader(infiles[0],paqsz, npaqf, fgnotrl);
    101 
    102     cout << " mcrd: NZones=" << nzones << " NbPaq=" << npaqz << "(in file=" << npaqf
    103          << " ) PaqSz=" << paqsz << endl;
    104          
    105     RAcqMemZoneMgr mmgr(nzones, npaqz, paqsz, sizeof(complex<r_4>)*paqsz);
    106     mmgr.SetFinalizedMask((uint_4)MemZS_ProcA);
    107 
    108     BRFitsReader reader(mmgr, infiles, fgnotrl);
    109     BRProcARaw2C proc(mmgr, outname, npaqf, 1, npaqf*infiles.size()/npaqz);
    110 
    111     cout << " mcrd.cc : Starting threads (reader, proc) ... " << endl;
    112     reader.start();
    113     proc.start();
    114     sleep(1);
    115     cout << " mcrd.cc : Waiting for reader thread to finish ... " << endl;
    116     reader.join();
    117     cout << " mcrd.cc : Reader finished, waiting for process thread to finish ... " << endl;
    118     sleep(2);
    119     mmgr.Stop();
    120     proc.join();
    121     mmgr.Print(cout);
     108    if (fg4c)
     109      rc =  Proc2FRawAB(outname, inpath, inpath2, imin, imax, fgnotrl, fgrdfits);
     110    else
     111      rc =  Proc1FRawA(outname, inpath, imin, imax, fgnotrl, fgrdfits);
    122112    cout << resu ;
    123113  }
     
    137127  }
    138128
    139   cout << ">>>> mcrd.cc ------- FIN ----------- RC=" << rc << endl;
     129  cout << ">>>> mcrd.cc ------- END ----------- RC=" << rc << endl;
    140130  return rc;
    141131
    142132}
     133
     134
     135
     136// Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW)
     137int Proc1FRawA(string& outname, string& inpath, int imin, int imax,
     138               bool fgnotrl, bool fgrdfile)
     139{
     140  vector<string> infiles;
     141  char nbuff[1024];
     142  for(int ii=imin; ii<=imax; ii++) {
     143    sprintf(nbuff,"%s/signal%d.fits",inpath.c_str(),ii);
     144    infiles.push_back(nbuff);
     145  }
     146  uint_4 nmaxz;
     147  uint_4 paqsz, npaqf;
     148  if (fgrdfile) {
     149    DecodeMiniFitsHeader(infiles[0],paqsz, npaqf, fgnotrl);
     150    nmaxz = infiles.size()*npaqf/NPaqinZone;
     151    cout << " mcrd/Proc1FRawA/ReadFits: NZones=" << NZones << " NbPaq=" << NPaqinZone
     152         << " NPaq in file=" << npaqf
     153         << " PaqSz=" << paqsz << " NMaxZ=" << nmaxz << " NMean=" << NMean << endl;
     154  }
     155  else {
     156    paqsz = GPaqSz;
     157    nmaxz = NGenZ;
     158    cout << " mcrd/Proc1FRawA/GeneratePaquets: NZones=" << NZones << " NbPaq=" << NPaqinZone
     159         << "  PaqSz=" << paqsz << " NMean=" << NMean << endl;
     160  }
     161  RAcqMemZoneMgr mmgr(NZones, NPaqinZone, paqsz, sizeof(complex<r_4>)*paqsz);
     162  mmgr.SetFinalizedMask((uint_4)MemZS_ProcA);
     163
     164  BRFitsReader reader(mmgr, infiles, fgnotrl);
     165  TestPCIWrapperNODMA pciw(paqsz,LossRate);
     166  PCIEReader pcird(pciw, paqsz, paqsz, mmgr, nmaxz, BR_Copy);
     167
     168  outname += "/Ch12";
     169  BRProcARaw2C proc(mmgr, outname, NMean, nmaxz, fgnotrl);
     170
     171  cout << " mcrd/Proc1FRawA: Starting threads (reader, proc) ... " << endl;
     172
     173  if (fgrdfile) reader.start();
     174  else pcird.start();
     175
     176  proc.start();
     177  sleep(1);
     178  cout << " mcrd/Proc1FRawA: Waiting for reader thread to finish ... " << endl;
     179  if (fgrdfile) reader.join();
     180  else pcird.join();
     181  cout << " mcrd/Proc1FRawA: Reader finished, waiting for process thread to finish ... " << endl;
     182  sleep(2);
     183  mmgr.Stop();
     184  proc.join();
     185  mmgr.Print(cout);
     186  return 0;
     187}
     188
     189
     190// Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW)
     191int Proc2FRawAB(string& outname, string& path1, string& path2, int imin, int imax,
     192               bool fgnotrl, bool fgrdfile)
     193{
     194  vector<string> infiles1;
     195  vector<string> infiles2;
     196  char nbuff[1024];
     197  for(int ii=imin; ii<=imax; ii++) {
     198    sprintf(nbuff,"%s/signal%d.fits",path1.c_str(),ii);
     199    infiles1.push_back(nbuff);
     200    sprintf(nbuff,"%s/signal%d.fits",path2.c_str(),ii);
     201    infiles2.push_back(nbuff);
     202  }
     203  uint_4 nmaxz;
     204  uint_4 paqsz, npaqf;
     205  if (fgrdfile) {
     206    DecodeMiniFitsHeader(infiles1[0],paqsz, npaqf, fgnotrl);
     207    nmaxz = infiles1.size()*npaqf/NPaqinZone;
     208    cout << " mcrd/Proc2FRawAB/ReadFits: NZones=" << NZones << " NbPaq=" << NPaqinZone
     209         << " NPaq in file=" << npaqf
     210         << " PaqSz=" << paqsz << " NMaxZ=" << nmaxz << " NMean=" << NMean << endl;
     211  }
     212  else {
     213    paqsz = GPaqSz;
     214    nmaxz = NGenZ;
     215    cout << " mcrd/Proc2FRawAB/GeneratePaquets: NZones=" << NZones << " NbPaq=" << NPaqinZone
     216         << "  PaqSz=" << paqsz << " NMean=" << NMean << endl;
     217  }
     218  RAcqMemZoneMgr mmgr1(NZones, NPaqinZone, paqsz, sizeof(complex<r_4>)*paqsz);
     219  mmgr1.SetFinalizedMask((uint_4)(MemZS_ProcA)|(uint_4)(MemZS_ProcB));
     220//  mmgr1.SetFinalizedMask((uint_4)(MemZS_ProcA));
     221  RAcqMemZoneMgr mmgr2(NZones, NPaqinZone, paqsz, sizeof(complex<r_4>)*paqsz);
     222  mmgr2.SetFinalizedMask((uint_4)(MemZS_ProcA)|(uint_4)(MemZS_ProcB));
     223//  mmgr2.SetFinalizedMask((uint_4)(MemZS_ProcA));
     224
     225  BRFitsReader reader1(mmgr1, infiles1, fgnotrl);
     226  BRFitsReader reader2(mmgr1, infiles2, fgnotrl);
     227
     228  TestPCIWrapperNODMA pciw1(paqsz,LossRate);
     229  PCIEReader pcird1(pciw1, paqsz, paqsz, mmgr1, nmaxz, BR_Copy);
     230  TestPCIWrapperNODMA pciw2(paqsz,LossRate);
     231  PCIEReader pcird2(pciw2, paqsz, paqsz, mmgr2, nmaxz, BR_Copy);
     232
     233  string outname1 = outname;
     234  outname1 += "/Ch12";
     235  BRProcARaw2C proc1(mmgr1, outname1, NMean, nmaxz, fgnotrl);
     236  string outname2 = outname;
     237  outname2 += "/Ch34";
     238  BRProcARaw2C proc2(mmgr2, outname2, NMean, nmaxz, fgnotrl,2);
     239  string outname12 = outname;
     240  outname12 += "/Ch1234";
     241  BRProcBRaw4C proc12(mmgr1, mmgr2, outname12, NMean, nmaxz, fgnotrl);
     242
     243  cout << " mcrd/Proc2FRawAB: Starting threads (reader1,2, procA1,2, procAB) ... " << endl;
     244
     245  if (fgrdfile) {
     246    reader1.start();
     247    reader2.start();
     248  }
     249  else {
     250    pcird1.start();
     251    pcird2.start();
     252  }
     253  proc1.start();
     254  proc2.start();
     255  proc12.start();
     256
     257  sleep(1);
     258  cout << " mcrd/Proc2FRawAB: Waiting for reader threads to finish ... " << endl;
     259  if (fgrdfile) {
     260    reader1.join();
     261    reader2.join();
     262  }
     263  else {
     264    pcird1.join();
     265    pcird2.join();
     266  }
     267  cout << " mcrd/Proc2FRawAB: Readers finished, waiting for process thread to finish ... " << endl;
     268  sleep(2);
     269  mmgr1.Stop();
     270  mmgr2.Stop();
     271  proc1.join();
     272  proc2.join();
     273  proc12.join();
     274  mmgr1.Print(cout);
     275  mmgr2.Print(cout);
     276  return 0;
     277}
     278
     279
     280/* --Fonction-- */
     281int Usage(bool fgshort)
     282{
     283  cout << " --- mcrd.cc : Reading/Processing BAORadio FITS files" << endl;
     284  cout << " Usage:  mcrd ACT OutPath InPath [InPath2] Imin,Imax\n"
     285       << "              [NZones,NPaqinZone] [NMean] [GPaqSz,NGenZones,LossRate]" << endl;
     286  if (fgshort) {
     287    cout << " mcrd -h for detailed instructions" << endl;
     288    return 1;
     289  }
     290  cout << " ACT= -2 , -2g , -2nt -> 1 fiber, 2 raw channel processing (ProcA)\n"
     291       << " ACT= -4 , -4g , -4g , -4nt -> 2 fibers, 4 raw channels (ProcA, ProcB)\n"
     292       << "   nt (notrl) -> FITS files without frame trailer \n"
     293       << "   g (generate paquets) -> generate paquets instead of reading fits files" <<endl;
     294  cout << " OutPath : Output directory name " << endl;
     295  cout << " InPath [InPath2] Imin,Imax: Input fits files directory name(s)\n"
     296       << "    (Inpath=Fiber1, InPath2=Fiber2) and sequence numbers \n"
     297       << "    FileNames=InPath/signalII.fits Imin<=II<=Imax \n"
     298       << " NZones,NbPaqinZone : Number of Zones and number of paquets in one zone\n"
     299       << "     of the RAcqMemZoneMgr memory manager (default = 4,128)\n"
     300       << " NMean: Number of packet used for spectra/visibility computation (def=1024)\n"
     301       << " GPaqSz,NGenZones,LossRate: Paquet Size, Number of memory zones filled and\n"
     302       << "      loss rate (-2g,-4g) , default=16424,100,0.1" << endl;
     303  return 1;
     304}
  • trunk/AddOn/TAcq/pciewrap.cc

    r3643 r3645  
    1111
    1212/* --Methode-- */
    13 TestPCIWrapperNODMA::TestPCIWrapperNODMA(UInt32 sz)
     13TestPCIWrapperNODMA::TestPCIWrapperNODMA(UInt32 sz, double lossrate)
    1414  : PCIEWrapperInterface() , size_(sz)
    1515{
     
    2020  frame_counter_ = 0;
    2121  timetag_ = 0;
    22   tottransfer_ = 0;     
     22  tottransfer_ = 0;
     23  lossrate_ = lossrate;
     24  cout << " TestPCIWrapperNODMA(PaqSz=" << sz << ",LossRate=" << lossrate << ")" << endl;
    2325}
    2426
     
    4547Byte* TestPCIWrapperNODMA::GetData()
    4648{
    47   frame_counter_ ++;
     49  if (lossrate_ > 1.e-19) {
     50    UInt32 dfc = 1;
     51    while (rg_.Flat01()<lossrate_)  dfc++;
     52    frame_counter_ += dfc;
     53  }
     54  else frame_counter_ ++;
    4855  timetag_ = frame_counter_ * size_ / 2;
    4956  BRPaquet paq(data_, size_);
  • trunk/AddOn/TAcq/pciewrap.h

    r3643 r3645  
    66#include "brpaqu.h"
    77#include <string>
     8#include "randr48.h"  // Generateur aleatoire SOPHYA pour simulation perte de paquets
    89
    910/*
     
    4546class TestPCIWrapperNODMA : public PCIEWrapperInterface {
    4647public:
    47   TestPCIWrapperNODMA(UInt32 sz);
     48  TestPCIWrapperNODMA(UInt32 sz, double lossrate=0.);
    4849  virtual ~TestPCIWrapperNODMA();
    4950
     
    6061  UInt64 timetag_;     
    6162  UInt64 tottransfer_;
     63  double lossrate_;
    6264  BRPaqChecker pchk_;
     65//  FMTRandGen rg_;
     66  ThSDR48RandGen rg_;
    6367};
    6468
  • trunk/AddOn/TAcq/tmtacq.cc

    r3644 r3645  
    410410  else {
    411411    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 ");
     412    if (!activate_pattern) {
     413      if (! dmap->StatusFibre() ) {
     414        cout << " tmtacq[3] - fibre non accrochee -> exit " << endl;
     415        throw PCIEWException(" Fibre non accrochee ");
     416      }
     417      else cout << " tmtacq[3] - fibre accrochee OK " << endl;
    415418    }
    416     else cout << " tmtacq[3] - fibre accrochee OK " << endl;
    417419    pciwp = new PCIEWrapper(*dmap);
    418420  }
     
    509511  else {
    510512    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");
     513    if (!activate_pattern) {
     514      if (! dmap1->StatusFibre() ) {
     515        cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[0] << " -> exit " << endl;
     516        throw PCIEWException(" Fibre non accrochee 1");
     517      }
     518      else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[0] << endl;
     519
     520      dmap2 = new DMAMgr(cardlist[1],patternSZ,dmaSize,activate_pattern);
     521      if (! dmap2->StatusFibre() ) {
     522        cout << " tmtacq[3] - fibre non accrochee Card" << cardlist[1] << " -> exit " << endl;
     523        throw PCIEWException(" Fibre non accrochee 2");
     524      }
     525      else cout << " tmtacq[3] - fibre accrochee OK Card " << cardlist[1] << endl;
    514526    }
    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;
    523527    pciwp1 = new PCIEWrapper(*dmap1);
    524528    pciwp2 = new PCIEWrapper(*dmap2);
Note: See TracChangeset for help on using the changeset viewer.