From be29edb90b30a79716a63589b171ff4171b520fa Mon Sep 17 00:00:00 2001 From: Furkan Date: Wed, 5 Oct 2022 09:29:58 +0200 Subject: [PATCH] #6598 / #10557 / #5638 - Done --- src/ExternLib/Timestamp/AMDAPlugin.cc | 5 +++++ src/ExternLib/Timestamp/TimestampCreator.hh | 16 +++++++++------- src/ExternLib/Timestamp/Timestamp_FromProcess.cc | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ExternLib/Timestamp/Timestamp_FromProcess.hh | 42 ++++++++++++++++++++++++++++++++++++++++++ src/ExternLib/Timestamp/Timestamp_Process.cc | 28 +--------------------------- src/ExternLib/Timestamp/Timestamp_op.hh | 13 ++++++++++--- 6 files changed, 130 insertions(+), 37 deletions(-) create mode 100644 src/ExternLib/Timestamp/Timestamp_FromProcess.cc create mode 100644 src/ExternLib/Timestamp/Timestamp_FromProcess.hh diff --git a/src/ExternLib/Timestamp/AMDAPlugin.cc b/src/ExternLib/Timestamp/AMDAPlugin.cc index a8cbadf..ef155a8 100644 --- a/src/ExternLib/Timestamp/AMDAPlugin.cc +++ b/src/ExternLib/Timestamp/AMDAPlugin.cc @@ -7,6 +7,7 @@ #include "PluginManager.hh" #include "Timestamp_Process.hh" +#include "Timestamp_FromProcess.hh" using namespace AMDA::Parameters; @@ -26,4 +27,8 @@ extern "C" void registerPlugin(AMDA::Plugins::PluginManager &pm) ProcessFactory factTimestamp_Process = boost::factory(); ServicesServer::getInstance()->addProcessFactory("timestamp", factTimestamp_Process); ServicesServer::getInstance()->linkProcessWithPlugin("timestamp", pm.getCurrentPluginPath()); + + ProcessFactory factTimestamp_FromProcess = boost::factory(); + ServicesServer::getInstance()->addProcessFactory("timestampfrom", factTimestamp_FromProcess); + ServicesServer::getInstance()->linkProcessWithPlugin("timestampfrom", pm.getCurrentPluginPath()); } diff --git a/src/ExternLib/Timestamp/TimestampCreator.hh b/src/ExternLib/Timestamp/TimestampCreator.hh index 97c4d04..a9221bf 100644 --- a/src/ExternLib/Timestamp/TimestampCreator.hh +++ b/src/ExternLib/Timestamp/TimestampCreator.hh @@ -5,10 +5,10 @@ */ /* - * File: InternalFieldsCreator.hh + * File: TimestampCreator.hh * Author: Furkan - AKKA I&S * - * Created on July 11, 2022, 4:14 PM + * Created on September 26, 2022, 4:14 PM */ #ifndef TIMESTAMPCREATOR_HH @@ -25,10 +25,9 @@ namespace AMDA class TimestampCreator : public VisitorOfParamData { public: - TimestampCreator(Process &pProcess, ParamData ¶mInput) - : _process(pProcess), _paramData(paramInput), _operation(NULL) + TimestampCreator(Process &pProcess, ParamData ¶mInput, bool isTimeFrom, double timeFrom = 0.0) + : _process(pProcess), _paramData(paramInput), _isTimeFrom(isTimeFrom), _timeFrom(timeFrom), _operation(NULL) { - _paramData.accept(*this); } @@ -187,15 +186,18 @@ namespace AMDA template void create() { - _operation = new Timestamp_op(_process, dynamic_cast(_paramData)); + _operation = new Timestamp_op(_process, dynamic_cast(_paramData), _isTimeFrom, _timeFrom); + } private: Process &_process; ParamData &_paramData; + bool _isTimeFrom; + double _timeFrom; Operation *_operation; }; } } -#endif /* INTERNALFIELDSCREATOR_HH */ +#endif /* TIMESTAMPCREATOR_HH */ diff --git a/src/ExternLib/Timestamp/Timestamp_FromProcess.cc b/src/ExternLib/Timestamp/Timestamp_FromProcess.cc new file mode 100644 index 0000000..628919d --- /dev/null +++ b/src/ExternLib/Timestamp/Timestamp_FromProcess.cc @@ -0,0 +1,63 @@ +/* + * 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: Timestamp_FromProcess.cc + * Author: Furkan - AKKA I&S + * + * Created on Septemner 19, 2022, 4:14 PM + */ +#include +#include + +#include "Operation.hh" +#include "ParameterManager.hh" +#include "ParameterCreatorFromExpression.hh" +#include "Timestamp_FromProcess.hh" +#include "TimestampCreator.hh" + +namespace AMDA +{ + namespace Parameters + { + + Timestamp_FromProcess::Timestamp_FromProcess(Parameter ¶meter) : SingleParamProcess_CRTP(parameter) + { + } + + Timestamp_FromProcess::Timestamp_FromProcess(const Timestamp_FromProcess &pProcess, Parameter ¶meter) : SingleParamProcess_CRTP(pProcess, parameter) + { + } + + TimeStamp Timestamp_FromProcess::init() + { + + TimeStamp timeStamp = _parameterInput->init(this, _timeIntervalList); + Parameter::InfoList lInfoList = _parameterInput->getInfoList(); + _parameter.getInfoList().insert(lInfoList.begin(), lInfoList.end()); + _paramInput = _parameterInput->getParamData(this).get(); + + /* Get the value of the time from witch we need to start */ + if (_attributList.size() == 1) + { + _timeFrom = std::stod(_attributList[0]) ; + } + + + /* Creation of the operation */ + + TimestampCreator lCreator(*this, *_paramInput, true, _timeFrom); + _operation = lCreator.getOperation(); + _paramData = ParamDataSPtr(_operation->getParamOutput()); + _paramData->setMinSampling(_paramInput->getMinSampling()); + return timeStamp; + } + + Timestamp_FromProcess::~Timestamp_FromProcess() + { + } + } +} \ No newline at end of file diff --git a/src/ExternLib/Timestamp/Timestamp_FromProcess.hh b/src/ExternLib/Timestamp/Timestamp_FromProcess.hh new file mode 100644 index 0000000..4ab5b8c --- /dev/null +++ b/src/ExternLib/Timestamp/Timestamp_FromProcess.hh @@ -0,0 +1,42 @@ +/* + * 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: TimeStamp_FromProcess.hh + * Author: Furkan - AKKA I&S + * + * Created on September 19, 2022, 4:14 PM + */ + +#ifndef TIMESTAMP_FROMPROCESS_HH +#define TIMESTAMP_FROMPROCESS_HH + +#include "SingleParamProcess.hh" + +namespace AMDA +{ + namespace Parameters + { + + class Timestamp_FromProcess : public AMDA::Parameters::SingleParamProcess_CRTP + { + public: + Timestamp_FromProcess(Parameter ¶meter); + Timestamp_FromProcess(const Timestamp_FromProcess &pProcess, Parameter &pParameter); + virtual ~Timestamp_FromProcess(); + + /** + * @overload DataWriter::init() + */ + TimeStamp init(); + + protected: + std::string _processType; + double _timeFrom; + }; + } +} +#endif /* TIMESTAMP_FROMPROCESS_HH */ diff --git a/src/ExternLib/Timestamp/Timestamp_Process.cc b/src/ExternLib/Timestamp/Timestamp_Process.cc index 9f42daa..752fb80 100644 --- a/src/ExternLib/Timestamp/Timestamp_Process.cc +++ b/src/ExternLib/Timestamp/Timestamp_Process.cc @@ -39,36 +39,10 @@ namespace AMDA Parameter::InfoList lInfoList = _parameterInput->getInfoList(); _parameter.getInfoList().insert(lInfoList.begin(), lInfoList.end()); _paramInput = _parameterInput->getParamData(this).get(); - - /* Get the modelname and the boolean for the use or not of Con2020 - std::string modelname; - if (_attributList.size() == 2) - { - switch (std::stoi(_attributList[0])) - { - case 0: - modelname = "jrm09"; - break; - case 1: - modelname = "jrm33"; - break; - case 2: - modelname = "isaac"; - break; - default: - modelname = "jrm09"; - break; - } - if (std::stoi(_attributList[1]) >= 0 && std::stoi(_attributList[1]) <= 3) // 0: no Con2020, 1 : Analytic, 2: Integral, 3: Hybrid - _addCon2020 = std::stoi(_attributList[1]); - else - _addCon2020 = 0; - } - */ /* Creation of the operation */ - TimestampCreator lCreator(*this, *_paramInput); + TimestampCreator lCreator(*this, *_paramInput, false); _operation = lCreator.getOperation(); _paramData = ParamDataSPtr(_operation->getParamOutput()); _paramData->setMinSampling(_paramInput->getMinSampling()); diff --git a/src/ExternLib/Timestamp/Timestamp_op.hh b/src/ExternLib/Timestamp/Timestamp_op.hh index 092f763..2f9e588 100644 --- a/src/ExternLib/Timestamp/Timestamp_op.hh +++ b/src/ExternLib/Timestamp/Timestamp_op.hh @@ -24,8 +24,8 @@ namespace AMDA class Timestamp_op : public Operation { public: - Timestamp_op(Process &pProcess, ParamDataType ¶mInput) - : Operation(pProcess), _paramInput(paramInput), + Timestamp_op(Process &pProcess, ParamDataType ¶mInput, bool isTimeFrom, double timeFrom) + : Operation(pProcess), _paramInput(paramInput), _isTimeFrom(isTimeFrom), _timeFrom(timeFrom), _paramOutput(new ParamDataScalaireDouble()) { _paramDataOutput = _paramOutput; @@ -41,14 +41,21 @@ namespace AMDA ++_index) { double crtTime = _paramInput.getTime(_index); - _paramOutput->pushTime(crtTime); + + if (_isTimeFrom){ + if(_timeFrom > 0 && _timeFrom <= crtTime){ + crtTime -= _timeFrom; + } + } _paramOutput->push(crtTime); } } protected: ParamDataType &_paramInput; + bool _isTimeFrom; + double _timeFrom; ParamDataScalaireDouble *_paramOutput; }; } -- libgit2 0.21.2