diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-07-26 12:20:57 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-07-26 12:20:57 -0400 |
commit | fd0db71f4c6422a820524e618f03823bd0ca6e36 (patch) | |
tree | 3d2181bf86a26855bb391e09e7887bb27fef763f /gr-qtgui/lib/number_sink_impl.cc | |
parent | e5e6f233a65ea27c9734d586cd286ac764267bdc (diff) | |
parent | ad3d36772d659ca1656e00bf89ecd5c02db582bc (diff) |
Merge branch 'maint'
Diffstat (limited to 'gr-qtgui/lib/number_sink_impl.cc')
-rw-r--r-- | gr-qtgui/lib/number_sink_impl.cc | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/gr-qtgui/lib/number_sink_impl.cc b/gr-qtgui/lib/number_sink_impl.cc index e5966ac203..ca0f0bdf10 100644 --- a/gr-qtgui/lib/number_sink_impl.cc +++ b/gr-qtgui/lib/number_sink_impl.cc @@ -30,6 +30,7 @@ #include <volk/volk.h> #include <gnuradio/fft/fft.h> #include <qwt_symbol.h> +#include <cmath> namespace gr { namespace qtgui { @@ -301,6 +302,23 @@ namespace gr { { } + void + number_sink_impl::_gui_update_trigger() + { + // Only update the time if different than the current interval + // add some slop in cpu ticks for double comparison + gr::high_res_timer_type tps = gr::high_res_timer_tps(); + double t = d_main_gui->updateTime(); + if((d_update_time < (tps*t-10)) || ((tps*t+10) < d_update_time)) { + set_update_time(t); + } + + float a = d_main_gui->average(); + if(a != d_average) { + set_average(a); + } + } + int number_sink_impl::work(int noutput_items, gr_vector_const_void_star &input_items, @@ -308,23 +326,20 @@ namespace gr { { gr::thread::scoped_lock lock(d_mutex); - float new_avg = d_main_gui->average(); - set_update_time(d_main_gui->updateTime()); - if(new_avg != d_average) { - set_average(new_avg); - } + _gui_update_trigger(); if(d_average > 0) { for(int n = 0; n < d_nconnections; n++) { float *in = (float*)input_items[n]; for(int i = 0; i < noutput_items; i++) { - d_avg_value[n] = d_iir[n].filter(in[i]); + if(std::isfinite(in[i])) + d_avg_value[n] = d_iir[n].filter(in[i]); } } } // Plot if we are able to update - if(gr::high_res_timer_now() - d_last_time > d_update_time) { + if((gr::high_res_timer_now() - d_last_time) > d_update_time) { d_last_time = gr::high_res_timer_now(); std::vector<float> d(d_nconnections); if(d_average > 0) { @@ -332,8 +347,11 @@ namespace gr { d[n] = d_avg_value[n]; } else { - for(int n = 0; n < d_nconnections; n++) - d[n] = ((float*)input_items[n])[0]; + for(int n = 0; n < d_nconnections; n++) { + float x = ((float*)input_items[n])[0]; + if(std::isfinite(x)) + d[n] = x; + } } d_qApplication->postEvent(d_main_gui, new NumberUpdateEvent(d)); |