diff options
-rw-r--r-- | TODO.txt | 11 | ||||
-rw-r--r-- | include/gnuradio/element.hpp | 3 | ||||
-rw-r--r-- | include/gnuradio/top_block.hpp | 2 | ||||
-rw-r--r-- | lib/element.cpp | 5 | ||||
-rw-r--r-- | lib/gr_top_block.cpp | 3 | ||||
-rw-r--r-- | swig/runtime.i | 5 | ||||
-rw-r--r-- | swig/sw_runtime.i | 87 |
7 files changed, 113 insertions, 3 deletions
@@ -1,11 +1,20 @@ +######################################################################## +## The GRAS TODO list +######################################################################## + * handle forecast * handle items multiple * handle calculating noutputitems using ninputs as a constraint * handle history ** test implementation -** stop output flush on mini history buffer +* allocation +** hooks for advanced allocation +** intelligent sizing of buffers +** communicate upstream requirements? +** communicate downstream requirements? * python wrappers for hier_block and top_block * python wrapper for block will come from grextras +* python wrapper should set weak_self somehow * bring in numanuma ** thread prio ** thread affinity diff --git a/include/gnuradio/element.hpp b/include/gnuradio/element.hpp index 4907467..51c79b8 100644 --- a/include/gnuradio/element.hpp +++ b/include/gnuradio/element.hpp @@ -51,6 +51,9 @@ struct GR_RUNTIME_API Element : boost::shared_ptr<ElementImpl> weak_self = elem; } + //! Get the derived class as an element + const Element &get_base(void) const; + //! for internal use only boost::weak_ptr<Element> weak_self; diff --git a/include/gnuradio/top_block.hpp b/include/gnuradio/top_block.hpp index bdc1ff9..5b3e9a2 100644 --- a/include/gnuradio/top_block.hpp +++ b/include/gnuradio/top_block.hpp @@ -68,7 +68,7 @@ struct GR_RUNTIME_API TopBlock : HierBlock void stop(void); //! Wait for threads to exit after stop() - void wait(void); + virtual void wait(void); }; } //namespace gnuradio diff --git a/lib/element.cpp b/lib/element.cpp index addc04d..861a2dc 100644 --- a/lib/element.cpp +++ b/lib/element.cpp @@ -46,6 +46,11 @@ ElementImpl::~ElementImpl(void) if (this->topology) this->hier_block_cleanup(); } +const Element &Element::get_base(void) const +{ + return *this; +} + long Element::unique_id(void) const { return (*this)->unique_id; diff --git a/lib/gr_top_block.cpp b/lib/gr_top_block.cpp index 238a643..9c4b68e 100644 --- a/lib/gr_top_block.cpp +++ b/lib/gr_top_block.cpp @@ -17,7 +17,8 @@ #include <gr_top_block.h> gr_top_block::gr_top_block(void): - gnuradio::TopBlock() + //cannot make a null top block, use name constructor + gnuradio::TopBlock("top") { //NOP } diff --git a/swig/runtime.i b/swig/runtime.i index d029501..6b41aa3 100644 --- a/swig/runtime.i +++ b/swig/runtime.i @@ -77,3 +77,8 @@ %include <gr_sync_interpolator.h> %include <gr_top_block.h> +#ifdef SW_RUNTIME + +%include "sw_runtime.i" + +#endif diff --git a/swig/sw_runtime.i b/swig/sw_runtime.i new file mode 100644 index 0000000..e8df947 --- /dev/null +++ b/swig/sw_runtime.i @@ -0,0 +1,87 @@ +// +// Copyright 2012 Josh Blum +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. + +%include "gruel_common.i" + +%inline %{ + +namespace gnuradio +{ + +struct TopBlockPython : TopBlock +{ + TopBlockPython(void): + TopBlock("top") + { + //NOP + } + + TopBlockPython(const std::string &name): + TopBlock(name) + { + //NOP + } + + void wait(void) + { + GR_PYTHON_BLOCKING_CODE + ( + TopBlock::wait(); + ) + } +}; +} + +%} + +%pythoncode %{ + +def internal_connect__(fcn, obj, *args): + + if len(args) == 1: + fcn(obj, args[0].get_base()) + return + + for src, sink in zip(args, args[1:]): + try: src, src_index = src + except: src_index = 0 + try: sink, sink_index = sink + except: sink_index = 0 + fcn(obj, src.get_base(), src_index, sink.get_base(), sink_index) + +class top_block(TopBlockPython): + def __init__(self, *args, **kwargs): + TopBlockPython.__init__(self, *args, **kwargs) + + def connect(self, *args): + return internal_connect__(TopBlockPython.connect, self, *args) + + def disconnect(self, *args): + return internal_connect__(TopBlockPython.disconnect, self, *args) + +class hier_block(HierBlock): + def __init__(self, *args, **kwargs): + HierBlock.__init__(self, *args, **kwargs) + + def connect(self, *args): + return internal_connect__(HierBlock.connect, self, *args) + + def disconnect(self, *args): + return internal_connect__(HierBlock.disconnect, self, *args) + +hier_block2 = hier_block + +%} |