summaryrefslogtreecommitdiff
path: root/grc/data/platforms/python/blocks/variable_sink.xml
blob: 87575ae1b74a25f442b21ece2e1cc4d80e97ff9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?xml version="1.0"?>
<!--
###################################################
##Variable Sink: Custom blks2 block
###################################################
 -->
<block>
	<name>Variable Sink</name>
	<key>variable_sink</key>
	<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) &gt;= $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>
		<type>enum</type>
		<option>
			<name>Complex</name>
			<key>complex</key>
			<opt>fcn:c</opt>
		</option>
		<option>
			<name>Float</name>
			<key>float</key>
			<opt>fcn:f</opt>
		</option>
		<option>
			<name>Int</name>
			<key>int</key>
			<opt>fcn:i</opt>
		</option>
		<option>
			<name>Short</name>
			<key>short</key>
			<opt>fcn:s</opt>
		</option>
		<option>
			<name>Byte</name>
			<key>byte</key>
			<opt>fcn:b</opt>
		</option>
	</param>
	<param>
		<name>Variable</name>
		<key>variable</key>
		<value></value>
		<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>0</value>
		<type>int</type>
	</param>
	<check>$vlen &gt;= 0</check>
	<sink>
		<name>in</name>
		<type>$type</type>
	</sink>
	<doc>
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>