From d46b800b882724c07975f1dc897f8166d45150fb Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 8 Nov 2010 00:47:10 -0500 Subject: Fixing signed/unsigned warnings. --- gnuradio-core/src/lib/general/gr_float_to_complex.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_float_to_complex.cc b/gnuradio-core/src/lib/general/gr_float_to_complex.cc index 89ef18869..a392abd06 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_complex.cc @@ -52,12 +52,12 @@ gr_float_to_complex::work (int noutput_items, switch (input_items.size ()){ case 1: - for (int j = 0; j < noutput_items*d_vlen; j++) + for (size_t j = 0; j < noutput_items*d_vlen; j++) out[j] = gr_complex (r[j], 0); break; case 2: - for (int j = 0; j < noutput_items*d_vlen; j++) + for (size_t j = 0; j < noutput_items*d_vlen; j++) out[j] = gr_complex (r[j], i[j]); break; -- cgit From 9eeb6dbaa1398946229db780f2eb1ca4e9eae04b Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 8 Nov 2010 01:44:16 -0500 Subject: Adding a bit more checking on file operations. --- gnuradio-core/src/lib/general/gr_circular_file.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_circular_file.cc b/gnuradio-core/src/lib/general/gr_circular_file.cc index 468b49a10..c9222597a 100644 --- a/gnuradio-core/src/lib/general/gr_circular_file.cc +++ b/gnuradio-core/src/lib/general/gr_circular_file.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -66,7 +66,10 @@ gr_circular_file::gr_circular_file (const char *filename, exit (1); } #ifdef HAVE_MMAP /* FIXME */ - ftruncate (d_fd, size + HEADER_SIZE); + if(ftruncate (d_fd, size + HEADER_SIZE) != 0) { + perror (filename); + exit (1); + } #endif } else { -- cgit From 9aaf98cff5e03ec2821da492f3857780a767258f Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 11 Nov 2010 15:55:04 -0500 Subject: Renaming random_annotator to annotator_1toall that moves tags from single input to all outputs. --- gnuradio-core/src/lib/general/Makefile.am | 11 ++- gnuradio-core/src/lib/general/general.i | 4 + .../src/lib/general/gr_annotator_1toall.cc | 99 ++++++++++++++++++++++ .../src/lib/general/gr_annotator_1toall.h | 55 ++++++++++++ .../src/lib/general/gr_annotator_1toall.i | 32 +++++++ 5 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 gnuradio-core/src/lib/general/gr_annotator_1toall.cc create mode 100644 gnuradio-core/src/lib/general/gr_annotator_1toall.h create mode 100644 gnuradio-core/src/lib/general/gr_annotator_1toall.i (limited to 'gnuradio-core/src/lib/general') 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 #include #include +#include +#include %} %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 +#include +#include +#include +#include + +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 all_tags = get_tags_in_range(0, (uint64_t)0, abs_N); + std::vector::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 + +class gr_annotator_1toall; +typedef boost::shared_ptr 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); +}; + -- cgit From 0952d5a28a898309f3b7a11a27fff27b52731b53 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 11 Nov 2010 15:55:58 -0500 Subject: Adding an annotator block that moves tags using 1-to-1 policy. --- gnuradio-core/src/lib/general/gr_annotator_1to1.cc | 101 +++++++++++++++++++++ gnuradio-core/src/lib/general/gr_annotator_1to1.h | 55 +++++++++++ gnuradio-core/src/lib/general/gr_annotator_1to1.i | 32 +++++++ 3 files changed, 188 insertions(+) create mode 100644 gnuradio-core/src/lib/general/gr_annotator_1to1.cc create mode 100644 gnuradio-core/src/lib/general/gr_annotator_1to1.h create mode 100644 gnuradio-core/src/lib/general/gr_annotator_1to1.i (limited to 'gnuradio-core/src/lib/general') 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 +#include +#include +#include +#include + +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 all_tags = get_tags_in_range(0, (uint64_t)0, abs_N); + std::vector::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 + +class gr_annotator_1to1; +typedef boost::shared_ptr 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); +}; + -- cgit From 3f6ebc2be1636a4727b6df9f336b3cb024031c67 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 11 Nov 2010 19:40:06 -0500 Subject: Modifying the all-to-all stream annotator for better use in testing. It now add tags at pre-determined points in the stream and also grabs all tags that flow past and stores them locally. These tags are to be used for testing that the correct tags are coming through. --- .../src/lib/general/gr_annotator_1toall.cc | 66 +++++++++++----------- .../src/lib/general/gr_annotator_1toall.h | 42 +++++++++++--- .../src/lib/general/gr_annotator_1toall.i | 11 +++- 3 files changed, 74 insertions(+), 45 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_annotator_1toall.cc b/gnuradio-core/src/lib/general/gr_annotator_1toall.cc index 34574c9e5..1410b8b94 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1toall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1toall.cc @@ -31,69 +31,69 @@ #include gr_annotator_1toall_sptr -gr_make_annotator_1toall (size_t sizeof_stream_item) +gr_make_annotator_1toall (size_t sizeof_stream_item, float rel_rate) { - return gnuradio::get_initial_sptr (new gr_annotator_1toall (sizeof_stream_item)); + return gnuradio::get_initial_sptr (new gr_annotator_1toall (sizeof_stream_item, rel_rate)); } -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) +gr_annotator_1toall::gr_annotator_1toall (size_t sizeof_stream_item, float rel_rate) + : gr_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), d_rel_rate(rel_rate) { set_tag_propagation_policy(TPP_ALL_TO_ALL); d_tag_counter = 0; + set_relative_rate(d_rel_rate); } 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) +gr_annotator_1toall::general_work (int noutput_items, + gr_vector_int &ninput_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]; + 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 all_tags = get_tags_in_range(0, (uint64_t)0, abs_N); + uint64_t abs_N = nitems_read(0); + std::vector all_tags = get_tags_in_range(0, abs_N, abs_N + noutput_items); std::vector::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; + d_stored_tags.push_back(*itr); } - - // 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++); + // Source ID and key for any tag that might get applied from this block 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 + // Adds a new tag when the number of items read is a multiple of N + uint64_t N = 10000; 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); + for(int j = 0; j < noutput_items; j++) { + abs_N++; + + for(int i = 0; i < noutputs; i++) { + if(abs_N % N == 0) { + pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); + add_item_tag(i, abs_N, key, value, srcid); + } + + out = (float*)output_items[i]; + out[j] = in[j]; + } } + consume_each(noutput_items); 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 index 4417e8c54..e118fd7a0 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1toall.h +++ b/gnuradio-core/src/lib/general/gr_annotator_1toall.h @@ -23,33 +23,57 @@ #ifndef INCLUDED_GR_ANNOTATOR_1TOALL_H #define INCLUDED_GR_ANNOTATOR_1TOALL_H -#include +#include class gr_annotator_1toall; typedef boost::shared_ptr gr_annotator_1toall_sptr; // public constructor gr_annotator_1toall_sptr -gr_make_annotator_1toall (size_t sizeof_stream_item); +gr_make_annotator_1toall (size_t sizeof_stream_item, float rel_rate=1.0); -class gr_annotator_1toall : public gr_sync_block +/*! + * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY. + * + * This block creates tags to be sent downstream every 10,000 items it sees. The + * tags contain the name and ID of the instantiated block, use "seq" as a key, + * and have a counter that increments by 1 for every tag produced that is used + * as the tag's value. The tags are propagated using the all-to-all policy. + * + * It also stores a copy of all tags it sees flow past it. These tags can be + * recalled externally with the data() member. + * + * This block is only meant for testing and showing how to use the tags. + */ +class gr_annotator_1toall : public gr_block { public: ~gr_annotator_1toall (); - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + void set_rel_rate(float rrate) { d_rel_rate = rrate; set_relative_rate(d_rel_rate); } + float rel_rate() { return d_rel_rate; } + + + std::vector data() const + { + return d_stored_tags; + } protected: - gr_annotator_1toall (size_t sizeof_stream_item); + gr_annotator_1toall (size_t sizeof_stream_item, float rel_rate); private: size_t d_itemsize; - std::stringstream d_sout; + float d_rel_rate; uint64_t d_tag_counter; + std::vector d_stored_tags; friend gr_annotator_1toall_sptr - gr_make_annotator_1toall (size_t sizeof_stream_item); + gr_make_annotator_1toall (size_t sizeof_stream_item, float rel_rate); }; #endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_1toall.i b/gnuradio-core/src/lib/general/gr_annotator_1toall.i index a8f1de3e0..02f79bf7e 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1toall.i +++ b/gnuradio-core/src/lib/general/gr_annotator_1toall.i @@ -22,11 +22,16 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_1toall); -gr_annotator_1toall_sptr gr_make_annotator_1toall (size_t sizeof_stream_item); +gr_annotator_1toall_sptr gr_make_annotator_1toall (size_t sizeof_stream_item, float rel_rate); -class gr_annotator_1toall : public gr_sync_block +class gr_annotator_1toall : public gr_block { +public: + void set_rel_rate(float rrate) { d_rel_rate = rrate; set_relative_rate(d_rel_rate); } + float rel_rate() { return d_rel_rate; } + std::vector data() const; + private: - gr_annotator_1toall (size_t sizeof_stream_item); + gr_annotator_1toall (size_t sizeof_stream_item, float rel_rate); }; -- cgit From 4a63bc91ddceaa8ce9d14a3f714bd0cdc3e85128 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 11 Nov 2010 20:04:44 -0500 Subject: Reworked 1-to-1 annotator block to better testing purposes. --- gnuradio-core/src/lib/general/gr_annotator_1to1.cc | 69 +++++++++++----------- gnuradio-core/src/lib/general/gr_annotator_1to1.h | 42 ++++++++++--- gnuradio-core/src/lib/general/gr_annotator_1to1.i | 11 +++- .../src/lib/general/gr_annotator_1toall.cc | 2 +- .../src/lib/general/gr_annotator_1toall.i | 4 +- 5 files changed, 78 insertions(+), 50 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index 315285e41..7ecadcd2c 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -31,71 +31,70 @@ #include gr_annotator_1to1_sptr -gr_make_annotator_1to1 (size_t sizeof_stream_item) +gr_make_annotator_1to1 (size_t sizeof_stream_item, float rel_rate) { - return gnuradio::get_initial_sptr (new gr_annotator_1to1 (sizeof_stream_item)); + return gnuradio::get_initial_sptr (new gr_annotator_1to1 (sizeof_stream_item, rel_rate)); } -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) +gr_annotator_1to1::gr_annotator_1to1 (size_t sizeof_stream_item, float rel_rate) + : gr_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), d_rel_rate(rel_rate) { set_tag_propagation_policy(TPP_ONE_TO_ONE); d_tag_counter = 0; + set_relative_rate(d_rel_rate); } 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) +gr_annotator_1to1::general_work (int noutput_items, + gr_vector_int &ninput_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]; + 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 all_tags = get_tags_in_range(0, (uint64_t)0, abs_N); - std::vector::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; + uint64_t abs_N = nitems_read(0); + std::vector all_tags = get_tags_in_range(0, abs_N, abs_N + noutput_items); + std::vector::iterator itr; 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; + d_stored_tags.push_back(*itr); } - // 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 + // Adds a new tag when the number of items read is a multiple of N + uint64_t N = 10000; 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); + for(int j = 0; j < noutput_items; j++) { + abs_N++; + + for(int i = 0; i < noutputs; i++) { + if(abs_N % N == 0) { + pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); + add_item_tag(i, abs_N, key, value, srcid); + } + + in = (const float*)input_items[i]; + out = (float*)output_items[i]; + out[j] = in[j]; + } } + consume_each(noutput_items); 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 index d40135be7..99a4e98c7 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.h +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.h @@ -23,33 +23,57 @@ #ifndef INCLUDED_GR_ANNOTATOR_1TO1_H #define INCLUDED_GR_ANNOTATOR_1TO1_H -#include +#include class gr_annotator_1to1; typedef boost::shared_ptr gr_annotator_1to1_sptr; // public constructor gr_annotator_1to1_sptr -gr_make_annotator_1to1 (size_t sizeof_stream_item); +gr_make_annotator_1to1 (size_t sizeof_stream_item, float rel_rate=1.0); -class gr_annotator_1to1 : public gr_sync_block +/*! + * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY. + * + * This block creates tags to be sent downstream every 10,000 items it sees. The + * tags contain the name and ID of the instantiated block, use "seq" as a key, + * and have a counter that increments by 1 for every tag produced that is used + * as the tag's value. The tags are propagated using the 1-to-1 policy. + * + * It also stores a copy of all tags it sees flow past it. These tags can be + * recalled externally with the data() member. + * + * This block is only meant for testing and showing how to use the tags. + */ +class gr_annotator_1to1 : public gr_block { public: ~gr_annotator_1to1 (); - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + void set_rel_rate(float rrate) { d_rel_rate = rrate; set_relative_rate(d_rel_rate); } + float rel_rate() { return d_rel_rate; } + + + std::vector data() const + { + return d_stored_tags; + } protected: - gr_annotator_1to1 (size_t sizeof_stream_item); + gr_annotator_1to1 (size_t sizeof_stream_item, float rel_rate); private: size_t d_itemsize; - std::stringstream d_sout; + float d_rel_rate; uint64_t d_tag_counter; + std::vector d_stored_tags; friend gr_annotator_1to1_sptr - gr_make_annotator_1to1 (size_t sizeof_stream_item); + gr_make_annotator_1to1 (size_t sizeof_stream_item, float rel_rate); }; #endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.i b/gnuradio-core/src/lib/general/gr_annotator_1to1.i index 9fba558b7..f2342af55 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.i +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.i @@ -22,11 +22,16 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_1to1); -gr_annotator_1to1_sptr gr_make_annotator_1to1 (size_t sizeof_stream_item); +gr_annotator_1to1_sptr gr_make_annotator_1to1 (size_t sizeof_stream_item, float rel_rate); -class gr_annotator_1to1 : public gr_sync_block +class gr_annotator_1to1 : public gr_block { +public: + void set_rel_rate(float rrate); + float rel_rate(); + std::vector data() const; + private: - gr_annotator_1to1 (size_t sizeof_stream_item); + gr_annotator_1to1 (size_t sizeof_stream_item, float rel_rate); }; diff --git a/gnuradio-core/src/lib/general/gr_annotator_1toall.cc b/gnuradio-core/src/lib/general/gr_annotator_1toall.cc index 1410b8b94..47002e3c9 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1toall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1toall.cc @@ -66,8 +66,8 @@ gr_annotator_1toall::general_work (int noutput_items, uint64_t abs_N = nitems_read(0); std::vector all_tags = get_tags_in_range(0, abs_N, abs_N + noutput_items); - std::vector::iterator itr; + std::vector::iterator itr; for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { d_stored_tags.push_back(*itr); } diff --git a/gnuradio-core/src/lib/general/gr_annotator_1toall.i b/gnuradio-core/src/lib/general/gr_annotator_1toall.i index 02f79bf7e..a6bd01017 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1toall.i +++ b/gnuradio-core/src/lib/general/gr_annotator_1toall.i @@ -27,8 +27,8 @@ gr_annotator_1toall_sptr gr_make_annotator_1toall (size_t sizeof_stream_item, fl class gr_annotator_1toall : public gr_block { public: - void set_rel_rate(float rrate) { d_rel_rate = rrate; set_relative_rate(d_rel_rate); } - float rel_rate() { return d_rel_rate; } + void set_rel_rate(float rrate); + float rel_rate(); std::vector data() const; private: -- cgit From 7ca96ad8b48b3426b470e87042c8e982664f3b9b Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 13 Nov 2010 14:26:39 -0500 Subject: Renamed annotator block that goes all-to-all now so that it can take in arbitrary number of inputs and pass tags on that way. --- gnuradio-core/src/lib/general/Makefile.am | 7 +- gnuradio-core/src/lib/general/general.i | 4 +- .../src/lib/general/gr_annotator_alltoall.cc | 108 +++++++++++++++++++++ .../src/lib/general/gr_annotator_alltoall.h | 79 +++++++++++++++ .../src/lib/general/gr_annotator_alltoall.i | 38 ++++++++ 5 files changed, 231 insertions(+), 5 deletions(-) create mode 100644 gnuradio-core/src/lib/general/gr_annotator_alltoall.cc create mode 100644 gnuradio-core/src/lib/general/gr_annotator_alltoall.h create mode 100644 gnuradio-core/src/lib/general/gr_annotator_alltoall.i (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index a58461165..2e52d88f3 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -176,7 +176,7 @@ libgeneral_la_SOURCES = \ gr_scrambler_bb.cc \ gr_probe_mpsk_snr_c.cc \ gr_probe_density_b.cc \ - gr_annotator_1toall.cc \ + gr_annotator_alltoall.cc \ gr_annotator_1to1.cc libgeneral_qa_la_SOURCES = \ @@ -347,7 +347,8 @@ grinclude_HEADERS = \ gr_scrambler_bb.h \ gr_probe_mpsk_snr_c.h \ gr_probe_density_b.h \ - gr_annotator_1toall.h + gr_annotator_alltoall.h \ + gr_annotator_1to1.h noinst_HEADERS = \ qa_general.h \ @@ -488,6 +489,6 @@ swiginclude_HEADERS = \ gr_scrambler_bb.i \ gr_probe_mpsk_snr_c.i \ gr_probe_density_b.i \ - gr_annotator_1toall.i \ + gr_annotator_alltoall.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 0dce5f68d..400f0b9b6 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -141,7 +141,7 @@ #include #include #include -#include +#include #include %} @@ -264,5 +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_alltoall.i" %include "gr_annotator_1to1.i" diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc new file mode 100644 index 000000000..f1fb8bc31 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc @@ -0,0 +1,108 @@ +/* -*- 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 +#include +#include +#include +#include + +gr_annotator_alltoall_sptr +gr_make_annotator_alltoall (size_t sizeof_stream_item, float rel_rate) +{ + return gnuradio::get_initial_sptr (new gr_annotator_alltoall (sizeof_stream_item, rel_rate)); +} + +gr_annotator_alltoall::gr_annotator_alltoall (size_t sizeof_stream_item, float rel_rate) + : gr_block ("annotator_alltoall", + gr_make_io_signature (1, -1, sizeof_stream_item), + gr_make_io_signature (1, -1, sizeof_stream_item)), + d_itemsize(sizeof_stream_item), d_rel_rate(rel_rate) +{ + set_tag_propagation_policy(TPP_ALL_TO_ALL); + + d_tag_counter = 0; + set_relative_rate(d_rel_rate); +} + +gr_annotator_alltoall::~gr_annotator_alltoall () +{ +} + +int +gr_annotator_alltoall::general_work (int noutput_items, + gr_vector_int &ninput_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 = 0; + int ninputs = input_items.size(); + for(int i = 0; i < ninputs; i++) { + abs_N = nitems_read(i); + std::vector all_tags = get_tags_in_range(i, abs_N, abs_N + noutput_items); + + std::vector::iterator itr; + for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { + d_stored_tags.push_back(*itr); + } + } + + // Source ID and key for any tag that might get applied from this block + 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 + // Adds a new tag when the number of items read is a multiple of N + uint64_t N = 10000; + int noutputs = output_items.size(); + for(int j = 0; j < noutput_items; j++) { + abs_N++; + + for(int i = 0; i < noutputs; i++) { + if(abs_N % N == 0) { + pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); + add_item_tag(i, abs_N, key, value, srcid); + } + + // Sum all of the inputs together for each output. Just 'cause. + out = (float*)output_items[i]; + out[j] = 0; + for(int ins = 0; ins < ninputs; ins++) { + in = (const float*)input_items[ins]; + out[j] += in[j]; + } + } + } + + consume_each(noutput_items); + return noutput_items; +} diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h new file mode 100644 index 000000000..30480e1ef --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h @@ -0,0 +1,79 @@ +/* -*- 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_ALLTOALL_H +#define INCLUDED_GR_ANNOTATOR_ALLTOALL_H + +#include + +class gr_annotator_alltoall; +typedef boost::shared_ptr gr_annotator_alltoall_sptr; + +// public constructor +gr_annotator_alltoall_sptr +gr_make_annotator_alltoall (size_t sizeof_stream_item, float rel_rate=1.0); + +/*! + * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY. + * + * This block creates tags to be sent downstream every 10,000 items it sees. The + * tags contain the name and ID of the instantiated block, use "seq" as a key, + * and have a counter that increments by 1 for every tag produced that is used + * as the tag's value. The tags are propagated using the all-to-all policy. + * + * It also stores a copy of all tags it sees flow past it. These tags can be + * recalled externally with the data() member. + * + * This block is only meant for testing and showing how to use the tags. + */ +class gr_annotator_alltoall : public gr_block +{ + public: + ~gr_annotator_alltoall (); + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + void set_rel_rate(float rrate) { d_rel_rate = rrate; set_relative_rate(d_rel_rate); } + float rel_rate() { return d_rel_rate; } + + + std::vector data() const + { + return d_stored_tags; + } + +protected: + gr_annotator_alltoall (size_t sizeof_stream_item, float rel_rate); + + private: + size_t d_itemsize; + float d_rel_rate; + uint64_t d_tag_counter; + std::vector d_stored_tags; + + friend gr_annotator_alltoall_sptr + gr_make_annotator_alltoall (size_t sizeof_stream_item, float rel_rate); +}; + +#endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i new file mode 100644 index 000000000..e7ae0b204 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i @@ -0,0 +1,38 @@ +/* -*- 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_alltoall); + +gr_annotator_alltoall_sptr gr_make_annotator_alltoall (size_t sizeof_stream_item, + float rel_rate); + +class gr_annotator_alltoall : public gr_block +{ +public: + void set_rel_rate(float rrate); + float rel_rate(); + std::vector data() const; + +private: + gr_annotator_alltoall (size_t sizeof_stream_item, float rel_rate); +}; + -- cgit From 74d17ff495c97fbb9eb3bd3cacf08a8dcdf677b6 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 13 Nov 2010 14:27:54 -0500 Subject: Fixing how 1-to-1 annotator handles inputs to better test propagataion method. --- gnuradio-core/src/lib/general/gr_annotator_1to1.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index 7ecadcd2c..273f684ed 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -64,12 +64,16 @@ gr_annotator_1to1::general_work (int noutput_items, std::stringstream str; str << name() << unique_id(); - uint64_t abs_N = nitems_read(0); - std::vector all_tags = get_tags_in_range(0, abs_N, abs_N + noutput_items); + uint64_t abs_N = 0; + int ninputs = ninput_items.size(); + for(int i = 0; i < ninputs; i++) { + abs_N = nitems_read(i); + std::vector all_tags = get_tags_in_range(i, abs_N, abs_N + noutput_items); - std::vector::iterator itr; - for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { - d_stored_tags.push_back(*itr); + std::vector::iterator itr; + for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { + d_stored_tags.push_back(*itr); + } } // Storing the current noutput_items as the value to the "noutput_items" key @@ -78,12 +82,16 @@ gr_annotator_1to1::general_work (int noutput_items, // Work does nothing to the data stream; just copy all inputs to outputs // Adds a new tag when the number of items read is a multiple of N + abs_N = nitems_read(0); uint64_t N = 10000; int noutputs = output_items.size(); for(int j = 0; j < noutput_items; j++) { abs_N++; - for(int i = 0; i < noutputs; i++) { + // the min() is a hack to make sure this doesn't segfault if there are a + // different number of ins and outs. This is specifically designed to test + // the 1-to-1 propagation policy. + for(int i = 0; i < std::min(noutputs, ninputs); i++) { if(abs_N % N == 0) { pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); add_item_tag(i, abs_N, key, value, srcid); -- cgit From 77d778896b72379676d2b00e591f9bbb5f6fcc44 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sat, 13 Nov 2010 14:29:11 -0500 Subject: More test methods. Better testing of the all-to-all policy and more tests for the 1-to-1. --- .../src/lib/general/gr_annotator_1toall.cc | 99 ---------------------- .../src/lib/general/gr_annotator_1toall.h | 79 ----------------- .../src/lib/general/gr_annotator_1toall.i | 37 -------- 3 files changed, 215 deletions(-) delete mode 100644 gnuradio-core/src/lib/general/gr_annotator_1toall.cc delete mode 100644 gnuradio-core/src/lib/general/gr_annotator_1toall.h delete mode 100644 gnuradio-core/src/lib/general/gr_annotator_1toall.i (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_annotator_1toall.cc b/gnuradio-core/src/lib/general/gr_annotator_1toall.cc deleted file mode 100644 index 47002e3c9..000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1toall.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- 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 -#include -#include -#include -#include - -gr_annotator_1toall_sptr -gr_make_annotator_1toall (size_t sizeof_stream_item, float rel_rate) -{ - return gnuradio::get_initial_sptr (new gr_annotator_1toall (sizeof_stream_item, rel_rate)); -} - -gr_annotator_1toall::gr_annotator_1toall (size_t sizeof_stream_item, float rel_rate) - : gr_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), d_rel_rate(rel_rate) -{ - set_tag_propagation_policy(TPP_ALL_TO_ALL); - - d_tag_counter = 0; - set_relative_rate(d_rel_rate); -} - -gr_annotator_1toall::~gr_annotator_1toall () -{ -} - -int -gr_annotator_1toall::general_work (int noutput_items, - gr_vector_int &ninput_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); - std::vector all_tags = get_tags_in_range(0, abs_N, abs_N + noutput_items); - - std::vector::iterator itr; - for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { - d_stored_tags.push_back(*itr); - } - - // Source ID and key for any tag that might get applied from this block - 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 - // Adds a new tag when the number of items read is a multiple of N - uint64_t N = 10000; - int noutputs = output_items.size(); - for(int j = 0; j < noutput_items; j++) { - abs_N++; - - for(int i = 0; i < noutputs; i++) { - if(abs_N % N == 0) { - pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); - add_item_tag(i, abs_N, key, value, srcid); - } - - out = (float*)output_items[i]; - out[j] = in[j]; - } - } - - consume_each(noutput_items); - 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 deleted file mode 100644 index e118fd7a0..000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1toall.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- 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 - -class gr_annotator_1toall; -typedef boost::shared_ptr gr_annotator_1toall_sptr; - -// public constructor -gr_annotator_1toall_sptr -gr_make_annotator_1toall (size_t sizeof_stream_item, float rel_rate=1.0); - -/*! - * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY. - * - * This block creates tags to be sent downstream every 10,000 items it sees. The - * tags contain the name and ID of the instantiated block, use "seq" as a key, - * and have a counter that increments by 1 for every tag produced that is used - * as the tag's value. The tags are propagated using the all-to-all policy. - * - * It also stores a copy of all tags it sees flow past it. These tags can be - * recalled externally with the data() member. - * - * This block is only meant for testing and showing how to use the tags. - */ -class gr_annotator_1toall : public gr_block -{ - public: - ~gr_annotator_1toall (); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_rel_rate(float rrate) { d_rel_rate = rrate; set_relative_rate(d_rel_rate); } - float rel_rate() { return d_rel_rate; } - - - std::vector data() const - { - return d_stored_tags; - } - -protected: - gr_annotator_1toall (size_t sizeof_stream_item, float rel_rate); - - private: - size_t d_itemsize; - float d_rel_rate; - uint64_t d_tag_counter; - std::vector d_stored_tags; - - friend gr_annotator_1toall_sptr - gr_make_annotator_1toall (size_t sizeof_stream_item, float rel_rate); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_1toall.i b/gnuradio-core/src/lib/general/gr_annotator_1toall.i deleted file mode 100644 index a6bd01017..000000000 --- a/gnuradio-core/src/lib/general/gr_annotator_1toall.i +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- 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, float rel_rate); - -class gr_annotator_1toall : public gr_block -{ -public: - void set_rel_rate(float rrate); - float rel_rate(); - std::vector data() const; - -private: - gr_annotator_1toall (size_t sizeof_stream_item, float rel_rate); -}; - -- cgit From 222c6c5be69575c00d6396b95d523e0dfa19f2c3 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 14 Nov 2010 00:04:11 -0500 Subject: Fixing some bugs. --- gnuradio-core/src/lib/general/gr_annotator_1to1.cc | 3 +-- gnuradio-core/src/lib/general/gr_annotator_alltoall.cc | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index 273f684ed..8b1da5778 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -86,8 +86,6 @@ gr_annotator_1to1::general_work (int noutput_items, uint64_t N = 10000; int noutputs = output_items.size(); for(int j = 0; j < noutput_items; j++) { - abs_N++; - // the min() is a hack to make sure this doesn't segfault if there are a // different number of ins and outs. This is specifically designed to test // the 1-to-1 propagation policy. @@ -101,6 +99,7 @@ gr_annotator_1to1::general_work (int noutput_items, out = (float*)output_items[i]; out[j] = in[j]; } + abs_N++; } consume_each(noutput_items); diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc index f1fb8bc31..699d5a256 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc @@ -85,8 +85,6 @@ gr_annotator_alltoall::general_work (int noutput_items, uint64_t N = 10000; int noutputs = output_items.size(); for(int j = 0; j < noutput_items; j++) { - abs_N++; - for(int i = 0; i < noutputs; i++) { if(abs_N % N == 0) { pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); @@ -101,6 +99,7 @@ gr_annotator_alltoall::general_work (int noutput_items, out[j] += in[j]; } } + abs_N++; } consume_each(noutput_items); -- cgit From 11b2b7c40048bee5201bd10dd753a9471cd6345d Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 14 Nov 2010 01:20:44 -0500 Subject: Adds argument to annotator test blocks to determine when they add a new tag. --- gnuradio-core/src/lib/general/gr_annotator_1to1.cc | 16 +++++++++------- gnuradio-core/src/lib/general/gr_annotator_1to1.h | 15 +++++++++++---- gnuradio-core/src/lib/general/gr_annotator_1to1.i | 7 +++++-- gnuradio-core/src/lib/general/gr_annotator_alltoall.cc | 17 ++++++++++------- gnuradio-core/src/lib/general/gr_annotator_alltoall.h | 15 +++++++++++---- gnuradio-core/src/lib/general/gr_annotator_alltoall.i | 5 +++-- 6 files changed, 49 insertions(+), 26 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index 8b1da5778..d2d2599d3 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -31,16 +31,19 @@ #include gr_annotator_1to1_sptr -gr_make_annotator_1to1 (size_t sizeof_stream_item, float rel_rate) +gr_make_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, + float rel_rate) { - return gnuradio::get_initial_sptr (new gr_annotator_1to1 (sizeof_stream_item, rel_rate)); + return gnuradio::get_initial_sptr (new gr_annotator_1to1 + (when, sizeof_stream_item, rel_rate)); } -gr_annotator_1to1::gr_annotator_1to1 (size_t sizeof_stream_item, float rel_rate) +gr_annotator_1to1::gr_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, + float rel_rate) : gr_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), d_rel_rate(rel_rate) + d_itemsize(sizeof_stream_item), d_rel_rate(rel_rate), d_when(when) { set_tag_propagation_policy(TPP_ONE_TO_ONE); @@ -81,16 +84,15 @@ gr_annotator_1to1::general_work (int noutput_items, pmt::pmt_t key = pmt::pmt_string_to_symbol("seq"); // Work does nothing to the data stream; just copy all inputs to outputs - // Adds a new tag when the number of items read is a multiple of N + // Adds a new tag when the number of items read is a multiple of d_when abs_N = nitems_read(0); - uint64_t N = 10000; int noutputs = output_items.size(); for(int j = 0; j < noutput_items; j++) { // the min() is a hack to make sure this doesn't segfault if there are a // different number of ins and outs. This is specifically designed to test // the 1-to-1 propagation policy. for(int i = 0; i < std::min(noutputs, ninputs); i++) { - if(abs_N % N == 0) { + if(abs_N % d_when == 0) { pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); add_item_tag(i, abs_N, key, value, srcid); } diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.h b/gnuradio-core/src/lib/general/gr_annotator_1to1.h index 99a4e98c7..ef14f9b52 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.h +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.h @@ -30,7 +30,8 @@ typedef boost::shared_ptr gr_annotator_1to1_sptr; // public constructor gr_annotator_1to1_sptr -gr_make_annotator_1to1 (size_t sizeof_stream_item, float rel_rate=1.0); +gr_make_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, + float rel_rate=1.0); /*! * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY. @@ -54,7 +55,10 @@ class gr_annotator_1to1 : public gr_block gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - void set_rel_rate(float rrate) { d_rel_rate = rrate; set_relative_rate(d_rel_rate); } + void set_rel_rate(float rrate) { + d_rel_rate = rrate; + set_relative_rate(d_rel_rate); + } float rel_rate() { return d_rel_rate; } @@ -64,16 +68,19 @@ class gr_annotator_1to1 : public gr_block } protected: - gr_annotator_1to1 (size_t sizeof_stream_item, float rel_rate); + gr_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, + float rel_rate); private: size_t d_itemsize; float d_rel_rate; + uint64_t d_when; uint64_t d_tag_counter; std::vector d_stored_tags; friend gr_annotator_1to1_sptr - gr_make_annotator_1to1 (size_t sizeof_stream_item, float rel_rate); + gr_make_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, + float rel_rate); }; #endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.i b/gnuradio-core/src/lib/general/gr_annotator_1to1.i index f2342af55..d8f10b44f 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.i +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.i @@ -22,7 +22,9 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_1to1); -gr_annotator_1to1_sptr gr_make_annotator_1to1 (size_t sizeof_stream_item, float rel_rate); +gr_annotator_1to1_sptr gr_make_annotator_1to1 (uint64_t when, + size_t sizeof_stream_item, + float rel_rate); class gr_annotator_1to1 : public gr_block { @@ -32,6 +34,7 @@ public: std::vector data() const; private: - gr_annotator_1to1 (size_t sizeof_stream_item, float rel_rate); + gr_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, + float rel_rate); }; diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc index 699d5a256..88419fe0d 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc @@ -31,16 +31,20 @@ #include gr_annotator_alltoall_sptr -gr_make_annotator_alltoall (size_t sizeof_stream_item, float rel_rate) +gr_make_annotator_alltoall (uint64_t when, size_t sizeof_stream_item, + float rel_rate) { - return gnuradio::get_initial_sptr (new gr_annotator_alltoall (sizeof_stream_item, rel_rate)); + return gnuradio::get_initial_sptr (new gr_annotator_alltoall + (when, sizeof_stream_item, rel_rate)); } -gr_annotator_alltoall::gr_annotator_alltoall (size_t sizeof_stream_item, float rel_rate) +gr_annotator_alltoall::gr_annotator_alltoall (uint64_t when, + size_t sizeof_stream_item, + float rel_rate) : gr_block ("annotator_alltoall", gr_make_io_signature (1, -1, sizeof_stream_item), gr_make_io_signature (1, -1, sizeof_stream_item)), - d_itemsize(sizeof_stream_item), d_rel_rate(rel_rate) + d_itemsize(sizeof_stream_item), d_rel_rate(rel_rate), d_when(when) { set_tag_propagation_policy(TPP_ALL_TO_ALL); @@ -81,12 +85,11 @@ gr_annotator_alltoall::general_work (int noutput_items, pmt::pmt_t key = pmt::pmt_string_to_symbol("seq"); // Work does nothing to the data stream; just copy all inputs to outputs - // Adds a new tag when the number of items read is a multiple of N - uint64_t N = 10000; + // Adds a new tag when the number of items read is a multiple of d_when int noutputs = output_items.size(); for(int j = 0; j < noutput_items; j++) { for(int i = 0; i < noutputs; i++) { - if(abs_N % N == 0) { + if(abs_N % d_when == 0) { pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); add_item_tag(i, abs_N, key, value, srcid); } diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h index 30480e1ef..d6d2f1503 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h @@ -30,7 +30,8 @@ typedef boost::shared_ptr gr_annotator_alltoall_sptr; // public constructor gr_annotator_alltoall_sptr -gr_make_annotator_alltoall (size_t sizeof_stream_item, float rel_rate=1.0); +gr_make_annotator_alltoall (uint64_t when, size_t sizeof_stream_item, + float rel_rate=1.0); /*! * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY. @@ -54,7 +55,10 @@ class gr_annotator_alltoall : public gr_block gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - void set_rel_rate(float rrate) { d_rel_rate = rrate; set_relative_rate(d_rel_rate); } + void set_rel_rate(float rrate) { + d_rel_rate = rrate; + set_relative_rate(d_rel_rate); + } float rel_rate() { return d_rel_rate; } @@ -64,16 +68,19 @@ class gr_annotator_alltoall : public gr_block } protected: - gr_annotator_alltoall (size_t sizeof_stream_item, float rel_rate); + gr_annotator_alltoall (uint64_t when, size_t sizeof_stream_item, + float rel_rate); private: size_t d_itemsize; float d_rel_rate; + uint64_t d_when; uint64_t d_tag_counter; std::vector d_stored_tags; friend gr_annotator_alltoall_sptr - gr_make_annotator_alltoall (size_t sizeof_stream_item, float rel_rate); + gr_make_annotator_alltoall (uint64_t when, size_t sizeof_stream_item, + float rel_rate); }; #endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i index e7ae0b204..c6abb1b5e 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i @@ -22,7 +22,8 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_alltoall); -gr_annotator_alltoall_sptr gr_make_annotator_alltoall (size_t sizeof_stream_item, +gr_annotator_alltoall_sptr gr_make_annotator_alltoall (uint64_t when, + size_t sizeof_stream_item, float rel_rate); class gr_annotator_alltoall : public gr_block @@ -33,6 +34,6 @@ public: std::vector data() const; private: - gr_annotator_alltoall (size_t sizeof_stream_item, float rel_rate); + gr_annotator_alltoall (uint64_t when, size_t sizeof_stream_item, float rel_rate); }; -- cgit From ad1eb7fd03b18b76b0799e6c6f3e1e40ff861742 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 14 Nov 2010 13:42:40 -0500 Subject: Fixing constructor interface to work better through python (int instead of uint64_t). --- gnuradio-core/src/lib/general/gr_annotator_1to1.cc | 6 +++--- gnuradio-core/src/lib/general/gr_annotator_1to1.h | 6 +++--- gnuradio-core/src/lib/general/gr_annotator_1to1.i | 4 ++-- gnuradio-core/src/lib/general/gr_annotator_alltoall.cc | 6 +++--- gnuradio-core/src/lib/general/gr_annotator_alltoall.h | 6 +++--- gnuradio-core/src/lib/general/gr_annotator_alltoall.i | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index d2d2599d3..1a6cadbcf 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -31,19 +31,19 @@ #include gr_annotator_1to1_sptr -gr_make_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, +gr_make_annotator_1to1 (int when, size_t sizeof_stream_item, float rel_rate) { return gnuradio::get_initial_sptr (new gr_annotator_1to1 (when, sizeof_stream_item, rel_rate)); } -gr_annotator_1to1::gr_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, +gr_annotator_1to1::gr_annotator_1to1 (int when, size_t sizeof_stream_item, float rel_rate) : gr_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), d_rel_rate(rel_rate), d_when(when) + d_itemsize(sizeof_stream_item), d_rel_rate(rel_rate), d_when((uint64_t)when) { set_tag_propagation_policy(TPP_ONE_TO_ONE); diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.h b/gnuradio-core/src/lib/general/gr_annotator_1to1.h index ef14f9b52..e9167bf39 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.h +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.h @@ -30,7 +30,7 @@ typedef boost::shared_ptr gr_annotator_1to1_sptr; // public constructor gr_annotator_1to1_sptr -gr_make_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, +gr_make_annotator_1to1 (int when, size_t sizeof_stream_item, float rel_rate=1.0); /*! @@ -68,7 +68,7 @@ class gr_annotator_1to1 : public gr_block } protected: - gr_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, + gr_annotator_1to1 (int when, size_t sizeof_stream_item, float rel_rate); private: @@ -79,7 +79,7 @@ protected: std::vector d_stored_tags; friend gr_annotator_1to1_sptr - gr_make_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, + gr_make_annotator_1to1 (int when, size_t sizeof_stream_item, float rel_rate); }; diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.i b/gnuradio-core/src/lib/general/gr_annotator_1to1.i index d8f10b44f..99ab4788c 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.i +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.i @@ -22,7 +22,7 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_1to1); -gr_annotator_1to1_sptr gr_make_annotator_1to1 (uint64_t when, +gr_annotator_1to1_sptr gr_make_annotator_1to1 (int when, size_t sizeof_stream_item, float rel_rate); @@ -34,7 +34,7 @@ public: std::vector data() const; private: - gr_annotator_1to1 (uint64_t when, size_t sizeof_stream_item, + gr_annotator_1to1 (int when, size_t sizeof_stream_item, float rel_rate); }; diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc index 88419fe0d..e7bf5d007 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc @@ -31,20 +31,20 @@ #include gr_annotator_alltoall_sptr -gr_make_annotator_alltoall (uint64_t when, size_t sizeof_stream_item, +gr_make_annotator_alltoall (int when, size_t sizeof_stream_item, float rel_rate) { return gnuradio::get_initial_sptr (new gr_annotator_alltoall (when, sizeof_stream_item, rel_rate)); } -gr_annotator_alltoall::gr_annotator_alltoall (uint64_t when, +gr_annotator_alltoall::gr_annotator_alltoall (int when, size_t sizeof_stream_item, float rel_rate) : gr_block ("annotator_alltoall", gr_make_io_signature (1, -1, sizeof_stream_item), gr_make_io_signature (1, -1, sizeof_stream_item)), - d_itemsize(sizeof_stream_item), d_rel_rate(rel_rate), d_when(when) + d_itemsize(sizeof_stream_item), d_rel_rate(rel_rate), d_when((uint64_t)when) { set_tag_propagation_policy(TPP_ALL_TO_ALL); diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h index d6d2f1503..38cb53bd6 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h @@ -30,7 +30,7 @@ typedef boost::shared_ptr gr_annotator_alltoall_sptr; // public constructor gr_annotator_alltoall_sptr -gr_make_annotator_alltoall (uint64_t when, size_t sizeof_stream_item, +gr_make_annotator_alltoall (int when, size_t sizeof_stream_item, float rel_rate=1.0); /*! @@ -68,7 +68,7 @@ class gr_annotator_alltoall : public gr_block } protected: - gr_annotator_alltoall (uint64_t when, size_t sizeof_stream_item, + gr_annotator_alltoall (int when, size_t sizeof_stream_item, float rel_rate); private: @@ -79,7 +79,7 @@ protected: std::vector d_stored_tags; friend gr_annotator_alltoall_sptr - gr_make_annotator_alltoall (uint64_t when, size_t sizeof_stream_item, + gr_make_annotator_alltoall (int when, size_t sizeof_stream_item, float rel_rate); }; diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i index c6abb1b5e..7812e80c5 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i @@ -22,7 +22,7 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_alltoall); -gr_annotator_alltoall_sptr gr_make_annotator_alltoall (uint64_t when, +gr_annotator_alltoall_sptr gr_make_annotator_alltoall (int when, size_t sizeof_stream_item, float rel_rate); @@ -34,6 +34,6 @@ public: std::vector data() const; private: - gr_annotator_alltoall (uint64_t when, size_t sizeof_stream_item, float rel_rate); + gr_annotator_alltoall (int when, size_t sizeof_stream_item, float rel_rate); }; -- cgit From 68b06ac6ab9571ac266b663b7f9ab173cf68941e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 16 Nov 2010 15:01:44 -0800 Subject: Reverting to a sync_block for the annotator functions. Testing different rates can be done using decimating/interpolating fir filters. --- gnuradio-core/src/lib/general/gr_annotator_1to1.cc | 28 ++++++++----------- gnuradio-core/src/lib/general/gr_annotator_1to1.h | 28 ++++++------------- gnuradio-core/src/lib/general/gr_annotator_1to1.i | 10 ++----- .../src/lib/general/gr_annotator_alltoall.cc | 32 ++++++++++------------ .../src/lib/general/gr_annotator_alltoall.h | 29 ++++++-------------- .../src/lib/general/gr_annotator_alltoall.i | 9 ++---- 6 files changed, 50 insertions(+), 86 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index 1a6cadbcf..11e2c2b4b 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -31,24 +31,22 @@ #include gr_annotator_1to1_sptr -gr_make_annotator_1to1 (int when, size_t sizeof_stream_item, - float rel_rate) +gr_make_annotator_1to1 (int when, size_t sizeof_stream_item) { return gnuradio::get_initial_sptr (new gr_annotator_1to1 - (when, sizeof_stream_item, rel_rate)); + (when, sizeof_stream_item)); } -gr_annotator_1to1::gr_annotator_1to1 (int when, size_t sizeof_stream_item, - float rel_rate) - : gr_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), d_rel_rate(rel_rate), d_when((uint64_t)when) +gr_annotator_1to1::gr_annotator_1to1 (int when, 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), d_when((uint64_t)when) { set_tag_propagation_policy(TPP_ONE_TO_ONE); d_tag_counter = 0; - set_relative_rate(d_rel_rate); + set_relative_rate(1.0); } gr_annotator_1to1::~gr_annotator_1to1 () @@ -56,10 +54,9 @@ gr_annotator_1to1::~gr_annotator_1to1 () } int -gr_annotator_1to1::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +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]; @@ -68,7 +65,7 @@ gr_annotator_1to1::general_work (int noutput_items, str << name() << unique_id(); uint64_t abs_N = 0; - int ninputs = ninput_items.size(); + int ninputs = input_items.size(); for(int i = 0; i < ninputs; i++) { abs_N = nitems_read(i); std::vector all_tags = get_tags_in_range(i, abs_N, abs_N + noutput_items); @@ -104,6 +101,5 @@ gr_annotator_1to1::general_work (int noutput_items, abs_N++; } - consume_each(noutput_items); 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 index e9167bf39..4abc5b051 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.h +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.h @@ -23,15 +23,14 @@ #ifndef INCLUDED_GR_ANNOTATOR_1TO1_H #define INCLUDED_GR_ANNOTATOR_1TO1_H -#include +#include class gr_annotator_1to1; typedef boost::shared_ptr gr_annotator_1to1_sptr; // public constructor gr_annotator_1to1_sptr -gr_make_annotator_1to1 (int when, size_t sizeof_stream_item, - float rel_rate=1.0); +gr_make_annotator_1to1 (int when, size_t sizeof_stream_item); /*! * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY. @@ -46,21 +45,13 @@ gr_make_annotator_1to1 (int when, size_t sizeof_stream_item, * * This block is only meant for testing and showing how to use the tags. */ -class gr_annotator_1to1 : public gr_block +class gr_annotator_1to1 : public gr_sync_block { public: ~gr_annotator_1to1 (); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_rel_rate(float rrate) { - d_rel_rate = rrate; - set_relative_rate(d_rel_rate); - } - float rel_rate() { return d_rel_rate; } - + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); std::vector data() const { @@ -68,19 +59,16 @@ class gr_annotator_1to1 : public gr_block } protected: - gr_annotator_1to1 (int when, size_t sizeof_stream_item, - float rel_rate); + gr_annotator_1to1 (int when, size_t sizeof_stream_item); private: size_t d_itemsize; - float d_rel_rate; uint64_t d_when; uint64_t d_tag_counter; std::vector d_stored_tags; friend gr_annotator_1to1_sptr - gr_make_annotator_1to1 (int when, size_t sizeof_stream_item, - float rel_rate); + gr_make_annotator_1to1 (int when, 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 index 99ab4788c..f29ecbf53 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.i +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.i @@ -23,18 +23,14 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_1to1); gr_annotator_1to1_sptr gr_make_annotator_1to1 (int when, - size_t sizeof_stream_item, - float rel_rate); + size_t sizeof_stream_item); -class gr_annotator_1to1 : public gr_block +class gr_annotator_1to1 : public gr_sync_block { public: - void set_rel_rate(float rrate); - float rel_rate(); std::vector data() const; private: - gr_annotator_1to1 (int when, size_t sizeof_stream_item, - float rel_rate); + gr_annotator_1to1 (int when, size_t sizeof_stream_item); }; diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc index e7bf5d007..9306f9e37 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc @@ -31,25 +31,22 @@ #include gr_annotator_alltoall_sptr -gr_make_annotator_alltoall (int when, size_t sizeof_stream_item, - float rel_rate) +gr_make_annotator_alltoall (int when, size_t sizeof_stream_item) { return gnuradio::get_initial_sptr (new gr_annotator_alltoall - (when, sizeof_stream_item, rel_rate)); + (when, sizeof_stream_item)); } gr_annotator_alltoall::gr_annotator_alltoall (int when, - size_t sizeof_stream_item, - float rel_rate) - : gr_block ("annotator_alltoall", - gr_make_io_signature (1, -1, sizeof_stream_item), - gr_make_io_signature (1, -1, sizeof_stream_item)), - d_itemsize(sizeof_stream_item), d_rel_rate(rel_rate), d_when((uint64_t)when) + size_t sizeof_stream_item) + : gr_sync_block ("annotator_alltoall", + gr_make_io_signature (1, -1, sizeof_stream_item), + gr_make_io_signature (1, -1, sizeof_stream_item)), + d_itemsize(sizeof_stream_item), d_when((uint64_t)when) { set_tag_propagation_policy(TPP_ALL_TO_ALL); d_tag_counter = 0; - set_relative_rate(d_rel_rate); } gr_annotator_alltoall::~gr_annotator_alltoall () @@ -57,10 +54,9 @@ gr_annotator_alltoall::~gr_annotator_alltoall () } int -gr_annotator_alltoall::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +gr_annotator_alltoall::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]; @@ -68,11 +64,12 @@ gr_annotator_alltoall::general_work (int noutput_items, std::stringstream str; str << name() << unique_id(); - uint64_t abs_N = 0; + uint64_t abs_N = 0, end_N; int ninputs = input_items.size(); for(int i = 0; i < ninputs; i++) { abs_N = nitems_read(i); - std::vector all_tags = get_tags_in_range(i, abs_N, abs_N + noutput_items); + end_N = abs_N + (uint64_t)(noutput_items); + std::vector all_tags = get_tags_in_range(i, abs_N, end_N); std::vector::iterator itr; for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { @@ -86,7 +83,9 @@ gr_annotator_alltoall::general_work (int noutput_items, // Work does nothing to the data stream; just copy all inputs to outputs // Adds a new tag when the number of items read is a multiple of d_when + abs_N = nitems_written(0); int noutputs = output_items.size(); + for(int j = 0; j < noutput_items; j++) { for(int i = 0; i < noutputs; i++) { if(abs_N % d_when == 0) { @@ -105,6 +104,5 @@ gr_annotator_alltoall::general_work (int noutput_items, abs_N++; } - consume_each(noutput_items); return noutput_items; } diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h index 38cb53bd6..e1e51ebf3 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h @@ -23,15 +23,14 @@ #ifndef INCLUDED_GR_ANNOTATOR_ALLTOALL_H #define INCLUDED_GR_ANNOTATOR_ALLTOALL_H -#include +#include class gr_annotator_alltoall; typedef boost::shared_ptr gr_annotator_alltoall_sptr; // public constructor gr_annotator_alltoall_sptr -gr_make_annotator_alltoall (int when, size_t sizeof_stream_item, - float rel_rate=1.0); +gr_make_annotator_alltoall (int when, size_t sizeof_stream_item); /*! * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY. @@ -46,41 +45,31 @@ gr_make_annotator_alltoall (int when, size_t sizeof_stream_item, * * This block is only meant for testing and showing how to use the tags. */ -class gr_annotator_alltoall : public gr_block +class gr_annotator_alltoall : public gr_sync_block { public: ~gr_annotator_alltoall (); - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void set_rel_rate(float rrate) { - d_rel_rate = rrate; - set_relative_rate(d_rel_rate); - } - float rel_rate() { return d_rel_rate; } - + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + std::vector data() const { return d_stored_tags; } protected: - gr_annotator_alltoall (int when, size_t sizeof_stream_item, - float rel_rate); + gr_annotator_alltoall (int when, size_t sizeof_stream_item); private: size_t d_itemsize; - float d_rel_rate; uint64_t d_when; uint64_t d_tag_counter; std::vector d_stored_tags; friend gr_annotator_alltoall_sptr - gr_make_annotator_alltoall (int when, size_t sizeof_stream_item, - float rel_rate); + gr_make_annotator_alltoall (int when, size_t sizeof_stream_item); }; #endif diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i index 7812e80c5..f9bf6dd9a 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i @@ -23,17 +23,14 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_alltoall); gr_annotator_alltoall_sptr gr_make_annotator_alltoall (int when, - size_t sizeof_stream_item, - float rel_rate); + size_t sizeof_stream_item); -class gr_annotator_alltoall : public gr_block +class gr_annotator_alltoall : public gr_sync_block { public: - void set_rel_rate(float rrate); - float rel_rate(); std::vector data() const; private: - gr_annotator_alltoall (int when, size_t sizeof_stream_item, float rel_rate); + gr_annotator_alltoall (int when, size_t sizeof_stream_item); }; -- cgit From e6751f477ba006923e9f0d2454ff870c52a6f0a5 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 16 Nov 2010 22:32:46 -0800 Subject: Adding a burst tagger that creates a tag when a signal is observed on line 1. --- gnuradio-core/src/lib/general/Makefile.am | 9 ++- gnuradio-core/src/lib/general/general.i | 2 + gnuradio-core/src/lib/general/gr_burst_tagger.cc | 83 ++++++++++++++++++++++++ gnuradio-core/src/lib/general/gr_burst_tagger.h | 56 ++++++++++++++++ gnuradio-core/src/lib/general/gr_burst_tagger.i | 31 +++++++++ 5 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 gnuradio-core/src/lib/general/gr_burst_tagger.cc create mode 100644 gnuradio-core/src/lib/general/gr_burst_tagger.h create mode 100644 gnuradio-core/src/lib/general/gr_burst_tagger.i (limited to 'gnuradio-core/src/lib/general') 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 #include #include +#include %} %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 +#include +#include + +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 + +class gr_burst_tagger; +typedef boost::shared_ptr 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); +}; -- cgit From b8da2172d0b10f5de04a12b942b48439a7aae8ae Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 17 Nov 2010 15:59:43 -0800 Subject: Changing blocks to use new get_tags api and tag convinience functions. --- gnuradio-core/src/lib/general/gr_annotator_1to1.cc | 4 +++- gnuradio-core/src/lib/general/gr_annotator_alltoall.cc | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index 11e2c2b4b..511b356e5 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -68,7 +68,9 @@ gr_annotator_1to1::work (int noutput_items, int ninputs = input_items.size(); for(int i = 0; i < ninputs; i++) { abs_N = nitems_read(i); - std::vector all_tags = get_tags_in_range(i, abs_N, abs_N + noutput_items); + + std::vector all_tags; + get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items); std::vector::iterator itr; for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc index 9306f9e37..344fd088b 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc @@ -69,7 +69,9 @@ gr_annotator_alltoall::work (int noutput_items, for(int i = 0; i < ninputs; i++) { abs_N = nitems_read(i); end_N = abs_N + (uint64_t)(noutput_items); - std::vector all_tags = get_tags_in_range(i, abs_N, end_N); + + std::vector all_tags; + get_tags_in_range(all_tags, i, abs_N, end_N); std::vector::iterator itr; for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { -- cgit From dd656e9db5e69ed6b11653deea710e299d72827e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 24 Nov 2010 18:21:02 -0500 Subject: Changing API for gr_skiphead to use uint64_t for the offset instead of size_t (still unsigned). Fixes issue #304. Also uses uint64_t's internally so everyone is always on the same type. This should not affect anyone's use of the block. --- gnuradio-core/src/lib/general/gr_skiphead.cc | 8 ++++---- gnuradio-core/src/lib/general/gr_skiphead.h | 10 +++++----- gnuradio-core/src/lib/general/gr_skiphead.i | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_skiphead.cc b/gnuradio-core/src/lib/general/gr_skiphead.cc index ea7e9405f..1670eb7cf 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.cc +++ b/gnuradio-core/src/lib/general/gr_skiphead.cc @@ -27,7 +27,7 @@ #include #include -gr_skiphead::gr_skiphead (size_t itemsize, size_t nitems_to_skip) +gr_skiphead::gr_skiphead (size_t itemsize, uint64_t nitems_to_skip) : gr_block ("skiphead", gr_make_io_signature(1, 1, itemsize), gr_make_io_signature(1, 1, itemsize)), @@ -36,7 +36,7 @@ gr_skiphead::gr_skiphead (size_t itemsize, size_t nitems_to_skip) } gr_skiphead_sptr -gr_make_skiphead (size_t itemsize, size_t nitems_to_skip) +gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip) { return gnuradio::get_initial_sptr(new gr_skiphead (itemsize, nitems_to_skip)); } @@ -55,11 +55,11 @@ gr_skiphead::general_work(int noutput_items, while (ii < ninput_items){ - long long ni_total = ii + d_nitems; // total items processed so far + uint64_t ni_total = ii + d_nitems; // total items processed so far if (ni_total < d_nitems_to_skip){ // need to skip some more int n_to_skip = (int) std::min(d_nitems_to_skip - ni_total, - (long long)(ninput_items - ii)); + (uint64_t)(ninput_items - ii)); ii += n_to_skip; } diff --git a/gnuradio-core/src/lib/general/gr_skiphead.h b/gnuradio-core/src/lib/general/gr_skiphead.h index 965feff9b..933c126e3 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.h +++ b/gnuradio-core/src/lib/general/gr_skiphead.h @@ -39,11 +39,11 @@ typedef boost::shared_ptr gr_skiphead_sptr; class gr_skiphead : public gr_block { - friend gr_skiphead_sptr gr_make_skiphead (size_t itemsize, size_t nitems_to_skip); - gr_skiphead (size_t itemsize, size_t nitems_to_skip); + friend gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); + gr_skiphead (size_t itemsize, uint64_t nitems_to_skip); - long long d_nitems_to_skip; - long long d_nitems; // total items seen + uint64_t d_nitems_to_skip; + uint64_t d_nitems; // total items seen public: @@ -54,7 +54,7 @@ class gr_skiphead : public gr_block }; gr_skiphead_sptr -gr_make_skiphead (size_t itemsize, size_t nitems_to_skip); +gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); #endif /* INCLUDED_GR_SKIPHEAD_H */ diff --git a/gnuradio-core/src/lib/general/gr_skiphead.i b/gnuradio-core/src/lib/general/gr_skiphead.i index 52c0808f0..45cbd0437 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.i +++ b/gnuradio-core/src/lib/general/gr_skiphead.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2007 Free Software Foundation, Inc. + * Copyright 2005,2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,9 +22,9 @@ GR_SWIG_BLOCK_MAGIC(gr,skiphead); -gr_skiphead_sptr gr_make_skiphead (size_t itemsize, size_t nitems_to_skip); +gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); class gr_skiphead : public gr_block { - friend gr_skiphead_sptr gr_make_skiphead (size_t itemsize, size_t nitems_to_skip); - gr_skiphead (size_t itemsize, size_t nitems_to_skip); + friend gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); + gr_skiphead (size_t itemsize, uint64_t nitems_to_skip); }; -- cgit From 649e4387848a5d9273983600be6f35c3e2a88191 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 29 Nov 2010 14:37:20 -0500 Subject: Block is a gr_block, so this sets its relative rate. Was required for using in the QA of the sample tags code. --- gnuradio-core/src/lib/general/gr_keep_one_in_n.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc index c07e177fe..85495e277 100644 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc +++ b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc @@ -38,8 +38,9 @@ gr_keep_one_in_n::gr_keep_one_in_n (size_t item_size, int n) : gr_block ("keep_one_in_n", gr_make_io_signature (1, 1, item_size), gr_make_io_signature (1, 1, item_size)), - d_n (n), d_count(n) + d_count(n) { + set_n(n); } void @@ -50,6 +51,8 @@ gr_keep_one_in_n::set_n(int n) d_n = n; d_count = n; + + set_relative_rate(1.0 / (float)n); } int -- cgit