diff options
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r-- | gr-blocks/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/lib/bin_statistics_f_impl.cc | 152 | ||||
-rw-r--r-- | gr-blocks/lib/bin_statistics_f_impl.h | 69 |
3 files changed, 0 insertions, 222 deletions
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index 45cf72b579..7a268f1522 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -62,7 +62,6 @@ add_library(gnuradio-blocks annotator_1to1_impl.cc annotator_alltoall_impl.cc annotator_raw_impl.cc - bin_statistics_f_impl.cc burst_tagger_impl.cc char_to_float_impl.cc char_to_short_impl.cc diff --git a/gr-blocks/lib/bin_statistics_f_impl.cc b/gr-blocks/lib/bin_statistics_f_impl.cc deleted file mode 100644 index dca2f868a5..0000000000 --- a/gr-blocks/lib/bin_statistics_f_impl.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "bin_statistics_f_impl.h" -#include <gnuradio/io_signature.h> -#include <string.h> - -namespace gr { -namespace blocks { - -bin_statistics_f::sptr bin_statistics_f::make(unsigned int vlen, - msg_queue::sptr msgq, - feval_dd* tune, - size_t tune_delay, - size_t dwell_delay) -{ - return gnuradio::get_initial_sptr( - new bin_statistics_f_impl(vlen, msgq, tune, tune_delay, dwell_delay)); -} - -bin_statistics_f_impl::bin_statistics_f_impl(unsigned int vlen, - msg_queue::sptr msgq, - feval_dd* tune, - size_t tune_delay, - size_t dwell_delay) - : sync_block("bin_statistics_f", - io_signature::make(1, 1, sizeof(float) * vlen), - io_signature::make(0, 0, 0)), - d_vlen(vlen), - d_msgq(msgq), - d_tune(tune), - d_tune_delay(tune_delay), - d_dwell_delay(dwell_delay), - d_center_freq(0), - d_delay(0), - d_max(vlen) -{ - enter_init(); -} - -bin_statistics_f_impl::~bin_statistics_f_impl() {} - -void bin_statistics_f_impl::enter_init() -{ - d_state = ST_INIT; - d_delay = 0; -} - -void bin_statistics_f_impl::enter_tune_delay() -{ - d_state = ST_TUNE_DELAY; - d_delay = d_tune_delay; - d_center_freq = d_tune->calleval(0); -} - -void bin_statistics_f_impl::enter_dwell_delay() -{ - d_state = ST_DWELL_DELAY; - d_delay = d_dwell_delay; - reset_stats(); -} - -void bin_statistics_f_impl::leave_dwell_delay() { send_stats(); } - -int bin_statistics_f_impl::work(int noutput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) -{ - const float* input = (const float*)input_items[0]; - size_t vlen = d_max.size(); - - int n = 0; - int t; - - while (n < noutput_items) { - switch (d_state) { - - case ST_INIT: - enter_tune_delay(); - break; - - case ST_TUNE_DELAY: - t = std::min(noutput_items - n, int(d_delay)); - n += t; - d_delay -= t; - if (d_delay == 0) - enter_dwell_delay(); - break; - - case ST_DWELL_DELAY: - t = std::min(noutput_items - n, int(d_delay)); - for (int i = 0; i < t; i++) { - accrue_stats(&input[n * vlen]); - n++; - } - d_delay -= t; - if (d_delay == 0) { - leave_dwell_delay(); - enter_tune_delay(); - } - break; - - default: - assert(0); - } - } - - return noutput_items; -} - -////////////////////////////////////////////////////////////////////////// -// virtual methods for gathering stats -////////////////////////////////////////////////////////////////////////// - -void bin_statistics_f_impl::reset_stats() -{ - for (size_t i = 0; i < vlen(); i++) { - d_max[i] = 0; - } -} - -void bin_statistics_f_impl::accrue_stats(const float* input) -{ - for (size_t i = 0; i < vlen(); i++) { - d_max[i] = std::max(d_max[i], input[i]); // compute per bin maxima - } -} - -void bin_statistics_f_impl::send_stats() -{ - if (msgq()->full_p()) // if the queue is full, don't block, drop the data... - return; - - // build & send a message - message::sptr msg = message::make(0, center_freq(), vlen(), vlen() * sizeof(float)); - memcpy(msg->msg(), &d_max[0], vlen() * sizeof(float)); - msgq()->insert_tail(msg); -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/bin_statistics_f_impl.h b/gr-blocks/lib/bin_statistics_f_impl.h deleted file mode 100644 index 42a838f3cd..0000000000 --- a/gr-blocks/lib/bin_statistics_f_impl.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_GR_BIN_STATISTICS_F_IMPL_H -#define INCLUDED_GR_BIN_STATISTICS_F_IMPL_H - -#include <gnuradio/blocks/bin_statistics_f.h> -#include <gnuradio/feval.h> -#include <gnuradio/message.h> -#include <gnuradio/msg_queue.h> - -namespace gr { -namespace blocks { - -class bin_statistics_f_impl : public bin_statistics_f -{ -private: - enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY }; - - const size_t d_vlen; - msg_queue::sptr d_msgq; - feval_dd* d_tune; - const size_t d_tune_delay; - const size_t d_dwell_delay; - double d_center_freq; - - state_t d_state; - size_t d_delay; // nsamples remaining to state transition - - void enter_init(); - void enter_tune_delay(); - void enter_dwell_delay(); - void leave_dwell_delay(); - -protected: - std::vector<float> d_max; // per bin maxima - - size_t vlen() const { return d_vlen; } - double center_freq() const { return d_center_freq; } - msg_queue::sptr msgq() const { return d_msgq; } - - virtual void reset_stats(); - virtual void accrue_stats(const float* input); - virtual void send_stats(); - -public: - bin_statistics_f_impl(unsigned int vlen, - msg_queue::sptr msgq, - feval_dd* tune, - size_t tune_delay, - size_t dwell_delay); - ~bin_statistics_f_impl(); - - int work(int noutput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_BIN_STATISTICS_F_IMPL_H */ |