#include "array.h" #include #include "genwproc.h" #include "toimanager.h" #include "pexceptions.h" #include "ctimer.h" // #define DEBUGGENW 1 // ------------------------------------------------------------- // Class GenWindowTOIProcessor : generic processor with window // ------------------------------------------------------------- //////////////////////////////////////////////////////////////// GenWindowTOIProcessor::GenWindowTOIProcessor(int nbinput,int nboutput ,int wsz, int wstep, int wsztot) { if(nbinput<1) throw ParmError("GenWindowTOIProcessor::Creator nbinput<1 !"); if(nboutput<0) nboutput=0; if(wsz<2) throw ParmError("GenWindowTOIProcessor::Creator wsz<2 !"); if(wsz%2==0) wsz++; if(wstep<1) wstep=1; if(wsztot vr8(1); // CMV+RZ supprimer taille(1) apres correction de TVector vi8(1); // constructeur copie de TArray (taille nulle) int k; for(k=0;k GenWindowTOIProcessor::GetWData(int numtoi) { if(numtoi<0 || numtoi>=NbInput) throw RangeCheckError("GenWindowTOIProcessor::GetWData : toi out of range !"); if(!WInFlg[numtoi]) throw ParmError("GenWindowTOIProcessor::GetWData : toi not connected!"); return (WDataIn[numtoi])(Range(StartWtIndex(),0,WSize)); } TVector GenWindowTOIProcessor::GetWFlag(int numtoi) { if(numtoi<0 || numtoi>=NbInput) throw RangeCheckError("GenWindowTOIProcessor::GetWFlag : toi out of range !"); if(!WInFlg[numtoi]) throw ParmError("GenWindowTOIProcessor::GetWFlag : toi not connected!"); return (WFlagIn[numtoi])(Range(StartWtIndex(),0,WSize)); } r_8 * GenWindowTOIProcessor::GetWDataPointer(int numtoi) { if(numtoi<0 || numtoi>=NbInput) throw RangeCheckError("GenWindowTOIProcessor::GetWDataPointer : toi out of range !"); if(!WInFlg[numtoi]) throw ParmError("GenWindowTOIProcessor::GetWDataPointer : toi not connected!"); return (WDataIn[numtoi].Data()+StartWtIndex()); } int_8 * GenWindowTOIProcessor::GetWFlagPointer(int numtoi) { if(numtoi<0 || numtoi>=NbInput) throw RangeCheckError("GenWindowTOIProcessor::GetWFlagPointer : toi out of range !"); if(!WInFlg[numtoi]) throw ParmError("GenWindowTOIProcessor::GetWFlagPointer : toi not connected!"); return (WFlagIn[numtoi].Data()+StartWtIndex()); } void GenWindowTOIProcessor::GetData(int numtoi, int_8 numsample, r_8 & data, int_8 & flag) { if(numtoi<0 || numtoi>=NbInput) throw RangeCheckError("GenWindowTOIProcessor::GetData : toi out of range !"); if(!WInFlg[numtoi]) throw ParmError("GenWindowTOIProcessor::GetData : toi not connected!"); int_8 k = numsample-GetStartSample(); if ((k<0) || (k >= GetWSize())) throw RangeCheckError("GenWindowTOIProcessor::GetData : numsample out of window!"); k += StartWtIndex(); data = (WDataIn[numtoi])(k); flag = (WFlagIn[numtoi])(k); } //////////////////////////////////////////////////////////////// void GenWindowTOIProcessor::PutWData(int numtoi,int_8 numsample ,TVector& data,TVector& flag) { if(numtoi<0 || numtoi>=NbOutput) throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !"); if(!WOutFlg[numtoi]) throw ParmError("GenWindowTOIProcessor::PutWFlag : toi not connected!"); if(data.Size()!=flag.Size()) throw ParmError("GenWindowTOIProcessor::PutWFlag : data.Size()!=flag.Size()!"); if(data.Size() == 0) throw ParmError("GenWindowTOIProcessor::PutWFlag : data.Size()==0 !"); WDataOut[numtoi].Share(data); WFlagOut[numtoi].Share(flag); OutSample[numtoi] = numsample; WPutOutFlg[numtoi] = true; WPutOutOwnVector[numtoi] = false; } void GenWindowTOIProcessor::PutWData(int numtoi,int_8 numsample ,r_8 data,int_8 flag) { if(numtoi<0 || numtoi>=NbOutput) throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !"); if(!WOutFlg[numtoi]) throw ParmError("GenWindowTOIProcessor::PutWFlag : toi not connected!"); if (!WPutOutOwnVector[numtoi]) { WDataOut[numtoi].Realloc(1,BaseArray::SameVectorType,true); WFlagOut[numtoi].Realloc(1,BaseArray::SameVectorType,true); WPutOutOwnVector[numtoi] = true; } (WDataOut[numtoi])(0) = data; (WFlagOut[numtoi])(0) = flag; OutSample[numtoi] = numsample; WPutOutFlg[numtoi] = true; } //////////////////////////////////////////////////////////////// void GenWindowTOIProcessor::UserInit(int_8 kstart) { cout<<"GenWindowTOIProcessor::UserInit() Default implementation does nothing"<" << SNend << endl; throw RangeCheckError("GenWindowTOIProcessor::remplissage : ksSNend !"); } int_8 wsz2=WSize/2; StartSample = ks - wsz2; // peut etre < snb au debut // Premier remplissage ???? Gestion de la borne inferieure if(CurWtIndex<0) { #ifdef DEBUGGENW cout << "GenWindowTOIProcessor::Remplissage 1ere fois" << endl; #endif CurWtIndex = 0; for(int_8 k=ks-wsz2; k<=ks+wsz2; k++) { // Lecture TOI for(int kc=0; kc=SNdeb && k<=SNend) { getData(kc,k,(WDataIn[kc])(CurWtIndex), (WFlagIn[kc])(CurWtIndex)); } else { (WDataIn[kc])(CurWtIndex) = R8DefVal; (WFlagIn[kc])(CurWtIndex) = I8DefVal; } } CurWtIndex++; } return; } // CMV gere decalage seulement si step < wsize sinon copie. // Faut-il decaler ???? if(CurWtIndex == WSizeTot) { // On decale #ifdef DEBUGGENW cout << "GenWindowTOIProcessor::Remplissage Decalage " << endl; #endif for(int kc=0; kc=SNdeb && kse<=SNend) { getData(kc,kse,(WDataIn[kc])(CurWtIndex),(WFlagIn[kc])(CurWtIndex)); } else { (WDataIn[kc])(CurWtIndex) = R8DefVal; (WFlagIn[kc])(CurWtIndex) = I8DefVal; } } CurWtIndex++; return; } void GenWindowTOIProcessor::Ecriture() { int_8 maxlenout = 0; int kc; for(kc=0; kc maxlenout) ) maxlenout = WDataOut[kc].Size(); for(int_8 k=0; k=WDataOut[kc].Size()) continue; putData(kc, k+OutSample[kc], (WDataOut[kc])(k), (WFlagOut[kc])(k)); } } for(kc=0; kc