summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/runtime
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-02-22 16:11:33 -0500
committerTom Rondeau <trondeau@vt.edu>2013-02-22 16:11:33 -0500
commita55dfd53d9b6a05016425448a1379fb599d3f0df (patch)
tree3a325719fe6d880f9f2c731dfcedcefff2619b54 /gnuradio-core/src/lib/runtime
parentff512cc1877adfa854ade0371726a136493d8dbb (diff)
core: adds a function to top_block to get a list of edges as a string.
Also exports it through ControlPort.
Diffstat (limited to 'gnuradio-core/src/lib/runtime')
-rw-r--r--gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc9
-rw-r--r--gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h3
-rw-r--r--gnuradio-core/src/lib/runtime/gr_flowgraph.h2
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block.cc19
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block.h6
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block.i1
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block_impl.cc9
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block_impl.h3
8 files changed, 51 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
index cc49091ddc..de1e227ef0 100644
--- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
+++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.cc
@@ -325,6 +325,15 @@ gr_flat_flowgraph::setup_buffer_alignment(gr_block_sptr block)
}
}
+std::string
+gr_flat_flowgraph::edge_list()
+{
+ std::stringstream s;
+ for(gr_edge_viter_t e = d_edges.begin(); e != d_edges.end(); e++)
+ s << (*e) << std::endl;
+ return s.str();
+}
+
void gr_flat_flowgraph::dump()
{
for (gr_edge_viter_t e = d_edges.begin(); e != d_edges.end(); e++)
diff --git a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h
index 031564f2ec..3cd3228f41 100644
--- a/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h
+++ b/gnuradio-core/src/lib/runtime/gr_flat_flowgraph.h
@@ -50,6 +50,9 @@ public:
// Merge applicable connections from existing flat flowgraph
void merge_connections(gr_flat_flowgraph_sptr sfg);
+ // Return a string list of edges
+ std::string edge_list();
+
void dump();
/*!
diff --git a/gnuradio-core/src/lib/runtime/gr_flowgraph.h b/gnuradio-core/src/lib/runtime/gr_flowgraph.h
index 3c8cd3cb02..40e9dc3675 100644
--- a/gnuradio-core/src/lib/runtime/gr_flowgraph.h
+++ b/gnuradio-core/src/lib/runtime/gr_flowgraph.h
@@ -237,7 +237,7 @@ void gr_flowgraph::disconnect(gr_basic_block_sptr src_block, int src_port,
inline std::ostream&
operator <<(std::ostream &os, const gr_endpoint endp)
{
- os << endp.block() << ":" << endp.port();
+ os << endp.block()->alias() << ":" << endp.port();
return os;
}
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.cc b/gnuradio-core/src/lib/runtime/gr_top_block.cc
index f41fb4ebd8..e5859768de 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block.cc
+++ b/gnuradio-core/src/lib/runtime/gr_top_block.cc
@@ -28,6 +28,7 @@
#include <gr_top_block.h>
#include <gr_top_block_impl.h>
#include <gr_io_signature.h>
+#include <gr_prefs.h>
#include <iostream>
gr_top_block_sptr
@@ -57,6 +58,10 @@ void
gr_top_block::start(int max_noutput_items)
{
d_impl->start(max_noutput_items);
+
+ if(gr_prefs::singleton()->get_bool("ControlPort", "on", false)) {
+ setup_rpc();
+ }
}
void
@@ -90,6 +95,12 @@ gr_top_block::unlock()
d_impl->unlock();
}
+std::string
+gr_top_block::edge_list()
+{
+ return d_impl->edge_list();
+}
+
void
gr_top_block::dump()
{
@@ -127,6 +138,14 @@ gr_top_block::setup_rpc()
"items", "Max number of output items",
RPC_PRIVLVL_MIN, DISPNULL)));
+ add_rpc_variable(
+ rpcbasic_sptr(new rpcbasic_register_get<gr_top_block, std::string>(
+ alias(), "edge list",
+ &gr_top_block::edge_list,
+ pmt::mp(""), pmt::mp(""), pmt::mp(""),
+ "edges", "List of edges in the graph",
+ RPC_PRIVLVL_MIN, DISPNULL)));
+
// Setters
add_rpc_variable(
rpcbasic_sptr(new rpcbasic_register_set<gr_top_block, int>(
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.h b/gnuradio-core/src/lib/runtime/gr_top_block.h
index 10a21a6434..cb99752f37 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block.h
+++ b/gnuradio-core/src/lib/runtime/gr_top_block.h
@@ -112,6 +112,12 @@ public:
virtual void unlock();
/*!
+ * Returns a string that lists the edge connections in the flattened
+ * flowgraph.
+ */
+ std::string edge_list();
+
+ /*!
* Displays flattened flowgraph edges and block connectivity
*/
void dump();
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.i b/gnuradio-core/src/lib/runtime/gr_top_block.i
index 024582a301..1612ddf8c5 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block.i
+++ b/gnuradio-core/src/lib/runtime/gr_top_block.i
@@ -44,6 +44,7 @@ public:
//void run() throw (std::runtime_error);
void lock();
void unlock() throw (std::runtime_error);
+ std::string edge_list();
void dump();
int max_noutput_items();
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc b/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
index 7a8e359bf1..b6d427ce27 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
+++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
@@ -182,6 +182,15 @@ gr_top_block_impl::restart()
d_state = RUNNING;
}
+std::string
+gr_top_block_impl::edge_list()
+{
+ if(d_ffg)
+ return d_ffg->edge_list();
+ else
+ return "";
+}
+
void
gr_top_block_impl::dump()
{
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h
index c49bdabff6..3e4da332ae 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h
+++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h
@@ -56,6 +56,9 @@ public:
// Unlock the top block at end of reconfiguration
void unlock();
+ // Return a string list of edges
+ std::string edge_list();
+
// Dump the flowgraph to stdout
void dump();