diff --git a/src/ExternLib/StatisticCorrelation/AMDAPlugin.cc b/src/ExternLib/StatisticCorrelation/AMDAPlugin.cc new file mode 100644 index 0000000..8085433 --- /dev/null +++ b/src/ExternLib/StatisticCorrelation/AMDAPlugin.cc @@ -0,0 +1,35 @@ +// Standard libraries include files +//----------------------------------------------------------------------------- +#include + +// Include oriented definitions +//----------------------------------------------------------------------------- + +// Module Kernel include files +//----------------------------------------------------------------------------- + +#include "CorrelationProcess.hh" +#include "ServicesServer.hh" +#include "PluginManager.hh" + +using namespace AMDA::Parameters; + +// Other modules include files +//----------------------------------------------------------------------------- + +/** + 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) { + std::string pluginPath=pm.getCurrentPluginPath(); + ProcessFactory factProcessCorrelation = boost::factory(); + ServicesServer::getInstance()->addProcessFactory("statCorrelation", factProcessCorrelation); + ServicesServer::getInstance()->linkProcessWithPlugin("statCorrelation", pluginPath); + } diff --git a/src/ExternLib/StatisticCorrelation/CMakeLists.txt b/src/ExternLib/StatisticCorrelation/CMakeLists.txt new file mode 100644 index 0000000..9d76923 --- /dev/null +++ b/src/ExternLib/StatisticCorrelation/CMakeLists.txt @@ -0,0 +1,36 @@ + +PROJECT(statisticCorrelation) + +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/ + ${CMAKE_HOME_DIRECTORY}/src/Info/ + ${LOG4CXX_INCLUDE_DIR} + ${Boost_INCLUDE_DIR} +) + +#Library configuration +file( + GLOB_RECURSE + source_files + ./* +) + +ADD_LIBRARY( statisticCorrelation SHARED ${source_files} ) + + +target_link_libraries( + statisticCorrelation + ${LOG4CXX_LIBRARIES} + Parameters + InternLib + TimeTableCatalog + TimeUtil + Info +) diff --git a/src/ExternLib/StatisticCorrelation/CorrelationProcess.cc b/src/ExternLib/StatisticCorrelation/CorrelationProcess.cc new file mode 100644 index 0000000..6bf062b --- /dev/null +++ b/src/ExternLib/StatisticCorrelation/CorrelationProcess.cc @@ -0,0 +1,95 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/* + * File: CorrelationProcess.cc + * Author: hacene + * + * Created on September 27, 2021, 10:02 AM + */ +#include +#include + +#include + +#include "DicError.hh" +#include "AMDA_exception.hh" + +#include "Operation.hh" +#include "ParameterManager.hh" +#include "ParamMgr.hh" +#include "ParameterCreatorFromExpression.hh" +#include "CorrelationProcess.hh" +using namespace std; +using namespace boost; +using namespace log4cxx; + +namespace AMDA { + namespace Parameters { + + CorrelationProcess::CorrelationProcess SingleParamProcess_CRTP(parameter) { + } + + CorrelationProcess::CorrelationProcess(const CorrelationProcess& pProcess, Parameter ¶meter) : SingleParamProcess_CRTP(pProcess, parameter) { + } + + CorrelationProcess::~CorrelationProcess() { + if (_secondInputParam != nullptr) + _secondInputParam->closeConnection(this); + } + + void CorrelationProcess::establishConnection() { + + + if (_attributList.size() < 3) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("CorrelationProcess::parse require 3 attributes'"))); + } + + //Imf parameter + _secondInputParam = _parameter.getParameterManager().getParameter(_attributList[0]); + if (_secondInputParam == nullptr) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("CorrelationProcess::parse cannot retrieve imf param"))); + } + _secondInputParam->openConnection(this); + + SingleParamProcess::establishConnection(); + } + + TimeStamp CorrelationProcess::init() { + _windowtime = atof(_attributList[1].c_str()); + _type = _attributList[2]; + + TimeStamp time = _parameterInput->init(this, _timeIntervalList); + _paramInput = _parameterInput->getParamData(this).get(); + + _secondInputParam->init(this, _timeIntervalList); + ParamData* lSecondParamInput = _secondInputParam->getParamData(this).get(); + + return time; + } + + unsigned int CorrelationProcess::write() { + getSecondParamData(); + return SingleParamProcess::write(); + } + + void CorrelationProcess::getSecondParamData() { + /** + try { + ParamDataIndexInfo lParamDataIndexInfo; + lParamDataIndexInfo = _secondInputParam->getAsync(this).get(); + while ((!lParamDataIndexInfo._noMoreTimeInt && !lParamDataIndexInfo._timeIntToProcessChanged) || (lParamDataIndexInfo._nbDataToProcess > 0)) { + reinterpret_cast (_operation)->pushSecondParamData(lParamDataIndexInfo); + if (lParamDataIndexInfo._timeIntToProcessChanged || lParamDataIndexInfo._noMoreTimeInt) + break; + lParamDataIndexInfo = _secondInputParam->getAsync(this).get(); + } + } catch (...) { + throw; + }*/ + } + } +} diff --git a/src/ExternLib/StatisticCorrelation/CorrelationProcess.hh b/src/ExternLib/StatisticCorrelation/CorrelationProcess.hh new file mode 100644 index 0000000..db7dd00 --- /dev/null +++ b/src/ExternLib/StatisticCorrelation/CorrelationProcess.hh @@ -0,0 +1,67 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/* + * File: CorrelationProcess.hh + * Author: hacene + * + * Created on September 27, 2021, 10:02 AM + */ + +#ifndef CORRELATIONPROCESS_HH +#define CORRELATIONPROCESS_HH + +#include "SingleParamProcess.hh" +#include "ParamInfo.hh" + +namespace AMDA { + namespace Parameters { + + class CorrelationProcess : public SingleParamProcess_CRTP { + public: + CorrelationProcess(Parameter ¶meter); + CorrelationProcess(const CorrelationProcess& pProcess, Parameter ¶meter); + + virtual ~CorrelationProcess(); + /** + * @overload Process::establishConnection() + */ + void establishConnection(); + + /** + * @overload Process::init() + */ + TimeStamp init(); + + /* + + * Write data in dataParam. + */ + unsigned int write(); + + protected: + + void getSecondParamData(); + + std::string _type; + + double _windowtime; + + + private: + /** + * @brief list of param name intput + * @detail this list must be ordered + */ + ParameterSPtr _secondInputParam; + + + }; + + } +} +#endif /* CORRELATIONPROCESS_HH */ + diff --git a/src/ExternLib/StatisticCorrelation/StatisticCorrelationCreator.hh b/src/ExternLib/StatisticCorrelation/StatisticCorrelationCreator.hh new file mode 100644 index 0000000..5b070f4 --- /dev/null +++ b/src/ExternLib/StatisticCorrelation/StatisticCorrelationCreator.hh @@ -0,0 +1,183 @@ +/* + * StatisticCorrelationCreator.hh + * + * Created on: Mar 26, 2019 + * Author: AKKA IS + */ + +#ifndef STATISTICCORRELATIONCREATOR_HH_ +#define STATISTICCORRELATIONCREATOR_HH_ + +#include "ParamData.hh" +#include "VisitorOfParamData.hh" +#include "SumIntoTableIndexes.hh" +#include "AMDA_exception.hh" + +namespace AMDA { + namespace Parameters { + + /** + * @class SumIntoTableIndexesCreator + * @brief Creator of the Operation SumIntoTableIndexes parameterized with ParamData input type. + * @details Implement the interface VisitorOfParamData. + */ + class StatisticCorrelationCreator : public VisitorOfParamData { + public: + + /** + * @brief Constructor. + */ + StatisticCorrelationCreator(Process& pProcess, ParamData& paramInput, ParamData& secondParamInput, double windowtime, const std::string type) + : _process(pProcess), _paramData(paramInput), _secondParamInput(secondParamInput), _windowtime(windowtime), _type(type) { + _paramData.accept(*this); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireShort *) + */ + void visit(ParamDataScalaireShort *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *) + */ + void visit(ParamDataScalaireFloat *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator 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("Tsyganenko96Creator 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("Tsyganenko96Creator 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("Tsyganenko96Creator 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("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DShort *) + */ + void visit(ParamDataTab1DShort *) { + createOperation1D(); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *) + */ + void visit(ParamDataTab1DFloat *) { + createOperation1D(); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *) + */ + void visit(ParamDataTab1DDouble *) { + createOperation1D(); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *) + */ + void visit(ParamDataTab1DLongDouble *) { + createOperation1D(); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DInt *) + */ + void visit(ParamDataTab1DInt *) { + createOperation1D(); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *) + */ + void visit(ParamDataTab1DLogicalData *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator 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("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *) + */ + void visit(ParamDataTab2DFloat *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *) + */ + void visit(ParamDataTab2DDouble *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *) + */ + void visit(ParamDataTab2DLongDouble *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DInt *) + */ + void visit(ParamDataTab2DInt *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *) + */ + void visit(ParamDataTab2DLogicalData *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @brief get the Tsyganenko96 parameterized operation. + */ + Operation * getOperation() const { + return _operation; + } + private: + + template + void createOperation1D() { + } + + Process &_process; + ParamData &_paramData; + ParamData &_secondParamInput; + double _windowtime; + std::string _type; + Operation *_operation; + }; + + } /* namespace Parameters */ +} /* namespace AMDA */ +#endif /* FRAMEINTOTABLEINDEXESCREATOR_HH_ */ diff --git a/src/ExternLib/StatisticFunctions/ProcessStatisticCorrelation.cc b/src/ExternLib/StatisticFunctions/ProcessStatisticCorrelation.cc deleted file mode 100644 index 0b6c9f3..0000000 --- a/src/ExternLib/StatisticFunctions/ProcessStatisticCorrelation.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -/* - * File: ProcessStatisticCorrelation.c++ - * Author: hacene - * - * Created on September 24, 2021, 4:36 PM - */ - - -#include -#include - -#include "AMDA_exception.hh" -#include "DicError.hh" - -#include "Operation.hh" -#include "ParameterManager.hh" -#include "ParameterCreatorFromExpression.hh" - -#include "ProcessStatisticCorrelation.hh" - -namespace AMDA { - namespace Parameters { - - ProcessStatisticCorrelation::ProcessStatisticCorrelation(Parameter ¶meter) - : MultiParamProcess_CRTP(parameter) { - } - - ProcessStatisticCorrelation::ProcessStatisticCorrelation(const ProcessStatisticCorrelation& orig) { - } - - ProcessStatisticCorrelation::~ProcessStatisticCorrelation() { - } - - void ProcessStatisticCorrelation::parse() { - ParameterCreatorFromExpression creator(_parameter.getParameterManager()); - ParameterSPtr lParameter = creator.getOneParameterFromExpression(_parameter, _expression, isUserProcess()); - _paramNameList[lParameter->getId()].first = lParameter; - _orderParamNameList.push_back(lParameter->getId()); - /// get other Parameter in attribute list - if (_attributList.size() < 2) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessStatisticCorrelation::parse required at least two attribute'"))); - } - for (auto param : _attributList) { - lParameter = creator.getOneParameterFromExpression(_parameter, param, isUserProcess()); - _paramNameList[lParameter->getId()].first = lParameter; - _orderParamNameList.push_back(lParameter->getId()); - } - } - - void ProcessStatisticCorrelation::establishConnection() { - parse(); - MultiParamProcess::establishConnection(); - } - - TimeStamp ProcessStatisticCorrelation::init() { - TimeStamp timeStamp = MultiParamProcess::init(); - - /// ParamData result Type is the same as the ParamData input - ParamData* lFirstParamInput = _paramNameList[_orderParamNameList[0]].first->getParamData(this).get(); - ParamData* SecondParamInput = _paramNameList[_orderParamNameList[2]].first->getParamData(this).get(); - - return timeStamp; - } - - } -} \ No newline at end of file diff --git a/src/ExternLib/StatisticFunctions/ProcessStatisticCorrelation.hh b/src/ExternLib/StatisticFunctions/ProcessStatisticCorrelation.hh deleted file mode 100644 index 3dbe596..0000000 --- a/src/ExternLib/StatisticFunctions/ProcessStatisticCorrelation.hh +++ /dev/null @@ -1,54 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -/* - * File: ProcessStatisticCorrelation.hh - * Author: hacene - * - * Created on September 24, 2021, 4:36 PM - */ - -#ifndef PROCESSSTATISTICCORRELATION_HH -#define PROCESSSTATISTICCORRELATION_HH - -#include "MultiParamProcess.hh" -namespace AMDA { - namespace Parameters { - - class ProcessStatisticCorrelation : public AMDA::Parameters::MultiParamProcess_CRTP{ - public: - ProcessStatisticCorrelation(AMDA::Parameters::Parameter ¶meter); - ProcessStatisticCorrelation(const ProcessStatisticCorrelation& pProcess, AMDA::Parameters::Parameter &pParameter); - virtual ~ProcessStatisticCorrelation(); - /** - * @overload Process::establishConnection() - */ - void establishConnection(); - /** - * @overload Process::init() - */ - TimeStamp init(); - protected: - - /** - * @brief If the expression is not a Single parameter, - * it must ask the creation of a parameter responsible of the formula calculation. - */ - void parse(); - - private: - /** - * @brief list of param name intput - * @detail - */ - std::vector _orderParamNameList; - - }; - - } -} -#endif /* PROCESSSTATISTICCORRELATION_HH */ - -- libgit2 0.21.2