Changeset 1502 in Sophya for trunk/ArchTOIPipe/ProcWSophya


Ignore:
Timestamp:
May 18, 2001, 7:29:04 PM (24 years ago)
Author:
cmv
Message:

definition des flags pour TOI flagtoidef.h (added)
Un peu plus pour GenWindowTOIProcessor.
commit mais classe inutilisable en l'etat. cmv 18/5/2001

Location:
trunk/ArchTOIPipe/ProcWSophya
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ArchTOIPipe/ProcWSophya/genwproc.cc

    r1496 r1502  
    66#include "ctimer.h"
    77
    8 
    9 // #define DEBUGGENW 1
    10 
    118// -------------------------------------------------------------
    129//   Class GenWindowTOIProcessor : generic processor with window
     
    1411
    1512////////////////////////////////////////////////////////////////
    16 GenWindowTOIProcessor::GenWindowTOIProcessor(int nbinput,int nboutput
    17                                    ,int wsz, int wstep, int wsztot)
     13GenWindowTOIProcessor::GenWindowTOIProcessor(int_4 nbinput,int_4 nboutput
     14                                   ,int_4 wsz, int_4 wstep, int_4 wsztot)
    1815{
    1916  if(nbinput<1) throw ParmError("GenWindowTOIProcessor::Creator nbinput<1 !");
    2017  if(nboutput<0) nboutput=0;
    2118  if(wsz<2) throw ParmError("GenWindowTOIProcessor::Creator wsz<2 !");
    22   if(wsz%2==0) wsz++;
     19  if(wsz%2==0) {if(wsztot==wsz) wsztot++; wsz++;}
    2320  if(wstep<1) wstep=1;
    24   if(wsztot<wsz) wsztot = 2*wsz;  // CMV prise de decision wsztot / wstep
     21  if(wsztot<wsz) wsztot = 2*wsz;
     22  // cas sans intersection entre 2 samples successifs
     23  if(wstep>=wsz) wsztot = wsz;
    2524
    2625  NbInput = nbinput;
     
    3029  WSizeTot = wsztot;
    3130
    32   SNdeb = SNend = StartSample = CurWtIndex = -1;
    33   TotNsCount = 0;
    34 
     31  CurWtIndex = -1;
     32  SNbegin = SNend = StartSample = LastFilledSn = -1;
     33  TotNsCount = TotDecalCount = 0;
     34
     35  SetDbgLevel();
     36  SetWSizeLCR();
    3537  SetDefaultValue();
    3638
     
    3840  TVector<int_8> vi8(1);   // constructeur copie de TArray (taille nulle)
    3941 
    40   int k;
     42  int_4 k;
    4143  for(k=0;k<NbInput;k++) {
    4244    WDataIn.push_back(vr8);
     
    4446    WInFlg.push_back(false);
    4547  }
    46   if(NbOutput) for(k=0;k<NbOutput;k++) {
    47     WDataOut.push_back(vr8);
    48     WFlagOut.push_back(vi8);
    49     WOutFlg.push_back(false);
    50     WPutOutFlg.push_back(false);
    51     WPutOutOwnVector.push_back(false);
    52     OutSample.push_back(0);
    53   }
     48  if(NbOutput)
     49    for(k=0;k<NbOutput;k++) {
     50      WDataOut.push_back(vr8);
     51      WFlagOut.push_back(vi8);
     52      WOutFlg.push_back(false);
     53      WPutOutFlg.push_back(false);
     54      WPutOutOwnVector.push_back(false);
     55      OutSample.push_back(0);
     56    }
    5457}
    5558
     
    5962
    6063////////////////////////////////////////////////////////////////
    61 void GenWindowTOIProcessor::PrintStatus(ostream & os)
    62 {
    63   os<<"\n ------------------------------------------------------ \n"
    64     <<" GenWindowTOIProcessor::PrintStatus() - ["
    65     <<NbInput<<","<<NbOutput<<"] (wtot="<<WSizeTot
    66     <<" WindowSize="<<GetWSize()
    67     <<" WStep= "<<GetWStep()<<endl;
    68   TOIProcessor::PrintStatus(os);
    69   os<<"ProcessedSampleCount="<<ProcessedSampleCount()<<endl;
    70   os<<"------------------------------------------------------ "<<endl;
    71 }
    72 
    73 ////////////////////////////////////////////////////////////////
    74 TVector<r_8> GenWindowTOIProcessor::GetWData(int numtoi)
     64void GenWindowTOIProcessor::PrintStatus(ostream & os,int lp)
     65{
     66os<<"\n ------------------------------------------------------ \n"
     67  <<" GenWindowTOIProcessor::PrintStatus() - ["<<NbInput<<","<<NbOutput<<"]"<<endl
     68  <<" WSizeTot="<<WSizeTot<<" WSize="<<GetWSize()<<" WStep= "<<GetWStep()<<endl;
     69if(lp>0) {
     70  os<<" WindowLCR: "
     71    <<" L=("<<W0Left<<","<<GetWSize('l')<<")"
     72    <<" C=("<<W0Center<<","<<GetWSize('c')<<")"
     73    <<" R=("<<W0Right<<","<<GetWSize('r')<<")"
     74    <<endl;
     75}
     76TOIProcessor::PrintStatus(os);
     77os<<"ProcessedSampleCount="<<ProcessedSampleCount()<<" NbDecal="<<TotDecalCount<<endl;
     78os<<"------------------------------------------------------ "<<endl;
     79}
     80
     81////////////////////////////////////////////////////////////////
     82TVector<r_8> GenWindowTOIProcessor::GetWData(int_4 numtoi)
    7583{
    7684  if(numtoi<0 || numtoi>=NbInput)
     
    8189}
    8290
    83 TVector<int_8> GenWindowTOIProcessor::GetWFlag(int numtoi)
     91TVector<int_8> GenWindowTOIProcessor::GetWFlag(int_4 numtoi)
    8492{
    8593  if(numtoi<0 || numtoi>=NbInput)
     
    9098}
    9199
    92 r_8 * GenWindowTOIProcessor::GetWDataPointer(int numtoi)
     100r_8 * GenWindowTOIProcessor::GetWDataPointer(int_4 numtoi)
    93101{
    94102  if(numtoi<0 || numtoi>=NbInput)
     
    100108}
    101109 
    102 int_8 * GenWindowTOIProcessor::GetWFlagPointer(int numtoi)
     110int_8 * GenWindowTOIProcessor::GetWFlagPointer(int_4 numtoi)
    103111{
    104112  if(numtoi<0 || numtoi>=NbInput)
     
    109117}
    110118
    111 void GenWindowTOIProcessor::GetData(int numtoi, int_8 numsample, r_8 & data, int_8 & flag)
     119void GenWindowTOIProcessor::GetData(int_4 numtoi, int_8 numsample, r_8 & data, int_8 & flag)
    112120{
    113121  if(numtoi<0 || numtoi>=NbInput)
     
    115123  if(!WInFlg[numtoi])
    116124    throw ParmError("GenWindowTOIProcessor::GetData : toi not connected!");
    117   int_8 k = numsample-GetStartSample();
     125  int_8 k = numsample-GetWStartSample();
    118126  if ((k<0) || (k >= GetWSize()))
    119127    throw RangeCheckError("GenWindowTOIProcessor::GetData : numsample out of window!");
     
    127135                                    ,TVector<r_8>& data,TVector<int_8>& flag)
    128136{
    129   if(numtoi<0 || numtoi>=NbOutput)
     137  if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
    130138    throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !");
    131139  if(!WOutFlg[numtoi])
     
    145153                                    ,r_8 data,int_8 flag)
    146154{
    147   if(numtoi<0 || numtoi>=NbOutput)
     155  if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
    148156    throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !");
    149157  if(!WOutFlg[numtoi])
     
    160168}
    161169
     170/******* cmv routines
     171void GenWindowTOIProcessor::PutWData(int_4 numtoi,int_8 numsample
     172                                    ,TVector<r_8>& data,TVector<int_8>& flag)
     173{
     174  if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
     175    throw RangeCheckError("GenWindowTOIProcessor::PutWData : toi out of range !");
     176  if(!WOutFlg[numtoi])
     177    throw ParmError("GenWindowTOIProcessor::PutWData : toi not connected!");
     178  if(data.Size()!=flag.Size())
     179    throw ParmError("GenWindowTOIProcessor::PutWData : data.Size()!=flag.Size()!");
     180  if(data.Size() == 0)
     181    throw ParmError("GenWindowTOIProcessor::PutWData : data.Size()==0 !");
     182
     183  for(int_4 k=0;k<data.Size(); k++)
     184     putData(numtoi,numsample+k,data(k),flag(k));
     185}
     186
     187void GenWindowTOIProcessor::PutWData(int_4 numtoi,int_8 numsample
     188                                    ,r_8 data,int_8 flag)
     189{
     190  if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
     191    throw RangeCheckError("GenWindowTOIProcessor::PutWData : toi out of range !");
     192  if(!WOutFlg[numtoi])
     193    throw ParmError("GenWindowTOIProcessor::PutWData : toi not connected!");
     194
     195  putData(numtoi,numsample,data,flag);
     196}
     197*********/
     198
     199////////////////////////////////////////////////////////////////
     200void GenWindowTOIProcessor::SetWSizeLCR(int_4 wszl,int_4 wszc,int_4 wszr)
     201// Fenetre a gauche, au centre et a droite du pixel central
     202// Selon la logique:
     203//-----------------------------------------------
     204//                     | pixel central
     205//                     |
     206//                     |
     207//          | wszl | wszc | wszr |
     208//                     |
     209//       |           WSize           |
     210//-----------------------------------------------
     211// wszc toujours impair SVP.
     212// Default: 0,0,0 : WSize/2,1,WSize/2
     213{
     214 int_4 wsz2 = WSize/2;
     215 // Default
     216 if(wszl<=0 && wszc<=0 && wszr<=0) {
     217   WSizeLeft = WSizeRight = wsz2; WSizeCenter = 1;
     218   W0Left = 0; W0Center = wsz2;   W0Right = wsz2+1;
     219   return;
     220 }
     221
     222 // Fenetre centrale
     223 if(wszc<=0)    wszc = 1;
     224 if(wszc%2==0)  wszc++;
     225 if(wszc>WSize) wszc = WSize;
     226 WSizeCenter = wszc;
     227 W0Center = wsz2 - WSizeCenter/2;
     228
     229 // Fenetre de gauche
     230 if(wszl<=0) wszl = WSize;
     231 W0Left = W0Center - wszl;
     232 if(W0Left<0) W0Left = 0;
     233 WSizeLeft = W0Center - W0Left;
     234 if(WSizeLeft<=0) WSizeLeft = 1;
     235
     236 // Fenetre de droite
     237 if(wszr<=0) wszr = WSize;
     238 W0Right = W0Center + WSizeCenter;
     239 if(W0Right>=WSize) W0Right = WSize - 1;
     240 int_4 dum = W0Right + wszr; if(dum>WSize) dum = WSize;
     241 WSizeRight = dum - W0Right;
     242 if(WSizeRight<=0) WSizeRight = 1;
     243}
     244
     245TVector<r_8> GenWindowTOIProcessor::GetWData(char cw,int_4 numtoi)
     246// cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
     247{
     248 if(numtoi<0 || numtoi>=NbInput)
     249    throw RangeCheckError("GenWindowTOIProcessor::GetWData(lcr) : toi out of range !");
     250 if(!WInFlg[numtoi])
     251   throw ParmError("GenWindowTOIProcessor::GetWData(lcr) : toi not connected!");
     252 return (WDataIn[numtoi])(Range(StartWtIndex(cw),0,GetWSize(cw)));
     253}
     254
     255TVector<int_8> GenWindowTOIProcessor::GetWFlag(char cw,int_4 numtoi)
     256// cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
     257{
     258 if(numtoi<0 || numtoi>=NbInput)
     259   throw RangeCheckError("GenWindowTOIProcessor::GetWFlag(lcr) : toi out of range !");
     260 if(!WInFlg[numtoi])
     261   throw ParmError("GenWindowTOIProcessor::GetWFlag(lcr) : toi not connected!");
     262 return (WFlagIn[numtoi])(Range(StartWtIndex(cw),0,GetWSize(cw)));
     263}
     264
     265r_8 * GenWindowTOIProcessor::GetWDataPointer(char cw,int_4 numtoi,int_4& n)
     266// cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
     267{
     268 if(numtoi<0 || numtoi>=NbInput)
     269   throw RangeCheckError("GenWindowTOIProcessor::GetWDataPointe(lcr)r : toi out of range !");
     270 if(!WInFlg[numtoi])
     271   throw ParmError("GenWindowTOIProcessor::GetWDataPointer(lcr) : toi not connected!");
     272 n = GetWSize(cw);
     273 return (WDataIn[numtoi].Data()+StartWtIndex(cw));
     274
     275}
     276 
     277int_8 * GenWindowTOIProcessor::GetWFlagPointer(char cw,int_4 numtoi,int_4& n)
     278// cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
     279{
     280 if(numtoi<0 || numtoi>=NbInput)
     281   throw RangeCheckError("GenWindowTOIProcessor::GetWFlagPointer(lcr) : toi out of range !");
     282 if(!WInFlg[numtoi])
     283   throw ParmError("GenWindowTOIProcessor::GetWFlagPointer(lcr) : toi not connected!");
     284 n = GetWSize(cw);
     285 return (WFlagIn[numtoi].Data()+StartWtIndex(cw));
     286}
     287
    162288////////////////////////////////////////////////////////////////
    163289void GenWindowTOIProcessor::UserInit(int_8 kstart)
     
    181307  cout << "GenWindowTOIProcessor::init" << endl;
    182308  char buff[64];
    183   int k;
     309  int_4 k;
    184310  for(k=0; k<NbInput; k++) {
    185311    sprintf(buff,"in%d", k);
    186312    declareInput(buff);
    187313  }
    188   for(k=0; k<NbOutput; k++) {
    189     sprintf(buff,"out%d",k);
    190     declareOutput(buff);
    191   }
     314  if(NbOutput)
     315    for(k=0; k<NbOutput; k++) {
     316      sprintf(buff,"out%d",k);
     317      declareOutput(buff);
     318    }
    192319  name = "GenWindowTOIProcessor";
    193320  // upExtra = 1; $CHECK a quoi ca sert EA?
     
    197324{
    198325  //  TOIManager* mgr = TOIManager::getManager();
    199   SNdeb = getMinIn();
    200   SNend = getMaxIn();
    201   if(SNend-SNdeb<WSize)
     326  SNbegin = getMinIn();
     327  SNend   = getMaxIn();
     328
     329  if(SNend-SNbegin<WSize)
    202330    throw ParmError("GenWindowTOIProcessor::run : sne-snb<WSize !");
    203331
    204332  // Allocation des tailles pour les vecteurs
    205   int kc, nc=0;
     333  int_4 kc, nc=0;
    206334  for(kc=0;kc<NbInput;kc++) {
    207335    if( !(WInFlg[kc]=checkInputTOIIndex(kc)) ) continue;
     
    214342    throw ParmError("GenWindowTOIProcessor::run() No input TOI connected!");
    215343  }
    216   for(kc=0;kc<NbOutput;kc++) WOutFlg[kc] = checkOutputTOIIndex(kc);
     344  if(NbOutput)
     345    for(kc=0;kc<NbOutput;kc++) WOutFlg[kc] = checkOutputTOIIndex(kc);
    217346
    218347  // Lecture des samples et remplissage des vecteurs
    219   cout<<"GenWindowTOIProcessor::run() SNRange="<<SNdeb<<" - "<<SNend<<endl;
     348  cout<<"GenWindowTOIProcessor::run() SNRange="<<SNbegin<<" - "<<SNend<<endl;
    220349  try {
    221350    Timer tm("GenWindowTOIProcessor::run()");
    222     for(int_8 ks=SNdeb;ks<=SNend;ks++) {  // CMV gerer le += step
     351    int_4 wsz2=WSize/2;
     352    int_8 ksend = SNbegin;
     353    for(int_8 ks=SNbegin; ks<=SNend; ks+=WStep) {
     354
    223355      Remplissage(ks);
    224       if (ks == SNdeb) {
    225         UserInit(ks);
    226         Ecriture();
    227       }
    228       if ((ks-SNdeb)%WStep == 0) {
    229         UserProc(ks);
    230         // Il faut traiter les ecritures en sortie
    231         Ecriture();
    232       }
     356      if(DbgLevel) test_avec_print(ks);
     357
     358      if(ks == SNbegin) {UserInit(ks); Ecriture();}
     359
     360      UserProc(ks);
     361      Ecriture();
     362
     363      ksend = ks;
    233364      TotNsCount++;
    234365    }
    235     UserEnd(SNend);
    236     Ecriture();
     366    UserEnd(ksend); Ecriture();
    237367    cout << " GenWindowTOIProcessor::run() - End of processing " << endl;
    238368
     
    249379//      samples :   sn-ws/2        sn          sn+ws/2
    250380//      fenetre :   0              ws/2+1      ws-1
    251 {
    252 #ifdef DEBUGGENW
    253  cout << "GenWindowTOIProcessor::Remplissage(" << ks << ") CurWtIndex=" << CurWtIndex << endl;
    254 #endif
    255 
    256 if(ks<SNdeb || ks>SNend) {
    257   cerr << "GenWindowTOIProcessor::remplissage/Erreur : ks(=" << ks << ") <"
    258        << SNdeb << " || ks>" << SNend << endl;
    259   throw RangeCheckError("GenWindowTOIProcessor::remplissage : ks<SNdeb || ks>SNend !");
    260  }
    261 int_8 wsz2=WSize/2;
    262 
    263 StartSample = ks - wsz2; // peut etre < snb au debut
    264 
    265 // Premier remplissage ???? Gestion de la borne inferieure
     381// Cette routine doit etre utilisee dans une boucle:
     382//      for(int k=???; k<???; k+=WStep) .....
     383// Dans le grand buffer WSizeTot il doit y avoir WSize samples
     384//      entre ks1=ks-wsz2 et ks2=ks-wsz2  (ks1<=k<=ks2)
     385// En ENTREE de cette routine :
     386// - CurWtIndex = c'est l'index du tableau WSizeTot qui doit etre rempli
     387//                (le dernier index qui a ete rempli par l'appel precedent
     388//                 est donc CurWtIndex-1)
     389// - LastFilledSn = c'est le dernier numero de sample qui a ete rempli
     390//                  dans le tableau WSizeTot par l'appel precedent
     391{
     392int_4 wsz2=WSize/2;
     393
     394// Numero de sample du premier element du tableau WSize
     395//   (peut etre < SNbegin au debut)
     396StartSample = ks - wsz2;
     397
     398// on doit avoir les samples [ks1,ks2] dans le buffer
     399// (mais selon le step, certain peuvent etre deja remplis)
     400int_8 ks1 = ks-wsz2, ks2 = ks+wsz2;
     401
     402if(DbgLevel>1)
     403  cout<<"DBG-GenWindowTOIProcessor::Remplissage("<<ks
     404      <<") ["<<ks1<<","<<ks2<<"]"
     405      <<" CurWtIndex="<<CurWtIndex<<" LastFilledSn="<<LastFilledSn<<endl;
     406
     407//--------------------------------------------------------
     408// Premier remplissage ????
     409// Gestion de la borne inferieure pour le permier sample
     410//--------------------------------------------------------
    266411if(CurWtIndex<0) {
    267 #ifdef DEBUGGENW
    268   cout << "GenWindowTOIProcessor::Remplissage 1ere fois" << endl;
    269 #endif
     412  if(DbgLevel>1)
     413    cout<<"DBG-GenWindowTOIProcessor::Remplissage 1ere fois"<<endl;
     414  for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
     415    if(!WInFlg[ntoi]) continue;
     416    for(int_8 k=ks1, j=0; k<=ks2; k++, j++) {
     417      if(k>=SNbegin && k<=SNend) {
     418        getData(ntoi,k,(WDataIn[ntoi])(j),(WFlagIn[ntoi])(j));
     419      } else {
     420        (WDataIn[ntoi])(j) = R8DefVal; (WFlagIn[ntoi])(j) = I8DefVal;
     421      }
     422    }
     423  }
     424  CurWtIndex = ks2 - ks1 + 1;
     425  LastFilledSn = ks2;
     426  return;
     427}
     428
     429//--------------------------------------------------------
     430// Faut-il decaler ????
     431//--------------------------------------------------------
     432if(WStep>=WSize) {
     433  // On ne decale pas puisque entre 2 appels a la routine
     434  // il faut TOUT recharger (aucun sample deja charge n'est utile)
    270435  CurWtIndex = 0;
    271   for(int_8 k=ks-wsz2; k<=ks+wsz2; k++) { // Lecture TOI
    272     for(int kc=0; kc<NbInput; kc++) {
    273       if(!WInFlg[kc]) continue;
    274       if(k>=SNdeb && k<=SNend) {
    275         getData(kc,k,(WDataIn[kc])(CurWtIndex), (WFlagIn[kc])(CurWtIndex));
    276       } else {
    277         (WDataIn[kc])(CurWtIndex) = R8DefVal;
    278         (WFlagIn[kc])(CurWtIndex) = I8DefVal;
     436} else {
     437  // Certains samples deja charges sont utiles
     438  int_8 ifin = ks2 - LastFilledSn + CurWtIndex-1;
     439  if(ifin >= WSizeTot) { // On decale
     440    int_8 ideb = CurWtIndex-1 - LastFilledSn + ks1;
     441    if(DbgLevel>1)
     442      cout<<"DBG-GenWindowTOIProcessor::Remplissage ... Decalage ideb="<<ideb
     443          <<" ifin="<<ifin<< endl;
     444    for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
     445      if(!WInFlg[ntoi]) continue;
     446      for(int_4 i=ideb, j=0; i<CurWtIndex; i++, j++) {
     447        (WDataIn[ntoi])(j) = (WDataIn[ntoi])(i);
     448        (WFlagIn[ntoi])(j) = (WFlagIn[ntoi])(i);
    279449      }
    280450    }
    281     CurWtIndex++;
    282   }
    283   return;
    284 }
    285 
    286 // CMV gere decalage seulement si step < wsize sinon copie.
    287 // Faut-il decaler ????
    288 if(CurWtIndex == WSizeTot) { // On decale
    289 #ifdef DEBUGGENW
    290   cout << "GenWindowTOIProcessor::Remplissage Decalage " << endl;
    291 #endif
    292   for(int kc=0; kc<NbInput; kc++) {
    293     if(!WInFlg[kc]) continue;
    294       for(int_8 k=1;k<WSize;k++) { // un en moins car on va remplir apres
    295         (WDataIn[kc])(k-1) = (WDataIn[kc])(WSizeTot-WSize+k);
    296         (WFlagIn[kc])(k-1) = (WFlagIn[kc])(WSizeTot-WSize+k);
    297       }
    298   }
    299   CurWtIndex = WSize-1;
    300 }
    301 
    302 // Remplissage de ks+wsz2 (dernier element de la fenetre pour ks central)
    303 int_8 kse = ks+wsz2;
    304 #ifdef DEBUGGENW
    305   cout << "GenWindowTOIProcessor::Normal fill " << endl;
    306 #endif
    307 for(int kc=0; kc<NbInput; kc++) {
    308   if(!WInFlg[kc]) continue;
    309   if(kse>=SNdeb && kse<=SNend) {
    310     getData(kc,kse,(WDataIn[kc])(CurWtIndex),(WFlagIn[kc])(CurWtIndex));
    311   } else {
    312     (WDataIn[kc])(CurWtIndex) = R8DefVal;
    313     (WFlagIn[kc])(CurWtIndex) = I8DefVal;
    314   }
    315 }
    316 CurWtIndex++;
     451    CurWtIndex = CurWtIndex-ideb;
     452    TotDecalCount++;
     453  }
     454}
     455
     456// Remplissage des samples utiles pour ks
     457if(ks1<=LastFilledSn) ks1 = LastFilledSn+1;
     458if(DbgLevel>1)
     459  cout<<"DBG-GenWindowTOIProcessor::Normal fill de ["<<ks1<<","<<ks2<<"]"<<endl;
     460for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
     461  if(!WInFlg[ntoi]) continue;
     462  for(int_4 k=ks1, j=CurWtIndex; k<=ks2; k++, j++) {
     463    if(k>=SNbegin && k<=SNend) {
     464      getData(ntoi,k,(WDataIn[ntoi])(j),(WFlagIn[ntoi])(j));
     465    } else {
     466      (WDataIn[ntoi])(j) = R8DefVal; (WFlagIn[ntoi])(j) = I8DefVal;
     467    }
     468  }
     469}
     470CurWtIndex += ks2 - ks1 + 1;
     471LastFilledSn = ks2;
    317472
    318473return;
     
    337492  for(kc=0; kc<NbOutput; kc++)  WPutOutFlg[kc] = false;
    338493}
     494
     495////////////////////////////////////////////////////////////////
     496void  GenWindowTOIProcessor::test_avec_print(int_8 ks)
     497{
     498if(DbgLevel<=0) return;
     499
     500int i,ii=0;
     501r_8   * datatot = WDataIn[0].Data();
     502int_8 * flagtot = WFlagIn[0].Data();
     503r_8   * data = GetWDataPointer();
     504int_8 * flag = GetWFlagPointer();
     505int_4 nl,nc,nr;
     506r_8   * datal = GetWDataPointer('l',nl);
     507int_8 * flagl = GetWFlagPointer('l',nl);
     508r_8   * datac = GetWDataPointer('c',nc);
     509int_8 * flagc = GetWFlagPointer('c',nc);
     510r_8   * datar = GetWDataPointer('r',nr);
     511int_8 * flagr = GetWFlagPointer('r',nr);
     512
     513cout<<"-------- ks = "<<ks<<endl;
     514
     515if(DbgLevel>2) {
     516  cout<<"datatot = ";
     517  for(i=0;i<WSizeTot;i++) {ii=0; cout<<" "<<datatot[i]; if(i%10==9) {cout<<endl; ii=1;}}
     518        if(ii==0) cout<<endl;
     519  cout<<"flagtot = ";
     520  for(i=0;i<WSizeTot;i++) {ii=0; cout<<" "<<flagtot[i]; if(i%10==9) {cout<<endl; ii=1;}}
     521        if(ii==0) cout<<endl;
     522}
     523
     524cout<<"data = ";
     525for(i=0;i<GetWSize();i++) {ii=0; cout<<" "<<data[i]; if(i%10==9) {cout<<endl; ii=1;}}
     526        if(ii==0) cout<<endl;
     527cout<<"flag = ";
     528for(i=0;i<GetWSize();i++) {ii=0; cout<<" "<<flag[i]; if(i%10==9) {cout<<endl; ii=1;}}
     529        if(ii==0) cout<<endl;
     530
     531if(DbgLevel>2) {
     532  cout<<"datal = ";
     533  for(i=0;i<nl;i++) {ii=0; cout<<" "<<datal[i]; if(i%10==9) {cout<<endl; ii=1;}}
     534        if(ii==0) cout<<endl;
     535  cout<<"flagl = ";
     536  for(i=0;i<nl;i++) {ii=0; cout<<" "<<flagl[i]; if(i%10==9) {cout<<endl; ii=1;}}
     537        if(ii==0) cout<<endl;
     538  cout<<"datac = ";
     539  for(i=0;i<nc;i++) {ii=0; cout<<" "<<datac[i]; if(i%10==9) {cout<<endl; ii=1;}}
     540        if(ii==0) cout<<endl;
     541  cout<<"flagc = ";
     542  for(i=0;i<nc;i++) {ii=0; cout<<" "<<flagc[i]; if(i%10==9) {cout<<endl; ii=1;}}
     543        if(ii==0) cout<<endl;
     544  cout<<"datar = ";
     545  for(i=0;i<nr;i++) {ii=0; cout<<" "<<datar[i]; if(i%10==9) {cout<<endl; ii=1;}}
     546        if(ii==0) cout<<endl;
     547  cout<<"flagr = ";
     548  for(i=0;i<nr;i++) {ii=0; cout<<" "<<flagr[i]; if(i%10==9) {cout<<endl; ii=1;}}
     549        if(ii==0) cout<<endl;
     550}
     551}
  • trunk/ArchTOIPipe/ProcWSophya/genwproc.h

    r1496 r1502  
    1212class GenWindowTOIProcessor : public TOIProcessor {
    1313public:
    14   GenWindowTOIProcessor(int nbinput,int nboutput,int wsz, int wstep=1, int wsztot=-1);
     14  GenWindowTOIProcessor(int_4 nbinput,int_4 nboutput,int_4 wsz, int_4 wstep=1, int_4 wsztot=-1);
    1515  virtual ~GenWindowTOIProcessor();
    1616
    17   inline int_8 GetWSize() const { return WSize; }
    18   inline int_8 GetWStep() const { return WStep; }
    19   inline int_8 ProcessedSampleCount() const { return TotNsCount; }
     17  inline int_4 GetWSize() const { return WSize; }
     18  inline int_4 GetWStep() const { return WStep; }
     19  inline int_4 ProcessedSampleCount() const { return TotNsCount; }
    2020
    21   inline int_8 GetStartSample()  {return StartSample;}
    22   inline int_8 GetCenterSample() {return StartSample + WSize/2;}
    23   inline int_8 StartSampleNum() { return SNdeb; }
    24   inline int_8 EndSampleNum() { return SNend; }
     21  // DbgLevel = 0 : No debug
     22  // DbgLevel = 1 : Print fenetre WSize
     23  // DbgLevel = 2 : 1 + Print logique remplissage/decalage
     24  // DbgLevel = 3 : 2 + Print fenetre WSizeTot et WSizeL,C,R
     25  inline void SetDbgLevel(int_2 lp=0) {DbgLevel = (lp>0) ? lp : 0;}
     26
     27  void SetWSizeLCR(int_4 wszl=0,int_4 wszc=0,int_4 wszr=0);
     28  inline int_4 GetWSize(char cw)
     29               {if     (cw=='l') return WSizeLeft;
     30                else if(cw=='c') return WSizeCenter;
     31                else if(cw=='r') return WSizeRight;
     32                                 return WSize;}
     33
     34  inline int_8 GetWStartSample()  {return StartSample;}
     35  inline int_8 GetWCenterSample() {return StartSample + WSize/2;}
     36  inline int_8 GetWCenterIndex()  {return WSize/2;}
     37  inline int_8 StartSampleNum()   {return SNbegin;}
     38  inline int_8 EndSampleNum()     {return SNend;}
    2539
    2640  inline void SetDefaultValue(r_8 r8dval=0., int_8 i8dval=0)
    2741                      {R8DefVal = r8dval; I8DefVal = i8dval;}
    2842
    29   TVector<r_8> GetWData(int numtoi=0);
    30   TVector<int_8> GetWFlag(int numtoi=0);
    31   r_8 * GetWDataPointer(int numtoi=0);
    32   int_8 * GetWFlagPointer(int numtoi=0);
    33   void GetData(int numtoi, int_8 numsample, r_8 & data, int_8 & flag);
     43  TVector<r_8> GetWData(int_4 numtoi=0);
     44  TVector<int_8> GetWFlag(int_4 numtoi=0);
     45  r_8 * GetWDataPointer(int_4 numtoi=0);
     46  int_8 * GetWFlagPointer(int_4 numtoi=0);
     47  void GetData(int_4 numtoi, int_8 numsample, r_8 & data, int_8 & flag);
    3448  inline void GetData(int_8 numsample, r_8 & data, int_8 & flag)
    3549                      { GetData(0, numsample, data, flag); }
    3650
    37   void PutWData(int numtoi,int_8 numsample,TVector<r_8>& data,TVector<int_8>& flag);
    38   void PutWData(int numtoi,int_8 numsample,r_8 data,int_8 flag);
     51  TVector<r_8> GetWData(char cw,int_4 numtoi=0);
     52  TVector<int_8> GetWFlag(char cw,int_4 numtoi=0);
     53  r_8   * GetWDataPointer(char cw,int_4 numtoi,int_4& n);
     54  int_8 * GetWFlagPointer(char cw,int_4 numtoi,int_4& n);
     55  inline   r_8 * GetWDataPointer(char cw,int_4& n)
     56                 {return GetWDataPointer(cw,0,n);}
     57  inline int_8 * GetWFlagPointer(char cw,int_4& n)
     58                 {return GetWFlagPointer(cw,0,n);}
     59
     60  void PutWData(int_4 numtoi,int_8 numsample,TVector<r_8>& data,TVector<int_8>& flag);
     61  void PutWData(int_4 numtoi,int_8 numsample,r_8 data,int_8 flag);
    3962  inline void PutWData(int_8 numsample,TVector<r_8>& data,TVector<int_8>& flag)
    4063                      {PutWData(0,numsample,data,flag);}
     
    4265                      {PutWData(0,numsample,data,flag);}
    4366
    44   virtual void PrintStatus(ostream & os);
     67  virtual void PrintStatus(ostream & os,int lp=0);
    4568
    4669  virtual void UserInit(int_8 kstart);
     
    5477  void Remplissage(int_8 ks);
    5578  void Ecriture();
    56   inline int_8 StartWtIndex()
    57          {if(CurWtIndex<0) return -1; else return CurWtIndex-WSize;}
    58   inline int_8 CenterWtIndex()
    59          {if(CurWtIndex<0) return -1; else return CurWtIndex-(WSize+1)/2;}
     79  void test_avec_print(int_8 ks);
     80  inline int_4 StartWtIndex()  {return CurWtIndex-WSize;}
     81  inline int_4 CenterWtIndex() {return CurWtIndex-(WSize+1)/2;}
     82  inline int_4 StartWtIndex(char cw)
     83         {if     (cw=='l') return StartWtIndex()+W0Left;
     84          else if(cw=='c') return StartWtIndex()+W0Center;
     85          else if(cw=='r') return StartWtIndex()+W0Right;
     86                           return StartWtIndex();}
    6087
    61   int NbInput,NbOutput;
    62   int_8 WSizeTot,WSize,WStep;
    63   int_8 SNdeb,SNend;
    64   int_8 StartSample,CurWtIndex;
    65   int_8 TotNsCount;
    66   r_8 R8DefVal;
     88  int_2 DbgLevel;
     89  int_4 NbInput,NbOutput;
     90  int_4 WSizeTot,WSize,WStep;
     91  int_4 WSizeLeft,WSizeCenter,WSizeRight, W0Left,W0Center,W0Right;
     92  int_8 SNbegin,SNend;
     93  int_8 TotNsCount,TotDecalCount;
     94  r_8   R8DefVal;
    6795  int_8 I8DefVal;
     96
     97  int_4 CurWtIndex;   // Prochain index a remplir dans le buffer WSizeTot
     98  int_8 LastFilledSn; // Numero du dernier sample remplie
     99  int_8 StartSample;  // Numero de sample du 1er element du buffer WSize
     100
    68101  vector< TVector<r_8>   > WDataIn;
    69102  vector< TVector<int_8> > WFlagIn;
     103  vector< bool > WInFlg;
    70104  vector< TVector<r_8>   > WDataOut;
    71105  vector< TVector<int_8> > WFlagOut;
    72   vector< bool > WInFlg;
    73106  vector< bool > WOutFlg;
    74107  vector< bool > WPutOutFlg;
Note: See TracChangeset for help on using the changeset viewer.