diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-03-07 10:28:09 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-03-07 10:28:09 -0500 |
commit | afdf1aff307f9214e81314ddb0868eb0ef6a874f (patch) | |
tree | 3fa8dcbf5f9337c0847fa2e36195990770166b0b /gnuradio-core/src/lib | |
parent | cb8cd020816f128a73d07bc557bd3c3e720b38fc (diff) |
blocks: removing bin_statistics_f from core; now in gr-blocks.
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r-- | gnuradio-core/src/lib/general/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/general.i | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_bin_statistics_f.cc | 174 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_bin_statistics_f.h | 100 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_bin_statistics_f.i | 47 |
5 files changed, 0 insertions, 324 deletions
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index bbc6a7612b..bca0583b59 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -140,7 +140,6 @@ endif(ENABLE_PYTHON) set(gr_core_general_triple_threats complex_vec_test gr_align_on_samplenumbers_ss - gr_bin_statistics_f gr_block_gateway gr_check_counting_s gr_check_lfsr_32k_s diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index f7f7942577..2712c4101c 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -43,7 +43,6 @@ #include <gr_test_types.h> #include <gr_test.h> #include <gr_feval.h> -#include <gr_bin_statistics_f.h> #include <gr_copy.h> #include <complex_vec_test.h> #include <gr_annotator_alltoall.h> @@ -73,7 +72,6 @@ %include "gr_test_types.h" %include "gr_test.i" %include "gr_feval.i" -%include "gr_bin_statistics_f.i" %include "gr_copy.i" %include "complex_vec_test.i" %include "gr_annotator_alltoall.i" diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc b/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc deleted file mode 100644 index 3938f2b487..0000000000 --- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_bin_statistics_f.h> -#include <gr_io_signature.h> -#include <string.h> - -gr_bin_statistics_f_sptr -gr_make_bin_statistics_f(unsigned int vlen, - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, - size_t tune_delay, - size_t dwell_delay) -{ - return gnuradio::get_initial_sptr(new gr_bin_statistics_f(vlen, - msgq, - tune, - tune_delay, - dwell_delay)); -} - -gr_bin_statistics_f::gr_bin_statistics_f(unsigned int vlen, - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, - size_t tune_delay, - size_t dwell_delay) - : gr_sync_block("bin_statistics_f", - gr_make_io_signature(1, 1, sizeof(float) * vlen), - gr_make_io_signature(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(); -} - -gr_bin_statistics_f::~gr_bin_statistics_f() -{ - // NOP -} - -void -gr_bin_statistics_f::enter_init() -{ - d_state = ST_INIT; - d_delay = 0; -} - -void -gr_bin_statistics_f::enter_tune_delay() -{ - d_state = ST_TUNE_DELAY; - d_delay = d_tune_delay; - d_center_freq = d_tune->calleval(0); -} - -void -gr_bin_statistics_f::enter_dwell_delay() -{ - d_state = ST_DWELL_DELAY; - d_delay = d_dwell_delay; - reset_stats(); -} - -void -gr_bin_statistics_f::leave_dwell_delay() -{ - send_stats(); -} - -int -gr_bin_statistics_f::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; - assert(d_delay >= 0); - 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; - assert(d_delay >= 0); - if (d_delay == 0){ - leave_dwell_delay(); - enter_tune_delay(); - } - break; - - default: - assert(0); - } - } - - return noutput_items; -} - -////////////////////////////////////////////////////////////////////////// -// virtual methods for gathering stats -////////////////////////////////////////////////////////////////////////// - -void -gr_bin_statistics_f::reset_stats() -{ - for (size_t i = 0; i < vlen(); i++){ - d_max[i] = 0; - } -} - -void -gr_bin_statistics_f::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 -gr_bin_statistics_f::send_stats() -{ - if (msgq()->full_p()) // if the queue is full, don't block, drop the data... - return; - - // build & send a message - gr_message_sptr msg = gr_make_message(0, center_freq(), vlen(), vlen() * sizeof(float)); - memcpy(msg->msg(), &d_max[0], vlen() * sizeof(float)); - msgq()->insert_tail(msg); -} diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.h b/gnuradio-core/src/lib/general/gr_bin_statistics_f.h deleted file mode 100644 index dd10759096..0000000000 --- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_BIN_STATISTICS_F_H -#define INCLUDED_GR_BIN_STATISTICS_F_H - - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_feval.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -class gr_bin_statistics_f; -typedef boost::shared_ptr<gr_bin_statistics_f> gr_bin_statistics_f_sptr; - - -GR_CORE_API gr_bin_statistics_f_sptr -gr_make_bin_statistics_f(unsigned int vlen, // vector length - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, // callback - size_t tune_delay, // samples - size_t dwell_delay); // samples - -/*! - * \brief control scanning and record frequency domain statistics - * \ingroup sink_blk - */ -class GR_CORE_API gr_bin_statistics_f : public gr_sync_block -{ - friend GR_CORE_API gr_bin_statistics_f_sptr - gr_make_bin_statistics_f(unsigned int vlen, // vector length - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, // callback - size_t tune_delay, // samples - size_t dwell_delay); // samples - - enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY }; - - size_t d_vlen; - gr_msg_queue_sptr d_msgq; - gr_feval_dd *d_tune; - size_t d_tune_delay; - size_t d_dwell_delay; - double d_center_freq; - - state_t d_state; - size_t d_delay; // nsamples remaining to state transition - - gr_bin_statistics_f(unsigned int vlen, - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, - size_t tune_delay, - size_t dwell_delay); - - 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; } - gr_msg_queue_sptr msgq() const { return d_msgq; } - - virtual void reset_stats(); - virtual void accrue_stats(const float *input); - virtual void send_stats(); - -public: - ~gr_bin_statistics_f(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.i b/gnuradio-core/src/lib/general/gr_bin_statistics_f.i deleted file mode 100644 index 94a3db69a2..0000000000 --- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.i +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -// Directors are only supported in Python, Java and C#. gr_feval_dd uses directors -#ifdef SWIGPYTHON - -GR_SWIG_BLOCK_MAGIC(gr,bin_statistics_f); - -gr_bin_statistics_f_sptr -gr_make_bin_statistics_f(unsigned int vlen, // vector length - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, // callback - size_t tune_delay, // samples - size_t dwell_delay); // samples - - -class gr_bin_statistics_f : public gr_sync_block -{ -private: - gr_bin_statistics_f(unsigned int vlen, - gr_msg_queue_sptr msgq, - gr_feval_dd *tune, - size_t tune_delay, - size_t dwell_delay); -public: - ~gr_bin_statistics_f(); -}; - -#endif |