diff options
author | Bill Clark <saikou@vt.edu> | 2015-04-01 13:07:30 -0400 |
---|---|---|
committer | Bill Clark <saikou@vt.edu> | 2015-04-01 13:07:30 -0400 |
commit | 2f33b9cee312a2b97948c2999a937b8ef601b09b (patch) | |
tree | 50257dfb57c0a0218693800e387972aaf5c4fa57 | |
parent | 34275a2c3e18c5738ccf02f4c3119efdacd00ae8 (diff) |
gnuradio-runtime: (option 1) The hier block can now take a generic min/max output buffer length and assign it to every block within the hier (assumes all output buffers have the same min/max values set); (option 2) sets only the blocks connected to hier output ports and does not set the other internal blocks (requires that each port has different values); for single port output hier blocks only option 1 is possible.
-rw-r--r-- | gnuradio-runtime/lib/hier_block2.cc | 21 | ||||
-rw-r--r-- | gnuradio-runtime/lib/hier_block2_detail.cc | 62 |
2 files changed, 69 insertions, 14 deletions
diff --git a/gnuradio-runtime/lib/hier_block2.cc b/gnuradio-runtime/lib/hier_block2.cc index 130b2a11d4..a12980ae48 100644 --- a/gnuradio-runtime/lib/hier_block2.cc +++ b/gnuradio-runtime/lib/hier_block2.cc @@ -29,6 +29,7 @@ #include <gnuradio/flowgraph.h> #include "hier_block2_detail.h" #include <iostream> +#include <stdio.h> namespace gr { @@ -199,8 +200,10 @@ namespace gr { { if(d_max_output_buffer.size() == 0) throw std::length_error("hier_block2::max_output_buffer: out_sig greater than zero, buff_vect isn't"); - for(int idx = 0; idx < output_signature()->max_streams(); idx++) + for(int idx = 0; idx < output_signature()->max_streams(); idx++){ d_max_output_buffer[idx] = max_output_buffer; + printf("Port %d is being set to max(%ld)\t%s\n",idx,max_output_buffer,(alias()).c_str()); + } } } @@ -209,8 +212,10 @@ namespace gr { { if((size_t)port >= d_max_output_buffer.size()) throw std::invalid_argument("hier_block2::max_output_buffer: port out of range."); - else + else{ d_max_output_buffer[port] = max_output_buffer; + printf("Port %d is being set to max(%ld)\t%s\n",port,max_output_buffer,(alias()).c_str()); + } } long @@ -228,8 +233,10 @@ namespace gr { { if(d_min_output_buffer.size() == 0) throw std::length_error("hier_block2::min_output_buffer: out_sig greater than zero, buff_vect isn't"); - for(int idx = 0; idx < output_signature()->max_streams(); idx++) + for(int idx = 0; idx < output_signature()->max_streams(); idx++){ d_min_output_buffer[idx] = min_output_buffer; + printf("Port %d is being set to min(%ld)\t%s\n",idx,min_output_buffer,(alias()).c_str()); + } } } @@ -238,8 +245,10 @@ namespace gr { { if((size_t)port >= d_min_output_buffer.size()) throw std::invalid_argument("hier_block2::min_output_buffer: port out of range."); - else + else{ d_min_output_buffer[port] = min_output_buffer; + printf("Port %d is being set to min(%ld)\t%s\n",port,min_output_buffer,(alias()).c_str()); + } } bool @@ -251,9 +260,11 @@ namespace gr { if(d_min_output_buffer[0] != d_min_output_buffer[idx]) all_equal = false; } + printf("Set all min (%d)\n",int(all_equal),(alias()).c_str()); return all_equal; } else{ + printf("Set all min (%d)\n",int(false),(alias()).c_str()); return false; } } @@ -266,9 +277,11 @@ namespace gr { if(d_max_output_buffer[0] != d_max_output_buffer[idx]) all_equal = false; } + printf("Set all max (%d)\t%s\n",int(all_equal),(alias()).c_str()); return all_equal; } else{ + printf("Set all max (%d)\t%s\n",int(false),(alias()).c_str()); return false; } } diff --git a/gnuradio-runtime/lib/hier_block2_detail.cc b/gnuradio-runtime/lib/hier_block2_detail.cc index 249fccf304..20a2e245f2 100644 --- a/gnuradio-runtime/lib/hier_block2_detail.cc +++ b/gnuradio-runtime/lib/hier_block2_detail.cc @@ -30,6 +30,7 @@ #include <stdexcept> #include <sstream> #include <boost/format.hpp> +#include <stdio.h> namespace gr { @@ -515,11 +516,6 @@ namespace gr { bool ctrlport_on = prefs::singleton()->get_bool("ControlPort", "on", false); // Get the min and max buffer length - // TODO: Currently assuming all blocks within hier - // are set to the first port value. (latency case) - // Address the condition where only the block connected - // to a specific hier port is modified by the hier port assignment - // TODO: handle the connect port only case long min_buff(-1), max_buff(-1); bool set_all_min_buff = d_owner->set_all_min_output_buffer(); bool set_all_max_buff = d_owner->set_all_max_output_buffer(); @@ -545,12 +541,16 @@ namespace gr { if(min_buff != -1){ block_sptr bb = boost::dynamic_pointer_cast<block>(b); if(bb != 0){ - bb->set_min_output_buffer(min_buff); + if(bb->min_output_buffer(0) != min_buff){ + bb->set_min_output_buffer(min_buff); + } } else{ hier_block2_sptr hh = boost::dynamic_pointer_cast<hier_block2>(b); if(hh != 0){ - hh->set_min_output_buffer(min_buff); + if(hh->min_output_buffer(0) != min_buff){ + hh->set_min_output_buffer(min_buff); + } } } } @@ -560,12 +560,16 @@ namespace gr { if(max_buff != -1){ block_sptr bb = boost::dynamic_pointer_cast<block>(b); if(bb != 0){ - bb->set_max_output_buffer(max_buff); + if(bb->max_output_buffer(0) != max_buff){ + bb->set_max_output_buffer(max_buff); + } } else{ hier_block2_sptr hh = boost::dynamic_pointer_cast<hier_block2>(b); if(hh != 0){ - hh->set_max_output_buffer(max_buff); + if(hh->max_output_buffer(0) != max_buff){ + hh->set_max_output_buffer(max_buff); + } } } } @@ -578,6 +582,44 @@ namespace gr { b->rpc_set(); } } + if(set_all_min_buff){ + //sets the min buff for every block within hier_block2 + if(min_buff != -1){ + block_sptr bb = boost::dynamic_pointer_cast<block>(b); + if(bb != 0){ + if(bb->min_output_buffer(0) != min_buff){ + bb->set_min_output_buffer(min_buff); + } + } + else{ + hier_block2_sptr hh = boost::dynamic_pointer_cast<hier_block2>(b); + if(hh != 0){ + if(hh->min_output_buffer(0) != min_buff){ + hh->set_min_output_buffer(min_buff); + } + } + } + } + } + if(set_all_max_buff){ + //sets the max buff for every block within hier_block2 + if(max_buff != -1){ + block_sptr bb = boost::dynamic_pointer_cast<block>(b); + if(bb != 0){ + if(bb->max_output_buffer(0) != max_buff){ + bb->set_max_output_buffer(max_buff); + } + } + else{ + hier_block2_sptr hh = boost::dynamic_pointer_cast<hier_block2>(b); + if(hh != 0){ + if(hh->max_output_buffer(0) != max_buff){ + hh->set_max_output_buffer(max_buff); + } + } + } + } + } } if(HIER_BLOCK2_DETAIL_DEBUG) @@ -685,7 +727,7 @@ namespace gr { << " is not connected internally"; throw std::runtime_error(msg.str()); } - // TODO: Update buffers of just these output blocks + // Set the buffers of only the blocks connected to the hier output if(!set_all_min_buff){ min_buff = d_owner->min_output_buffer(i); if(min_buff != -1){ |