From 6a45ff23847455be066b87c244e0f9529eeafd87 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 28 May 2019 06:27:45 +0000 Subject: [PATCH] - added Jay's Peak Manager git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@488 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- gr-jay/grc/jay_peak_manager.xml | 20 +++++++++ gr-jay/python/CMakeLists.txt | 3 +- gr-jay/python/__init__.py | 1 + gr-jay/python/peak_manager.py | 75 ++++++++++++++++++++++++++++++++ gr-jay/python/qa_peak_manager.py | 41 +++++++++++++++++ peak_det_eval.grc | 47 +++++++++++++++++++- 6 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 gr-jay/grc/jay_peak_manager.xml create mode 100644 gr-jay/python/peak_manager.py create mode 100755 gr-jay/python/qa_peak_manager.py diff --git a/gr-jay/grc/jay_peak_manager.xml b/gr-jay/grc/jay_peak_manager.xml new file mode 100644 index 0000000..8ef39ed --- /dev/null +++ b/gr-jay/grc/jay_peak_manager.xml @@ -0,0 +1,20 @@ + + + Jay's Peak Manager + jay_peak_manager + [jay] + import jay + jay.peak_manager() + + control + message + 1 + + + + status + message + 1 + + + diff --git a/gr-jay/python/CMakeLists.txt b/gr-jay/python/CMakeLists.txt index a79d606..3ca1735 100644 --- a/gr-jay/python/CMakeLists.txt +++ b/gr-jay/python/CMakeLists.txt @@ -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) diff --git a/gr-jay/python/__init__.py b/gr-jay/python/__init__.py index 2c45fbf..006e6d0 100644 --- a/gr-jay/python/__init__.py +++ b/gr-jay/python/__init__.py @@ -31,4 +31,5 @@ except ImportError: pass # import any pure python here +from peak_manager import peak_manager # diff --git a/gr-jay/python/peak_manager.py b/gr-jay/python/peak_manager.py new file mode 100644 index 0000000..1e087f8 --- /dev/null +++ b/gr-jay/python/peak_manager.py @@ -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]) + diff --git a/gr-jay/python/qa_peak_manager.py b/gr-jay/python/qa_peak_manager.py new file mode 100755 index 0000000..0b32fa4 --- /dev/null +++ b/gr-jay/python/qa_peak_manager.py @@ -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") diff --git a/peak_det_eval.grc b/peak_det_eval.grc index 43a9de8..ca9ea58 100644 --- a/peak_det_eval.grc +++ b/peak_det_eval.grc @@ -1242,7 +1242,7 @@ _enabled - 1 + 0 _coordinate @@ -1332,6 +1332,45 @@ N_FFT + + jay_peak_manager + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (928, 472) + + + _rotation + 0 + + + id + jay_peak_manager_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + qtgui_freq_sink_x @@ -3686,6 +3725,12 @@ status control + + jay_peak_detect_1 + jay_peak_manager_0 + status + control + uhd_usrp_source_1 blocks_add_xx_0