Changeset 1124
- Timestamp:
- 05/05/17 08:58:37 (7 years ago)
- Location:
- XIOS/trunk/src/filter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/filter/temporal_filter.cpp
r1123 r1124 12 12 : CFilter(gc, 1, this) 13 13 , functor(createFunctor(opId, ignoreMissingValue, missingValue, tmpData)) 14 , isOnceOperation(functor->timeType() == func::CFunctor::once) 15 , isInstantOperation(functor->timeType() == func::CFunctor::instant) 14 16 // If we can optimize the sampling when dealing with an instant functor we do it 15 , samplingFreq(( functor->timeType() == func::CFunctor::instant&& samplingFreq == TimeStep && samplingOffset == NoneDu) ? opFreq : samplingFreq)16 , samplingOffset(( functor->timeType() == func::CFunctor::instant&& samplingFreq == TimeStep && samplingOffset == NoneDu) ? opFreq - initDate.getRelCalendar().getTimeStep() : samplingOffset)17 , samplingFreq((isInstantOperation && samplingFreq == TimeStep && samplingOffset == NoneDu) ? opFreq : samplingFreq) 18 , samplingOffset((isInstantOperation && samplingFreq == TimeStep && samplingOffset == NoneDu) ? opFreq - initDate.getRelCalendar().getTimeStep() : samplingOffset) 17 19 , opFreq(opFreq) 18 20 , nextSamplingDate(initDate + this->samplingOffset + initDate.getRelCalendar().getTimeStep()) 19 21 , nextOperationDate(initDate + this->samplingOffset + opFreq) 20 22 , isFirstOperation(true) 21 , isOnceOperation(functor->timeType() == func::CFunctor::once)22 23 { 23 24 } … … 29 30 if (data[0]->status != CDataPacket::END_OF_STREAM) 30 31 { 31 const bool usePacket = isOnceOperation ? isFirstOperation : (data[0]->date >= nextSamplingDate); 32 bool usePacket, outputResult, copyLess; 33 if (isOnceOperation) 34 usePacket = outputResult = copyLess = isFirstOperation; 35 else 36 { 37 usePacket = (data[0]->date >= nextSamplingDate); 38 outputResult = (data[0]->date + samplingFreq > nextOperationDate); 39 copyLess = (isInstantOperation && usePacket && outputResult); 40 } 41 32 42 if (usePacket) 33 43 { 34 if (!tmpData.numElements()) 35 tmpData.resize(data[0]->data.numElements()); 44 if (!copyLess) 45 { 46 if (!tmpData.numElements()) 47 tmpData.resize(data[0]->data.numElements()); 36 48 37 (*functor)(data[0]->data); 49 (*functor)(data[0]->data); 50 } 38 51 39 52 nextSamplingDate = nextSamplingDate + samplingFreq; 40 53 } 41 54 42 const bool outputResult = isOnceOperation ? isFirstOperation : (data[0]->date + samplingFreq > nextOperationDate);43 55 if (outputResult) 44 56 { 45 functor->final(); 57 if (!copyLess) 58 { 59 functor->final(); 46 60 47 packet = CDataPacketPtr(new CDataPacket); 48 packet->date = data[0]->date; 49 packet->timestamp = data[0]->timestamp; 50 packet->status = data[0]->status; 51 packet->data.resize(tmpData.numElements()); 52 packet->data = tmpData; 61 packet = CDataPacketPtr(new CDataPacket); 62 packet->date = data[0]->date; 63 packet->timestamp = data[0]->timestamp; 64 packet->status = data[0]->status; 65 packet->data.resize(tmpData.numElements()); 66 packet->data = tmpData; 67 } 68 else 69 packet = data[0]; 53 70 54 71 isFirstOperation = false; -
XIOS/trunk/src/filter/temporal_filter.hpp
r1123 r1124 57 57 bool isFirstOperation; //!< True before the first operation was been computed 58 58 const bool isOnceOperation; //!< True if the operation should be computed just once 59 const bool isInstantOperation; //!< True if the operation is instant 59 60 }; // class CTemporalFilter 60 61 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.