From f2db3c160de97807b1ef5138c14a212829b60fbb Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 24 Sep 2015 11:11:29 +0200 Subject: [PATCH] Support variable table definition Add Stereo A SWEA PAD & Maven PLASTIC C0 parameters --- config/DataBaseParameters/mav_sta_c0.xml | 24 ++++++++++++++++++++++++ config/DataBaseParameters/mav_sta_c0_energy.xml | 15 +++++++++++++++ config/DataBaseParameters/mav_sta_c0_tab2d.xml | 23 +++++++++++++++++++++++ config/DataBaseParameters/sta_swea_pad_energy.xml | 13 +++++++++++++ config/DataBaseParameters/sta_swea_pad_pasum.xml | 24 ++++++++++++++++++++++++ config/DataBaseParameters/sta_swea_pad_tab2d.xml | 7 ------- config/DataBaseParameters/xsd/info/paramInfo.xsd | 1 + src/ExternLib/GetMavenStaticEnergy/AMDAPlugin.cc | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ExternLib/GetMavenStaticEnergy/CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++ src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergy.hh | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyCreator.hh | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyProcess.cc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyProcess.hh | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/Info/ParamTable.cc | 310 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------- src/Info/ParamTable.hh | 62 ++++++++++++++++++++++++++++++++++++++++---------------------- src/Info/ParamTableNode.cc | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- src/ParamGetImpl/DDServerInterface/VirtualInstrument.cc | 4 ++++ src/ParamOutputImpl/Plot/PanelPlotOutput.cc | 42 +++++++++++++++++++++++++++++++++++++++--- src/ParamOutputImpl/Plot/ParameterData.cc | 30 ++++++++++++++++++------------ src/ParamOutputImpl/Plot/SpectroProperties.hh | 18 ++++++++++++++++++ src/ParamOutputImpl/Plot/Time/TimePlot.cc | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- src/Parameters/VisitorOfParamData.hh | 12 ++++++++++++ 22 files changed, 1098 insertions(+), 219 deletions(-) create mode 100644 config/DataBaseParameters/mav_sta_c0.xml create mode 100644 config/DataBaseParameters/mav_sta_c0_energy.xml create mode 100644 config/DataBaseParameters/mav_sta_c0_tab2d.xml create mode 100644 config/DataBaseParameters/sta_swea_pad_energy.xml create mode 100644 config/DataBaseParameters/sta_swea_pad_pasum.xml create mode 100644 src/ExternLib/GetMavenStaticEnergy/AMDAPlugin.cc create mode 100644 src/ExternLib/GetMavenStaticEnergy/CMakeLists.txt create mode 100644 src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergy.hh create mode 100644 src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyCreator.hh create mode 100644 src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyProcess.cc create mode 100644 src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyProcess.hh diff --git a/config/DataBaseParameters/mav_sta_c0.xml b/config/DataBaseParameters/mav_sta_c0.xml new file mode 100644 index 0000000..5919adf --- /dev/null +++ b/config/DataBaseParameters/mav_sta_c0.xml @@ -0,0 +1,24 @@ + + + + Eflux + Eflux + + eV/st/sec + + 0 + + + +
+ -1e+31 + + +
+ + + + + $mav_sta_c0_tab2d[0].toVector() + + diff --git a/config/DataBaseParameters/mav_sta_c0_energy.xml b/config/DataBaseParameters/mav_sta_c0_energy.xml new file mode 100644 index 0000000..1ccb6b0 --- /dev/null +++ b/config/DataBaseParameters/mav_sta_c0_energy.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + #getMavenStaticEnergy($mavpds_sta_c0_swp_ind) + + \ No newline at end of file diff --git a/config/DataBaseParameters/mav_sta_c0_tab2d.xml b/config/DataBaseParameters/mav_sta_c0_tab2d.xml new file mode 100644 index 0000000..b8ee26b --- /dev/null +++ b/config/DataBaseParameters/mav_sta_c0_tab2d.xml @@ -0,0 +1,23 @@ + + + + Eflux + Eflux + + eV/st/sec + + 0 + + -1e+31 + + + + + + + + + + + + diff --git a/config/DataBaseParameters/sta_swea_pad_energy.xml b/config/DataBaseParameters/sta_swea_pad_energy.xml new file mode 100644 index 0000000..5d511bb --- /dev/null +++ b/config/DataBaseParameters/sta_swea_pad_energy.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + #getClbInfo($sta_swea_pad_EnergyTab;0:ETab0;1:ETab1) + + \ No newline at end of file diff --git a/config/DataBaseParameters/sta_swea_pad_pasum.xml b/config/DataBaseParameters/sta_swea_pad_pasum.xml new file mode 100644 index 0000000..16c5f7b --- /dev/null +++ b/config/DataBaseParameters/sta_swea_pad_pasum.xml @@ -0,0 +1,24 @@ + + + + Stereo-A SWEA PAD Total under all angles + SWEA PAD Total under all angles + + s3/km6 + + 0 + + + +
+ -1e+31 + + +
+ + + + + total($sta_swea_pad_tab2d,1) + + diff --git a/config/DataBaseParameters/sta_swea_pad_tab2d.xml b/config/DataBaseParameters/sta_swea_pad_tab2d.xml index c4c599c..ef50b0b 100644 --- a/config/DataBaseParameters/sta_swea_pad_tab2d.xml +++ b/config/DataBaseParameters/sta_swea_pad_tab2d.xml @@ -8,10 +8,6 @@ 0 - - - -
-1e+31 @@ -19,9 +15,6 @@ - - - diff --git a/config/DataBaseParameters/xsd/info/paramInfo.xsd b/config/DataBaseParameters/xsd/info/paramInfo.xsd index e1b631b..546198e 100644 --- a/config/DataBaseParameters/xsd/info/paramInfo.xsd +++ b/config/DataBaseParameters/xsd/info/paramInfo.xsd @@ -17,6 +17,7 @@ + diff --git a/src/ExternLib/GetMavenStaticEnergy/AMDAPlugin.cc b/src/ExternLib/GetMavenStaticEnergy/AMDAPlugin.cc new file mode 100644 index 0000000..633b92c --- /dev/null +++ b/src/ExternLib/GetMavenStaticEnergy/AMDAPlugin.cc @@ -0,0 +1,81 @@ +/* -*- Base: 10 ; Mode: C++ -*- */ +/*------------------------------------------------------------------------ + ** + FOST project + ** +-------------------------------------------------------------------------- +-------------------------------------------------------------------------- + FILE LOG + $Revision: 1.3 $ $Date: 2012-06-15 13:04:42 $ +-------------------------------------------------------------------------- +CREATION + V.SAC + +SUMMARY + +DESCRIPTION + + The main function performs the following actions : +
    +
  • +
+ +------------------------------------------------------------------------*/ + +//============================================================================= +// +// History of code +// +// creation +// +// modification +//============================================================================= + +/** + +*/ +//============================================================================= +// Include section +//============================================================================= + +// Standard libraries include files +//----------------------------------------------------------------------------- +#include + +// Include oriented definitions +//----------------------------------------------------------------------------- + +// Module Kernel include files +//----------------------------------------------------------------------------- + +#include "GetMavenStaticEnergyProcess.hh" +#include "ServicesServer.hh" +#include "PluginManager.hh" + +using namespace AMDA::Parameters; + +// Other modules include files +//----------------------------------------------------------------------------- + +//============================================================================= +// Methods of Class AMDAPlugin +//============================================================================= + + + +/** + Retrieve the Plugin version we're going to expect +*/ +extern "C" const char* getPluginVersion() +{ + return "(Version)"; +} + +/** + Tells us to register our functionality to an engine kernel +*/ +extern "C" void registerPlugin(AMDA::Plugins::PluginManager & /*pm*/) +{ + ProcessFactory factProcessGetMavenStaticEnergy = boost::factory(); + ServicesServer::getInstance()->addProcessFactory("getMavenStaticEnergy", factProcessGetMavenStaticEnergy); +} diff --git a/src/ExternLib/GetMavenStaticEnergy/CMakeLists.txt b/src/ExternLib/GetMavenStaticEnergy/CMakeLists.txt new file mode 100644 index 0000000..dfb4250 --- /dev/null +++ b/src/ExternLib/GetMavenStaticEnergy/CMakeLists.txt @@ -0,0 +1,33 @@ + +PROJECT(GetMavenStaticEnergy) + +set(LIBRARY_OUTPUT_PATH ${PLUGIN_OUTPUT_PATH}) + +include_directories( + ${CMAKE_HOME_DIRECTORY}/src/InternLib/ + ${CMAKE_HOME_DIRECTORY}/src/Common/ + ${CMAKE_HOME_DIRECTORY}/src/Parameters/ + ${CMAKE_HOME_DIRECTORY}/src/Plugins/ + ${CMAKE_HOME_DIRECTORY}/src/helpers/ + ${CMAKE_HOME_DIRECTORY}/src/TimeTableCatalog/ + ${LOG4CXX_INCLUDE_DIR} + ${Boost_INCLUDE_DIR} +) + +#Library configuration +file( + GLOB_RECURSE + source_files + ./* +) + +ADD_LIBRARY( GetMavenStaticEnergy SHARED ${source_files} ) + + +target_link_libraries( + GetMavenStaticEnergy + ${LOG4CXX_LIBRARIES} + Parameters + InternLib + TimeTableCatalog +) \ No newline at end of file diff --git a/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergy.hh b/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergy.hh new file mode 100644 index 0000000..718e2be --- /dev/null +++ b/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergy.hh @@ -0,0 +1,133 @@ +/* + * GetMavenStaticEnergy.hh + * + * Created on: Sep 23, 2015 + * Author: AKKA + */ + +#ifndef GetMavenStaticEnergy_HH_ +#define GetMavenStaticEnergy_HH_ + +#include "vector" + +#include + +#include "AMDA_exception.hh" +#include "DicError.hh" + +#include "Parameter.hh" +#include "ParamData.hh" +#include "Operation.hh" + +using namespace std; +using namespace boost; +using namespace AMDA::Parameters; + +namespace AMDA { +namespace MavenStatic { + +namespace Base { +/** + * @class Base::GetMavenStaticEnergy + * @brief Compute Maven STATIC energy + */ + class GetMavenStaticEnergy : public Operation { + public: + + /** + * @brief Default Constructor. + */ + GetMavenStaticEnergy(Process& pProcess) : Operation(pProcess) {} + + /** + * @brief Destructor. + */ + virtual ~GetMavenStaticEnergy() {} + + /** + * @brief initialize the operation . + * @detail initialize the operation with information stored in pInput.getInfoList() and pAttribute. + */ + virtual void init(Parameter& input, Process::AttributeList& pAttribute) = 0; + + protected: + }; + } + + +/** + * @class GetMavenStaticEnergy + * @brief Compute Maven STATIC energy. + */ +template +class GetMavenStaticEnergy : public Base::GetMavenStaticEnergy { +public: + /** + * @brief Constructor. + * @details Create the ParamData type of the input ParamData. + */ + GetMavenStaticEnergy(Process& pProcess, TParamData& paramInput) + : Base::GetMavenStaticEnergy(pProcess), _paramInput(paramInput), _paramOutput(new ParamDataTab1DDouble()) { + _paramDataOutput=_paramOutput; + } + + /** + * + * @overload Base::GetMavenStaticEnergy::init() + */ + void init(Parameter& pInput, Process::AttributeList& /* pAttribute */) { + Parameter::InfoList& lInfoList = pInput.getInfoList(); + + int nbMass = (*lInfoList["nmass"].get())[0]; + int nbSweep = (*lInfoList["nswp"].get())[0]; + int nbEnergy = (*lInfoList["nenergy"].get())[0]; + + for (int i = 0; i < nbSweep; ++i) + { + for (int j = 0; j < nbMass; ++j) + { + for (int k = 0; k < nbEnergy; ++k) + { + std::string infoKey = "energy_"; + infoKey += std::to_string(j * nbEnergy + k); + _energyList[i].push_back((*lInfoList[infoKey].get())[i]); + } + } + } + } + + /** + * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo) + */ + void write(ParamDataIndexInfo &pParamDataIndexInfo) { + unsigned int index = pParamDataIndexInfo._startIndex; + for (; index< pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; index++) { + _paramOutput->pushTime(_paramInput.getTime(index)); + _paramOutput->getDataList().push_back((_energyList[(int)floor(_paramInput.getDataList()[index])])); + } + } + +private: + /** + * @brief It is the channel of calibration. + */ + TParamData &_paramInput; + + /** + * @brief It is the channel of the data shifted. + */ + ParamDataTab1DDouble *_paramOutput; + + + /** + * @brief map of calibrationInfo. + * @detail for expression #getClbInfo($ETableN;0:ImaEner_0;1:ImaEner_1) + * the key of map is 0 respectively 1 + * the value of map is the value of attributes ImaEner[0] respectively and ImaEner[0] + */ + std::map> _energyList; +}; + +} /* namespace MavenStatic */ +} /* namespace AMDA */ +#endif /* GetMavenStaticEnergy_HH_ */ diff --git a/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyCreator.hh b/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyCreator.hh new file mode 100644 index 0000000..60790cc --- /dev/null +++ b/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyCreator.hh @@ -0,0 +1,163 @@ +/* + * GetMavenStaticEnergyCreator.hh + * + * Created on: Sep 23, 2015 + * Author: AKKA + */ + +#ifndef GetMavenStaticEnergyCreator_HH_ +#define GetMavenStaticEnergyCreator_HH_ + +#include "DicError.hh" +#include "AMDA_exception.hh" + +#include "ParamData.hh" +#include "VisitorOfParamData.hh" +#include "GetMavenStaticEnergy.hh" + +namespace AMDA { +namespace MavenStatic { + +/** + * @class GetMavenStaticEnergyCreator + * @brief Creator of the Operation GetMavenStaticEnergy parameterized with ParamData input type. + * @details Implement the interface VisitorOfParamData. + */ +class GetMavenStaticEnergyCreator : public VisitorOfParamData { +public: + /** + * @brief Constructor. + */ + GetMavenStaticEnergyCreator(Process& pProcess, ParamData& paramInput) + : _process(pProcess), _paramData(paramInput), _operation(NULL) { + + _paramData.accept(*this); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireShort *) + */ + void visit(ParamDataScalaireShort *) {_operation = new GetMavenStaticEnergy( _process, dynamic_cast(_paramData));} + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *) + */ + void visit(ParamDataScalaireFloat *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *) + */ + void visit(ParamDataScalaireDouble *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *) + */ + void visit(ParamDataScalaireLongDouble *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireInt *) + */ + void visit(ParamDataScalaireInt *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataLogicalData *) + */ + void visit(ParamDataLogicalData *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DShort *) + */ + void visit(ParamDataTab1DShort *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *) + */ + void visit(ParamDataTab1DFloat *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *) + */ + void visit(ParamDataTab1DDouble *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *) + */ + void visit(ParamDataTab1DLongDouble *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DInt *) + */ + void visit(ParamDataTab1DInt *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *) + */ + void visit(ParamDataTab1DLogicalData *) { BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("GetClbInfoCreator operation not supported")); } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DShort *) + */ + void visit(ParamDataTab2DShort *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DShort data not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *) + */ + void visit(ParamDataTab2DFloat *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DFloat data not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *) + */ + void visit(ParamDataTab2DDouble *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DDouble data not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *) + */ + void visit(ParamDataTab2DLongDouble *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DLongDouble data not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DInt *) + */ + void visit(ParamDataTab2DInt *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DInt data not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *) + */ + void visit(ParamDataTab2DLogicalData *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("ParamDataTab2DLogicalData data not supported")); + } + + /** + * @brief get the GetClbInfo parameterized operation. + */ + Operation * getOperation() const { return _operation; } + +private: + /** + * @brief a reference on the process of Calibration + */ + Process &_process; + + /** + * @brief the input paramData + */ + ParamData &_paramData; + + /** + * @brief the operation which is created + */ + Operation *_operation; +}; + +} /* namespace MavenStatic */ +} /* namespace AMDA */ +#endif /* GetMavenStaticEnergyCreator_HH_ */ diff --git a/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyProcess.cc b/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyProcess.cc new file mode 100644 index 0000000..0a28781 --- /dev/null +++ b/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyProcess.cc @@ -0,0 +1,51 @@ +/* + * GetMavenStaticEnergyProcess.cc + * + * Created on: Sep 23, 2015 + * Author: AKKA + */ +#include +#include + +#include "AMDA_exception.hh" +#include "DicError.hh" + +#include "Operation.hh" +#include "ParameterManager.hh" +#include "GetMavenStaticEnergyProcess.hh" +#include "GetMavenStaticEnergyCreator.hh" +#include "ParameterCreatorFromExpression.hh" + +using namespace std; +using namespace boost; +using namespace log4cxx; + +namespace AMDA { +namespace MavenStatic { + +GetMavenStaticEnergyProcess::GetMavenStaticEnergyProcess(Parameter ¶meter) + : SingleParamProcess_CRTP(parameter) { + } + +GetMavenStaticEnergyProcess::GetMavenStaticEnergyProcess(const GetMavenStaticEnergyProcess& pProcess, Parameter ¶meter) + : SingleParamProcess_CRTP(pProcess,parameter) { + } + +GetMavenStaticEnergyProcess::~GetMavenStaticEnergyProcess() { + } + +TimeStamp GetMavenStaticEnergyProcess::init() { + TimeStamp timeStamp = _parameterInput->init( this, _timeIntervalList); + Parameter::InfoList lInfoList = _parameterInput->getInfoList(); + _parameter.getInfoList().insert(lInfoList.begin(), lInfoList.end()); + _paramInput = _parameterInput->getParamData(this).get(); + GetMavenStaticEnergyCreator lGetMavenStaticEnergyCreator(*this,*_paramInput); + _operation = lGetMavenStaticEnergyCreator.getOperation(); + dynamic_cast(_operation)->init(*_parameterInput,_attributList); + _paramData = ParamDataSPtr(_operation->getParamOutput()); + _paramData->setMinSampling(_paramInput->getMinSampling()); + return timeStamp; +} + +} /* namespace MavenStatic */ +} /* namespace AMDA */ diff --git a/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyProcess.hh b/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyProcess.hh new file mode 100644 index 0000000..e327317 --- /dev/null +++ b/src/ExternLib/GetMavenStaticEnergy/GetMavenStaticEnergyProcess.hh @@ -0,0 +1,44 @@ +/* + * GetMavenStaticEnergyProcess.hh + * + * Created on: Sep 23, 2015 + * Author: AKKA + */ + +#ifndef GetMavenStaticEnergyProcess_HH_ +#define GetMavenStaticEnergyProcess_HH_ + +#include "SingleParamProcess.hh" + +namespace AMDA { +namespace MavenStatic { + + /** + * @class GetMavenStaticEnergyProcess + * @brief Return the energy table got Maven STATIC. + */ + class GetMavenStaticEnergyProcess : public AMDA::Parameters::SingleParamProcess_CRTP { + public: + /** + * @brief Constructor. + */ + GetMavenStaticEnergyProcess(AMDA::Parameters::Parameter ¶meter); + /** + * @brief Copy Constructor. + */ + GetMavenStaticEnergyProcess(const GetMavenStaticEnergyProcess& pProcess, AMDA::Parameters::Parameter &pParameter) ; + /** + * @brief Destructor. + */ + ~GetMavenStaticEnergyProcess(); + + // Overload Process methods + /** + * @overload Process::init() + */ + AMDA::Parameters::TimeStamp init(); + }; + +} /* namespace MavenStatic */ +} /* namespace AMDA */ +#endif /* GetMavenStaticEnergyProcess_HH_ */ diff --git a/src/Info/ParamTable.cc b/src/Info/ParamTable.cc index f17c0e7..62ed832 100644 --- a/src/Info/ParamTable.cc +++ b/src/Info/ParamTable.cc @@ -7,6 +7,7 @@ #include "ParamTable.hh" #include "Parameter.hh" +#include "ParamData.hh" using namespace log4cxx; @@ -16,7 +17,7 @@ namespace Info { LoggerPtr ParamTable::_logger(Logger::getLogger("AMDA-Kernel.ParamTable")); ParamTable::ParamTable(const char *paramId) : _paramId(paramId), - _tableName(""), _tableUnits("") + _tableName(""), _tableUnits(""), _variable("false") { } @@ -56,57 +57,121 @@ std::string ParamTable::getUnits(void) return _tableUnits; } -ParamBoundsTable::ParamBoundsTable(const char *paramId, const char *boundsName) : - ParamTable(paramId), _boundsName(boundsName) +/* + * @brief Set isVariable attribute + */ +void ParamTable::setIsVariable(bool isVariable) { + _variable = isVariable; } /* - * @brief Get size of the table + * @brief Get if it's a variable table */ -int ParamBoundsTable::getSize(ParameterManager *parameterManager) +bool ParamTable::isVariable(void) { + return _variable; +} + +void ParamTable::addTableParam(std::string key, std::string name) +{ + _tableParams[key] = name; +} + +std::string ParamTable::getTableParamByKey(std::string key) +{ + return _tableParams[key]; +} + +std::map& ParamTable::getTableParams() +{ + return _tableParams; +} + +std::vector ParamTable::getConstantTableParamValuesByKey(ParameterManager *parameterManager, std::string key) +{ + std::vector paramValues; ParameterSPtr tmpParam = parameterManager->getParameter(_paramId); + if (tmpParam == nullptr) + return paramValues; AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList(); - AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_boundsName]; - return pTableInfo->size() - 1; + if (_tableParams.find(key) == _tableParams.end()) + return paramValues; + std::string tableParamName = _tableParams[key]; + if (lInfoList.find(tableParamName) == lInfoList.end()) + return paramValues; + paramValues = *lInfoList[tableParamName].get(); + return paramValues; +} + +std::vector ParamTable::getVariableTableParamValuesByKey(std::map>* paramsTableData, std::string key) +{ + std::vector paramValues; + if (paramsTableData == NULL) + return paramValues; + if (paramsTableData->find(key) == paramsTableData->end()) + return paramValues; + return (*paramsTableData)[key]; +} + +std::vector ParamTable::getTableParamValuesByKey(ParameterManager *parameterManager, std::map>* paramsTableData, std::string key) +{ + if (_variable) + return getVariableTableParamValuesByKey(paramsTableData, key); + else + return getConstantTableParamValuesByKey(parameterManager, key); +} + +std::string ParamBoundsTable::_boundsParamKey = "TABLEPARAM_BOUNDS"; + +ParamBoundsTable::ParamBoundsTable(const char *paramId) : + ParamTable(paramId) +{ } /* - * @brief Get a bounds for a specified index + * @brief Get size of the table */ -t_TableBound ParamBoundsTable::getBound(ParameterManager *parameterManager, unsigned int index) +int ParamBoundsTable::getSize(ParameterManager *parameterManager) { - ParameterSPtr tmpParam = parameterManager->getParameter(_paramId); + if (!_variable) + { + std::vector boundsValues = getConstantTableParamValuesByKey(parameterManager, ParamBoundsTable::_boundsParamKey); + return boundsValues.size() - 1; + } + else + { + return 0; + } +} +/* + * @brief Get a bounds for a specified index + */ +t_TableBound ParamBoundsTable::getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData) +{ t_TableBound bound; bound.index = index; - if (tmpParam == nullptr) - { - LOG4CXX_ERROR(_logger, "Associated parameter not reachable!"); - bound.min = index; - bound.max = index+1; - return bound; - } - //get table info from parameter info list - AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList(); - AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_boundsName]; - if (index >= pTableInfo->size() - 1) + std::vector boundsValues = getTableParamValuesByKey(parameterManager, paramsTableData, ParamBoundsTable::_boundsParamKey); + + if (index >= boundsValues.size() - 1) { LOG4CXX_ERROR(_logger, "Index " << index << " outside of table definition => Cannot get real bound" ); bound.min = index; bound.max = index+1; return bound; } - bound.min = std::min((*pTableInfo)[index], (*pTableInfo)[index+1]); - bound.max = std::max((*pTableInfo)[index], (*pTableInfo)[index+1]); + bound.min = std::min(boundsValues[index], boundsValues[index+1]); + bound.max = std::max(boundsValues[index], boundsValues[index+1]); return bound; } -ParamCenterTable::ParamCenterTable(const char *paramId, const char *centerName, double size) : - ParamTable(paramId), _centerName(centerName), _size(size) +std::string ParamCenterTable::_centersParamKey = "TABLEPARAM_CENTERS"; + +ParamCenterTable::ParamCenterTable(const char *paramId, double size) : + ParamTable(paramId), _size(size) { } @@ -115,36 +180,28 @@ ParamCenterTable::ParamCenterTable(const char *paramId, const char *centerName, */ int ParamCenterTable::getSize(ParameterManager *parameterManager) { - ParameterSPtr tmpParam = parameterManager->getParameter(_paramId); - AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList(); - AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_centerName]; - return pTableInfo->size(); + if (!_variable) + { + std::vector centersValues = getConstantTableParamValuesByKey(parameterManager, ParamCenterTable::_centersParamKey); + return centersValues.size(); + } + else + { + return 0; + } } /* * @brief Get a bound for a specified index */ -t_TableBound ParamCenterTable::getBound(ParameterManager *parameterManager, unsigned int index) +t_TableBound ParamCenterTable::getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData) { - ParameterSPtr tmpParam = parameterManager->getParameter(_paramId); - t_TableBound bound; bound.index = index; - if (tmpParam == nullptr) - { - LOG4CXX_ERROR(_logger, "Associated parameter not reachable!"); - bound.min = index; - bound.max = index+1; - return bound; - } + std::vector centersValues = getTableParamValuesByKey(parameterManager, paramsTableData, ParamCenterTable::_centersParamKey); - //get table info from parameter info list - - AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList(); - AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_centerName]; - - if (index >= pTableInfo->size()) + if (index >= centersValues.size()) { LOG4CXX_ERROR(_logger, "Index " << index << " outside of table definition => Cannot get real bound" ); bound.min = index; @@ -152,14 +209,17 @@ t_TableBound ParamCenterTable::getBound(ParameterManager *parameterManager, unsi return bound; } - bound.min = (*pTableInfo)[index] - _size/2.; - bound.max = (*pTableInfo)[index] + _size/2.;; + bound.min = centersValues[index] - _size/2.; + bound.max = centersValues[index] + _size/2.;; return bound; } -ParamCenterWidthTable::ParamCenterWidthTable(const char *paramId, const char *centerName, const char *widthName) : - ParamTable(paramId), _centerName(centerName), _widthName(widthName) +std::string ParamCenterWidthTable::_centersParamKey = "TABLEPARAM_CENTERS"; +std::string ParamCenterWidthTable::_widthsParamKey = "TABLEPARAM_WIDTHS"; + +ParamCenterWidthTable::ParamCenterWidthTable(const char *paramId) : + ParamTable(paramId) { } @@ -168,37 +228,29 @@ ParamCenterWidthTable::ParamCenterWidthTable(const char *paramId, const char *ce */ int ParamCenterWidthTable::getSize(ParameterManager *parameterManager) { - ParameterSPtr tmpParam = parameterManager->getParameter(_paramId); - AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList(); - AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_centerName]; - return pTableInfo->size(); + if (!_variable) + { + std::vector centersValues = getConstantTableParamValuesByKey(parameterManager, ParamCenterWidthTable::_centersParamKey); + return centersValues.size(); + } + else + { + return 0; + } } /* * @brief Get a bound for a specified index */ -t_TableBound ParamCenterWidthTable::getBound(ParameterManager *parameterManager, unsigned int index) +t_TableBound ParamCenterWidthTable::getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData) { - ParameterSPtr tmpParam = parameterManager->getParameter(_paramId); - t_TableBound bound; bound.index = index; - if (tmpParam == nullptr) - { - LOG4CXX_ERROR(_logger, "Associated parameter not reachable!"); - bound.min = index; - bound.max = index+1; - return bound; - } - - //get table info from parameter info list - - AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList(); - AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_centerName]; - AMDA::Parameters::Parameter::InfoValuesSPtr pWidthInfo = lInfoList[_widthName]; + std::vector centersValues = getTableParamValuesByKey(parameterManager, paramsTableData, ParamCenterWidthTable::_centersParamKey); + std::vector widthsValues = getTableParamValuesByKey(parameterManager, paramsTableData, ParamCenterWidthTable::_centersParamKey); - if ((index >= pTableInfo->size()) || (index >= pWidthInfo->size())) + if ((index >= centersValues.size()) || (index >= widthsValues.size())) { LOG4CXX_ERROR(_logger, "Index " << index << " outside of table definition => Cannot get real bound" ); bound.min = index; @@ -206,14 +258,16 @@ t_TableBound ParamCenterWidthTable::getBound(ParameterManager *parameterManager, return bound; } - bound.min = (*pTableInfo)[index] - (*pWidthInfo)[index]/2.; - bound.max = (*pTableInfo)[index] + (*pWidthInfo)[index]/2.;; + bound.min = centersValues[index] - widthsValues[index]/2.; + bound.max = centersValues[index] + widthsValues[index]/2.;; return bound; } -ParamCenterAutoTable::ParamCenterAutoTable(const char *paramId, const char *centerName, bool log) : - ParamTable(paramId), _centerName(centerName), _log(log) +std::string ParamCenterAutoTable::_centersParamKey = "TABLEPARAM_CENTERS"; + +ParamCenterAutoTable::ParamCenterAutoTable(const char *paramId, bool log) : + ParamTable(paramId), _log(log) { } @@ -222,36 +276,28 @@ ParamCenterAutoTable::ParamCenterAutoTable(const char *paramId, const char *cent */ int ParamCenterAutoTable::getSize(ParameterManager *parameterManager) { - ParameterSPtr tmpParam = parameterManager->getParameter(_paramId); - AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList(); - AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_centerName]; - return pTableInfo->size(); + if (!_variable) + { + std::vector centersValues = getConstantTableParamValuesByKey(parameterManager, ParamCenterAutoTable::_centersParamKey); + return centersValues.size(); + } + else + { + return 0; + } } /* * @brief Get a bound for a specified index */ -t_TableBound ParamCenterAutoTable::getBound(ParameterManager *parameterManager, unsigned int index) +t_TableBound ParamCenterAutoTable::getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData) { - ParameterSPtr tmpParam = parameterManager->getParameter(_paramId); - t_TableBound bound; bound.index = index; - if (tmpParam == nullptr) - { - LOG4CXX_ERROR(_logger, "Associated parameter not reachable!"); - bound.min = index; - bound.max = index+1; - return bound; - } - - //get table info from parameter info list - - AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList(); - AMDA::Parameters::Parameter::InfoValuesSPtr pTableInfo = lInfoList[_centerName]; + std::vector centersValues = getTableParamValuesByKey(parameterManager, paramsTableData, ParamCenterAutoTable::_centersParamKey); - if (index >= pTableInfo->size()) + if (index >= centersValues.size()) { LOG4CXX_ERROR(_logger, "Index " << index << " outside of table definition => Cannot get real bound" ); bound.min = index; @@ -261,7 +307,7 @@ t_TableBound ParamCenterAutoTable::getBound(ParameterManager *parameterManager, //Compute bounds - if (pTableInfo->size() <= 1) + if (centersValues.size() <= 1) { LOG4CXX_ERROR(_logger, "Table dimension too small to compute bound" ); bound.min = index; @@ -275,17 +321,17 @@ t_TableBound ParamCenterAutoTable::getBound(ParameterManager *parameterManager, if (index == 0) { if (_log) - plus = exp((log10((*pTableInfo)[1]) - log10((*pTableInfo)[0]))/2.); + plus = (log10(centersValues[1]) - log10(centersValues[0]))/2.; else - plus = ((*pTableInfo)[1] - (*pTableInfo)[0])/2.; + plus = (centersValues[1] - centersValues[0])/2.; minus = plus; } - else if (index == pTableInfo->size() - 1) + else if (index == centersValues.size() - 1) { if (_log) - minus = exp((log10((*pTableInfo)[pTableInfo->size() - 1]) - log10((*pTableInfo)[pTableInfo->size() - 2]))/2.); + minus = (log10(centersValues[centersValues.size() - 1]) - log10(centersValues[centersValues.size() - 2]))/2.; else - minus = ((*pTableInfo)[pTableInfo->size() - 1] - (*pTableInfo)[pTableInfo->size() - 2])/2.; + minus = (centersValues[centersValues.size() - 1] - centersValues[centersValues.size() - 2])/2.; plus = minus; } @@ -293,18 +339,26 @@ t_TableBound ParamCenterAutoTable::getBound(ParameterManager *parameterManager, { if (_log) { - minus = exp((log10((*pTableInfo)[index]) - log10((*pTableInfo)[index-1]))/2.); - plus = exp((log10((*pTableInfo)[index+1]) - log10((*pTableInfo)[index]))/2.); + minus = (log10(centersValues[index]) - log10(centersValues[index-1]))/2.; + plus = (log10(centersValues[index+1]) - log10(centersValues[index]))/2.; } else { - minus = ((*pTableInfo)[index] - (*pTableInfo)[index-1])/2.; - plus = ((*pTableInfo)[index+1] - (*pTableInfo)[index])/2.; + minus = (centersValues[index] - centersValues[index-1])/2.; + plus = (centersValues[index+1] - centersValues[index])/2.; } } - bound.min = (*pTableInfo)[index] - minus; - bound.max = (*pTableInfo)[index] + plus; + if (_log) + { + bound.min = exp(log10(centersValues[index]) - minus); + bound.max = exp(log10(centersValues[index]) + plus); + } + else + { + bound.min = centersValues[index] - minus; + bound.max = centersValues[index] + plus; + } if (bound.min > bound.max) { @@ -316,8 +370,10 @@ t_TableBound ParamCenterAutoTable::getBound(ParameterManager *parameterManager, return bound; } -ParamMinMaxTable::ParamMinMaxTable(const char *paramId, const char *minName, const char *maxName) : - ParamTable(paramId), _minName(minName), _maxName(maxName) +std::string ParamMinMaxTable::_minParamKey = "TABLEPARAM_MIN"; +std::string ParamMinMaxTable::_maxParamKey = "TABLEPARAM_MAX"; + +ParamMinMaxTable::ParamMinMaxTable(const char *paramId) : ParamTable(paramId) { } @@ -326,37 +382,29 @@ ParamMinMaxTable::ParamMinMaxTable(const char *paramId, const char *minName, con */ int ParamMinMaxTable::getSize(ParameterManager *parameterManager) { - ParameterSPtr tmpParam = parameterManager->getParameter(_paramId); - AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList(); - AMDA::Parameters::Parameter::InfoValuesSPtr pTableMinInfo = lInfoList[_minName]; - return pTableMinInfo->size(); + if (!_variable) + { + std::vector minValues = getConstantTableParamValuesByKey(parameterManager, ParamMinMaxTable::_minParamKey); + return minValues.size(); + } + else + { + return 0; + } } /* * @brief Get bound for a specified index */ -t_TableBound ParamMinMaxTable::getBound(ParameterManager *parameterManager, unsigned int index) +t_TableBound ParamMinMaxTable::getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData) { - ParameterSPtr tmpParam = parameterManager->getParameter(_paramId); - t_TableBound bound; bound.index = index; - if (tmpParam == nullptr) - { - LOG4CXX_ERROR(_logger, "Associated parameter not reachable!"); - bound.min = index; - bound.max = index+1; - return bound; - } - - //get table info from parameter info list - - AMDA::Parameters::Parameter::InfoList lInfoList = tmpParam->getInfoList(); - AMDA::Parameters::Parameter::InfoValuesSPtr pTableMinInfo = lInfoList[_minName]; - AMDA::Parameters::Parameter::InfoValuesSPtr pTableMaxInfo = lInfoList[_maxName]; + std::vector minValues = getTableParamValuesByKey(parameterManager, paramsTableData, ParamMinMaxTable::_minParamKey); + std::vector maxValues = getTableParamValuesByKey(parameterManager, paramsTableData, ParamMinMaxTable::_maxParamKey); - if ((index >= pTableMinInfo->size()) || (index >= pTableMaxInfo->size())) + if ((index >= minValues.size()) || (index >= maxValues.size())) { LOG4CXX_ERROR(_logger, "Index " << index << " outside of table definition => Cannot get real bound" ); bound.min = index; @@ -364,8 +412,8 @@ t_TableBound ParamMinMaxTable::getBound(ParameterManager *parameterManager, unsi return bound; } - bound.min = std::min((*pTableMinInfo)[index], (*pTableMaxInfo)[index]); - bound.max = std::max((*pTableMinInfo)[index], (*pTableMaxInfo)[index]); + bound.min = std::min(minValues[index], maxValues[index]); + bound.max = std::max(minValues[index], maxValues[index]); return bound; } diff --git a/src/Info/ParamTable.hh b/src/Info/ParamTable.hh index 363faa1..463c771 100644 --- a/src/Info/ParamTable.hh +++ b/src/Info/ParamTable.hh @@ -40,7 +40,7 @@ namespace Info { virtual int getSize(ParameterManager *parameterManager) = 0; - virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index) = 0; + virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL) = 0; void setParameterLink(ParameterSPtr parameter); @@ -52,6 +52,16 @@ namespace Info { std::string getUnits(void); + void setIsVariable(bool isVariable); + + bool isVariable(void); + + void addTableParam(std::string key, std::string name); + + std::string getTableParamByKey(std::string key); + + std::map& getTableParams(); + protected: /** logger of paramTable */ static log4cxx::LoggerPtr _logger; @@ -61,6 +71,16 @@ namespace Info { std::string _tableName; std::string _tableUnits; + + bool _variable; + + std::map _tableParams; + + std::vector getTableParamValuesByKey(ParameterManager *parameterManager, std::map>* paramsTableData, std::string key); + + std::vector getConstantTableParamValuesByKey(ParameterManager *parameterManager, std::string key); + + std::vector getVariableTableParamValuesByKey(std::map>* paramsTableData, std::string key); }; /** @@ -70,14 +90,13 @@ namespace Info { */ class ParamBoundsTable : public ParamTable { public: - ParamBoundsTable(const char *paramId, const char *boundsName); + ParamBoundsTable(const char *paramId); virtual int getSize(ParameterManager *parameterManager); - virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index); + virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL); - private: - std::string _boundsName; + static std::string _boundsParamKey; }; /** @@ -87,14 +106,15 @@ namespace Info { */ class ParamCenterTable : public ParamTable { public: - ParamCenterTable(const char *paramId, const char *centerName, double size); + ParamCenterTable(const char *paramId, double size); virtual int getSize(ParameterManager *parameterManager); - virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index); + virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL); + + static std::string _centersParamKey; private: - std::string _centerName; double _size; }; @@ -105,15 +125,14 @@ namespace Info { */ class ParamCenterWidthTable : public ParamTable { public: - ParamCenterWidthTable(const char *paramId, const char *centerName, const char *widthName); + ParamCenterWidthTable(const char *paramId); virtual int getSize(ParameterManager *parameterManager); - virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index); + virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL); - private: - std::string _centerName; - std::string _widthName; + static std::string _centersParamKey; + static std::string _widthsParamKey; }; /** @@ -123,14 +142,15 @@ namespace Info { */ class ParamCenterAutoTable : public ParamTable { public: - ParamCenterAutoTable(const char *paramId, const char *centerName, bool log); + ParamCenterAutoTable(const char *paramId, bool log); virtual int getSize(ParameterManager *parameterManager); - virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index); + virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL); + + static std::string _centersParamKey; private: - std::string _centerName; bool _log; }; @@ -141,16 +161,14 @@ namespace Info { */ class ParamMinMaxTable : public ParamTable { public: - ParamMinMaxTable(const char *paramId, const char *minName, const char *maxName); + ParamMinMaxTable(const char *paramId); virtual int getSize(ParameterManager *parameterManager); - virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index); - - private: - std::string _minName; + virtual t_TableBound getBound(ParameterManager *parameterManager, unsigned int index, std::map>* paramsTableData = NULL); - std::string _maxName; + static std::string _minParamKey; + static std::string _maxParamKey; }; } /* namespace Info */ } /* namespace AMDA */ diff --git a/src/Info/ParamTableNode.cc b/src/Info/ParamTableNode.cc index 81a6617..027255d 100644 --- a/src/Info/ParamTableNode.cc +++ b/src/Info/ParamTableNode.cc @@ -63,6 +63,15 @@ public: xmlFree(value); } + //Get variable + value = xmlGetProp(pNode, (const xmlChar *) "variable"); + bool variable = false; + if (value != NULL) + { + variable = (strcmp((char*)value,"true") == 0); + xmlFree(value); + } + xmlChar* lboundsName = NULL; try { if (!(lboundsName = xmlGetProp(pNode, (const xmlChar *) "boundsName"))) { @@ -73,10 +82,12 @@ public: LOG4CXX_DEBUG(gLogger, "BoundsTable::proceed - Bounds name : " << lboundsName); boost::shared_ptr table(new ParamBoundsTable( - paramId.c_str(), (const char*)lboundsName)); + paramId.c_str())); + table->addTableParam(ParamBoundsTable::_boundsParamKey, (const char*)lboundsName); table->setName(name); table->setUnits(units); + table->setIsVariable(variable); pParamInfo->addTable(dim, table); } catch (...) { @@ -130,6 +141,15 @@ public: xmlFree(value); } + //Get variable + value = xmlGetProp(pNode, (const xmlChar *) "variable"); + bool variable = false; + if (value != NULL) + { + variable = (strcmp((char*)value,"true") == 0); + xmlFree(value); + } + xmlChar* lminTableName = NULL; xmlChar* lmaxTableName = NULL; @@ -147,10 +167,13 @@ public: LOG4CXX_DEBUG(gLogger, "MinMaxTable::proceed - Min Table name : " << lminTableName << " - Max Table name : " << lmaxTableName); boost::shared_ptr table(new ParamMinMaxTable( - paramId.c_str(), (const char*)lminTableName, (const char*)lmaxTableName)); + paramId.c_str())); + table->addTableParam(ParamMinMaxTable::_minParamKey, (const char*)lminTableName); + table->addTableParam(ParamMinMaxTable::_maxParamKey, (const char*)lmaxTableName); table->setName(name); table->setUnits(units); + table->setIsVariable(variable); pParamInfo->addTable(dim,table); @@ -207,6 +230,15 @@ public: xmlFree(value); } + //Get variable + value = xmlGetProp(pNode, (const xmlChar *) "variable"); + bool variable = false; + if (value != NULL) + { + variable = (strcmp((char*)value,"true") == 0); + xmlFree(value); + } + xmlChar* lcenterName = NULL; xmlChar* lsize = NULL; try { @@ -223,10 +255,12 @@ public: } boost::shared_ptr table(new ParamCenterTable( - paramId.c_str(), (const char*)lcenterName, atof((const char*)lsize))); + paramId.c_str(), atof((const char*)lsize))); + table->addTableParam(ParamCenterTable::_centersParamKey, (const char*)lcenterName); table->setName(name); table->setUnits(units); + table->setIsVariable(variable); pParamInfo->addTable(dim, table); } catch (...) { @@ -286,6 +320,15 @@ public: xmlFree(value); } + //Get variable + value = xmlGetProp(pNode, (const xmlChar *) "variable"); + bool variable = false; + if (value != NULL) + { + variable = (strcmp((char*)value,"true") == 0); + xmlFree(value); + } + xmlChar* lcenterName = NULL; xmlChar* lwidthName = NULL; try { @@ -304,10 +347,13 @@ public: LOG4CXX_DEBUG(gLogger, "CenterWidthTable::proceed - Width name : " << lwidthName); boost::shared_ptr table(new ParamCenterWidthTable( - paramId.c_str(), (const char*)lcenterName, (const char*)lwidthName)); + paramId.c_str())); + table->addTableParam(ParamCenterWidthTable::_centersParamKey, (const char*)lcenterName); + table->addTableParam(ParamCenterWidthTable::_widthsParamKey, (const char*)lwidthName); table->setName(name); table->setUnits(units); + table->setIsVariable(variable); pParamInfo->addTable(dim, table); } catch (...) { @@ -367,6 +413,15 @@ public: xmlFree(value); } + //Get variable + value = xmlGetProp(pNode, (const xmlChar *) "variable"); + bool variable = false; + if (value != NULL) + { + variable = (strcmp((char*)value,"true") == 0); + xmlFree(value); + } + xmlChar* lcenterName = NULL; xmlChar* llog = NULL; try { @@ -384,10 +439,12 @@ public: } boost::shared_ptr table(new ParamCenterAutoTable( - paramId.c_str(), (const char*)lcenterName, isLog)); + paramId.c_str(), isLog)); + table->addTableParam(ParamCenterAutoTable::_centersParamKey, (const char*)lcenterName); table->setName(name); table->setUnits(units); + table->setIsVariable(variable); pParamInfo->addTable(dim, table); } catch (...) { diff --git a/src/ParamGetImpl/DDServerInterface/VirtualInstrument.cc b/src/ParamGetImpl/DDServerInterface/VirtualInstrument.cc index 04da9f3..cd2ca9b 100644 --- a/src/ParamGetImpl/DDServerInterface/VirtualInstrument.cc +++ b/src/ParamGetImpl/DDServerInterface/VirtualInstrument.cc @@ -136,6 +136,10 @@ namespace DDServerInterface { recurseInfoValues(infoList, pIinfoName, data->DimNumber, data->Dimensions, *data->Variables); + } else if (data->type == DD_SHORT) { + recurseInfoValues(infoList, pIinfoName, + data->DimNumber, data->Dimensions, + *data->Variables); } } else { diff --git a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc index 0ead4d2..8fd6620 100644 --- a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc +++ b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc @@ -1563,6 +1563,9 @@ void PanelPlotOutput::drawMatrix(MatrixGrid& matrixGrid, double minDataVal, doub y[2] = part.y[1]; y[3] = y[2]; + if (isNAN(part.value)) + continue; + if (!dataValueIsColorIndex) { if (!getColoredValue(part.value, minDataVal, maxDataVal, col)) @@ -1570,8 +1573,6 @@ void PanelPlotOutput::drawMatrix(MatrixGrid& matrixGrid, double minDataVal, doub } else { - if (isNAN(part.value)) - continue; Color dataValueColor(colorMapIndex, (int)part.value); restoreColor(_pls, dataValueColor, _panel->_page->_mode); _pls->fill(4, x, y); @@ -2901,9 +2902,12 @@ void PanelPlotOutput::createParameters(std::list& usedParametersId_ std::shared_ptr pSpecProp = it->getSpectroProperties(); if (pSpecProp != nullptr) { + AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(originalParam->getInfoId()); + boost::shared_ptr tableSPtr; + if (paramInfo != nullptr) + tableSPtr = paramInfo->getTable(pSpecProp->getRelatedDim()); //get corrected sampling value in relation with max resolution double correctedSamplingValue = getCorrectedSamplingValue(pSpecProp->getMaxResolution(), samplingValue); - AMDA::Parameters::ParameterSPtr usedParam; if (abs(samplingValue - correctedSamplingValue) > 1.) @@ -2911,17 +2915,49 @@ void PanelPlotOutput::createParameters(std::list& usedParametersId_ //more than one second between samplingValue and correctedSamplingValue //=> use resampling parameter usedParam = createSampledParameter(originalParam, correctedSamplingValue); + if ((tableSPtr != nullptr) && tableSPtr->isVariable()) + { + for (std::map::iterator it = tableSPtr->getTableParams().begin(); it != tableSPtr->getTableParams().end(); ++it) + { + std::string tableParamKey = it->first; + std::string tableParamName = it->second; + + AMDA::Parameters::ParameterSPtr originalTableParam = _parameterManager.getParameter(tableParamName); + AMDA::Parameters::ParameterSPtr usedTableParam = createSampledParameter(originalTableParam, correctedSamplingValue); + pSpecProp->addTableParam(tableParamKey, usedTableParam->getId()); + } + } } else { //use original parameter usedParam = originalParam; + if ((tableSPtr != nullptr) && tableSPtr->isVariable()) + { + for (std::map::iterator it = tableSPtr->getTableParams().begin(); it != tableSPtr->getTableParams().end(); ++it) + { + std::string tableParamKey = it->first; + std::string tableParamName = it->second; + + AMDA::Parameters::ParameterSPtr originalTableParam = _parameterManager.getParameter(tableParamName); + pSpecProp->addTableParam(tableParamKey, originalTableParam->getId()); + } + } } //Add used parameter to parameters list if (std::find (usedParametersId_.begin(),usedParametersId_.end(),usedParam->getId()) == usedParametersId_.end()) usedParametersId_.push_back(usedParam->getId()); pSpecProp->setParamId(usedParam->getId()); + //Add table parameters to parameters list + for (std::map::iterator it = pSpecProp->getTableParams().begin(); it != pSpecProp->getTableParams().end(); ++it) + { + std::string tableParamKey = it->first; + std::string tableParamId = it->second; + + if (std::find (usedParametersId_.begin(),usedParametersId_.end(),tableParamId) == usedParametersId_.end()) + usedParametersId_.push_back(tableParamId); + } } } } diff --git a/src/ParamOutputImpl/Plot/ParameterData.cc b/src/ParamOutputImpl/Plot/ParameterData.cc index ce4bb79..baf574f 100644 --- a/src/ParamOutputImpl/Plot/ParameterData.cc +++ b/src/ParamOutputImpl/Plot/ParameterData.cc @@ -188,20 +188,26 @@ void ComponentParameterData::preAllocate(int nbData) void ComponentParameterData::addValue(double value) { _values.push_back(value); - if (isnan(_min) && !isnan(value)) { - _min = value; - } else if (!isnan(_min) && !isnan(value)) { - _min = std::min(_min, value); - } + if (!isnan(value)) + { + if (isnan(_min)) + _min = value; + else + _min = std::min(_min, value); - if (isnan(_max) && !isnan(value)) { - _max = value; - } else if (!isnan(value) && !isnan(_max)) { - _max = std::max(_max, value); - } + if (isnan(_max)) + _max = value; + else + _max = std::max(_max, value); - if (isnan(_minStrictPos) && !isnan(value) && (value > 0)) - _minStrictPos = std::min(_min, value); + if (value > 0) + { + if (isnan(_minStrictPos)) + _minStrictPos = value; + else + _minStrictPos = std::min(_min, value); + } + } } } /* namespace plot */ diff --git a/src/ParamOutputImpl/Plot/SpectroProperties.hh b/src/ParamOutputImpl/Plot/SpectroProperties.hh index 59941f7..8020714 100644 --- a/src/ParamOutputImpl/Plot/SpectroProperties.hh +++ b/src/ParamOutputImpl/Plot/SpectroProperties.hh @@ -56,6 +56,7 @@ public: SpectroProperties& operator=(const SpectroProperties& ref_) { DrawingProperties::operator=(ref_); _paramId = ref_._paramId; + _tableParamsId = ref_._tableParamsId; _hasYAxis = ref_._hasYAxis; _hasXAxis = ref_._hasXAxis; _hasZAxis = ref_._hasZAxis; @@ -76,6 +77,18 @@ public: _paramId = paramId_; } + std::string getTableParamIdByName(std::string paramName){ + return _tableParamsId[paramName]; + } + + std::map& getTableParams() { + return _tableParamsId; + } + + void addTableParam(std::string paramName, std::string paramId) { + _tableParamsId[paramName] = paramId; + } + bool hasXAxis() const { return _hasXAxis; } @@ -135,6 +148,11 @@ private: std::string _paramId; /** + * @brief Calculated tableParamsId (from resolution). + */ + std::map _tableParamsId; + + /** * @brief Flag that indicates the serie has X Axis */ bool _hasXAxis; diff --git a/src/ParamOutputImpl/Plot/Time/TimePlot.cc b/src/ParamOutputImpl/Plot/Time/TimePlot.cc index 1edd762..fdaadd5 100644 --- a/src/ParamOutputImpl/Plot/Time/TimePlot.cc +++ b/src/ParamOutputImpl/Plot/Time/TimePlot.cc @@ -278,11 +278,39 @@ void TimePlot::configureSpectroAxis() { else { AMDA::Info::t_TableBound crtBound; - for (int i = 0; i < parameterDimension; ++i) + if (!tableSPtr->isVariable()) { - crtBound = tableSPtr->getBound(&_parameterManager, i); - lYAxisRange.setMin(std::min(crtBound.min,lYAxisRange.getMin())); - lYAxisRange.setMax(std::max(crtBound.max,lYAxisRange.getMax())); + for (int i = 0; i < parameterDimension; ++i) + { + crtBound = tableSPtr->getBound(&_parameterManager, i); + lYAxisRange.setMin(std::min(crtBound.min,lYAxisRange.getMin())); + lYAxisRange.setMax(std::max(crtBound.max,lYAxisRange.getMax())); + } + } + else + { + //Variable table => we need to loop under all records to find axis min & max values + for (int i = 0; i < (*_pParameterValues)[spectroPropertiesPtr->getParamId()].getSize(); ++i) + { + std::map> paramsTableData; + for (std::map::iterator it = spectroPropertiesPtr->getTableParams().begin(); it != spectroPropertiesPtr->getTableParams().end(); ++it) + { + ParameterData& data = (*_pParameterValues)[it->second]; + std::vector paramTableValues; + for (int j = 0; j < data.getDim1Size(); ++j) + { + double* values = data.getValues(AMDA::Common::ParameterIndexComponent(j,-1), i); + paramTableValues.push_back((*values)); + } + paramsTableData[it->first] = paramTableValues; + } + for (int j = 0; j < parameterDimension; ++j) + { + crtBound = tableSPtr->getBound(&_parameterManager, j, ¶msTableData); + lYAxisRange.setMin(std::min(crtBound.min,lYAxisRange.getMin())); + lYAxisRange.setMax(std::max(crtBound.max,lYAxisRange.getMax())); + } + } } // Set Y axis legend if not already done @@ -305,7 +333,7 @@ void TimePlot::configureSpectroAxis() { otherTableSPtr = paramInfo->getTable(0); otherDimIndex = spectroPropertiesPtr->getIndexes().front().getDim1Index(); } - if (otherTableSPtr != nullptr) + if ((otherTableSPtr != nullptr) && !otherTableSPtr->isVariable()) { AMDA::Info::t_TableBound crtBound = otherTableSPtr->getBound(&_parameterManager, otherDimIndex); if (otherTableSPtr->getName().empty()) @@ -364,8 +392,10 @@ void TimePlot::configureSpectroAxis() { else minVal = (*_pParameterValues)[spectroPropertiesPtr->getParamId()].getMin(index); maxVal = (*_pParameterValues)[spectroPropertiesPtr->getParamId()].getMax(index); - lParamRange.setMin(std::min(minVal,lParamRange.getMin())); - lParamRange.setMax(std::max(maxVal,lParamRange.getMax())); + if (!isnan(maxVal)) + lParamRange.setMin(std::min(minVal,lParamRange.getMin())); + if (!isnan(maxVal)) + lParamRange.setMax(std::max(maxVal,lParamRange.getMax())); } } else @@ -893,49 +923,101 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam } MatrixGrid matrixGrid; - for (auto index : pSpectro.getIndexes()) + + if ((tableSPtr == nullptr) || !tableSPtr->isVariable()) { - GridPart part; - if (tableSPtr == nullptr) - { - if (pSpectro.getRelatedDim() == 0) - part.y[0] = index.getDim1Index(); - else - part.y[0] = index.getDim2Index(); - part.y[1] = part.y[0]+1; - } - else + for (auto index : pSpectro.getIndexes()) { - AMDA::Info::t_TableBound crtBound; - if (pSpectro.getRelatedDim() == 0) - crtBound = tableSPtr->getBound(&_parameterManager, index.getDim1Index()); + GridPart part; + if (tableSPtr == nullptr) + { + if (pSpectro.getRelatedDim() == 0) + part.y[0] = index.getDim1Index(); + else + part.y[0] = index.getDim2Index(); + part.y[1] = part.y[0]+1; + } else - crtBound = tableSPtr->getBound(&_parameterManager, index.getDim2Index()); - part.y[0] = crtBound.min; - part.y[1] = crtBound.max; - if (lYAxis->_scale == Axis::Scale::LOGARITHMIC) { - part.y[0] = ((part.y[0] > 0) ? log10(part.y[0]) : 10e-3); - part.y[1] = ((part.y[1] > 0) ? log10(part.y[1]) : 10e-3); + AMDA::Info::t_TableBound crtBound; + if (pSpectro.getRelatedDim() == 0) + crtBound = tableSPtr->getBound(&_parameterManager, index.getDim1Index()); + else + crtBound = tableSPtr->getBound(&_parameterManager, index.getDim2Index()); + part.y[0] = crtBound.min; + part.y[1] = crtBound.max; + if (lYAxis->_scale == Axis::Scale::LOGARITHMIC) + { + part.y[0] = ((part.y[0] > 0) ? log10(part.y[0]) : 10e-3); + part.y[1] = ((part.y[1] > 0) ? log10(part.y[1]) : 10e-3); + } } - } - //get original data for interval [startDate, stopDate] - int startIndex; - int nbValues; - double *valuesInterval = data.getIntervalValues(startDate, stopDate, index, + //get original data for interval [startDate, stopDate] + int startIndex; + int nbValues; + double *valuesInterval = data.getIntervalValues(startDate, stopDate, index, startIndex, nbValues); - if (valuesInterval == NULL) - continue; + if (valuesInterval == NULL) + continue; - for (int i = startIndex; i < startIndex + nbValues - 1; ++i) + for (int i = startIndex; i < startIndex + nbValues - 1; ++i) + { + part.x[0] = data.getTimes()[i]; + part.x[1] = data.getTimes()[i+1]; + + part.value = valuesInterval[i]; + matrixGrid.push_back(part); + } + } + } + else + { + //Variable table + AMDA::Info::t_TableBound crtBound; + for (auto index : pSpectro.getIndexes()) { - part.x[0] = data.getTimes()[i]; - part.x[1] = data.getTimes()[i+1]; + int startIndex; + int nbValues; + double *valuesInterval = data.getIntervalValues(startDate, stopDate, index, + startIndex, nbValues); + for (int i = startIndex; i < startIndex + nbValues - 1; ++i) + { + GridPart part; + part.x[0] = data.getTimes()[i]; + part.x[1] = data.getTimes()[i+1]; - part.value = valuesInterval[i]; - matrixGrid.push_back(part); + part.value = valuesInterval[i]; + + std::map> paramsTableData; + for (std::map::iterator it = pSpectro.getTableParams().begin(); it != pSpectro.getTableParams().end(); ++it) + { + ParameterData& tableData = (*_pParameterValues)[it->second]; + std::vector paramTableValues; + for (int j = 0; j < data.getDim1Size(); ++j) + { + double* values = tableData.getValues(AMDA::Common::ParameterIndexComponent(j,-1), i); + paramTableValues.push_back((*values)); + } + paramsTableData[it->first] = paramTableValues; + } + + if (pSpectro.getRelatedDim() == 0) + crtBound = tableSPtr->getBound(&_parameterManager, index.getDim1Index(), ¶msTableData); + else + crtBound = tableSPtr->getBound(&_parameterManager, index.getDim2Index(), ¶msTableData); + + part.y[0] = crtBound.min; + part.y[1] = crtBound.max; + if (lYAxis->_scale == Axis::Scale::LOGARITHMIC) + { + part.y[0] = ((part.y[0] > 0) ? log10(part.y[0]) : 10e-3); + part.y[1] = ((part.y[1] > 0) ? log10(part.y[1]) : 10e-3); + } + + matrixGrid.push_back(part); + } } } diff --git a/src/Parameters/VisitorOfParamData.hh b/src/Parameters/VisitorOfParamData.hh index 7c6b8c9..74b17f2 100644 --- a/src/Parameters/VisitorOfParamData.hh +++ b/src/Parameters/VisitorOfParamData.hh @@ -61,6 +61,18 @@ public: return _data[col]; } + std::vector toVector() + { + std::vector res(_data, _data + _size); + return res; + } + + const std::vector toVector() const + { + std::vector res(_data, _data + _size); + return res; + } + private: int _size; -- libgit2 0.21.2