commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 01/01: runtime: addes get_tags_in_window to


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/01: runtime: addes get_tags_in_window to block_gateway for python blocks. Added QA.
Date: Thu, 26 Jun 2014 20:29:11 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch maint
in repository gnuradio.

commit a6bf31afb3e2bb1c3bd70cdcc66d393ff6d5feb6
Author: Tom Rondeau <address@hidden>
Date:   Thu Jun 26 16:27:26 2014 -0400

    runtime: addes get_tags_in_window to block_gateway for python blocks. Added 
QA.
    
    Addresses Issue #683.
---
 gnuradio-runtime/include/gnuradio/block_gateway.h | 29 +++++++++++++++++++----
 gr-blocks/python/blocks/qa_block_gateway.py       | 26 ++++++++++++++++++--
 2 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/gnuradio-runtime/include/gnuradio/block_gateway.h 
b/gnuradio-runtime/include/gnuradio/block_gateway.h
index b89afab..8a6fa9d 100644
--- a/gnuradio-runtime/include/gnuradio/block_gateway.h
+++ b/gnuradio-runtime/include/gnuradio/block_gateway.h
@@ -28,7 +28,7 @@
 #include <gnuradio/feval.h>
 
 namespace gr {
-  
+
   /*!
    * The work type enum tells the gateway what kind of block to
    * implement.  The choices are familiar gnuradio block overloads
@@ -94,7 +94,7 @@ namespace gr {
   public:
     // gr::block_gateway::sptr
     typedef boost::shared_ptr<block_gateway> sptr;
-    
+
     /*!
      * Make a new gateway block.
      * \param handler the swig director object with callback
@@ -218,6 +218,25 @@ namespace gr {
       return tags;
     }
 
+    std::vector<tag_t> block__get_tags_in_window(unsigned int which_input,
+                                                 uint64_t rel_start,
+                                                 uint64_t rel_end)
+    {
+      std::vector<gr::tag_t> tags;
+      gr::block::get_tags_in_window(tags, which_input, rel_start, rel_end);
+      return tags;
+    }
+
+    std::vector<tag_t> block__get_tags_in_window(unsigned int which_input,
+                                                 uint64_t rel_start,
+                                                 uint64_t rel_end,
+                                                 const pmt::pmt_t &key)
+    {
+      std::vector<gr::tag_t> tags;
+      gr::block::get_tags_in_window(tags, which_input, rel_start, rel_end, 
key);
+      return tags;
+    }
+
     /* Message passing interface */
     void block__message_port_register_in(pmt::pmt_t port_id) {
       gr::basic_block::message_port_register_in(port_id);
@@ -242,7 +261,7 @@ namespace gr {
     pmt::pmt_t block__message_subscribers(pmt::pmt_t which_port) {
       return gr::basic_block::message_subscribers(which_port);
     }
-    
+
     pmt::pmt_t block__message_ports_in() {
       return gr::basic_block::message_ports_in();
     }
@@ -254,7 +273,7 @@ namespace gr {
     void set_msg_handler_feval(pmt::pmt_t which_port, gr::feval_p *msg_handler)
     {
       if(msg_queue.find(which_port) == msg_queue.end()) {
-        throw std::runtime_error("attempt to set_msg_handler_feval() on bad 
input message port!"); 
+        throw std::runtime_error("attempt to set_msg_handler_feval() on bad 
input message port!");
       }
       d_msg_handlers_feval[which_port] = msg_handler;
     }
@@ -267,7 +286,7 @@ namespace gr {
     {
       return (d_msg_handlers_feval.find(which_port) != 
d_msg_handlers_feval.end());
     }
-    
+
     void dispatch_msg(pmt::pmt_t which_port, pmt::pmt_t msg)
     {
       // Is there a handler?
diff --git a/gr-blocks/python/blocks/qa_block_gateway.py 
b/gr-blocks/python/blocks/qa_block_gateway.py
index f62726a..1e848cf 100644
--- a/gr-blocks/python/blocks/qa_block_gateway.py
+++ b/gr-blocks/python/blocks/qa_block_gateway.py
@@ -146,6 +146,20 @@ class tag_sink(gr.sync_block):
 
         return num_input_items
 
+class tag_sink_win(gr.sync_block):
+    def __init__(self):
+        gr.sync_block.__init__(self, name = "tag sink",
+                               in_sig = [numpy.float32],
+                               out_sig = None)
+        self.key = None
+
+    def work(self, input_items, output_items):
+        num_input_items = len(input_items[0])
+        tags = self.get_tags_in_window(0, 0, num_input_items)
+        for tag in tags:
+            self.key = pmt.symbol_to_string(tag.key)
+        return num_input_items
+
 class fc32_to_f32_2(gr.sync_block):
     def __init__(self):
         gr.sync_block.__init__(
@@ -177,7 +191,7 @@ class vector_to_stream(gr.interp_block):
             for j in xrange(self.block_size):
                 output_items[0][n] = input_items[0][i][j]
                 n += 1
-      
+
         return len(output_items[0])
 
 class test_block_gateway(gr_unittest.TestCase):
@@ -242,6 +256,15 @@ class test_block_gateway(gr_unittest.TestCase):
         tb.run()
         self.assertEqual(sink.key, "example_key")
 
+    def test_tags_win(self):
+        src = tag_source()
+        sink = tag_sink_win()
+        head = blocks.head(gr.sizeof_float, 50000) #should be enough items to 
get a tag through
+        tb = gr.top_block()
+        tb.connect(src, head, sink)
+        tb.run()
+        self.assertEqual(sink.key, "example_key")
+
     def test_fc32_to_f32_2(self):
         tb = gr.top_block()
         src = blocks.vector_source_c([1+2j, 3+4j, 5+6j, 7+8j, 9+10j], False)
@@ -254,4 +277,3 @@ class test_block_gateway(gr_unittest.TestCase):
 
 if __name__ == '__main__':
     gr_unittest.run(test_block_gateway, "test_block_gateway.xml")
-



reply via email to

[Prev in Thread] Current Thread [Next in Thread]