/* * ParamOutputDataMining.hh * * Created on: 23 août 2013 * Author: CS */ #ifndef PARAMOUTPUTDATAMINING_HH_ #define PARAMOUTPUTDATAMINING_HH_ #include #include #include // Parameters #include "ParamOutput.hh" #include "VisitorOfParamData.hh" // DataMining #include "ParamNode.hh" #include "DataMiningValidInterval.hh" #include "DataMiningInvalidInterval.hh" // TimeTable #include "TimeTable.hh" using namespace AMDA::Parameters; using namespace TimeTableCatalog; namespace AMDA { namespace Parameters { class ParameterManager; } // namespace Parameters namespace ParamOutputImpl { /** * @brief Implement ParamOutput to store logical state of an equation in file. */ namespace DataMining { typedef std::list DataMiningValidIntervalList; typedef std::list DataMiningInvalidIntervalList; /** * AMDA::ParamOutputImpl::DataMining::ParamOutputDataMining */ class ParamOutputDataMining: public AMDA::Parameters::ParamOutput, public VisitorOfParamData { // Declare mapping between output request parameter and timetable parameter class static const std::map TIME_FORMAT_MAP; static const std::map FILE_FORMAT_MAP; /** * @brief Check if the output treatment must be aborted. * The treatment is aborted only if an other output of the same type than this * work on the same param name and has an higher priority. */ bool cancelIntervalCreation(); /** * @note Create instance of DataMiningType */ void createDataMiningWriter(); /** * @note Process data where time interval list is valid (greater or equal than sampling time). */ void processValidInterval(); /** * @note Process data where time interval list is invalid (less than sampling time). */ void processInvalidInterval(); public: enum PRIORITY { PARAM, REQUEST, HIGHER_PRIORITY_VALUE // this must never be used; it's used in "apply" method }; /** * Exception specific for AMDA::XMLConfigurator module */ struct exception: virtual AMDA::AMDA_exception { }; ParamOutputDataMining(AMDA::Parameters::ParameterManager& pParameterManager); virtual ~ParamOutputDataMining(); // Getter methods const std::string& getFileFormat() { return _fileFormat; } TimeTable::TIME_FORMAT getTimeFormat()const { return _timeFormat; } const std::string& getOutputStructure() { return _outputStructure; } const std::string& getParamName() const { return _paramName; } PRIORITY getOutputPriority() { return _taskPriority; } float getSamplingValue() const { return _samplingValue; } const std::string getSamplingMode() const { return _samplingMode; } const std::string getFileName() const { return _fileName; } float getGapThreshold() const { return _gapThreshold; } ParameterSPtr getParameter() { return _parameter; } // Setter methods void setFileFormat(const std::string& pFileFormat); void setTimeFormat(TimeTable::TIME_FORMAT pTimeFormat) { _timeFormat = pTimeFormat; } void setTimeFormat(std::string pTimeFormat); void setOutputStructure(const std::string& pOutputStructure) { _outputStructure = pOutputStructure; } void setParamName(const std::string& pParamName) { _paramName = pParamName; } void setOutputPriority(PRIORITY pTaskPriority) { _taskPriority = pTaskPriority; } void setFileName(const std::string &pFileName) { _fileName = pFileName; } void setParameter(ParameterSPtr pParameter) { _parameter = pParameter; } // Others methods void establishConnection(); // Visit methods /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataScalaireShort *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataScalaireFloat *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataScalaireDouble *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataScalaireLongDouble *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataScalaireInt *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataLogicalData *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataTab1DShort *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataTab1DFloat *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataTab1DDouble *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataTab1DLongDouble *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataTab1DInt *); /** * @overload VisitorOfParamData::visit() */ void visit(AMDA::Parameters::ParamDataTab1DLogicalData *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DShort *) */ void visit(AMDA::Parameters::ParamDataTab2DShort *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *) */ void visit(AMDA::Parameters::ParamDataTab2DFloat *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *) */ void visit(AMDA::Parameters::ParamDataTab2DDouble *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *) */ void visit(AMDA::Parameters::ParamDataTab2DLongDouble *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DInt *) */ void visit(AMDA::Parameters::ParamDataTab2DInt *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *) */ void visit(AMDA::Parameters::ParamDataTab2DLogicalData *); protected: /** * @overload ParamOutput::init() */ virtual void init(); /** * @brief Write time table content in a file. * @note this step is required and must be called by the main thread (and not child thread) / * because of the behavior when cleaning several time parser in libxml2 (when cleaning parser,/ * a call to method that need to write in a file will cause segmentation fault;/ * this context is only valid in a child thread). */ void terminate(); /** * @overload ParamOutput::apply() */ virtual void apply(); ParameterSPtr _parameter; /** * @brief _fileFormat format of the Time Table file. Can be ASCII or Internal XML. */ std::string _fileFormat; /** * @brief _timeFormat is the format used to format time in TimeTable */ TimeTable::TIME_FORMAT _timeFormat; /** * @brief _outputStructure describe structure of a file. One file for each interval or one file per interval */ std::string _outputStructure; /** * @brief _fileName is the name of the output TimeTable file */ std::string _fileName; /** * @brief Id of the parameter */ std::string _paramName; // OutputFormatTime _typeFormatTime; bool _firstVisit; PRIORITY _taskPriority; DataMiningValidIntervalList _dataMiningValidIntervalList; DataMiningInvalidIntervalList _dataMiningInvalidIntervalList; //DataMiningValidIntervalList _dataMiningValidIntervalList; }; } // namespace DataMining } // namespace ParamOutputImpl } /* namespace AMDA */ #endif /* PARAMOUTPUTDATAMINING_HH_ */