commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10472 - gnuradio/branches/developers/jblum/gui_guts/g


From: jblum
Subject: [Commit-gnuradio] r10472 - gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python
Date: Fri, 20 Feb 2009 21:55:12 -0700 (MST)

Author: jblum
Date: 2009-02-20 21:55:11 -0700 (Fri, 20 Feb 2009)
New Revision: 10472

Modified:
   gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/common.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/const_window.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/constsink_gl.py
   gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/fft_window.py
   gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/fftsink_gl.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/number_window.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/numbersink2.py
   gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/pubsub.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/waterfall_window.py
   
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/waterfallsink_gl.py
Log:
Made use of the proxy method of the pubsub.
Cleaned up some code real nice.



Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/common.py
===================================================================
--- gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/common.py   
2009-02-20 20:27:49 UTC (rev 10471)
+++ gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/common.py   
2009-02-21 04:55:11 UTC (rev 10472)
@@ -24,11 +24,17 @@
 import math
 import wx
 
-class prop_setter(object):
-       def _register_set_prop(self, controller, control_key, *args):
-               def set_method(value): controller[control_key] = value
-               if args: set_method(args[0])
-               setattr(self, 'set_%s'%control_key, set_method)
+def register_access_methods(destination, controller):
+       """
+       Register setter and getter functions in the destination object for all 
keys in the controller.
+       @param destination the object to get new setter and getter methods
+       @param controller the pubsub controller
+       """
+       for key in controller.keys():
+               def set(value): controller[key] = value
+               setattr(destination, 'set_'+key, set)
+               def get(): return controller[key]
+               setattr(destination, 'get_'+key, get) 
 
 ##################################################
 # Custom Data Event
@@ -48,16 +54,18 @@
        Read messages from the message queue.
        Forward messages to the message handler.
        """
-       def __init__ (self, msgq, handle_msg):
+       def __init__ (self, msgq, controller, key):
                threading.Thread.__init__(self)
                self.setDaemon(1)
                self.msgq = msgq
-               self._handle_msg = handle_msg
+               self._controller = controller
+               self._key = key
                self.keep_running = True
                self.start()
 
        def run(self):
-               while self.keep_running: 
self._handle_msg(self.msgq.delete_head().to_string())
+               while self.keep_running:
+                       self._controller[self._key] = 
self.msgq.delete_head().to_string()
 
 ##################################################
 # WX Shared Classes

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/const_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/const_window.py 
    2009-02-20 20:27:49 UTC (rev 10471)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/const_window.py 
    2009-02-21 04:55:11 UTC (rev 10472)
@@ -77,7 +77,7 @@
                self.alpha_slider = common.LogSliderController(
                        self, 'Alpha',
                        ALPHA_MIN_EXP, ALPHA_MAX_EXP, SLIDER_STEPS,
-                       parent.ext_controller, parent.alpha_key,
+                       parent, ALPHA_KEY,
                )
                control_box.Add(self.alpha_slider, 0, wx.EXPAND)
                #gain_mu
@@ -85,7 +85,7 @@
                self.gain_mu_slider = common.LogSliderController(
                        self, 'Gain Mu',
                        GAIN_MU_MIN_EXP, GAIN_MU_MAX_EXP, SLIDER_STEPS,
-                       parent.ext_controller, parent.gain_mu_key,
+                       parent, GAIN_MU_KEY,
                )
                control_box.Add(self.gain_mu_slider, 0, wx.EXPAND)
                #run/stop
@@ -98,7 +98,7 @@
 ##################################################
 # Constellation window with plotter and control panel
 ##################################################
-class const_window(wx.Panel, pubsub.pubsub, common.prop_setter):
+class const_window(wx.Panel, pubsub.pubsub):
        def __init__(
                self,
                parent,
@@ -110,14 +110,18 @@
                beta_key,
                gain_mu_key,
                gain_omega_key,
+               omega_key,
+               sample_rate_key,
        ):
                pubsub.pubsub.__init__(self)
-               #setup
-               self.ext_controller = controller
-               self.alpha_key = alpha_key
-               self.beta_key = beta_key
-               self.gain_mu_key = gain_mu_key
-               self.gain_omega_key = gain_omega_key
+               #proxy the keys
+               self.proxy(MSG_KEY, controller, msg_key)
+               self.proxy(ALPHA_KEY, controller, alpha_key)
+               self.proxy(BETA_KEY, controller, beta_key)
+               self.proxy(GAIN_MU_KEY, controller, gain_mu_key)
+               self.proxy(GAIN_OMEGA_KEY, controller, gain_omega_key)
+               self.proxy(OMEGA_KEY, controller, omega_key)
+               self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
                #init panel and plot
                wx.Panel.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
                self.plotter = plotter.channel_plotter(self)
@@ -133,19 +137,19 @@
                main_box.Add(self.control_panel, 0, wx.EXPAND)
                self.SetSizerAndFit(main_box)
                #alpha and gain mu 2nd orders
-               def set_beta(alpha): self.ext_controller[self.beta_key] = 
.25*alpha**2
-               self.ext_controller.subscribe(self.alpha_key, set_beta)
-               def set_gain_omega(gain_mu): 
self.ext_controller[self.gain_omega_key] = .25*gain_mu**2
-               self.ext_controller.subscribe(self.gain_mu_key, set_gain_omega)
-               #initial setup
-               self.ext_controller[self.alpha_key] = 
self.ext_controller[self.alpha_key]
-               self.ext_controller[self.gain_mu_key] = 
self.ext_controller[self.gain_mu_key]
-               self._register_set_prop(self, RUNNING_KEY, True)
-               self._register_set_prop(self, X_DIVS_KEY, 8)
-               self._register_set_prop(self, Y_DIVS_KEY, 8)
-               self._register_set_prop(self, MARKER_KEY, DEFAULT_MARKER_TYPE)
+               def set_beta(alpha): self[BETA_KEY] = .25*alpha**2
+               self.subscribe(ALPHA_KEY, set_beta)
+               def set_gain_omega(gain_mu): self[GAIN_OMEGA_KEY] = 
.25*gain_mu**2
+               self.subscribe(GAIN_MU_KEY, set_gain_omega)
+               #initialize values
+               self[ALPHA_KEY] = self[ALPHA_KEY]
+               self[GAIN_MU_KEY] = self[GAIN_MU_KEY]
+               self[RUNNING_KEY] = True
+               self[X_DIVS_KEY] = 8
+               self[Y_DIVS_KEY] = 8
+               self[MARKER_KEY] = DEFAULT_MARKER_TYPE
                #register events
-               self.ext_controller.subscribe(msg_key, self.handle_msg)
+               self.subscribe(MSG_KEY, self.handle_msg)
                for key in (
                        X_DIVS_KEY, Y_DIVS_KEY,
                ): self.subscribe(key, self.update_grid)

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/constsink_gl.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/constsink_gl.py 
    2009-02-20 20:27:49 UTC (rev 10471)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/constsink_gl.py 
    2009-02-21 04:55:11 UTC (rev 10472)
@@ -31,7 +31,7 @@
 ##################################################
 # Constellation sink block (wrapper for old wxgui)
 ##################################################
-class const_sink_c(gr.hier_block2, common.prop_setter):
+class const_sink_c(gr.hier_block2):
        """
        A constellation block with a gui window.
        """
@@ -116,7 +116,7 @@
                #initial update
                self.controller[SAMPLE_RATE_KEY] = sample_rate
                #start input watcher
-               common.input_watcher(msgq, lambda x: setter(self.controller, 
MSG_KEY, x))
+               common.input_watcher(msgq, self.controller, MSG_KEY)
                #create window
                self.win = const_window.const_window(
                        parent=parent,
@@ -128,15 +128,9 @@
                        beta_key=BETA_KEY,
                        gain_mu_key=GAIN_MU_KEY,
                        gain_omega_key=GAIN_OMEGA_KEY,
+                       omega_key=OMEGA_KEY,
+                       sample_rate_key=SAMPLE_RATE_KEY,
                )
-               #register callbacks from window for external use
-               for attr in filter(lambda a: a.startswith('set_'), 
dir(self.win)):
-                       setattr(self, attr, getattr(self.win, attr))
-               self._register_set_prop(self.controller, ALPHA_KEY)
-               self._register_set_prop(self.controller, BETA_KEY)
-               self._register_set_prop(self.controller, GAIN_MU_KEY)
-               self._register_set_prop(self.controller, OMEGA_KEY)
-               self._register_set_prop(self.controller, GAIN_OMEGA_KEY)
-               self._register_set_prop(self.controller, SAMPLE_RATE_KEY)
+               common.register_access_methods(self, self.controller)
 
 

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/fft_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/fft_window.py   
    2009-02-20 20:27:49 UTC (rev 10471)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/fft_window.py   
    2009-02-21 04:55:11 UTC (rev 10472)
@@ -62,7 +62,7 @@
                #checkboxes for average and peak hold
                control_box.AddStretchSpacer()
                control_box.Add(common.LabelText(self, 'Options'), 0, 
wx.ALIGN_CENTER)
-               self.average_check_box = common.CheckBoxController(self, 
'Average', parent.ext_controller, parent.average_key)
+               self.average_check_box = common.CheckBoxController(self, 
'Average', parent, AVERAGE_KEY)
                control_box.Add(self.average_check_box, 0, wx.EXPAND)
                self.peak_hold_check_box = common.CheckBoxController(self, 
'Peak Hold', parent, PEAK_HOLD_KEY)
                control_box.Add(self.peak_hold_check_box, 0, wx.EXPAND)
@@ -70,10 +70,10 @@
                self.avg_alpha_slider = common.LogSliderController(
                        self, 'Avg Alpha',
                        AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP, SLIDER_STEPS,
-                       parent.ext_controller, parent.avg_alpha_key,
+                       parent, AVG_ALPHA_KEY,
                        formatter=lambda x: ': %.4f'%x,
                )
-               parent.ext_controller.subscribe(parent.average_key, 
self.avg_alpha_slider.Enable)
+               parent.subscribe(AVERAGE_KEY, self.avg_alpha_slider.Enable)
                control_box.Add(self.avg_alpha_slider, 0, wx.EXPAND)
                #radio buttons for div size
                control_box.AddStretchSpacer()
@@ -117,16 +117,14 @@
                index = self.radio_buttons.index(selected_radio_button)
                self.parent[Y_PER_DIV_KEY] = DIV_LEVELS[index]
        def _on_incr_ref_level(self, event):
-               self.parent.set_ref_level(
-                       self.parent[REF_LEVEL_KEY] + self.parent[Y_PER_DIV_KEY])
+               self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] + 
self.parent[Y_PER_DIV_KEY]
        def _on_decr_ref_level(self, event):
-               self.parent.set_ref_level(
-                       self.parent[REF_LEVEL_KEY] - self.parent[Y_PER_DIV_KEY])
+               self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] - 
self.parent[Y_PER_DIV_KEY]
 
 ##################################################
 # FFT window with plotter and control panel
 ##################################################
-class fft_window(wx.Panel, pubsub.pubsub, common.prop_setter):
+class fft_window(wx.Panel, pubsub.pubsub):
        def __init__(
                self,
                parent,
@@ -150,13 +148,14 @@
                if y_per_div not in DIV_LEVELS: y_per_div = DIV_LEVELS[0]
                #setup
                self.samples = list()
-               self.ext_controller = controller
                self.real = real
                self.fft_size = fft_size
-               self.sample_rate_key = sample_rate_key
-               self.average_key = average_key
-               self.avg_alpha_key = avg_alpha_key
                self._reset_peak_vals()
+               #proxy the keys
+               self.proxy(MSG_KEY, controller, msg_key)
+               self.proxy(AVERAGE_KEY, controller, average_key)
+               self.proxy(AVG_ALPHA_KEY, controller, avg_alpha_key)
+               self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
                #init panel and plot
                wx.Panel.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
                self.plotter = plotter.channel_plotter(self)
@@ -169,21 +168,21 @@
                main_box.Add(self.plotter, 1, wx.EXPAND)
                main_box.Add(self.control_panel, 0, wx.EXPAND)
                self.SetSizerAndFit(main_box)
-               #initial setup
-               self.ext_controller[self.average_key] = 
self.ext_controller[self.average_key]
-               self.ext_controller[self.avg_alpha_key] = 
self.ext_controller[self.avg_alpha_key]
-               self._register_set_prop(self, PEAK_HOLD_KEY, peak_hold)
-               self._register_set_prop(self, Y_PER_DIV_KEY, y_per_div)
-               self._register_set_prop(self, Y_DIVS_KEY, y_divs)
-               self._register_set_prop(self, X_DIVS_KEY, 8) #approximate
-               self._register_set_prop(self, REF_LEVEL_KEY, ref_level)
-               self._register_set_prop(self, BASEBAND_FREQ_KEY, baseband_freq)
-               self._register_set_prop(self, RUNNING_KEY, True)
+               #initialize values
+               self[AVERAGE_KEY] = self[AVERAGE_KEY]
+               self[AVG_ALPHA_KEY] = self[AVG_ALPHA_KEY]
+               self[PEAK_HOLD_KEY] = peak_hold
+               self[Y_PER_DIV_KEY] = y_per_div
+               self[Y_DIVS_KEY] = y_divs
+               self[X_DIVS_KEY] = 8 #approximate
+               self[REF_LEVEL_KEY] = ref_level
+               self[BASEBAND_FREQ_KEY] = baseband_freq
+               self[RUNNING_KEY] = True
                #register events
                self.subscribe(PEAK_HOLD_KEY, self.plotter.enable_legend)
-               self.ext_controller.subscribe(AVERAGE_KEY, lambda x: 
self._reset_peak_vals())
-               self.ext_controller.subscribe(msg_key, self.handle_msg)
-               self.ext_controller.subscribe(self.sample_rate_key, 
self.update_grid)
+               self.subscribe(AVERAGE_KEY, lambda x: self._reset_peak_vals())
+               self.subscribe(MSG_KEY, self.handle_msg)
+               self.subscribe(SAMPLE_RATE_KEY, self.update_grid)
                for key in (
                        BASEBAND_FREQ_KEY,
                        Y_PER_DIV_KEY, X_DIVS_KEY,
@@ -207,9 +206,9 @@
                noise_floor -= abs(noise_floor)*.5
                peak_level += abs(peak_level)*.1
                #set the reference level to a multiple of y divs
-               
self.set_ref_level(self[Y_DIVS_KEY]*math.ceil(peak_level/self[Y_DIVS_KEY]))
+               self[REF_LEVEL_KEY] = 
self[Y_DIVS_KEY]*math.ceil(peak_level/self[Y_DIVS_KEY])
                #set the range to a clean number of the dynamic range
-               self.set_y_per_div(common.get_clean_num((peak_level - 
noise_floor)/self[Y_DIVS_KEY]))
+               self[Y_PER_DIV_KEY] = common.get_clean_num((peak_level - 
noise_floor)/self[Y_DIVS_KEY])
 
        def _reset_peak_vals(self): self.peak_vals = NO_PEAK_VALS
 
@@ -259,7 +258,7 @@
                The y axis depends on y per div, y divs, and ref level.
                """
                #grid parameters
-               sample_rate = self.ext_controller[self.sample_rate_key]
+               sample_rate = self[SAMPLE_RATE_KEY]
                baseband_freq = self[BASEBAND_FREQ_KEY]
                y_per_div = self[Y_PER_DIV_KEY]
                y_divs = self[Y_DIVS_KEY]

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/fftsink_gl.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/fftsink_gl.py   
    2009-02-20 20:27:49 UTC (rev 10471)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/fftsink_gl.py   
    2009-02-21 04:55:11 UTC (rev 10472)
@@ -31,7 +31,7 @@
 ##################################################
 # FFT sink block (wrapper for old wxgui)
 ##################################################
-class _fft_sink_base(gr.hier_block2, common.prop_setter):
+class _fft_sink_base(gr.hier_block2):
        """
        An fft block with real/complex inputs and a gui window.
        """
@@ -85,9 +85,7 @@
                self.controller.subscribe(SAMPLE_RATE_KEY, fft.set_sample_rate)
                self.controller.publish(SAMPLE_RATE_KEY, fft.sample_rate)
                #start input watcher
-               def setter(p, k, x): # lambdas can't have assignments :(
-                   p[k] = x
-               common.input_watcher(msgq, lambda x: setter(self.controller, 
MSG_KEY, x))
+               common.input_watcher(msgq, self.controller, MSG_KEY)
                #create window
                self.win = fft_window.fft_window(
                        parent=parent,
@@ -106,12 +104,7 @@
                        peak_hold=peak_hold,
                        msg_key=MSG_KEY,
                )
-               #register callbacks from window for external use
-               for attr in filter(lambda a: a.startswith('set_'), 
dir(self.win)):
-                       setattr(self, attr, getattr(self.win, attr))
-               self._register_set_prop(self.controller, SAMPLE_RATE_KEY)
-               self._register_set_prop(self.controller, AVERAGE_KEY)
-               self._register_set_prop(self.controller, AVG_ALPHA_KEY)
+               common.register_access_methods(self, self.controller)
 
 class fft_sink_f(_fft_sink_base):
        _fft_chain = blks2.logpwrfft_f

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/number_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/number_window.py
    2009-02-20 20:27:49 UTC (rev 10471)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/number_window.py
    2009-02-21 04:55:11 UTC (rev 10472)
@@ -58,7 +58,7 @@
                #checkboxes for average and peak hold
                control_box.AddStretchSpacer()
                control_box.Add(common.LabelText(self, 'Options'), 0, 
wx.ALIGN_CENTER)
-               self.average_check_box = common.CheckBoxController(self, 
'Average', parent.ext_controller, parent.average_key)
+               self.average_check_box = common.CheckBoxController(self, 
'Average', parent, AVERAGE_KEY)
                control_box.Add(self.average_check_box, 0, wx.EXPAND)
                self.peak_hold_check_box = common.CheckBoxController(self, 
'Peak Hold', parent, PEAK_HOLD_KEY)
                control_box.Add(self.peak_hold_check_box, 0, wx.EXPAND)
@@ -66,10 +66,10 @@
                self.avg_alpha_slider = common.LogSliderController(
                        self, 'Avg Alpha',
                        AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP, SLIDER_STEPS,
-                       parent.ext_controller, parent.avg_alpha_key,
+                       parent, AVG_ALPHA_KEY,
                        formatter=lambda x: ': %.4f'%x,
                )
-               parent.ext_controller.subscribe(parent.average_key, 
self.avg_alpha_slider.Enable)
+               parent.subscribe(AVERAGE_KEY, self.avg_alpha_slider.Enable)
                control_box.Add(self.avg_alpha_slider, 0, wx.EXPAND)
                #run/stop
                control_box.AddStretchSpacer()
@@ -81,7 +81,7 @@
 ##################################################
 # Numbersink window with label and gauges
 ##################################################
-class number_window(wx.Panel, pubsub.pubsub, common.prop_setter):
+class number_window(wx.Panel, pubsub.pubsub):
        def __init__(
                self,
                parent,
@@ -98,20 +98,23 @@
                avg_alpha_key,
                peak_hold,
                msg_key,
+               sample_rate_key,
        ):
                pubsub.pubsub.__init__(self)
                wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER)
                #setup
                self.peak_val_real = NEG_INF
                self.peak_val_imag = NEG_INF
-               self.ext_controller = controller
                self.real = real
                self.units = units
                self.minval = minval
                self.maxval = maxval
                self.decimal_places = decimal_places
-               self.average_key = average_key
-               self.avg_alpha_key = avg_alpha_key
+               #proxy the keys
+               self.proxy(MSG_KEY, controller, msg_key)
+               self.proxy(AVERAGE_KEY, controller, average_key)
+               self.proxy(AVG_ALPHA_KEY, controller, avg_alpha_key)
+               self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
                #setup the box with display and controls
                self.control_panel = control_panel(self)
                main_box = wx.BoxSizer(wx.HORIZONTAL)
@@ -128,13 +131,13 @@
                sizer.Add(self.gauge_real, 1, wx.EXPAND)
                sizer.Add(self.gauge_imag, 1, wx.EXPAND)
                self.SetSizerAndFit(main_box)
-               #initial setup
-               self.ext_controller[self.average_key] = 
self.ext_controller[self.average_key]
-               self.ext_controller[self.avg_alpha_key] = 
self.ext_controller[self.avg_alpha_key]
-               self._register_set_prop(self, PEAK_HOLD_KEY, peak_hold)
-               self._register_set_prop(self, RUNNING_KEY, True)
+               #initialize values
+               self[PEAK_HOLD_KEY] = peak_hold
+               self[RUNNING_KEY] = True
+               self[AVERAGE_KEY] = self[AVERAGE_KEY]
+               self[AVG_ALPHA_KEY] = self[AVG_ALPHA_KEY]
                #register events
-               self.ext_controller.subscribe(msg_key, self.handle_msg)
+               self.subscribe(MSG_KEY, self.handle_msg)
                self.Bind(common.EVT_DATA, self.update)
 
        def show_gauges(self, show_gauge):

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-20 20:27:49 UTC (rev 10471)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/numbersink2.py  
    2009-02-21 04:55:11 UTC (rev 10472)
@@ -31,7 +31,7 @@
 ##################################################
 # Number sink block (wrapper for old wxgui)
 ##################################################
-class _number_sink_base(gr.hier_block2, common.prop_setter):
+class _number_sink_base(gr.hier_block2):
        """
        An decimator block with a number window display
        """
@@ -90,13 +90,13 @@
                #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)
                #start input watcher
-               def set_msg(msg): self.controller[MSG_KEY] = msg
-               common.input_watcher(msgq, set_msg)
+               common.input_watcher(msgq, self.controller, MSG_KEY)
                #create window
                self.win = number_window.number_window(
                        parent=parent,
@@ -113,11 +113,9 @@
                        avg_alpha_key=AVG_ALPHA_KEY,
                        peak_hold=peak_hold,
                        msg_key=MSG_KEY,
+                       sample_rate_key=SAMPLE_RATE_KEY,
                )
-               #register callbacks from window for external use
-               for attr in filter(lambda a: a.startswith('set_'), 
dir(self.win)):
-                       setattr(self, attr, getattr(self.win, attr))
-               self._register_set_prop(self.controller, SAMPLE_RATE_KEY)
+               common.register_access_methods(self, self.controller)
                #backwards compadibility
                self.set_show_gauge = self.win.show_gauges
 

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/pubsub.py
===================================================================
--- gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/pubsub.py   
2009-02-20 20:27:49 UTC (rev 10471)
+++ gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/pubsub.py   
2009-02-21 04:55:11 UTC (rev 10472)
@@ -28,73 +28,73 @@
 
 class pubsub(dict):
     def __init__(self):
-       self._publishers = { }
-       self._subscribers = { }
-       self._proxies = { }
-       
+        self._publishers = { }
+        self._subscribers = { }
+        self._proxies = { }
+
     def __missing__(self, key, value=None):
-       dict.__setitem__(self, key, value)
-       self._publishers[key] = None
-       self._subscribers[key] = []
-       self._proxies[key] = None
-       
+        dict.__setitem__(self, key, value)
+        self._publishers[key] = None
+        self._subscribers[key] = []
+        self._proxies[key] = None
+
     def __setitem__(self, key, val):
-       if not self.has_key(key): 
-           self.__missing__(key, val)
-       elif self._proxies[key] is not None:
-           (p, newkey) = self._proxies[key]
-           p[newkey] = val
-       else:
-           dict.__setitem__(self, key, val)
-       for sub in self._subscribers[key]:
-           # Note this means subscribers will get called in the thread
-           # context of the 'set' caller.
-           sub(val)
+        if not self.has_key(key):
+            self.__missing__(key, val)
+        elif self._proxies[key] is not None:
+            (p, pkey) = self._proxies[key]
+            p[pkey] = val
+        else:
+            dict.__setitem__(self, key, val)
+        for sub in self._subscribers[key]:
+            # Note this means subscribers will get called in the thread
+            # context of the 'set' caller.
+            sub(val)
 
     def __getitem__(self, key):
-       if not self.has_key(key): self.__missing__(key)
-       if self._proxies[key] is not None:
-           (p, newkey) = self._proxies[key]
-           return p[newkey]
-       elif self._publishers[key] is not None:
-           return self._publishers[key]()
-       else:
-           return dict.__getitem__(self, key)
+        if not self.has_key(key): self.__missing__(key)
+        if self._proxies[key] is not None:
+            (p, pkey) = self._proxies[key]
+            return p[pkey]
+        elif self._publishers[key] is not None:
+            return self._publishers[key]()
+        else:
+            return dict.__getitem__(self, key)
 
     def publish(self, key, publisher):
-       if not self.has_key(key): self.__missing__(key)
+        if not self.has_key(key): self.__missing__(key)
         if self._proxies[key] is not None:
-            (p, newkey) = self._proxies[key]
-            p.publish(newkey, publisher)
+            (p, pkey) = self._proxies[key]
+            p.publish(pkey, publisher)
         else:
             self._publishers[key] = publisher
-       
+
     def subscribe(self, key, subscriber):
-       if not self.has_key(key): self.__missing__(key)
+        if not self.has_key(key): self.__missing__(key)
         if self._proxies[key] is not None:
-            (p, newkey) = self._proxies[key]
-            p.subscribe(newkey, subscriber)
+            (p, pkey) = self._proxies[key]
+            p.subscribe(pkey, subscriber)
         else:
             self._subscribers[key].append(subscriber)
-       
+
     def unpublish(self, key):
         if self._proxies[key] is not None:
-            (p, newkey) = self._proxies[key]
-            p.unpublish(newkey)
+            (p, pkey) = self._proxies[key]
+            p.unpublish(pkey)
         else:
             self._publishers[key] = None
-       
+
     def unsubscribe(self, key, subscriber):
         if self._proxies[key] is not None:
-            (p, newkey) = self._proxies[key]
-            p.unsubscribe(newkey, subscriber)
+            (p, pkey) = self._proxies[key]
+            p.unsubscribe(pkey, subscriber)
         else:
             self._subscribers[key].remove(subscriber)
 
-    def proxy(self, key, p, newkey=None):
-       if not self.has_key(key): self.__missing__(key)
-       if newkey is None: newkey = key
-       self._proxies[key] = (p, newkey)        
+    def proxy(self, key, p, pkey=None):
+        if not self.has_key(key): self.__missing__(key)
+        if pkey is None: pkey = key
+        self._proxies[key] = (p, pkey)
 
     def unproxy(self, key):
         self._proxies[key] = None
@@ -110,22 +110,22 @@
     # Add some subscribers
     # First is a bare function
     def print_len(x):
-       print "len=%i" % (len(x), )
+        print "len=%i" % (len(x), )
     o.subscribe('foo', print_len)
 
     # The second is a class member function
     class subber(object):
-       def __init__(self, param):
-           self._param = param
-       def printer(self, x):
-           print self._param, `x`
+        def __init__(self, param):
+            self._param = param
+        def printer(self, x):
+            print self._param, `x`
     s = subber('param')
     o.subscribe('foo', s.printer)
 
     # The third is a lambda function
     o.subscribe('foo', lambda x: sys.stdout.write('val='+`x`+'\n'))
 
-    # Update key 'foo', will notify subscribers    
+    # Update key 'foo', will notify subscribers
     print "Updating 'foo' with three subscribers:"
     o['foo'] = 'bar';
 
@@ -135,7 +135,7 @@
     # Update now will only trigger second and third subscriber
     print "Updating 'foo' after removing a subscriber:"
     o['foo'] = 'bar2';
-    
+
     # Publish a key as a function, in this case, a lambda function
     o.publish('baz', lambda : 42)
     print "Published value of 'baz':", o['baz']
@@ -145,7 +145,7 @@
 
     # This will return None, as there is no publisher
     print "Value of 'baz' with no publisher:", o['baz']
-    
+
     # Set 'baz' key, it gets cached
     o['baz'] = 'bazzz'
 

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-20 20:27:49 UTC (rev 10471)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py 
    2009-02-21 04:55:11 UTC (rev 10472)
@@ -81,18 +81,18 @@
                control_box.AddStretchSpacer()
                control_box.Add(common.LabelText(self, 'Trigger Options'), 0, 
wx.ALIGN_CENTER)
                control_box.AddSpacer(2)
-               #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.ext_controller, parent.trigger_channel_key)
-               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)
                #trigger mode
-               self.trigger_mode_chooser = common.DropDownController(self, 
'Mode', TRIGGER_MODES, parent.ext_controller, parent.trigger_mode_key)
+               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.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))
+               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)
@@ -101,12 +101,12 @@
                def trigger_level_button_disable(x):
                        if x==gr.gr_TRIG_MODE_FREE: 
trigger_level_button.Disable()
                        else: trigger_level_button.Enable()
-               parent.ext_controller.subscribe(parent.trigger_mode_key, 
trigger_level_button_disable)
+               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.ext_controller.subscribe(parent.trigger_mode_key, lambda 
x: trigger_level_buttons.Disable(x==gr.gr_TRIG_MODE_FREE))
+               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
@@ -217,54 +217,40 @@
                self.control_box.Layout()
        #trigger level
        def _on_incr_trigger_level(self, event):
-               self.parent.ext_controller[self.parent.trigger_level_key] += \
-                       self.parent[Y_PER_DIV_KEY]/3.
+               self.parent[SCOPE_TRIGGER_LEVEL_KEY] += 
self.parent[Y_PER_DIV_KEY]/3.
        def _on_decr_trigger_level(self, event):
-               self.parent.ext_controller[self.parent.trigger_level_key] -= \
-                       self.parent[Y_PER_DIV_KEY]/3.
+               self.parent[SCOPE_TRIGGER_LEVEL_KEY] -= 
self.parent[Y_PER_DIV_KEY]/3.
        #incr/decr divs
        def _on_incr_t_divs(self, event):
-               self.parent.set_t_per_div(
-                       common.get_clean_incr(self.parent[T_PER_DIV_KEY]))
+               self.parent[T_PER_DIV_KEY] = 
common.get_clean_incr(self.parent[T_PER_DIV_KEY])
        def _on_decr_t_divs(self, event):
-               self.parent.set_t_per_div(
-                       common.get_clean_decr(self.parent[T_PER_DIV_KEY]))
+               self.parent[T_PER_DIV_KEY] = 
common.get_clean_decr(self.parent[T_PER_DIV_KEY])
        def _on_incr_x_divs(self, event):
-               self.parent.set_x_per_div(
-                       common.get_clean_incr(self.parent[X_PER_DIV_KEY]))
+               self.parent[X_PER_DIV_KEY] = 
common.get_clean_incr(self.parent[X_PER_DIV_KEY])
        def _on_decr_x_divs(self, event):
-               self.parent.set_x_per_div(
-                       common.get_clean_decr(self.parent[X_PER_DIV_KEY]))
+               self.parent[X_PER_DIV_KEY] = 
common.get_clean_decr(self.parent[X_PER_DIV_KEY])
        def _on_incr_y_divs(self, event):
-               self.parent.set_y_per_div(
-                       common.get_clean_incr(self.parent[Y_PER_DIV_KEY]))
+               self.parent[Y_PER_DIV_KEY] = 
common.get_clean_incr(self.parent[Y_PER_DIV_KEY])
        def _on_decr_y_divs(self, event):
-               self.parent.set_y_per_div(
-                       common.get_clean_decr(self.parent[Y_PER_DIV_KEY]))
+               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.set_t_off(
-                       self.parent[T_OFF_KEY] + self.parent[T_PER_DIV_KEY])
+               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.set_t_off(
-                       self.parent[T_OFF_KEY] - self.parent[T_PER_DIV_KEY])
+               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.set_x_off(
-                       self.parent[X_OFF_KEY] + self.parent[X_PER_DIV_KEY])
+               self.parent[X_OFF_KEY] = self.parent[X_OFF_KEY] + 
self.parent[X_PER_DIV_KEY]
        def _on_decr_x_off(self, event):
-               self.parent.set_x_off(
-                       self.parent[X_OFF_KEY] - self.parent[X_PER_DIV_KEY])
+               self.parent[X_OFF_KEY] = self.parent[X_OFF_KEY] - 
self.parent[X_PER_DIV_KEY]
        def _on_incr_y_off(self, event):
-               self.parent.set_y_off(
-                       self.parent[Y_OFF_KEY] + self.parent[Y_PER_DIV_KEY])
+               self.parent[Y_OFF_KEY] = self.parent[Y_OFF_KEY] + 
self.parent[Y_PER_DIV_KEY]
        def _on_decr_y_off(self, event):
-               self.parent.set_y_off(
-                       self.parent[Y_OFF_KEY] - self.parent[Y_PER_DIV_KEY])
+               self.parent[Y_OFF_KEY] = self.parent[Y_OFF_KEY] - 
self.parent[Y_PER_DIV_KEY]
 
 ##################################################
 # Scope window with plotter and control panel
 ##################################################
-class scope_window(wx.Panel, pubsub.pubsub, common.prop_setter):
+class scope_window(wx.Panel, pubsub.pubsub):
        def __init__(
                self,
                parent,
@@ -290,19 +276,19 @@
                assert num_inputs <= len(CHANNEL_COLOR_SPECS)
                #setup
                self.sampleses = None
-               self.ext_controller = controller
                self.num_inputs = num_inputs
-               self.sample_rate_key = sample_rate_key
                autorange = v_scale is None
                self.autorange_ts = 0
                if v_scale is None: v_scale = 1
                self.frame_rate_ts = 0
-               #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
+               #proxy the keys
+               self.proxy(MSG_KEY, controller, msg_key)
+               self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
+               self.proxy(SCOPE_TRIGGER_LEVEL_KEY, controller, 
trigger_level_key)
+               self.proxy(SCOPE_TRIGGER_MODE_KEY, controller, trigger_mode_key)
+               self.proxy(SCOPE_TRIGGER_SLOPE_KEY, controller, 
trigger_slope_key)
+               self.proxy(SCOPE_TRIGGER_CHANNEL_KEY, controller, 
trigger_channel_key)
+               self.proxy(DECIMATION_KEY, controller, decimation_key)
                #init panel and plot
                wx.Panel.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
                self.plotter = plotter.channel_plotter(self)
@@ -316,38 +302,37 @@
                main_box.Add(self.plotter, 1, wx.EXPAND)
                main_box.Add(self.control_panel, 0, wx.EXPAND)
                self.SetSizerAndFit(main_box)
-               #initial setup
-               self._register_set_prop(self, RUNNING_KEY, True)
-               self._register_set_prop(self, AC_COUPLE_KEY, ac_couple)
-               self._register_set_prop(self, SCOPE_XY_MODE_KEY, xy_mode)
-               self._register_set_prop(self, AUTORANGE_KEY, autorange)
-               self._register_set_prop(self, T_PER_DIV_KEY, t_scale)
-               self._register_set_prop(self, X_PER_DIV_KEY, v_scale)
-               self._register_set_prop(self, Y_PER_DIV_KEY, v_scale)
-               self._register_set_prop(self, T_OFF_KEY, 0)
-               self._register_set_prop(self, X_OFF_KEY, 0)
-               self._register_set_prop(self, Y_OFF_KEY, 0)
-               self._register_set_prop(self, T_DIVS_KEY, 8)
-               self._register_set_prop(self, X_DIVS_KEY, 8)
-               self._register_set_prop(self, Y_DIVS_KEY, 8)
-               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)
-               self._register_set_prop(self, MARKER_KEY, DEFAULT_MARKER_TYPE)
-               self.ext_controller[self.trigger_level_key] = 0
-               self.ext_controller[self.trigger_channel_key] = 0
-               self.ext_controller[self.trigger_mode_key] = 
gr.gr_TRIG_MODE_AUTO
-               self.ext_controller[self.trigger_slope_key] = 
gr.gr_TRIG_SLOPE_POS
+               #initialize values
+               self[RUNNING_KEY] = True
+               self[AC_COUPLE_KEY] = ac_couple
+               self[SCOPE_XY_MODE_KEY] = xy_mode
+               self[AUTORANGE_KEY] = autorange
+               self[T_PER_DIV_KEY] = t_scale
+               self[X_PER_DIV_KEY] = v_scale
+               self[Y_PER_DIV_KEY] = v_scale
+               self[T_OFF_KEY] = 0
+               self[X_OFF_KEY] = 0
+               self[Y_OFF_KEY] = 0
+               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
                #register events for trigger
-               self.ext_controller.subscribe(self.trigger_level_key, 
self.update_trigger)
-               self.ext_controller.subscribe(self.trigger_mode_key, 
self.update_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,
                ): self.subscribe(key, self.update_trigger)
                #register events for message
-               self.ext_controller.subscribe(msg_key, self.handle_msg)
+               self.subscribe(MSG_KEY, self.handle_msg)
                #register events for grid
                for key in (
                        T_PER_DIV_KEY, X_PER_DIV_KEY, Y_PER_DIV_KEY,
@@ -390,25 +375,25 @@
                Use the current trigger channel and samples to calculate the 
50% level.
                """
                if not self.sampleses: return
-               samples = 
self.sampleses[self.ext_controller[self.trigger_channel_key]]
-               self.ext_controller[self.trigger_level_key] = 
(numpy.max(samples)+numpy.min(samples))/2
+               samples = self.sampleses[self[SCOPE_TRIGGER_CHANNEL_KEY]]
+               self[SCOPE_TRIGGER_LEVEL_KEY] = 
(numpy.max(samples)+numpy.min(samples))/2
 
        def update_trigger(self, *args):
                """
                Redraw the trigger line with current settings.
                """
                #keep trigger level within range
-               if self.ext_controller[self.trigger_level_key] > 
self.get_y_max():
-                       self.ext_controller[self.trigger_level_key] = 
self.get_y_max()
+               if self[SCOPE_TRIGGER_LEVEL_KEY] > self.get_y_max():
+                       self[SCOPE_TRIGGER_LEVEL_KEY] = self.get_y_max()
                        return
-               if self.ext_controller[self.trigger_level_key] < 
self.get_y_min():
-                       self.ext_controller[self.trigger_level_key] = 
self.get_y_min()
+               if self[SCOPE_TRIGGER_LEVEL_KEY] < self.get_y_min():
+                       self[SCOPE_TRIGGER_LEVEL_KEY] = self.get_y_min()
                        return
                #disable the trigger channel
-               if self[SCOPE_XY_MODE_KEY] or 
self.ext_controller[self.trigger_mode_key] == gr.gr_TRIG_MODE_FREE:
+               if self[SCOPE_XY_MODE_KEY] or self[SCOPE_TRIGGER_MODE_KEY] == 
gr.gr_TRIG_MODE_FREE:
                        self.plotter.set_waveform(channel='Trig')
                else: #show trigger channel
-                       trigger_level = 
self.ext_controller[self.trigger_level_key]
+                       trigger_level = self[SCOPE_TRIGGER_LEVEL_KEY]
                        self.plotter.set_waveform(
                                channel='Trig',
                                samples=(
@@ -438,16 +423,16 @@
                                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.set_x_per_div(x_per_div)
+                               if x_per_div != self[X_PER_DIV_KEY]: 
self[X_PER_DIV_KEY] = x_per_div
                                #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.set_x_off(x_off)
+                               if x_off != self[X_OFF_KEY]: self[X_OFF_KEY] = 
x_off
                                #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.set_y_per_div(y_per_div)
+                               if y_per_div != self[Y_PER_DIV_KEY]: 
self[Y_PER_DIV_KEY] = y_per_div
                                #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.set_y_off(y_off)
+                               if y_off != self[Y_OFF_KEY]: self[Y_OFF_KEY] = 
y_off
                                self.autorange_ts = time.time()
                        #plot xy channel
                        self.plotter.set_waveform(
@@ -467,22 +452,22 @@
                                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.set_y_per_div(y_per_div)
+                               if y_per_div != self[Y_PER_DIV_KEY]: 
self[Y_PER_DIV_KEY] = y_per_div
                                #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.set_y_off(y_off)
+                               if y_off != self[Y_OFF_KEY]: self[Y_OFF_KEY] = 
y_off
                                self.autorange_ts = time.time()
                        #number of samples to scale to the screen
-                       actual_rate = 
self.ext_controller[self.sample_rate_key]/self.ext_controller[self.decimation_key]
+                       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))
                        #adjust the decim so that we use about half the samps
-                       self.ext_controller[self.decimation_key] = int(round(
-                                       
time_span*self.ext_controller[self.sample_rate_key]/(0.5*len(sampleses[0]))
+                       self[DECIMATION_KEY] = int(round(
+                                       
time_span*self[SAMPLE_RATE_KEY]/(0.5*len(sampleses[0]))
                                )
                        )
                        #num samps too small, auto increment the time
-                       if num_samps < 2: 
self.set_t_per_div(common.get_clean_incr(self[T_PER_DIV_KEY]))
+                       if num_samps < 2: self[T_PER_DIV_KEY] = 
common.get_clean_incr(self[T_PER_DIV_KEY])
                        #num samps in bounds, plot each waveform
                        elif num_samps <= len(sampleses[0]):
                                for i, samples in enumerate(sampleses):

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-20 20:27:49 UTC (rev 10471)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py 
    2009-02-21 04:55:11 UTC (rev 10472)
@@ -31,7 +31,7 @@
 ##################################################
 # Scope sink block (wrapper for old wxgui)
 ##################################################
-class _scope_sink_base(gr.hier_block2, common.prop_setter):
+class _scope_sink_base(gr.hier_block2):
        """
        A scope block with a gui window.
        """
@@ -87,9 +87,7 @@
                self.controller.subscribe(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
-               common.input_watcher(msgq, lambda x: setter(self.controller, 
MSG_KEY, x))
+               common.input_watcher(msgq, self.controller, MSG_KEY)
                #create window
                self.win = scope_window.scope_window(
                        parent=parent,
@@ -110,10 +108,7 @@
                        decimation_key=DECIMATION_KEY,
                        msg_key=MSG_KEY,
                )
-               #register callbacks from window for external use
-               for attr in filter(lambda a: a.startswith('set_'), 
dir(self.win)):
-                       setattr(self, attr, getattr(self.win, attr))
-               self._register_set_prop(self.controller, SAMPLE_RATE_KEY)
+               common.register_access_methods(self, self.controller)
                #backwards compadibility
                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)

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/waterfall_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/waterfall_window.py
 2009-02-20 20:27:49 UTC (rev 10471)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/waterfall_window.py
 2009-02-21 04:55:11 UTC (rev 10472)
@@ -71,16 +71,16 @@
                control_box.Add(self.color_mode_chooser, 0, wx.EXPAND)
                #average
                control_box.AddStretchSpacer()
-               self.average_check_box = common.CheckBoxController(self, 
'Average', parent.ext_controller, parent.average_key)
+               self.average_check_box = common.CheckBoxController(self, 
'Average', parent, AVERAGE_KEY)
                control_box.Add(self.average_check_box, 0, wx.EXPAND)
                control_box.AddSpacer(2)
                self.avg_alpha_slider = common.LogSliderController(
                        self, 'Avg Alpha',
                        AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP, SLIDER_STEPS,
-                       parent.ext_controller, parent.avg_alpha_key,
+                       parent, AVG_ALPHA_KEY,
                        formatter=lambda x: ': %.4f'%x,
                )
-               parent.ext_controller.subscribe(parent.average_key, 
self.avg_alpha_slider.Enable)
+               parent.subscribe(AVERAGE_KEY, self.avg_alpha_slider.Enable)
                control_box.Add(self.avg_alpha_slider, 0, wx.EXPAND)
                #dyanmic range buttons
                control_box.AddStretchSpacer()
@@ -119,34 +119,30 @@
        # Event handlers
        ##################################################
        def _on_clear_button(self, event):
-               self.parent.set_num_lines(self.parent[NUM_LINES_KEY])
+               self.parent[NUM_LINES_KEY] = self.parent[NUM_LINES_KEY]
        def _on_incr_dynamic_range(self, event):
-               self.parent.set_dynamic_range(
-                       min(self.parent[DYNAMIC_RANGE_KEY] + 10, 
MAX_DYNAMIC_RANGE))
+               self.parent[DYNAMIC_RANGE_KEY] = 
min(self.parent[DYNAMIC_RANGE_KEY] + 10, MAX_DYNAMIC_RANGE)
        def _on_decr_dynamic_range(self, event):
-               self.parent.set_dynamic_range(
-                       max(self.parent[DYNAMIC_RANGE_KEY] - 10, 
MIN_DYNAMIC_RANGE))
+               self.parent[DYNAMIC_RANGE_KEY] = 
max(self.parent[DYNAMIC_RANGE_KEY] - 10, MIN_DYNAMIC_RANGE)
        def _on_incr_ref_level(self, event):
-               self.parent.set_ref_level(
-                       self.parent[REF_LEVEL_KEY] + 
self.parent[DYNAMIC_RANGE_KEY]*.1)
+               self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] + 
self.parent[DYNAMIC_RANGE_KEY]*.1
        def _on_decr_ref_level(self, event):
-               self.parent.set_ref_level(
-                       self.parent[REF_LEVEL_KEY] - 
self.parent[DYNAMIC_RANGE_KEY]*.1)
+               self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] - 
self.parent[DYNAMIC_RANGE_KEY]*.1
        def _on_incr_time_scale(self, event):
-               old_rate = 
self.parent.ext_controller[self.parent.frame_rate_key]
-               self.parent.ext_controller[self.parent.frame_rate_key] *= 0.75
-               if self.parent.ext_controller[self.parent.frame_rate_key] == 
old_rate:
-                       self.parent.ext_controller[self.parent.decimation_key] 
+= 1
+               old_rate = self.parent[FRAME_RATE_KEY]
+               self.parent[FRAME_RATE_KEY] *= 0.75
+               if self.parent[FRAME_RATE_KEY] == old_rate:
+                       self.parent[DECIMATION_KEY] += 1
        def _on_decr_time_scale(self, event):
-               old_rate = 
self.parent.ext_controller[self.parent.frame_rate_key]
-               self.parent.ext_controller[self.parent.frame_rate_key] *= 1.25
-               if self.parent.ext_controller[self.parent.frame_rate_key] == 
old_rate:
-                       self.parent.ext_controller[self.parent.decimation_key] 
-= 1
+               old_rate = self.parent[FRAME_RATE_KEY]
+               self.parent[FRAME_RATE_KEY] *= 1.25
+               if self.parent[FRAME_RATE_KEY] == old_rate:
+                       self.parent[DECIMATION_KEY] -= 1
 
 ##################################################
 # Waterfall window with plotter and control panel
 ##################################################
-class waterfall_window(wx.Panel, pubsub.pubsub, common.prop_setter):
+class waterfall_window(wx.Panel, pubsub.pubsub):
        def __init__(
                self,
                parent,
@@ -169,14 +165,15 @@
                pubsub.pubsub.__init__(self)
                #setup
                self.samples = list()
-               self.ext_controller = controller
                self.real = real
                self.fft_size = fft_size
-               self.decimation_key = decimation_key
-               self.sample_rate_key = sample_rate_key
-               self.frame_rate_key = frame_rate_key
-               self.average_key = average_key
-               self.avg_alpha_key = avg_alpha_key
+               #proxy the keys
+               self.proxy(MSG_KEY, controller, msg_key)
+               self.proxy(DECIMATION_KEY, controller, decimation_key)
+               self.proxy(FRAME_RATE_KEY, controller, frame_rate_key)
+               self.proxy(AVERAGE_KEY, controller, average_key)
+               self.proxy(AVG_ALPHA_KEY, controller, avg_alpha_key)
+               self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
                #init panel and plot
                wx.Panel.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
                self.plotter = plotter.waterfall_plotter(self)
@@ -192,26 +189,23 @@
                #plotter listeners
                self.subscribe(COLOR_MODE_KEY, self.plotter.set_color_mode)
                self.subscribe(NUM_LINES_KEY, self.plotter.set_num_lines)
-               #initial setup
-               self.ext_controller[self.average_key] = 
self.ext_controller[self.average_key]
-               self.ext_controller[self.avg_alpha_key] = 
self.ext_controller[self.avg_alpha_key]
-               self._register_set_prop(self, DYNAMIC_RANGE_KEY, dynamic_range)
-               self._register_set_prop(self, NUM_LINES_KEY, num_lines)
-               self._register_set_prop(self, Y_DIVS_KEY, 8)
-               self._register_set_prop(self, X_DIVS_KEY, 8) #approximate
-               self._register_set_prop(self, REF_LEVEL_KEY, ref_level)
-               self._register_set_prop(self, BASEBAND_FREQ_KEY, baseband_freq)
-               self._register_set_prop(self, COLOR_MODE_KEY, COLOR_MODES[0][1])
-               self._register_set_prop(self, RUNNING_KEY, True)
+               #initialize values
+               self[AVERAGE_KEY] = self[AVERAGE_KEY]
+               self[AVG_ALPHA_KEY] = self[AVG_ALPHA_KEY]
+               self[DYNAMIC_RANGE_KEY] = dynamic_range
+               self[NUM_LINES_KEY] = num_lines
+               self[Y_DIVS_KEY] = 8
+               self[X_DIVS_KEY] = 8 #approximate
+               self[REF_LEVEL_KEY] = ref_level
+               self[BASEBAND_FREQ_KEY] = baseband_freq
+               self[COLOR_MODE_KEY] = COLOR_MODES[0][1]
+               self[RUNNING_KEY] = True
                #register events
-               self.ext_controller.subscribe(msg_key, self.handle_msg)
-               self.ext_controller.subscribe(self.decimation_key, 
self.update_grid)
-               self.ext_controller.subscribe(self.sample_rate_key, 
self.update_grid)
-               self.ext_controller.subscribe(self.frame_rate_key, 
self.update_grid)
-               self.subscribe(BASEBAND_FREQ_KEY, self.update_grid)
-               self.subscribe(NUM_LINES_KEY, self.update_grid)
-               self.subscribe(Y_DIVS_KEY, self.update_grid)
-               self.subscribe(X_DIVS_KEY, self.update_grid)
+               self.subscribe(MSG_KEY, self.handle_msg)
+               for key in (
+                       DECIMATION_KEY, SAMPLE_RATE_KEY, FRAME_RATE_KEY,
+                       BASEBAND_FREQ_KEY, X_DIVS_KEY, Y_DIVS_KEY, 
NUM_LINES_KEY,
+               ): self.subscribe(key, self.update_grid)
                #initial update
                self.update_grid()
 
@@ -230,8 +224,8 @@
                noise_floor -= abs(noise_floor)*.5
                peak_level += abs(peak_level)*.1
                #set the range and level
-               self.set_ref_level(peak_level)
-               self.set_dynamic_range(peak_level - noise_floor)
+               self[REF_LEVEL_KEY] = peak_level
+               self[DYNAMIC_RANGE_KEY] = peak_level - noise_floor
 
        def handle_msg(self, msg):
                """
@@ -266,8 +260,8 @@
                The y axis depends on y per div, y divs, and ref level.
                """
                #grid parameters
-               sample_rate = self.ext_controller[self.sample_rate_key]
-               frame_rate = self.ext_controller[self.frame_rate_key]
+               sample_rate = self[SAMPLE_RATE_KEY]
+               frame_rate = self[FRAME_RATE_KEY]
                baseband_freq = self[BASEBAND_FREQ_KEY]
                num_lines = self[NUM_LINES_KEY]
                y_divs = self[Y_DIVS_KEY]

Modified: 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/waterfallsink_gl.py
===================================================================
--- 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/waterfallsink_gl.py
 2009-02-20 20:27:49 UTC (rev 10471)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/waterfallsink_gl.py
 2009-02-21 04:55:11 UTC (rev 10472)
@@ -31,7 +31,7 @@
 ##################################################
 # Waterfall sink block (wrapper for old wxgui)
 ##################################################
-class _waterfall_sink_base(gr.hier_block2, common.prop_setter):
+class _waterfall_sink_base(gr.hier_block2):
        """
        An fft block with real/complex inputs and a gui window.
        """
@@ -89,9 +89,7 @@
                self.controller.subscribe(FRAME_RATE_KEY, fft.set_vec_rate)
                self.controller.publish(FRAME_RATE_KEY, fft.frame_rate)
                #start input watcher
-               def setter(p, k, x): # lambdas can't have assignments :(
-                       p[k] = x
-               common.input_watcher(msgq, lambda x: setter(self.controller, 
MSG_KEY, x))
+               common.input_watcher(msgq, self.controller, MSG_KEY)
                #create window
                self.win = waterfall_window.waterfall_window(
                        parent=parent,
@@ -111,12 +109,7 @@
                        avg_alpha_key=AVG_ALPHA_KEY,
                        msg_key=MSG_KEY,
                )
-               #register callbacks from window for external use
-               for attr in filter(lambda a: a.startswith('set_'), 
dir(self.win)):
-                       setattr(self, attr, getattr(self.win, attr))
-               self._register_set_prop(self.controller, SAMPLE_RATE_KEY)
-               self._register_set_prop(self.controller, AVERAGE_KEY)
-               self._register_set_prop(self.controller, AVG_ALPHA_KEY)
+               common.register_access_methods(self, self.controller)
 
 class waterfall_sink_f(_waterfall_sink_base):
        _fft_chain = blks2.logpwrfft_f





reply via email to

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