Commit d85350c399b44c614bb11b54170bd9a97b8a711b
1 parent
1b3811f0
Exists in
master
and in
98 other branches
Add no data suport for local data ParamGet (#6094)
Showing
5 changed files
with
108 additions
and
5 deletions
Show diff stats
src/ParamGetImpl/LocalFileInterface/LocalParamData.hh
... | ... | @@ -67,7 +67,7 @@ public: |
67 | 67 | */ |
68 | 68 | LocalParamDataPacket(void) : _isInit(false), _containerType(CONTAINER_SCALAR), |
69 | 69 | _paramType(TYPE_UNKNOWN), _nbData(0), _nbMaxData(0), _dims(NULL), _size(0), |
70 | - _times(NULL), _datas(NULL) | |
70 | + _times(NULL), _datas(NULL), _noData(false), _startTime(0.), _stopTime(0.) | |
71 | 71 | { |
72 | 72 | } |
73 | 73 | |
... | ... | @@ -407,6 +407,24 @@ public: |
407 | 407 | return true; |
408 | 408 | } |
409 | 409 | |
410 | + bool isNoData() { | |
411 | + return _noData; | |
412 | + } | |
413 | + | |
414 | + double getStartTime() { | |
415 | + return _startTime; | |
416 | + } | |
417 | + | |
418 | + double getStopTime() { | |
419 | + return _stopTime; | |
420 | + } | |
421 | + | |
422 | + void setNoData(double startTime, double stopTime) { | |
423 | + _noData = true; | |
424 | + _startTime = startTime; | |
425 | + _stopTime = stopTime; | |
426 | + } | |
427 | + | |
410 | 428 | private: |
411 | 429 | /* |
412 | 430 | * @brief Flag to know if the packet is init |
... | ... | @@ -452,6 +470,12 @@ private: |
452 | 470 | * @brief record data buffer |
453 | 471 | */ |
454 | 472 | void* _datas; |
473 | + | |
474 | + bool _noData; | |
475 | + | |
476 | + double _startTime; | |
477 | + | |
478 | + double _stopTime; | |
455 | 479 | }; |
456 | 480 | |
457 | 481 | } /* LocalFileInterface */ | ... | ... |
src/ParamGetImpl/LocalFileInterface/ParamGetLocalFile.cc
... | ... | @@ -135,7 +135,17 @@ unsigned int ParamGetLocalFile::write() |
135 | 135 | if (lPacket) { |
136 | 136 | _pusher->setFillValue(_fillValue); |
137 | 137 | do { |
138 | - result += _pusher->put(lPacket); | |
138 | + if (lPacket->isNoData()) { | |
139 | + LOG4CXX_DEBUG(gLogger, "ParamGetLocalFile::write => no data packet"); | |
140 | + _paramData->getTimeList().push_back(lPacket->getStartTime()); | |
141 | + _pusher->putNaN(); | |
142 | + _paramData->getTimeList().push_back(lPacket->getStopTime()); | |
143 | + _pusher->putNaN(); | |
144 | + result += 2; | |
145 | + } | |
146 | + else { | |
147 | + result += _pusher->put(lPacket); | |
148 | + } | |
139 | 149 | delete lPacket; |
140 | 150 | lPacket = _paramFlow->tryGet(_paramId); |
141 | 151 | } while(lPacket); | ... | ... |
src/ParamGetImpl/LocalFileInterface/Pusher.hh
... | ... | @@ -60,6 +60,8 @@ public: |
60 | 60 | */ |
61 | 61 | virtual int put(LocalParamDataPacket *packet) = 0; |
62 | 62 | |
63 | + virtual void putNaN() = 0; | |
64 | + | |
63 | 65 | protected: |
64 | 66 | /* |
65 | 67 | * @brief Pointer to the paramData |
... | ... | @@ -164,6 +166,17 @@ public: |
164 | 166 | return packet->getNbData(); |
165 | 167 | } |
166 | 168 | |
169 | + virtual void putNaN() { | |
170 | + _specParamData->getDataList().resize(1); | |
171 | + ElemenType nanElem = ElemenType(_dim1,_dim2); | |
172 | + for(int i = 0; i < _dim1; ++i) { | |
173 | + for(int j = 0; j < _dim2; ++j) { | |
174 | + nanElem[i][j] = ((BaseElemenType)NAN); | |
175 | + } | |
176 | + } | |
177 | + _specParamData->getDataList().push_back(nanElem); | |
178 | + } | |
179 | + | |
167 | 180 | /* |
168 | 181 | * @brief ParamData creation |
169 | 182 | */ |
... | ... | @@ -238,6 +251,14 @@ public: |
238 | 251 | return packet->getNbData(); |
239 | 252 | } |
240 | 253 | |
254 | + virtual void putNaN() { | |
255 | + _specParamData->getDataList().resize(1); | |
256 | + ElemenType nanElem = ElemenType(); | |
257 | + nanElem.resize(_dim1); | |
258 | + nanElem << NotANumber(); | |
259 | + _specParamData->getDataList().push_back(nanElem); | |
260 | + } | |
261 | + | |
241 | 262 | /* |
242 | 263 | * @brief ParamData creation |
243 | 264 | */ |
... | ... | @@ -306,6 +327,11 @@ public: |
306 | 327 | return packet->getNbData(); |
307 | 328 | } |
308 | 329 | |
330 | + virtual void putNaN() { | |
331 | + _specParamData->getDataList().resize(1); | |
332 | + _specParamData->getDataList().push_back((BaseElemenType)NAN); | |
333 | + } | |
334 | + | |
309 | 335 | SpecParamData* createParamData() { |
310 | 336 | return new SpecParamData(); |
311 | 337 | } | ... | ... |
src/ParamGetImpl/LocalFileInterface/VirtualInstrumentInterval.cc
... | ... | @@ -29,7 +29,8 @@ VirtualInstrumentInterval::VirtualInstrumentInterval(VirtualInstrument& pVI, |
29 | 29 | _timeIntToProcessChanged(false), |
30 | 30 | _noMoreTimeInt(false), |
31 | 31 | _crtFileIndex(0), |
32 | - _crtRecordIndex(0) | |
32 | + _crtRecordIndex(0), | |
33 | + _nodata(false) | |
33 | 34 | { |
34 | 35 | _step = &VirtualInstrumentInterval::writeData; |
35 | 36 | |
... | ... | @@ -66,6 +67,9 @@ unsigned int VirtualInstrumentInterval::writeData() |
66 | 67 | return 0; |
67 | 68 | } |
68 | 69 | |
70 | + if (_nodata) | |
71 | + return writeNoData(); | |
72 | + | |
69 | 73 | double lStopTime = (*_currentTimeIntToProcess)._stopTime; |
70 | 74 | |
71 | 75 | int crtIntervalRecIndex = _crtRecordIndex; |
... | ... | @@ -167,8 +171,40 @@ unsigned int VirtualInstrumentInterval::writeEmptyData() |
167 | 171 | return 0; |
168 | 172 | } |
169 | 173 | |
174 | +unsigned int VirtualInstrumentInterval::writeNoData() | |
175 | +{ | |
176 | + LOG4CXX_INFO(gLogger, "VirtualInstrumentInterval::writeNoData"); | |
177 | + | |
178 | + double crtStartTime = _currentTimeIntToProcess->_startTime; | |
179 | + double crtStopTime = _currentTimeIntToProcess->_stopTime; | |
180 | + | |
181 | + // If there is an other TimeInterval to process, change _step function to retrieve data from server. | |
182 | + if( (_currentTimeIntToProcess != _timeIntervalList.end()) && setTimeInterval()) { | |
183 | + // Time interval set to the next. | |
184 | + _timeIntToProcessChanged = true; | |
185 | + } else { | |
186 | + _noMoreTimeInt = true; | |
187 | + if (!_nodata) | |
188 | + _step = &VirtualInstrumentInterval::writeData; | |
189 | + else | |
190 | + _step = &VirtualInstrumentInterval::writeEmptyData; | |
191 | + } | |
192 | + | |
193 | + for(auto paramInfo : _paramFlowSPtr->getParamInfoMap()) | |
194 | + { | |
195 | + std::string paramId = paramInfo.first; | |
196 | + LocalParamDataPacket *noDataPacket= new LocalParamDataPacket(); | |
197 | + noDataPacket->setNoData(crtStartTime, crtStopTime); | |
198 | + _paramFlowSPtr->push(paramId, noDataPacket); | |
199 | + } | |
200 | + | |
201 | + return 0; | |
202 | +} | |
203 | + | |
170 | 204 | bool VirtualInstrumentInterval::setTimeInterval() |
171 | 205 | { |
206 | + _nodata = false; | |
207 | + | |
172 | 208 | if (_currentTimeIntToProcess == _timeIntervalList.end()) { |
173 | 209 | _currentTimeIntToProcess = _timeIntervalList.begin(); |
174 | 210 | } else if (++_currentTimeIntToProcess != _timeIntervalList.end()) { |
... | ... | @@ -185,8 +221,11 @@ bool VirtualInstrumentInterval::setTimeInterval() |
185 | 221 | |
186 | 222 | if (lStopTime < _vi.getGlobalStartTime() || lStartTime > _vi.getGlobalStopTime()) |
187 | 223 | { |
188 | - LOG4CXX_ERROR(gLogger, "VirtualInstrumentInterval::setTimeInterval - Cannot get data for this time interval - Outside of global start and global stop definition"); | |
189 | - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_OUTOFTIME_ERR) << AMDA::ex_msg("Cannot get data for this time interval - Outside of global start and global stop definition")); | |
224 | + _nodata = true; | |
225 | + return true; | |
226 | + | |
227 | + //LOG4CXX_ERROR(gLogger, "VirtualInstrumentInterval::setTimeInterval - Cannot get data for this time interval - Outside of global start and global stop definition"); | |
228 | + //BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_OUTOFTIME_ERR) << AMDA::ex_msg("Cannot get data for this time interval - Outside of global start and global stop definition")); | |
190 | 229 | } |
191 | 230 | |
192 | 231 | LOG4CXX_DEBUG(gLogger, "VirtualInstrumentInterval => start time: " << lStartTime << " lStopTime: " << lStopTime); | ... | ... |
src/ParamGetImpl/LocalFileInterface/VirtualInstrumentInterval.hh
... | ... | @@ -99,6 +99,8 @@ private: |
99 | 99 | */ |
100 | 100 | unsigned int writeEmptyData(); |
101 | 101 | |
102 | + unsigned int writeNoData(); | |
103 | + | |
102 | 104 | unsigned int (VirtualInstrumentInterval::*_step)(); |
103 | 105 | |
104 | 106 | /* |
... | ... | @@ -125,6 +127,8 @@ private: |
125 | 127 | int _crtFileIndex; |
126 | 128 | |
127 | 129 | int _crtRecordIndex; |
130 | + | |
131 | + bool _nodata; | |
128 | 132 | }; |
129 | 133 | |
130 | 134 | } /* namespace LocalFileInterface */ | ... | ... |