summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-blocks/grc/blocks_block_tree.xml1
-rw-r--r--gr-blocks/grc/blocks_tag_gate.xml68
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt2
-rw-r--r--gr-blocks/include/blocks/tag_gate.h56
-rw-r--r--gr-blocks/lib/CMakeLists.txt3
-rw-r--r--gr-blocks/lib/tag_gate_impl.cc79
-rw-r--r--gr-blocks/lib/tag_gate_impl.h52
-rwxr-xr-xgr-blocks/python/qa_tag_gate.py49
-rw-r--r--gr-blocks/swig/blocks_swig0.i3
9 files changed, 311 insertions, 2 deletions
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml
index 04fe1f6955..64eacfa91e 100644
--- a/gr-blocks/grc/blocks_block_tree.xml
+++ b/gr-blocks/grc/blocks_block_tree.xml
@@ -163,6 +163,7 @@
<cat>
<name>Stream Tag Tools</name>
<block>blocks_tag_debug</block>
+ <block>blocks_tag_gate</block>
<block>blocks_tagged_file_sink</block>
<block>blocks_tagged_stream_mux</block>
</cat>
diff --git a/gr-blocks/grc/blocks_tag_gate.xml b/gr-blocks/grc/blocks_tag_gate.xml
new file mode 100644
index 0000000000..5c748f27cf
--- /dev/null
+++ b/gr-blocks/grc/blocks_tag_gate.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<block>
+ <name>Tag Gate</name>
+ <key>blocks_tag_gate</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.tag_gate($type.size * $vlen, $propagate_tags)</make>
+ <param>
+ <name>Item Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>size:gr.sizeof_gr_complex</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>size:gr.sizeof_float</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>size:gr.sizeof_int</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>size:gr.sizeof_short</opt>
+ </option>
+ <option>
+ <name>Byte</name>
+ <key>byte</key>
+ <opt>size:gr.sizeof_char</opt>
+ </option>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Propagate_tags</name>
+ <key>propagate_tags</key>
+ <value>False</value>
+ <type>enum</type>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ </param>
+ <check>$vlen &gt; 0</check>
+ <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/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index 7b74ca7a5d..a877dfc557 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -203,6 +203,6 @@ install(FILES
vector_to_streams.h
wavfile_sink.h
wavfile_source.h
- DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks
+ tag_gate.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks
COMPONENT "blocks_devel"
)
diff --git a/gr-blocks/include/blocks/tag_gate.h b/gr-blocks/include/blocks/tag_gate.h
new file mode 100644
index 0000000000..2c3d20d464
--- /dev/null
+++ b/gr-blocks/include/blocks/tag_gate.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifndef INCLUDED_BLOCKS_TAG_GATE_H
+#define INCLUDED_BLOCKS_TAG_GATE_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ /*!
+ * \brief Control tag propagation.
+ * \ingroup blocks
+ *
+ * Use this block to stop tags from propagating.
+ */
+ class BLOCKS_API tag_gate : virtual public gr_sync_block
+ {
+ public:
+ typedef boost::shared_ptr<tag_gate> sptr;
+
+ virtual void set_propagation(bool propagate_tags) = 0;
+
+ /*!
+ * \param item_size Item size
+ * \param propagate_tags Set this to true to allow tags to pass through this block.
+ */
+ static sptr make(size_t item_size, bool propagate_tags=false);
+ };
+
+ } // namespace blocks
+} // namespace gr
+
+#endif /* INCLUDED_BLOCKS_TAG_GATE_H */
+
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index eb7af51c0b..57c1cd20df 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -266,7 +266,8 @@ list(APPEND blocks_libs
${LOG4CPP_LIBRARIES}
)
-add_library(gnuradio-blocks SHARED ${gr_blocks_sources})
+add_library(gnuradio-blocks SHARED ${gr_blocks_sources}
+ tag_gate_impl.cc)
add_dependencies(gnuradio-blocks blocks_generated_includes)
target_link_libraries(gnuradio-blocks ${blocks_libs})
diff --git a/gr-blocks/lib/tag_gate_impl.cc b/gr-blocks/lib/tag_gate_impl.cc
new file mode 100644
index 0000000000..854031bf8b
--- /dev/null
+++ b/gr-blocks/lib/tag_gate_impl.cc
@@ -0,0 +1,79 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_io_signature.h>
+#include "tag_gate_impl.h"
+
+namespace gr {
+ namespace blocks {
+
+ tag_gate::sptr
+ tag_gate::make(size_t item_size, bool propagate_tags)
+ {
+ return gnuradio::get_initial_sptr (new tag_gate_impl(item_size, propagate_tags));
+ }
+
+ tag_gate_impl::tag_gate_impl(size_t item_size, bool propagate_tags)
+ : gr_sync_block("tag_gate",
+ gr_make_io_signature(1, 1, item_size),
+ gr_make_io_signature(1, 1, item_size)),
+ d_item_size(item_size),
+ d_propagate_tags(propagate_tags)
+ {
+ if (!d_propagate_tags) {
+ set_tag_propagation_policy(TPP_DONT);
+ }
+ }
+
+ tag_gate_impl::~tag_gate_impl()
+ {
+ }
+
+ void tag_gate_impl::set_propagation(bool propagate_tags)
+ {
+ if (propagate_tags) {
+ set_tag_propagation_policy(TPP_ALL_TO_ALL);
+ } else {
+ set_tag_propagation_policy(TPP_DONT);
+ }
+ }
+
+ int
+ tag_gate_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const unsigned char *in = (const unsigned char *) input_items[0];
+ unsigned char *out = (unsigned char *) output_items[0];
+
+ memcpy((void *) out, (void *) in, d_item_size * noutput_items);
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
+
diff --git a/gr-blocks/lib/tag_gate_impl.h b/gr-blocks/lib/tag_gate_impl.h
new file mode 100644
index 0000000000..4b61b62036
--- /dev/null
+++ b/gr-blocks/lib/tag_gate_impl.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2013 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.
+ */
+
+#ifndef INCLUDED_BLOCKS_TAG_GATE_IMPL_H
+#define INCLUDED_BLOCKS_TAG_GATE_IMPL_H
+
+#include <blocks/tag_gate.h>
+
+namespace gr {
+ namespace blocks {
+
+ class tag_gate_impl : public tag_gate
+ {
+ private:
+ size_t d_item_size;
+ bool d_propagate_tags;
+
+ public:
+ tag_gate_impl(size_t item_size, bool propagate_tags);
+ ~tag_gate_impl();
+
+ void set_propagation(bool propagate_tags);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } // namespace blocks
+} // namespace gr
+
+#endif /* INCLUDED_BLOCKS_TAG_GATE_IMPL_H */
+
diff --git a/gr-blocks/python/qa_tag_gate.py b/gr-blocks/python/qa_tag_gate.py
new file mode 100755
index 0000000000..fa3c501fb4
--- /dev/null
+++ b/gr-blocks/python/qa_tag_gate.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 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 pmt
+import blocks_swig as blocks
+
+
+class qa_tag_gate (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_001_t (self):
+ tag = gr.gr_tag_t()
+ tag.key = pmt.pmt_string_to_symbol('key')
+ tag.value = pmt.pmt_from_long(42)
+ tag.offset = 0
+ src = blocks.vector_source_f(range(20), False, 1, (tag,))
+ gate = blocks.tag_gate(gr.sizeof_float, False)
+ sink = blocks.vector_sink_f()
+ self.tb.run ()
+ self.assertEqual(len(sink.tags()), 0)
+
+if __name__ == '__main__':
+ gr_unittest.run(qa_tag_gate, "qa_tag_gate.xml")
+
diff --git a/gr-blocks/swig/blocks_swig0.i b/gr-blocks/swig/blocks_swig0.i
index 1a6e0331d1..912adcfd0c 100644
--- a/gr-blocks/swig/blocks_swig0.i
+++ b/gr-blocks/swig/blocks_swig0.i
@@ -56,6 +56,7 @@
#include "blocks/streams_to_stream.h"
#include "blocks/streams_to_vector.h"
#include "blocks/tag_debug.h"
+#include "blocks/tag_gate.h"
#include "blocks/tagged_file_sink.h"
#include "blocks/throttle.h"
#include "blocks/vector_map.h"
@@ -106,6 +107,7 @@
%include "blocks/streams_to_stream.h"
%include "blocks/streams_to_vector.h"
%include "blocks/tag_debug.h"
+%include "blocks/tag_gate.h"
%include "blocks/tagged_file_sink.h"
%include "blocks/throttle.h"
%include "blocks/vector_map.h"
@@ -154,6 +156,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_vector);
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, tag_gate);
GR_SWIG_BLOCK_MAGIC2(blocks, tagged_file_sink);
GR_SWIG_BLOCK_MAGIC2(blocks, throttle);
GR_SWIG_BLOCK_MAGIC2(blocks, vector_map);