ParamOutput.cc
2.12 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* 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();
// 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) {
try {
ParameterSPtr p = _parameterManager.getParameter(it->first);
if (p != nullptr) {
p->setTimeRestriction(it->second);
if (p->getDataWriterTemplate() != nullptr) {
p->getDataWriterTemplate()->setTimeRestriction(it->second);
}
}
}
catch (...) {
}
}
init();
}
void ParamOutput::process() {
apply();
}
void ParamOutput::terminate() {
applyPostProcessing();
}
/**
* @brief Search for a sampling time
*/
double getSamplingInTreeParameter (ParameterSPtr pParam) {
return pParam->getDataWriterTemplate()->getMinSampling();
}
} /* namespace Parameters */
} /* namespace AMDA */