diff options
author | trondeau | 2007-07-15 18:05:55 +0000 |
---|---|---|
committer | trondeau | 2007-07-15 18:05:55 +0000 |
commit | 2e458356def8ef23944a2e578ce563bcb14dcab5 (patch) | |
tree | d746b085eb19f1d056908f24fef41ffd9a0f57ec /gnuradio-core/src/lib/general | |
parent | ee7cc3b28783c6b564f32085d0a0fb9b66bc101b (diff) | |
download | gnuradio-2e458356def8ef23944a2e578ce563bcb14dcab5.tar.gz gnuradio-2e458356def8ef23944a2e578ce563bcb14dcab5.tar.bz2 gnuradio-2e458356def8ef23944a2e578ce563bcb14dcab5.zip |
merged -r5947:5965 on trondeau/regen into trunk. Fixes ticket:154 on gr_regenerate_bb block.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@5966 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_regenerate_bb.cc | 32 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_regenerate_bb.h | 20 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_regenerate_bb.i | 7 |
3 files changed, 49 insertions, 10 deletions
diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.cc b/gnuradio-core/src/lib/general/gr_regenerate_bb.cc index 6b0535e18..eb2220bf1 100644 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.cc +++ b/gnuradio-core/src/lib/general/gr_regenerate_bb.cc @@ -38,11 +38,26 @@ gr_regenerate_bb::gr_regenerate_bb (int period, unsigned int max_regen) gr_make_io_signature (1, 1, sizeof (char)), gr_make_io_signature (1, 1, sizeof (char))), d_period(period), + d_countdown(0), d_max_regen(max_regen), - d_regen_count(0) + d_regen_count(max_regen) { } +void gr_regenerate_bb::set_max_regen(unsigned int regen) +{ + d_max_regen = regen; + d_countdown = 0; + d_regen_count = d_max_regen; +} + +void gr_regenerate_bb::set_period(int period) +{ + d_period = period; + d_countdown = 0; + d_regen_count = d_max_regen; +} + int gr_regenerate_bb::work (int noutput_items, gr_vector_const_void_star &input_items, @@ -53,14 +68,8 @@ gr_regenerate_bb::work (int noutput_items, for (int i = 0; i < noutput_items; i++){ optr[i] = 0; - - if(iptr[i] == 1) { - d_countdown = d_period; - optr[i] = 1; - d_regen_count = 0; - } - if(d_regen_count <= d_max_regen) { + if(d_regen_count < d_max_regen) { d_countdown--; if(d_countdown == 0) { @@ -69,6 +78,13 @@ gr_regenerate_bb::work (int noutput_items, d_regen_count++; } } + + if(iptr[i] == 1) { + d_countdown = d_period; + optr[i] = 1; + d_regen_count = 0; + } + } return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.h b/gnuradio-core/src/lib/general/gr_regenerate_bb.h index 446e658ae..f5b589fe5 100644 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.h +++ b/gnuradio-core/src/lib/general/gr_regenerate_bb.h @@ -31,14 +31,23 @@ typedef boost::shared_ptr<gr_regenerate_bb> gr_regenerate_bb_sptr; gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen=500); /*! - * \brief Detect the peak of a signal + * \brief Detect the peak of a signal and repeat every period samples * \ingroup block * * If a peak is detected, this block outputs a 1 repeated every period samples - * until reset by detection of another 1 on the input + * until reset by detection of another 1 on the input or stopped after max_regen + * regenerations have occurred. + * + * Note that if max_regen=(-1)/ULONG_MAX then the regeneration will run forever. */ class gr_regenerate_bb : public gr_sync_block { + /*! + * \brief Make a regenerate block + * \param period The number of samples between regenerations + * \param max_regen The maximum number of regenerations to perform; if set to + * ULONG_MAX, it will regenerate continuously. + */ friend gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen); gr_regenerate_bb (int period, unsigned int max_regen); @@ -50,6 +59,13 @@ class gr_regenerate_bb : public gr_sync_block unsigned int d_regen_count; public: + /*! \brief Reset the maximum regeneration count; this will reset the current regen. + */ + void set_max_regen(unsigned int regen); + + /*! \brief Reset the period of regenerations; this will reset the current regen. + */ + void set_period(int period); int work (int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.i b/gnuradio-core/src/lib/general/gr_regenerate_bb.i index 6afd84d8d..afdbe184d 100644 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.i +++ b/gnuradio-core/src/lib/general/gr_regenerate_bb.i @@ -28,4 +28,11 @@ class gr_regenerate_bb : public gr_sync_block { private: gr_regenerate_bb (int period, unsigned int max_regen); + +public: + void set_max_regen(unsigned int regen); + + /*! \brief Reset the period of regenerations; this will reset the current regen. + */ + void set_period(int period); }; |