commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10464 - in gnuradio/branches/developers/jblum/gui_gut


From: jblum
Subject: [Commit-gnuradio] r10464 - in gnuradio/branches/developers/jblum/gui_guts: gnuradio-core/src/lib/io gr-wxgui/src/python
Date: Wed, 18 Feb 2009 15:55:54 -0700 (MST)

Author: jblum
Date: 2009-02-18 15:55:53 -0700 (Wed, 18 Feb 2009)
New Revision: 10464

Modified:
   
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.cc
   
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.h
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py
Log:
If too many samples are processed without a trigger found, release the samples 
anyway.
Solves major irritation with the scope gui and sudden amplitide changes.
Also, f/r tabs to spaces.



Modified: 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.cc
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.cc
      2009-02-18 20:31:47 UTC (rev 10463)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.cc
      2009-02-18 22:55:53 UTC (rev 10464)
@@ -31,22 +31,22 @@
 #include <math.h>
 #include <assert.h>
 
-static const int OUTPUT_RECORD_SIZE = 2048;    // must be power of 2
+static const int OUTPUT_RECORD_SIZE = 2048;        // must be power of 2
 
 static inline int
-wrap_bi (int buffer_index)             // wrap buffer index
+wrap_bi (int buffer_index)                // wrap buffer index
 {
   return buffer_index & (OUTPUT_RECORD_SIZE - 1);
 }
 
 static inline int
-incr_bi (int buffer_index)             // increment buffer index
+incr_bi (int buffer_index)                // increment buffer index
 {
   return wrap_bi (buffer_index + 1);
 }
 
 static inline int
-decr_bi (int buffer_index)             // decrement buffer index
+decr_bi (int buffer_index)                // decrement buffer index
 {
   return wrap_bi (buffer_index - 1);
 }
@@ -65,6 +65,7 @@
     d_decimator_count_init (1),
     d_hold_off_count (0),
     d_hold_off_count_init (OUTPUT_RECORD_SIZE/2-1),
+    d_pre_trigger_count (0),
     d_post_trigger_count (0),
     d_post_trigger_count_init (OUTPUT_RECORD_SIZE/2),
     d_prev_sample (0)
@@ -109,7 +110,7 @@
   d_decimator_count = d_decimator_count_init;
   
   for (int i = 0; i < d_nchannels; i++)
-    d_buffer[i][d_obi] = channel_data[i];              // copy data into buffer
+    d_buffer[i][d_obi] = channel_data[i];                // copy data into 
buffer
 
   int trigger = 0;
   
@@ -124,9 +125,12 @@
     trigger = found_trigger (d_buffer[d_trigger_channel][d_obi]);
     if (trigger != 0){
       enter_post_trigger ();
-      if (trigger < 0)                 // previous sample was closer
-       d_post_trigger_count--;
+      if (trigger < 0)                        // previous sample was closer
+        d_post_trigger_count--;
+    }else if (d_pre_trigger_count > OUTPUT_RECORD_SIZE/2){
+      enter_post_trigger (); //too long without a trigger, force post trigger
     }
+    d_pre_trigger_count++;
     break;
 
   case POST_TRIGGER:
@@ -167,6 +171,7 @@
 {
   d_state = POST_TRIGGER;
   d_post_trigger_count = d_post_trigger_count_init;
+  d_pre_trigger_count = 0;
 }
 
 // ----------------------------------------------------------------
@@ -183,16 +188,16 @@
 
   switch (d_trigger_mode){
 
-  case gr_TRIG_AUTO:           // always trigger
+  case gr_TRIG_AUTO:                // always trigger
     return +1;
     
   case gr_TRIG_POS_SLOPE:
     trig = prev_sample < d_trigger_level && new_sample >= d_trigger_level;
     if (trig){
       if (fabs (prev_sample - d_trigger_level) < fabs (new_sample - 
d_trigger_level))
-       return -1;
+        return -1;
       else
-       return +1;
+        return +1;
     }
     return 0;
 
@@ -200,9 +205,9 @@
     trig = prev_sample > d_trigger_level && new_sample <= d_trigger_level;
     if (trig){
       if (fabs (prev_sample - d_trigger_level) < fabs (new_sample - 
d_trigger_level))
-       return -1;
+        return -1;
       else
-       return +1;
+        return +1;
     }
     return 0;
 
@@ -224,12 +229,12 @@
 
   // Build a message to hold the output records
   gr_message_sptr msg = 
-    gr_make_message(0,                                                // msg 
type
-                   d_nchannels,                                       // arg1 
for other side
-                   OUTPUT_RECORD_SIZE,                                // arg2 
for other side
-                   d_nchannels * OUTPUT_RECORD_SIZE * sizeof(float)); // 
sizeof payload
+    gr_make_message(0,                                         // msg type
+            d_nchannels,                                       // arg1 for 
other side
+            OUTPUT_RECORD_SIZE,                                // arg2 for 
other side
+            d_nchannels * OUTPUT_RECORD_SIZE * sizeof(float)); // sizeof 
payload
 
-  float *out = (float *)msg->msg();    // get pointer to raw message buffer
+  float *out = (float *)msg->msg();        // get pointer to raw message buffer
 
   for (int ch = 0; ch < d_nchannels; ch++){
     // note that d_obi + 1 points at the oldest sample in the buffer
@@ -239,7 +244,7 @@
     out += OUTPUT_RECORD_SIZE;
   }
 
-  d_msgq->handle(msg);         // send the msg
+  d_msgq->handle(msg);                // send the msg
 }
 
 // ----------------------------------------------------------------
@@ -315,17 +320,14 @@
 {
   // find the level 1/2 way between the min and the max
 
-  float        min_v = d_buffer[d_trigger_channel][0];
-  float        max_v = d_buffer[d_trigger_channel][0];
+  float min_v = d_buffer[d_trigger_channel][0];
+  float max_v = d_buffer[d_trigger_channel][0];
 
   for (int i = 1; i < OUTPUT_RECORD_SIZE; i++){
     min_v = std::min (min_v, d_buffer[d_trigger_channel][i]);
     max_v = std::max (max_v, d_buffer[d_trigger_channel][i]);
   }
-
-  d_trigger_level = (min_v + max_v) * 0.5;
-  trigger_changed ();
-  return true;
+  return set_trigger_level((min_v + max_v) * 0.5);
 }
 
 void

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.h
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.h
       2009-02-18 20:31:47 UTC (rev 10463)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.h
       2009-02-18 22:55:53 UTC (rev 10464)
@@ -61,6 +61,7 @@
   int                  d_decimator_count_init;
   int                  d_hold_off_count;
   int                  d_hold_off_count_init;
+  int                  d_pre_trigger_count;
   int                  d_post_trigger_count;
   int                  d_post_trigger_count_init;
   float                        d_prev_sample;                  // used for 
trigger checking

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py 
    2009-02-18 20:31:47 UTC (rev 10463)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py 
    2009-02-18 22:55:53 UTC (rev 10464)
@@ -278,7 +278,6 @@
                self.autorange_ts = 0
                if v_scale is None: v_scale = 1
                self.frame_rate_ts = 0
-               self._init = False #HACK
                #scope keys
                self.scope_trigger_level_key = scope_trigger_level_key
                self.scope_trigger_mode_key = scope_trigger_mode_key
@@ -330,8 +329,8 @@
                        AC_COUPLE_KEY,
                        MARKER_KEY,
                ): self.subscribe(key, self.update_grid)
-               #initial update, dont do this here, wait for handle_msg #HACK
-               #self.update_grid()
+               #initial update
+               self.update_grid()
 
        def handle_msg(self, msg):
                """
@@ -347,9 +346,6 @@
                samples = numpy.fromstring(msg, numpy.float32)
                samps_per_ch = len(samples)/self.num_inputs
                self.sampleses = [samples[samps_per_ch*i:samps_per_ch*(i+1)] 
for i in range(self.num_inputs)]
-               if not self._init: #HACK
-                       self._init = True
-                       self.update_grid()
                #handle samples
                self.handle_samples()
                self.frame_rate_ts = time.time()
@@ -369,7 +365,7 @@
                else:
                        samples = sampleses[self[TRIGGER_CHANNEL_KEY]]
                        self.ext_controller[self.scope_trigger_level_key] = \
-                       trigger_level*(numpy.max(samples)-numpy.min(samples))/2 
+ numpy.average(samples)
+                               
trigger_level*(numpy.max(samples)-numpy.min(samples))/2 + numpy.average(samples)
                #ac coupling
                if self[AC_COUPLE_KEY]:
                        sampleses = [samples - numpy.average(samples) for 
samples in sampleses]





reply via email to

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