summaryrefslogtreecommitdiff
path: root/gnuradio-core
diff options
context:
space:
mode:
authorTim O'Shea2012-12-10 19:56:54 -0500
committerTom Rondeau2012-12-12 14:16:51 -0500
commit74817aee3eda6a8878b14e016091277d978b8cb5 (patch)
tree1f0917fa907529079a06de4dcd26795a4da5455e /gnuradio-core
parent60c60b02cd1f22d7d52fcc5da313635fd8dbed01 (diff)
downloadgnuradio-74817aee3eda6a8878b14e016091277d978b8cb5.tar.gz
gnuradio-74817aee3eda6a8878b14e016091277d978b8cb5.tar.bz2
gnuradio-74817aee3eda6a8878b14e016091277d978b8cb5.zip
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
Diffstat (limited to 'gnuradio-core')
-rw-r--r--gnuradio-core/src/examples/msg_passing/hier/test_msg_hier.grc287
-rw-r--r--gnuradio-core/src/examples/msg_passing/hier/test_msg_hier_topblock.grc185
-rw-r--r--gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc25
-rw-r--r--gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h1
-rw-r--r--gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc7
5 files changed, 502 insertions, 3 deletions
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 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+ <timestamp>Mon Dec 10 19:56:24 2012</timestamp>
+ <block>
+ <key>options</key>
+ <param>
+ <key>id</key>
+ <value>test_msg_hier</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>title</key>
+ <value></value>
+ </param>
+ <param>
+ <key>author</key>
+ <value></value>
+ </param>
+ <param>
+ <key>description</key>
+ <value></value>
+ </param>
+ <param>
+ <key>window_size</key>
+ <value>1280, 1024</value>
+ </param>
+ <param>
+ <key>generate_options</key>
+ <value>hb</value>
+ </param>
+ <param>
+ <key>category</key>
+ <value>Custom</value>
+ </param>
+ <param>
+ <key>run_options</key>
+ <value>prompt</value>
+ </param>
+ <param>
+ <key>run</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>max_nouts</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>realtime_scheduling</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(10, 10)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>pad_source</key>
+ <param>
+ <key>id</key>
+ <value>pad_source_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>label</key>
+ <value>TEST_PORT</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>message</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>optional</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(234, 145)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>pad_source</key>
+ <param>
+ <key>id</key>
+ <value>pad_source_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>label</key>
+ <value>TEST_PORT2</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>message</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>optional</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(167, 54)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_message_strobe</key>
+ <param>
+ <key>id</key>
+ <value>gr_message_strobe_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>msg</key>
+ <value>pmt.pmt_cons(pmt.PMT_NIL, pmt.pmt_make_u8vector(16,0x77))</value>
+ </param>
+ <param>
+ <key>period</key>
+ <value>200</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(362, 81)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>pad_sink</key>
+ <param>
+ <key>id</key>
+ <value>pad_sink_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>label</key>
+ <value>TEST_PORT</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>message</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>optional</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(618, 87)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_message_strobe</key>
+ <param>
+ <key>id</key>
+ <value>gr_message_strobe_0_1</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>msg</key>
+ <value>pmt.pmt_intern("OUTPUT2")</value>
+ </param>
+ <param>
+ <key>period</key>
+ <value>100</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(400, 156)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>pad_sink</key>
+ <param>
+ <key>id</key>
+ <value>pad_sink_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>label</key>
+ <value>TEST_PORT3</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>message</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>optional</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(695, 172)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <connection>
+ <source_block_id>pad_source_0_0</source_block_id>
+ <sink_block_id>gr_message_strobe_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>pad_source_0</source_block_id>
+ <sink_block_id>gr_message_strobe_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_message_strobe_0</source_block_id>
+ <sink_block_id>pad_sink_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_message_strobe_0_1</source_block_id>
+ <sink_block_id>pad_sink_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_message_strobe_0_1</source_block_id>
+ <sink_block_id>pad_sink_0_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+</flow_graph>
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 @@
+<?xml version='1.0' encoding='ASCII'?>
+<flow_graph>
+ <timestamp>Mon Dec 10 19:56:42 2012</timestamp>
+ <block>
+ <key>options</key>
+ <param>
+ <key>id</key>
+ <value>test_msg_hier_topblock</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>title</key>
+ <value></value>
+ </param>
+ <param>
+ <key>author</key>
+ <value></value>
+ </param>
+ <param>
+ <key>description</key>
+ <value></value>
+ </param>
+ <param>
+ <key>window_size</key>
+ <value>1280, 1024</value>
+ </param>
+ <param>
+ <key>generate_options</key>
+ <value>no_gui</value>
+ </param>
+ <param>
+ <key>category</key>
+ <value>Custom</value>
+ </param>
+ <param>
+ <key>run_options</key>
+ <value>prompt</value>
+ </param>
+ <param>
+ <key>run</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>max_nouts</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>realtime_scheduling</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(10, 10)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_message_strobe</key>
+ <param>
+ <key>id</key>
+ <value>gr_message_strobe_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>msg</key>
+ <value>pmt.pmt_intern("UPDATED2")</value>
+ </param>
+ <param>
+ <key>period</key>
+ <value>3000</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(51, 88)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_message_strobe</key>
+ <param>
+ <key>id</key>
+ <value>gr_message_strobe_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>msg</key>
+ <value>pmt.pmt_intern("UPDATED")</value>
+ </param>
+ <param>
+ <key>period</key>
+ <value>2000</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(211, 168)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>gr_message_debug</key>
+ <param>
+ <key>id</key>
+ <value>gr_message_debug_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(758, 71)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>TEST_MSG_HIER</key>
+ <param>
+ <key>id</key>
+ <value>TEST_MSG_HIER_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(402, 52)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <connection>
+ <source_block_id>TEST_MSG_HIER_0</source_block_id>
+ <sink_block_id>gr_message_debug_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_message_strobe_0</source_block_id>
+ <sink_block_id>TEST_MSG_HIER_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>gr_message_strobe_0_0</source_block_id>
+ <sink_block_id>TEST_MSG_HIER_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>1</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>TEST_MSG_HIER_0</source_block_id>
+ <sink_block_id>gr_message_debug_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>1</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>TEST_MSG_HIER_0</source_block_id>
+ <sink_block_id>gr_message_debug_0</sink_block_id>
+ <source_key>1</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+</flow_graph>
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<d_msg_edges.size(); i++){
+ if(is_src){
+ if(d_msg_edges[i].src() == e){
+ d_msg_edges.erase(d_msg_edges.begin() + i);
+ i--;
+ }
+ } else {
+ if(d_msg_edges[i].dst() == e){
+ d_msg_edges.erase(d_msg_edges.begin() + i);
+ i--;
+ }
+ }
+ }
+}
+
void gr_flat_flowgraph::replace_endpoint(const gr_msg_endpoint &e, const gr_msg_endpoint &r, bool is_src){
size_t n_replr(0);
if(GR_FLAT_FLOWGRAPH_DEBUG)
@@ -369,16 +385,19 @@ void gr_flat_flowgraph::replace_endpoint(const gr_msg_endpoint &e, const gr_msg_
for(size_t i=0; i<d_msg_edges.size(); i++){
if(is_src){
if(d_msg_edges[i].src() == e){
- d_msg_edges[i] = gr_msg_edge(r, d_msg_edges[i].dst() );
+ if(GR_FLAT_FLOWGRAPH_DEBUG)
+ std::cout << boost::format("gr_flat_flowgraph::replace_endpoint() flattening to ( %s, %s )\n") % r.block()% d_msg_edges[i].dst().block();
+ d_msg_edges.push_back( gr_msg_edge(r, d_msg_edges[i].dst() ) );
n_replr++;
}
} else {
if(d_msg_edges[i].dst() == e){
- d_msg_edges[i] = gr_msg_edge(d_msg_edges[i].src(), r );
+ if(GR_FLAT_FLOWGRAPH_DEBUG)
+ std::cout << boost::format("gr_flat_flowgraph::replace_endpoint() flattening to ( %s, %s )\n") % r.block()% d_msg_edges[i].dst().block();
+ d_msg_edges.push_back( gr_msg_edge(d_msg_edges[i].src(), r ) );
n_replr++;
}
}
}
-// std::cout << "n_repl = " << n_repl <<"\n";
}
diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h
index 52f202334..5c8268d7d 100644
--- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h
+++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h
@@ -58,6 +58,7 @@ public:
static gr_block_vector_t make_block_vector(gr_basic_block_vector_t &blocks);
void replace_endpoint(const gr_msg_endpoint &e, const gr_msg_endpoint &r, bool is_src);
+ void clear_endpoint(const gr_msg_endpoint &e, bool is_src);
private:
gr_flat_flowgraph();
diff --git a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
index e70553ddc..add6da024 100644
--- a/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
+++ b/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
@@ -498,6 +498,8 @@ gr_hier_block2_detail::flatten_aux(gr_flat_flowgraph_sptr sfg) const
if (GR_HIER_BLOCK2_DETAIL_DEBUG)
std::cout << "Flattening msg connections: " << std::endl;
+
+ std::vector<std::pair<gr_msg_endpoint, bool> > 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<gr_msg_endpoint, bool>(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<gr_msg_endpoint, bool>(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<std::pair<gr_msg_endpoint, bool> >::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++) {