summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim O'Shea <tim.oshea753@gmail.com>2013-11-26 14:17:42 -0500
committerTom Rondeau <tom@trondeau.com>2013-11-27 15:28:33 -0500
commitf863f08c747d10feb2cee0ab4088da851d2e51b7 (patch)
tree0429fb764fb4ec7f000bef96b001676c33e506f7
parent94976b10bf50c52e07f847e32683855b2b95b276 (diff)
blocks: allow the user to specify the tag key used in the tags_strobe block
-rw-r--r--gr-blocks/grc/blocks_tags_strobe.xml9
-rw-r--r--gr-blocks/include/gnuradio/blocks/tags_strobe.h14
-rw-r--r--gr-blocks/lib/tags_strobe_impl.cc20
-rw-r--r--gr-blocks/lib/tags_strobe_impl.h5
4 files changed, 39 insertions, 9 deletions
diff --git a/gr-blocks/grc/blocks_tags_strobe.xml b/gr-blocks/grc/blocks_tags_strobe.xml
index 16109eaad1..f17edd2b99 100644
--- a/gr-blocks/grc/blocks_tags_strobe.xml
+++ b/gr-blocks/grc/blocks_tags_strobe.xml
@@ -9,8 +9,9 @@
<key>blocks_tags_strobe</key>
<import>from gnuradio import blocks</import>
<import>import pmt</import>
- <make>blocks.tags_strobe($type.size*$vlen, $value, $nsamps)</make>
+ <make>blocks.tags_strobe($type.size*$vlen, $value, $nsamps, $key)</make>
<callback>set_value($value)</callback>
+ <callback>set_key($key)</callback>
<callback>set_nsamps($nsamps)</callback>
<param>
<name>Output Type</name>
@@ -49,6 +50,12 @@
<type>raw</type>
</param>
<param>
+ <name>Key (PMT)</name>
+ <key>key</key>
+ <value>pmt.intern("strobe")</value>
+ <type>raw</type>
+ </param>
+ <param>
<name>Num. Samples</name>
<key>nsamps</key>
<value>1000</value>
diff --git a/gr-blocks/include/gnuradio/blocks/tags_strobe.h b/gr-blocks/include/gnuradio/blocks/tags_strobe.h
index 3660ca4c1b..eb04f01415 100644
--- a/gr-blocks/include/gnuradio/blocks/tags_strobe.h
+++ b/gr-blocks/include/gnuradio/blocks/tags_strobe.h
@@ -54,9 +54,10 @@ namespace gr {
* \param sizeof_stream_item size of the stream items in bytes.
* \param value The value of the tags to send, as a PMT.
* \param nsamps the number of samples between each tag.
+ * \param key The tag key to sent
*/
static sptr make(size_t sizeof_stream_item,
- pmt::pmt_t value, uint64_t nsamps);
+ pmt::pmt_t value, uint64_t nsamps, pmt::pmt_t key = pmt::intern("strobe"));
/*!
* Reset the value of the tags being sent.
@@ -65,11 +66,21 @@ namespace gr {
virtual void set_value(pmt::pmt_t value) = 0;
/*!
+ * Change the tag key we are sending
+ */
+ virtual void set_key(pmt::pmt_t key) = 0;
+
+ /*!
* Get the value of the tags being sent.
*/
virtual pmt::pmt_t value() const = 0;
/*!
+ * Get the key of the tags being sent.
+ */
+ virtual pmt::pmt_t key() const = 0;
+
+ /*!
* Reset the sending interval.
* \param nsamps the number of samples between each tag
*/
@@ -79,6 +90,7 @@ namespace gr {
* Get the number of samples between the tag strobe.
*/
virtual uint64_t nsamps() const = 0;
+
};
} /* namespace blocks */
diff --git a/gr-blocks/lib/tags_strobe_impl.cc b/gr-blocks/lib/tags_strobe_impl.cc
index 41329d88a3..cfe335781c 100644
--- a/gr-blocks/lib/tags_strobe_impl.cc
+++ b/gr-blocks/lib/tags_strobe_impl.cc
@@ -40,20 +40,25 @@ namespace gr {
tags_strobe::sptr
tags_strobe::make(size_t sizeof_stream_item,
- pmt::pmt_t value, uint64_t nsamps)
+ pmt::pmt_t value, uint64_t nsamps, pmt::pmt_t key)
{
return gnuradio::get_initial_sptr
- (new tags_strobe_impl(sizeof_stream_item, value, nsamps));
+ (new tags_strobe_impl(sizeof_stream_item, value, nsamps, key));
}
tags_strobe_impl::tags_strobe_impl(size_t sizeof_stream_item,
- pmt::pmt_t value, uint64_t nsamps)
+ pmt::pmt_t value, uint64_t nsamps,
+ pmt::pmt_t key)
: sync_block("tags_strobe",
io_signature::make(0, 0, 0),
io_signature::make(1, 1, sizeof_stream_item)),
d_itemsize(sizeof_stream_item)
{
+ d_tag.offset = 0;
+ d_tag.key = pmt::intern("strobe");
+ d_tag.srcid = alias_pmt();
set_value(value);
+ set_key(key);
set_nsamps(nsamps);
}
@@ -64,10 +69,13 @@ namespace gr {
void
tags_strobe_impl::set_value(pmt::pmt_t value)
{
- d_tag.offset = 0;
- d_tag.key = pmt::intern("strobe");
d_tag.value = value;
- d_tag.srcid = alias_pmt();
+ }
+
+ void
+ tags_strobe_impl::set_key(pmt::pmt_t key)
+ {
+ d_tag.key = key;
}
void
diff --git a/gr-blocks/lib/tags_strobe_impl.h b/gr-blocks/lib/tags_strobe_impl.h
index a6d73cfead..e99d3e1b44 100644
--- a/gr-blocks/lib/tags_strobe_impl.h
+++ b/gr-blocks/lib/tags_strobe_impl.h
@@ -40,11 +40,14 @@ namespace gr {
public:
tags_strobe_impl(size_t sizeof_stream_item,
- pmt::pmt_t value, uint64_t nsamps);
+ pmt::pmt_t value, uint64_t nsamps,
+ pmt::pmt_t key);
~tags_strobe_impl();
void set_value(pmt::pmt_t value);
+ void set_key(pmt::pmt_t key);
pmt::pmt_t value() const { return d_tag.value; }
+ pmt::pmt_t key() const { return d_tag.key; }
void set_nsamps(uint64_t nsamps);
uint64_t nsamps() const { return d_nsamps; }