summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/flowgraph.cc
diff options
context:
space:
mode:
authorJohannes Schmitz <schmitz@ti.rwth-aachen.de>2014-03-07 12:31:52 -0500
committerTom Rondeau <tom@trondeau.com>2014-03-07 12:31:52 -0500
commit216799215efaaec72aa2d60f230f90f836196d51 (patch)
treec2e404764653ee3858f0932490a79c7c2ed3ccb4 /gnuradio-runtime/lib/flowgraph.cc
parent0f18a39b39f74eb01865e59b5e7e1896f47d8197 (diff)
runtime: adds ability to output flowgraph in dot format (resolves issue 245).
Diffstat (limited to 'gnuradio-runtime/lib/flowgraph.cc')
-rw-r--r--gnuradio-runtime/lib/flowgraph.cc33
1 files changed, 31 insertions, 2 deletions
diff --git a/gnuradio-runtime/lib/flowgraph.cc b/gnuradio-runtime/lib/flowgraph.cc
index 634236dea0..3d8dfea65a 100644
--- a/gnuradio-runtime/lib/flowgraph.cc
+++ b/gnuradio-runtime/lib/flowgraph.cc
@@ -149,7 +149,7 @@ namespace gr {
}
}
- void
+ void
flowgraph::check_valid_port(const msg_endpoint &e)
{
if(FLOWGRAPH_DEBUG)
@@ -496,7 +496,7 @@ namespace gr {
check_valid_port(src);
check_valid_port(dst);
for(msg_edge_viter_t p = d_msg_edges.begin(); p != d_msg_edges.end(); p++) {
- if(p->src() == src && p->dst() == dst){
+ if(p->src() == src && p->dst() == dst){
throw std::runtime_error("connect called on already connected edge!");
}
}
@@ -517,4 +517,33 @@ namespace gr {
throw std::runtime_error("disconnect called on non-connected edge!");
}
+ std::string
+ dot_graph_fg(flowgraph_sptr fg)
+ {
+ basic_block_vector_t blocks = fg->calc_used_blocks();
+ edge_vector_t edges = fg->edges();
+
+ std::stringstream out;
+
+ out << "digraph flowgraph {" << std::endl;
+
+ // Define nodes and set labels
+ for(basic_block_viter_t block = blocks.begin(); block != blocks.end(); ++block) {
+ out << (*block)->unique_id()
+ << " [ label=\"" << (*block)->name() << "\" ]"
+ << std::endl;
+ }
+
+ // Define edges
+ for(edge_viter_t edge = edges.begin(); edge != edges.end(); ++edge) {
+ out << edge->src().block()->unique_id()
+ << " -> "
+ << edge->dst().block()->unique_id() << std::endl;
+ }
+
+ out << "}" << std::endl;
+
+ return out.str();
+ }
+
} /* namespace gr */