commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8799 - gnuradio/trunk/gnuradio-core/src/python/gnurad


From: jcorgan
Subject: [Commit-gnuradio] r8799 - gnuradio/trunk/gnuradio-core/src/python/gnuradio/blks2impl
Date: Sat, 5 Jul 2008 13:14:04 -0600 (MDT)

Author: jcorgan
Date: 2008-07-05 13:14:04 -0600 (Sat, 05 Jul 2008)
New Revision: 8799

Added:
   
gnuradio/trunk/gnuradio-core/src/python/gnuradio/blks2impl/stream_to_vector_decimator.py
Modified:
   gnuradio/trunk/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am
Log:
Adds blks2.stream_to_vector_decimator block.

Modified: gnuradio/trunk/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am
===================================================================
--- gnuradio/trunk/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am      
2008-07-05 02:17:40 UTC (rev 8798)
+++ gnuradio/trunk/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am      
2008-07-05 19:14:04 UTC (rev 8799)
@@ -55,6 +55,7 @@
        qam256.py               \
        rational_resampler.py   \
        standard_squelch.py     \
+       stream_to_vector_decimator.py \
        wfm_rcv.py              \
        wfm_rcv_pll.py          \
        wfm_tx.py               

Added: 
gnuradio/trunk/gnuradio-core/src/python/gnuradio/blks2impl/stream_to_vector_decimator.py
===================================================================
--- 
gnuradio/trunk/gnuradio-core/src/python/gnuradio/blks2impl/stream_to_vector_decimator.py
                            (rev 0)
+++ 
gnuradio/trunk/gnuradio-core/src/python/gnuradio/blks2impl/stream_to_vector_decimator.py
    2008-07-05 19:14:04 UTC (rev 8799)
@@ -0,0 +1,80 @@
+#
+# Copyright 2008 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.
+#
+
+from gnuradio import gr
+
+class stream_to_vector_decimator(gr.hier_block2):
+    """!
+    Convert the stream to a vector, decimate the vector stream to achieve the 
vector rate.
+    """
+
+    def __init__(self, item_size, sample_rate, vec_rate, vec_len):
+       """!
+       Create the block chain.
+       @param item_size the number of bytes per sample
+       @param sample_rate the rate of incoming samples
+       @param vec_rate the rate of outgoing vectors (same units as sample_rate)
+       @param vec_len the length of the outgoing vectors in items
+       """
+       self._vec_rate = vec_rate
+       self._vec_len = vec_len
+       self._sample_rate = sample_rate
+       
+       gr.hier_block2.__init__(self, "stream_decimator_block",
+                               gr.io_signature(1, 1, item_size),         # 
Input signature
+                               gr.io_signature(1, 1, item_size*vec_len)) # 
Output signature
+
+       s2v = gr.stream_to_vector(item_size, vec_len)
+       self.one_in_n = gr.keep_one_in_n(item_size*vec_len, 1)
+       self._update_decimator()
+       self.connect(self, s2v, self.one_in_n, self)
+
+    def set_sample_rate(self, sample_rate):
+       """!
+       Set the new sampling rate and update the decimator.
+       @param sample_rate the new rate
+       """
+       self._sample_rate = sample_rate
+       self._update_decimator()
+
+    def set_vec_rate(self, vec_rate):
+       """!
+       Set the new vector rate and update the decimator.
+       @param vec_rate the new rate
+       """
+       self._vec_rate = vec_rate
+       self._update_decimator()
+       
+    def _update_decimator(self):
+       self._decim = max(1, 
int(self._sample_rate/self._vec_len/self._vec_rate))
+       self.one_in_n.set_n(self._decim)
+
+    def sample_rate(self):
+       """!
+       Returns configured sample rate.
+       """
+       return self._sample_rate
+       
+    def frame_rate(self):
+       """!
+       Returns actual frame rate
+       """
+       return self._sample_rate/self._vec_len/self._decim





reply via email to

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