commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: jblum
Subject: [Commit-gnuradio] r10496 - gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python
Date: Mon, 23 Feb 2009 23:55:57 -0700 (MST)

Author: jblum
Date: 2009-02-23 23:55:57 -0700 (Mon, 23 Feb 2009)
New Revision: 10496

Modified:
   gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/common.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:
AC coupling performed by hier block with IIR filter.



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-23 23:25:33 UTC (rev 10495)
+++ gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/common.py   
2009-02-24 06:55:57 UTC (rev 10496)
@@ -24,6 +24,9 @@
 import math
 import wx
 
+#A macro to apply an index to a key
+index_key = lambda key, i: "%s_%d"%(key, i+1)
+
 def register_access_methods(destination, controller):
        """
        Register setter and getter functions in the destination object for all 
keys in the controller.

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 23:25:33 UTC (rev 10495)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scope_window.py 
    2009-02-24 06:55:57 UTC (rev 10496)
@@ -66,7 +66,6 @@
        ('None', 0.0),
 )
 DEFAULT_MARKER_TYPE = None
-def index_key(key, i): return "%s_%d"%(key, i+1)
 
 ##################################################
 # Scope window control panel
@@ -198,11 +197,11 @@
                        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)
+                       coupling_chooser = 
common.DropDownController(channel_menu_panel, 'Coupling', COUPLING_MODES, 
parent, common.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)
+                       marker_chooser = 
common.DropDownController(channel_menu_panel, 'Marker', MARKER_TYPES, parent, 
common.index_key(MARKER_KEY, i), SIZE)
                        channel_menu_box.Add(marker_chooser, 0, wx.EXPAND)
                        channel_menu_box.AddStretchSpacer()
                ##################################################
@@ -294,8 +293,8 @@
                sample_rate_key,
                t_scale,
                v_scale,
-               ac_couple,
                xy_mode,
+               ac_couple_key,
                trigger_level_key,
                trigger_mode_key,
                trigger_slope_key,
@@ -321,6 +320,8 @@
                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)
+               for i in range(num_inputs):
+                       self.proxy(common.index_key(AC_COUPLE_KEY, i), 
controller, common.index_key(ac_couple_key, i))
                #init panel and plot
                wx.Panel.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
                self.plotter = plotter.channel_plotter(self)
@@ -337,8 +338,8 @@
                #initialize values
                self[RUNNING_KEY] = True
                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[common.index_key(AC_COUPLE_KEY, i)] = 
self[common.index_key(AC_COUPLE_KEY, i)]
+                       self[common.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
@@ -366,7 +367,7 @@
                #register events for message
                self.subscribe(MSG_KEY, self.handle_msg)
                #register events for grid
-               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)] + [
+               for key in [common.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,
@@ -438,9 +439,6 @@
                """
                if not self.sampleses: return
                sampleses = self.sampleses
-               #ac coupling
-               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]]
@@ -466,7 +464,7 @@
                                channel='XY',
                                samples=(x_samples, y_samples),
                                color_spec=CHANNEL_COLOR_SPECS[0],
-                               marker=self[index_key(MARKER_KEY, 0)],
+                               marker=self[common.index_key(MARKER_KEY, 0)],
                        )
                        #turn off each waveform
                        for i, samples in enumerate(sampleses):
@@ -507,7 +505,7 @@
                                                channel='Ch%d'%(i+1),
                                                
samples=samples[samps_off:num_samps+samps_off],
                                                
color_spec=CHANNEL_COLOR_SPECS[i],
-                                               
marker=self[index_key(MARKER_KEY, i)],
+                                               
marker=self[common.index_key(MARKER_KEY, i)],
                                                trig_off=self.trigger_offset,
                                        )
                        #turn XY channel off

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 23:25:33 UTC (rev 10495)
+++ 
gnuradio/branches/developers/jblum/gui_guts/gr-wxgui/src/python/scopesink_gl.py 
    2009-02-24 06:55:57 UTC (rev 10496)
@@ -28,6 +28,34 @@
 from pubsub import pubsub
 from constants import *
 
+class ac_couple_block(gr.hier_block2):
+       """
+       AC couple the incoming stream by subtracting out the low pass signal.
+       Mute the low pass filter to disable ac coupling.
+       """
+
+       def __init__(self, controller, ac_couple_key, ac_couple, 
sample_rate_key):
+               gr.hier_block2.__init__(
+                       self,
+                       "ac_couple",
+                       gr.io_signature(1, 1, gr.sizeof_float),
+                       gr.io_signature(1, 1, gr.sizeof_float),
+               )
+               #blocks
+               copy = gr.kludge_copy(gr.sizeof_float)
+               lpf = gr.single_pole_iir_filter_ff(0.0)
+               sub = gr.sub_ff()
+               mute = gr.mute_ff()
+               #connect
+               self.connect(self, copy, sub, self)
+               self.connect(copy, lpf, mute, (sub, 1))
+               #subscribe
+               controller.subscribe(ac_couple_key, lambda x: mute.set_mute(not 
x))
+               controller.subscribe(sample_rate_key, lambda x: 
lpf.set_taps(2.0/x))
+               #initialize
+               controller[ac_couple_key] = ac_couple
+               controller[sample_rate_key] = controller[sample_rate_key]
+
 ##################################################
 # Scope sink block (wrapper for old wxgui)
 ##################################################
@@ -46,11 +74,11 @@
                v_scale=scope_window.DEFAULT_V_SCALE,
                t_scale=None,
                num_inputs=1,
+               xy_mode=None,
                ac_couple=False,
-               xy_mode=None,
                frame_rate=scope_window.DEFAULT_FRAME_RATE,
        ):
-               if t_scale is None: t_scale = 0.001
+               if t_scale is None: t_scale = 10.0/sample_rate
                #init
                gr.hier_block2.__init__(
                        self,
@@ -61,17 +89,6 @@
                #scope
                msgq = gr.msg_queue(2)
                scope = gr.oscope_sink_f(sample_rate, msgq)
-               #connect
-               if self._real:
-                       for i in range(num_inputs):
-                               self.connect((self, i), (scope, i))
-               else:
-                       for i in range(num_inputs):
-                               c2f = gr.complex_to_float() 
-                               self.connect((self, i), c2f)
-                               self.connect((c2f, 0), (scope, 2*i+0))
-                               self.connect((c2f, 1), (scope, 2*i+1))
-                       num_inputs *= 2
                #controller
                self.controller = pubsub()
                self.controller.subscribe(SAMPLE_RATE_KEY, 
scope.set_sample_rate)
@@ -86,6 +103,25 @@
                self.controller.publish(SCOPE_TRIGGER_SLOPE_KEY, 
scope.get_trigger_slope)
                self.controller.subscribe(SCOPE_TRIGGER_CHANNEL_KEY, 
scope.set_trigger_channel)
                self.controller.publish(SCOPE_TRIGGER_CHANNEL_KEY, 
scope.get_trigger_channel)
+               #connect
+               if self._real:
+                       for i in range(num_inputs):
+                               self.connect(
+                                       (self, i),
+                                       ac_couple_block(self.controller, 
common.index_key(AC_COUPLE_KEY, i), ac_couple, SAMPLE_RATE_KEY),
+                                       (scope, i),
+                               )
+               else:
+                       for i in range(num_inputs):
+                               c2f = gr.complex_to_float() 
+                               self.connect((self, i), c2f)
+                               for j in range(2):
+                                       self.connect(
+                                               (c2f, j), 
+                                               
ac_couple_block(self.controller, common.index_key(AC_COUPLE_KEY, 2*i+j), 
ac_couple, SAMPLE_RATE_KEY),
+                                               (scope, 2*i+j),
+                                       )
+                       num_inputs *= 2
                #start input watcher
                common.input_watcher(msgq, self.controller, MSG_KEY)
                #create window
@@ -99,8 +135,8 @@
                        sample_rate_key=SAMPLE_RATE_KEY,
                        t_scale=t_scale,
                        v_scale=v_scale,
-                       ac_couple=ac_couple,
                        xy_mode=xy_mode,
+                       ac_couple_key=AC_COUPLE_KEY,
                        trigger_level_key=SCOPE_TRIGGER_LEVEL_KEY,
                        trigger_mode_key=SCOPE_TRIGGER_MODE_KEY,
                        trigger_slope_key=SCOPE_TRIGGER_SLOPE_KEY,





reply via email to

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