diff options
author | Jiří Pinkava <j-pi@seznam.cz> | 2015-02-23 01:44:43 +0100 |
---|---|---|
committer | Jiří Pinkava <j-pi@seznam.cz> | 2015-02-23 04:24:55 +0100 |
commit | f426108cf0d7440dc1fbbaa33b83c9e6488a91d0 (patch) | |
tree | f7b6e80d38d3e0fe9b2f4a4c58d3657c99141e56 | |
parent | e03b287c8641f2b7d5ed42e0442d285dd03e5466 (diff) |
blocks: integration supports vector input
-rw-r--r-- | gr-blocks/grc/blocks_integrate_xx.xml | 10 | ||||
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/integrate_XX.h.t | 2 | ||||
-rw-r--r-- | gr-blocks/lib/integrate_XX_impl.cc.t | 23 | ||||
-rw-r--r-- | gr-blocks/lib/integrate_XX_impl.h.t | 4 | ||||
-rwxr-xr-x | gr-blocks/python/blocks/qa_integrate.py | 22 |
5 files changed, 48 insertions, 13 deletions
diff --git a/gr-blocks/grc/blocks_integrate_xx.xml b/gr-blocks/grc/blocks_integrate_xx.xml index 13c2ec3c85..8f47b94997 100644 --- a/gr-blocks/grc/blocks_integrate_xx.xml +++ b/gr-blocks/grc/blocks_integrate_xx.xml @@ -8,7 +8,7 @@ <name>Integrate</name> <key>blocks_integrate_xx</key> <import>from gnuradio import blocks</import> - <make>blocks.integrate_$(type.fcn)($decim)</make> + <make>blocks.integrate_$(type.fcn)($decim, $vlen)</make> <param> <name>IO Type</name> <key>type</key> @@ -39,12 +39,20 @@ <key>decim</key> <type>int</type> </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> <sink> <name>in</name> <type>$type</type> + <vlen>$vlen</vlen> </sink> <source> <name>out</name> <type>$type</type> + <vlen>$vlen</vlen> </source> </block> diff --git a/gr-blocks/include/gnuradio/blocks/integrate_XX.h.t b/gr-blocks/include/gnuradio/blocks/integrate_XX.h.t index 33707970bc..7ec1176558 100644 --- a/gr-blocks/include/gnuradio/blocks/integrate_XX.h.t +++ b/gr-blocks/include/gnuradio/blocks/integrate_XX.h.t @@ -42,7 +42,7 @@ namespace gr { // gr::blocks::@NAME@::sptr typedef boost::shared_ptr<@NAME@> sptr; - static sptr make(int decim); + static sptr make(int decim, int vlen = 1); }; } /* namespace blocks */ diff --git a/gr-blocks/lib/integrate_XX_impl.cc.t b/gr-blocks/lib/integrate_XX_impl.cc.t index 800d6bc3cb..cb7a448ced 100644 --- a/gr-blocks/lib/integrate_XX_impl.cc.t +++ b/gr-blocks/lib/integrate_XX_impl.cc.t @@ -32,18 +32,18 @@ namespace gr { namespace blocks { - @NAME@::sptr @NAME@::make(int decim) + @NAME@::sptr @NAME@::make(int decim, int vlen) { - return gnuradio::get_initial_sptr(new @NAME_IMPL@(decim)); + return gnuradio::get_initial_sptr(new @NAME_IMPL@(decim, vlen)); } - @NAME_IMPL@::@NAME_IMPL@(int decim) + @NAME_IMPL@::@NAME_IMPL@(int decim, int vlen) : sync_decimator("@NAME@", - io_signature::make(1, 1, sizeof (@I_TYPE@)), - io_signature::make(1, 1, sizeof (@O_TYPE@)), + io_signature::make(1, 1, sizeof (@I_TYPE@) * vlen), + io_signature::make(1, 1, sizeof (@O_TYPE@) * vlen), decim), d_decim(decim), - d_count(0) + d_vlen(vlen) { } @@ -56,9 +56,14 @@ namespace gr { @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]; + for (int j = 0; j < d_vlen; ++j) { + out[i*d_vlen + j] = (@O_TYPE@)0; + } + for (int j = 0; j < d_decim; j++) { + for (int k = 0; k < d_vlen; ++k) { + out[i*d_vlen + k] += in[i*d_decim*d_vlen + j*d_vlen + k]; + } + } } return noutput_items; diff --git a/gr-blocks/lib/integrate_XX_impl.h.t b/gr-blocks/lib/integrate_XX_impl.h.t index e37ddc077d..67e6fce43a 100644 --- a/gr-blocks/lib/integrate_XX_impl.h.t +++ b/gr-blocks/lib/integrate_XX_impl.h.t @@ -33,10 +33,10 @@ namespace gr { class BLOCKS_API @NAME_IMPL@ : public @NAME@ { int d_decim; - int d_count; + int d_vlen; public: - @NAME_IMPL@(int decim); + @NAME_IMPL@(int decim, int vlen); int work(int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gr-blocks/python/blocks/qa_integrate.py b/gr-blocks/python/blocks/qa_integrate.py index 6128169a61..be4285ce95 100755 --- a/gr-blocks/python/blocks/qa_integrate.py +++ b/gr-blocks/python/blocks/qa_integrate.py @@ -70,5 +70,27 @@ class test_integrate (gr_unittest.TestCase): self.tb.run() self.assertComplexTuplesAlmostEqual(dst_data, dst.data(), 6) + def test_004_ss_vec(self): + src_data = (1, 2, 3, 4, 5, 6) + dst_data = (9, 12) + vlen = 2 + src = blocks.vector_source_s(src_data, False, vlen) + itg = blocks.integrate_ss(3, vlen) + dst = blocks.vector_sink_s(vlen) + self.tb.connect(src, itg, dst) + self.tb.run() + self.assertEqual(dst_data, dst.data()) + + def test_003_cc_vec(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 = [9.0+9.0j, 12.0+12.0j] + vlen = 2 + src = blocks.vector_source_c(src_data, False, vlen) + itg = blocks.integrate_cc(3, vlen) + dst = blocks.vector_sink_c(vlen) + 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") |