[1738] | 1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
| 2 | // Eric Aubourg
|
---|
| 3 | // Christophe Magneville
|
---|
| 4 | // Reza Ansari
|
---|
[1762] | 5 | // $Id: genwproc.cc,v 1.8 2001-11-13 16:22:46 aubourg Exp $
|
---|
[1738] | 6 |
|
---|
[1495] | 7 | #include "array.h"
|
---|
| 8 | #include <math.h>
|
---|
| 9 | #include "genwproc.h"
|
---|
| 10 | #include "toimanager.h"
|
---|
| 11 | #include "pexceptions.h"
|
---|
| 12 | #include "ctimer.h"
|
---|
| 13 |
|
---|
| 14 | // -------------------------------------------------------------
|
---|
| 15 | // Class GenWindowTOIProcessor : generic processor with window
|
---|
| 16 | // -------------------------------------------------------------
|
---|
| 17 |
|
---|
| 18 | ////////////////////////////////////////////////////////////////
|
---|
[1502] | 19 | GenWindowTOIProcessor::GenWindowTOIProcessor(int_4 nbinput,int_4 nboutput
|
---|
| 20 | ,int_4 wsz, int_4 wstep, int_4 wsztot)
|
---|
[1495] | 21 | {
|
---|
| 22 | if(nbinput<1) throw ParmError("GenWindowTOIProcessor::Creator nbinput<1 !");
|
---|
| 23 | if(nboutput<0) nboutput=0;
|
---|
| 24 | if(wsz<2) throw ParmError("GenWindowTOIProcessor::Creator wsz<2 !");
|
---|
[1502] | 25 | if(wsz%2==0) {if(wsztot==wsz) wsztot++; wsz++;}
|
---|
[1495] | 26 | if(wstep<1) wstep=1;
|
---|
[1502] | 27 | if(wsztot<wsz) wsztot = 2*wsz;
|
---|
| 28 | // cas sans intersection entre 2 samples successifs
|
---|
| 29 | if(wstep>=wsz) wsztot = wsz;
|
---|
[1495] | 30 |
|
---|
| 31 | NbInput = nbinput;
|
---|
| 32 | NbOutput = nboutput;
|
---|
| 33 | WSize = wsz;
|
---|
| 34 | WStep = wstep;
|
---|
| 35 | WSizeTot = wsztot;
|
---|
| 36 |
|
---|
[1502] | 37 | CurWtIndex = -1;
|
---|
| 38 | SNbegin = SNend = StartSample = LastFilledSn = -1;
|
---|
| 39 | TotNsCount = TotDecalCount = 0;
|
---|
[1495] | 40 |
|
---|
[1502] | 41 | SetDbgLevel();
|
---|
| 42 | SetWSizeLCR();
|
---|
[1496] | 43 | SetDefaultValue();
|
---|
| 44 |
|
---|
| 45 | TVector<r_8> vr8(1); // CMV+RZ supprimer taille(1) apres correction de
|
---|
| 46 | TVector<int_8> vi8(1); // constructeur copie de TArray (taille nulle)
|
---|
[1495] | 47 |
|
---|
[1502] | 48 | int_4 k;
|
---|
[1495] | 49 | for(k=0;k<NbInput;k++) {
|
---|
| 50 | WDataIn.push_back(vr8);
|
---|
| 51 | WFlagIn.push_back(vi8);
|
---|
| 52 | WInFlg.push_back(false);
|
---|
| 53 | }
|
---|
[1502] | 54 | if(NbOutput)
|
---|
| 55 | for(k=0;k<NbOutput;k++) {
|
---|
| 56 | WDataOut.push_back(vr8);
|
---|
| 57 | WFlagOut.push_back(vi8);
|
---|
| 58 | WOutFlg.push_back(false);
|
---|
| 59 | WPutOutFlg.push_back(false);
|
---|
| 60 | WPutOutOwnVector.push_back(false);
|
---|
| 61 | OutSample.push_back(0);
|
---|
| 62 | }
|
---|
[1495] | 63 | }
|
---|
| 64 |
|
---|
| 65 | GenWindowTOIProcessor::~GenWindowTOIProcessor()
|
---|
| 66 | {
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | ////////////////////////////////////////////////////////////////
|
---|
[1762] | 70 | void GenWindowTOIProcessor::PrintStatus(::ostream & os)
|
---|
[1495] | 71 | {
|
---|
[1502] | 72 | os<<"\n ------------------------------------------------------ \n"
|
---|
| 73 | <<" GenWindowTOIProcessor::PrintStatus() - ["<<NbInput<<","<<NbOutput<<"]"<<endl
|
---|
| 74 | <<" WSizeTot="<<WSizeTot<<" WSize="<<GetWSize()<<" WStep= "<<GetWStep()<<endl;
|
---|
[1546] | 75 | os<<" WindowLCR: "
|
---|
| 76 | <<" L=("<<W0Left<<","<<GetWSize('l')<<")"
|
---|
| 77 | <<" C=("<<W0Center<<","<<GetWSize('c')<<")"
|
---|
| 78 | <<" R=("<<W0Right<<","<<GetWSize('r')<<")"
|
---|
| 79 | <<endl;
|
---|
| 80 |
|
---|
[1502] | 81 | TOIProcessor::PrintStatus(os);
|
---|
| 82 | os<<"ProcessedSampleCount="<<ProcessedSampleCount()<<" NbDecal="<<TotDecalCount<<endl;
|
---|
| 83 | os<<"------------------------------------------------------ "<<endl;
|
---|
| 84 | }
|
---|
[1495] | 85 |
|
---|
| 86 | ////////////////////////////////////////////////////////////////
|
---|
[1502] | 87 | TVector<r_8> GenWindowTOIProcessor::GetWData(int_4 numtoi)
|
---|
[1495] | 88 | {
|
---|
| 89 | if(numtoi<0 || numtoi>=NbInput)
|
---|
| 90 | throw RangeCheckError("GenWindowTOIProcessor::GetWData : toi out of range !");
|
---|
| 91 | if(!WInFlg[numtoi])
|
---|
[1496] | 92 | throw ParmError("GenWindowTOIProcessor::GetWData : toi not connected!");
|
---|
| 93 | return (WDataIn[numtoi])(Range(StartWtIndex(),0,WSize));
|
---|
[1495] | 94 | }
|
---|
| 95 |
|
---|
[1532] | 96 | TVector<uint_8> GenWindowTOIProcessor::GetWFlag(int_4 numtoi)
|
---|
[1495] | 97 | {
|
---|
| 98 | if(numtoi<0 || numtoi>=NbInput)
|
---|
| 99 | throw RangeCheckError("GenWindowTOIProcessor::GetWFlag : toi out of range !");
|
---|
| 100 | if(!WInFlg[numtoi])
|
---|
[1496] | 101 | throw ParmError("GenWindowTOIProcessor::GetWFlag : toi not connected!");
|
---|
| 102 | return (WFlagIn[numtoi])(Range(StartWtIndex(),0,WSize));
|
---|
[1495] | 103 | }
|
---|
| 104 |
|
---|
[1502] | 105 | r_8 * GenWindowTOIProcessor::GetWDataPointer(int_4 numtoi)
|
---|
[1496] | 106 | {
|
---|
| 107 | if(numtoi<0 || numtoi>=NbInput)
|
---|
| 108 | throw RangeCheckError("GenWindowTOIProcessor::GetWDataPointer : toi out of range !");
|
---|
| 109 | if(!WInFlg[numtoi])
|
---|
| 110 | throw ParmError("GenWindowTOIProcessor::GetWDataPointer : toi not connected!");
|
---|
| 111 | return (WDataIn[numtoi].Data()+StartWtIndex());
|
---|
| 112 |
|
---|
| 113 | }
|
---|
| 114 |
|
---|
[1532] | 115 | uint_8 * GenWindowTOIProcessor::GetWFlagPointer(int_4 numtoi)
|
---|
[1496] | 116 | {
|
---|
| 117 | if(numtoi<0 || numtoi>=NbInput)
|
---|
| 118 | throw RangeCheckError("GenWindowTOIProcessor::GetWFlagPointer : toi out of range !");
|
---|
| 119 | if(!WInFlg[numtoi])
|
---|
| 120 | throw ParmError("GenWindowTOIProcessor::GetWFlagPointer : toi not connected!");
|
---|
| 121 | return (WFlagIn[numtoi].Data()+StartWtIndex());
|
---|
| 122 | }
|
---|
| 123 |
|
---|
[1532] | 124 | void GenWindowTOIProcessor::GetData(int_4 numtoi, int_8 numsample, r_8 & data, uint_8 & flag)
|
---|
[1496] | 125 | {
|
---|
| 126 | if(numtoi<0 || numtoi>=NbInput)
|
---|
| 127 | throw RangeCheckError("GenWindowTOIProcessor::GetData : toi out of range !");
|
---|
| 128 | if(!WInFlg[numtoi])
|
---|
| 129 | throw ParmError("GenWindowTOIProcessor::GetData : toi not connected!");
|
---|
[1502] | 130 | int_8 k = numsample-GetWStartSample();
|
---|
[1496] | 131 | if ((k<0) || (k >= GetWSize()))
|
---|
| 132 | throw RangeCheckError("GenWindowTOIProcessor::GetData : numsample out of window!");
|
---|
| 133 | k += StartWtIndex();
|
---|
| 134 | data = (WDataIn[numtoi])(k);
|
---|
| 135 | flag = (WFlagIn[numtoi])(k);
|
---|
| 136 | }
|
---|
| 137 |
|
---|
[1495] | 138 | ////////////////////////////////////////////////////////////////
|
---|
| 139 | void GenWindowTOIProcessor::PutWData(int numtoi,int_8 numsample
|
---|
[1532] | 140 | ,TVector<r_8>& data,TVector<uint_8>& flag)
|
---|
[1495] | 141 | {
|
---|
[1502] | 142 | if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
|
---|
[1495] | 143 | throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !");
|
---|
| 144 | if(!WOutFlg[numtoi])
|
---|
[1496] | 145 | throw ParmError("GenWindowTOIProcessor::PutWFlag : toi not connected!");
|
---|
[1495] | 146 | if(data.Size()!=flag.Size())
|
---|
| 147 | throw ParmError("GenWindowTOIProcessor::PutWFlag : data.Size()!=flag.Size()!");
|
---|
[1496] | 148 | if(data.Size() == 0)
|
---|
| 149 | throw ParmError("GenWindowTOIProcessor::PutWFlag : data.Size()==0 !");
|
---|
[1495] | 150 | WDataOut[numtoi].Share(data);
|
---|
| 151 | WFlagOut[numtoi].Share(flag);
|
---|
| 152 | OutSample[numtoi] = numsample;
|
---|
| 153 | WPutOutFlg[numtoi] = true;
|
---|
[1496] | 154 | WPutOutOwnVector[numtoi] = false;
|
---|
[1495] | 155 | }
|
---|
| 156 |
|
---|
| 157 | void GenWindowTOIProcessor::PutWData(int numtoi,int_8 numsample
|
---|
[1532] | 158 | , r_8 data, uint_8 flag)
|
---|
[1495] | 159 | {
|
---|
[1502] | 160 | if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
|
---|
[1495] | 161 | throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !");
|
---|
| 162 | if(!WOutFlg[numtoi])
|
---|
[1496] | 163 | throw ParmError("GenWindowTOIProcessor::PutWFlag : toi not connected!");
|
---|
| 164 | if (!WPutOutOwnVector[numtoi]) {
|
---|
| 165 | WDataOut[numtoi].Realloc(1,BaseArray::SameVectorType,true);
|
---|
| 166 | WFlagOut[numtoi].Realloc(1,BaseArray::SameVectorType,true);
|
---|
| 167 | WPutOutOwnVector[numtoi] = true;
|
---|
| 168 | }
|
---|
| 169 | (WDataOut[numtoi])(0) = data;
|
---|
| 170 | (WFlagOut[numtoi])(0) = flag;
|
---|
[1495] | 171 | OutSample[numtoi] = numsample;
|
---|
| 172 | WPutOutFlg[numtoi] = true;
|
---|
| 173 | }
|
---|
| 174 |
|
---|
[1502] | 175 | /******* cmv routines
|
---|
| 176 | void GenWindowTOIProcessor::PutWData(int_4 numtoi,int_8 numsample
|
---|
[1532] | 177 | ,TVector<r_8>& data,TVector<uint_8>& flag)
|
---|
[1502] | 178 | {
|
---|
| 179 | if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
|
---|
| 180 | throw RangeCheckError("GenWindowTOIProcessor::PutWData : toi out of range !");
|
---|
| 181 | if(!WOutFlg[numtoi])
|
---|
| 182 | throw ParmError("GenWindowTOIProcessor::PutWData : toi not connected!");
|
---|
| 183 | if(data.Size()!=flag.Size())
|
---|
| 184 | throw ParmError("GenWindowTOIProcessor::PutWData : data.Size()!=flag.Size()!");
|
---|
| 185 | if(data.Size() == 0)
|
---|
| 186 | throw ParmError("GenWindowTOIProcessor::PutWData : data.Size()==0 !");
|
---|
| 187 |
|
---|
| 188 | for(int_4 k=0;k<data.Size(); k++)
|
---|
| 189 | putData(numtoi,numsample+k,data(k),flag(k));
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | void GenWindowTOIProcessor::PutWData(int_4 numtoi,int_8 numsample
|
---|
[1532] | 193 | ,r_8 data, uint_8 flag)
|
---|
[1502] | 194 | {
|
---|
| 195 | if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
|
---|
| 196 | throw RangeCheckError("GenWindowTOIProcessor::PutWData : toi out of range !");
|
---|
| 197 | if(!WOutFlg[numtoi])
|
---|
| 198 | throw ParmError("GenWindowTOIProcessor::PutWData : toi not connected!");
|
---|
| 199 |
|
---|
| 200 | putData(numtoi,numsample,data,flag);
|
---|
| 201 | }
|
---|
| 202 | *********/
|
---|
| 203 |
|
---|
[1495] | 204 | ////////////////////////////////////////////////////////////////
|
---|
[1502] | 205 | void GenWindowTOIProcessor::SetWSizeLCR(int_4 wszl,int_4 wszc,int_4 wszr)
|
---|
| 206 | // Fenetre a gauche, au centre et a droite du pixel central
|
---|
| 207 | // Selon la logique:
|
---|
| 208 | //-----------------------------------------------
|
---|
| 209 | // | pixel central
|
---|
| 210 | // |
|
---|
| 211 | // |
|
---|
| 212 | // | wszl | wszc | wszr |
|
---|
| 213 | // |
|
---|
| 214 | // | WSize |
|
---|
| 215 | //-----------------------------------------------
|
---|
| 216 | // wszc toujours impair SVP.
|
---|
| 217 | // Default: 0,0,0 : WSize/2,1,WSize/2
|
---|
| 218 | {
|
---|
| 219 | int_4 wsz2 = WSize/2;
|
---|
| 220 | // Default
|
---|
| 221 | if(wszl<=0 && wszc<=0 && wszr<=0) {
|
---|
| 222 | WSizeLeft = WSizeRight = wsz2; WSizeCenter = 1;
|
---|
| 223 | W0Left = 0; W0Center = wsz2; W0Right = wsz2+1;
|
---|
| 224 | return;
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | // Fenetre centrale
|
---|
| 228 | if(wszc<=0) wszc = 1;
|
---|
| 229 | if(wszc%2==0) wszc++;
|
---|
| 230 | if(wszc>WSize) wszc = WSize;
|
---|
| 231 | WSizeCenter = wszc;
|
---|
| 232 | W0Center = wsz2 - WSizeCenter/2;
|
---|
| 233 |
|
---|
| 234 | // Fenetre de gauche
|
---|
| 235 | if(wszl<=0) wszl = WSize;
|
---|
| 236 | W0Left = W0Center - wszl;
|
---|
| 237 | if(W0Left<0) W0Left = 0;
|
---|
| 238 | WSizeLeft = W0Center - W0Left;
|
---|
| 239 | if(WSizeLeft<=0) WSizeLeft = 1;
|
---|
| 240 |
|
---|
| 241 | // Fenetre de droite
|
---|
| 242 | if(wszr<=0) wszr = WSize;
|
---|
| 243 | W0Right = W0Center + WSizeCenter;
|
---|
| 244 | if(W0Right>=WSize) W0Right = WSize - 1;
|
---|
| 245 | int_4 dum = W0Right + wszr; if(dum>WSize) dum = WSize;
|
---|
| 246 | WSizeRight = dum - W0Right;
|
---|
| 247 | if(WSizeRight<=0) WSizeRight = 1;
|
---|
| 248 | }
|
---|
| 249 |
|
---|
| 250 | TVector<r_8> GenWindowTOIProcessor::GetWData(char cw,int_4 numtoi)
|
---|
| 251 | // cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
|
---|
| 252 | {
|
---|
| 253 | if(numtoi<0 || numtoi>=NbInput)
|
---|
| 254 | throw RangeCheckError("GenWindowTOIProcessor::GetWData(lcr) : toi out of range !");
|
---|
| 255 | if(!WInFlg[numtoi])
|
---|
| 256 | throw ParmError("GenWindowTOIProcessor::GetWData(lcr) : toi not connected!");
|
---|
| 257 | return (WDataIn[numtoi])(Range(StartWtIndex(cw),0,GetWSize(cw)));
|
---|
| 258 | }
|
---|
| 259 |
|
---|
[1532] | 260 | TVector<uint_8> GenWindowTOIProcessor::GetWFlag(char cw,int_4 numtoi)
|
---|
[1502] | 261 | // cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
|
---|
| 262 | {
|
---|
| 263 | if(numtoi<0 || numtoi>=NbInput)
|
---|
| 264 | throw RangeCheckError("GenWindowTOIProcessor::GetWFlag(lcr) : toi out of range !");
|
---|
| 265 | if(!WInFlg[numtoi])
|
---|
| 266 | throw ParmError("GenWindowTOIProcessor::GetWFlag(lcr) : toi not connected!");
|
---|
| 267 | return (WFlagIn[numtoi])(Range(StartWtIndex(cw),0,GetWSize(cw)));
|
---|
| 268 | }
|
---|
| 269 |
|
---|
| 270 | r_8 * GenWindowTOIProcessor::GetWDataPointer(char cw,int_4 numtoi,int_4& n)
|
---|
| 271 | // cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
|
---|
| 272 | {
|
---|
| 273 | if(numtoi<0 || numtoi>=NbInput)
|
---|
| 274 | throw RangeCheckError("GenWindowTOIProcessor::GetWDataPointe(lcr)r : toi out of range !");
|
---|
| 275 | if(!WInFlg[numtoi])
|
---|
| 276 | throw ParmError("GenWindowTOIProcessor::GetWDataPointer(lcr) : toi not connected!");
|
---|
| 277 | n = GetWSize(cw);
|
---|
| 278 | return (WDataIn[numtoi].Data()+StartWtIndex(cw));
|
---|
| 279 |
|
---|
| 280 | }
|
---|
| 281 |
|
---|
[1532] | 282 | uint_8 * GenWindowTOIProcessor::GetWFlagPointer(char cw,int_4 numtoi,int_4& n)
|
---|
[1502] | 283 | // cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
|
---|
| 284 | {
|
---|
| 285 | if(numtoi<0 || numtoi>=NbInput)
|
---|
| 286 | throw RangeCheckError("GenWindowTOIProcessor::GetWFlagPointer(lcr) : toi out of range !");
|
---|
| 287 | if(!WInFlg[numtoi])
|
---|
| 288 | throw ParmError("GenWindowTOIProcessor::GetWFlagPointer(lcr) : toi not connected!");
|
---|
| 289 | n = GetWSize(cw);
|
---|
| 290 | return (WFlagIn[numtoi].Data()+StartWtIndex(cw));
|
---|
| 291 | }
|
---|
| 292 |
|
---|
| 293 | ////////////////////////////////////////////////////////////////
|
---|
[1496] | 294 | void GenWindowTOIProcessor::UserInit(int_8 kstart)
|
---|
[1495] | 295 | {
|
---|
| 296 | cout<<"GenWindowTOIProcessor::UserInit() Default implementation does nothing"<<endl;
|
---|
| 297 | }
|
---|
| 298 |
|
---|
[1496] | 299 | void GenWindowTOIProcessor::UserProc(int_8 ks)
|
---|
[1495] | 300 | {
|
---|
| 301 | cout<<"GenWindowTOIProcessor:UserProc() Default implementation does nothing"<<endl;
|
---|
| 302 | }
|
---|
| 303 |
|
---|
[1496] | 304 | void GenWindowTOIProcessor::UserEnd(int_8 kend)
|
---|
[1495] | 305 | {
|
---|
| 306 | cout<<"GenWindowTOIProcessor::UserEnd() Default implementation does nothing"<<endl;
|
---|
| 307 | }
|
---|
| 308 |
|
---|
| 309 | ////////////////////////////////////////////////////////////////
|
---|
| 310 | void GenWindowTOIProcessor::init()
|
---|
| 311 | {
|
---|
| 312 | cout << "GenWindowTOIProcessor::init" << endl;
|
---|
| 313 | char buff[64];
|
---|
[1502] | 314 | int_4 k;
|
---|
[1495] | 315 | for(k=0; k<NbInput; k++) {
|
---|
| 316 | sprintf(buff,"in%d", k);
|
---|
| 317 | declareInput(buff);
|
---|
| 318 | }
|
---|
[1502] | 319 | if(NbOutput)
|
---|
| 320 | for(k=0; k<NbOutput; k++) {
|
---|
| 321 | sprintf(buff,"out%d",k);
|
---|
| 322 | declareOutput(buff);
|
---|
| 323 | }
|
---|
[1495] | 324 | name = "GenWindowTOIProcessor";
|
---|
| 325 | // upExtra = 1; $CHECK a quoi ca sert EA?
|
---|
| 326 | }
|
---|
| 327 |
|
---|
| 328 | void GenWindowTOIProcessor::run()
|
---|
| 329 | {
|
---|
| 330 | // TOIManager* mgr = TOIManager::getManager();
|
---|
[1502] | 331 | SNbegin = getMinIn();
|
---|
| 332 | SNend = getMaxIn();
|
---|
| 333 |
|
---|
| 334 | if(SNend-SNbegin<WSize)
|
---|
[1496] | 335 | throw ParmError("GenWindowTOIProcessor::run : sne-snb<WSize !");
|
---|
[1495] | 336 |
|
---|
| 337 | // Allocation des tailles pour les vecteurs
|
---|
[1502] | 338 | int_4 kc, nc=0;
|
---|
[1495] | 339 | for(kc=0;kc<NbInput;kc++) {
|
---|
| 340 | if( !(WInFlg[kc]=checkInputTOIIndex(kc)) ) continue;
|
---|
| 341 | WDataIn[kc].ReSize(WSizeTot);
|
---|
| 342 | WFlagIn[kc].ReSize(WSizeTot);
|
---|
| 343 | nc++;
|
---|
| 344 | }
|
---|
| 345 | if(nc==0) {
|
---|
| 346 | cerr<<" GenWindowTOIProcessor::run() - No input TOI connected!"<<endl;
|
---|
| 347 | throw ParmError("GenWindowTOIProcessor::run() No input TOI connected!");
|
---|
| 348 | }
|
---|
[1502] | 349 | if(NbOutput)
|
---|
| 350 | for(kc=0;kc<NbOutput;kc++) WOutFlg[kc] = checkOutputTOIIndex(kc);
|
---|
[1495] | 351 |
|
---|
| 352 | // Lecture des samples et remplissage des vecteurs
|
---|
[1502] | 353 | cout<<"GenWindowTOIProcessor::run() SNRange="<<SNbegin<<" - "<<SNend<<endl;
|
---|
[1495] | 354 | try {
|
---|
| 355 | Timer tm("GenWindowTOIProcessor::run()");
|
---|
[1502] | 356 | int_4 wsz2=WSize/2;
|
---|
| 357 | int_8 ksend = SNbegin;
|
---|
| 358 | for(int_8 ks=SNbegin; ks<=SNend; ks+=WStep) {
|
---|
| 359 |
|
---|
[1495] | 360 | Remplissage(ks);
|
---|
[1502] | 361 | if(DbgLevel) test_avec_print(ks);
|
---|
| 362 |
|
---|
| 363 | if(ks == SNbegin) {UserInit(ks); Ecriture();}
|
---|
| 364 |
|
---|
| 365 | UserProc(ks);
|
---|
| 366 | Ecriture();
|
---|
| 367 |
|
---|
| 368 | ksend = ks;
|
---|
[1495] | 369 | TotNsCount++;
|
---|
| 370 | }
|
---|
[1502] | 371 | UserEnd(ksend); Ecriture();
|
---|
[1495] | 372 | cout << " GenWindowTOIProcessor::run() - End of processing " << endl;
|
---|
| 373 |
|
---|
| 374 | } catch(PException & exc) {
|
---|
[1496] | 375 | cerr<<"GenWindowTOIProcessor::run Catched Exception "<<(string)typeid(exc).name()
|
---|
[1495] | 376 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
| 377 | }
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 | ////////////////////////////////////////////////////////////////
|
---|
| 381 | void GenWindowTOIProcessor::Remplissage(int_8 ks)
|
---|
| 382 | // INPUT:
|
---|
| 383 | // ks : numero du sample CENTRAL
|
---|
| 384 | // samples : sn-ws/2 sn sn+ws/2
|
---|
| 385 | // fenetre : 0 ws/2+1 ws-1
|
---|
[1502] | 386 | // Cette routine doit etre utilisee dans une boucle:
|
---|
| 387 | // for(int k=???; k<???; k+=WStep) .....
|
---|
| 388 | // Dans le grand buffer WSizeTot il doit y avoir WSize samples
|
---|
| 389 | // entre ks1=ks-wsz2 et ks2=ks-wsz2 (ks1<=k<=ks2)
|
---|
| 390 | // En ENTREE de cette routine :
|
---|
| 391 | // - CurWtIndex = c'est l'index du tableau WSizeTot qui doit etre rempli
|
---|
| 392 | // (le dernier index qui a ete rempli par l'appel precedent
|
---|
| 393 | // est donc CurWtIndex-1)
|
---|
| 394 | // - LastFilledSn = c'est le dernier numero de sample qui a ete rempli
|
---|
| 395 | // dans le tableau WSizeTot par l'appel precedent
|
---|
[1495] | 396 | {
|
---|
[1502] | 397 | int_4 wsz2=WSize/2;
|
---|
[1496] | 398 |
|
---|
[1502] | 399 | // Numero de sample du premier element du tableau WSize
|
---|
| 400 | // (peut etre < SNbegin au debut)
|
---|
| 401 | StartSample = ks - wsz2;
|
---|
[1495] | 402 |
|
---|
[1502] | 403 | // on doit avoir les samples [ks1,ks2] dans le buffer
|
---|
| 404 | // (mais selon le step, certain peuvent etre deja remplis)
|
---|
| 405 | int_8 ks1 = ks-wsz2, ks2 = ks+wsz2;
|
---|
[1495] | 406 |
|
---|
[1502] | 407 | if(DbgLevel>1)
|
---|
| 408 | cout<<"DBG-GenWindowTOIProcessor::Remplissage("<<ks
|
---|
| 409 | <<") ["<<ks1<<","<<ks2<<"]"
|
---|
| 410 | <<" CurWtIndex="<<CurWtIndex<<" LastFilledSn="<<LastFilledSn<<endl;
|
---|
| 411 |
|
---|
| 412 | //--------------------------------------------------------
|
---|
| 413 | // Premier remplissage ????
|
---|
| 414 | // Gestion de la borne inferieure pour le permier sample
|
---|
| 415 | //--------------------------------------------------------
|
---|
[1496] | 416 | if(CurWtIndex<0) {
|
---|
[1502] | 417 | if(DbgLevel>1)
|
---|
| 418 | cout<<"DBG-GenWindowTOIProcessor::Remplissage 1ere fois"<<endl;
|
---|
| 419 | for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
|
---|
| 420 | if(!WInFlg[ntoi]) continue;
|
---|
| 421 | for(int_8 k=ks1, j=0; k<=ks2; k++, j++) {
|
---|
| 422 | if(k>=SNbegin && k<=SNend) {
|
---|
| 423 | getData(ntoi,k,(WDataIn[ntoi])(j),(WFlagIn[ntoi])(j));
|
---|
[1495] | 424 | } else {
|
---|
[1502] | 425 | (WDataIn[ntoi])(j) = R8DefVal; (WFlagIn[ntoi])(j) = I8DefVal;
|
---|
[1495] | 426 | }
|
---|
| 427 | }
|
---|
| 428 | }
|
---|
[1502] | 429 | CurWtIndex = ks2 - ks1 + 1;
|
---|
| 430 | LastFilledSn = ks2;
|
---|
[1495] | 431 | return;
|
---|
| 432 | }
|
---|
| 433 |
|
---|
[1502] | 434 | //--------------------------------------------------------
|
---|
[1495] | 435 | // Faut-il decaler ????
|
---|
[1502] | 436 | //--------------------------------------------------------
|
---|
| 437 | if(WStep>=WSize) {
|
---|
| 438 | // On ne decale pas puisque entre 2 appels a la routine
|
---|
| 439 | // il faut TOUT recharger (aucun sample deja charge n'est utile)
|
---|
| 440 | CurWtIndex = 0;
|
---|
| 441 | } else {
|
---|
| 442 | // Certains samples deja charges sont utiles
|
---|
| 443 | int_8 ifin = ks2 - LastFilledSn + CurWtIndex-1;
|
---|
| 444 | if(ifin >= WSizeTot) { // On decale
|
---|
| 445 | int_8 ideb = CurWtIndex-1 - LastFilledSn + ks1;
|
---|
| 446 | if(DbgLevel>1)
|
---|
| 447 | cout<<"DBG-GenWindowTOIProcessor::Remplissage ... Decalage ideb="<<ideb
|
---|
| 448 | <<" ifin="<<ifin<< endl;
|
---|
| 449 | for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
|
---|
| 450 | if(!WInFlg[ntoi]) continue;
|
---|
| 451 | for(int_4 i=ideb, j=0; i<CurWtIndex; i++, j++) {
|
---|
| 452 | (WDataIn[ntoi])(j) = (WDataIn[ntoi])(i);
|
---|
| 453 | (WFlagIn[ntoi])(j) = (WFlagIn[ntoi])(i);
|
---|
[1495] | 454 | }
|
---|
[1502] | 455 | }
|
---|
| 456 | CurWtIndex = CurWtIndex-ideb;
|
---|
| 457 | TotDecalCount++;
|
---|
[1495] | 458 | }
|
---|
| 459 | }
|
---|
| 460 |
|
---|
[1502] | 461 | // Remplissage des samples utiles pour ks
|
---|
| 462 | if(ks1<=LastFilledSn) ks1 = LastFilledSn+1;
|
---|
| 463 | if(DbgLevel>1)
|
---|
| 464 | cout<<"DBG-GenWindowTOIProcessor::Normal fill de ["<<ks1<<","<<ks2<<"]"<<endl;
|
---|
| 465 | for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
|
---|
| 466 | if(!WInFlg[ntoi]) continue;
|
---|
| 467 | for(int_4 k=ks1, j=CurWtIndex; k<=ks2; k++, j++) {
|
---|
| 468 | if(k>=SNbegin && k<=SNend) {
|
---|
| 469 | getData(ntoi,k,(WDataIn[ntoi])(j),(WFlagIn[ntoi])(j));
|
---|
| 470 | } else {
|
---|
| 471 | (WDataIn[ntoi])(j) = R8DefVal; (WFlagIn[ntoi])(j) = I8DefVal;
|
---|
| 472 | }
|
---|
[1495] | 473 | }
|
---|
| 474 | }
|
---|
[1502] | 475 | CurWtIndex += ks2 - ks1 + 1;
|
---|
| 476 | LastFilledSn = ks2;
|
---|
[1495] | 477 |
|
---|
| 478 | return;
|
---|
| 479 | }
|
---|
[1496] | 480 |
|
---|
| 481 | void GenWindowTOIProcessor::Ecriture()
|
---|
| 482 | {
|
---|
| 483 | int_8 maxlenout = 0;
|
---|
| 484 | int kc;
|
---|
| 485 | for(kc=0; kc<NbOutput; kc++)
|
---|
| 486 | if(WOutFlg[kc] && WPutOutFlg[kc] && (WDataOut[kc].Size() > maxlenout) )
|
---|
| 487 | maxlenout = WDataOut[kc].Size();
|
---|
| 488 |
|
---|
| 489 | for(int_8 k=0; k<maxlenout; k++) {
|
---|
| 490 | for(int kc=0; kc<NbOutput; kc++) {
|
---|
| 491 | if(!WOutFlg[kc]) continue;
|
---|
| 492 | if(!WPutOutFlg[kc]) continue;
|
---|
| 493 | if(k>=WDataOut[kc].Size()) continue;
|
---|
| 494 | putData(kc, k+OutSample[kc], (WDataOut[kc])(k), (WFlagOut[kc])(k));
|
---|
| 495 | }
|
---|
| 496 | }
|
---|
| 497 | for(kc=0; kc<NbOutput; kc++) WPutOutFlg[kc] = false;
|
---|
| 498 | }
|
---|
[1502] | 499 |
|
---|
| 500 | ////////////////////////////////////////////////////////////////
|
---|
| 501 | void GenWindowTOIProcessor::test_avec_print(int_8 ks)
|
---|
| 502 | {
|
---|
| 503 | if(DbgLevel<=0) return;
|
---|
| 504 |
|
---|
| 505 | int i,ii=0;
|
---|
| 506 | r_8 * datatot = WDataIn[0].Data();
|
---|
[1532] | 507 | uint_8 * flagtot = WFlagIn[0].Data();
|
---|
[1502] | 508 | r_8 * data = GetWDataPointer();
|
---|
[1532] | 509 | uint_8 * flag = GetWFlagPointer();
|
---|
[1502] | 510 | int_4 nl,nc,nr;
|
---|
| 511 | r_8 * datal = GetWDataPointer('l',nl);
|
---|
[1532] | 512 | uint_8 * flagl = GetWFlagPointer('l',nl);
|
---|
[1502] | 513 | r_8 * datac = GetWDataPointer('c',nc);
|
---|
[1532] | 514 | uint_8 * flagc = GetWFlagPointer('c',nc);
|
---|
[1502] | 515 | r_8 * datar = GetWDataPointer('r',nr);
|
---|
[1532] | 516 | uint_8 * flagr = GetWFlagPointer('r',nr);
|
---|
[1502] | 517 |
|
---|
| 518 | cout<<"-------- ks = "<<ks<<endl;
|
---|
| 519 |
|
---|
| 520 | if(DbgLevel>2) {
|
---|
| 521 | cout<<"datatot = ";
|
---|
| 522 | for(i=0;i<WSizeTot;i++) {ii=0; cout<<" "<<datatot[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
| 523 | if(ii==0) cout<<endl;
|
---|
| 524 | cout<<"flagtot = ";
|
---|
| 525 | for(i=0;i<WSizeTot;i++) {ii=0; cout<<" "<<flagtot[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
| 526 | if(ii==0) cout<<endl;
|
---|
| 527 | }
|
---|
| 528 |
|
---|
| 529 | cout<<"data = ";
|
---|
| 530 | for(i=0;i<GetWSize();i++) {ii=0; cout<<" "<<data[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
| 531 | if(ii==0) cout<<endl;
|
---|
| 532 | cout<<"flag = ";
|
---|
| 533 | for(i=0;i<GetWSize();i++) {ii=0; cout<<" "<<flag[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
| 534 | if(ii==0) cout<<endl;
|
---|
| 535 |
|
---|
| 536 | if(DbgLevel>2) {
|
---|
| 537 | cout<<"datal = ";
|
---|
| 538 | for(i=0;i<nl;i++) {ii=0; cout<<" "<<datal[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
| 539 | if(ii==0) cout<<endl;
|
---|
| 540 | cout<<"flagl = ";
|
---|
| 541 | for(i=0;i<nl;i++) {ii=0; cout<<" "<<flagl[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
| 542 | if(ii==0) cout<<endl;
|
---|
| 543 | cout<<"datac = ";
|
---|
| 544 | for(i=0;i<nc;i++) {ii=0; cout<<" "<<datac[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
| 545 | if(ii==0) cout<<endl;
|
---|
| 546 | cout<<"flagc = ";
|
---|
| 547 | for(i=0;i<nc;i++) {ii=0; cout<<" "<<flagc[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
| 548 | if(ii==0) cout<<endl;
|
---|
| 549 | cout<<"datar = ";
|
---|
| 550 | for(i=0;i<nr;i++) {ii=0; cout<<" "<<datar[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
| 551 | if(ii==0) cout<<endl;
|
---|
| 552 | cout<<"flagr = ";
|
---|
| 553 | for(i=0;i<nr;i++) {ii=0; cout<<" "<<flagr[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
| 554 | if(ii==0) cout<<endl;
|
---|
| 555 | }
|
---|
| 556 | }
|
---|