Commit 9f0d52de3854971945eb00a99af601b89555d42e
1 parent
7014a201
Exists in
9084
First test
Showing
4 changed files
with
77 additions
and
9 deletions
Show diff stats
src/InternLib/ProcessStandard.cc
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | #include "ServicesServer.hh" |
36 | 36 | #include "DataWriter.hh" |
37 | 37 | #include "ParameterManager.hh" |
38 | +#include "ParamMgr.hh" | |
38 | 39 | |
39 | 40 | #include "ProcessStandard.hh" |
40 | 41 | |
... | ... | @@ -57,7 +58,7 @@ ProcessStandard::ProcessStandard(Parameter & parameter) : |
57 | 58 | _accesDirect(false), |
58 | 59 | _alreadyParsed(false), |
59 | 60 | _propertiesList("app.properties"), |
60 | - _timeOfSoFile(0) { | |
61 | + _timeOfSoFile(0), _fillValue(NAN) { | |
61 | 62 | _servicesServer = ServicesServer::getInstance(); |
62 | 63 | } |
63 | 64 | |
... | ... | @@ -73,7 +74,7 @@ ProcessStandard::ProcessStandard(const ProcessStandard & pProcess, Parameter &pa |
73 | 74 | _accesDirect(pProcess._accesDirect), |
74 | 75 | _alreadyParsed(pProcess._alreadyParsed), |
75 | 76 | _propertiesList(pProcess._propertiesList), |
76 | - _timeOfSoFile(pProcess._timeOfSoFile) { | |
77 | + _timeOfSoFile(pProcess._timeOfSoFile), _fillValue(pProcess._fillValue) { | |
77 | 78 | _servicesServer = ServicesServer::getInstance(); |
78 | 79 | establishConnection(); |
79 | 80 | } |
... | ... | @@ -327,6 +328,7 @@ bool ProcessStandard::mustGenerated(TimeStamp timeDepend) { |
327 | 328 | |
328 | 329 | //Wirte methode |
329 | 330 | fileC << "void write(AMDA::Parameters::ParamDataIndexInfo &pParamDataIndexInfo) {" << endl; |
331 | + fileC << " _paramOutput->setFillValue(_processStandard.getFillValue());" << endl; | |
330 | 332 | fileC << " for (unsigned int index = pParamDataIndexInfo._startIndex; index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; ++index) {" << endl; |
331 | 333 | fileC << " _paramOutput->pushTime(_processStandard.getParameterList().begin()->second.first->getParamData(&_process)->getTime(index));" << endl; |
332 | 334 | fileC << " _paramOutput->push("<< _parser.getFormulaCc() <<");"; fileC << endl; |
... | ... | @@ -461,5 +463,24 @@ void ProcessStandard::closeDynamicLib() { |
461 | 463 | |
462 | 464 | } |
463 | 465 | |
466 | +/** | |
467 | + * @brief update parameter info in relation to the process | |
468 | + */ | |
469 | +void ProcessStandard::updateInfo(Parameter & parameter) | |
470 | +{ | |
471 | + LOG4CXX_DEBUG(_logger, "ProcessStandard::updateInfo - " << parameter.getId()); | |
472 | + | |
473 | + if (parameter.getInfoId().empty()) | |
474 | + parameter.setInfoId(parameter.getId()); | |
475 | + | |
476 | + //Param info | |
477 | + AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(parameter.getInfoId(),true); | |
478 | + | |
479 | + if (paramInfo == nullptr) | |
480 | + return; | |
481 | + | |
482 | + this->_fillValue = paramInfo->getOriginalFillValue(); | |
483 | +} | |
484 | + | |
464 | 485 | } /* namespace Parameters */ |
465 | 486 | } /* namespace AMDA */ | ... | ... |
src/InternLib/ProcessStandard.hh
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | #include "MultiParamProcess.hh" |
26 | 26 | #include "Parser.hh" |
27 | 27 | |
28 | -#define PROCESS_STANDARD_COMPIL_VERSION 5 | |
28 | +#define PROCESS_STANDARD_COMPIL_VERSION 6 | |
29 | 29 | |
30 | 30 | namespace AMDA { |
31 | 31 | namespace Parameters { |
... | ... | @@ -73,6 +73,15 @@ public: |
73 | 73 | |
74 | 74 | virtual void establishConnection(); |
75 | 75 | |
76 | + /** | |
77 | + * @overload DataWriter::updateInfo - update parameter info in relation to the process | |
78 | + */ | |
79 | + virtual void updateInfo(Parameter & parameter); | |
80 | + | |
81 | + double getFillValue() { | |
82 | + return _fillValue; | |
83 | + } | |
84 | + | |
76 | 85 | protected: |
77 | 86 | /** |
78 | 87 | * get paramName and fctName of expression |
... | ... | @@ -132,6 +141,8 @@ protected: |
132 | 141 | * @details give by mkdtemp(_propertiesList["app.process.src"]/XXXXXX); |
133 | 142 | */ |
134 | 143 | std::string _workingDiretory ; |
144 | + | |
145 | + double _fillValue; | |
135 | 146 | }; |
136 | 147 | |
137 | 148 | } /* namespace Parameters */ | ... | ... |
src/Parameters/ParamData.cc
... | ... | @@ -18,7 +18,7 @@ namespace Parameters { |
18 | 18 | |
19 | 19 | LoggerPtr ParamData::_logger(Logger::getLogger("AMDA-Kernel.ParamData")); |
20 | 20 | |
21 | -ParamData::ParamData() : _minSampling(0.0) { | |
21 | +ParamData::ParamData() : _minSampling(0.0), _fillValue(NAN) { | |
22 | 22 | } |
23 | 23 | |
24 | 24 | ParamData::~ParamData() { |
... | ... | @@ -29,6 +29,8 @@ ParamData::~ParamData() { |
29 | 29 | } /* namespace AMDA */ |
30 | 30 | |
31 | 31 | |
32 | + | |
33 | + | |
32 | 34 | const NotANumber notANumber; |
33 | 35 | const ElemNull elemNull; |
34 | 36 | |
... | ... | @@ -37,6 +39,9 @@ a = (type)val;\ |
37 | 39 | }\ |
38 | 40 | void operator <<(type &a, ElemNull /*b*/) {\ |
39 | 41 | a = (type)0;\ |
42 | +}\ | |
43 | +void applyFillValue(type &a, double fillVal) {\ | |
44 | +if (a==fillVal) a << NotANumber();\ | |
40 | 45 | } |
41 | 46 | |
42 | 47 | GENARATED_SCALAIRE_IMPL(short, SHRT_MIN) |
... | ... | @@ -55,6 +60,11 @@ void operator <<(std::vector<type> &a, ElemNull /*b*/) {\ |
55 | 60 | for(std::vector<type>::iterator it = a.begin(); it != a.end(); ++it) {\ |
56 | 61 | *it = (type)0;\ |
57 | 62 | }\ |
63 | +}\ | |
64 | +void applyFillValue(std::vector<type> &a, double fillVal) {\ | |
65 | +for(std::vector<type>::iterator it = a.begin(); it != a.end(); ++it) {\ | |
66 | +if (*it==fillVal) (*it) << NotANumber();\ | |
67 | +}\ | |
58 | 68 | } |
59 | 69 | |
60 | 70 | GENARATED_VECTOR_IMPL(short,SHRT_MIN) |
... | ... | @@ -77,6 +87,13 @@ for(int i = 0; i < a.getDim1Size(); ++i) {\ |
77 | 87 | a[i][j] = (type)0;\ |
78 | 88 | }\ |
79 | 89 | }\ |
90 | +}\ | |
91 | +void applyFillValue(AMDA::Parameters::Tab2DData<type> &a, double fillVal) {\ | |
92 | +for(int i = 0; i < a.getDim1Size(); ++i) {\ | |
93 | + for(int j = 0; j < a.getDim2Size(); ++j) {\ | |
94 | + if (a[i][j] == fillVal) a[i][j] << NotANumber();\ | |
95 | + }\ | |
96 | +}\ | |
80 | 97 | } |
81 | 98 | |
82 | 99 | GENARATED_TAB2D_IMPL(short,SHRT_MIN) | ... | ... |
src/Parameters/ParamData.hh
... | ... | @@ -102,6 +102,8 @@ public: |
102 | 102 | |
103 | 103 | unsigned int getDataNumber() { return _blockTimeTab.size(); } |
104 | 104 | |
105 | + void setFillValue(double fillValue) { _fillValue = fillValue; } | |
106 | + | |
105 | 107 | protected: |
106 | 108 | |
107 | 109 | /** logger of paramData */ |
... | ... | @@ -111,6 +113,9 @@ protected: |
111 | 113 | */ |
112 | 114 | double _minSampling; |
113 | 115 | |
116 | + | |
117 | + double _fillValue; | |
118 | + | |
114 | 119 | private: |
115 | 120 | |
116 | 121 | |
... | ... | @@ -133,7 +138,7 @@ public: |
133 | 138 | typedef ElType ElementType ; |
134 | 139 | typedef ClassName ParamType ; |
135 | 140 | |
136 | - ParamDataSpec_CRTP(int dim1=1, int dim2=2) : _dim1(dim1), _dim2(dim2){} | |
141 | + ParamDataSpec_CRTP(int dim1=1, int dim2=2) : _dim1(dim1), _dim2(dim2) {} | |
137 | 142 | ~ParamDataSpec_CRTP() {} |
138 | 143 | |
139 | 144 | typedef Container<ElementType> DataList; |
... | ... | @@ -143,7 +148,8 @@ public: |
143 | 148 | const DataList& getDataList() const { return _dataList; } |
144 | 149 | double getMinSampling(){ return _minSampling;} |
145 | 150 | |
146 | - void push(ElementType el) { _dataList.push_back(el); } | |
151 | + void push(ElementType el) ; | |
152 | + | |
147 | 153 | |
148 | 154 | virtual unsigned int getDim1() { return _dim1; } |
149 | 155 | virtual unsigned int getDim2() { return _dim2; } |
... | ... | @@ -175,6 +181,8 @@ public: |
175 | 181 | val << NotANumber(); |
176 | 182 | _dataList.replace(val,index); |
177 | 183 | } |
184 | + | |
185 | + | |
178 | 186 | |
179 | 187 | private: |
180 | 188 | template<typename Type> |
... | ... | @@ -202,6 +210,7 @@ private: |
202 | 210 | |
203 | 211 | unsigned int _dim1; |
204 | 212 | unsigned int _dim2; |
213 | + | |
205 | 214 | |
206 | 215 | }; |
207 | 216 | |
... | ... | @@ -243,7 +252,8 @@ extern const ElemNull elemNull; |
243 | 252 | |
244 | 253 | #define GENARATED_SCALAIRE(type, val) \ |
245 | 254 | void operator <<(type &a, NotANumber b) ; \ |
246 | - void operator <<(type &a, ElemNull b) ; | |
255 | + void operator <<(type &a, ElemNull b) ; \ | |
256 | + void applyFillValue(type &a, double fillVal) ; | |
247 | 257 | |
248 | 258 | GENARATED_SCALAIRE(short, SHRT_MIN) |
249 | 259 | GENARATED_SCALAIRE(float, NAN) |
... | ... | @@ -254,7 +264,8 @@ GENARATED_SCALAIRE(AMDA::Parameters::LogicalData, AMDA::Parameters::LogicalData: |
254 | 264 | |
255 | 265 | #define GENARATED_VECTOR(type, val) \ |
256 | 266 | void operator <<(std::vector<type> &a, NotANumber b); \ |
257 | - void operator <<(std::vector<type> &a, ElemNull b); | |
267 | + void operator <<(std::vector<type> &a, ElemNull b); \ | |
268 | + void applyFillValue(std::vector<type> &a, double fillVal); | |
258 | 269 | |
259 | 270 | GENARATED_VECTOR(short,SHRT_MIN) |
260 | 271 | GENARATED_VECTOR(float, NAN) |
... | ... | @@ -265,7 +276,8 @@ GENARATED_VECTOR(AMDA::Parameters::LogicalData, AMDA::Parameters::LogicalData::N |
265 | 276 | |
266 | 277 | #define GENARATED_TAB2D(type, val) \ |
267 | 278 | void operator <<(AMDA::Parameters::Tab2DData<type> &a, NotANumber b); \ |
268 | - void operator <<(AMDA::Parameters::Tab2DData<type> &a, ElemNull b); | |
279 | + void operator <<(AMDA::Parameters::Tab2DData<type> &a, ElemNull b); \ | |
280 | + void applyFillValue(AMDA::Parameters::Tab2DData<type> &a, double fillVal); | |
269 | 281 | |
270 | 282 | GENARATED_TAB2D(short,SHRT_MIN) |
271 | 283 | GENARATED_TAB2D(float, NAN) |
... | ... | @@ -274,6 +286,13 @@ GENARATED_TAB2D(long double, NAN) |
274 | 286 | GENARATED_TAB2D(int, INT_MIN) |
275 | 287 | GENARATED_TAB2D(AMDA::Parameters::LogicalData, AMDA::Parameters::LogicalData::NaN) |
276 | 288 | |
289 | +template<class ElType, class ClassName> | |
290 | +void AMDA::Parameters::ParamDataSpec_CRTP<ElType, ClassName>::push(ElementType el) { | |
291 | + if (!std::isnan(_fillValue)) | |
292 | + applyFillValue(el,_fillValue); | |
293 | + _dataList.push_back(el); | |
294 | +} | |
295 | + | |
277 | 296 | bool isNAN(short pval); |
278 | 297 | bool isNAN(float pval); |
279 | 298 | bool isNAN(double pval); | ... | ... |