commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 01/01: blocks: better handling of srcid wit


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/01: blocks: better handling of srcid with vector_source blocks.
Date: Thu, 2 Oct 2014 16:22:03 +0000 (UTC)

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

trondeau pushed a commit to branch master
in repository gnuradio.

commit 4f03a54b2b802f0eff6802985ec6479738843c57
Author: Tom Rondeau <address@hidden>
Date:   Thu Oct 2 12:18:29 2014 -0400

    blocks: better handling of srcid with vector_source blocks.
    
     - vector_source now adds the srcid of the tag to the actual tag stream.
     - tag_utils' python_to_tag can now be called with just 3 parameters by 
omitting the srcid; gets filled in with PMT_F.
     - updated vector_source_with_tags example to have tags with and without 
srcid set.
---
 gnuradio-runtime/python/gnuradio/gr/tag_utils.py |  17 ++-
 gr-blocks/examples/vector_source_with_tags.grc   | 128 +++++++++++++++++++----
 gr-blocks/lib/vector_source_X_impl.cc.t          |   2 +-
 3 files changed, 122 insertions(+), 25 deletions(-)

diff --git a/gnuradio-runtime/python/gnuradio/gr/tag_utils.py 
b/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
index cbca9d4..ba46e3f 100644
--- a/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
+++ b/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
@@ -89,9 +89,22 @@ def python_to_tag(tag_struct):
                 tag.srcid = tag_struct[3]
                 good = True
 
+        elif(len(tag_struct) == 3):
+            if(isinstance(tag_struct[0], (int,long))):
+                tag.offset = tag_struct[0]
+                good = True
+
+            if(isinstance(tag_struct[1], pmt.pmt_swig.swig_int_ptr)):
+                tag.key = tag_struct[1]
+                good = True
+
+            if(isinstance(tag_struct[2], pmt.pmt_swig.swig_int_ptr)):
+                tag.value = tag_struct[2]
+                good = True
+
+            tag.srcid = pmt.PMT_F
+
     if(good):
         return tag
     else:
         return None
-
-
diff --git a/gr-blocks/examples/vector_source_with_tags.grc 
b/gr-blocks/examples/vector_source_with_tags.grc
index 981ee6c..e266b91 100644
--- a/gr-blocks/examples/vector_source_with_tags.grc
+++ b/gr-blocks/examples/vector_source_with_tags.grc
@@ -69,7 +69,7 @@
     <key>variable</key>
     <param>
       <key>id</key>
-      <value>samp_rate</value>
+      <value>tag1</value>
     </param>
     <param>
       <key>_enabled</key>
@@ -77,7 +77,7 @@
     </param>
     <param>
       <key>value</key>
-      <value>32000</value>
+      <value>gr.tag_utils.python_to_tag((1, pmt.intern('mark'), 
pmt.PMT_T))</value>
     </param>
     <param>
       <key>alias</key>
@@ -85,7 +85,7 @@
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(184, 11)</value>
+      <value>(16, 267)</value>
     </param>
     <param>
       <key>_rotation</key>
@@ -120,6 +120,33 @@
     </param>
   </block>
   <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>samp_rate</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>32000</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(184, 11)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
     <key>import</key>
     <param>
       <key>id</key>
@@ -147,10 +174,10 @@
     </param>
   </block>
   <block>
-    <key>blocks_vector_source_x</key>
+    <key>blocks_throttle</key>
     <param>
       <key>id</key>
-      <value>blocks_vector_source_x_0</value>
+      <value>blocks_throttle_0</value>
     </param>
     <param>
       <key>_enabled</key>
@@ -161,22 +188,18 @@
       <value>float</value>
     </param>
     <param>
-      <key>vector</key>
-      <value>(-0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 0.0)</value>
+      <key>samples_per_second</key>
+      <value>samp_rate</value>
     </param>
     <param>
-      <key>tags</key>
-      <value>[tag0]</value>
+      <key>vlen</key>
+      <value>1</value>
     </param>
     <param>
-      <key>repeat</key>
+      <key>ignoretag</key>
       <value>True</value>
     </param>
     <param>
-      <key>vlen</key>
-      <value>1</value>
-    </param>
-    <param>
       <key>alias</key>
       <value></value>
     </param>
@@ -194,7 +217,7 @@
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(16, 107)</value>
+      <value>(272, 123)</value>
     </param>
     <param>
       <key>_rotation</key>
@@ -202,10 +225,10 @@
     </param>
   </block>
   <block>
-    <key>blocks_throttle</key>
+    <key>blocks_tag_debug</key>
     <param>
       <key>id</key>
-      <value>blocks_throttle_0</value>
+      <value>blocks_tag_debug_0</value>
     </param>
     <param>
       <key>_enabled</key>
@@ -216,15 +239,23 @@
       <value>float</value>
     </param>
     <param>
-      <key>samples_per_second</key>
-      <value>samp_rate</value>
+      <key>name</key>
+      <value></value>
+    </param>
+    <param>
+      <key>filter</key>
+      <value>""</value>
+    </param>
+    <param>
+      <key>num_inputs</key>
+      <value>1</value>
     </param>
     <param>
       <key>vlen</key>
       <value>1</value>
     </param>
     <param>
-      <key>ignoretag</key>
+      <key>display</key>
       <value>True</value>
     </param>
     <param>
@@ -236,6 +267,53 @@
       <value></value>
     </param>
     <param>
+      <key>_coordinate</key>
+      <value>(456, 195)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_vector_source_x</key>
+    <param>
+      <key>id</key>
+      <value>blocks_vector_source_x_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>float</value>
+    </param>
+    <param>
+      <key>vector</key>
+      <value>(-0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75, 0.0)</value>
+    </param>
+    <param>
+      <key>tags</key>
+      <value>[tag0, tag1]</value>
+    </param>
+    <param>
+      <key>repeat</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
       <key>minoutbuf</key>
       <value>0</value>
     </param>
@@ -245,7 +323,7 @@
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(272, 123)</value>
+      <value>(16, 107)</value>
     </param>
     <param>
       <key>_rotation</key>
@@ -592,7 +670,7 @@
     </param>
     <param>
       <key>_coordinate</key>
-      <value>(440, 107)</value>
+      <value>(456, 107)</value>
     </param>
     <param>
       <key>_rotation</key>
@@ -611,4 +689,10 @@
     <source_key>0</source_key>
     <sink_key>0</sink_key>
   </connection>
+  <connection>
+    <source_block_id>blocks_throttle_0</source_block_id>
+    <sink_block_id>blocks_tag_debug_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
 </flow_graph>
diff --git a/gr-blocks/lib/vector_source_X_impl.cc.t 
b/gr-blocks/lib/vector_source_X_impl.cc.t
index 93f672b..cb17c70 100644
--- a/gr-blocks/lib/vector_source_X_impl.cc.t
+++ b/gr-blocks/lib/vector_source_X_impl.cc.t
@@ -106,7 +106,7 @@ namespace gr {
             optr += size;
             for(unsigned t = 0; t < d_tags.size(); t++) {
               add_item_tag(0, nitems_written(0)+i+d_tags[t].offset,
-                           d_tags[t].key, d_tags[t].value);
+                           d_tags[t].key, d_tags[t].value, d_tags[t].srcid);
             }
           }
         }



reply via email to

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