summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/block_task.cpp2
-rw-r--r--lib/element.cpp2
-rw-r--r--lib/top_block.cpp7
-rw-r--r--swig/gr_message.i65
-rw-r--r--swig/gr_msg_handler.i32
-rw-r--r--swig/gr_msg_queue.i107
-rw-r--r--swig/runtime.i3
-rw-r--r--swig/sw_runtime.i3
8 files changed, 217 insertions, 4 deletions
diff --git a/lib/block_task.cpp b/lib/block_task.cpp
index 6954382..0dcfca4 100644
--- a/lib/block_task.cpp
+++ b/lib/block_task.cpp
@@ -61,11 +61,13 @@ void ElementImpl::mark_done(const tsbe::TaskInterface &task_iface)
task_iface.post_downstream(i, CheckTokensMessage());
}
+ /*
std::cout
<< "==================================================\n"
<< "== The " << name << " is done...\n"
<< "==================================================\n"
<< std::flush;
+ //*/
}
void ElementImpl::handle_task(const tsbe::TaskInterface &task_iface)
diff --git a/lib/element.cpp b/lib/element.cpp
index db0bbac..34cfcf4 100644
--- a/lib/element.cpp
+++ b/lib/element.cpp
@@ -30,7 +30,7 @@ Element::Element(void)
Element::Element(const std::string &name)
{
this->reset(new ElementImpl());
- VAR(name);
+ //VAR(name);
(*this)->name = name;
(*this)->unique_id = ++unique_id_pool;
diff --git a/lib/top_block.cpp b/lib/top_block.cpp
index e0751b5..ea86470 100644
--- a/lib/top_block.cpp
+++ b/lib/top_block.cpp
@@ -32,9 +32,11 @@ TopBlock::TopBlock(const std::string &name):
config.topology = (*this)->topology;
(*this)->executor = tsbe::Executor(config);
(*this)->token = Token::make();
+ /*
std::cout << "===================================================" << std::endl;
std::cout << "== Top Block Created: " << name << std::endl;
std::cout << "===================================================" << std::endl;
+ //*/
}
void ElementImpl::top_block_cleanup(void)
@@ -42,6 +44,11 @@ void ElementImpl::top_block_cleanup(void)
TopBlockMessage event;
event.what = TopBlockMessage::INERT;
this->executor.post_msg(event);
+ /*
+ std::cout << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" << std::endl;
+ std::cout << "xx Top Block Deleted: " << name << std::endl;
+ std::cout << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" << std::endl;
+ //*/
}
void TopBlock::update(void)
diff --git a/swig/gr_message.i b/swig/gr_message.i
new file mode 100644
index 0000000..356bba5
--- /dev/null
+++ b/swig/gr_message.i
@@ -0,0 +1,65 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005 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.
+ */
+
+class gr_message;
+typedef boost::shared_ptr<gr_message> gr_message_sptr;
+%template(gr_message_sptr) boost::shared_ptr<gr_message>;
+
+%rename(message_from_string) gr_make_message_from_string;
+gr_message_sptr
+gr_make_message_from_string(const std::string s, long type = 0, double arg1 = 0, double arg2 = 0);
+
+%rename(message) gr_make_message;
+gr_message_sptr
+gr_make_message(long type = 0, double arg1 = 0, double arg2 = 0, size_t length = 0);
+
+/*!
+ * \brief Message.
+ *
+ * The ideas and method names for adjustable message length were
+ * lifted from the click modular router "Packet" class.
+ */
+class gr_message {
+ gr_message (long type, double arg1, double arg2, size_t length);
+
+ unsigned char *buf_data() const { return d_buf_start; }
+ size_t buf_len() const { return d_buf_end - d_buf_start; }
+
+public:
+ ~gr_message ();
+
+ long type() const { return d_type; }
+ double arg1() const { return d_arg1; }
+ double arg2() const { return d_arg2; }
+
+ void set_type(long type) { d_type = type; }
+ void set_arg1(double arg1) { d_arg1 = arg1; }
+ void set_arg2(double arg2) { d_arg2 = arg2; }
+
+ size_t length() const;
+ std::string to_string() const;
+
+};
+
+%rename(message_ncurrently_allocated) gr_message_ncurrently_allocated;
+long gr_message_ncurrently_allocated();
+
diff --git a/swig/gr_msg_handler.i b/swig/gr_msg_handler.i
new file mode 100644
index 0000000..f493dac
--- /dev/null
+++ b/swig/gr_msg_handler.i
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005 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.
+ */
+
+/*!
+ * \brief abstract class of message handlers
+ */
+class gr_msg_handler {
+public:
+ virtual ~gr_msg_handler () = 0;
+
+ //! handle \p msg
+ virtual void handle (gr_message_sptr msg) = 0;
+};
diff --git a/swig/gr_msg_queue.i b/swig/gr_msg_queue.i
new file mode 100644
index 0000000..65cbe78
--- /dev/null
+++ b/swig/gr_msg_queue.i
@@ -0,0 +1,107 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005,2009,2010,2011 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.
+ */
+
+class gr_msg_queue;
+typedef boost::shared_ptr<gr_msg_queue> gr_msg_queue_sptr;
+%template(gr_msg_queue_sptr) boost::shared_ptr<gr_msg_queue>;
+
+%rename(msg_queue) gr_make_msg_queue;
+gr_msg_queue_sptr gr_make_msg_queue(unsigned limit=0);
+
+/*!
+ * \brief thread-safe message queue
+ */
+%ignore gr_msg_queue;
+class gr_msg_queue : public gr_msg_handler {
+public:
+ gr_msg_queue(unsigned int limit);
+ ~gr_msg_queue();
+
+ //! Generic msg_handler method: insert the message.
+ //void handle(gr_message_sptr msg) { insert_tail (msg); }
+
+ /*!
+ * \brief Insert message at tail of queue.
+ * \param msg message
+ *
+ * Block if queue if full.
+ */
+ //void insert_tail(gr_message_sptr msg);
+
+ /*!
+ * \brief Delete message from head of queue and return it.
+ * Block if no message is available.
+ */
+ //gr_message_sptr delete_head();
+
+ /*!
+ * \brief If there's a message in the q, delete it and return it.
+ * If no message is available, return 0.
+ */
+ gr_message_sptr delete_head_nowait();
+
+ //! is the queue empty?
+ bool empty_p() const;
+
+ //! is the queue full?
+ bool full_p() const;
+
+ //! return number of messages in queue
+ unsigned int count() const;
+
+ //! Delete all messages from the queue
+ void flush();
+};
+
+/*
+ * The following kludge-o-rama releases the Python global interpreter
+ * lock around these potentially blocking calls. We don't want
+ * libgnuradio-core to be dependent on Python, thus we create these
+ * functions that serve as replacements for the normal C++ delete_head
+ * and insert_tail methods. The %pythoncode smashes these new C++
+ * functions into the gr.msg_queue wrapper class, so that everything
+ * appears normal. (An evil laugh is heard in the distance...)
+ */
+#ifdef SWIGPYTHON
+%inline %{
+ gr_message_sptr gr_py_msg_queue__delete_head(gr_msg_queue_sptr q) {
+ gr_message_sptr msg;
+ GR_PYTHON_BLOCKING_CODE(
+ msg = q->delete_head();
+ )
+ return msg;
+ }
+
+ void gr_py_msg_queue__insert_tail(gr_msg_queue_sptr q, gr_message_sptr msg) {
+ GR_PYTHON_BLOCKING_CODE(
+ q->insert_tail(msg);
+ )
+ }
+%}
+
+// smash in new python delete_head and insert_tail methods...
+%pythoncode %{
+gr_msg_queue_sptr.delete_head = gr_py_msg_queue__delete_head
+gr_msg_queue_sptr.insert_tail = gr_py_msg_queue__insert_tail
+gr_msg_queue_sptr.handle = gr_py_msg_queue__insert_tail
+%}
+#endif // SWIGPYTHON
diff --git a/swig/runtime.i b/swig/runtime.i
index 4ab380e..bc2525e 100644
--- a/swig/runtime.i
+++ b/swig/runtime.i
@@ -40,6 +40,9 @@
%}
+%include <gr_message.i>
+%include <gr_msg_handler.i>
+%include <gr_msg_queue.i>
%include <gr_swig_block_magic.i>
#ifdef SW_RUNTIME
diff --git a/swig/sw_runtime.i b/swig/sw_runtime.i
index b40d142..88fd591 100644
--- a/swig/sw_runtime.i
+++ b/swig/sw_runtime.i
@@ -34,9 +34,6 @@
%include <gnuradio/io_signature.hpp>
%include <gr_io_signature.h>
%include <gr_block.h>
-%include <gr_message.h>
-%include <gr_msg_handler.h>
-%include <gr_msg_queue.h>
%include <gr_sync_block.h>
%include <gr_sync_decimator.h>
%include <gr_sync_interpolator.h>