summaryrefslogtreecommitdiff
path: root/gr-blocks
diff options
context:
space:
mode:
authorJohnathan Corgan <jcorgan@corganenterprises.com>2012-06-29 08:30:23 -0700
committerJohnathan Corgan <jcorgan@corganenterprises.com>2012-06-29 08:30:23 -0700
commitbfcc9dc634cc8d7da77b109a7ad9cd90714fd768 (patch)
tree2f739f2b13068294b4fe5846bb27eb2f160313f1 /gr-blocks
parentf2e815329402f170231c054e108b531094d046be (diff)
blocks: added gr::blocks::integrate_XX with ss ii ff cc
Diffstat (limited to 'gr-blocks')
-rw-r--r--gr-blocks/grc/blocks_block_tree.xml1
-rw-r--r--gr-blocks/grc/blocks_integrate_xx.xml50
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt1
-rw-r--r--gr-blocks/include/blocks/integrate_XX.h.t51
-rw-r--r--gr-blocks/lib/CMakeLists.txt1
-rw-r--r--gr-blocks/lib/integrate_XX_impl.cc.t68
-rw-r--r--gr-blocks/lib/integrate_XX_impl.h.t49
-rwxr-xr-xgr-blocks/python/qa_integrate.py76
-rw-r--r--gr-blocks/swig/blocks_swig.i12
9 files changed, 309 insertions, 0 deletions
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml
index 197daa0f6d..d7cbbeb558 100644
--- a/gr-blocks/grc/blocks_block_tree.xml
+++ b/gr-blocks/grc/blocks_block_tree.xml
@@ -37,6 +37,7 @@
<block>blocks_multiply_const_vxx</block>
<block>blocks_sub_xx</block>
<block>blocks_conjugate_cc</block>
+ <block>blocks_integrate_xx</block>
</cat>
<cat>
<name>Stream Type Conversions (New) </name>
diff --git a/gr-blocks/grc/blocks_integrate_xx.xml b/gr-blocks/grc/blocks_integrate_xx.xml
new file mode 100644
index 0000000000..13c2ec3c85
--- /dev/null
+++ b/gr-blocks/grc/blocks_integrate_xx.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Integrate
+###################################################
+ -->
+<block>
+ <name>Integrate</name>
+ <key>blocks_integrate_xx</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.integrate_$(type.fcn)($decim)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:cc</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:ff</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:ii</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:ss</opt>
+ </option>
+ </param>
+ <param>
+ <name>Decimation</name>
+ <key>decim</key>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ </source>
+</block>
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index 3110e2abbe..9f1af046d7 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -68,6 +68,7 @@ expand_h(add_XX ss ii cc)
expand_h(add_const_XX ss ii ff cc)
expand_h(add_const_vXX ss ii ff cc)
expand_h(divide_XX ss ii ff cc)
+expand_h(integrate_XX ss ii ff cc)
expand_h(multiply_XX ss ii)
expand_h(multiply_const_XX ss ii)
expand_h(multiply_const_vXX ss ii ff cc)
diff --git a/gr-blocks/include/blocks/integrate_XX.h.t b/gr-blocks/include/blocks/integrate_XX.h.t
new file mode 100644
index 0000000000..8a313a0ba9
--- /dev/null
+++ b/gr-blocks/include/blocks/integrate_XX.h.t
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2012 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 <blocks/api.h>
+#include <gr_sync_decimator.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Integrate successive samples and decimate
+ * \ingroup math_blk
+ */
+ class BLOCKS_API @NAME@ : virtual public gr_sync_decimator
+ {
+ public:
+
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
+
+ static sptr make(int decim);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 8d433801d8..e3a40dfc85 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -89,6 +89,7 @@ expand_cc_h_impl(add_XX ss ii cc)
expand_cc_h_impl(add_const_XX ss ii ff cc)
expand_cc_h_impl(add_const_vXX ss ii ff cc)
expand_cc_h_impl(divide_XX ss ii ff cc)
+expand_cc_h_impl(integrate_XX ss ii ff cc)
expand_cc_h_impl(multiply_XX ss ii)
expand_cc_h_impl(multiply_const_XX ss ii)
expand_cc_h_impl(multiply_const_vXX ss ii ff cc)
diff --git a/gr-blocks/lib/integrate_XX_impl.cc.t b/gr-blocks/lib/integrate_XX_impl.cc.t
new file mode 100644
index 0000000000..4c82729e3c
--- /dev/null
+++ b/gr-blocks/lib/integrate_XX_impl.cc.t
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2010,2012 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_IMPL@.h>
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace blocks {
+
+ @NAME@::sptr @NAME@::make(int decim)
+ {
+ return gnuradio::get_initial_sptr(new @NAME_IMPL@(decim));
+ }
+
+ @NAME_IMPL@::@NAME_IMPL@(int decim)
+ : gr_sync_decimator("@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)
+ {
+ }
+
+ int
+ @NAME_IMPL@::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;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/integrate_XX_impl.h.t b/gr-blocks/lib/integrate_XX_impl.h.t
new file mode 100644
index 0000000000..9fc3333882
--- /dev/null
+++ b/gr-blocks/lib/integrate_XX_impl.h.t
@@ -0,0 +1,49 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2012 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_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API @NAME_IMPL@ : public @NAME@
+ {
+ int d_decim;
+ int d_count;
+
+ public:
+ @NAME_IMPL@(int decim);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/python/qa_integrate.py b/gr-blocks/python/qa_integrate.py
new file mode 100755
index 0000000000..c404f1b309
--- /dev/null
+++ b/gr-blocks/python/qa_integrate.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+#
+# Copyright 2008,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.
+#
+
+from gnuradio import gr, gr_unittest
+import blocks_swig
+import math
+
+class test_integrate (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_000_ss(self):
+ src_data = (1, 2, 3, 4, 5, 6)
+ dst_data = (6, 15)
+ src = gr.vector_source_s(src_data)
+ itg = blocks_swig.integrate_ss(3)
+ dst = gr.vector_sink_s()
+ self.tb.connect(src, itg, dst)
+ self.tb.run()
+ self.assertEqual(dst_data, dst.data())
+
+ def test_001_ii(self):
+ src_data = (1, 2, 3, 4, 5, 6)
+ dst_data = (6, 15)
+ src = gr.vector_source_i(src_data)
+ itg = blocks_swig.integrate_ii(3)
+ dst = gr.vector_sink_i()
+ self.tb.connect(src, itg, dst)
+ self.tb.run()
+ self.assertEqual(dst_data, dst.data())
+
+ def test_002_ff(self):
+ src_data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
+ dst_data = [6.0, 15.0]
+ src = gr.vector_source_f(src_data)
+ itg = blocks_swig.integrate_ff(3)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, itg, dst)
+ self.tb.run()
+ self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6)
+
+ def test_003_cc(self):
+ src_data = [1.0+1.0j, 2.0+2.0j, 3.0+3.0j, 4.0+4.0j, 5.0+5.0j, 6.0+6.0j]
+ dst_data = [6.0+6.0j, 15.0+15.0j]
+ src = gr.vector_source_c(src_data)
+ itg = blocks_swig.integrate_cc(3)
+ dst = gr.vector_sink_c()
+ self.tb.connect(src, itg, dst)
+ self.tb.run()
+ self.assertComplexTuplesAlmostEqual(dst_data, dst.data(), 6)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_integrate, "test_integrate.xml")
diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i
index cfd9d9db16..fe2745da08 100644
--- a/gr-blocks/swig/blocks_swig.i
+++ b/gr-blocks/swig/blocks_swig.i
@@ -60,6 +60,10 @@
#include "blocks/float_to_short.h"
#include "blocks/float_to_uchar.h"
#include "blocks/int_to_float.h"
+#include "blocks/integrate_ss.h"
+#include "blocks/integrate_ii.h"
+#include "blocks/integrate_ff.h"
+#include "blocks/integrate_cc.h"
#include "blocks/interleaved_short_to_complex.h"
#include "blocks/multiply_ss.h"
#include "blocks/multiply_ii.h"
@@ -114,6 +118,10 @@
%include "blocks/float_to_short.h"
%include "blocks/float_to_uchar.h"
%include "blocks/int_to_float.h"
+%include "blocks/integrate_ss.h"
+%include "blocks/integrate_ii.h"
+%include "blocks/integrate_ff.h"
+%include "blocks/integrate_cc.h"
%include "blocks/interleaved_short_to_complex.h"
%include "blocks/multiply_ss.h"
%include "blocks/multiply_ii.h"
@@ -167,6 +175,10 @@ GR_SWIG_BLOCK_MAGIC2(blocks, float_to_int);
GR_SWIG_BLOCK_MAGIC2(blocks, float_to_short);
GR_SWIG_BLOCK_MAGIC2(blocks, float_to_uchar);
GR_SWIG_BLOCK_MAGIC2(blocks, int_to_float);
+GR_SWIG_BLOCK_MAGIC2(blocks, integrate_ss);
+GR_SWIG_BLOCK_MAGIC2(blocks, integrate_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, integrate_ff);
+GR_SWIG_BLOCK_MAGIC2(blocks, integrate_cc);
GR_SWIG_BLOCK_MAGIC2(blocks, interleaved_short_to_complex);
GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ii);