summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2013-10-23 16:37:41 -0400
committerTom Rondeau <tom@trondeau.com>2013-10-29 12:04:09 -0400
commit1cbeec5083bbfdd281b30271e874f0849b0a9be0 (patch)
tree0301fb3e4547d7f571ac9c7ffc423771e8c4f540
parent32bcd3dcbf9ef398d834c664e7e6e5f6cb5124d8 (diff)
blocks: adding ability to set a key filter in tag_debug block.
-rw-r--r--gr-blocks/grc/blocks_tag_debug.xml8
-rw-r--r--gr-blocks/include/gnuradio/blocks/tag_debug.h19
-rw-r--r--gr-blocks/lib/tag_debug_impl.cc33
-rw-r--r--gr-blocks/lib/tag_debug_impl.h7
4 files changed, 58 insertions, 9 deletions
diff --git a/gr-blocks/grc/blocks_tag_debug.xml b/gr-blocks/grc/blocks_tag_debug.xml
index bf2b4a7ec0..03dd147cbe 100644
--- a/gr-blocks/grc/blocks_tag_debug.xml
+++ b/gr-blocks/grc/blocks_tag_debug.xml
@@ -8,7 +8,7 @@
<name>Tag Debug</name>
<key>blocks_tag_debug</key>
<import>from gnuradio import blocks</import>
- <make>blocks.tag_debug($type.size*$vlen, $name); self.$(id).set_display($display)</make>
+ <make>blocks.tag_debug($type.size*$vlen, $name, $filter); self.$(id).set_display($display)</make>
<callback>set_display($display)</callback>
<param>
<name>Input Type</name>
@@ -46,6 +46,12 @@
<type>string</type>
</param>
<param>
+ <name>Key Filter</name>
+ <key>filter</key>
+ <value>""</value>
+ <type>string</type>
+ </param>
+ <param>
<name>Num Inputs</name>
<key>num_inputs</key>
<value>1</value>
diff --git a/gr-blocks/include/gnuradio/blocks/tag_debug.h b/gr-blocks/include/gnuradio/blocks/tag_debug.h
index ab222f02f1..3d7725c7d5 100644
--- a/gr-blocks/include/gnuradio/blocks/tag_debug.h
+++ b/gr-blocks/include/gnuradio/blocks/tag_debug.h
@@ -47,6 +47,11 @@ namespace gr {
* to any block and watch all tags streaming out of that block for
* debugging purposes.
*
+ * Specifying a key will allow this block to filter out all other
+ * tags and only display tags that match the given key. This can
+ * help clean up the output and allow you to focus in on a
+ * particular tag of interest.
+ *
* The tags from the last call to this work function are stored
* and can be retrieved using the function 'current_tags'.
*/
@@ -61,9 +66,11 @@ namespace gr {
*
* \param sizeof_stream_item size of the items in the incoming stream.
* \param name name to identify which debug sink generated the info.
+ * \param key_filter Specify a tag's key value to use as a filter.
*/
static sptr make(size_t sizeof_stream_item,
- const std::string &name);
+ const std::string &name,
+ const std::string &key_filter="");
/*!
* \brief Returns a vector of tag_t items as of the last call to
@@ -80,6 +87,16 @@ namespace gr {
* \brief Set the display of tags to stdout on/off.
*/
virtual void set_display(bool d) = 0;
+
+ /*!
+ * \brief Set a new key to filter with.
+ */
+ virtual void set_key_filter(const std::string &key_filter) = 0;
+
+ /*!
+ * \brief Get the current filter key.
+ */
+ virtual std::string key_filter() const = 0;
};
} /* namespace blocks */
diff --git a/gr-blocks/lib/tag_debug_impl.cc b/gr-blocks/lib/tag_debug_impl.cc
index 567f83dcb6..7f4502c346 100644
--- a/gr-blocks/lib/tag_debug_impl.cc
+++ b/gr-blocks/lib/tag_debug_impl.cc
@@ -34,19 +34,22 @@ namespace gr {
tag_debug::sptr
tag_debug::make(size_t sizeof_stream_item,
- const std::string &name)
+ const std::string &name,
+ const std::string &key_filter)
{
return gnuradio::get_initial_sptr
- (new tag_debug_impl(sizeof_stream_item, name));
+ (new tag_debug_impl(sizeof_stream_item, name, key_filter));
}
tag_debug_impl::tag_debug_impl(size_t sizeof_stream_item,
- const std::string &name)
+ const std::string &name,
+ const std::string &key_filter)
: sync_block("tag_debug",
- io_signature::make(1, -1, sizeof_stream_item),
- io_signature::make(0, 0, 0)),
+ io_signature::make(1, -1, sizeof_stream_item),
+ io_signature::make(0, 0, 0)),
d_name(name), d_display(true)
{
+ set_key_filter(key_filter);
}
tag_debug_impl::~tag_debug_impl()
@@ -74,6 +77,21 @@ namespace gr {
d_display = d;
}
+ void
+ tag_debug_impl::set_key_filter(const std::string &key_filter)
+ {
+ if(key_filter == "")
+ d_filter = pmt::PMT_NIL;
+ else
+ d_filter = pmt::intern(key_filter);
+ }
+
+ std::string
+ tag_debug_impl::key_filter() const
+ {
+ return pmt::symbol_to_string(d_filter);
+ }
+
int
tag_debug_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -94,7 +112,10 @@ namespace gr {
end_N = abs_N + (uint64_t)(noutput_items);
d_tags.clear();
- get_tags_in_range(d_tags, i, abs_N, end_N);
+ if(pmt::is_null(d_filter))
+ get_tags_in_range(d_tags, i, abs_N, end_N);
+ else
+ get_tags_in_range(d_tags, i, abs_N, end_N, d_filter);
if(d_display) {
sout << "Input Stream: " << std::setw(2) << std::setfill('0')
diff --git a/gr-blocks/lib/tag_debug_impl.h b/gr-blocks/lib/tag_debug_impl.h
index 03b1846139..1d28f123d3 100644
--- a/gr-blocks/lib/tag_debug_impl.h
+++ b/gr-blocks/lib/tag_debug_impl.h
@@ -37,10 +37,12 @@ namespace gr {
std::vector<tag_t> d_tags;
std::vector<tag_t>::iterator d_tags_itr;
bool d_display;
+ pmt::pmt_t d_filter;
gr::thread::mutex d_mutex;
public:
- tag_debug_impl(size_t sizeof_stream_item, const std::string &name);
+ tag_debug_impl(size_t sizeof_stream_item, const std::string &name,
+ const std::string &key_filter="");
~tag_debug_impl();
void setup_rpc();
@@ -50,6 +52,9 @@ namespace gr {
void set_display(bool d);
+ void set_key_filter(const std::string &key_filter);
+ std::string key_filter() const;
+
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);