commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 01/02: qtgui: fixes a bug in the number sin


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/02: qtgui: fixes a bug in the number sink to respect the update time.
Date: Sat, 26 Jul 2014 16:21:05 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch maint
in repository gnuradio.

commit 737ec8954ab3236b9f931fe2741a71a932a05cb1
Author: Tom Rondeau <address@hidden>
Date:   Sat Jul 26 12:06:57 2014 -0400

    qtgui: fixes a bug in the number sink to respect the update time.
    
    Addresses issue #703.
---
 gr-qtgui/lib/number_sink_impl.cc | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/gr-qtgui/lib/number_sink_impl.cc b/gr-qtgui/lib/number_sink_impl.cc
index abfb872..1be2653 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) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]