同理,构建一个python的blcok,多了init的python文件。
'''
This is the GNU Radio PYBLOCK module. Place your Python package
description here (python/__init__.py).
'''
# import swig generated symbols into the pyblock namespace
try:
# this might fail if the module is python-only
from pyblock_swig import *
except ImportError:
pass
# import any pure python here
from pyblock import pyblock
#
python源代码文件。
import numpy
from gnuradio import gr
class pyblock(gr.basic_block):
"""
docstring for block pyblock
"""
def __init__(self):
gr.basic_block.__init__(self,
name="pyblock",
in_sig=[<+numpy.float+>],
out_sig=[<+numpy.float+>])
def forecast(self, noutput_items, ninput_items_required):
#setup size of input_items[i] for work call
for i in range(len(ninput_items_required)):
ninput_items_required[i] = noutput_items
def general_work(self, input_items, output_items):
output_items[0][:] = input_items[0]
consume(0, len(input_items[0]))
#self.consume_each(len(input_items[0]))
return len(output_items[0])