ParamOutput.cc 1.58 KB
/**
 * ParamOutput.cc
 *
 *  Created on: 18 oct. 2012
 *      Author: AKKA IS
 */

#include "ParamOutput.hh"
#include "DicError.hh"

//#include "TimeTableCatalogFactory.hh"
//#include "TimeInterval.hh"

namespace AMDA {
namespace Parameters {

using namespace TimeTableCatalog;

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

ParamOutput::ParamOutput(ParameterManager& pParameterManager) : DataClient(),
		_samplingMode(""),
		_samplingValue(0.0),
		_gapThreshold(0.0),
		_parameterManager(pParameterManager)  {
}

ParamOutput::~ParamOutput() {
}

void ParamOutput::init(TimeIntervalListSPtr pTimeIntervalList) {
	// Separate short time interval.
	if (_samplingValue == 0) {
		LOG4CXX_WARN(_logger, "Sampling time is equal to 0. Time interval too short separation mechanism not taken into account");
	}

	_timeIntervalList.reset (new TimeIntervalList);
	_timeIntervalListTooSmall.reset (new TimeIntervalList);

	for(TimeIntervalList::iterator it = pTimeIntervalList->begin(); it != pTimeIntervalList->end(); ++it) {
		if ( (it->_stopTime - it->_startTime) < _samplingValue ) {
			_timeIntervalListTooSmall->push_back(*it);
		} else {
			_timeIntervalList->push_back(*it);
		}
	}

	_currentTimeInterval = _timeIntervalList->begin();
	init();
}

void ParamOutput::process() {
	apply();
}

void ParamOutput::terminate() {
	applyPostProcessing();
}


/**
 * @brief Search for a sampling time
 */
float getSamplingInTreeParameter (ParameterSPtr pParam) {
	return pParam->getDataWriterTemplate()->getMinSampling();
}

} /* namespace Parameters */
} /* namespace AMDA */