24 #include "cheetah/ddtr/detail/Buffering.h" 25 #include "panda/ResourcePool.h" 26 #include "panda/TypeTraits.h" 27 #include "panda/Log.h" 35 template<
typename DdtrTraits,
typename PlanType>
36 Buffering<DdtrTraits, PlanType>::Buffering(BufferFullCallBack
const& callback
37 , PlanType
const& plan
38 , std::size_t max_buffer_size)
39 : _max_spectra(max_buffer_size)
40 , _current_number_of_channels(0)
41 , _agg_buf_filler(callback ,0)
47 template<
typename DdtrTraits,
typename PlanType>
48 Buffering<DdtrTraits, PlanType>::~Buffering()
52 template<
typename DdtrTraits,
typename PlanType>
53 void Buffering<DdtrTraits, PlanType>::agg_buffer_init(TimeFrequencyType
const& data)
55 if (data.number_of_channels() != _current_number_of_channels)
57 data::DimensionSize<data::Time> dedisp_samples = _plan.dedispersion_strategy(data);
58 data::DimensionSize<data::Time> number_of_spectra = dedisp_samples;
59 if(dedisp_samples > _max_spectra && _max_spectra != 0) {
60 PANDA_LOG_WARN <<
"algorithm algo plans ignored mac number of samples";
64 data::DimensionSize<data::Time> overlap = _plan.buffer_overlap();
66 PANDA_LOG_WARN <<
"buffer overlap is zero";
68 data::DimensionSize<data::Time> min_number_of_spectra(overlap + 1);
70 if(min_number_of_spectra >= _max_spectra && _max_spectra != 0) {
71 panda::Error e(
"configuration error: dedispersion plan requires at least ");
72 e << min_number_of_spectra <<
" spectra. " <<
"Maximum possible (given algo and pool selection)=" << dedisp_samples;
76 if(overlap >= number_of_spectra) {
77 PANDA_LOG_ERROR <<
"configuration error: samples requested < minimum required for dedispersion plan(" << overlap <<
")";
78 throw panda::Error(
"dedispersion sample buffer size is too small");
80 PANDA_LOG <<
"setting dedispersion buffer size to " << number_of_spectra <<
" spectra";
81 _agg_buf_filler.resize(data.number_of_channels() * number_of_spectra);
83 PANDA_LOG <<
"setting buffer overlap to " << overlap <<
" spectra";
84 _agg_buf_filler.set_overlap(data.number_of_channels() * overlap);
86 _current_number_of_channels = data.number_of_channels();
90 template<
typename DdtrTraits,
typename PlanType>
91 template<
typename DataT>
92 void Buffering<DdtrTraits, PlanType>::agg_buffer_fill(DataT& data)
94 TimeFrequencyType
const& tf_data =
static_cast<TimeFrequencyType const&
>(panda::is_pointer_wrapper<typename std::remove_reference<DataT>::type>::extract(data));
95 agg_buffer_init(tf_data);
96 _agg_buf_filler << data;
99 template<
typename DdtrTraits,
typename PlanType>
100 template<
typename DataT>
101 void Buffering<DdtrTraits, PlanType>::operator()(DataT
const& data)
103 this->
template agg_buffer_fill(data);
Some limits and constants for FLDO.