summaryrefslogtreecommitdiff
path: root/gnuradio-runtime
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2015-07-06 16:05:42 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2015-07-06 16:05:42 -0700
commit9c91a38f0dad9e0bacb96b87f6793c13522d00b2 (patch)
tree250ec6c5e285678701322773fb814baeed300c03 /gnuradio-runtime
parent8ef1ea6d5e1781379473a1990ca30e3833f49c0c (diff)
parent1185d401caf8f420b93754398675d012f08ef68f (diff)
Merge branch 'master' into next
Diffstat (limited to 'gnuradio-runtime')
-rw-r--r--gnuradio-runtime/include/gnuradio/flowgraph.h76
-rw-r--r--gnuradio-runtime/python/gnuradio/CMakeLists.txt1
-rw-r--r--gnuradio-runtime/python/gnuradio/eng_arg.py53
3 files changed, 115 insertions, 15 deletions
diff --git a/gnuradio-runtime/include/gnuradio/flowgraph.h b/gnuradio-runtime/include/gnuradio/flowgraph.h
index 452a20cbc6..280c01fc28 100644
--- a/gnuradio-runtime/include/gnuradio/flowgraph.h
+++ b/gnuradio-runtime/include/gnuradio/flowgraph.h
@@ -146,49 +146,95 @@ namespace gr {
public:
friend GR_RUNTIME_API flowgraph_sptr make_flowgraph();
- // Destruct an arbitrary flowgraph
+ /*!
+ * \brief Destruct an arbitrary flowgraph
+ */
virtual ~flowgraph();
- // Connect two endpoints
+ /*!
+ * \brief Connect two endpoints
+ * \details
+ * Checks the validity of both endpoints, and whether the
+ * destination is unused so far, then adds the edge to the internal list of
+ * edges.
+ */
void connect(const endpoint &src, const endpoint &dst);
- // Disconnect two endpoints
+ /*!
+ * \brief Disconnect two endpoints
+ */
void disconnect(const endpoint &src, const endpoint &dst);
- // Connect an output port to an input port (convenience)
+ /*!
+ * \brief convenience wrapper; used to connect two endpoints
+ */
void connect(basic_block_sptr src_block, int src_port,
basic_block_sptr dst_block, int dst_port);
- // Disconnect an input port from an output port (convenience)
+ /*!
+ * \brief convenience wrapper; used to disconnect two endpoints
+ */
void disconnect(basic_block_sptr src_block, int src_port,
basic_block_sptr dst_block, int dst_port);
- // Connect two msg endpoints
+ /*!
+ * \brief Connect two message endpoints
+ * \details
+ * Checks the validity of both endpoints, then adds the edge to the
+ * internal list of edges.
+ */
void connect(const msg_endpoint &src, const msg_endpoint &dst);
- // Disconnect two msg endpoints
+ /*!
+ * \brief Disconnect two message endpoints
+ */
void disconnect(const msg_endpoint &src, const msg_endpoint &dst);
- // Validate connectivity, raise exception if invalid
+ /*!
+ * \brief Validate flow graph
+ * \details
+ * Gathers all used blocks, checks the contiguity of all connected in- and
+ * outputs, and calls the check_topology method of each block.
+ */
void validate();
- // Clear existing flowgraph
+ /*!
+ * \brief Clear existing flowgraph
+ */
void clear();
- // Return vector of edges
+ /*!
+ * \brief Get vector of edges
+ */
const edge_vector_t &edges() const { return d_edges; }
- // Return vector of msg edges
+ /*!
+ * \brief Get vector of message edges
+ */
const msg_edge_vector_t &msg_edges() const { return d_msg_edges; }
- // Return vector of connected blocks
+ /*!
+ * \brief calculates all used blocks in a flow graph
+ * \details
+ * Iterates over all message edges and stream edges, noting both endpoints in a vector.
+ *
+ * \return a unique vector of used blocks
+ */
basic_block_vector_t calc_used_blocks();
- // Return toplogically sorted vector of blocks. All the sources come first.
+ /*!
+ * \brief topologically sort blocks
+ * \details
+ * Uses depth-first search to return a sorted vector of blocks
+ *
+ * \return toplogically sorted vector of blocks. All the sources come first.
+ */
basic_block_vector_t topological_sort(basic_block_vector_t &blocks);
- // Return vector of vectors of disjointly connected blocks,
- // topologically sorted.
+ /*!
+ * \brief Calculate vector of disjoint graph partions
+ * \return vector of disjoint vectors of topologically sorted blocks
+ */
std::vector<basic_block_vector_t> partition();
protected:
diff --git a/gnuradio-runtime/python/gnuradio/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/CMakeLists.txt
index bd566edf14..d29e6aa9d2 100644
--- a/gnuradio-runtime/python/gnuradio/CMakeLists.txt
+++ b/gnuradio-runtime/python/gnuradio/CMakeLists.txt
@@ -31,6 +31,7 @@ GR_PYTHON_INSTALL(FILES
__init__.py
eng_notation.py
eng_option.py
+ eng_arg.py
gr_unittest.py
gr_xmlrunner.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio
diff --git a/gnuradio-runtime/python/gnuradio/eng_arg.py b/gnuradio-runtime/python/gnuradio/eng_arg.py
new file mode 100644
index 0000000000..05cd8a1f2a
--- /dev/null
+++ b/gnuradio-runtime/python/gnuradio/eng_arg.py
@@ -0,0 +1,53 @@
+#
+# Copyright 2015 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+'''
+Add support for engineering notation to argparse.ArgumentParser
+'''
+
+import argparse
+from gnuradio import eng_notation
+
+def intx(string):
+ """
+ Generic integer type, will interpret string as string literal.
+ Does the right thing for 0x1F, 0b10101, 010.
+ """
+ try:
+ return int(string, 0)
+ except:
+ raise argparse.ArgumentTypeError(
+ "Invalid integer value: {}".format(string)
+ )
+
+def eng_float(string):
+ """
+ Takes a string, returns a float. Accepts engineering notation.
+ Designed for use with argparse.ArgumentParser.
+ Will raise an ArgumentTypeError if not possible.
+ """
+ try:
+ return eng_notation.str_to_num(string)
+ except:
+ raise argparse.ArgumentTypeError(
+ "Invalid engineering notation value: {}".format(string)
+ )
+