From 296f981f79344d042f09ca2b30dcd7aa56f32981 Mon Sep 17 00:00:00 2001
From: jcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Date: Sat, 12 Apr 2008 17:42:20 +0000
Subject: Adds gr.integrate_XX for ss, ii, ff, and cc.  Sums successive samples
 and decimates.  Trunk passes distcheck.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8190 221aa14e-8319-0410-a670-987f0aec2ac5
---
 gnuradio-core/src/lib/gengen/Makefile.am          |  3 +
 gnuradio-core/src/lib/gengen/Makefile.gen         | 12 ++++
 gnuradio-core/src/lib/gengen/generate_common.py   |  1 +
 gnuradio-core/src/lib/gengen/gengen_generated.i   |  8 +++
 gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t | 67 +++++++++++++++++++++++
 gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t  | 60 ++++++++++++++++++++
 gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t  | 33 +++++++++++
 7 files changed, 184 insertions(+)
 create mode 100644 gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t
 create mode 100644 gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t
 create mode 100644 gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t

(limited to 'gnuradio-core/src/lib')

diff --git a/gnuradio-core/src/lib/gengen/Makefile.am b/gnuradio-core/src/lib/gengen/Makefile.am
index ebc403e3f..fb96ed2be 100644
--- a/gnuradio-core/src/lib/gengen/Makefile.am
+++ b/gnuradio-core/src/lib/gengen/Makefile.am
@@ -53,6 +53,9 @@ CODE_GENERATOR = 			\
 	gr_divide_XX.cc.t		\
 	gr_divide_XX.h.t		\
 	gr_divide_XX.i.t		\
+	gr_integrate_XX.cc.t		\
+	gr_integrate_XX.h.t		\
+	gr_integrate_XX.i.t		\
 	gr_max_XX.cc.t			\
 	gr_max_XX.h.t			\
 	gr_max_XX.i.t			\
diff --git a/gnuradio-core/src/lib/gengen/Makefile.gen b/gnuradio-core/src/lib/gengen/Makefile.gen
index 512576ac2..79b0ef7bd 100644
--- a/gnuradio-core/src/lib/gengen/Makefile.gen
+++ b/gnuradio-core/src/lib/gengen/Makefile.gen
@@ -35,6 +35,10 @@ GENERATED_H = \
 	gr_divide_ff.h \
 	gr_divide_ii.h \
 	gr_divide_ss.h \
+	gr_integrate_cc.h \
+	gr_integrate_ff.h \
+	gr_integrate_ii.h \
+	gr_integrate_ss.h \
 	gr_max_ff.h \
 	gr_max_ii.h \
 	gr_max_ss.h \
@@ -137,6 +141,10 @@ GENERATED_I = \
 	gr_divide_ff.i \
 	gr_divide_ii.i \
 	gr_divide_ss.i \
+	gr_integrate_cc.i \
+	gr_integrate_ff.i \
+	gr_integrate_ii.i \
+	gr_integrate_ss.i \
 	gr_max_ff.i \
 	gr_max_ii.i \
 	gr_max_ss.i \
@@ -239,6 +247,10 @@ GENERATED_CC = \
 	gr_divide_ff.cc \
 	gr_divide_ii.cc \
 	gr_divide_ss.cc \
+	gr_integrate_cc.cc \
+	gr_integrate_ff.cc \
+	gr_integrate_ii.cc \
+	gr_integrate_ss.cc \
 	gr_max_ff.cc \
 	gr_max_ii.cc \
 	gr_max_ss.cc \
diff --git a/gnuradio-core/src/lib/gengen/generate_common.py b/gnuradio-core/src/lib/gengen/generate_common.py
index 089d7d380..e46d4b74a 100755
--- a/gnuradio-core/src/lib/gengen/generate_common.py
+++ b/gnuradio-core/src/lib/gengen/generate_common.py
@@ -51,6 +51,7 @@ reg_roots = [
     'gr_multiply_vXX',
     'gr_add_const_vXX',
     'gr_multiply_const_vXX',
+    'gr_integrate_XX',
     ]
 
 # other blocks
diff --git a/gnuradio-core/src/lib/gengen/gengen_generated.i b/gnuradio-core/src/lib/gengen/gengen_generated.i
index a4de58dbe..bdc15e50c 100644
--- a/gnuradio-core/src/lib/gengen/gengen_generated.i
+++ b/gnuradio-core/src/lib/gengen/gengen_generated.i
@@ -35,6 +35,10 @@
 #include <gr_divide_ff.h>
 #include <gr_divide_ii.h>
 #include <gr_divide_ss.h>
+#include <gr_integrate_cc.h>
+#include <gr_integrate_ff.h>
+#include <gr_integrate_ii.h>
+#include <gr_integrate_ss.h>
 #include <gr_max_ff.h>
 #include <gr_max_ii.h>
 #include <gr_max_ss.h>
@@ -137,6 +141,10 @@
 %include <gr_divide_ff.i>
 %include <gr_divide_ii.i>
 %include <gr_divide_ss.i>
+%include <gr_integrate_cc.i>
+%include <gr_integrate_ff.i>
+%include <gr_integrate_ii.i>
+%include <gr_integrate_ss.i>
 %include <gr_max_ff.i>
 %include <gr_max_ii.i>
 %include <gr_max_ss.i>
diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t
new file mode 100644
index 000000000..0a62554bd
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t
@@ -0,0 +1,67 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME@.h>
+#include <gr_io_signature.h>
+
+@SPTR_NAME@ 
+gr_make_@BASE_NAME@ (int decim)
+{
+  return @SPTR_NAME@ (new @NAME@ (decim));
+}
+
+@NAME@::@NAME@ (int decim)
+  : gr_sync_decimator ("@BASE_NAME@",
+		       gr_make_io_signature (1, 1, sizeof (@I_TYPE@)),
+		       gr_make_io_signature (1, 1, sizeof (@O_TYPE@)),
+		       decim),
+    d_decim(decim),
+    d_count(0)
+{
+}
+
+@NAME@::~@NAME@ ()
+{
+}
+
+int 
+@NAME@::work (int noutput_items,
+	      gr_vector_const_void_star &input_items,
+	      gr_vector_void_star &output_items)
+{
+  const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0];
+  @O_TYPE@ *out = (@O_TYPE@ *) output_items[0];
+  
+  for (int i = 0; i < noutput_items; i++) {
+    out[i] = (@O_TYPE@)0;
+    for (int j = 0; j < d_decim; j++)
+      out[i] += in[i*d_decim+j];
+  }
+
+  return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t
new file mode 100644
index 000000000..c8eca2d0a
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gr_sync_decimator.h>
+
+class @NAME@;
+
+typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ (int decim);
+
+/*!
+ * \brief output = sum(input[0]...input[n])
+ * \ingroup math
+ *
+ * Integrate successive samples in input stream and decimate
+ */
+class @NAME@ : public gr_sync_decimator
+{
+private:
+  friend @SPTR_NAME@ gr_make_@BASE_NAME@(int decim);
+
+  @NAME@ (int decim);
+
+  int d_decim;
+  int d_count;
+
+public:
+  ~@NAME@ ();	
+
+  int work (int noutput_items,
+	    gr_vector_const_void_star &input_items,
+	    gr_vector_void_star &output_items);
+};
+
+#endif /* @GUARD_NAME@ */
diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t
new file mode 100644
index 000000000..24a2381ad
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t
@@ -0,0 +1,33 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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.
+ */
+
+// @WARNING@
+
+GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@);
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ (int decim);
+
+class @NAME@ : public gr_sync_decimator
+{
+private:
+  @NAME@ ();
+};
-- 
cgit v1.2.3