- added Jay's Peak Manager

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@488 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-28 06:27:45 +00:00
parent deb1d90cb4
commit 6a45ff2384
6 changed files with 185 additions and 2 deletions
+2 -1
View File
@@ -32,7 +32,7 @@ endif()
GR_PYTHON_INSTALL(
FILES
__init__.py
DESTINATION ${GR_PYTHON_DIR}/jay
peak_manager.py DESTINATION ${GR_PYTHON_DIR}/jay
)
########################################################################
@@ -50,3 +50,4 @@ GR_ADD_TEST(qa_bit_packer ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_bi
GR_ADD_TEST(qa_add ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_add.py)
GR_ADD_TEST(qa_peak_detect ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_peak_detect.py)
GR_ADD_TEST(qa_message_debug ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_message_debug.py)
GR_ADD_TEST(qa_peak_manager ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_peak_manager.py)
+1
View File
@@ -31,4 +31,5 @@ except ImportError:
pass
# import any pure python here
from peak_manager import peak_manager
#
+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2019 Jay Arrowfield.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
import numpy
import pmt
from gnuradio import gr
class peak_manager(gr.basic_block):
"""
docstring for block peak_manager
"""
def __init__(self):
gr.basic_block.__init__(self,
name="peak_manager",
in_sig=None,
out_sig=None)
# Register in / out message ports
self.message_port_register_in(pmt.intern("control"))
self.message_port_register_out(pmt.intern("status"))
# Register in message handler
self.set_msg_handler(pmt.intern("control"), self.msg_handler)
#self.message_port_pub(pmt.intern("port name"), < pmt message >)
def msg_handler(self, msg):
print ("Message received:")
if pmt.is_dict(msg):
items = pmt.dict_items(msg)
for n in range(0, pmt.length(items)):
pair = pmt.nth(n, items)
key = pmt.car(pair)
val = pmt.cdr(pair)
if pmt.is_integer(val):
print("{}={}".format(pmt.symbol_to_string(key), pmt.to_long(val)))
elif pmt.is_real(val):
print("{}={}".format(pmt.symbol_to_string(key), pmt.to_float(val)))
elif pmt.is_bool(val):
print("{}={}".format(pmt.symbol_to_string(key), pmt.to_bool(val)))
else:
print(pmt.symbol_to_string(msg))
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])
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2019 Jay Arrowfield.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
from gnuradio import gr, gr_unittest
from gnuradio import blocks
from peak_manager import peak_manager
class qa_peak_manager (gr_unittest.TestCase):
def setUp (self):
self.tb = gr.top_block ()
def tearDown (self):
self.tb = None
def test_001_t (self):
# set up fg
self.tb.run ()
# check data
if __name__ == '__main__':
gr_unittest.run(qa_peak_manager, "qa_peak_manager.xml")