summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_1to1.cc101
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_1to1.h55
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_1to1.i32
-rw-r--r--gnuradio-core/src/lib/runtime/qa_block_tags.cc5
4 files changed, 191 insertions, 2 deletions
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc
new file mode 100644
index 000000000..315285e41
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc
@@ -0,0 +1,101 @@
+/* -*- 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_1to1.h>
+#include <gr_io_signature.h>
+#include <string.h>
+#include <iostream>
+#include <iomanip>
+
+gr_annotator_1to1_sptr
+gr_make_annotator_1to1 (size_t sizeof_stream_item)
+{
+ return gnuradio::get_initial_sptr (new gr_annotator_1to1 (sizeof_stream_item));
+}
+
+gr_annotator_1to1::gr_annotator_1to1 (size_t sizeof_stream_item)
+ : gr_sync_block ("annotator_1to1",
+ 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_ONE_TO_ONE);
+
+ d_tag_counter = 0;
+}
+
+gr_annotator_1to1::~gr_annotator_1to1 ()
+{
+ std::cout << d_sout.str();
+}
+
+int
+gr_annotator_1to1::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 srcid = pmt::pmt_string_to_symbol(str.str());
+ pmt::pmt_t key = pmt::pmt_string_to_symbol("seq");
+ pmt::pmt_t value;
+
+ // Work does nothing to the data stream; just copy all inputs to outputs
+ int noutputs = output_items.size();
+ int ninputs = input_items.size();
+ for (int i = 0; i < noutputs; i++) {
+ value = pmt::pmt_from_uint64(d_tag_counter++);
+ memcpy(out[i], in[i], noutput_items * d_itemsize);
+ add_item_tag(i, abs_N, key, value, srcid);
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.h b/gnuradio-core/src/lib/general/gr_annotator_1to1.h
new file mode 100644
index 000000000..d40135be7
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.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_1TO1_H
+#define INCLUDED_GR_ANNOTATOR_1TO1_H
+
+#include <gr_sync_block.h>
+
+class gr_annotator_1to1;
+typedef boost::shared_ptr<gr_annotator_1to1> gr_annotator_1to1_sptr;
+
+// public constructor
+gr_annotator_1to1_sptr
+gr_make_annotator_1to1 (size_t sizeof_stream_item);
+
+class gr_annotator_1to1 : public gr_sync_block
+{
+ public:
+ ~gr_annotator_1to1 ();
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+protected:
+ gr_annotator_1to1 (size_t sizeof_stream_item);
+
+ private:
+ size_t d_itemsize;
+ std::stringstream d_sout;
+ uint64_t d_tag_counter;
+
+ friend gr_annotator_1to1_sptr
+ gr_make_annotator_1to1 (size_t sizeof_stream_item);
+};
+
+#endif
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.i b/gnuradio-core/src/lib/general/gr_annotator_1to1.i
new file mode 100644
index 000000000..9fba558b7
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.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_1to1);
+
+gr_annotator_1to1_sptr gr_make_annotator_1to1 (size_t sizeof_stream_item);
+
+class gr_annotator_1to1 : public gr_sync_block
+{
+private:
+ gr_annotator_1to1 (size_t sizeof_stream_item);
+};
+
diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc
index a845f70dc..0c96052e3 100644
--- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc
+++ b/gnuradio-core/src/lib/runtime/qa_block_tags.cc
@@ -89,8 +89,9 @@ qa_block_tags::t1 ()
tb->connect(ann1, 0, ann3, 0);
tb->connect(ann2, 0, ann4, 0);
- tb->connect(ann1, 0, snk0, 0);
- tb->connect(ann2, 0, snk1, 0);
+ tb->connect(ann3, 0, snk0, 0);
+ tb->connect(ann4, 0, snk1, 0);
+
tb->run();
}