diff options
author | Tom Rondeau <tom@trondeau.com> | 2014-07-26 12:06:57 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2014-07-26 12:06:57 -0400 |
commit | 737ec8954ab3236b9f931fe2741a71a932a05cb1 (patch) | |
tree | cc6e2b232ae199cc07280f39ba603c92460d22b8 /gr-qtgui/lib/number_sink_impl.cc | |
parent | 5c3c34544248e1fa9aec8733012ea968acd03498 (diff) |
qtgui: fixes a bug in the number sink to respect the update time.
Addresses issue #703.
Diffstat (limited to 'gr-qtgui/lib/number_sink_impl.cc')
-rw-r--r-- | gr-qtgui/lib/number_sink_impl.cc | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/gr-qtgui/lib/number_sink_impl.cc b/gr-qtgui/lib/number_sink_impl.cc index abfb8725f4..1be2653053 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 { @@ -265,6 +266,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, @@ -272,11 +290,7 @@ 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++) { @@ -288,7 +302,7 @@ namespace gr { } // 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) { |