summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/general
diff options
context:
space:
mode:
authorTom Rondeau2010-11-11 15:55:04 -0500
committerTom Rondeau2010-11-11 15:55:04 -0500
commit9aaf98cff5e03ec2821da492f3857780a767258f (patch)
tree93a0ae5a39f572a222239aff77892063723d2c7a /gnuradio-core/src/lib/general
parentc204913321f0618ac131738088dab23065bdfa80 (diff)
downloadgnuradio-9aaf98cff5e03ec2821da492f3857780a767258f.tar.gz
gnuradio-9aaf98cff5e03ec2821da492f3857780a767258f.tar.bz2
gnuradio-9aaf98cff5e03ec2821da492f3857780a767258f.zip
Renaming random_annotator to annotator_1toall that moves tags from single input to all outputs.
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am11
-rw-r--r--gnuradio-core/src/lib/general/general.i4
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_1toall.cc99
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_1toall.h55
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_1toall.i32
5 files changed, 198 insertions, 3 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index 3d8a42805..a58461165 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -175,7 +175,9 @@ libgeneral_la_SOURCES = \
gr_descrambler_bb.cc \
gr_scrambler_bb.cc \
gr_probe_mpsk_snr_c.cc \
- gr_probe_density_b.cc
+ gr_probe_density_b.cc \
+ gr_annotator_1toall.cc \
+ gr_annotator_1to1.cc
libgeneral_qa_la_SOURCES = \
qa_general.cc \
@@ -344,7 +346,8 @@ grinclude_HEADERS = \
gr_descrambler_bb.h \
gr_scrambler_bb.h \
gr_probe_mpsk_snr_c.h \
- gr_probe_density_b.h
+ gr_probe_density_b.h \
+ gr_annotator_1toall.h
noinst_HEADERS = \
qa_general.h \
@@ -484,5 +487,7 @@ swiginclude_HEADERS = \
gr_descrambler_bb.i \
gr_scrambler_bb.i \
gr_probe_mpsk_snr_c.i \
- gr_probe_density_b.i
+ gr_probe_density_b.i \
+ gr_annotator_1toall.i \
+ gr_annotator_1to1.i
endif
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index 68cafce2e..0dce5f68d 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -141,6 +141,8 @@
#include <gr_copy.h>
#include <gr_fll_band_edge_cc.h>
#include <gr_additive_scrambler_bb.h>
+#include <gr_annotator_1toall.h>
+#include <gr_annotator_1to1.h>
%}
%include "gr_nop.i"
@@ -262,3 +264,5 @@
%include "gr_copy.i"
%include "gr_fll_band_edge_cc.i"
%include "gr_additive_scrambler_bb.i"
+%include "gr_annotator_1toall.i"
+%include "gr_annotator_1to1.i"
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1toall.cc b/gnuradio-core/src/lib/general/gr_annotator_1toall.cc
new file mode 100644
index 000000000..34574c9e5
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_1toall.cc
@@ -0,0 +1,99 @@
+/* -*- 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_annotator_1toall.h>
+#include <gr_io_signature.h>
+#include <string.h>
+#include <iostream>
+#include <iomanip>
+
+gr_annotator_1toall_sptr
+gr_make_annotator_1toall (size_t sizeof_stream_item)
+{
+ return gnuradio::get_initial_sptr (new gr_annotator_1toall (sizeof_stream_item));
+}
+
+gr_annotator_1toall::gr_annotator_1toall (size_t sizeof_stream_item)
+ : gr_sync_block ("annotator_1toall",
+ gr_make_io_signature (1, 1, sizeof_stream_item),
+ gr_make_io_signature (1, -1, sizeof_stream_item)),
+ d_itemsize(sizeof_stream_item)
+{
+ set_tag_propagation_policy(TPP_ALL_TO_ALL);
+
+ d_tag_counter = 0;
+}
+
+gr_annotator_1toall::~gr_annotator_1toall ()
+{
+ std::cout << d_sout.str();
+}
+
+int
+gr_annotator_1toall::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const float **in = (const float **) &input_items[0];
+ float **out = (float **) &output_items[0];
+
+ std::stringstream str;
+ str << name() << unique_id();
+
+ uint64_t abs_N = nitems_read(0) + noutput_items;
+ std::vector<pmt::pmt_t> all_tags = get_tags_in_range(0, (uint64_t)0, abs_N);
+ std::vector<pmt::pmt_t>::iterator itr;
+
+ d_sout << std::endl << "Found " << all_tags.size() << " tags." << std::endl;
+ d_sout.setf(std::ios::left);
+ d_sout << std::setw(25) << "Receiver" << std::setw(25) << "Sender"
+ << std::setw(10) << "nitem" << std::setw(20) << "key"
+ << std::setw(10) << "value" << std::endl;
+
+ for(itr = all_tags.begin(); itr != all_tags.end(); itr++) {
+ d_sout << std::setw(25) << str.str()
+ << std::setw(25) << pmt::pmt_tuple_ref(*itr, 1)
+ << std::setw(10) << pmt::pmt_tuple_ref(*itr, 0)
+ << std::setw(20) << pmt::pmt_tuple_ref(*itr, 2)
+ << std::setw(10) << pmt::pmt_tuple_ref(*itr, 3)
+ << std::endl;
+ }
+
+
+ // Storing the current noutput_items as the value to the "noutput_items" key
+ pmt::pmt_t cur_N = pmt::pmt_from_uint64(d_tag_counter++);
+ pmt::pmt_t srcid = pmt::pmt_string_to_symbol(str.str());
+ pmt::pmt_t key = pmt::pmt_string_to_symbol("seq");
+
+ // Work does nothing to the data stream; just copy all inputs to outputs
+ int noutputs = output_items.size();
+ for (int i = 0; i < noutputs; i++) {
+ memcpy(out[i], in[0], noutput_items * d_itemsize);
+ add_item_tag(i, abs_N, key, cur_N, srcid);
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1toall.h b/gnuradio-core/src/lib/general/gr_annotator_1toall.h
new file mode 100644
index 000000000..4417e8c54
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_1toall.h
@@ -0,0 +1,55 @@
+/* -*- 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_ANNOTATOR_1TOALL_H
+#define INCLUDED_GR_ANNOTATOR_1TOALL_H
+
+#include <gr_sync_block.h>
+
+class gr_annotator_1toall;
+typedef boost::shared_ptr<gr_annotator_1toall> gr_annotator_1toall_sptr;
+
+// public constructor
+gr_annotator_1toall_sptr
+gr_make_annotator_1toall (size_t sizeof_stream_item);
+
+class gr_annotator_1toall : public gr_sync_block
+{
+ public:
+ ~gr_annotator_1toall ();
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+protected:
+ gr_annotator_1toall (size_t sizeof_stream_item);
+
+ private:
+ size_t d_itemsize;
+ std::stringstream d_sout;
+ uint64_t d_tag_counter;
+
+ friend gr_annotator_1toall_sptr
+ gr_make_annotator_1toall (size_t sizeof_stream_item);
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1toall.i b/gnuradio-core/src/lib/general/gr_annotator_1toall.i
new file mode 100644
index 000000000..a8f1de3e0
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_1toall.i
@@ -0,0 +1,32 @@
+/* -*- 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,annotator_1toall);
+
+gr_annotator_1toall_sptr gr_make_annotator_1toall (size_t sizeof_stream_item);
+
+class gr_annotator_1toall : public gr_sync_block
+{
+private:
+ gr_annotator_1toall (size_t sizeof_stream_item);
+};
+