diff options
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/tsb_vector_sink_X.h.t | 63 | ||||
-rw-r--r-- | gr-blocks/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/lib/tsb_vector_sink_X_impl.cc.t | 85 | ||||
-rw-r--r-- | gr-blocks/lib/tsb_vector_sink_X_impl.h.t | 58 | ||||
-rwxr-xr-x | gr-blocks/python/blocks/qa_tsb_vector_sink_X.py | 58 | ||||
-rw-r--r-- | gr-blocks/swig/blocks_swig1.i | 15 |
7 files changed, 281 insertions, 0 deletions
diff --git a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt index 6789cccf70..14d0549703 100644 --- a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt +++ b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt @@ -86,6 +86,7 @@ expand_h(probe_signal_X b s i f c) expand_h(probe_signal_vX b s i f c) expand_h(sample_and_hold_XX bb ss ii ff) expand_h(sub_XX ss ii ff cc) +expand_h(tsb_vector_sink_X b s i f c) expand_h(xor_XX bb ss ii) expand_h(packed_to_unpacked_XX bb ss ii) expand_h(unpacked_to_packed_XX bb ss ii) diff --git a/gr-blocks/include/gnuradio/blocks/tsb_vector_sink_X.h.t b/gr-blocks/include/gnuradio/blocks/tsb_vector_sink_X.h.t new file mode 100644 index 0000000000..ec7c7d4c3f --- /dev/null +++ b/gr-blocks/include/gnuradio/blocks/tsb_vector_sink_X.h.t @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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 <gnuradio/blocks/api.h> +#include <gnuradio/tagged_stream_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief A vector sink for tagged streams. + * + * Unlike a gr::blocks::vector_sink_f, this only works with tagged streams. + * + * \ingroup blocks + */ + class BLOCKS_API @NAME@ : virtual public gr::tagged_stream_block + { + public: + typedef boost::shared_ptr<@NAME@> sptr; + + virtual void reset() = 0; + virtual std::vector<std::vector<@TYPE@> > data() const = 0; + /*! Doesn't include the TSB tags. + */ + virtual std::vector<tag_t> tags() const = 0; + + /*! + * \param vlen Vector length + * \param tsb_key Tagged Stream Key + */ + static sptr make(int vlen=1, const std::string &tsb_key="ts_last"); + }; + + } // namespace blocks +} // namespace gr + +#endif /* @GUARD_NAME@ */ + diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index e7aee4021c..1446f04367 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -111,6 +111,7 @@ expand_cc_h_impl(peak_detector_XX fb ib sb) expand_cc_h_impl(probe_signal_X b s i f c) expand_cc_h_impl(probe_signal_vX b s i f c) expand_cc_h_impl(sample_and_hold_XX bb ss ii ff) +expand_cc_h_impl(tsb_vector_sink_X b s i f c) expand_cc_h_impl(sub_XX ss ii ff cc) expand_cc_h_impl(xor_XX bb ss ii) expand_cc_h_impl(packed_to_unpacked_XX bb ss ii) diff --git a/gr-blocks/lib/tsb_vector_sink_X_impl.cc.t b/gr-blocks/lib/tsb_vector_sink_X_impl.cc.t new file mode 100644 index 0000000000..450339ac5e --- /dev/null +++ b/gr-blocks/lib/tsb_vector_sink_X_impl.cc.t @@ -0,0 +1,85 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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 <gnuradio/io_signature.h> +#include "@NAME_IMPL@.h" + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(int vlen, const std::string &tsb_key) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(vlen, tsb_key)); + } + + @NAME_IMPL@::@NAME_IMPL@(int vlen, const std::string &tsb_key) + : gr::tagged_stream_block("@NAME@", + gr::io_signature::make(1, 1, vlen * sizeof(@TYPE@)), + gr::io_signature::make(0, 0, 0), tsb_key), + d_vlen(vlen) + {} + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + std::vector<std::vector<@TYPE@> > + @NAME_IMPL@::data() const + { + return d_data; + } + + std::vector<tag_t> + @NAME_IMPL@::tags() const + { + return d_tags; + } + + int + @NAME_IMPL@::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const @TYPE@ *in = (const @TYPE@ *) input_items[0]; + + std::vector<@TYPE@> new_data(in, in + (ninput_items[0] * d_vlen)); + d_data.push_back(new_data); + + std::vector<tag_t> tags; + get_tags_in_window(tags, 0, 0, ninput_items[0]); + d_tags.insert(d_tags.end(), tags.begin(), tags.end()); + + return ninput_items[0]; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/tsb_vector_sink_X_impl.h.t b/gr-blocks/lib/tsb_vector_sink_X_impl.h.t new file mode 100644 index 0000000000..8a97378ab2 --- /dev/null +++ b/gr-blocks/lib/tsb_vector_sink_X_impl.h.t @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2014 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 <gnuradio/blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + std::vector<std::vector<@TYPE@> > d_data; + std::vector<tag_t> d_tags; + int d_vlen; + + public: + @NAME_IMPL@(int vlen, const std::string &tsb_key); + ~@NAME_IMPL@(); + + void reset() { d_data.clear(); } + std::vector<std::vector<@TYPE@> > data() const; + std::vector<tag_t> tags() const; + + int work(int noutput_items, + gr_vector_int &ninput_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/blocks/qa_tsb_vector_sink_X.py b/gr-blocks/python/blocks/qa_tsb_vector_sink_X.py new file mode 100755 index 0000000000..fbc9c9fca3 --- /dev/null +++ b/gr-blocks/python/blocks/qa_tsb_vector_sink_X.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright 2014 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. +# + +import pmt +from gnuradio import gr, gr_unittest +from gnuradio import blocks + +class qa_tsb_vector_sink (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + self.tsb_key = "ts_last" + + def tearDown (self): + self.tb = None + + def test_001_t (self): + packet_len = 4 + data = range(2 * packet_len) + tag = gr.tag_t() + tag.key = pmt.intern("foo") + tag.offset = 5 + tag.value = pmt.intern("bar") + src = blocks.vector_source_f(data, tags=(tag,)) + sink = blocks.tsb_vector_sink_f() + self.tb.connect( + src, + blocks.stream_to_tagged_stream(gr.sizeof_float, 1, packet_len, self.tsb_key), + sink + ) + self.tb.run() + self.assertEqual((tuple(data[0:packet_len]), tuple(data[packet_len:])), sink.data()) + self.assertEqual(len(sink.tags()), 1) + self.assertEqual(sink.tags()[0].offset, tag.offset) + + +if __name__ == '__main__': + gr_unittest.run(qa_tsb_vector_sink, "qa_tsb_vector_sink.xml") diff --git a/gr-blocks/swig/blocks_swig1.i b/gr-blocks/swig/blocks_swig1.i index c87b4df03e..24483fcf91 100644 --- a/gr-blocks/swig/blocks_swig1.i +++ b/gr-blocks/swig/blocks_swig1.i @@ -36,6 +36,11 @@ #include "gnuradio/blocks/streams_to_vector.h" #include "gnuradio/blocks/tag_debug.h" #include "gnuradio/blocks/tagged_file_sink.h" +#include "gnuradio/blocks/tsb_vector_sink_b.h" +#include "gnuradio/blocks/tsb_vector_sink_c.h" +#include "gnuradio/blocks/tsb_vector_sink_f.h" +#include "gnuradio/blocks/tsb_vector_sink_i.h" +#include "gnuradio/blocks/tsb_vector_sink_s.h" #include "gnuradio/blocks/throttle.h" #include "gnuradio/blocks/vector_map.h" #include "gnuradio/blocks/vector_to_stream.h" @@ -68,6 +73,11 @@ %include "gnuradio/blocks/streams_to_vector.h" %include "gnuradio/blocks/tag_debug.h" %include "gnuradio/blocks/tagged_file_sink.h" +%include "gnuradio/blocks/tsb_vector_sink_b.h" +%include "gnuradio/blocks/tsb_vector_sink_c.h" +%include "gnuradio/blocks/tsb_vector_sink_f.h" +%include "gnuradio/blocks/tsb_vector_sink_i.h" +%include "gnuradio/blocks/tsb_vector_sink_s.h" %include "gnuradio/blocks/throttle.h" %include "gnuradio/blocks/vector_map.h" %include "gnuradio/blocks/vector_to_stream.h" @@ -99,6 +109,11 @@ GR_SWIG_BLOCK_MAGIC2(blocks, streams_to_stream); GR_SWIG_BLOCK_MAGIC2(blocks, streams_to_vector); GR_SWIG_BLOCK_MAGIC2(blocks, tag_debug); GR_SWIG_BLOCK_MAGIC2(blocks, tagged_file_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, tsb_vector_sink_b); +GR_SWIG_BLOCK_MAGIC2(blocks, tsb_vector_sink_c); +GR_SWIG_BLOCK_MAGIC2(blocks, tsb_vector_sink_f); +GR_SWIG_BLOCK_MAGIC2(blocks, tsb_vector_sink_i); +GR_SWIG_BLOCK_MAGIC2(blocks, tsb_vector_sink_s); GR_SWIG_BLOCK_MAGIC2(blocks, throttle); GR_SWIG_BLOCK_MAGIC2(blocks, vector_map); GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_stream); |