[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/12: blocks: Added tsb_vector_sinks
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/12: blocks: Added tsb_vector_sinks |
Date: |
Fri, 23 May 2014 17:35:56 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 979060c0e7edac88ebcb56b4c44409c0c5c8ea19
Author: Martin Braun <address@hidden>
Date: Sun May 4 23:02:21 2014 +0200
blocks: Added tsb_vector_sinks
---
gr-blocks/include/gnuradio/blocks/CMakeLists.txt | 1 +
.../include/gnuradio/blocks/tsb_vector_sink_X.h.t | 63 ++++++++++++++++
gr-blocks/lib/CMakeLists.txt | 1 +
gr-blocks/lib/tsb_vector_sink_X_impl.cc.t | 85 ++++++++++++++++++++++
gr-blocks/lib/tsb_vector_sink_X_impl.h.t | 58 +++++++++++++++
gr-blocks/python/blocks/qa_tsb_vector_sink_X.py | 58 +++++++++++++++
gr-blocks/swig/blocks_swig1.i | 15 ++++
7 files changed, 281 insertions(+)
diff --git a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt
b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt
index 6789ccc..14d0549 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 0000000..ec7c7d4
--- /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 e7aee40..1446f04 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 0000000..450339a
--- /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 "@address@hidden"
+
+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@::address@hidden@()
+ {
+ }
+
+ 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 0000000..8a97378
--- /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/@address@hidden>
+
+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);
+ address@hidden@();
+
+ 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 0000000..fbc9c9f
--- /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 c87b4df..24483fc 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);
- [Commit-gnuradio] [gnuradio] branch master updated (cba2d18 -> 5cb67ce), git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 10/12: Merge branch 'maint', git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 04/12: blocks: Added tsb_vector_sinks,
git <=
- [Commit-gnuradio] [gnuradio] 07/12: runtime: Added packet_utils and marked tagged_streams.py for removal in future, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 05/12: blocks: updated some QAs to use proper tsb functions, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 06/12: digital: updated some QAs to use proper tsb functions, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 11/12: Merge remote-tracking branch 'martin/tsb/prep_for_38', git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 08/12: uhd: Nicer labels for device args and addres in GRC, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 09/12: Merge branch 'uint64_sugar' of git://github.com/osh/gnuradio, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 02/12: pmt: support conversion of basic pmt pairs to python, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 01/12: pmt: adding uint64 sugar, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 03/12: pmt: making uint64_t sugar more friendly, git, 2014/05/23
- [Commit-gnuradio] [gnuradio] 12/12: Merge remote-tracking branch 'martin/uhd/clearer_grc_args', git, 2014/05/23