commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r5964 - gnuradio/branches/developers/trondeau/regen/gn


From: trondeau
Subject: [Commit-gnuradio] r5964 - gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general
Date: Sun, 15 Jul 2007 11:06:56 -0600 (MDT)

Author: trondeau
Date: 2007-07-15 11:06:56 -0600 (Sun, 15 Jul 2007)
New Revision: 5964

Modified:
   
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.cc
   
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.h
   
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.i
Log:
fixed regen startup issue; also added some set commands for period and 
max_regen parameters.

Modified: 
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.cc
       2007-07-14 17:00:03 UTC (rev 5963)
+++ 
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.cc
       2007-07-15 17:06:56 UTC (rev 5964)
@@ -38,11 +38,26 @@
                   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 @@
 
   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 @@
        d_regen_count++;
       }
     }
+    
+    if(iptr[i] == 1) {
+      d_countdown = d_period;
+      optr[i] = 1;
+      d_regen_count = 0;
+    }
+
   }
   return noutput_items;
 }

Modified: 
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.h
        2007-07-14 17:00:03 UTC (rev 5963)
+++ 
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.h
        2007-07-15 17:06:56 UTC (rev 5964)
@@ -31,14 +31,23 @@
 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,7 +59,14 @@
   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,
            gr_vector_void_star &output_items);

Modified: 
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.i
===================================================================
--- 
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.i
        2007-07-14 17:00:03 UTC (rev 5963)
+++ 
gnuradio/branches/developers/trondeau/regen/gnuradio-core/src/lib/general/gr_regenerate_bb.i
        2007-07-15 17:06:56 UTC (rev 5964)
@@ -28,4 +28,11 @@
 {
  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);
 };





reply via email to

[Prev in Thread] Current Thread [Next in Thread]