24 #include "cheetah/psbc/Psbc.h" 25 #include "panda/Log.h" 26 #include "panda/Error.h" 33 template<
typename Handler>
35 : _duration(0 * data::seconds)
36 , _dump_time(config.dump_time())
39 , _mutex(
std::unique_ptr<
std::mutex>(new
std::mutex))
43 template<
typename Handler>
48 template<
typename Handler>
51 PANDA_LOG_DEBUG <<
"Psbc::operator() invoked";
52 std::unique_lock<std::mutex> lk(*_mutex);
53 PANDA_LOG_DEBUG <<
"Psbc::operator() lock acquired";
55 auto const& dmtrials = *data;
57 if (!_data->blocks().empty())
59 auto const& previous_dmtrials = *(_data->blocks().back());
60 if (!previous_dmtrials.is_compatible(dmtrials))
62 throw panda::Error(
"Incompatible data block passed to Psbc instance.");
66 if (dmtrials.size() == 0)
68 PANDA_LOG_WARN <<
"Psbc was passed an empty dmtrials block.";
73 _duration += dmtrials.duration();
75 PANDA_LOG_DEBUG <<
"Psbc::operator() data added to buffer";
76 PANDA_LOG_DEBUG <<
"Duration: " << _duration
77 <<
" Dump time:" << _dump_time;
78 if(_duration >= _dump_time) {
79 PANDA_LOG_DEBUG <<
"Psbc::operator() invoking handler";
80 if (!this->is_contiguous())
83 PANDA_LOG_DEBUG <<
"Not contiguous";
86 _duration = 0 * data::seconds;
87 _data = DmTimeType::make_shared();
92 template<
typename Handler>
95 auto const& blocks = _data->blocks();
96 auto prev = blocks.cbegin();
97 auto next = std::next(blocks.cbegin(), 1);
98 for (std::size_t idx=0; idx<blocks.size()-1; ++idx)
100 if (!((*prev)->is_contiguous(**next)))
A class for buffering DmTrials objects.
Some limits and constants for FLDO.
A wrapper class for a list of DmTime instances.
Configuration for the data collection buffer.
Psbc(Config const &config, Handler &handler)
Construct a new instance.