From 9f0d52de3854971945eb00a99af601b89555d42e Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 4 Oct 2022 13:56:41 +0000 Subject: [PATCH] First test --- src/InternLib/ProcessStandard.cc | 25 +++++++++++++++++++++++-- src/InternLib/ProcessStandard.hh | 13 ++++++++++++- src/Parameters/ParamData.cc | 19 ++++++++++++++++++- src/Parameters/ParamData.hh | 29 ++++++++++++++++++++++++----- 4 files changed, 77 insertions(+), 9 deletions(-) diff --git a/src/InternLib/ProcessStandard.cc b/src/InternLib/ProcessStandard.cc index a97e9e0..f9c8f53 100644 --- a/src/InternLib/ProcessStandard.cc +++ b/src/InternLib/ProcessStandard.cc @@ -35,6 +35,7 @@ #include "ServicesServer.hh" #include "DataWriter.hh" #include "ParameterManager.hh" +#include "ParamMgr.hh" #include "ProcessStandard.hh" @@ -57,7 +58,7 @@ ProcessStandard::ProcessStandard(Parameter & parameter) : _accesDirect(false), _alreadyParsed(false), _propertiesList("app.properties"), - _timeOfSoFile(0) { + _timeOfSoFile(0), _fillValue(NAN) { _servicesServer = ServicesServer::getInstance(); } @@ -73,7 +74,7 @@ ProcessStandard::ProcessStandard(const ProcessStandard & pProcess, Parameter &pa _accesDirect(pProcess._accesDirect), _alreadyParsed(pProcess._alreadyParsed), _propertiesList(pProcess._propertiesList), - _timeOfSoFile(pProcess._timeOfSoFile) { + _timeOfSoFile(pProcess._timeOfSoFile), _fillValue(pProcess._fillValue) { _servicesServer = ServicesServer::getInstance(); establishConnection(); } @@ -327,6 +328,7 @@ bool ProcessStandard::mustGenerated(TimeStamp timeDepend) { //Wirte methode fileC << "void write(AMDA::Parameters::ParamDataIndexInfo &pParamDataIndexInfo) {" << endl; + fileC << " _paramOutput->setFillValue(_processStandard.getFillValue());" << endl; fileC << " for (unsigned int index = pParamDataIndexInfo._startIndex; index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; ++index) {" << endl; fileC << " _paramOutput->pushTime(_processStandard.getParameterList().begin()->second.first->getParamData(&_process)->getTime(index));" << endl; fileC << " _paramOutput->push("<< _parser.getFormulaCc() <<");"; fileC << endl; @@ -461,5 +463,24 @@ void ProcessStandard::closeDynamicLib() { } +/** + * @brief update parameter info in relation to the process + */ +void ProcessStandard::updateInfo(Parameter & parameter) +{ + LOG4CXX_DEBUG(_logger, "ProcessStandard::updateInfo - " << parameter.getId()); + + if (parameter.getInfoId().empty()) + parameter.setInfoId(parameter.getId()); + + //Param info + AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(parameter.getInfoId(),true); + + if (paramInfo == nullptr) + return; + + this->_fillValue = paramInfo->getOriginalFillValue(); +} + } /* namespace Parameters */ } /* namespace AMDA */ diff --git a/src/InternLib/ProcessStandard.hh b/src/InternLib/ProcessStandard.hh index ea6baad..b16099c 100644 --- a/src/InternLib/ProcessStandard.hh +++ b/src/InternLib/ProcessStandard.hh @@ -25,7 +25,7 @@ #include "MultiParamProcess.hh" #include "Parser.hh" -#define PROCESS_STANDARD_COMPIL_VERSION 5 +#define PROCESS_STANDARD_COMPIL_VERSION 6 namespace AMDA { namespace Parameters { @@ -73,6 +73,15 @@ public: virtual void establishConnection(); + /** + * @overload DataWriter::updateInfo - update parameter info in relation to the process + */ + virtual void updateInfo(Parameter & parameter); + + double getFillValue() { + return _fillValue; + } + protected: /** * get paramName and fctName of expression @@ -132,6 +141,8 @@ protected: * @details give by mkdtemp(_propertiesList["app.process.src"]/XXXXXX); */ std::string _workingDiretory ; + + double _fillValue; }; } /* namespace Parameters */ diff --git a/src/Parameters/ParamData.cc b/src/Parameters/ParamData.cc index 5994854..1262186 100644 --- a/src/Parameters/ParamData.cc +++ b/src/Parameters/ParamData.cc @@ -18,7 +18,7 @@ namespace Parameters { LoggerPtr ParamData::_logger(Logger::getLogger("AMDA-Kernel.ParamData")); -ParamData::ParamData() : _minSampling(0.0) { +ParamData::ParamData() : _minSampling(0.0), _fillValue(NAN) { } ParamData::~ParamData() { @@ -29,6 +29,8 @@ ParamData::~ParamData() { } /* namespace AMDA */ + + const NotANumber notANumber; const ElemNull elemNull; @@ -37,6 +39,9 @@ a = (type)val;\ }\ void operator <<(type &a, ElemNull /*b*/) {\ a = (type)0;\ +}\ +void applyFillValue(type &a, double fillVal) {\ +if (a==fillVal) a << NotANumber();\ } GENARATED_SCALAIRE_IMPL(short, SHRT_MIN) @@ -55,6 +60,11 @@ void operator <<(std::vector &a, ElemNull /*b*/) {\ for(std::vector::iterator it = a.begin(); it != a.end(); ++it) {\ *it = (type)0;\ }\ +}\ +void applyFillValue(std::vector &a, double fillVal) {\ +for(std::vector::iterator it = a.begin(); it != a.end(); ++it) {\ +if (*it==fillVal) (*it) << NotANumber();\ +}\ } GENARATED_VECTOR_IMPL(short,SHRT_MIN) @@ -77,6 +87,13 @@ for(int i = 0; i < a.getDim1Size(); ++i) {\ a[i][j] = (type)0;\ }\ }\ +}\ +void applyFillValue(AMDA::Parameters::Tab2DData &a, double fillVal) {\ +for(int i = 0; i < a.getDim1Size(); ++i) {\ + for(int j = 0; j < a.getDim2Size(); ++j) {\ + if (a[i][j] == fillVal) a[i][j] << NotANumber();\ + }\ +}\ } GENARATED_TAB2D_IMPL(short,SHRT_MIN) diff --git a/src/Parameters/ParamData.hh b/src/Parameters/ParamData.hh index ea8dc89..5b12a49 100644 --- a/src/Parameters/ParamData.hh +++ b/src/Parameters/ParamData.hh @@ -102,6 +102,8 @@ public: unsigned int getDataNumber() { return _blockTimeTab.size(); } + void setFillValue(double fillValue) { _fillValue = fillValue; } + protected: /** logger of paramData */ @@ -111,6 +113,9 @@ protected: */ double _minSampling; + + double _fillValue; + private: @@ -133,7 +138,7 @@ public: typedef ElType ElementType ; typedef ClassName ParamType ; - ParamDataSpec_CRTP(int dim1=1, int dim2=2) : _dim1(dim1), _dim2(dim2){} + ParamDataSpec_CRTP(int dim1=1, int dim2=2) : _dim1(dim1), _dim2(dim2) {} ~ParamDataSpec_CRTP() {} typedef Container DataList; @@ -143,7 +148,8 @@ public: const DataList& getDataList() const { return _dataList; } double getMinSampling(){ return _minSampling;} - void push(ElementType el) { _dataList.push_back(el); } + void push(ElementType el) ; + virtual unsigned int getDim1() { return _dim1; } virtual unsigned int getDim2() { return _dim2; } @@ -175,6 +181,8 @@ public: val << NotANumber(); _dataList.replace(val,index); } + + private: template @@ -202,6 +210,7 @@ private: unsigned int _dim1; unsigned int _dim2; + }; @@ -243,7 +252,8 @@ extern const ElemNull elemNull; #define GENARATED_SCALAIRE(type, val) \ void operator <<(type &a, NotANumber b) ; \ - void operator <<(type &a, ElemNull b) ; + void operator <<(type &a, ElemNull b) ; \ + void applyFillValue(type &a, double fillVal) ; GENARATED_SCALAIRE(short, SHRT_MIN) GENARATED_SCALAIRE(float, NAN) @@ -254,7 +264,8 @@ GENARATED_SCALAIRE(AMDA::Parameters::LogicalData, AMDA::Parameters::LogicalData: #define GENARATED_VECTOR(type, val) \ void operator <<(std::vector &a, NotANumber b); \ - void operator <<(std::vector &a, ElemNull b); + void operator <<(std::vector &a, ElemNull b); \ + void applyFillValue(std::vector &a, double fillVal); GENARATED_VECTOR(short,SHRT_MIN) GENARATED_VECTOR(float, NAN) @@ -265,7 +276,8 @@ GENARATED_VECTOR(AMDA::Parameters::LogicalData, AMDA::Parameters::LogicalData::N #define GENARATED_TAB2D(type, val) \ void operator <<(AMDA::Parameters::Tab2DData &a, NotANumber b); \ - void operator <<(AMDA::Parameters::Tab2DData &a, ElemNull b); + void operator <<(AMDA::Parameters::Tab2DData &a, ElemNull b); \ + void applyFillValue(AMDA::Parameters::Tab2DData &a, double fillVal); GENARATED_TAB2D(short,SHRT_MIN) GENARATED_TAB2D(float, NAN) @@ -274,6 +286,13 @@ GENARATED_TAB2D(long double, NAN) GENARATED_TAB2D(int, INT_MIN) GENARATED_TAB2D(AMDA::Parameters::LogicalData, AMDA::Parameters::LogicalData::NaN) +template +void AMDA::Parameters::ParamDataSpec_CRTP::push(ElementType el) { + if (!std::isnan(_fillValue)) + applyFillValue(el,_fillValue); + _dataList.push_back(el); +} + bool isNAN(short pval); bool isNAN(float pval); bool isNAN(double pval); -- libgit2 0.21.2