Changeset 1496 in Sophya for trunk/ArchTOIPipe/ProcWSophya
- Timestamp:
- May 16, 2001, 4:26:28 PM (24 years ago)
- Location:
- trunk/ArchTOIPipe/ProcWSophya
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/ProcWSophya/genwproc.cc
r1495 r1496 6 6 #include "ctimer.h" 7 7 8 9 // #define DEBUGGENW 1 10 8 11 // ------------------------------------------------------------- 9 12 // Class GenWindowTOIProcessor : generic processor with window … … 19 22 if(wsz%2==0) wsz++; 20 23 if(wstep<1) wstep=1; 21 if(wsztot<wsz) wsztot = 2*wsz; 24 if(wsztot<wsz) wsztot = 2*wsz; // CMV prise de decision wsztot / wstep 22 25 23 26 NbInput = nbinput; … … 27 30 WSizeTot = wsztot; 28 31 29 SNdeb = SNend = StartSample = Cur SnInd= -1;32 SNdeb = SNend = StartSample = CurWtIndex = -1; 30 33 TotNsCount = 0; 31 34 32 TVector<r_8> vr8; 33 TVector<int_8> vi8; 35 SetDefaultValue(); 36 37 TVector<r_8> vr8(1); // CMV+RZ supprimer taille(1) apres correction de 38 TVector<int_8> vi8(1); // constructeur copie de TArray (taille nulle) 34 39 35 40 int k; … … 44 49 WOutFlg.push_back(false); 45 50 WPutOutFlg.push_back(false); 51 WPutOutOwnVector.push_back(false); 46 52 OutSample.push_back(0); 47 53 } … … 71 77 throw RangeCheckError("GenWindowTOIProcessor::GetWData : toi out of range !"); 72 78 if(!WInFlg[numtoi]) 73 throw RangeCheckError("GenWindowTOIProcessor::GetWData : toi not connected!");74 return WDataIn[numtoi];79 throw ParmError("GenWindowTOIProcessor::GetWData : toi not connected!"); 80 return (WDataIn[numtoi])(Range(StartWtIndex(),0,WSize)); 75 81 } 76 82 … … 80 86 throw RangeCheckError("GenWindowTOIProcessor::GetWFlag : toi out of range !"); 81 87 if(!WInFlg[numtoi]) 82 throw RangeCheckError("GenWindowTOIProcessor::GetWFlag : toi not connected!"); 83 return WFlagIn[numtoi]; 88 throw ParmError("GenWindowTOIProcessor::GetWFlag : toi not connected!"); 89 return (WFlagIn[numtoi])(Range(StartWtIndex(),0,WSize)); 90 } 91 92 r_8 * GenWindowTOIProcessor::GetWDataPointer(int numtoi) 93 { 94 if(numtoi<0 || numtoi>=NbInput) 95 throw RangeCheckError("GenWindowTOIProcessor::GetWDataPointer : toi out of range !"); 96 if(!WInFlg[numtoi]) 97 throw ParmError("GenWindowTOIProcessor::GetWDataPointer : toi not connected!"); 98 return (WDataIn[numtoi].Data()+StartWtIndex()); 99 100 } 101 102 int_8 * GenWindowTOIProcessor::GetWFlagPointer(int numtoi) 103 { 104 if(numtoi<0 || numtoi>=NbInput) 105 throw RangeCheckError("GenWindowTOIProcessor::GetWFlagPointer : toi out of range !"); 106 if(!WInFlg[numtoi]) 107 throw ParmError("GenWindowTOIProcessor::GetWFlagPointer : toi not connected!"); 108 return (WFlagIn[numtoi].Data()+StartWtIndex()); 109 } 110 111 void GenWindowTOIProcessor::GetData(int numtoi, int_8 numsample, r_8 & data, int_8 & flag) 112 { 113 if(numtoi<0 || numtoi>=NbInput) 114 throw RangeCheckError("GenWindowTOIProcessor::GetData : toi out of range !"); 115 if(!WInFlg[numtoi]) 116 throw ParmError("GenWindowTOIProcessor::GetData : toi not connected!"); 117 int_8 k = numsample-GetStartSample(); 118 if ((k<0) || (k >= GetWSize())) 119 throw RangeCheckError("GenWindowTOIProcessor::GetData : numsample out of window!"); 120 k += StartWtIndex(); 121 data = (WDataIn[numtoi])(k); 122 flag = (WFlagIn[numtoi])(k); 84 123 } 85 124 … … 91 130 throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !"); 92 131 if(!WOutFlg[numtoi]) 93 throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi not connected!");132 throw ParmError("GenWindowTOIProcessor::PutWFlag : toi not connected!"); 94 133 if(data.Size()!=flag.Size()) 95 134 throw ParmError("GenWindowTOIProcessor::PutWFlag : data.Size()!=flag.Size()!"); 135 if(data.Size() == 0) 136 throw ParmError("GenWindowTOIProcessor::PutWFlag : data.Size()==0 !"); 96 137 WDataOut[numtoi].Share(data); 97 138 WFlagOut[numtoi].Share(flag); 98 139 OutSample[numtoi] = numsample; 99 140 WPutOutFlg[numtoi] = true; 141 WPutOutOwnVector[numtoi] = false; 100 142 } 101 143 … … 106 148 throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !"); 107 149 if(!WOutFlg[numtoi]) 108 throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi not connected!"); 109 WDataOut[numtoi].Realloc(1,BaseArray::SameVectorType,true); 110 (WDataOut[numtoi])(0) = data; 111 WFlagOut[numtoi].Realloc(1,BaseArray::SameVectorType,true); 112 (WFlagOut[numtoi])(0) = flag; 150 throw ParmError("GenWindowTOIProcessor::PutWFlag : toi not connected!"); 151 if (!WPutOutOwnVector[numtoi]) { 152 WDataOut[numtoi].Realloc(1,BaseArray::SameVectorType,true); 153 WFlagOut[numtoi].Realloc(1,BaseArray::SameVectorType,true); 154 WPutOutOwnVector[numtoi] = true; 155 } 156 (WDataOut[numtoi])(0) = data; 157 (WFlagOut[numtoi])(0) = flag; 113 158 OutSample[numtoi] = numsample; 114 159 WPutOutFlg[numtoi] = true; … … 116 161 117 162 //////////////////////////////////////////////////////////////// 118 void GenWindowTOIProcessor::UserInit( )163 void GenWindowTOIProcessor::UserInit(int_8 kstart) 119 164 { 120 165 cout<<"GenWindowTOIProcessor::UserInit() Default implementation does nothing"<<endl; 121 166 } 122 167 123 void GenWindowTOIProcessor::UserProc( )168 void GenWindowTOIProcessor::UserProc(int_8 ks) 124 169 { 125 170 cout<<"GenWindowTOIProcessor:UserProc() Default implementation does nothing"<<endl; 126 171 } 127 172 128 void GenWindowTOIProcessor::UserEnd( )173 void GenWindowTOIProcessor::UserEnd(int_8 kend) 129 174 { 130 175 cout<<"GenWindowTOIProcessor::UserEnd() Default implementation does nothing"<<endl; … … 152 197 { 153 198 // TOIManager* mgr = TOIManager::getManager(); 154 int_8SNdeb = getMinIn();155 int_8SNend = getMaxIn();199 SNdeb = getMinIn(); 200 SNend = getMaxIn(); 156 201 if(SNend-SNdeb<WSize) 157 throw RangeCheckError("GenWindowTOIProcessor::run : sne-snb<WSize !");202 throw ParmError("GenWindowTOIProcessor::run : sne-snb<WSize !"); 158 203 159 204 // Allocation des tailles pour les vecteurs … … 169 214 throw ParmError("GenWindowTOIProcessor::run() No input TOI connected!"); 170 215 } 171 for(kc=0;kc<NbOutput;kc++) 172 WOutFlg[kc] = checkOutputTOIIndex(kc); 216 for(kc=0;kc<NbOutput;kc++) WOutFlg[kc] = checkOutputTOIIndex(kc); 173 217 174 218 // Lecture des samples et remplissage des vecteurs … … 176 220 try { 177 221 Timer tm("GenWindowTOIProcessor::run()"); 178 int_8 ki = -1; 179 180 for(int_8 ks=SNdeb;ks<=SNend;ks++) { 222 for(int_8 ks=SNdeb;ks<=SNend;ks++) { // CMV gerer le += step 181 223 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 } 182 233 TotNsCount++; 183 234 } 235 UserEnd(SNend); 236 Ecriture(); 184 237 cout << " GenWindowTOIProcessor::run() - End of processing " << endl; 185 238 186 239 } catch(PException & exc) { 187 cerr<<"GenWindowTOIProcessor: Catched Exception "<<(string)typeid(exc).name()240 cerr<<"GenWindowTOIProcessor::run Catched Exception "<<(string)typeid(exc).name() 188 241 <<"\n .... Msg= "<<exc.Msg()<<endl; 189 242 } … … 196 249 // samples : sn-ws/2 sn sn+ws/2 197 250 // fenetre : 0 ws/2+1 ws-1 198 // ki : index des vecteurs a remplir. 199 // C'est l'index ou on veut remplir la donnee 200 // dans un vecteur (fictif) de taille WSize. 201 // La routine gere le decalage dans le grand buffer WSizeTot. 202 // Si ki depasse la taille maximale permise on decale, sinon on ne fait rien 203 // RETURN: 204 // numero du PROCHAIN index a remplir (ki+1 si pas decale !) 205 { 206 if(ks<SNdeb || ks>SNend) 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; 207 259 throw RangeCheckError("GenWindowTOIProcessor::remplissage : ks<SNdeb || ks>SNend !"); 208 260 } 209 261 int_8 wsz2=WSize/2; 210 262 … … 212 264 213 265 // Premier remplissage ???? Gestion de la borne inferieure 214 if(CurSnInd<0) { 215 CurSnInd = 0; 266 if(CurWtIndex<0) { 267 #ifdef DEBUGGENW 268 cout << "GenWindowTOIProcessor::Remplissage 1ere fois" << endl; 269 #endif 270 CurWtIndex = 0; 216 271 for(int_8 k=ks-wsz2; k<=ks+wsz2; k++) { // Lecture TOI 217 272 for(int kc=0; kc<NbInput; kc++) { 218 273 if(!WInFlg[kc]) continue; 219 274 if(k>=SNdeb && k<=SNend) { 220 getData(kc,k,(WDataIn[kc])(Cur SnInd), (WFlagIn[kc])(CurSnInd));275 getData(kc,k,(WDataIn[kc])(CurWtIndex), (WFlagIn[kc])(CurWtIndex)); 221 276 } else { 222 (WDataIn[kc])(Cur SnInd) = (r_8) 0.;223 (WFlagIn[kc])(Cur SnInd) = (int_8) 0;277 (WDataIn[kc])(CurWtIndex) = R8DefVal; 278 (WFlagIn[kc])(CurWtIndex) = I8DefVal; 224 279 } 225 280 } 226 Cur SnInd++;281 CurWtIndex++; 227 282 } 228 283 return; 229 284 } 230 285 286 // CMV gere decalage seulement si step < wsize sinon copie. 231 287 // Faut-il decaler ???? 232 if(CurSnInd == WSizeTot) { // On decale 288 if(CurWtIndex == WSizeTot) { // On decale 289 #ifdef DEBUGGENW 290 cout << "GenWindowTOIProcessor::Remplissage Decalage " << endl; 291 #endif 233 292 for(int kc=0; kc<NbInput; kc++) { 234 293 if(!WInFlg[kc]) continue; … … 238 297 } 239 298 } 240 Cur SnInd= WSize-1;299 CurWtIndex = WSize-1; 241 300 } 242 301 243 302 // Remplissage de ks+wsz2 (dernier element de la fenetre pour ks central) 244 303 int_8 kse = ks+wsz2; 304 #ifdef DEBUGGENW 305 cout << "GenWindowTOIProcessor::Normal fill " << endl; 306 #endif 245 307 for(int kc=0; kc<NbInput; kc++) { 246 308 if(!WInFlg[kc]) continue; 247 309 if(kse>=SNdeb && kse<=SNend) { 248 getData(kc,kse,(WDataIn[kc])(Cur SnInd),(WFlagIn[kc])(CurSnInd));310 getData(kc,kse,(WDataIn[kc])(CurWtIndex),(WFlagIn[kc])(CurWtIndex)); 249 311 } else { 250 (WDataIn[kc])(Cur SnInd) = (r_8) 0.;251 (WFlagIn[kc])(Cur SnInd) = (int_8) 0;252 } 253 } 254 Cur SnInd++;312 (WDataIn[kc])(CurWtIndex) = R8DefVal; 313 (WFlagIn[kc])(CurWtIndex) = I8DefVal; 314 } 315 } 316 CurWtIndex++; 255 317 256 318 return; 257 319 } 320 321 void GenWindowTOIProcessor::Ecriture() 322 { 323 int_8 maxlenout = 0; 324 int kc; 325 for(kc=0; kc<NbOutput; kc++) 326 if(WOutFlg[kc] && WPutOutFlg[kc] && (WDataOut[kc].Size() > maxlenout) ) 327 maxlenout = WDataOut[kc].Size(); 328 329 for(int_8 k=0; k<maxlenout; k++) { 330 for(int kc=0; kc<NbOutput; kc++) { 331 if(!WOutFlg[kc]) continue; 332 if(!WPutOutFlg[kc]) continue; 333 if(k>=WDataOut[kc].Size()) continue; 334 putData(kc, k+OutSample[kc], (WDataOut[kc])(k), (WFlagOut[kc])(k)); 335 } 336 } 337 for(kc=0; kc<NbOutput; kc++) WPutOutFlg[kc] = false; 338 } -
trunk/ArchTOIPipe/ProcWSophya/genwproc.h
r1495 r1496 13 13 public: 14 14 GenWindowTOIProcessor(int nbinput,int nboutput,int wsz, int wstep=1, int wsztot=-1); 15 ~GenWindowTOIProcessor();15 virtual ~GenWindowTOIProcessor(); 16 16 17 17 inline int_8 GetWSize() const { return WSize; } … … 21 21 inline int_8 GetStartSample() {return StartSample;} 22 22 inline int_8 GetCenterSample() {return StartSample + WSize/2;} 23 inline int_8 StartSampleNum() { return SNdeb; } 24 inline int_8 EndSampleNum() { return SNend; } 25 26 inline void SetDefaultValue(r_8 r8dval=0., int_8 i8dval=0) 27 {R8DefVal = r8dval; I8DefVal = i8dval;} 28 23 29 TVector<r_8> GetWData(int numtoi=0); 24 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); 34 inline void GetData(int_8 numsample, r_8 & data, int_8 & flag) 35 { GetData(0, numsample, data, flag); } 36 25 37 void PutWData(int numtoi,int_8 numsample,TVector<r_8>& data,TVector<int_8>& flag); 26 38 void PutWData(int numtoi,int_8 numsample,r_8 data,int_8 flag); … … 32 44 virtual void PrintStatus(ostream & os); 33 45 34 virtual void UserInit( );35 virtual void UserProc( );36 virtual void UserEnd( );46 virtual void UserInit(int_8 kstart); 47 virtual void UserProc(int_8 ks); 48 virtual void UserEnd(int_8 kend); 37 49 38 50 virtual void init(); … … 41 53 protected: 42 54 void Remplissage(int_8 ks); 43 inline int_8 StartSnIndex() 44 {if(CurSnInd<0) return -1; else return CurSnInd-WSize;} 45 inline int_8 CenterSnIndex() 46 {if(CurSnInd<0) return -1; else return CurSnInd-(WSize+1)/2;} 55 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;} 47 60 48 61 int NbInput,NbOutput; 49 62 int_8 WSizeTot,WSize,WStep; 50 63 int_8 SNdeb,SNend; 51 int_8 StartSample,Cur SnInd;64 int_8 StartSample,CurWtIndex; 52 65 int_8 TotNsCount; 66 r_8 R8DefVal; 67 int_8 I8DefVal; 53 68 vector< TVector<r_8> > WDataIn; 54 69 vector< TVector<int_8> > WFlagIn; … … 58 73 vector< bool > WOutFlg; 59 74 vector< bool > WPutOutFlg; 75 vector< bool > WPutOutOwnVector; 60 76 vector< int_8 > OutSample; 61 77 };
Note:
See TracChangeset
for help on using the changeset viewer.