DataMiningValidInterval.cc 2.2 KB
/*
 * DataMiningValidInterval.cc
 *
 *  Created on: 3 oct. 2013
 *      Author: CS
 */

#include "DataMiningValidInterval.hh"

// TimeTable
#include "TimeTableCatalogUtil.hh"


using namespace TimeTableCatalog;

namespace AMDA {
	namespace ParamOutputImpl {
		namespace DataMining {

			log4cxx::LoggerPtr DataMiningValidInterval::_logger(log4cxx::Logger::getLogger("AMDA-Kernel.DataMiningValidInterval"));

			DataMiningValidInterval::DataMiningValidInterval(std::string pPrefixTTFileName, bool pIsGapFile, ParamOutputDataMining* pParamOutputDataMining) :
				DataMiningType(pParamOutputDataMining, pPrefixTTFileName),
				_valCurrent(false),
				_beginTimeInterval(0),
				_endTimeInterval(0),
				_isGapFile(pIsGapFile){
			}

			void DataMiningValidInterval::setTimeInterval(const TimeInterval& pTimeInterval) {
				DataMiningType::setTimeInterval(pTimeInterval);
				_valCurrent = false;
				_beginTimeInterval = 0;
				_endTimeInterval = 0;
			}

			void DataMiningValidInterval::checkTimeIntervalBounds() {
				// If the begin time of the interval is the same value as the start time research,
				// We must not subtract samplingTime / 2 to the _beginTimeInterval (boundary value)
				// TODO prendre en compte une liste d'intervalle de temps
				// et non plus une date de départ suivi d'un délai.
				if (_beginTimeInterval != _inputTimeInterval._startTime) {
					_beginTimeInterval = _beginTimeInterval - (_samplingTime / 2);
				}

				if(_endTimeInterval != _inputTimeInterval._stopTime) {
					_endTimeInterval = _endTimeInterval + (_samplingTime / 2);
				} else {
					// Nothing to do we have reached the end time research so we must not
					// add samplingTime / 2 to the _endTimeInterval (boundary value).
				}
			}

			void DataMiningValidInterval::finalize() {
				// If the last interval is not closed, so close it.
				if(_valCurrent) {
					_timeTable->addInterval(TimeInterval(_beginTimeInterval - (_samplingTime / 2), _inputTimeInterval._stopTime));
				}
			}

			void DataMiningValidInterval::fillInformation(TimeTable::TIME_FORMAT pTimeFormat, std::string pFileName, int pIndex) {
				finalize();

				DataMiningType::fillInformation(pTimeFormat, pFileName, pIndex);
			}

		} // DataMining
	} // ParamOutputImpl
} // AMDA