summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau2010-11-16 22:32:46 -0800
committerTom Rondeau2010-11-16 22:32:46 -0800
commite6751f477ba006923e9f0d2454ff870c52a6f0a5 (patch)
treeddb7123f7ed0bb110f1123e9eb473457990e38d7
parent5ef9a41c9ddfae56a77c118c1dcf2b0af2973207 (diff)
downloadgnuradio-e6751f477ba006923e9f0d2454ff870c52a6f0a5.tar.gz
gnuradio-e6751f477ba006923e9f0d2454ff870c52a6f0a5.tar.bz2
gnuradio-e6751f477ba006923e9f0d2454ff870c52a6f0a5.zip
Adding a burst tagger that creates a tag when a signal is observed on line 1.
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am9
-rw-r--r--gnuradio-core/src/lib/general/general.i2
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.cc83
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.h56
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.i31
5 files changed, 178 insertions, 3 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index 2e52d88f3..0e9109d6c 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -177,7 +177,8 @@ libgeneral_la_SOURCES = \
gr_probe_mpsk_snr_c.cc \
gr_probe_density_b.cc \
gr_annotator_alltoall.cc \
- gr_annotator_1to1.cc
+ gr_annotator_1to1.cc \
+ gr_burst_tagger.cc
libgeneral_qa_la_SOURCES = \
qa_general.cc \
@@ -348,7 +349,8 @@ grinclude_HEADERS = \
gr_probe_mpsk_snr_c.h \
gr_probe_density_b.h \
gr_annotator_alltoall.h \
- gr_annotator_1to1.h
+ gr_annotator_1to1.h \
+ gr_burst_tagger.h
noinst_HEADERS = \
qa_general.h \
@@ -490,5 +492,6 @@ swiginclude_HEADERS = \
gr_probe_mpsk_snr_c.i \
gr_probe_density_b.i \
gr_annotator_alltoall.i \
- gr_annotator_1to1.i
+ gr_annotator_1to1.i \
+ gr_burst_tagger.i
endif
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index 400f0b9b6..0f8b57a44 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -143,6 +143,7 @@
#include <gr_additive_scrambler_bb.h>
#include <gr_annotator_alltoall.h>
#include <gr_annotator_1to1.h>
+#include <gr_burst_tagger.h>
%}
%include "gr_nop.i"
@@ -266,3 +267,4 @@
%include "gr_additive_scrambler_bb.i"
%include "gr_annotator_alltoall.i"
%include "gr_annotator_1to1.i"
+%include "gr_burst_tagger.i"
diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.cc b/gnuradio-core/src/lib/general/gr_burst_tagger.cc
new file mode 100644
index 000000000..4b3847b08
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.cc
@@ -0,0 +1,83 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 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_burst_tagger.h>
+#include <gr_io_signature.h>
+#include <string.h>
+
+gr_burst_tagger_sptr
+gr_make_burst_tagger(size_t itemsize)
+{
+ return gnuradio::get_initial_sptr(new gr_burst_tagger(itemsize));
+}
+
+gr_burst_tagger::gr_burst_tagger(size_t itemsize)
+ : gr_sync_block ("burst_tagger",
+ gr_make_io_signature2 (2, 2, itemsize, sizeof(short)),
+ gr_make_io_signature (1, 1, itemsize)),
+ d_itemsize(itemsize), d_state(false)
+{
+ std::stringstream str;
+ str << name() << unique_id();
+
+ d_key = pmt::pmt_string_to_symbol("burst");
+ d_id = pmt::pmt_string_to_symbol(str.str());
+}
+
+gr_burst_tagger::~gr_burst_tagger()
+{
+}
+
+int
+gr_burst_tagger::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const char *signal = (const char*)input_items[0];
+ const short *trigger = (const short*)input_items[1];
+ char *out = (char*)output_items[0];
+
+ memcpy(out, signal, noutput_items * d_itemsize);
+
+ for(int i = 0; i < noutput_items; i++) {
+ 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);
+ }
+ }
+ 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);
+ }
+ }
+ }
+
+ 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
new file mode 100644
index 000000000..8f814bea0
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 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_GR_BURST_TAGGER_H
+#define INCLUDED_GR_BURST_TAGGER_H
+
+#include <gr_sync_block.h>
+
+class gr_burst_tagger;
+typedef boost::shared_ptr<gr_burst_tagger> gr_burst_tagger_sptr;
+
+gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize);
+
+/*!
+ * \brief output[i] = input[i]
+ * \ingroup misc_blk
+ *
+ */
+class gr_burst_tagger : public gr_sync_block
+{
+ size_t d_itemsize;
+ bool d_state;
+ pmt::pmt_t d_key;
+ pmt::pmt_t d_id;
+
+ friend gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize);
+ gr_burst_tagger(size_t itemsize);
+
+ public:
+ ~gr_burst_tagger();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.i b/gnuradio-core/src/lib/general/gr_burst_tagger.i
new file mode 100644
index 000000000..ebf1eea8c
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.i
@@ -0,0 +1,31 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,burst_tagger)
+
+gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize);
+
+class gr_burst_tagger : public gr_sync_block
+{
+ private:
+ gr_burst_tagger(size_t itemsize);
+};