summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.cc38
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.h11
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.i4
-rw-r--r--grc/blocks/Makefile.am1
-rw-r--r--grc/blocks/block_tree.xml1
-rw-r--r--grc/blocks/gr_burst_tagger.xml87
6 files changed, 134 insertions, 8 deletions
diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.cc b/gnuradio-core/src/lib/general/gr_burst_tagger.cc
index 4b3847b08..bd713d663 100644
--- a/gnuradio-core/src/lib/general/gr_burst_tagger.cc
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.cc
@@ -43,10 +43,39 @@ gr_burst_tagger::gr_burst_tagger(size_t itemsize)
std::stringstream str;
str << name() << unique_id();
- d_key = pmt::pmt_string_to_symbol("burst");
+ d_true_key = pmt::pmt_string_to_symbol("burst");
+ d_true_value = pmt::PMT_T;
+
+ d_false_key = pmt::pmt_string_to_symbol("burst");
+ d_false_value = pmt::PMT_F;
+
d_id = pmt::pmt_string_to_symbol(str.str());
}
+void
+gr_burst_tagger::set_true_tag (const std::string &key, bool value)
+{
+ d_true_key = pmt::pmt_string_to_symbol(key);
+ if(value == true) {
+ d_true_value = pmt::PMT_T;
+ }
+ else {
+ d_true_value = pmt::PMT_F;
+ }
+}
+
+void
+gr_burst_tagger::set_false_tag (const std::string &key, bool value)
+{
+ d_false_key = pmt::pmt_string_to_symbol(key);
+ if(value == true) {
+ d_false_value = pmt::PMT_T;
+ }
+ else {
+ d_false_value = pmt::PMT_F;
+ }
+}
+
gr_burst_tagger::~gr_burst_tagger()
{
}
@@ -66,18 +95,15 @@ gr_burst_tagger::work(int noutput_items,
if(trigger[i] > 0) {
if(d_state == false) {
d_state = true;
- pmt::pmt_t value = pmt::PMT_T;
- add_item_tag(0, nitems_written(0)+i, d_key, value, d_id);
+ add_item_tag(0, nitems_written(0)+i, d_true_key, d_true_value, d_id);
}
}
else {
if(d_state == true) {
d_state = false;
- pmt::pmt_t value = pmt::PMT_F;
- add_item_tag(0, nitems_written(0)+i, d_key, value, d_id);
+ add_item_tag(0, nitems_written(0)+i, d_false_key, d_false_value, d_id);
}
}
}
-
return noutput_items;
}
diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.h b/gnuradio-core/src/lib/general/gr_burst_tagger.h
index 7547ba9cc..663a146f2 100644
--- a/gnuradio-core/src/lib/general/gr_burst_tagger.h
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.h
@@ -40,14 +40,21 @@ class GR_CORE_API gr_burst_tagger : public gr_sync_block
{
size_t d_itemsize;
bool d_state;
- pmt::pmt_t d_key;
+ pmt::pmt_t d_true_key;
+ pmt::pmt_t d_true_value;
+
+ pmt::pmt_t d_false_key;
+ pmt::pmt_t d_false_value;
+
pmt::pmt_t d_id;
-
+
friend GR_CORE_API gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize);
gr_burst_tagger(size_t itemsize);
public:
~gr_burst_tagger();
+ void set_true_tag (const std::string &key, bool value);
+ void set_false_tag (const std::string &key, bool value);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.i b/gnuradio-core/src/lib/general/gr_burst_tagger.i
index ebf1eea8c..868941fc6 100644
--- a/gnuradio-core/src/lib/general/gr_burst_tagger.i
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.i
@@ -28,4 +28,8 @@ class gr_burst_tagger : public gr_sync_block
{
private:
gr_burst_tagger(size_t itemsize);
+
+ public:
+ void set_true_tag(const std::string &key, bool value);
+ void set_false_tag(const std::string &key, bool value);
};
diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am
index 020dcecdd..738e79f24 100644
--- a/grc/blocks/Makefile.am
+++ b/grc/blocks/Makefile.am
@@ -162,6 +162,7 @@ dist_ourdata_DATA = \
gr_stream_to_vector.xml \
gr_streams_to_stream.xml \
gr_streams_to_vector.xml \
+ gr_burst_tagger.xml \
gr_sub_xx.xml \
gr_threshold_ff.xml \
gr_throttle.xml \
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index 183408cec..abc12b97f 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -104,6 +104,7 @@
<block>blks2_stream_to_vector_decimator</block>
<block>gr_stream_mux</block>
+ <block>gr_burst_tagger</block>
</cat>
<cat>
<name>Misc Conversions</name>
diff --git a/grc/blocks/gr_burst_tagger.xml b/grc/blocks/gr_burst_tagger.xml
new file mode 100644
index 000000000..58c909999
--- /dev/null
+++ b/grc/blocks/gr_burst_tagger.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Burst tagger:
+## all types, 1 output, 2 input: stream & trigger (short)
+###################################################
+ -->
+<block>
+ <name>Burst Tagger</name>
+ <key>gr_burst_tagger</key>
+ <import>from gnuradio import gr</import>
+ <make>gr.burst_tagger($type.size)
+self.$(id).set_true_tag($true_key,$true_value)
+self.$(id).set_false_tag($false_key,$false_value)
+ </make>
+ <callback>set_true_tag($true_key,$true_value)</callback>
+ <callback>set_false_tag($false_key,$false_value)</callback>
+ <param>
+ <name>Stream 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>True KeyID</name>
+ <key>true_key</key>
+ <value>burst</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>True Value</name>
+ <key>true_value</key>
+ <value>True</value>
+ <type>bool</type>
+ </param>
+ <param>
+ <name>False KeyID</name>
+ <key>false_key</key>
+ <value>burst</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>False Value</name>
+ <key>false_value</key>
+ <value>False</value>
+ <type>bool</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>1</vlen>
+ </sink>
+ <sink>
+ <name>trigger</name>
+ <type>short</type>
+ <vlen>1</vlen>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>1</vlen>
+ </source>
+</block>