diff options
Diffstat (limited to 'grc/data/platforms/python/blocks/variable_sink.xml')
-rw-r--r-- | grc/data/platforms/python/blocks/variable_sink.xml | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/grc/data/platforms/python/blocks/variable_sink.xml b/grc/data/platforms/python/blocks/variable_sink.xml index a4adb5c00..87575ae1b 100644 --- a/grc/data/platforms/python/blocks/variable_sink.xml +++ b/grc/data/platforms/python/blocks/variable_sink.xml @@ -7,9 +7,24 @@ <block> <name>Variable Sink</name> <key>variable_sink</key> - <import>from grc_gnuradio import blks2 as grc_blks2</import> - <make>grc_blks2.queue_sink_$(type.fcn)($vlen) -grc_blks2.queue_sink_thread(self.$id, self.set_$(variable))</make> + <import>from gnuradio import gr</import> + <import>import threading</import> + <import>import time</import> + <make>gr.vector_sink_$(type.fcn)() +def _$(id)_run(): + while True: + time.sleep(1.0/$samp_rate) + data = self.$(id).data() +#if $vlen.eval == 0 + if data: + self.set_$(variable.eval)(data[-1]) + self.$(id).clear() +#else + if len(data) >= $vlen: + self.set_$(variable.eval)(data[-($vlen):]) + self.$(id).clear() +#end if +threading.Thread(target=_$(id)_run).start()</make> <param> <name>Type</name> <key>type</key> @@ -44,23 +59,31 @@ grc_blks2.queue_sink_thread(self.$id, self.set_$(variable))</make> <name>Variable</name> <key>variable</key> <value></value> - <type>raw</type> + <type>string</type> + </param> + <param> + <name>Sample Rate</name> + <key>samp_rate</key> + <value>10</value> + <type>real</type> </param> <param> <name>Vec Length</name> <key>vlen</key> - <value>1</value> + <value>0</value> <type>int</type> </param> - <check>$vlen > 0</check> + <check>$vlen >= 0</check> <sink> <name>in</name> <type>$type</type> - <vlen>$vlen</vlen> </sink> <doc> -Read samples from the input stream and write each sample to the variable. +Read samples at from the input stream and write each sample to the variable. The variable must be the id of an existing variable block. + +When the vector length is 0, the variable will be set to numbers. \ +When the vector length is > 0, the variable will be set to vectors. </doc> </block> |