summaryrefslogtreecommitdiff
path: root/code/.grc_gnuradio/my_block.py
blob: 2c3dffc20596c29db952b378d20d212c637cc20e (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
import gras
import numpy

class MyBlock(gras.Block):

	def __init__(self):
		gras.Block.__init__(self,
			name="my_block",
			in_sig=[numpy.float32, numpy.float32], # input and output are 32bit numpy float datatype
			out_sig=[numpy.float32])	
		

	def set_parameters(self, value):
		self.value = value
	
	# Here's where you define the function of block | This function runs for each input value
	def work(self, input_items, output_items):
		
		# output_items is a double array | first index corresponds to output port which starts from 0
		# since we have only one output, first index is 0
		# the item has to be an array even if it is a single integer
		output_items[0][:1] = input_items[0][:1] + self.value

		print "Output Value", output_items[0][:1]
		print "Hello World"
		
		# These lines report to GNU Radio how many items were consumed and produced
		self.consume(0, 1) # Consume one item from input port 0 
		self.produce(0, 1) # Produce one item from output port 0