diff options
Diffstat (limited to 'gnuradio-core/src')
22 files changed, 165 insertions, 271 deletions
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index 511b356e5..d12bfbf04 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -69,10 +69,10 @@ gr_annotator_1to1::work (int noutput_items, for(int i = 0; i < ninputs; i++) { abs_N = nitems_read(i); - std::vector<pmt::pmt_t> all_tags; + std::vector<gr_tag_t> all_tags; get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items); - std::vector<pmt::pmt_t>::iterator itr; + std::vector<gr_tag_t>::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_1to1.h b/gnuradio-core/src/lib/general/gr_annotator_1to1.h index d866407fe..a62720224 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.h +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.h @@ -54,7 +54,7 @@ class GR_CORE_API gr_annotator_1to1 : public gr_sync_block gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - std::vector<pmt::pmt_t> data() const + std::vector<gr_tag_t> data() const { return d_stored_tags; } @@ -66,7 +66,7 @@ protected: size_t d_itemsize; uint64_t d_when; uint64_t d_tag_counter; - std::vector<pmt::pmt_t> d_stored_tags; + std::vector<gr_tag_t> d_stored_tags; friend GR_CORE_API gr_annotator_1to1_sptr gr_make_annotator_1to1 (int when, size_t sizeof_stream_item); diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.i b/gnuradio-core/src/lib/general/gr_annotator_1to1.i index f29ecbf53..2c8149a3c 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.i +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,15 +22,4 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_1to1); -gr_annotator_1to1_sptr gr_make_annotator_1to1 (int when, - size_t sizeof_stream_item); - -class gr_annotator_1to1 : public gr_sync_block -{ -public: - std::vector<pmt::pmt_t> data() const; - -private: - gr_annotator_1to1 (int when, size_t sizeof_stream_item); -}; - +%include <gr_annotator_1to1.h> diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc index 344fd088b..dd31bff78 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc @@ -70,10 +70,10 @@ gr_annotator_alltoall::work (int noutput_items, abs_N = nitems_read(i); end_N = abs_N + (uint64_t)(noutput_items); - std::vector<pmt::pmt_t> all_tags; + std::vector<gr_tag_t> all_tags; get_tags_in_range(all_tags, i, abs_N, end_N); - std::vector<pmt::pmt_t>::iterator itr; + std::vector<gr_tag_t>::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_alltoall.h b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h index 259b2e54c..fe8b736c2 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.h +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.h @@ -55,7 +55,7 @@ class GR_CORE_API gr_annotator_alltoall : public gr_sync_block gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - std::vector<pmt::pmt_t> data() const + std::vector<gr_tag_t> data() const { return d_stored_tags; } @@ -67,7 +67,7 @@ protected: size_t d_itemsize; uint64_t d_when; uint64_t d_tag_counter; - std::vector<pmt::pmt_t> d_stored_tags; + std::vector<gr_tag_t> d_stored_tags; friend GR_CORE_API gr_annotator_alltoall_sptr gr_make_annotator_alltoall (int when, size_t sizeof_stream_item); diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i index f9bf6dd9a..49bd1e446 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.i +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,15 +22,4 @@ GR_SWIG_BLOCK_MAGIC(gr,annotator_alltoall); -gr_annotator_alltoall_sptr gr_make_annotator_alltoall (int when, - size_t sizeof_stream_item); - -class gr_annotator_alltoall : public gr_sync_block -{ -public: - std::vector<pmt::pmt_t> data() const; - -private: - gr_annotator_alltoall (int when, size_t sizeof_stream_item); -}; - +%include <gr_annotator_alltoall.h> 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 8bccefa95..3f98a003b 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 @@ -91,15 +91,13 @@ gr_keep_one_in_n::general_work (int noutput_items, // Because we have set TPP_DONT, we have to propagate the tags here manually. // Adjustment of the tag sample value is done using the float d_decim_rate. - std::vector<pmt::pmt_t> tags; - std::vector<pmt::pmt_t>::iterator t; + std::vector<gr_tag_t> tags; + std::vector<gr_tag_t>::iterator t; get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+ni); for(t = tags.begin(); t != tags.end(); t++) { - uint64_t newcount = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*t, 0)); - add_item_tag(0, newcount * d_decim_rate, - pmt::pmt_tuple_ref(*t, 1), - pmt::pmt_tuple_ref(*t, 2), - pmt::pmt_tuple_ref(*t, 3)); + gr_tag_t new_tag = *t; + new_tag.offset *= d_decim_rate; + add_item_tag(0, new_tag); } consume_each (ni); diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc index 67184b9c5..4ac8c3512 100644 --- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc +++ b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc @@ -32,7 +32,6 @@ #include <fcntl.h> #include <stdexcept> #include <iostream> -#include <gr_tag_info.h> #ifdef HAVE_IO_H #include <io.h> @@ -85,21 +84,21 @@ gr_tagged_file_sink::work (int noutput_items, pmt::pmt_t bkey = pmt::pmt_string_to_symbol("burst"); //pmt::pmt_t tkey = pmt::pmt_string_to_symbol("time"); // use gr_tags::key_time - std::vector<pmt::pmt_t> all_tags; + std::vector<gr_tag_t> all_tags; get_tags_in_range(all_tags, 0, start_N, end_N); - std::sort(all_tags.begin(), all_tags.end(), gr_tags::nitems_compare); + std::sort(all_tags.begin(), all_tags.end(), gr_tag_t::offset_compare); - std::vector<pmt::pmt_t>::iterator vitr = all_tags.begin(); + std::vector<gr_tag_t>::iterator vitr = all_tags.begin(); int idx = 0, idx_stop = 0; while(idx < noutput_items) { if(d_state == NOT_IN_BURST) { while(vitr != all_tags.end()) { - if((pmt::pmt_eqv(gr_tags::get_key(*vitr), bkey)) && - pmt::pmt_is_true(gr_tags::get_value(*vitr))) { + if((pmt::pmt_eqv((*vitr).key, bkey)) && + pmt::pmt_is_true((*vitr).value)) { - uint64_t N = gr_tags::get_nitems(*vitr); + uint64_t N = (*vitr).offset; idx = (int)(N - start_N); //std::cout << std::endl << "Found start of burst: " @@ -107,17 +106,17 @@ gr_tagged_file_sink::work (int noutput_items, // Find time burst occurred by getting latest time tag and extrapolating // to new time based on sample rate of this block. - std::vector<pmt::pmt_t> time_tags; + std::vector<gr_tag_t> time_tags; //get_tags_in_range(time_tags, 0, d_last_N, N, gr_tags::key_time); get_tags_in_range(time_tags, 0, d_last_N, N, pmt::pmt_string_to_symbol("time")); if(time_tags.size() > 0) { - pmt::pmt_t tag = time_tags[time_tags.size()-1]; + const gr_tag_t tag = time_tags[time_tags.size()-1]; - uint64_t time_nitems = gr_tags::get_nitems(tag); + uint64_t time_nitems = tag.offset; // Get time based on last time tag from USRP - pmt::pmt_t time = gr_tags::get_value(tag); + pmt::pmt_t time = tag.value; int tsecs = pmt::pmt_to_long(pmt::pmt_tuple_ref(time, 0)); double tfrac = pmt::pmt_to_double(pmt::pmt_tuple_ref(time, 1)); @@ -175,9 +174,9 @@ gr_tagged_file_sink::work (int noutput_items, } else { // In burst while(vitr != all_tags.end()) { - if((pmt::pmt_eqv(gr_tags::get_key(*vitr), bkey)) && - pmt::pmt_is_false(gr_tags::get_value(*vitr))) { - uint64_t N = gr_tags::get_nitems(*vitr); + if((pmt::pmt_eqv((*vitr).key, bkey)) && + pmt::pmt_is_false((*vitr).value)) { + uint64_t N = (*vitr).offset; idx_stop = (int)N - start_N; //std::cout << "Found end of burst: " diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt index 52cb39c40..e0774154e 100644 --- a/gnuradio-core/src/lib/runtime/CMakeLists.txt +++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt @@ -64,7 +64,6 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_vmcircbuf_createfilemapping.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_vmcircbuf_sysv_shm.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_select_handler.cc - ${CMAKE_CURRENT_SOURCE_DIR}/gr_tag_info.cc ) ######################################################################## @@ -128,7 +127,7 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_types.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_unittests.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_vmcircbuf.h - ${CMAKE_CURRENT_SOURCE_DIR}/gr_tag_info.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_tags.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel" ) diff --git a/gnuradio-core/src/lib/runtime/Makefile.am b/gnuradio-core/src/lib/runtime/Makefile.am index eca92e526..b4a59337e 100644 --- a/gnuradio-core/src/lib/runtime/Makefile.am +++ b/gnuradio-core/src/lib/runtime/Makefile.am @@ -69,7 +69,6 @@ libruntime_la_SOURCES = \ gr_vmcircbuf_createfilemapping.cc \ gr_vmcircbuf_sysv_shm.cc \ gr_select_handler.cc \ - gr_tag_info.cc libruntime_qa_la_SOURCES = \ qa_gr_block.cc \ @@ -125,7 +124,7 @@ grinclude_HEADERS = \ gr_types.h \ gr_unittests.h \ gr_vmcircbuf.h \ - gr_tag_info.h + gr_tags.h noinst_HEADERS = \ gr_vmcircbuf_mmap_shm_open.h \ diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc index 81a55af9d..9463869f5 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_block.cc @@ -144,16 +144,13 @@ gr_block::nitems_written(unsigned int which_output) void gr_block::add_item_tag(unsigned int which_output, - uint64_t offset, - const pmt::pmt_t &key, - const pmt::pmt_t &value, - const pmt::pmt_t &srcid) + const gr_tag_t &tag) { - d_detail->add_item_tag(which_output, offset, key, value, srcid); + d_detail->add_item_tag(which_output, tag); } void -gr_block::get_tags_in_range(std::vector<pmt::pmt_t> &v, +gr_block::get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_output, uint64_t start, uint64_t end) { @@ -161,7 +158,7 @@ gr_block::get_tags_in_range(std::vector<pmt::pmt_t> &v, } void -gr_block::get_tags_in_range(std::vector<pmt::pmt_t> &v, +gr_block::get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_output, uint64_t start, uint64_t end, const pmt::pmt_t &key) diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index 2453e97b8..86e0583e9 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -25,6 +25,7 @@ #include <gr_core_api.h> #include <gr_basic_block.h> +#include <gr_tags.h> /*! * \brief The abstract base class for all 'terminal' processing blocks. @@ -255,11 +256,27 @@ class GR_CORE_API gr_block : public gr_basic_block { * \param value any PMT holding any value for the given key * \param srcid optional source ID specifier; defaults to PMT_F */ - void add_item_tag(unsigned int which_output, + inline void add_item_tag(unsigned int which_output, uint64_t abs_offset, const pmt::pmt_t &key, const pmt::pmt_t &value, - const pmt::pmt_t &srcid=pmt::PMT_F); + const pmt::pmt_t &srcid=pmt::PMT_F) + { + gr_tag_t tag; + tag.offset = abs_offset; + tag.key = key; + tag.value = value; + tag.srcid = srcid; + this->add_item_tag(which_output, tag); + } + + /*! + * \brief Adds a new tag onto the given output buffer. + * + * \param which_output an integer of which output stream to attach the tag + * \param tag the tag object to add + */ + void add_item_tag(unsigned int which_output, const gr_tag_t &tag); /*! * \brief Given a [start,end), returns a vector of all tags in the range. @@ -274,7 +291,7 @@ class GR_CORE_API gr_block : public gr_basic_block { * \param abs_start a uint64 count of the start of the range of interest * \param abs_end a uint64 count of the end of the range of interest */ - void get_tags_in_range(std::vector<pmt::pmt_t> &v, + void get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end); @@ -294,7 +311,7 @@ class GR_CORE_API gr_block : public gr_basic_block { * \param abs_end a uint64 count of the end of the range of interest * \param key a PMT symbol key to filter only tags of this key */ - void get_tags_in_range(std::vector<pmt::pmt_t> &v, + void get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end, diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.cc b/gnuradio-core/src/lib/runtime/gr_block_detail.cc index a360240c0..cbd4239f3 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.cc @@ -150,27 +150,19 @@ gr_block_detail::nitems_written(unsigned int which_output) } void -gr_block_detail::add_item_tag(unsigned int which_output, - uint64_t abs_offset, - const pmt_t &key, - const pmt_t &value, - const pmt_t &srcid) -{ - if(!pmt_is_symbol(key)) { - throw pmt_wrong_type("gr_block_detail::add_item_tag key", key); +gr_block_detail::add_item_tag(unsigned int which_output, const gr_tag_t &tag) +{ + if(!pmt_is_symbol(tag.key)) { + throw pmt_wrong_type("gr_block_detail::add_item_tag key", tag.key); } else { - // build tag tuple - pmt_t nitem = pmt_from_uint64(abs_offset); - pmt_t tuple = pmt_make_tuple(nitem, srcid, key, value); - // Add tag to gr_buffer's deque tags - d_output[which_output]->add_item_tag(tuple); + d_output[which_output]->add_item_tag(tag); } } void -gr_block_detail::get_tags_in_range(std::vector<pmt::pmt_t> &v, +gr_block_detail::get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end) @@ -180,13 +172,13 @@ gr_block_detail::get_tags_in_range(std::vector<pmt::pmt_t> &v, } void -gr_block_detail::get_tags_in_range(std::vector<pmt_t> &v, +gr_block_detail::get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end, const pmt_t &key) { - std::vector<pmt_t> found_items; + std::vector<gr_tag_t> found_items; v.resize(0); @@ -195,9 +187,9 @@ gr_block_detail::get_tags_in_range(std::vector<pmt_t> &v, // Filter further by key name pmt_t itemkey; - std::vector<pmt_t>::iterator itr; + std::vector<gr_tag_t>::iterator itr; for(itr = found_items.begin(); itr != found_items.end(); itr++) { - itemkey = pmt_tuple_ref(*itr, 2); + itemkey = (*itr).key; if(pmt_eqv(key, itemkey)) { v.push_back(*itr); } diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.h b/gnuradio-core/src/lib/runtime/gr_block_detail.h index 633da1b0c..89081156a 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.h @@ -26,7 +26,7 @@ #include <gr_core_api.h> #include <gr_runtime_types.h> #include <gr_tpb_detail.h> -#include <gr_tag_info.h> +#include <gr_tags.h> #include <stdexcept> /*! @@ -105,17 +105,9 @@ class GR_CORE_API gr_block_detail { * which appends the tag onto its deque. * * \param which_output an integer of which output stream to attach the tag - * \param abs_offset a uint64 number of the absolute item number - * assicated with the tag. Can get from nitems_written. - * \param key the tag key as a PMT symbol - * \param value any PMT holding any value for the given key - * \param srcid a PMT source ID specifier + * \param tag the tag object to add */ - void add_item_tag(unsigned int which_output, - uint64_t abs_offset, - const pmt::pmt_t &key, - const pmt::pmt_t &value, - const pmt::pmt_t &srcid); + void add_item_tag(unsigned int which_output, const gr_tag_t &tag); /*! * \brief Given a [start,end), returns a vector of all tags in the range. @@ -131,7 +123,7 @@ class GR_CORE_API gr_block_detail { * \param abs_start a uint64 count of the start of the range of interest * \param abs_end a uint64 count of the end of the range of interest */ - void get_tags_in_range(std::vector<pmt::pmt_t> &v, + void get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end); @@ -153,7 +145,7 @@ class GR_CORE_API gr_block_detail { * \param abs_end a uint64 count of the end of the range of interest * \param key a PMT symbol to select only tags of this key */ - void get_tags_in_range(std::vector<pmt::pmt_t> &v, + void get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end, diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc index b3f987f72..737b26f67 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc @@ -91,7 +91,7 @@ min_available_space (gr_block_detail *d, int output_multiple) static bool propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, const std::vector<uint64_t> &start_nitems_read, double rrate, - std::vector<pmt::pmt_t> &rtags) + std::vector<gr_tag_t> &rtags) { // Move tags downstream // if a sink, we don't need to move downstream @@ -109,7 +109,7 @@ propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, d->get_tags_in_range(rtags, i, start_nitems_read[i], d->nitems_read(i)); - std::vector<pmt::pmt_t>::iterator t; + std::vector<gr_tag_t>::iterator t; if(rrate == 1.0) { for(t = rtags.begin(); t != rtags.end(); t++) { for(int o = 0; o < d->noutputs(); o++) @@ -118,14 +118,10 @@ propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, } else { for(t = rtags.begin(); t != rtags.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)); - + gr_tag_t new_tag = *t; + new_tag.offset *= rrate; for(int o = 0; o < d->noutputs(); o++) - d->output(o)->add_item_tag(newtup); + d->output(o)->add_item_tag(new_tag); } } } @@ -139,14 +135,11 @@ propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, d->get_tags_in_range(rtags, i, start_nitems_read[i], d->nitems_read(i)); - std::vector<pmt::pmt_t>::iterator t; + std::vector<gr_tag_t>::iterator t; for(t = rtags.begin(); t != rtags.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)); - d->output(i)->add_item_tag(newtup); + gr_tag_t new_tag = *t; + new_tag.offset *= rrate; + d->output(i)->add_item_tag(new_tag); } } } diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.h b/gnuradio-core/src/lib/runtime/gr_block_executor.h index cd93212e1..15279f273 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.h +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.h @@ -26,7 +26,7 @@ #include <gr_core_api.h> #include <gr_runtime_types.h> #include <fstream> -#include <gruel/pmt.h> +#include <gr_tags.h> //class gr_block_executor; //typedef boost::shared_ptr<gr_block_executor> gr_block_executor_sptr; @@ -50,7 +50,7 @@ protected: std::vector<bool> d_input_done; gr_vector_void_star d_output_items; std::vector<uint64_t> d_start_nitems_read; //stores where tag counts are before work - std::vector<pmt::pmt_t> d_returned_tags; + std::vector<gr_tag_t> d_returned_tags; public: gr_block_executor(gr_block_sptr block); diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc index fa3722714..8ccc9db32 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.cc +++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc @@ -227,7 +227,7 @@ gr_buffer::drop_reader (gr_buffer_reader *reader) } void -gr_buffer::add_item_tag(const pmt::pmt_t &tag) +gr_buffer::add_item_tag(const gr_tag_t &tag) { gruel::scoped_lock guard(*mutex()); d_item_tags.push_back(tag); @@ -245,7 +245,7 @@ gr_buffer::prune_tags(uint64_t max_time) buffer's mutex al la the scoped_lock line below. */ //gruel::scoped_lock guard(*mutex()); - std::deque<pmt::pmt_t>::iterator itr = d_item_tags.begin(); + std::deque<gr_tag_t>::iterator itr = d_item_tags.begin(); uint64_t item_time; @@ -255,7 +255,7 @@ gr_buffer::prune_tags(uint64_t max_time) // to find more. Mostly, we wil be erasing from the front and // therefore lose little time this way. while(itr != d_item_tags.end()) { - item_time = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 0)); + item_time = (*itr).offset; if(item_time < max_time) { d_item_tags.erase(itr); itr = d_item_tags.begin(); @@ -307,18 +307,18 @@ gr_buffer_reader::update_read_pointer (int nitems) } void -gr_buffer_reader::get_tags_in_range(std::vector<pmt::pmt_t> &v, +gr_buffer_reader::get_tags_in_range(std::vector<gr_tag_t> &v, uint64_t abs_start, uint64_t abs_end) { gruel::scoped_lock guard(*mutex()); v.resize(0); - std::deque<pmt::pmt_t>::iterator itr = d_buffer->get_tags_begin(); + std::deque<gr_tag_t>::iterator itr = d_buffer->get_tags_begin(); uint64_t item_time; while(itr != d_buffer->get_tags_end()) { - item_time = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 0)); + item_time = (*itr).offset; if((item_time >= abs_start) && (item_time < abs_end)) { v.push_back(*itr); diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.h b/gnuradio-core/src/lib/runtime/gr_buffer.h index e7c0a06a5..e8e393756 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.h +++ b/gnuradio-core/src/lib/runtime/gr_buffer.h @@ -27,7 +27,7 @@ #include <gr_runtime_types.h> #include <boost/weak_ptr.hpp> #include <gruel/thread.h> -#include <gruel/pmt.h> +#include <gr_tags.h> #include <deque> class gr_vmcircbuf; @@ -97,9 +97,9 @@ class GR_CORE_API gr_buffer { /*! * \brief Adds a new tag to the buffer. * - * \param tag a PMT tuple containing the new tag + * \param tag the new tag */ - void add_item_tag(const pmt::pmt_t &tag); + void add_item_tag(const gr_tag_t &tag); /*! * \brief Removes all tags before \p max_time from buffer @@ -108,8 +108,8 @@ class GR_CORE_API gr_buffer { */ void prune_tags(uint64_t max_time); - std::deque<pmt::pmt_t>::iterator get_tags_begin() { return d_item_tags.begin(); } - std::deque<pmt::pmt_t>::iterator get_tags_end() { return d_item_tags.end(); } + std::deque<gr_tag_t>::iterator get_tags_begin() { return d_item_tags.begin(); } + std::deque<gr_tag_t>::iterator get_tags_end() { return d_item_tags.end(); } // ------------------------------------------------------------------------- @@ -136,7 +136,7 @@ class GR_CORE_API gr_buffer { unsigned int d_write_index; // in items [0,d_bufsize) uint64_t d_abs_write_offset; // num items written since the start bool d_done; - std::deque<pmt::pmt_t> d_item_tags; + std::deque<gr_tag_t> d_item_tags; uint64_t d_last_min_items_read; unsigned @@ -268,7 +268,7 @@ class GR_CORE_API gr_buffer_reader { * \param abs_start a uint64 count of the start of the range of interest * \param abs_end a uint64 count of the end of the range of interest */ - void get_tags_in_range(std::vector<pmt::pmt_t> &v, + void get_tags_in_range(std::vector<gr_tag_t> &v, uint64_t abs_start, uint64_t abs_end); diff --git a/gnuradio-core/src/lib/runtime/gr_tag_info.cc b/gnuradio-core/src/lib/runtime/gr_tag_info.cc deleted file mode 100644 index f15329f9b..000000000 --- a/gnuradio-core/src/lib/runtime/gr_tag_info.cc +++ /dev/null @@ -1,38 +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 <gr_tag_info.h> -#include <gruel/pmt.h> - -namespace gr_tags { -/* - const pmt::pmt_t key_time = pmt::pmt_string_to_symbol("time"); - const pmt::pmt_t key_sample_rate = pmt::pmt_string_to_symbol("sample_rate"); - const pmt::pmt_t key_frequency = pmt::pmt_string_to_symbol("frequency"); - const pmt::pmt_t key_rssi = pmt::pmt_string_to_symbol("rssi"); - const pmt::pmt_t key_rx_gain = pmt::pmt_string_to_symbol("gain"); -*/ -} diff --git a/gnuradio-core/src/lib/runtime/gr_tag_info.h b/gnuradio-core/src/lib/runtime/gr_tag_info.h deleted file mode 100644 index 5a1e1555a..000000000 --- a/gnuradio-core/src/lib/runtime/gr_tag_info.h +++ /dev/null @@ -1,87 +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_TAG_INFO_H -#define INCLUDED_GR_TAG_INFO_H - -#include <gruel/pmt.h> - -namespace gr_tags { - - enum { - TAG_NITEM_REF = 0, - TAG_SRCID_REF, - TAG_KEY_REF, - TAG_VALUE_REF - }; - - /* - extern const pmt::pmt_t key_time; - extern const pmt::pmt_t key_sample_rate; - extern const pmt::pmt_t key_frequency; - extern const pmt::pmt_t key_rssi; - extern const pmt::pmt_t key_gain; - */ - - /*! - * \brief Returns the item \p tag occurred at (as a uint64_t) - */ - static inline uint64_t - get_nitems(const pmt::pmt_t &tag) { - return pmt::pmt_to_uint64(pmt::pmt_tuple_ref(tag, TAG_NITEM_REF)); - } - - /*! - * \brief Returns the source ID of \p tag (as a PMT) - */ - static inline pmt::pmt_t - get_srcid(const pmt::pmt_t &tag) { - return pmt::pmt_tuple_ref(tag, TAG_SRCID_REF); - } - - /*! - * \brief Returns the key of \p tag (as a PMT symbol) - */ - static inline pmt::pmt_t - get_key(const pmt::pmt_t &tag) { - return pmt::pmt_tuple_ref(tag, TAG_KEY_REF); - } - - /*! - * \brief Returns the value of \p tag (as a PMT) - */ - static inline pmt::pmt_t - get_value(const pmt::pmt_t &tag) { - return pmt::pmt_tuple_ref(tag, TAG_VALUE_REF); - } - - /*! - * \brief Comparison function to test which tag, \p x or \p y, came first in time - */ - static inline bool - nitems_compare(pmt::pmt_t x, pmt::pmt_t y) { - return get_nitems(x) < get_nitems(y); - } - -}; /* namespace tags */ - -#endif /* GR_TAG_INFO */ diff --git a/gnuradio-core/src/lib/runtime/gr_tags.h b/gnuradio-core/src/lib/runtime/gr_tags.h new file mode 100644 index 000000000..e410e76a4 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_tags.h @@ -0,0 +1,55 @@ +/* + * Copyright 2011 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_TAGS_H +#define INCLUDED_GR_TAGS_H + +#include <gr_core_api.h> +#include <gruel/pmt.h> + +//dummy namespace so the line below makes swig happy +namespace pmt{} +//stupid using namespace because pmt::pmt_t confuses swig +using namespace pmt; + +struct GR_CORE_API gr_tag_t{ + + //! the item \p tag occurred at (as a uint64_t) + uint64_t offset; + + //! the key of \p tag (as a PMT symbol) + pmt_t key; + + //! the value of \p tag (as a PMT) + pmt_t value; + + //! the source ID of \p tag (as a PMT) + pmt_t srcid; + + //! Comparison function to test which tag, \p x or \p y, came first in time + static inline bool offset_compare( + const gr_tag_t &x, const gr_tag_t &y + ){ + return x.offset < y.offset; + } +}; + +#endif /*INCLUDED_GR_TAGS_H*/ diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc index 07ce5c276..ab5840c6d 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.cc @@ -103,9 +103,9 @@ qa_block_tags::t1 () tb->run(); - std::vector<pmt::pmt_t> tags0 = ann0->data(); - std::vector<pmt::pmt_t> tags3 = ann3->data(); - std::vector<pmt::pmt_t> tags4 = ann4->data(); + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags3 = ann3->data(); + std::vector<gr_tag_t> tags4 = ann4->data(); // The first annotator does not receive any tags from the null sink upstream CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); @@ -187,11 +187,11 @@ qa_block_tags::t2 () tb->run(); - 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 = ann4->data(); - std::vector<pmt::pmt_t> tags4 = ann4->data(); + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags1 = ann1->data(); + std::vector<gr_tag_t> tags2 = ann2->data(); + std::vector<gr_tag_t> tags3 = ann4->data(); + std::vector<gr_tag_t> tags4 = ann4->data(); // The first annotator does not receive any tags from the null sink upstream CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); @@ -287,9 +287,9 @@ qa_block_tags::t3 () tb->run(); - std::vector<pmt::pmt_t> tags0 = ann0->data(); - std::vector<pmt::pmt_t> tags3 = ann3->data(); - std::vector<pmt::pmt_t> tags4 = ann4->data(); + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags3 = ann3->data(); + std::vector<gr_tag_t> tags4 = ann4->data(); // The first annotator does not receive any tags from the null sink upstream CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); @@ -394,9 +394,9 @@ qa_block_tags::t5 () tb->run(); - 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<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags1 = ann1->data(); + std::vector<gr_tag_t> tags2 = ann2->data(); // The first annotator does not receive any tags from the null sink upstream CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); |