commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: jblum
Subject: [Commit-gnuradio] r10469 - in gnuradio/branches/developers/jblum/gui_guts: gnuradio-core/src/lib/io gr-wxgui/src/python
Date: Thu, 19 Feb 2009 17:37:30 -0700 (MST)

Author: jblum
Date: 2009-02-19 17:37:29 -0700 (Thu, 19 Feb 2009)
New Revision: 10469

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/gnuradio-core/src/lib/io/gr_oscope_sink.i
   
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc
   
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.h
   
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_trigger_mode.h
   gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/constants.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_nongl.py
Log:
trigger options for slope (separated from the mode)

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-19 22:49:49 UTC (rev 10468)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.cc
      2009-02-20 00:37:29 UTC (rev 10469)
@@ -54,7 +54,8 @@
 gr_oscope_guts::gr_oscope_guts (double sample_rate, gr_msg_queue_sptr msgq)
   : d_nchannels (1),
     d_msgq (msgq), 
-    d_trigger_mode (gr_TRIG_AUTO),
+    d_trigger_mode (gr_TRIG_MODE_AUTO),
+    d_trigger_slope (gr_TRIG_SLOPE_POS),
     d_trigger_channel (0),
     d_sample_rate (sample_rate),
     d_update_rate (20),
@@ -114,9 +115,7 @@
     break;
 
   case LOOK_FOR_TRIGGER:
-    d_pre_trigger_count++;
-    //found a trigger or too many samples without a trigger in auto mode
-    if (found_trigger () || (d_trigger_mode == gr_TRIG_AUTO && 
d_pre_trigger_count > OUTPUT_RECORD_SIZE/2))
+    if (found_trigger ())
       enter_post_trigger ();
     break;
 
@@ -171,32 +170,37 @@
 {
   float prev_sample = d_buffer[d_trigger_channel][decr_bi(d_obi)];
   float new_sample = d_buffer[d_trigger_channel][d_obi];
-  bool trig;
 
   switch (d_trigger_mode){
 
-  case gr_TRIG_FREE: //free run mode, always trigger
+  case gr_TRIG_MODE_AUTO: //too many samples without a trigger
+    d_pre_trigger_count++;
+    if (d_pre_trigger_count > OUTPUT_RECORD_SIZE/2) return true;
+
+  case gr_TRIG_MODE_NORM: //look for trigger
+    switch (d_trigger_slope){
+
+    case gr_TRIG_SLOPE_POS: //trigger point in pos slope?
+      if (new_sample < d_trigger_level || prev_sample >= d_trigger_level) 
return false;
+      break;
+
+    case gr_TRIG_SLOPE_NEG: //trigger point in neg slope?
+      if (new_sample > d_trigger_level || prev_sample <= d_trigger_level) 
return false;
+      break;
+    }
+
+    //calculate the trigger offset in % sample
+    d_trigger_off = (d_trigger_level - prev_sample)/(new_sample - prev_sample);
+    return true;
+
+  case gr_TRIG_MODE_FREE: //free run mode, always trigger
     d_trigger_off = 0;
     return true;
 
-  case gr_TRIG_AUTO: //not really automatic, just do pos slope, auto handled 
in process sample
-  case gr_TRIG_POS_SLOPE:
-    trig = prev_sample < d_trigger_level && new_sample >= d_trigger_level;
-    break;
-
-  case gr_TRIG_NEG_SLOPE:
-    trig = prev_sample > d_trigger_level && new_sample <= d_trigger_level;
-    break;
-
   default:
     assert (0);
     return false;
   }
-  if (trig){
-    d_trigger_off = (d_trigger_level - prev_sample)/(new_sample - prev_sample);
-    return true;
-  }
-  return false;
 }
 
 // ----------------------------------------------------------------
@@ -288,6 +292,14 @@
 }
 
 bool
+gr_oscope_guts::set_trigger_slope (gr_trigger_slope slope)
+{
+  d_trigger_slope = slope;
+  trigger_changed ();
+  return true;
+}
+
+bool
 gr_oscope_guts::set_trigger_level (double trigger_level)
 {
   d_trigger_level = trigger_level;
@@ -365,6 +377,12 @@
   return d_trigger_mode;
 }
 
+gr_trigger_slope
+gr_oscope_guts::get_trigger_slope () const
+{
+  return d_trigger_slope;
+}
+
 double
 gr_oscope_guts::get_trigger_level () const
 {

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-19 22:49:49 UTC (rev 10468)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_guts.h
       2009-02-20 00:37:29 UTC (rev 10469)
@@ -48,7 +48,8 @@
 
   int                  d_nchannels;            // how many channels
   gr_msg_queue_sptr    d_msgq;                 // message queue we stuff 
output records into
-  gr_trigger_mode      d_trigger_mode;         
+  gr_trigger_mode      d_trigger_mode;
+  gr_trigger_slope     d_trigger_slope;
   int                  d_trigger_channel;      // which channel to watch for 
trigger condition
   double               d_sample_rate;          // input sample rate in Hz
   double               d_update_rate;          // approx freq to produce an 
output record (Hz)
@@ -97,6 +98,7 @@
   bool set_decimation_count (int decimation_count);
   bool set_trigger_channel (int channel);
   bool set_trigger_mode (gr_trigger_mode mode);
+  bool set_trigger_slope (gr_trigger_slope slope);
   bool set_trigger_level (double trigger_level);
   bool set_trigger_level_auto ();                              // set to 50% 
level
   bool set_sample_rate(double sample_rate);
@@ -110,6 +112,7 @@
   int get_decimation_count () const;
   int get_trigger_channel () const;
   gr_trigger_mode get_trigger_mode () const;
+  gr_trigger_slope get_trigger_slope () const;
   double get_trigger_level () const;
 
   // # of samples written to each output record.

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink.i
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink.i
       2009-02-19 22:49:49 UTC (rev 10468)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink.i
       2009-02-20 00:37:29 UTC (rev 10469)
@@ -39,6 +39,7 @@
   bool set_decimation_count (int decimation_count);
   bool set_trigger_channel (int channel);
   bool set_trigger_mode (gr_trigger_mode mode);
+  bool set_trigger_slope (gr_trigger_slope slope);
   bool set_trigger_level (double trigger_level);
   bool set_trigger_level_auto ();                              // set to 50% 
level
   bool set_sample_rate(double sample_rate);
@@ -50,6 +51,7 @@
   int get_decimation_count () const;
   int get_trigger_channel () const;
   gr_trigger_mode get_trigger_mode () const;
+  gr_trigger_slope get_trigger_slope () const;
   double get_trigger_level () const;
 
   // # of samples written to each output record.

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc
    2009-02-19 22:49:49 UTC (rev 10468)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.cc
    2009-02-20 00:37:29 UTC (rev 10469)
@@ -69,6 +69,12 @@
 }
 
 bool
+gr_oscope_sink_x::set_trigger_slope (gr_trigger_slope slope)
+{
+  return d_guts->set_trigger_slope (slope);
+}
+
+bool
 gr_oscope_sink_x::set_trigger_level (double trigger_level)
 {
   return d_guts->set_trigger_level (trigger_level);
@@ -131,6 +137,12 @@
   return d_guts->get_trigger_mode ();
 }
 
+gr_trigger_slope
+gr_oscope_sink_x::get_trigger_slope () const
+{
+  return d_guts->get_trigger_slope ();
+}
+
 double
 gr_oscope_sink_x::get_trigger_level () const
 {

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.h
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.h
     2009-02-19 22:49:49 UTC (rev 10468)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_oscope_sink_x.h
     2009-02-20 00:37:29 UTC (rev 10469)
@@ -51,6 +51,7 @@
   bool set_decimation_count (int decimation_count);
   bool set_trigger_channel (int channel);
   bool set_trigger_mode (gr_trigger_mode mode);
+  bool set_trigger_slope (gr_trigger_slope slope);
   bool set_trigger_level (double trigger_level);
   bool set_trigger_level_auto ();                              // set to 50% 
level
   bool set_sample_rate(double sample_rate);
@@ -64,6 +65,7 @@
   int get_decimation_count () const;
   int get_trigger_channel () const;
   gr_trigger_mode get_trigger_mode () const;
+  gr_trigger_slope get_trigger_slope () const;
   double get_trigger_level () const;
 
   // # of samples written to each output record.

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_trigger_mode.h
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_trigger_mode.h
      2009-02-19 22:49:49 UTC (rev 10468)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gnuradio-core/src/lib/io/gr_trigger_mode.h
      2009-02-20 00:37:29 UTC (rev 10469)
@@ -24,10 +24,14 @@
 #define INCLUDED_GR_TRIGGER_MODE_H
 
 enum gr_trigger_mode {
-  gr_TRIG_FREE,                        // freerun
-  gr_TRIG_AUTO,                        // auto trigger
-  gr_TRIG_POS_SLOPE,   // trigger on positive slope across trigger level
-  gr_TRIG_NEG_SLOPE            // trigger on negative slope across trigger 
level
+  gr_TRIG_MODE_FREE,
+  gr_TRIG_MODE_AUTO,
+  gr_TRIG_MODE_NORM,
 };
 
+enum gr_trigger_slope {
+  gr_TRIG_SLOPE_POS,
+  gr_TRIG_SLOPE_NEG,
+};
+
 #endif /* INCLUDED_GR_TRIGGER_MODE_H */

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/constants.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/constants.py    
    2009-02-19 22:49:49 UTC (rev 10468)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/constants.py    
    2009-02-20 00:37:29 UTC (rev 10469)
@@ -46,12 +46,10 @@
 SCOPE_TRIGGER_CHANNEL_KEY = 'scope_trigger_channel'
 SCOPE_TRIGGER_LEVEL_KEY = 'scope_trigger_level'
 SCOPE_TRIGGER_MODE_KEY = 'scope_trigger_mode'
+SCOPE_TRIGGER_SLOPE_KEY = 'scope_trigger_slope'
 SCOPE_X_CHANNEL_KEY = 'scope_x_channel'
 SCOPE_Y_CHANNEL_KEY = 'scope_y_channel'
 SCOPE_XY_MODE_KEY = 'scope_xy_mode'
-TRIGGER_CHANNEL_KEY = 'trigger_channel'
-TRIGGER_LEVEL_KEY = 'trigger_level'
-TRIGGER_MODE_KEY = 'trigger_mode'
 T_DIVS_KEY = 't_divs'
 T_OFF_KEY = 't_off'
 T_PER_DIV_KEY = 't_per_div'

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-19 22:49:49 UTC (rev 10468)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py 
    2009-02-20 00:37:29 UTC (rev 10469)
@@ -38,13 +38,16 @@
 DEFAULT_WIN_SIZE = (600, 300)
 DEFAULT_V_SCALE = 1000
 TRIGGER_MODES = (
-       ('Freerun', gr.gr_TRIG_FREE),
-       ('Auto', gr.gr_TRIG_AUTO),
-       ('Neg', gr.gr_TRIG_NEG_SLOPE),
-       ('Pos', gr.gr_TRIG_POS_SLOPE),
+       ('Freerun', gr.gr_TRIG_MODE_FREE),
+       ('Automatic', gr.gr_TRIG_MODE_AUTO),
+       ('Normal', gr.gr_TRIG_MODE_NORM),
 )
+TRIGGER_SLOPES = (
+       ('Positive', gr.gr_TRIG_SLOPE_POS),
+       ('Negative', gr.gr_TRIG_SLOPE_NEG),
+)
 TRIGGER_LEVELS = (
-       ('Auto', None),
+       ('Automatic', None),
        ('+High', 0.75),
        ('+Med', 0.5),
        ('+Low', 0.25),
@@ -90,14 +93,18 @@
                #trigger mode
                self.trigger_mode_chooser = common.DropDownController(self, 
'Mode', TRIGGER_MODES, parent.ext_controller, parent.trigger_mode_key)
                control_box.Add(self.trigger_mode_chooser, 0, wx.EXPAND)
+               #trigger slope
+               self.trigger_slope_chooser = common.DropDownController(self, 
'Slope', TRIGGER_SLOPES, parent.ext_controller, parent.trigger_slope_key)
+               parent.ext_controller.subscribe(parent.trigger_mode_key, lambda 
x: self.trigger_slope_chooser.Disable(x==gr.gr_TRIG_MODE_FREE))
+               control_box.Add(self.trigger_slope_chooser, 0, wx.EXPAND)
                #trigger level
-               self.trigger_level_chooser = common.DropDownController(self, 
'Level', TRIGGER_LEVELS, parent, TRIGGER_LEVEL_KEY)
-               parent.subscribe(parent.trigger_mode_key, lambda x: 
self.trigger_level_chooser.Disable(x==gr.gr_TRIG_FREE))
+               self.trigger_level_chooser = common.DropDownController(self, 
'Level', TRIGGER_LEVELS, parent, SCOPE_TRIGGER_LEVEL_KEY)
+               parent.ext_controller.subscribe(parent.trigger_mode_key, lambda 
x: self.trigger_level_chooser.Disable(x==gr.gr_TRIG_MODE_FREE))
                control_box.Add(self.trigger_level_chooser, 0, wx.EXPAND)
                #trigger channel
-               choices = [('Ch%d'%(i+1), i) for i in range(parent.num_inputs)]
+               choices = [('Channel %d'%(i+1), i) for i in 
range(parent.num_inputs)]
                self.trigger_channel_chooser = common.DropDownController(self, 
'Channel', choices, parent.ext_controller, parent.trigger_channel_key)
-               parent.subscribe(parent.trigger_mode_key, lambda x: 
self.trigger_channel_chooser.Disable(x==gr.gr_TRIG_FREE))
+               parent.ext_controller.subscribe(parent.trigger_mode_key, lambda 
x: self.trigger_channel_chooser.Disable(x==gr.gr_TRIG_MODE_FREE))
                control_box.Add(self.trigger_channel_chooser, 0, wx.EXPAND)
                #axes options
                SPACING = 15
@@ -264,6 +271,7 @@
                xy_mode,
                trigger_level_key,
                trigger_mode_key,
+               trigger_slope_key,
                trigger_channel_key,
                decimation_key,
                msg_key,
@@ -283,6 +291,7 @@
                #scope keys
                self.trigger_level_key = trigger_level_key
                self.trigger_mode_key = trigger_mode_key
+               self.trigger_slope_key = trigger_slope_key
                self.trigger_channel_key = trigger_channel_key
                self.decimation_key = decimation_key
                #init panel and plot
@@ -315,14 +324,11 @@
                self._register_set_prop(self, SCOPE_X_CHANNEL_KEY, 0)
                self._register_set_prop(self, SCOPE_Y_CHANNEL_KEY, num_inputs-1)
                self._register_set_prop(self, FRAME_RATE_KEY, frame_rate)
-               #REMOVE self._register_set_prop(self, TRIGGER_CHANNEL_KEY, 0)
-               #REMOVE self._register_set_prop(self, TRIGGER_MODE_KEY, 
gr.gr_TRIG_AUTO)
-               self._register_set_prop(self, TRIGGER_LEVEL_KEY, None)
+               self._register_set_prop(self, SCOPE_TRIGGER_LEVEL_KEY, None)
                self._register_set_prop(self, MARKER_KEY, DEFAULT_MARKER_TYPE)
-               
                self.ext_controller[self.trigger_channel_key] = 0
-               self.ext_controller[self.trigger_mode_key] = gr.gr_TRIG_AUTO
-               
+               self.ext_controller[self.trigger_mode_key] = 
gr.gr_TRIG_MODE_AUTO
+               self.ext_controller[self.trigger_slope_key] = 
gr.gr_TRIG_SLOPE_POS
                #register events
                self.ext_controller.subscribe(msg_key, self.handle_msg)
                for key in (
@@ -367,13 +373,10 @@
                """
                if not self.sampleses: return
                sampleses = self.sampleses
-               #REMOVE #trigger level (must do before ac coupling)
-               #REMOVE self.ext_controller[self.trigger_channel_key] = 
self[TRIGGER_CHANNEL_KEY]
-               #REMOVE self.ext_controller[self.trigger_mode_key] = 
self[TRIGGER_MODE_KEY]
-               trigger_level = self[TRIGGER_LEVEL_KEY]
+               trigger_level = self[SCOPE_TRIGGER_LEVEL_KEY]
                if trigger_level is None: 
self.ext_controller[self.trigger_level_key] = ''
                else:
-                       samples = sampleses[self[TRIGGER_CHANNEL_KEY]]
+                       samples = 
sampleses[self.ext_controller[self.trigger_channel_key]]
                        self.ext_controller[self.trigger_level_key] = \
                                
trigger_level*(numpy.max(samples)-numpy.min(samples))/2 + numpy.average(samples)
                #ac coupling

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py 
    2009-02-19 22:49:49 UTC (rev 10468)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py 
    2009-02-20 00:37:29 UTC (rev 10469)
@@ -84,8 +84,10 @@
                self.controller.subscribe(SCOPE_TRIGGER_LEVEL_KEY, 
set_trigger_level)
                self.controller.subscribe(SCOPE_TRIGGER_MODE_KEY, 
scope.set_trigger_mode)
                self.controller.publish(SCOPE_TRIGGER_MODE_KEY, 
scope.get_trigger_mode)
+               self.controller.subscribe(SCOPE_TRIGGER_SLOPE_KEY, 
scope.set_trigger_slope)
+               self.controller.publish(SCOPE_TRIGGER_SLOPE_KEY, 
scope.get_trigger_slope)
                self.controller.subscribe(SCOPE_TRIGGER_CHANNEL_KEY, 
scope.set_trigger_channel)
-               self.controller.publish(SCOPE_TRIGGER_CHANNEL_KEY, 
scope.set_trigger_channel)
+               self.controller.publish(SCOPE_TRIGGER_CHANNEL_KEY, 
scope.get_trigger_channel)
                #start input watcher
                def setter(p, k, x): # lambdas can't have assignments :(
                    p[k] = x
@@ -105,6 +107,7 @@
                        xy_mode=xy_mode,
                        trigger_level_key=SCOPE_TRIGGER_LEVEL_KEY,
                        trigger_mode_key=SCOPE_TRIGGER_MODE_KEY,
+                       trigger_slope_key=SCOPE_TRIGGER_SLOPE_KEY,
                        trigger_channel_key=SCOPE_TRIGGER_CHANNEL_KEY,
                        decimation_key=DECIMATION_KEY,
                        msg_key=MSG_KEY,

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_nongl.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_nongl.py
  2009-02-19 22:49:49 UTC (rev 10468)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_nongl.py
  2009-02-20 00:37:29 UTC (rev 10469)
@@ -320,7 +320,7 @@
         ctrlbox.Add (self.trig_chan_choice, 0, wx.ALIGN_CENTER)
 
         self.trig_mode_choice = wx.Choice (self, 1005,
-                                           choices = ['Free', 'Auto', 'Pos', 
'Neg'])
+                                           choices = ['Free', 'Auto', 'Norm'])
         self.trig_mode_choice.SetSelection(1)
         self.trig_mode_choice.SetToolTipString ("Select trigger slope or Auto 
(untriggered roll)")
         wx.EVT_CHOICE (self, 1005, self.trig_mode_choice_event)
@@ -433,14 +433,12 @@
     def trig_mode_choice_event (self, evt):
         sink = self.info.scopesink
         s = evt.GetString ()
-        if s == 'Pos':
-            sink.set_trigger_mode (gr.gr_TRIG_POS_SLOPE)
-        elif s == 'Neg':
-            sink.set_trigger_mode (gr.gr_TRIG_NEG_SLOPE)
+        if s == 'Norm':
+            sink.set_trigger_mode (gr.gr_TRIG_MODE_NORM)
         elif s == 'Auto':
-            sink.set_trigger_mode (gr.gr_TRIG_AUTO)
+            sink.set_trigger_mode (gr.gr_TRIG_MODE_AUTO)
         elif s == 'Free':
-            sink.set_trigger_mode (gr.gr_TRIG_FREE)
+            sink.set_trigger_mode (gr.gr_TRIG_MODE_FREE)
         else:
             assert 0, "Bad trig_mode_choice string"
     





reply via email to

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