From 74817aee3eda6a8878b14e016091277d978b8cb5 Mon Sep 17 00:00:00 2001 From: Tim O'Shea Date: Mon, 10 Dec 2012 19:56:54 -0500 Subject: 1. msg passing logic fix for fan-in to hier block outputs and fan-out from hier block inputs 2. adding hier msg passing example --- .../examples/msg_passing/hier/test_msg_hier.grc | 287 +++++++++++++++++++++ .../msg_passing/hier/test_msg_hier_topblock.grc | 185 +++++++++++++ gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc | 25 +- gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h | 1 + .../src/lib/runtime/gr_hier_block2_detail.cc | 7 + 5 files changed, 502 insertions(+), 3 deletions(-) create mode 100644 gnuradio-core/src/examples/msg_passing/hier/test_msg_hier.grc create mode 100644 gnuradio-core/src/examples/msg_passing/hier/test_msg_hier_topblock.grc diff --git a/gnuradio-core/src/examples/msg_passing/hier/test_msg_hier.grc b/gnuradio-core/src/examples/msg_passing/hier/test_msg_hier.grc new file mode 100644 index 000000000..0faed49bc --- /dev/null +++ b/gnuradio-core/src/examples/msg_passing/hier/test_msg_hier.grc @@ -0,0 +1,287 @@ + + + Mon Dec 10 19:56:24 2012 + + options + + id + test_msg_hier + + + _enabled + True + + + title + + + + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + hb + + + category + Custom + + + run_options + prompt + + + run + True + + + max_nouts + 0 + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + pad_source + + id + pad_source_0 + + + _enabled + True + + + label + TEST_PORT + + + type + message + + + vlen + 1 + + + optional + False + + + _coordinate + (234, 145) + + + _rotation + 0 + + + + pad_source + + id + pad_source_0_0 + + + _enabled + True + + + label + TEST_PORT2 + + + type + message + + + vlen + 1 + + + optional + False + + + _coordinate + (167, 54) + + + _rotation + 0 + + + + gr_message_strobe + + id + gr_message_strobe_0 + + + _enabled + True + + + msg + pmt.pmt_cons(pmt.PMT_NIL, pmt.pmt_make_u8vector(16,0x77)) + + + period + 200 + + + _coordinate + (362, 81) + + + _rotation + 0 + + + + pad_sink + + id + pad_sink_0 + + + _enabled + True + + + label + TEST_PORT + + + type + message + + + vlen + 1 + + + optional + True + + + _coordinate + (618, 87) + + + _rotation + 0 + + + + gr_message_strobe + + id + gr_message_strobe_0_1 + + + _enabled + True + + + msg + pmt.pmt_intern("OUTPUT2") + + + period + 100 + + + _coordinate + (400, 156) + + + _rotation + 0 + + + + pad_sink + + id + pad_sink_0_0 + + + _enabled + True + + + label + TEST_PORT3 + + + type + message + + + vlen + 1 + + + optional + True + + + _coordinate + (695, 172) + + + _rotation + 0 + + + + pad_source_0_0 + gr_message_strobe_0 + 0 + 0 + + + pad_source_0 + gr_message_strobe_0 + 0 + 0 + + + gr_message_strobe_0 + pad_sink_0 + 0 + 0 + + + gr_message_strobe_0_1 + pad_sink_0 + 0 + 0 + + + gr_message_strobe_0_1 + pad_sink_0_0 + 0 + 0 + + diff --git a/gnuradio-core/src/examples/msg_passing/hier/test_msg_hier_topblock.grc b/gnuradio-core/src/examples/msg_passing/hier/test_msg_hier_topblock.grc new file mode 100644 index 000000000..f440b06b3 --- /dev/null +++ b/gnuradio-core/src/examples/msg_passing/hier/test_msg_hier_topblock.grc @@ -0,0 +1,185 @@ + + + Mon Dec 10 19:56:42 2012 + + options + + id + test_msg_hier_topblock + + + _enabled + True + + + title + + + + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + no_gui + + + category + Custom + + + run_options + prompt + + + run + True + + + max_nouts + 0 + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + gr_message_strobe + + id + gr_message_strobe_0_0 + + + _enabled + True + + + msg + pmt.pmt_intern("UPDATED2") + + + period + 3000 + + + _coordinate + (51, 88) + + + _rotation + 0 + + + + gr_message_strobe + + id + gr_message_strobe_0 + + + _enabled + True + + + msg + pmt.pmt_intern("UPDATED") + + + period + 2000 + + + _coordinate + (211, 168) + + + _rotation + 0 + + + + gr_message_debug + + id + gr_message_debug_0 + + + _enabled + True + + + _coordinate + (758, 71) + + + _rotation + 0 + + + + TEST_MSG_HIER + + id + TEST_MSG_HIER_0 + + + _enabled + True + + + _coordinate + (402, 52) + + + _rotation + 0 + + + + TEST_MSG_HIER_0 + gr_message_debug_0 + 0 + 0 + + + gr_message_strobe_0 + TEST_MSG_HIER_0 + 0 + 0 + + + gr_message_strobe_0_0 + TEST_MSG_HIER_0 + 0 + 1 + + + TEST_MSG_HIER_0 + gr_message_debug_0 + 0 + 1 + + + TEST_MSG_HIER_0 + gr_message_debug_0 + 1 + 0 + + diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc index c19863f34..9294a5dca 100644 --- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc +++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc @@ -362,6 +362,22 @@ gr_flat_flowgraph::make_block_vector(gr_basic_block_vector_t &blocks) } +void gr_flat_flowgraph::clear_endpoint(const gr_msg_endpoint &e, bool is_src){ + for(size_t i=0; i > resolved_endpoints; for(q = msg_edges.begin(); q != msg_edges.end(); q++) { if (GR_HIER_BLOCK2_DETAIL_DEBUG) std::cout << boost::format(" flattening edge ( %s, %s, %d) -> ( %s, %s, %d)\n") % q->src().block() % q->src().port() % q->src().is_hier() % q->dst().block() % q->dst().port() % q->dst().is_hier(); @@ -509,6 +511,7 @@ gr_hier_block2_detail::flatten_aux(gr_flat_flowgraph_sptr sfg) const if (GR_HIER_BLOCK2_DETAIL_DEBUG) std::cout << boost::format(" resolve hier output (%s, %s)") % q->dst().block() % q->dst().port() << std::endl; sfg->replace_endpoint( q->dst(), q->src(), true ); + resolved_endpoints.push_back(std::pair(q->dst(),true)); normal_connection = false; } @@ -516,6 +519,7 @@ gr_hier_block2_detail::flatten_aux(gr_flat_flowgraph_sptr sfg) const if (GR_HIER_BLOCK2_DETAIL_DEBUG) std::cout << boost::format(" resolve hier input (%s, %s)") % q->src().block() % q->src().port() << std::endl; sfg->replace_endpoint( q->src(), q->dst(), false ); + resolved_endpoints.push_back(std::pair(q->src(),false)); normal_connection = false; } @@ -524,6 +528,9 @@ gr_hier_block2_detail::flatten_aux(gr_flat_flowgraph_sptr sfg) const sfg->connect( q->src(), q->dst() ); } } + for(std::vector >::iterator it = resolved_endpoints.begin(); it != resolved_endpoints.end(); it++){ + sfg->clear_endpoint( (*it).first, (*it).second ); + } /* // connect primitive edges in the new fg for(q = msg_edges.begin(); q != msg_edges.end(); q++) { -- cgit