diff options
author | Tom Rondeau | 2010-11-14 01:20:44 -0500 |
---|---|---|
committer | Tom Rondeau | 2010-11-14 01:20:44 -0500 |
commit | 11b2b7c40048bee5201bd10dd753a9471cd6345d (patch) | |
tree | f0eecc24774db8eab4257fafd6d2a5f535617885 | |
parent | 222c6c5be69575c00d6396b95d523e0dfa19f2c3 (diff) | |
download | gnuradio-11b2b7c40048bee5201bd10dd753a9471cd6345d.tar.gz gnuradio-11b2b7c40048bee5201bd10dd753a9471cd6345d.tar.bz2 gnuradio-11b2b7c40048bee5201bd10dd753a9471cd6345d.zip |
Adds argument to annotator test blocks to determine when they add a new tag.
7 files changed, 67 insertions, 44 deletions
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 <iomanip> 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> 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<pmt::pmt_t> 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<pmt::pmt_t> 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 <iomanip> 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> 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<pmt::pmt_t> 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<pmt::pmt_t> 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); }; diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc index 8612a1067..9c4dac698 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.cc @@ -75,11 +75,11 @@ qa_block_tags::t1 () gr_top_block_sptr tb = gr_make_top_block("top"); gr_block_sptr src (gr_make_null_source(sizeof(int))); gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(sizeof(int))); - gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(sizeof(int))); - gr_annotator_alltoall_sptr ann4 (gr_make_annotator_alltoall(sizeof(int))); + gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann4 (gr_make_annotator_alltoall(10000, sizeof(int))); gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); @@ -155,11 +155,11 @@ qa_block_tags::t2 () gr_top_block_sptr tb = gr_make_top_block("top"); gr_block_sptr src (gr_make_null_source(sizeof(int))); gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(sizeof(int))); - gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(sizeof(int))); - gr_annotator_alltoall_sptr ann4 (gr_make_annotator_alltoall(sizeof(int))); + gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann4 (gr_make_annotator_alltoall(10000, sizeof(int))); gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); gr_block_sptr snk2 (gr_make_null_sink(sizeof(int))); @@ -255,11 +255,11 @@ qa_block_tags::t3 () gr_top_block_sptr tb = gr_make_top_block("top"); gr_block_sptr src (gr_make_null_source(sizeof(int))); gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_1to1_sptr ann0 (gr_make_annotator_1to1(sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(sizeof(int))); - gr_annotator_1to1_sptr ann3 (gr_make_annotator_1to1(sizeof(int))); - gr_annotator_1to1_sptr ann4 (gr_make_annotator_1to1(sizeof(int))); + gr_annotator_1to1_sptr ann0 (gr_make_annotator_1to1(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); + gr_annotator_1to1_sptr ann3 (gr_make_annotator_1to1(10000, sizeof(int))); + gr_annotator_1to1_sptr ann4 (gr_make_annotator_1to1(10000, sizeof(int))); gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); @@ -337,9 +337,9 @@ qa_block_tags::t4 () gr_top_block_sptr tb = gr_make_top_block("top"); gr_block_sptr src (gr_make_null_source(sizeof(int))); gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_1to1_sptr ann0 (gr_make_annotator_1to1(sizeof(int))); - gr_annotator_1to1_sptr ann1 (gr_make_annotator_1to1(sizeof(int))); - gr_annotator_1to1_sptr ann2 (gr_make_annotator_1to1(sizeof(int))); + gr_annotator_1to1_sptr ann0 (gr_make_annotator_1to1(10000, sizeof(int))); + gr_annotator_1to1_sptr ann1 (gr_make_annotator_1to1(10000, sizeof(int))); + gr_annotator_1to1_sptr ann2 (gr_make_annotator_1to1(10000, sizeof(int))); gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); |