Changeset 9776

Show
Ignore:
Timestamp:
10/10/08 22:59:23
Author:
jblum
Message:

use vector sink inside variable sink

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/trunk/grc/data/platforms/python/blocks/variable_sink.xml

    r9772 r9776  
    88        <name>Variable Sink</name> 
    99        <key>variable_sink</key> 
    10         <import>from grc_gnuradio import blks2 as grc_blks2</import> 
    11         <make>grc_blks2.queue_sink_$(type.fcn)($vlen) 
    12 grc_blks2.queue_sink_thread(self.$id, self.set_$(variable))</make> 
     10        <import>from gnuradio import gr</import> 
     11        <import>import threading</import> 
     12        <import>import time</import> 
     13        <make>gr.vector_sink_$(type.fcn)() 
     14def _$(id)_run(): 
     15        while True: 
     16                time.sleep(1.0/$samp_rate) 
     17                data = self.$(id).data() 
     18#if $vlen.eval == 0 
     19                if data: 
     20                        self.set_$(variable.eval)(data[-1]) 
     21                        self.$(id).clear() 
     22#else 
     23                if len(data) &gt;= $vlen: 
     24                        self.set_$(variable.eval)(data[-($vlen):]) 
     25                        self.$(id).clear() 
     26#end if 
     27threading.Thread(target=_$(id)_run).start()</make> 
    1328        <param> 
    1429                <name>Type</name> 
     
    4560                <key>variable</key> 
    4661                <value></value> 
    47                 <type>raw</type> 
     62                <type>string</type> 
     63        </param> 
     64        <param> 
     65                <name>Sample Rate</name> 
     66                <key>samp_rate</key> 
     67                <value>10</value> 
     68                <type>real</type> 
    4869        </param> 
    4970        <param> 
    5071                <name>Vec Length</name> 
    5172                <key>vlen</key> 
    52                 <value>1</value> 
     73                <value>0</value> 
    5374                <type>int</type> 
    5475        </param> 
    55         <check>$vlen &gt; 0</check> 
     76        <check>$vlen &gt;= 0</check> 
    5677        <sink> 
    5778                <name>in</name> 
    5879                <type>$type</type> 
    59                 <vlen>$vlen</vlen> 
    6080        </sink> 
    6181        <doc> 
    62 Read samples from the input stream and write each sample to the variable. 
     82Read samples at from the input stream and write each sample to the variable. 
    6383 
    6484The variable must be the id of an existing variable block. 
     85 
     86When the vector length is 0, the variable will be set to numbers. \ 
     87When the vector length is > 0, the variable will be set to vectors. 
    6588        </doc> 
    6689</block> 
  • gnuradio/trunk/grc/src/grc_gnuradio/blks2/Makefile.am

    r9741 r9776  
    2929        packet.py \ 
    3030        probe.py \ 
    31         queue.py \ 
    3231        selector.py