[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10871 - in gnuradio/trunk/gnuradio-core/src: lib/runt
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r10871 - in gnuradio/trunk/gnuradio-core/src: lib/runtime python/gnuradio/gr |
Date: |
Fri, 17 Apr 2009 14:30:56 -0600 (MDT) |
Author: jcorgan
Date: 2009-04-17 14:30:56 -0600 (Fri, 17 Apr 2009)
New Revision: 10871
Modified:
gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
Log:
Fixes ticket:383
Modified: gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
===================================================================
--- gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
2009-04-17 18:48:23 UTC (rev 10870)
+++ gnuradio/trunk/gnuradio-core/src/lib/runtime/gr_hier_block2_detail.cc
2009-04-17 20:30:56 UTC (rev 10871)
@@ -365,9 +365,12 @@
std::stringstream msg;
// Check if endpoint is a leaf node
- if (cast_to_block_sptr(endp.block()))
+ if (cast_to_block_sptr(endp.block())) {
+ if (GR_HIER_BLOCK2_DETAIL_DEBUG)
+ std::cout << "Block " << endp.block() << " is a leaf node, returning."
<< std::endl;
return endp;
-
+ }
+
// Check if endpoint is a hierarchical block
gr_hier_block2_sptr hier_block2(cast_to_hier_block2_sptr(endp.block()));
if (hier_block2) {
@@ -387,35 +390,53 @@
gr_hier_block2_detail::flatten_aux(gr_flat_flowgraph_sptr sfg) const
{
if (GR_HIER_BLOCK2_DETAIL_DEBUG)
- std::cout << "flattening " << d_owner->name() << std::endl;
+ std::cout << "Flattening " << d_owner->name() << std::endl;
// Add my edges to the flow graph, resolving references to actual endpoints
gr_edge_vector_t edges = d_fg->edges();
-
+
for (gr_edge_viter_t p = edges.begin(); p != edges.end(); p++) {
if (GR_HIER_BLOCK2_DETAIL_DEBUG)
std::cout << "Flattening edge " << (*p) << std::endl;
gr_endpoint src_endp = resolve_endpoint(p->src(), false);
gr_endpoint dst_endp = resolve_endpoint(p->dst(), true);
+
+ if (GR_HIER_BLOCK2_DETAIL_DEBUG) {
+ std::cout << "src_endp = " << src_endp
+ << ", dst_endp = " << dst_endp << std::endl;
+ }
+
sfg->connect(src_endp, dst_endp);
}
- // Construct unique list of blocks used either in edges or
- // by themselves. I hate STL.
+ // Construct unique list of blocks used either in edges, inputs,
+ // outputs, or by themselves. I still hate STL.
gr_basic_block_vector_t blocks, tmp = d_fg->calc_used_blocks();
- std::insert_iterator<gr_basic_block_vector_t> inserter(blocks,
blocks.begin());
+
std::vector<gr_basic_block_sptr>::const_iterator p; // Because flatten_aux
is const
for (p = d_blocks.begin(); p != d_blocks.end(); p++)
tmp.push_back(*p);
+
+ std::vector<gr_endpoint>::const_iterator e; // Because flatten_aux is const
+ for (e = d_inputs.begin(); e != d_inputs.end(); e++)
+ tmp.push_back((*e).block());
+ for (e = d_outputs.begin(); e != d_outputs.end(); e++)
+ tmp.push_back((*e).block());
+
sort(tmp.begin(), tmp.end());
+
+ std::insert_iterator<gr_basic_block_vector_t> inserter(blocks,
blocks.begin());
unique_copy(tmp.begin(), tmp.end(), inserter);
// Recurse hierarchical children
for (gr_basic_block_viter_t p = blocks.begin(); p != blocks.end(); p++) {
gr_hier_block2_sptr hier_block2(cast_to_hier_block2_sptr(*p));
- if (hier_block2)
+ if (hier_block2) {
+ if (GR_HIER_BLOCK2_DETAIL_DEBUG)
+ std::cout << "flatten_aux: recursing into hierarchical block " <<
hier_block2 << std::endl;
hier_block2->d_detail->flatten_aux(sfg);
+ }
}
}
Modified: gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
===================================================================
--- gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
2009-04-17 18:48:23 UTC (rev 10870)
+++ gnuradio/trunk/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py
2009-04-17 20:30:56 UTC (rev 10871)
@@ -273,6 +273,22 @@
tb.connect(src, dst)
tb.run()
self.assertEquals(dst.data(), (1,))
+
+ def test_030_nested_input(self):
+ tb = gr.top_block()
+ src = gr.vector_source_b([1,])
+ hb1 = gr.hier_block2("hb1",
+ gr.io_signature(1, 1, gr.sizeof_char),
+ gr.io_signature(0, 0, 0))
+ hb2 = gr.hier_block2("hb2",
+ gr.io_signature(1, 1, gr.sizeof_char),
+ gr.io_signature(0, 0, 0))
+ dst = gr.vector_sink_b()
+ tb.connect(gr.vector_source_b([1,]), hb1)
+ hb1.connect(hb1, hb2)
+ hb2.connect(hb2, gr.kludge_copy(gr.sizeof_char), dst)
+ tb.run()
+ self.assertEquals(dst.data(), (1,))
if __name__ == "__main__":
gr_unittest.main()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10871 - in gnuradio/trunk/gnuradio-core/src: lib/runtime python/gnuradio/gr,
jcorgan <=