diff options
author | Tom Rondeau | 2010-11-06 14:24:19 -0400 |
---|---|---|
committer | Tom Rondeau | 2010-11-06 14:24:19 -0400 |
commit | cafe83aa6bd47f8e05bd347cc4495d3662b5440f (patch) | |
tree | 8cbb03a2ce7be9c993dff98012cad97a5f21c53e /gnuradio-core/src/lib/runtime | |
parent | 8b184fda9da4e7fdf08ddfd4d973d5d8d83be308 (diff) | |
download | gnuradio-cafe83aa6bd47f8e05bd347cc4495d3662b5440f.tar.gz gnuradio-cafe83aa6bd47f8e05bd347cc4495d3662b5440f.tar.bz2 gnuradio-cafe83aa6bd47f8e05bd347cc4495d3662b5440f.zip |
Don't directly output tag info to screen from gr_random_annotator; instead, store the stream and write it to stdout when block is being destroyed. This avoids issues of the muliple threads writing simultaneously to screen.
Diffstat (limited to 'gnuradio-core/src/lib/runtime')
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_random_annotator.cc | 20 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_random_annotator.h | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/qa_block_tags.cc | 4 |
3 files changed, 15 insertions, 10 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_random_annotator.cc b/gnuradio-core/src/lib/runtime/gr_random_annotator.cc index d9ad15a55..93d9aa793 100644 --- a/gnuradio-core/src/lib/runtime/gr_random_annotator.cc +++ b/gnuradio-core/src/lib/runtime/gr_random_annotator.cc @@ -46,6 +46,7 @@ gr_random_annotator::gr_random_annotator (size_t sizeof_stream_item) gr_random_annotator::~gr_random_annotator () { + std::cout << d_sout.str(); } int @@ -62,21 +63,22 @@ gr_random_annotator::work (int noutput_items, gr_uint64 abs_N = nitems_written(0); std::deque<pmt::pmt_t> all_tags = get_tags_in_range(0, (gr_uint64)0, abs_N); std::deque<pmt::pmt_t>::iterator itr; - std::cout << std::endl << "Found " << all_tags.size() << " tags." << std::endl; - std::cout.setf(std::ios::left); - std::cout << std::setw(25) << "Receiver" << std::setw(25) << "Sender" - << std::setw(10) << "nitem" << std::setw(20) << "key" - << std::setw(10) << "value" << std::endl; + 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++) { gr_uint64 nitem = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 0)); std::string srcid = pmt::pmt_symbol_to_string(pmt::pmt_tuple_ref(*itr, 1)); std::string key = pmt::pmt_symbol_to_string(pmt::pmt_tuple_ref(*itr, 2)); gr_uint64 value = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 3)); - std::cout << std::setw(25) << str.str() << std::setw(25) << srcid - << std::setw(10) << nitem << std::setw(20) << key - << std::setw(10) << value << std::endl; + d_sout << std::setw(25) << str.str() << std::setw(25) << srcid + << std::setw(10) << nitem << std::setw(20) << key + << std::setw(10) << value << std::endl; } // Work does nothing to the data stream; just copy all inputs to outputs @@ -86,7 +88,7 @@ gr_random_annotator::work (int noutput_items, } // Storing the current noutput_items as the value to the "noutput_items" key - pmt::pmt_t cur_N = pmt::pmt_from_uint64(noutput_items); + pmt::pmt_t cur_N = pmt::pmt_from_uint64(random()); pmt::pmt_t srcid = pmt::pmt_string_to_symbol(str.str()); pmt::pmt_t key = pmt::pmt_string_to_symbol("noutput_items"); add_item_tag(0, abs_N, key, cur_N, srcid); diff --git a/gnuradio-core/src/lib/runtime/gr_random_annotator.h b/gnuradio-core/src/lib/runtime/gr_random_annotator.h index 7f200eff7..3f21b71ad 100644 --- a/gnuradio-core/src/lib/runtime/gr_random_annotator.h +++ b/gnuradio-core/src/lib/runtime/gr_random_annotator.h @@ -45,6 +45,7 @@ protected: private: size_t d_itemsize; + std::stringstream d_sout; friend gr_random_annotator_sptr gr_make_random_annotator (size_t sizeof_stream_item); diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc index 7fe1b4bfd..ab3db6653 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.cc @@ -75,12 +75,14 @@ qa_block_tags::t1 () gr_block_sptr head (gr_make_head(sizeof(int), N)); gr_block_sptr ann0 (gr_make_random_annotator(sizeof(int))); gr_block_sptr ann1 (gr_make_random_annotator(sizeof(int))); + gr_block_sptr ann2 (gr_make_random_annotator(sizeof(int))); gr_block_sptr snk (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, snk, 0); + tb->connect(ann1, 0, ann2, 0); + tb->connect(ann2, 0, snk, 0); tb->run(); } |