[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 10/16: blocks: better implementation of pea
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 10/16: blocks: better implementation of peak_detector2. Address #783. |
Date: |
Sun, 26 Apr 2015 23:18:03 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit abb3e0643ae245f08b7e7bcdaf3b8e8f0c312908
Author: Achilleas Anastasopoulos <address@hidden>
Date: Wed Apr 22 11:00:50 2015 -0400
blocks: better implementation of peak_detector2. Address #783.
In the original form, work function in peak_detector2 block sometimes
returns -1. For more details, see the mailing list thread:
- http://lists.gnu.org/archive/html/discuss-gnuradio/2015-04/msg00197.html
---
gr-blocks/examples/peak_detector2.grc | 1039 ++++++++++++++++++++++++++
gr-blocks/grc/blocks_peak_detector2_fb.xml | 5 +
gr-blocks/lib/peak_detector2_fb_impl.cc | 82 +-
gr-blocks/python/blocks/qa_peak_detector2.py | 87 ++-
4 files changed, 1171 insertions(+), 42 deletions(-)
diff --git a/gr-blocks/examples/peak_detector2.grc
b/gr-blocks/examples/peak_detector2.grc
new file mode 100644
index 0000000..6c62ac5
--- /dev/null
+++ b/gr-blocks/examples/peak_detector2.grc
@@ -0,0 +1,1039 @@
+<?xml version='1.0' encoding='ASCII'?>
+<?grc format='1' created='3.7.7'?>
+<flow_graph>
+ <timestamp>Wed Apr 8 18:17:58 2015</timestamp>
+ <block>
+ <key>options</key>
+ <param>
+ <key>id</key>
+ <value>test_peak2</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>title</key>
+ <value></value>
+ </param>
+ <param>
+ <key>author</key>
+ <value></value>
+ </param>
+ <param>
+ <key>description</key>
+ <value></value>
+ </param>
+ <param>
+ <key>window_size</key>
+ <value>1280, 1024</value>
+ </param>
+ <param>
+ <key>generate_options</key>
+ <value>qt_gui</value>
+ </param>
+ <param>
+ <key>category</key>
+ <value>Custom</value>
+ </param>
+ <param>
+ <key>run_options</key>
+ <value>run</value>
+ </param>
+ <param>
+ <key>run</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>max_nouts</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>realtime_scheduling</key>
+ <value></value>
+ </param>
+ <param>
+ <key>thread_safe_setters</key>
+ <value></value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(10, 10)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>alpha</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>0.001</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(624, 69)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>lookahead</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>int(samp_rate/1e3/1.1)</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(424, 69)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>factor</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>0.3</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(296, 69)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>variable</key>
+ <param>
+ <key>id</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>100e3</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(48, 101)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>analog_sig_source_x</key>
+ <param>
+ <key>id</key>
+ <value>analog_sig_source_x_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>waveform</key>
+ <value>analog.GR_COS_WAVE</value>
+ </param>
+ <param>
+ <key>freq</key>
+ <value>1000</value>
+ </param>
+ <param>
+ <key>amp</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>offset</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(24, 184)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_add_const_vxx</key>
+ <param>
+ <key>id</key>
+ <value>blocks_add_const_vxx_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>const</key>
+ <value>0.1</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(320, 212)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_throttle</key>
+ <param>
+ <key>id</key>
+ <value>blocks_throttle_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>samples_per_second</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>ignoretag</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(560, 172)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_peak_detector2_fb</key>
+ <param>
+ <key>id</key>
+ <value>blocks_peak_detector2_fb_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>threshold_factor_rise</key>
+ <value>factor</value>
+ </param>
+ <param>
+ <key>look_ahead</key>
+ <value>lookahead</value>
+ </param>
+ <param>
+ <key>alpha</key>
+ <value>alpha</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(160, 374)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_char_to_float</key>
+ <param>
+ <key>id</key>
+ <value>blocks_char_to_float_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>scale</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>minoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>maxoutbuf</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(384, 372)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_file_sink</key>
+ <param>
+ <key>id</key>
+ <value>blocks_file_sink_0_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>file</key>
+ <value>avg.data</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>unbuffered</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>append</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(824, 438)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_file_sink</key>
+ <param>
+ <key>id</key>
+ <value>blocks_file_sink_0_1</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>file</key>
+ <value>flag.data</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>unbuffered</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>append</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(824, 334)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>blocks_file_sink</key>
+ <param>
+ <key>id</key>
+ <value>blocks_file_sink_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>file</key>
+ <value>in.data</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>unbuffered</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>append</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(824, 238)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>qtgui_time_sink_x</key>
+ <param>
+ <key>id</key>
+ <value>qtgui_time_sink_x_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>float</value>
+ </param>
+ <param>
+ <key>name</key>
+ <value>""</value>
+ </param>
+ <param>
+ <key>ylabel</key>
+ <value>Amplitude</value>
+ </param>
+ <param>
+ <key>yunit</key>
+ <value>""</value>
+ </param>
+ <param>
+ <key>size</key>
+ <value>512</value>
+ </param>
+ <param>
+ <key>srate</key>
+ <value>samp_rate</value>
+ </param>
+ <param>
+ <key>grid</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>autoscale</key>
+ <value>False</value>
+ </param>
+ <param>
+ <key>ymin</key>
+ <value>-1.5</value>
+ </param>
+ <param>
+ <key>ymax</key>
+ <value>1.5</value>
+ </param>
+ <param>
+ <key>nconnections</key>
+ <value>3</value>
+ </param>
+ <param>
+ <key>update_time</key>
+ <value>0.10</value>
+ </param>
+ <param>
+ <key>entags</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>gui_hint</key>
+ <value></value>
+ </param>
+ <param>
+ <key>tr_mode</key>
+ <value>qtgui.TRIG_MODE_AUTO</value>
+ </param>
+ <param>
+ <key>tr_slope</key>
+ <value>qtgui.TRIG_SLOPE_POS</value>
+ </param>
+ <param>
+ <key>tr_level</key>
+ <value>0.0</value>
+ </param>
+ <param>
+ <key>tr_delay</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>tr_chan</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>tr_tag</key>
+ <value>""</value>
+ </param>
+ <param>
+ <key>ctrlpanel</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>legend</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>label1</key>
+ <value></value>
+ </param>
+ <param>
+ <key>width1</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>color1</key>
+ <value>"blue"</value>
+ </param>
+ <param>
+ <key>style1</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>marker1</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>alpha1</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>label2</key>
+ <value></value>
+ </param>
+ <param>
+ <key>width2</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>color2</key>
+ <value>"red"</value>
+ </param>
+ <param>
+ <key>style2</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>marker2</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>alpha2</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>label3</key>
+ <value></value>
+ </param>
+ <param>
+ <key>width3</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>color3</key>
+ <value>"green"</value>
+ </param>
+ <param>
+ <key>style3</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>marker3</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>alpha3</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>label4</key>
+ <value></value>
+ </param>
+ <param>
+ <key>width4</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>color4</key>
+ <value>"black"</value>
+ </param>
+ <param>
+ <key>style4</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>marker4</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>alpha4</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>label5</key>
+ <value></value>
+ </param>
+ <param>
+ <key>width5</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>color5</key>
+ <value>"cyan"</value>
+ </param>
+ <param>
+ <key>style5</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>marker5</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>alpha5</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>label6</key>
+ <value></value>
+ </param>
+ <param>
+ <key>width6</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>color6</key>
+ <value>"magenta"</value>
+ </param>
+ <param>
+ <key>style6</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>marker6</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>alpha6</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>label7</key>
+ <value></value>
+ </param>
+ <param>
+ <key>width7</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>color7</key>
+ <value>"yellow"</value>
+ </param>
+ <param>
+ <key>style7</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>marker7</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>alpha7</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>label8</key>
+ <value></value>
+ </param>
+ <param>
+ <key>width8</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>color8</key>
+ <value>"dark red"</value>
+ </param>
+ <param>
+ <key>style8</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>marker8</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>alpha8</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>label9</key>
+ <value></value>
+ </param>
+ <param>
+ <key>width9</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>color9</key>
+ <value>"dark green"</value>
+ </param>
+ <param>
+ <key>style9</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>marker9</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>alpha9</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>label10</key>
+ <value></value>
+ </param>
+ <param>
+ <key>width10</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>color10</key>
+ <value>"blue"</value>
+ </param>
+ <param>
+ <key>style10</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>marker10</key>
+ <value>-1</value>
+ </param>
+ <param>
+ <key>alpha10</key>
+ <value>1.0</value>
+ </param>
+ <param>
+ <key>alias</key>
+ <value></value>
+ </param>
+ <param>
+ <key>affinity</key>
+ <value></value>
+ </param>
+ <param>
+ <key>comment</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(672, 712)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <connection>
+ <source_block_id>blocks_peak_detector2_fb_0</source_block_id>
+ <sink_block_id>blocks_char_to_float_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>analog_sig_source_x_0</source_block_id>
+ <sink_block_id>blocks_add_const_vxx_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_add_const_vxx_0</source_block_id>
+ <sink_block_id>blocks_throttle_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_throttle_0</source_block_id>
+ <sink_block_id>blocks_peak_detector2_fb_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_peak_detector2_fb_0</source_block_id>
+ <sink_block_id>qtgui_time_sink_x_0</sink_block_id>
+ <source_key>1</source_key>
+ <sink_key>2</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_char_to_float_0</source_block_id>
+ <sink_block_id>qtgui_time_sink_x_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>1</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_throttle_0</source_block_id>
+ <sink_block_id>qtgui_time_sink_x_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_peak_detector2_fb_0</source_block_id>
+ <sink_block_id>blocks_file_sink_0_0</sink_block_id>
+ <source_key>1</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_char_to_float_0</source_block_id>
+ <sink_block_id>blocks_file_sink_0_1</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+ <connection>
+ <source_block_id>blocks_add_const_vxx_0</source_block_id>
+ <sink_block_id>blocks_file_sink_0</sink_block_id>
+ <source_key>0</source_key>
+ <sink_key>0</sink_key>
+ </connection>
+</flow_graph>
diff --git a/gr-blocks/grc/blocks_peak_detector2_fb.xml
b/gr-blocks/grc/blocks_peak_detector2_fb.xml
index 584e7a1..0b25e01 100644
--- a/gr-blocks/grc/blocks_peak_detector2_fb.xml
+++ b/gr-blocks/grc/blocks_peak_detector2_fb.xml
@@ -38,4 +38,9 @@
<name>out</name>
<type>byte</type>
</source>
+ <source>
+ <name>debug</name>
+ <type>float</type>
+ <optional>1</optional>
+ </source>
</block>
diff --git a/gr-blocks/lib/peak_detector2_fb_impl.cc
b/gr-blocks/lib/peak_detector2_fb_impl.cc
index 7ff7f54..e631768 100644
--- a/gr-blocks/lib/peak_detector2_fb_impl.cc
+++ b/gr-blocks/lib/peak_detector2_fb_impl.cc
@@ -43,8 +43,8 @@ namespace gr {
peak_detector2_fb_impl::peak_detector2_fb_impl(float threshold_factor_rise,
int look_ahead, float alpha)
: sync_block("peak_detector2_fb",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make2(1, 2, sizeof(char), sizeof(float))),
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make2(1, 2, sizeof(char), sizeof(float))),
d_threshold_factor_rise(threshold_factor_rise),
d_look_ahead(look_ahead), d_alpha(alpha), d_avg(0.0f), d_found(false)
{
@@ -61,53 +61,61 @@ namespace gr {
{
float *iptr = (float *)input_items[0];
char *optr = (char *)output_items[0];
+ float *sigout;
+
+ //bool DEB=false;
+
+ //if (DEB) printf("\nEnter work(): noutput_items= %d \n", noutput_items);
+
+ if(output_items.size() == 2)
+ sigout = (float *)output_items[1];
memset(optr, 0, noutput_items*sizeof(char));
- for(int i = 0; i < noutput_items; i++) {
- if(!d_found) {
- // Have not yet detected presence of peak
+ if(d_found==false) { // have not crossed threshold yet
+ for(int i=0;i<noutput_items;i++) {
+ d_avg = d_alpha*iptr[i] + (1.0f - d_alpha)*d_avg;
+ if(output_items.size() == 2)
+ sigout[i]=d_avg;
if(iptr[i] > d_avg * (1.0f + d_threshold_factor_rise)) {
d_found = true;
- d_look_ahead_remaining = d_look_ahead;
d_peak_val = -(float)INFINITY;
- }
- else {
- d_avg = d_alpha*iptr[i] + (1.0f - d_alpha)*d_avg;
+ //if (DEB) printf("crossed threshold at i=%d with
value=%f\n",i,iptr[i]);
+ set_output_multiple(d_look_ahead); // this is done so that the
block eventually returns if there are not enough inputs.
+ //if (DEB) printf("output multiple set at %d\n",output_multiple());
+ //if (DEB) printf("return %d items\n",i);
+ return i;
}
}
- else {
- // Detected presence of peak
+ //if (DEB) printf("output multiple is %d\n",output_multiple());
+ //if (DEB) printf("returning (below threshold) items
=%d\n",noutput_items);
+ return noutput_items;
+ } // end d_found==false
+ else if(noutput_items>=d_look_ahead) { // can complete in this call
+ //if (DEB) printf("Can complete in this call\n");
+ for(int i=0;i<d_look_ahead;i++) {
+ d_avg = d_alpha*iptr[i] + (1.0f - d_alpha)*d_avg;
+ if(output_items.size() == 2)
+ sigout[i]=d_avg;
if(iptr[i] > d_peak_val) {
d_peak_val = iptr[i];
- d_peak_ind = i;
- }
- else if(d_look_ahead_remaining <= 0) {
- optr[d_peak_ind] = 1;
- d_found = false;
- d_avg = iptr[i];
+ d_peak_ind =i;
+ //if (DEB) printf("peak found at i=%d, val=%f\n",i,d_peak_val);
}
-
- // Have not yet located peak, loop and keep searching.
- d_look_ahead_remaining--;
}
-
- // Every iteration of the loop, write debugging signal out if
- // connected:
- if(output_items.size() == 2) {
- float *sigout = (float *)output_items[1];
- sigout[i] = d_avg;
- }
- } // loop
-
- if(!d_found)
- return noutput_items;
-
- // else if detected presence, keep searching during the next call to
work.
- int tmp = d_peak_ind;
- d_peak_ind = 1;
-
- return tmp - 1;
+ optr[d_peak_ind] = 1;
+ //if (DEB) printf("PEAK=%f\n",d_peak_val);
+ d_found = false; // start searching again
+ set_output_multiple(1);
+ //if (DEB) printf("output multiple set at %d\n",output_multiple());
+ //if (DEB) printf("returning (above threshold and finished searching)
items =%d\n",d_look_ahead);
+ return d_look_ahead;
+ } // end can complete in this call
+ else { // cannot complete in this call
+ //if (DEB) printf("CANNOT BE HERE!!!!!!!!!!!!!!!!!!!!!\n");
+ //if (DEB) printf("returning (above threshold, but not enough inputs).
New lookahead=%d\n",d_look_ahead);
+ return 0; // ask for more
+ }
}
} /* namespace blocks */
diff --git a/gr-blocks/python/blocks/qa_peak_detector2.py
b/gr-blocks/python/blocks/qa_peak_detector2.py
index 475897e..d6fd4fe 100644
--- a/gr-blocks/python/blocks/qa_peak_detector2.py
+++ b/gr-blocks/python/blocks/qa_peak_detector2.py
@@ -30,18 +30,20 @@ class test_peak_detector2(gr_unittest.TestCase):
def tearDown(self):
self.tb = None
- def test_regen1(self):
+ def test_peak1(self):
+ #print "\n\nTEST 1"
tb = self.tb
- data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
- 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
+ n=10
+ data = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,)+n*(0,)
expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)+n*(0,)
src = blocks.vector_source_f(data, False)
- regen = blocks.peak_detector2_fb()
+ regen = blocks.peak_detector2_fb(7.0, 25, 0.001)
dst = blocks.vector_sink_b()
tb.connect(src, regen)
@@ -52,5 +54,80 @@ class test_peak_detector2(gr_unittest.TestCase):
self.assertEqual(expected_result, dst_data)
+ def test_peak2(self):
+ #print "\n\nTEST 2"
+ tb = self.tb
+
+ n=10
+ data = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,)+n*(0,)
+
+ expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)+n*(0,)
+
+
+ src = blocks.vector_source_f(data, False)
+ regen = blocks.peak_detector2_fb(7.0, 1000, 0.001) # called with a
LONG window
+ dst = blocks.vector_sink_b()
+
+ tb.connect(src, regen)
+ tb.connect(regen, dst)
+ tb.run()
+
+ dst_data = dst.data()
+
+ # here we know that the block will terminate prematurely, so we
compare only part of the expected_result
+ self.assertEqual(expected_result[0:len(dst_data)], dst_data)
+
+
+ def test_peak3(self):
+ #print "\n\nTEST 3"
+ tb = self.tb
+
+ l = 8100
+ m = 100
+ n = 10
+ data = l*(0,)+ (10,)+ m*(0,)+(100,)+ n*(0,)
+ expected_result = l*(0,)+ (0,)+ m*(0,)+(1,)+ n*(0,)
+
+
+ src = blocks.vector_source_f(data, False)
+ regen = blocks.peak_detector2_fb(7.0, 105, 0.001)
+ dst = blocks.vector_sink_b()
+
+ tb.connect(src, regen)
+ tb.connect(regen, dst)
+ tb.run()
+
+ dst_data = dst.data()
+
+ self.assertEqual(expected_result, dst_data)
+
+
+ def test_peak4(self):
+ #print "\n\nTEST 4"
+ tb = self.tb
+
+ l = 8100
+ m = 100
+ n = 10
+ data = l*(0,)+ (10,)+ m*(0,)+(100,)+ n*(0,)
+ expected_result = l*(0,)+ (0,)+ m*(0,)+(1,)+ n*(0,)
+
+
+ src = blocks.vector_source_f(data, False)
+ regen = blocks.peak_detector2_fb(7.0, 150, 0.001)
+ dst = blocks.vector_sink_b()
+
+ tb.connect(src, regen)
+ tb.connect(regen, dst)
+ tb.run()
+
+ dst_data = dst.data()
+
+ # here we know that the block will terminate prematurely, so we
compare only part of the expected_result
+ self.assertEqual(expected_result[0:len(dst_data)], dst_data)
+
+
if __name__ == '__main__':
gr_unittest.run(test_peak_detector2, "test_peak_detector2.xml")
- [Commit-gnuradio] [gnuradio] 13/16: Merge remote-tracking branch 'mmueller/pwr_squelch_add_tags', (continued)
- [Commit-gnuradio] [gnuradio] 13/16: Merge remote-tracking branch 'mmueller/pwr_squelch_add_tags', git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 12/16: Merge remote-tracking branch 'tom/ctrlport/fixes1', git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 06/16: controlport: use proper default return value from prefs get_bool., git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 08/16: digital: fix skipped sample handling in burst_shaper, git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 05/16: qtgui: improved type checking for range block and simplifies python., git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 02/16: controlport: fixed up performance monitor., git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 03/16: qtgui: adds Type setting for Range widget., git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 01/16: controlport: fixed controlport probes., git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 07/16: analog: Power Squelch now emit tags on start/end of bursts, git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 09/16: digital: added tag propagation to burst_shaper blocks, git, 2015/04/26
- [Commit-gnuradio] [gnuradio] 10/16: blocks: better implementation of peak_detector2. Address #783.,
git <=
- [Commit-gnuradio] [gnuradio] 11/16: blocks: more fixups to peak_detector2., git, 2015/04/26