commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: jblum
Subject: [Commit-gnuradio] r10479 - in gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python: . plotter
Date: Sun, 22 Feb 2009 21:32:51 -0700 (MST)

Author: jblum
Date: 2009-02-22 21:32:50 -0700 (Sun, 22 Feb 2009)
New Revision: 10479

Modified:
   gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/constants.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/numbersink2.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/plotter/channel_plotter.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
Log:
Made use of pubsub in the numbersink's avg alpha filter.
Added clear_waveform method to the channel plotter.
Time offset slider for scope.
Scope GUI controls moved around.



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-23 02:14:39 UTC (rev 10478)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/constants.py    
    2009-02-23 04:32:50 UTC (rev 10479)
@@ -47,9 +47,9 @@
 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'
+SCOPE_TRIGGER_SHOW_KEY = 'scope_trigger_show'
+SCOPE_MODE_KEY = 'scope_mode'
+T_FRAC_OFF_KEY = 't_frac_off'
 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/numbersink2.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/numbersink2.py  
    2009-02-23 02:14:39 UTC (rev 10478)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/numbersink2.py  
    2009-02-23 04:32:50 UTC (rev 10479)
@@ -74,27 +74,26 @@
                if self._real:
                        mult = gr.multiply_const_ff(factor)
                        add = gr.add_const_ff(ref_level)
-                       self._avg = gr.single_pole_iir_filter_ff(1.0)
+                       avg = gr.single_pole_iir_filter_ff(1.0)
                else:
                        mult = gr.multiply_const_cc(factor)
                        add = gr.add_const_cc(ref_level)
-                       self._avg = gr.single_pole_iir_filter_cc(1.0)
+                       avg = gr.single_pole_iir_filter_cc(1.0)
                msgq = gr.msg_queue(2)
                sink = gr.message_sink(self._item_size, msgq, True)
                #connect
-               self.connect(self, sd, mult, add, self._avg, sink)
-               #setup averaging
-               self._avg_alpha = avg_alpha
-               self.set_average(average)
-               self.set_avg_alpha(avg_alpha)
+               self.connect(self, sd, mult, add, avg, sink)
                #controller
                self.controller = pubsub()
                self.controller.subscribe(SAMPLE_RATE_KEY, sd.set_sample_rate)
                self.controller.publish(SAMPLE_RATE_KEY, sd.sample_rate)
-               self.controller.subscribe(AVERAGE_KEY, self.set_average)
-               self.controller.publish(AVERAGE_KEY, self.get_average)
-               self.controller.subscribe(AVG_ALPHA_KEY, self.set_avg_alpha)
-               self.controller.publish(AVG_ALPHA_KEY, self.get_avg_alpha)
+               def update_avg(*args):
+                       if self.controller[AVERAGE_KEY]: 
avg.set_taps(self.controller[AVG_ALPHA_KEY])
+                       else: avg.set_taps(1.0)
+               self.controller.subscribe(AVERAGE_KEY, update_avg)
+               self.controller.subscribe(AVG_ALPHA_KEY, update_avg)
+               self.controller[AVERAGE_KEY] = average
+               self.controller[AVG_ALPHA_KEY] = avg_alpha
                #start input watcher
                common.input_watcher(msgq, self.controller, MSG_KEY)
                #create window
@@ -119,17 +118,6 @@
                #backwards compadibility
                self.set_show_gauge = self.win.show_gauges
 
-       def get_average(self): return self._average
-       def set_average(self, average):
-               self._average = average
-               if self.get_average(): self._avg.set_taps(self.get_avg_alpha())
-               else: self._avg.set_taps(1.0)
-
-       def get_avg_alpha(self): return self._avg_alpha
-       def set_avg_alpha(self, avg_alpha):
-               self._avg_alpha = avg_alpha
-               self.set_average(self.get_average())
-
 class number_sink_f(_number_sink_base):
        _item_size = gr.sizeof_float
        _real = True

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/plotter/channel_plotter.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/plotter/channel_plotter.py
  2009-02-23 02:14:39 UTC (rev 10478)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/plotter/channel_plotter.py
  2009-02-23 04:32:50 UTC (rev 10479)
@@ -129,9 +129,13 @@
                        #draw the points/lines
                        glColor3f(*self._channels[channel][COLOR_SPEC_KEY])
                        marker = self._channels[channel][MARKERY_KEY]
-                       if marker: glPointSize(marker)
-                       glVertexPointerf(points)
-                       glDrawArrays(marker is None and GL_LINE_STRIP or 
GL_POINTS, 0, len(points))
+                       if marker is None:
+                               glVertexPointerf(points)
+                               glDrawArrays(GL_LINE_STRIP, 0, len(points))
+                       elif isinstance(marker, (int, float)) and marker > 0:
+                               glPointSize(marker)
+                               glVertexPointerf(points)
+                               glDrawArrays(GL_POINTS, 0, len(points))
                        glPopMatrix()
 
        def _populate_point_label(self, x_val, y_val):
@@ -189,6 +193,17 @@
                        txt.draw_text(wx.Point(x_off - w, self.padding_top/2 - 
h/2))
                        x_off -= w + 4*LEGEND_BOX_PADDING
 
+       def clear_waveform(self, channel):
+               """
+               Remove a waveform from the list of waveforms.
+               @param channel the channel key
+               """
+               self.lock()
+               if channel in self._channels.keys():
+                       self._channels.pop(channel)
+                       self.changed(True)
+               self.unlock()
+
        def set_waveform(self, channel, samples=[], color_spec=(0, 0, 0), 
marker=None, trig_off=0):
                """
                Set the waveform for a given channel.

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-23 02:14:39 UTC (rev 10478)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py 
    2009-02-23 04:32:50 UTC (rev 10479)
@@ -37,6 +37,10 @@
 DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'scope_rate', 30)
 DEFAULT_WIN_SIZE = (600, 300)
 DEFAULT_V_SCALE = 1000
+COUPLING_MODES = (
+       ('DC', False),
+       ('AC', True),
+)
 TRIGGER_MODES = (
        ('Freerun', gr.gr_TRIG_MODE_FREE),
        ('Automatic', gr.gr_TRIG_MODE_AUTO),
@@ -47,20 +51,22 @@
        ('Negative -', gr.gr_TRIG_SLOPE_NEG),
 )
 CHANNEL_COLOR_SPECS = (
-       (0, 0, 1),
-       (0, 1, 0),
-       (1, 0, 0),
-       (1, 0, 1),
+       (0.0, 0.0, 1.0),
+       (0.0, 0.8, 0.0),
+       (1.0, 0.0, 0.0),
+       (0.8, 0.0, 0.8),
 )
-TRIGGER_COLOR_SPEC = (1, .4, 0)
+TRIGGER_COLOR_SPEC = (1.0, 0.4, 0.0)
 AUTORANGE_UPDATE_RATE = 0.5 #sec
 MARKER_TYPES = (
+       ('Line Link', None),
+       ('Dot Large', 3.0),
+       ('Dot Medium', 2.0),
        ('Dot Small', 1.0),
-       ('Dot Medium', 2.0),
-       ('Dot Large', 3.0),
-       ('Line Link', None),
+       ('None', 0.0),
 )
 DEFAULT_MARKER_TYPE = None
+def index_key(key, i): return "%s_%d"%(key, i+1)
 
 ##################################################
 # Scope window control panel
@@ -74,134 +80,168 @@
                Create a new control panel.
                @param parent the wx parent window
                """
+               SIZE = (100, -1)
                self.parent = parent
                wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
-               self.control_box = control_box = wx.BoxSizer(wx.VERTICAL)
-               #trigger options
+               control_box = wx.BoxSizer(wx.VERTICAL)
+               ##################################################
+               # Axes Options
+               ##################################################
                control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Trigger Options'), 0, 
wx.ALIGN_CENTER)
-               control_box.AddSpacer(2)
-               #trigger mode
-               self.trigger_mode_chooser = common.DropDownController(self, 
'Mode', TRIGGER_MODES, parent, SCOPE_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, SCOPE_TRIGGER_SLOPE_KEY)
-               parent.subscribe(SCOPE_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 channel
-               choices = [('Channel %d'%(i+1), i) for i in 
range(parent.num_inputs)]
-               self.trigger_channel_chooser = common.DropDownController(self, 
'Channel', choices, parent, SCOPE_TRIGGER_CHANNEL_KEY)
-               parent.subscribe(SCOPE_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)
-               #trigger level
-               hbox = wx.BoxSizer(wx.HORIZONTAL)
-               control_box.Add(hbox, 0, wx.EXPAND)
-               hbox.Add(wx.StaticText(self, -1, ' Level '), 1, 
wx.ALIGN_CENTER_VERTICAL)
-               trigger_level_button = wx.Button(self, label='50%', 
style=wx.BU_EXACTFIT)
-               def trigger_level_button_disable(x):
-                       if x==gr.gr_TRIG_MODE_FREE: 
trigger_level_button.Disable()
-                       else: trigger_level_button.Enable()
-               parent.subscribe(SCOPE_TRIGGER_MODE_KEY, 
trigger_level_button_disable)
-               trigger_level_button.Bind(wx.EVT_BUTTON, 
self.parent.set_auto_trigger_level)
-               hbox.Add(trigger_level_button, 0, wx.ALIGN_CENTER_VERTICAL)
-               hbox.AddSpacer(10)
-               trigger_level_buttons = common.IncrDecrButtons(self, 
self._on_incr_trigger_level, self._on_decr_trigger_level)
-               parent.subscribe(SCOPE_TRIGGER_MODE_KEY, lambda x: 
trigger_level_buttons.Disable(x==gr.gr_TRIG_MODE_FREE))
-               hbox.Add(trigger_level_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
-               #axes options
-               SPACING = 15
-               control_box.AddStretchSpacer()
                control_box.Add(common.LabelText(self, 'Axes Options'), 0, 
wx.ALIGN_CENTER)
                control_box.AddSpacer(2)
+               #scope mode chooser
+               choices = [('Scope', None)]
+               for i in range(parent.num_inputs):
+                       for j in range(parent.num_inputs):
+                               choices.append(('Ch%d : Ch%d'%(i+1, j+1), (i, 
j)))
+               scope_mode_chooser = common.DropDownController(self, 'Mode', 
choices, parent, SCOPE_MODE_KEY, SIZE)
+               control_box.Add(scope_mode_chooser, 0, wx.EXPAND)
                ##################################################
                # Scope Mode Box
                ##################################################
-               self.scope_mode_box = wx.BoxSizer(wx.VERTICAL)
-               control_box.Add(self.scope_mode_box, 0, wx.EXPAND)
+               scope_mode_box = wx.BoxSizer(wx.VERTICAL)
+               control_box.Add(scope_mode_box, 0, wx.EXPAND)
                #x axis divs
                hbox = wx.BoxSizer(wx.HORIZONTAL)
-               self.scope_mode_box.Add(hbox, 0, wx.EXPAND)
+               scope_mode_box.Add(hbox, 0, wx.EXPAND)
                hbox.Add(wx.StaticText(self, -1, ' Secs/Div '), 1, 
wx.ALIGN_CENTER_VERTICAL)
                x_buttons = common.IncrDecrButtons(self, self._on_incr_t_divs, 
self._on_decr_t_divs)
                hbox.Add(x_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
-               hbox.AddSpacer(SPACING)
                #y axis divs
                hbox = wx.BoxSizer(wx.HORIZONTAL)
-               self.scope_mode_box.Add(hbox, 0, wx.EXPAND)
-               hbox.Add(wx.StaticText(self, -1, ' Units/Div '), 1, 
wx.ALIGN_CENTER_VERTICAL)
+               scope_mode_box.Add(hbox, 0, wx.EXPAND)
+               hbox.Add(wx.StaticText(self, -1, ' Counts/Div '), 1, 
wx.ALIGN_CENTER_VERTICAL)
                y_buttons = common.IncrDecrButtons(self, self._on_incr_y_divs, 
self._on_decr_y_divs)
                parent.subscribe(AUTORANGE_KEY, y_buttons.Disable)
                hbox.Add(y_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
-               hbox.AddSpacer(SPACING)
                #y axis ref lvl
                hbox = wx.BoxSizer(wx.HORIZONTAL)
-               self.scope_mode_box.Add(hbox, 0, wx.EXPAND)
+               scope_mode_box.Add(hbox, 0, wx.EXPAND)
                hbox.Add(wx.StaticText(self, -1, ' Y Offset '), 1, 
wx.ALIGN_CENTER_VERTICAL)
                y_off_buttons = common.IncrDecrButtons(self, 
self._on_incr_y_off, self._on_decr_y_off)
                parent.subscribe(AUTORANGE_KEY, y_off_buttons.Disable)
                hbox.Add(y_off_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
-               hbox.AddSpacer(SPACING)
+               #t axis ref lvl
+               scope_mode_box.AddSpacer(5)
+               hbox = wx.BoxSizer(wx.HORIZONTAL)
+               scope_mode_box.Add(hbox, 0, wx.EXPAND)
+               hbox.Add(wx.StaticText(self, -1, ' T Offset '), 1, 
wx.ALIGN_CENTER_VERTICAL)
+               #t axis control
+               t_off_slider = wx.Slider(self, size=SIZE, 
style=wx.SL_HORIZONTAL)
+               t_off_slider.SetRange(0, SIZE[0])
+               def t_off_slider_changed(evt): parent[T_FRAC_OFF_KEY] = 
float(t_off_slider.GetValue())/t_off_slider.GetMax()
+               t_off_slider.Bind(wx.EVT_SLIDER, t_off_slider_changed)
+               parent.subscribe(T_FRAC_OFF_KEY, lambda x: 
t_off_slider.SetValue(int(round(x*t_off_slider.GetMax()))))
+               hbox.Add(t_off_slider, 0, wx.ALIGN_CENTER_VERTICAL)
+               scope_mode_box.AddSpacer(5)
                ##################################################
                # XY Mode Box
                ##################################################
-               self.xy_mode_box = wx.BoxSizer(wx.VERTICAL)
-               control_box.Add(self.xy_mode_box, 0, wx.EXPAND)
-               #x and y channel
-               CHOOSER_WIDTH = 60
-               CENTER_SPACING = 10
+               xy_mode_box = wx.BoxSizer(wx.VERTICAL)
+               control_box.Add(xy_mode_box, 0, wx.EXPAND)
+               #x div controls
                hbox = wx.BoxSizer(wx.HORIZONTAL)
-               self.xy_mode_box.Add(hbox, 0, wx.EXPAND)
-               choices = [('Ch%d'%(i+1), i) for i in range(parent.num_inputs)]
-               self.channel_x_chooser = common.DropDownController(self, 'X 
Ch', choices, parent, SCOPE_X_CHANNEL_KEY, (CHOOSER_WIDTH, -1))
-               hbox.Add(self.channel_x_chooser, 0, wx.EXPAND)
-               hbox.AddSpacer(CENTER_SPACING)
-               self.channel_y_chooser = common.DropDownController(self, 'Y 
Ch', choices, parent, SCOPE_Y_CHANNEL_KEY, (CHOOSER_WIDTH, -1))
-               hbox.Add(self.channel_y_chooser, 0, wx.EXPAND)
-               #div controls
-               hbox = wx.BoxSizer(wx.HORIZONTAL)
-               self.xy_mode_box.Add(hbox, 0, wx.EXPAND)
+               xy_mode_box.Add(hbox, 0, wx.EXPAND)
                hbox.Add(wx.StaticText(self, -1, ' X/Div '), 1, 
wx.ALIGN_CENTER_VERTICAL)
                x_buttons = common.IncrDecrButtons(self, self._on_incr_x_divs, 
self._on_decr_x_divs)
                parent.subscribe(AUTORANGE_KEY, x_buttons.Disable)
                hbox.Add(x_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
-               hbox.AddSpacer(CENTER_SPACING)
+               #y div controls
+               hbox = wx.BoxSizer(wx.HORIZONTAL)
+               xy_mode_box.Add(hbox, 0, wx.EXPAND)
                hbox.Add(wx.StaticText(self, -1, ' Y/Div '), 1, 
wx.ALIGN_CENTER_VERTICAL)
                y_buttons = common.IncrDecrButtons(self, self._on_incr_y_divs, 
self._on_decr_y_divs)
                parent.subscribe(AUTORANGE_KEY, y_buttons.Disable)
                hbox.Add(y_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
-               #offset controls
+               #x offset controls
                hbox = wx.BoxSizer(wx.HORIZONTAL)
-               self.xy_mode_box.Add(hbox, 0, wx.EXPAND)
+               xy_mode_box.Add(hbox, 0, wx.EXPAND)
                hbox.Add(wx.StaticText(self, -1, ' X Off '), 1, 
wx.ALIGN_CENTER_VERTICAL)
                x_off_buttons = common.IncrDecrButtons(self, 
self._on_incr_x_off, self._on_decr_x_off)
                parent.subscribe(AUTORANGE_KEY, x_off_buttons.Disable)
                hbox.Add(x_off_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
-               hbox.AddSpacer(CENTER_SPACING)
+               #y offset controls
+               hbox = wx.BoxSizer(wx.HORIZONTAL)
+               xy_mode_box.Add(hbox, 0, wx.EXPAND)
                hbox.Add(wx.StaticText(self, -1, ' Y Off '), 1, 
wx.ALIGN_CENTER_VERTICAL)
                y_off_buttons = common.IncrDecrButtons(self, 
self._on_incr_y_off, self._on_decr_y_off)
                parent.subscribe(AUTORANGE_KEY, y_off_buttons.Disable)
                hbox.Add(y_off_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
-               ##################################################
-               # End Special Boxes
-               ##################################################
-               #misc options
-               control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Range Options'), 0, 
wx.ALIGN_CENTER)
-               #ac couple check box
-               self.ac_couple_check_box = common.CheckBoxController(self, 'AC 
Couple', parent, AC_COUPLE_KEY)
-               control_box.Add(self.ac_couple_check_box, 0, wx.ALIGN_LEFT)
+               xy_mode_box.ShowItems(False)
+               def scope_mode_changed(mode):
+                       scope_mode_box.ShowItems(mode is None)
+                       xy_mode_box.ShowItems(mode is not None)
+                       control_box.Layout()
+               parent.subscribe(SCOPE_MODE_KEY, scope_mode_changed)
                #autorange check box
                self.autorange_check_box = common.CheckBoxController(self, 
'Autorange', parent, AUTORANGE_KEY)
                control_box.Add(self.autorange_check_box, 0, wx.ALIGN_LEFT)
-               #marker
                control_box.AddStretchSpacer()
-               self.marker_chooser = common.DropDownController(self, 'Marker', 
MARKER_TYPES, parent, MARKER_KEY)
-               control_box.Add(self.marker_chooser, 0, wx.EXPAND)
-               #xy mode
+               ##################################################
+               # Channel Options
+               ##################################################
+               control_box.Add(common.LabelText(self, 'Channel Options'), 0, 
wx.ALIGN_CENTER)
+               control_box.AddSpacer(2)
+               options_notebook = wx.Notebook(self)
+               control_box.Add(options_notebook, 0, wx.EXPAND)
                control_box.AddStretchSpacer()
-               self.scope_xy_mode_button = common.ToggleButtonController(self, 
parent, SCOPE_XY_MODE_KEY, 'Scope Mode', 'X:Y Mode')
-               parent.subscribe(SCOPE_XY_MODE_KEY, self._on_scope_xy_mode)
-               control_box.Add(self.scope_xy_mode_button, 0, wx.EXPAND)
+               def options_notebook_changed(evt): 
parent[SCOPE_TRIGGER_SHOW_KEY] = options_notebook.GetSelection() == 
parent.num_inputs
+               options_notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, 
options_notebook_changed)
+               ##################################################
+               # Channel Menu Boxes
+               ##################################################
+               for i in range(parent.num_inputs):
+                       channel_menu_panel = wx.Panel(options_notebook)
+                       options_notebook.AddPage(channel_menu_panel, 'Ch 
%d'%(i+1))
+                       channel_menu_box = wx.BoxSizer(wx.VERTICAL)
+                       channel_menu_panel.SetSizer(channel_menu_box)
+                       #ac couple check box
+                       channel_menu_box.AddStretchSpacer()
+                       coupling_chooser = 
common.DropDownController(channel_menu_panel, 'Coupling', COUPLING_MODES, 
parent, index_key(AC_COUPLE_KEY, i), SIZE)
+                       channel_menu_box.Add(coupling_chooser, 0, wx.EXPAND)
+                       #marker
+                       channel_menu_box.AddStretchSpacer()
+                       marker_chooser = 
common.DropDownController(channel_menu_panel, 'Marker', MARKER_TYPES, parent, 
index_key(MARKER_KEY, i), SIZE)
+                       channel_menu_box.Add(marker_chooser, 0, wx.EXPAND)
+                       channel_menu_box.AddStretchSpacer()
+               ##################################################
+               # Trigger Menu Box
+               ##################################################
+               trigger_menu_panel = wx.Panel(options_notebook)
+               options_notebook.AddPage(trigger_menu_panel, 'Trigger')
+               trigger_menu_box = wx.BoxSizer(wx.VERTICAL)
+               trigger_menu_panel.SetSizer(trigger_menu_box)
+               #trigger mode
+               trigger_mode_chooser = 
common.DropDownController(trigger_menu_panel, 'Mode', TRIGGER_MODES, parent, 
SCOPE_TRIGGER_MODE_KEY, SIZE)
+               trigger_menu_box.Add(trigger_mode_chooser, 0, wx.EXPAND)
+               #trigger slope
+               trigger_slope_chooser = 
common.DropDownController(trigger_menu_panel, 'Slope', TRIGGER_SLOPES, parent, 
SCOPE_TRIGGER_SLOPE_KEY, SIZE)
+               parent.subscribe(SCOPE_TRIGGER_MODE_KEY, lambda x: 
trigger_slope_chooser.Disable(x==gr.gr_TRIG_MODE_FREE))
+               trigger_menu_box.Add(trigger_slope_chooser, 0, wx.EXPAND)
+               #trigger channel
+               choices = [('Channel %d'%(i+1), i) for i in 
range(parent.num_inputs)]
+               trigger_channel_chooser = 
common.DropDownController(trigger_menu_panel, 'Channel', choices, parent, 
SCOPE_TRIGGER_CHANNEL_KEY, SIZE)
+               parent.subscribe(SCOPE_TRIGGER_MODE_KEY, lambda x: 
trigger_channel_chooser.Disable(x==gr.gr_TRIG_MODE_FREE))
+               trigger_menu_box.Add(trigger_channel_chooser, 0, wx.EXPAND)
+               #trigger level
+               hbox = wx.BoxSizer(wx.HORIZONTAL)
+               trigger_menu_box.Add(hbox, 0, wx.EXPAND)
+               hbox.Add(wx.StaticText(trigger_menu_panel, -1, ' Level '), 1, 
wx.ALIGN_CENTER_VERTICAL)
+               trigger_level_button = wx.Button(trigger_menu_panel, 
label='50%', style=wx.BU_EXACTFIT)
+               def trigger_level_button_disable(x):
+                       if x==gr.gr_TRIG_MODE_FREE: 
trigger_level_button.Disable()
+                       else: trigger_level_button.Enable()
+               parent.subscribe(SCOPE_TRIGGER_MODE_KEY, 
trigger_level_button_disable)
+               trigger_level_button.Bind(wx.EVT_BUTTON, 
self.parent.set_auto_trigger_level)
+               hbox.Add(trigger_level_button, 0, wx.ALIGN_CENTER_VERTICAL)
+               hbox.AddSpacer(10)
+               trigger_level_buttons = 
common.IncrDecrButtons(trigger_menu_panel, self._on_incr_trigger_level, 
self._on_decr_trigger_level)
+               parent.subscribe(SCOPE_TRIGGER_MODE_KEY, lambda x: 
trigger_level_buttons.Disable(x==gr.gr_TRIG_MODE_FREE))
+               hbox.Add(trigger_level_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
+               ##################################################
+               # Run/Stop Button
+               ##################################################
                #run/stop
                self.run_button = common.ToggleButtonController(self, parent, 
RUNNING_KEY, 'Stop', 'Run')
                control_box.Add(self.run_button, 0, wx.EXPAND)
@@ -211,10 +251,6 @@
        ##################################################
        # Event handlers
        ##################################################
-       def _on_scope_xy_mode(self, mode):
-               self.scope_mode_box.ShowItems(not mode)
-               self.xy_mode_box.ShowItems(mode)
-               self.control_box.Layout()
        #trigger level
        def _on_incr_trigger_level(self, event):
                self.parent[SCOPE_TRIGGER_LEVEL_KEY] += 
self.parent[Y_PER_DIV_KEY]/3.
@@ -234,10 +270,6 @@
        def _on_decr_y_divs(self, event):
                self.parent[Y_PER_DIV_KEY] = 
common.get_clean_decr(self.parent[Y_PER_DIV_KEY])
        #incr/decr offset
-       def _on_incr_t_off(self, event):
-               self.parent[T_OFF_KEY] = self.parent[T_OFF_KEY] + 
self.parent[T_PER_DIV_KEY]
-       def _on_decr_t_off(self, event):
-               self.parent[T_OFF_KEY] = self.parent[T_OFF_KEY] - 
self.parent[T_PER_DIV_KEY]
        def _on_incr_x_off(self, event):
                self.parent[X_OFF_KEY] = self.parent[X_OFF_KEY] + 
self.parent[X_PER_DIV_KEY]
        def _on_decr_x_off(self, event):
@@ -304,8 +336,10 @@
                self.SetSizerAndFit(main_box)
                #initialize values
                self[RUNNING_KEY] = True
-               self[AC_COUPLE_KEY] = ac_couple
-               self[SCOPE_XY_MODE_KEY] = xy_mode
+               for i in range(self.num_inputs):
+                       self[index_key(AC_COUPLE_KEY, i)] = ac_couple
+                       self[index_key(MARKER_KEY, i)] = DEFAULT_MARKER_TYPE
+               self[SCOPE_MODE_KEY] = xy_mode
                self[AUTORANGE_KEY] = autorange
                self[T_PER_DIV_KEY] = t_scale
                self[X_PER_DIV_KEY] = v_scale
@@ -316,35 +350,28 @@
                self[T_DIVS_KEY] = 8
                self[X_DIVS_KEY] = 8
                self[Y_DIVS_KEY] = 8
-               self[SCOPE_X_CHANNEL_KEY] = 0
-               self[SCOPE_Y_CHANNEL_KEY] = num_inputs-1
                self[FRAME_RATE_KEY] = frame_rate
-               self[MARKER_KEY] = DEFAULT_MARKER_TYPE
                self[SCOPE_TRIGGER_LEVEL_KEY] = 0
                self[SCOPE_TRIGGER_CHANNEL_KEY] = 0
                self[SCOPE_TRIGGER_MODE_KEY] = gr.gr_TRIG_MODE_AUTO
                self[SCOPE_TRIGGER_SLOPE_KEY] = gr.gr_TRIG_SLOPE_POS
+               self[T_FRAC_OFF_KEY] = 0
                #register events for trigger
                for key in (
                        SCOPE_TRIGGER_LEVEL_KEY, SCOPE_TRIGGER_MODE_KEY,
                        T_PER_DIV_KEY, T_OFF_KEY, T_DIVS_KEY,
                        Y_PER_DIV_KEY, Y_OFF_KEY, Y_DIVS_KEY,
-                       SCOPE_XY_MODE_KEY,
+                       SCOPE_MODE_KEY, SCOPE_TRIGGER_SHOW_KEY,
                ): self.subscribe(key, self.update_trigger)
                #register events for message
                self.subscribe(MSG_KEY, self.handle_msg)
                #register events for grid
-               for key in (
+               for key in [index_key(AC_COUPLE_KEY, i) for i in 
range(self.num_inputs)] + [index_key(MARKER_KEY, i) for i in 
range(self.num_inputs)] + [
                        T_PER_DIV_KEY, X_PER_DIV_KEY, Y_PER_DIV_KEY,
                        T_OFF_KEY, X_OFF_KEY, Y_OFF_KEY,
                        T_DIVS_KEY, X_DIVS_KEY, Y_DIVS_KEY,
-                       SCOPE_XY_MODE_KEY,
-                       SCOPE_X_CHANNEL_KEY,
-                       SCOPE_Y_CHANNEL_KEY,
-                       AUTORANGE_KEY,
-                       AC_COUPLE_KEY,
-                       MARKER_KEY,
-               ): self.subscribe(key, self.update_grid)
+                       SCOPE_MODE_KEY, AUTORANGE_KEY, T_FRAC_OFF_KEY,
+               ]: self.subscribe(key, self.update_grid)
                #initial update
                self.update_trigger()
                self.update_grid()
@@ -390,8 +417,8 @@
                        self[SCOPE_TRIGGER_LEVEL_KEY] = self.get_y_min()
                        return
                #disable the trigger channel
-               if self[SCOPE_XY_MODE_KEY] or self[SCOPE_TRIGGER_MODE_KEY] == 
gr.gr_TRIG_MODE_FREE:
-                       self.plotter.set_waveform(channel='Trig')
+               if not self[SCOPE_TRIGGER_SHOW_KEY] or self[SCOPE_MODE_KEY] or 
self[SCOPE_TRIGGER_MODE_KEY] == gr.gr_TRIG_MODE_FREE:
+                       self.plotter.clear_waveform(channel='Trig')
                else: #show trigger channel
                        trigger_level = self[SCOPE_TRIGGER_LEVEL_KEY]
                        self.plotter.set_waveform(
@@ -412,38 +439,38 @@
                if not self.sampleses: return
                sampleses = self.sampleses
                #ac coupling
-               if self[AC_COUPLE_KEY]:
-                       sampleses = [samples - numpy.average(samples) for 
samples in sampleses]
-               if self[SCOPE_XY_MODE_KEY]:
-                       x_samples = sampleses[self[SCOPE_X_CHANNEL_KEY]]
-                       y_samples = sampleses[self[SCOPE_Y_CHANNEL_KEY]]
+               for i in range(self.num_inputs):
+                       if self[index_key(AC_COUPLE_KEY, i)]: sampleses[i] -= 
numpy.average(sampleses[i])
+               if self[SCOPE_MODE_KEY]:
+                       x_samples = sampleses[self[SCOPE_MODE_KEY][1]]
+                       y_samples = sampleses[self[SCOPE_MODE_KEY][0]]
                        #autorange
                        if self[AUTORANGE_KEY] and time.time() - 
self.autorange_ts > AUTORANGE_UPDATE_RATE:
                                x_min, x_max = common.get_min_max(x_samples)
                                y_min, y_max = common.get_min_max(y_samples)
                                #adjust the x per div
                                x_per_div = 
common.get_clean_num((x_max-x_min)/self[X_DIVS_KEY])
-                               if x_per_div != self[X_PER_DIV_KEY]: 
self[X_PER_DIV_KEY] = x_per_div
+                               if x_per_div != self[X_PER_DIV_KEY]: 
self[X_PER_DIV_KEY] = x_per_div; return
                                #adjust the x offset
                                x_off = 
x_per_div*round((x_max+x_min)/2/x_per_div)
-                               if x_off != self[X_OFF_KEY]: self[X_OFF_KEY] = 
x_off
+                               if x_off != self[X_OFF_KEY]: self[X_OFF_KEY] = 
x_off; return
                                #adjust the y per div
                                y_per_div = 
common.get_clean_num((y_max-y_min)/self[Y_DIVS_KEY])
-                               if y_per_div != self[Y_PER_DIV_KEY]: 
self[Y_PER_DIV_KEY] = y_per_div
+                               if y_per_div != self[Y_PER_DIV_KEY]: 
self[Y_PER_DIV_KEY] = y_per_div; return
                                #adjust the y offset
                                y_off = 
y_per_div*round((y_max+y_min)/2/y_per_div)
-                               if y_off != self[Y_OFF_KEY]: self[Y_OFF_KEY] = 
y_off
+                               if y_off != self[Y_OFF_KEY]: self[Y_OFF_KEY] = 
y_off; return
                                self.autorange_ts = time.time()
                        #plot xy channel
                        self.plotter.set_waveform(
                                channel='XY',
                                samples=(x_samples, y_samples),
                                color_spec=CHANNEL_COLOR_SPECS[0],
-                               marker=self[MARKER_KEY],
+                               marker=self[index_key(MARKER_KEY, 0)],
                        )
                        #turn off each waveform
                        for i, samples in enumerate(sampleses):
-                               self.plotter.set_waveform(channel='Ch%d'%(i+1))
+                               
self.plotter.clear_waveform(channel='Ch%d'%(i+1))
                else:
                        #autorange
                        if self[AUTORANGE_KEY] and time.time() - 
self.autorange_ts > AUTORANGE_UPDATE_RATE:
@@ -452,15 +479,19 @@
                                y_max = numpy.max([bound[1] for bound in 
bounds])
                                #adjust the y per div
                                y_per_div = 
common.get_clean_num((y_max-y_min)/self[Y_DIVS_KEY])
-                               if y_per_div != self[Y_PER_DIV_KEY]: 
self[Y_PER_DIV_KEY] = y_per_div
+                               if y_per_div != self[Y_PER_DIV_KEY]: 
self[Y_PER_DIV_KEY] = y_per_div; return
                                #adjust the y offset
                                y_off = 
y_per_div*round((y_max+y_min)/2/y_per_div)
-                               if y_off != self[Y_OFF_KEY]: self[Y_OFF_KEY] = 
y_off
+                               if y_off != self[Y_OFF_KEY]: self[Y_OFF_KEY] = 
y_off; return
                                self.autorange_ts = time.time()
                        #number of samples to scale to the screen
                        actual_rate = self[SAMPLE_RATE_KEY]/self[DECIMATION_KEY]
                        time_span = self[T_PER_DIV_KEY]*self[T_DIVS_KEY]
                        num_samps = int(round(time_span*actual_rate))
+                       #handle the time offset
+                       t_off = 
self[T_FRAC_OFF_KEY]*(len(sampleses[0])/actual_rate - time_span)
+                       if t_off != self[T_OFF_KEY]: self[T_OFF_KEY] = t_off; 
return
+                       samps_off = int(round(actual_rate*self[T_OFF_KEY]))
                        #adjust the decim so that we use about half the samps
                        self[DECIMATION_KEY] = int(round(
                                        
time_span*self[SAMPLE_RATE_KEY]/(0.5*len(sampleses[0]))
@@ -474,13 +505,13 @@
                                        #plot samples
                                        self.plotter.set_waveform(
                                                channel='Ch%d'%(i+1),
-                                               samples=samples[:num_samps],
+                                               
samples=samples[samps_off:num_samps+samps_off],
                                                
color_spec=CHANNEL_COLOR_SPECS[i],
-                                               marker=self[MARKER_KEY],
+                                               
marker=self[index_key(MARKER_KEY, i)],
                                                trig_off=self.trigger_offset,
                                        )
                        #turn XY channel off
-                       self.plotter.set_waveform(channel='XY')
+                       self.plotter.clear_waveform(channel='XY')
                #update the plotter
                self.plotter.update()
 
@@ -496,12 +527,12 @@
                Update the grid to reflect the current settings:
                xy divisions, xy offset, xy mode setting
                """
-               if self[SCOPE_XY_MODE_KEY]:
+               if self[SCOPE_MODE_KEY]:
                        #update the x axis
-                       
self.plotter.set_x_label('Ch%d'%(self[SCOPE_X_CHANNEL_KEY]+1))
+                       
self.plotter.set_x_label('Ch%d'%(self[SCOPE_MODE_KEY][1]+1))
                        self.plotter.set_x_grid(self.get_x_min(), 
self.get_x_max(), self[X_PER_DIV_KEY])
                        #update the y axis
-                       
self.plotter.set_y_label('Ch%d'%(self[SCOPE_Y_CHANNEL_KEY]+1))
+                       
self.plotter.set_y_label('Ch%d'%(self[SCOPE_MODE_KEY][0]+1))
                        self.plotter.set_y_grid(self.get_y_min(), 
self.get_y_max(), self[Y_PER_DIV_KEY])
                else:
                        #update the t axis

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-23 02:14:39 UTC (rev 10478)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py 
    2009-02-23 04:32:50 UTC (rev 10479)
@@ -47,7 +47,7 @@
                t_scale=None,
                num_inputs=1,
                ac_couple=False,
-               xy_mode=False,
+               xy_mode=None,
                frame_rate=scope_window.DEFAULT_FRAME_RATE,
        ):
                if t_scale is None: t_scale = 0.001
@@ -110,6 +110,7 @@
                )
                common.register_access_methods(self, self.controller)
                #backwards compadibility
+               def setter(x, y, z): x[y] = z
                self.win.set_format_line = lambda: setter(self.win, MARKER_KEY, 
None)
                self.win.set_format_dot = lambda: setter(self.win, MARKER_KEY, 
2.0)
                self.win.set_format_plus =  lambda: setter(self.win, 
MARKER_KEY, 3.0)





reply via email to

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