Changeset 1502 in Sophya for trunk/ArchTOIPipe
- Timestamp:
- May 18, 2001, 7:29:04 PM (24 years ago)
- Location:
- trunk/ArchTOIPipe
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/ProcWSophya/genwproc.cc
r1496 r1502 6 6 #include "ctimer.h" 7 7 8 9 // #define DEBUGGENW 110 11 8 // ------------------------------------------------------------- 12 9 // Class GenWindowTOIProcessor : generic processor with window … … 14 11 15 12 //////////////////////////////////////////////////////////////// 16 GenWindowTOIProcessor::GenWindowTOIProcessor(int nbinput,intnboutput17 ,int wsz, int wstep, intwsztot)13 GenWindowTOIProcessor::GenWindowTOIProcessor(int_4 nbinput,int_4 nboutput 14 ,int_4 wsz, int_4 wstep, int_4 wsztot) 18 15 { 19 16 if(nbinput<1) throw ParmError("GenWindowTOIProcessor::Creator nbinput<1 !"); 20 17 if(nboutput<0) nboutput=0; 21 18 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++;} 23 20 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; 25 24 26 25 NbInput = nbinput; … … 30 29 WSizeTot = wsztot; 31 30 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(); 35 37 SetDefaultValue(); 36 38 … … 38 40 TVector<int_8> vi8(1); // constructeur copie de TArray (taille nulle) 39 41 40 int k;42 int_4 k; 41 43 for(k=0;k<NbInput;k++) { 42 44 WDataIn.push_back(vr8); … … 44 46 WInFlg.push_back(false); 45 47 } 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 } 54 57 } 55 58 … … 59 62 60 63 //////////////////////////////////////////////////////////////// 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) 64 void GenWindowTOIProcessor::PrintStatus(ostream & os,int lp) 65 { 66 os<<"\n ------------------------------------------------------ \n" 67 <<" GenWindowTOIProcessor::PrintStatus() - ["<<NbInput<<","<<NbOutput<<"]"<<endl 68 <<" WSizeTot="<<WSizeTot<<" WSize="<<GetWSize()<<" WStep= "<<GetWStep()<<endl; 69 if(lp>0) { 70 os<<" WindowLCR: " 71 <<" L=("<<W0Left<<","<<GetWSize('l')<<")" 72 <<" C=("<<W0Center<<","<<GetWSize('c')<<")" 73 <<" R=("<<W0Right<<","<<GetWSize('r')<<")" 74 <<endl; 75 } 76 TOIProcessor::PrintStatus(os); 77 os<<"ProcessedSampleCount="<<ProcessedSampleCount()<<" NbDecal="<<TotDecalCount<<endl; 78 os<<"------------------------------------------------------ "<<endl; 79 } 80 81 //////////////////////////////////////////////////////////////// 82 TVector<r_8> GenWindowTOIProcessor::GetWData(int_4 numtoi) 75 83 { 76 84 if(numtoi<0 || numtoi>=NbInput) … … 81 89 } 82 90 83 TVector<int_8> GenWindowTOIProcessor::GetWFlag(int numtoi)91 TVector<int_8> GenWindowTOIProcessor::GetWFlag(int_4 numtoi) 84 92 { 85 93 if(numtoi<0 || numtoi>=NbInput) … … 90 98 } 91 99 92 r_8 * GenWindowTOIProcessor::GetWDataPointer(int numtoi)100 r_8 * GenWindowTOIProcessor::GetWDataPointer(int_4 numtoi) 93 101 { 94 102 if(numtoi<0 || numtoi>=NbInput) … … 100 108 } 101 109 102 int_8 * GenWindowTOIProcessor::GetWFlagPointer(int numtoi)110 int_8 * GenWindowTOIProcessor::GetWFlagPointer(int_4 numtoi) 103 111 { 104 112 if(numtoi<0 || numtoi>=NbInput) … … 109 117 } 110 118 111 void GenWindowTOIProcessor::GetData(int numtoi, int_8 numsample, r_8 & data, int_8 & flag)119 void GenWindowTOIProcessor::GetData(int_4 numtoi, int_8 numsample, r_8 & data, int_8 & flag) 112 120 { 113 121 if(numtoi<0 || numtoi>=NbInput) … … 115 123 if(!WInFlg[numtoi]) 116 124 throw ParmError("GenWindowTOIProcessor::GetData : toi not connected!"); 117 int_8 k = numsample-Get StartSample();125 int_8 k = numsample-GetWStartSample(); 118 126 if ((k<0) || (k >= GetWSize())) 119 127 throw RangeCheckError("GenWindowTOIProcessor::GetData : numsample out of window!"); … … 127 135 ,TVector<r_8>& data,TVector<int_8>& flag) 128 136 { 129 if(numtoi<0 || numtoi>=NbOutput )137 if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0) 130 138 throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !"); 131 139 if(!WOutFlg[numtoi]) … … 145 153 ,r_8 data,int_8 flag) 146 154 { 147 if(numtoi<0 || numtoi>=NbOutput )155 if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0) 148 156 throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !"); 149 157 if(!WOutFlg[numtoi]) … … 160 168 } 161 169 170 /******* cmv routines 171 void 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 187 void 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 //////////////////////////////////////////////////////////////// 200 void 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 245 TVector<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 255 TVector<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 265 r_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 277 int_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 162 288 //////////////////////////////////////////////////////////////// 163 289 void GenWindowTOIProcessor::UserInit(int_8 kstart) … … 181 307 cout << "GenWindowTOIProcessor::init" << endl; 182 308 char buff[64]; 183 int k;309 int_4 k; 184 310 for(k=0; k<NbInput; k++) { 185 311 sprintf(buff,"in%d", k); 186 312 declareInput(buff); 187 313 } 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 } 192 319 name = "GenWindowTOIProcessor"; 193 320 // upExtra = 1; $CHECK a quoi ca sert EA? … … 197 324 { 198 325 // 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) 202 330 throw ParmError("GenWindowTOIProcessor::run : sne-snb<WSize !"); 203 331 204 332 // Allocation des tailles pour les vecteurs 205 int kc, nc=0;333 int_4 kc, nc=0; 206 334 for(kc=0;kc<NbInput;kc++) { 207 335 if( !(WInFlg[kc]=checkInputTOIIndex(kc)) ) continue; … … 214 342 throw ParmError("GenWindowTOIProcessor::run() No input TOI connected!"); 215 343 } 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); 217 346 218 347 // Lecture des samples et remplissage des vecteurs 219 cout<<"GenWindowTOIProcessor::run() SNRange="<<SN deb<<" - "<<SNend<<endl;348 cout<<"GenWindowTOIProcessor::run() SNRange="<<SNbegin<<" - "<<SNend<<endl; 220 349 try { 221 350 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 223 355 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; 233 364 TotNsCount++; 234 365 } 235 UserEnd(SNend); 236 Ecriture(); 366 UserEnd(ksend); Ecriture(); 237 367 cout << " GenWindowTOIProcessor::run() - End of processing " << endl; 238 368 … … 249 379 // samples : sn-ws/2 sn sn+ws/2 250 380 // 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 { 392 int_4 wsz2=WSize/2; 393 394 // Numero de sample du premier element du tableau WSize 395 // (peut etre < SNbegin au debut) 396 StartSample = ks - wsz2; 397 398 // on doit avoir les samples [ks1,ks2] dans le buffer 399 // (mais selon le step, certain peuvent etre deja remplis) 400 int_8 ks1 = ks-wsz2, ks2 = ks+wsz2; 401 402 if(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 //-------------------------------------------------------- 266 411 if(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 //-------------------------------------------------------- 432 if(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) 270 435 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); 279 449 } 280 450 } 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 457 if(ks1<=LastFilledSn) ks1 = LastFilledSn+1; 458 if(DbgLevel>1) 459 cout<<"DBG-GenWindowTOIProcessor::Normal fill de ["<<ks1<<","<<ks2<<"]"<<endl; 460 for(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 } 470 CurWtIndex += ks2 - ks1 + 1; 471 LastFilledSn = ks2; 317 472 318 473 return; … … 337 492 for(kc=0; kc<NbOutput; kc++) WPutOutFlg[kc] = false; 338 493 } 494 495 //////////////////////////////////////////////////////////////// 496 void GenWindowTOIProcessor::test_avec_print(int_8 ks) 497 { 498 if(DbgLevel<=0) return; 499 500 int i,ii=0; 501 r_8 * datatot = WDataIn[0].Data(); 502 int_8 * flagtot = WFlagIn[0].Data(); 503 r_8 * data = GetWDataPointer(); 504 int_8 * flag = GetWFlagPointer(); 505 int_4 nl,nc,nr; 506 r_8 * datal = GetWDataPointer('l',nl); 507 int_8 * flagl = GetWFlagPointer('l',nl); 508 r_8 * datac = GetWDataPointer('c',nc); 509 int_8 * flagc = GetWFlagPointer('c',nc); 510 r_8 * datar = GetWDataPointer('r',nr); 511 int_8 * flagr = GetWFlagPointer('r',nr); 512 513 cout<<"-------- ks = "<<ks<<endl; 514 515 if(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 524 cout<<"data = "; 525 for(i=0;i<GetWSize();i++) {ii=0; cout<<" "<<data[i]; if(i%10==9) {cout<<endl; ii=1;}} 526 if(ii==0) cout<<endl; 527 cout<<"flag = "; 528 for(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 531 if(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 12 12 class GenWindowTOIProcessor : public TOIProcessor { 13 13 public: 14 GenWindowTOIProcessor(int nbinput,int nboutput,int wsz, int wstep=1, intwsztot=-1);14 GenWindowTOIProcessor(int_4 nbinput,int_4 nboutput,int_4 wsz, int_4 wstep=1, int_4 wsztot=-1); 15 15 virtual ~GenWindowTOIProcessor(); 16 16 17 inline int_ 8GetWSize() const { return WSize; }18 inline int_ 8GetWStep() const { return WStep; }19 inline int_ 8ProcessedSampleCount() 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; } 20 20 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;} 25 39 26 40 inline void SetDefaultValue(r_8 r8dval=0., int_8 i8dval=0) 27 41 {R8DefVal = r8dval; I8DefVal = i8dval;} 28 42 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); 34 48 inline void GetData(int_8 numsample, r_8 & data, int_8 & flag) 35 49 { GetData(0, numsample, data, flag); } 36 50 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); 39 62 inline void PutWData(int_8 numsample,TVector<r_8>& data,TVector<int_8>& flag) 40 63 {PutWData(0,numsample,data,flag);} … … 42 65 {PutWData(0,numsample,data,flag);} 43 66 44 virtual void PrintStatus(ostream & os );67 virtual void PrintStatus(ostream & os,int lp=0); 45 68 46 69 virtual void UserInit(int_8 kstart); … … 54 77 void Remplissage(int_8 ks); 55 78 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();} 60 87 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; 67 95 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 68 101 vector< TVector<r_8> > WDataIn; 69 102 vector< TVector<int_8> > WFlagIn; 103 vector< bool > WInFlg; 70 104 vector< TVector<r_8> > WDataOut; 71 105 vector< TVector<int_8> > WFlagOut; 72 vector< bool > WInFlg;73 106 vector< bool > WOutFlg; 74 107 vector< bool > WPutOutFlg; -
trunk/ArchTOIPipe/TestPipes/tgenw.cc
r1497 r1502 1 1 /* Test de GenWindowTOIProcessor (generic processor with window) 2 3 2 ---------------- Exemple d'appel --------------------- 4 csh> time ./tgenw -intoi bolo -start 1 -end 50000 -wgen 128,1,256 \ 5 bols.fits xx.fits 6 // CMV tester wgen 16,64,... 3 csh> time ./tgenw -intoi bolo -start 1 -end 50000 -wgen 16,1,64 -wlcr 0,0,0 \ 4 -dbg 0 toto.fits xx.fits 7 5 */ 8 9 10 6 11 7 #include "machdefs.h" … … 27 23 class TGenWProc : public GenWindowTOIProcessor { 28 24 public: 29 TGenWProc(int wsz, int step, int wt);25 TGenWProc(int ntoiout, int wsz, int step, int wt); 30 26 virtual void UserInit(int_8 kstart); 31 27 virtual void UserProc(int_8 ks); 32 28 virtual void UserEnd(int_8 kend); 33 29 protected: 30 int_8 SNRunning; 34 31 }; 35 32 36 TGenWProc::TGenWProc(int wsz, int step, int wt) 37 : GenWindowTOIProcessor(1,1,wsz,step,wt) 38 { 33 TGenWProc::TGenWProc(int ntoiout,int wsz, int step, int wt) 34 : GenWindowTOIProcessor(1,ntoiout,wsz,step,wt) 35 { 36 SNRunning = 1; 39 37 } 40 38 void TGenWProc::UserInit(int_8 kstart) … … 49 47 void TGenWProc::UserProc(int_8 ks) 50 48 { 51 if ( (ks == StartSampleNum()) || (ks >= EndSampleNum()-1) || (ks%1000 == 0) ) 52 cout << "TGenWProc::UserProc(" << ks << ") CenterSample=" << GetCenterSample() << endl; 53 if (GetWStep() > 1) { 49 if( ks==StartSampleNum() || ks>=EndSampleNum()-1 || ks%1000==0 ) 50 cout<<"TGenWProc::UserProc("<<ks<<") CenterSample="<<GetWCenterSample()<<endl; 51 52 // Test pour fichier cmv toto.fits (sn=100000+i, bolo=i) 53 r_8 * datatest = GetWDataPointer(); 54 for(int_4 i=0;i<WSize;i++) { 55 int_8 k=ks-WSize/2+i; 56 if(k<SNbegin || k>SNend) continue; 57 if(datatest[i]!=k-100000) {cout<<"PROBLEME ks="<<ks<<endl; break;} 58 } 59 60 if(!NbOutput) return; 61 62 if(GetWStep()==1) { 63 // Cas ou on a un step de 1 64 r_8 data; 65 int_8 flag; 66 GetData(ks,data,flag); 67 PutWData(ks,data,flag); 68 69 } else if(GetWStep()<GetWSize()) { 70 // Cas ou on a un step plus petit que la fenetre: 71 // on peut donc reconstituer le TOI original en sortie 72 // (ca marche aussi pour WStep==1 mais test different) 73 // ATTENTION: l'ordre d'ecriture depend de la taille relative 74 // de WSize et WStep. 75 // Il faut en plus faire attention au premier echantillon et au dernier 76 // Visiblement il faut ecrire autant de donnees en sortie que lues en entree (??) 77 // ===> Conduit a une logique d'une simplicite extreme: 78 // ATTENTION: dans certains cas ca bloque car il peut arriver que 79 // SNend ne soit jamais atteint selon les valeurs de WSize/WStep ! 80 // et on ne peut donc pas ecrire autant de valeurs en sortie que lues en entree 54 81 TVector<r_8> data; 55 82 TVector<int_8> flag; 56 data = GetWData()(Range(GetWSize()/2,0,GetWStep())); 57 flag = GetWFlag()(Range(GetWSize()/2,0,GetWStep())); 58 PutWData(GetCenterSample(), data, flag); 59 } 60 else { 61 // PutWData(GetCenterSample(), GetWData()(GetWSize()/2), GetWFlag()(GetWSize()/2)); 62 r_8 data; 63 int_8 flag; 64 GetData(GetCenterSample(), data, flag); 65 PutWData(GetCenterSample(), data, flag); 66 } 83 int_4 ideb,ifin,isndeb; 84 if(GetWStep()<=GetWSize()/2+1) { 85 // ------|------ 86 // ------|------ 87 // : : 88 // WStep 89 // : : 90 // d..f 91 ideb = GetWCenterIndex(); 92 isndeb = GetWCenterSample(); 93 ifin = ideb + GetWStep()-1; 94 } else { 95 // ------|------ 96 // ------|------ 97 // : : 98 // WStep 99 // : : 100 // d.........f 101 ifin = GetWSize()-1; 102 ideb = ifin - GetWStep()+1; 103 isndeb = GetWStartSample() + ideb; 104 } 105 if(isndeb<StartSampleNum()) { 106 cout<<"........ ideb="<<ideb<<" isndeb="<<isndeb<<endl; 107 ideb = StartSampleNum() - GetWStartSample(); 108 isndeb = StartSampleNum(); 109 } 110 if(GetWStartSample()+ifin>EndSampleNum()) { 111 cout<<"........ ifin="<<ifin<<endl; 112 ifin = EndSampleNum() - GetWStartSample(); 113 } 114 cout<<".... ideb="<<ideb<<" ifin="<<ifin<<" isndeb="<<isndeb<<endl; 115 data = GetWData()(Range(ideb,ifin)); 116 flag = GetWFlag()(Range(ideb,ifin)); 117 PutWData(isndeb,data,flag); 118 } else { 119 // Cas ou on ne peut reproduire le TOI initial 120 // On renumerote les samples 121 // ATTENTION: faut en mettre autant en sortie que lu en entree (???) 122 // ATTENTION: dans certains cas ca bloque car il peut arriver que 123 // SNend ne soit jamais atteint selon les valeurs de WSize/WStep ! 124 // et on ne peut donc pas ecrire autant de valeurs en sortie que lues en entree 125 // CA NE MARCHE PAS DANS CE CAS 126 TVector<r_8> data; 127 TVector<int_8> flag; 128 int_4 ideb=0, ifin=GetWSize()-1; 129 int_8 ilen = EndSampleNum() - StartSampleNum() + 1; 130 if(GetWStartSample()+ideb<StartSampleNum()) { 131 cout<<"........ ideb="<<ideb<<endl; 132 ideb = StartSampleNum() - GetWStartSample(); 133 } 134 if(GetWStartSample()+ifin>EndSampleNum()) { 135 cout<<"........ ifin="<<ifin<<endl; 136 ifin = EndSampleNum() - GetWStartSample(); 137 } 138 data = GetWData()(Range(ideb,ifin)); 139 flag = GetWFlag()(Range(ideb,ifin)); 140 cout<<".... ideb="<<ideb<<" ifin="<<ifin<<" SNRunning="<<SNRunning<<endl; 141 PutWData(SNRunning,data,flag); 142 SNRunning += ifin-ideb+1; 143 if(SNRunning<=ilen && GetWStep()-GetWSize()>0) { 144 for(int_4 i=0;i<GetWStep()-GetWSize() && SNRunning<=ilen;i++) 145 {PutWData(SNRunning,0.,0); SNRunning++;} 146 // De toute facon impossible a faire puisque 147 // ce putwdata efface le vecteur du putwdata precedent 148 } 149 cout<<".................... SNRunning="<<SNRunning<<endl; 150 } 151 // Oh que voila une logique simple et utilisable par tout un chacun !!! 67 152 } 68 153 … … 75 160 } 76 161 else { 77 cout << "\n Usage : tgenw [- dbg] [-start snb] [-end sne] [-intoi name] \n"162 cout << "\n Usage : tgenw [-prt] [-dbg dbg] [-start snb] [-end sne] [-intoi name] \n" 78 163 << " [-wtoi sz] [-wgen sz,step,szt] inFitsName outFitsName \n" 79 << " -dbg : sets TOISeqBuffered debug level to 1 \n" 164 << " -prt : sets TOISeqBuffered debug level to 1 \n" 165 << " -dbg : debug level for GenWProc \n" 80 166 << " -start snb : sets the start sample num \n" 81 167 << " -end sne : sets the end sample num \n" … … 83 169 << " -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n" 84 170 << " -wgen sz,step,szt : sets GenWProc window size, step total size \n" 171 << " -wlcr szl,szc,szr : sets LCR Window \n" 85 172 << endl; 86 173 exit(0); … … 96 183 bool fgdbg = false; 97 184 bool fgsetstart = false; 185 int dbglevel = 0; 98 186 int wtoi = 8192; 99 187 int wgen = 16; 100 188 int stepgen = 1; 189 int wgl = 0, wgc = 0, wgr = 0; 101 190 int wtotgen = 0; 102 191 int istart = 0; 103 192 int iend = 0; 104 193 string infile; 105 string outfile ;194 string outfile = ""; 106 195 string outppfname; 107 196 string intoi = "boloMuV_27"; 108 197 109 if (narg < 3) Usage(true);198 if (narg < 2) Usage(true); 110 199 int ko=1; 111 200 // decoding arguments … … 128 217 sscanf(arg[ia+1],"%d,%d,%d",&wgen,&stepgen,&wtotgen); ia++; 129 218 } 219 else if (strcmp(arg[ia],"-wlcr") == 0) { 220 if (ia == narg-1) Usage(true); 221 sscanf(arg[ia+1],"%d,%d,%d",&wgl,&wgc,&wgr); ia++; 222 } 130 223 else if (strcmp(arg[ia],"-intoi") == 0) { 131 224 if (ia == narg-1) Usage(true); 132 225 intoi = arg[ia+1]; ia++; 133 226 } 134 else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true; 227 else if (strcmp(arg[ia],"-dbg") == 0) { 228 if (ia == narg-1) Usage(true); 229 sscanf(arg[ia+1],"%d",&dbglevel); ia++; 230 } 231 else if (strcmp(arg[ia],"-prt") == 0) fgdbg = true; 135 232 136 233 else { ko = ia; break; } // Debut des noms … … 138 235 139 236 if (iend < istart) iend = istart+wtoi*10; 140 if ((narg-ko) < 2) Usage(true);237 if ((narg-ko) < 1) Usage(true); 141 238 infile = arg[ko]; 142 outfile = arg[ko+1];143 // 239 if(ko+1<narg) outfile = arg[ko+1]; 240 // outppfname = arg[ko+2]; 144 241 145 242 cout << " Initializing SOPHYA ... " << endl; … … 150 247 << outfile << endl; 151 248 cout << ">>> Window Size WTOI= " << wtoi << " WGenSz= " << wgen 152 << " StepGen=" << stepgen << " WTot=" << wtotgen << endl; 249 << " StepGen=" << stepgen << " WTot=" << wtotgen 250 << " Wglcr=" << wgl << "," << wgc << "," << wgr << endl; 153 251 cout << ">>>> InTOIName= " << intoi 154 252 << " iStart= " << istart << " iEnd= " << iend << endl; … … 159 257 // mgr->setRequestedSample(11680920,11710584); 160 258 // mgr->setRequestedSample(104121000, 104946120); 161 if (fgsetstart) 259 if (fgsetstart) 162 260 mgr->setRequestedSample(istart, iend); 163 261 164 262 FITSTOIReader r(infile); 165 263 cout << "reader created" << endl; 166 FITSTOIWriter w(outfile); 167 cout << "fits writer created" << endl; 168 264 265 int ntoiout=0; 266 FITSTOIWriter* w=NULL; 267 if(outfile.size()>0) { 268 ntoiout=1; 269 w = new FITSTOIWriter(outfile); 270 w->setOutFlags(true); 271 cout << "fits writer created" << endl; 272 } 169 273 170 274 TOISeqBuffered * toiin = new TOISeqBuffered("f2in", wtoi); 171 275 if (fgdbg) toiin->setDebugLevel(1); 172 276 277 TOISeqBuffered * toiout = NULL; 278 if(w) { 279 toiout = new TOISeqBuffered("genout", wtoi); 280 if (fgdbg) toiout->setDebugLevel(1); 281 } 282 283 TGenWProc tgenp(ntoiout, wgen, stepgen, wtotgen); 284 tgenp.SetWSizeLCR(wgl,wgc,wgr); 285 tgenp.SetDbgLevel(dbglevel); 286 173 287 cout << " Connecting to FitsReader ... " << endl; 174 288 r.addOutput(intoi, toiin); 175 289 176 TOISeqBuffered * toiout = new TOISeqBuffered("genout", wtoi); 177 if (fgdbg) toiout->setDebugLevel(1); 178 TGenWProc tgenp(wgen, stepgen, wtotgen); 290 if(w && toiout) { 291 cout << " Connecting to FitsWriter ... " << endl; 292 w->addInput("genout",toiout); 293 } 179 294 180 295 cout << " Connecting TGenWProc ... " << endl; 181 296 tgenp.addInput("in0",toiin); 182 tgenp.addOutput("out0",toiout); 183 184 cout << tgenp; 185 186 w.addInput("genout", toiout); 297 if(toiout) tgenp.addOutput("out0",toiout); 298 tgenp.PrintStatus(cout,1); 187 299 188 300 PrtTim("starting threads"); 189 301 r.start(); 190 302 tgenp.start(); 191 w.start(); 192 303 if(w) w->start(); 193 304 194 305 /* 195 306 for(int jj=0; jj<3; jj++) { 196 307 cout << *toiin; 197 cout << *toiout;308 if(toiout) cout << *toiout; 198 309 sleep(1); 199 310 } 200 311 */ 201 202 203 204 312 205 313 mgr->joinAll(); … … 209 317 // r.PrintStatus(cout); 210 318 // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl; 211 // w .PrintStatus(cout);319 // w->PrintStatus(cout); 212 320 213 321 cout << " ------ toiin, toiout Status information ------- " << endl; 214 322 cout << *toiin; 215 cout << *toiout; 216 217 cout << tgenp; 218 323 if(toiout) cout << *toiout; 324 tgenp.PrintStatus(cout); 325 326 // Fermeture du fitswriter 327 if(w) delete w;; 328 219 329 } 220 330 catch (PThrowable & exc) {
Note:
See TracChangeset
for help on using the changeset viewer.