diff options
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_executor.cc | 14 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_buffer.cc | 4 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/qa_block_tags.cc | 99 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/qa_block_tags.h | 2 |
4 files changed, 114 insertions, 5 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc index dd0993ec7..9882c2e5d 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc @@ -89,7 +89,7 @@ min_available_space (gr_block_detail *d, int output_multiple) static bool propagate_tags(gr_block::TAG_PROPAGATION_POLICY policy, gr_block_detail *d, - const std::vector<uint64_t> &start_nitems_read) + const std::vector<uint64_t> &start_nitems_read, double rrate) { // Move tags downstream // if a sink, we don't need to move downstream; @@ -109,8 +109,15 @@ propagate_tags(gr_block::TAG_PROPAGATION_POLICY policy, gr_block_detail *d, d->nitems_read(i)); std::vector<pmt::pmt_t>::iterator t; for(t = tuple.begin(); t != tuple.end(); t++ ) { + uint64_t newcount = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*t, 0)); + pmt::pmt_t newtup = pmt::mp(pmt::pmt_from_uint64(newcount * rrate), + pmt::pmt_tuple_ref(*t, 1), + pmt::pmt_tuple_ref(*t, 2), + pmt::pmt_tuple_ref(*t, 3)); + for(int o = 0; o < d->noutputs(); o++) - d->output(o)->add_item_tag(*t); + d->output(o)->add_item_tag(newtup); + //d->output(o)->add_item_tag(*t); } } break; @@ -358,7 +365,8 @@ gr_block_executor::run_one_iteration() LOG(*d_log << " general_work: noutput_items = " << noutput_items << " result = " << n << std::endl); - if(!propagate_tags(m->tag_propagation_policy(), d, d_start_nitems_read)) + if(!propagate_tags(m->tag_propagation_policy(), d, + d_start_nitems_read, m->relative_rate())) goto were_done; if (n == gr_block::WORK_DONE) diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc index f6a0a98fb..84a65f921 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.cc +++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc @@ -307,8 +307,8 @@ gr_buffer_reader::prune_tags(uint64_t max_time) d_buffer->tags_pop_front(); n++; } - else - break; + //else + // break; itr++; } } diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc index 9c4dac698..e337e3768 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.cc @@ -355,3 +355,102 @@ qa_block_tags::t4 () tb->run(); } + +void +qa_block_tags::t5 () +{ + printf("\nqa_block_tags::t5\n"); + + int N = 40000; + 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(10000, sizeof(int))); + gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(1000, sizeof(int))); + gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(1000, sizeof(int))); + gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(1000, sizeof(int))); + gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); + + tb->connect(src, 0, head, 0); + tb->connect(head, 0, ann0, 0); + tb->connect(ann0, 0, ann1, 0); + tb->connect(ann1, 0, ann2, 0); + tb->connect(ann2, 0, snk0, 0); + + tb->run(); + + // Kludge together the tags that we know should result from the above graph + std::stringstream str0, str1, str2; + str0 << ann0->name() << ann0->unique_id(); + str1 << ann1->name() << ann1->unique_id(); + str2 << ann2->name() << ann2->unique_id(); + + pmt_t expected_tags1[5]; + expected_tags1[0] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags1[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); + expected_tags1[2] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags1[3] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags1[4] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(4)); + + pmt_t expected_tags2[10]; + expected_tags2[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags2[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags2[2] = mp(pmt_from_uint64(1000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags2[3] = mp(pmt_from_uint64(1000), mp(str0.str()), mp("seq"), mp(1)); + expected_tags2[4] = mp(pmt_from_uint64(2000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags2[5] = mp(pmt_from_uint64(2000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags2[6] = mp(pmt_from_uint64(3000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags2[7] = mp(pmt_from_uint64(3000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags2[8] = mp(pmt_from_uint64(4000), mp(str1.str()), mp("seq"), mp(4)); + expected_tags2[9] = mp(pmt_from_uint64(4000), mp(str0.str()), mp("seq"), mp(4)); + + pmt_t expected_tags3[12]; + expected_tags3[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); + expected_tags3[1] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags3[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags3[3] = mp(pmt_from_uint64(1000), mp(str2.str()), mp("seq"), mp(1)); + expected_tags3[4] = mp(pmt_from_uint64(2000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags3[5] = mp(pmt_from_uint64(2000), mp(str0.str()), mp("seq"), mp(1)); + expected_tags3[6] = mp(pmt_from_uint64(2000), mp(str2.str()), mp("seq"), mp(2)); + expected_tags3[7] = mp(pmt_from_uint64(4000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags3[8] = mp(pmt_from_uint64(4000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags3[9] = mp(pmt_from_uint64(3000), mp(str2.str()), mp("seq"), mp(3)); + expected_tags3[10] = mp(pmt_from_uint64(6000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags3[11] = mp(pmt_from_uint64(6000), mp(str0.str()), mp("seq"), mp(3)); + + std::vector<pmt::pmt_t> tags0 = ann0->data(); + std::vector<pmt::pmt_t> tags1 = ann1->data(); + std::vector<pmt::pmt_t> tags2 = ann2->data(); + std::vector<pmt::pmt_t> tags3 = ann3->data(); + + // The first annotator does not receive any tags from the null sink upstream + CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); + + // annotator 1 gets tags from annotator 0 + std::cout << "tags1.size(): " << tags1.size() << std::endl; + //CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)4); + for(size_t i = 0; i < tags1.size(); i++) { + std::cout << "tags1[" << i << "] = " << tags1[i] << "\t\t" << expected_tags1[i] << std::endl; + //pmt_equal(tags1[i], expected_tags1[i]) + //CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags1[i]), pmt_write_string(expected_tags1[i])); + } + + // annotator 2 gets tags from annotators 0 and 1 + std::cout << std::endl; + std::cout << "tags2.size(): " << tags2.size() << std::endl; + //CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)8); + for(size_t i = 0; i < tags2.size(); i++) { + std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; + //CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags2[i]), pmt_write_string(expected_tags2[i])); + } + + // annotator 3 gets tags from annotators 0, 1, and 2 + std::cout << std::endl; + std::cout << "tags3.size(): " << tags3.size() << std::endl; + //CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)8); + for(size_t i = 0; i < tags3.size(); i++) { + std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; + //CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags3[i]), pmt_write_string(expected_tags3[i])); + } +} + diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.h b/gnuradio-core/src/lib/runtime/qa_block_tags.h index 2bf134d96..661d607b2 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.h +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.h @@ -35,6 +35,7 @@ class qa_block_tags : public CppUnit::TestCase { CPPUNIT_TEST (t2); CPPUNIT_TEST (t3); CPPUNIT_TEST (t4); + //CPPUNIT_TEST (t5); CPPUNIT_TEST_SUITE_END (); private: @@ -43,6 +44,7 @@ class qa_block_tags : public CppUnit::TestCase { void t2 (); void t3 (); void t4 (); + void t5 (); }; |