From a6bf31afb3e2bb1c3bd70cdcc66d393ff6d5feb6 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <tom@trondeau.com>
Date: Thu, 26 Jun 2014 16:27:26 -0400
Subject: runtime: addes get_tags_in_window to block_gateway for python blocks.
 Added QA.

Addresses Issue #683.
---
 gr-blocks/python/blocks/qa_block_gateway.py | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

(limited to 'gr-blocks/python')

diff --git a/gr-blocks/python/blocks/qa_block_gateway.py b/gr-blocks/python/blocks/qa_block_gateway.py
index f62726adf3..1e848cff04 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")
-
-- 
cgit v1.2.3