diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2016-03-27 06:45:26 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2016-03-27 06:45:26 -0700 |
commit | d44dae83c5b486ad320cf2274e4fbcf79c9178c1 (patch) | |
tree | 9f22310f173469bb5ad308a945056e1920f8f899 | |
parent | 4114f71dba3c9c27174d8bfcc12ab54951558c9b (diff) | |
parent | 5297e411f206b9c3c45ee022b8f123994b5e7c6e (diff) |
Merge remote-tracking branch 'nwest/vector-repeat'
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/vector_source_X.h.t | 1 | ||||
-rw-r--r-- | gr-blocks/lib/vector_source_X_impl.h.t | 1 | ||||
-rwxr-xr-x | gr-blocks/python/blocks/qa_vector_sink_source.py | 36 |
3 files changed, 38 insertions, 0 deletions
diff --git a/gr-blocks/include/gnuradio/blocks/vector_source_X.h.t b/gr-blocks/include/gnuradio/blocks/vector_source_X.h.t index d5298e8b47..b0ca6b869f 100644 --- a/gr-blocks/include/gnuradio/blocks/vector_source_X.h.t +++ b/gr-blocks/include/gnuradio/blocks/vector_source_X.h.t @@ -76,6 +76,7 @@ namespace gr { virtual void rewind() = 0; virtual void set_data(const std::vector<@TYPE@> &data, const std::vector<tag_t> &tags=std::vector<tag_t>()) = 0; + virtual void set_repeat(bool repeat) = 0; }; } /* namespace blocks */ diff --git a/gr-blocks/lib/vector_source_X_impl.h.t b/gr-blocks/lib/vector_source_X_impl.h.t index 2641c6661b..bc9b329d8f 100644 --- a/gr-blocks/lib/vector_source_X_impl.h.t +++ b/gr-blocks/lib/vector_source_X_impl.h.t @@ -50,6 +50,7 @@ namespace gr { void rewind() { d_offset=0; } void set_data(const std::vector<@TYPE@> &data, const std::vector<tag_t> &tags); + void set_repeat(bool repeat) { d_repeat=repeat; }; int work(int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gr-blocks/python/blocks/qa_vector_sink_source.py b/gr-blocks/python/blocks/qa_vector_sink_source.py index 5dab7014cd..026713f5f4 100755 --- a/gr-blocks/python/blocks/qa_vector_sink_source.py +++ b/gr-blocks/python/blocks/qa_vector_sink_source.py @@ -46,6 +46,7 @@ class test_vector_sink_source(gr_unittest.TestCase): self.tb = None def test_001(self): + # Test that sink has data set in source for the simplest case src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) @@ -58,6 +59,7 @@ class test_vector_sink_source(gr_unittest.TestCase): self.assertEqual(expected_result, result_data) def test_002(self): + # Test vectors (the gnuradio vector I/O type) src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) @@ -70,11 +72,14 @@ class test_vector_sink_source(gr_unittest.TestCase): self.assertEqual(expected_result, result_data) def test_003(self): + # Test that we can only make vectors (the I/O type) if the input + # vector has sufficient size src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) self.assertRaises(RuntimeError, lambda : blocks.vector_source_f(src_data, False, 3)) def test_004(self): + # Test sending and receiving tagged streams src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) src_tags = tuple([make_tag('key', 'val', 0, 'src')]) @@ -92,6 +97,7 @@ class test_vector_sink_source(gr_unittest.TestCase): self.assertTrue(compare_tags(expected_tags[0], result_tags[0])) def test_005(self): + # Test that repeat works (with tagged streams) length = 16 src_data = [float(x) for x in range(length)] expected_result = tuple(src_data + src_data) @@ -112,6 +118,36 @@ class test_vector_sink_source(gr_unittest.TestCase): self.assertTrue(compare_tags(expected_tags[0], result_tags[0])) self.assertTrue(compare_tags(expected_tags[1], result_tags[1])) + def test_006(self): + # Test set_data + src_data = [float(x) for x in range(16)] + expected_result = tuple(src_data) + + src = blocks.vector_source_f((3,1,4)) + dst = blocks.vector_sink_f() + src.set_data(src_data) + + self.tb.connect(src, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def test_007(self): + # Test set_repeat + src_data = [float(x) for x in range(16)] + expected_result = tuple(src_data) + + src = blocks.vector_source_f(src_data, True) + dst = blocks.vector_sink_f() + src.set_repeat(False) + + self.tb.connect(src, dst) + # will timeout if set_repeat does not work + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + if __name__ == '__main__': gr_unittest.run(test_vector_sink_source, "test_vector_sink_source.xml") |