Blame view

src/Parameters/ParamOutput.cc 2.12 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * 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();
193183ca   Benjamin Renard   Give the possibil...
49
50
51
52

	// Update params time restrictions
	std::map<std::string, double> paramsTimeRestrictions = _parameterManager.getParamsTimeRestrictions();
	for (std::map<std::string, double>::iterator it = paramsTimeRestrictions.begin(); it != paramsTimeRestrictions.end(); ++it) {
8852b057   Benjamin Renard   Catch exception w...
53
54
55
56
		try {
			ParameterSPtr p = _parameterManager.getParameter(it->first);
			if (p != nullptr) {
				p->setTimeRestriction(it->second);
263de286   Benjamin Renard   Apply time restri...
57
58
59
				if (p->getDataWriterTemplate() != nullptr) {
					p->getDataWriterTemplate()->setTimeRestriction(it->second);
				}
8852b057   Benjamin Renard   Catch exception w...
60
61
62
			}
		}
		catch (...) {
193183ca   Benjamin Renard   Give the possibil...
63
64
65
		}
	}

fbe3c2bb   Benjamin Renard   First commit
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
	init();
}

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

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


/**
 * @brief Search for a sampling time
 */
f7b99646   Benjamin Renard   Give the possibil...
81
double getSamplingInTreeParameter (ParameterSPtr pParam) {
fbe3c2bb   Benjamin Renard   First commit
82
83
84
85
86
	return pParam->getDataWriterTemplate()->getMinSampling();
}

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