- 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
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<block>
<name>Jay's Peak Manager</name>
<key>jay_peak_manager</key>
<category>[jay]</category>
<import>import jay</import>
<make>jay.peak_manager()</make>
<sink>
<name>control</name>
<type>message</type>
<optional>1</optional>
</sink>
<source>
<name>status</name>
<type>message</type>
<optional>1</optional>
</source>
</block>
+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")
+46 -1
View File
@@ -1242,7 +1242,7 @@
</param>
<param>
<key>_enabled</key>
<value>1</value>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
@@ -1332,6 +1332,45 @@
<value>N_FFT</value>
</param>
</block>
<block>
<key>jay_peak_manager</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(928, 472)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>jay_peak_manager_0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
</block>
<block>
<key>qtgui_freq_sink_x</key>
<param>
@@ -3686,6 +3725,12 @@
<source_key>status</source_key>
<sink_key>control</sink_key>
</connection>
<connection>
<source_block_id>jay_peak_detect_1</source_block_id>
<sink_block_id>jay_peak_manager_0</sink_block_id>
<source_key>status</source_key>
<sink_key>control</sink_key>
</connection>
<connection>
<source_block_id>uhd_usrp_source_1</source_block_id>
<sink_block_id>blocks_add_xx_0</sink_block_id>