Updates to C++ and Python APIs:
[debian/gnuradio] / grc / data / platforms / python / blocks / variable_sink.xml
1 <?xml version="1.0"?>
2 <!--
3 ###################################################
4 ##Variable Sink: Custom blks2 block
5 ###################################################
6  -->
7 <block>
8         <name>Variable Sink</name>
9         <key>variable_sink</key>
10         <import>from gnuradio import gr</import>
11         <import>import threading</import>
12         <import>import time</import>
13         <make>gr.vector_sink_$(type.fcn)()
14 def _$(id)_run():
15         while True:
16                 time.sleep(1.0/$samp_rate)
17                 data = self.$(id).data()
18 #if $vlen() == 0
19                 if data:
20                         self.set_$(variable())(data[-1])
21                         self.$(id).clear()
22 #else
23                 if len(data) &gt;= $vlen:
24                         self.set_$(variable())(data[-($vlen):])
25                         self.$(id).clear()
26 #end if
27 threading.Thread(target=_$(id)_run).start()</make>
28         <param>
29                 <name>Type</name>
30                 <key>type</key>
31                 <type>enum</type>
32                 <option>
33                         <name>Complex</name>
34                         <key>complex</key>
35                         <opt>fcn:c</opt>
36                 </option>
37                 <option>
38                         <name>Float</name>
39                         <key>float</key>
40                         <opt>fcn:f</opt>
41                 </option>
42                 <option>
43                         <name>Int</name>
44                         <key>int</key>
45                         <opt>fcn:i</opt>
46                 </option>
47                 <option>
48                         <name>Short</name>
49                         <key>short</key>
50                         <opt>fcn:s</opt>
51                 </option>
52                 <option>
53                         <name>Byte</name>
54                         <key>byte</key>
55                         <opt>fcn:b</opt>
56                 </option>
57         </param>
58         <param>
59                 <name>Variable</name>
60                 <key>variable</key>
61                 <value></value>
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>
69         </param>
70         <param>
71                 <name>Vec Length</name>
72                 <key>vlen</key>
73                 <value>0</value>
74                 <type>int</type>
75         </param>
76         <check>$vlen &gt;= 0</check>
77         <sink>
78                 <name>in</name>
79                 <type>$type</type>
80         </sink>
81         <doc>
82 Read samples at from the input stream and write each sample to the variable.
83
84 The variable must be the id of an existing variable block.
85
86 When the vector length is 0, the variable will be set to numbers. \
87 When the vector length is > 0, the variable will be set to vectors.
88         </doc>
89 </block>