commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8884 - gnuradio/branches/features/experimental-gui


From: jblum
Subject: [Commit-gnuradio] r8884 - gnuradio/branches/features/experimental-gui
Date: Mon, 14 Jul 2008 19:02:25 -0600 (MDT)

Author: jblum
Date: 2008-07-14 19:02:24 -0600 (Mon, 14 Jul 2008)
New Revision: 8884

Added:
   gnuradio/branches/features/experimental-gui/grc_fftsink_test.py
Modified:
   gnuradio/branches/features/experimental-gui/common.py
   gnuradio/branches/features/experimental-gui/fft_controller.py
   gnuradio/branches/features/experimental-gui/fft_window.py
   gnuradio/branches/features/experimental-gui/fftsink.py
   gnuradio/branches/features/experimental-gui/todo.txt
Log:
fftsink wrapper for fftwindow + controller + logpwrfft

Modified: gnuradio/branches/features/experimental-gui/common.py
===================================================================
--- gnuradio/branches/features/experimental-gui/common.py       2008-07-14 
21:13:26 UTC (rev 8883)
+++ gnuradio/branches/features/experimental-gui/common.py       2008-07-15 
01:02:24 UTC (rev 8884)
@@ -102,7 +102,7 @@
                controller.add_listener(control_key, lambda x: 
self.SetValue(bool(x)))
 
 class LogSliderController(wx.BoxSizer):
-       def __init__(self, parent, label, min_exp, max_exp, slider_steps, 
controller, control_key, formatter=lambda x: ': %.3g'%x):
+       def __init__(self, parent, label, min_exp, max_exp, slider_steps, 
controller, control_key, formatter=lambda x: ': %.3f'%x):
                wx.BoxSizer.__init__(self, wx.VERTICAL)
                self._label = wx.StaticText(parent, -1, label + 
formatter(1/3.0))
                self.Add(self._label, 0, wx.EXPAND)

Modified: gnuradio/branches/features/experimental-gui/fft_controller.py
===================================================================
--- gnuradio/branches/features/experimental-gui/fft_controller.py       
2008-07-14 21:13:26 UTC (rev 8883)
+++ gnuradio/branches/features/experimental-gui/fft_controller.py       
2008-07-15 01:02:24 UTC (rev 8884)
@@ -115,7 +115,7 @@
        """
        while self._keep_running:
            msg = self._tb.queue().delete_head()
-           self['fft'] = msg.to_string()
+           self['fft'] = msg
            
     def on_exit(self):
        """

Modified: gnuradio/branches/features/experimental-gui/fft_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/fft_window.py   2008-07-14 
21:13:26 UTC (rev 8883)
+++ gnuradio/branches/features/experimental-gui/fft_window.py   2008-07-15 
01:02:24 UTC (rev 8884)
@@ -35,7 +35,7 @@
 SLIDER_STEPS = 100
 AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0
 DEFAULT_FRAME_RATE = 30
-DEFAULT_WIN_SIZE = (640, 240)
+DEFAULT_WIN_SIZE = (600, 300)
 DIV_LEVELS = (1, 2, 5, 10, 20)
 FFT_PLOT_COLOR_SPEC = (0, 0, 1)
 PEAK_VALS_COLOR_SPEC = (0, 1, 0)
@@ -98,11 +98,10 @@
 
                #ref lvl buttons
                control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Adj Ref Lvl'), 0, 
wx.ALIGN_CENTER)
+               control_box.Add(common.LabelText(self, 'Set Ref Level'), 0, 
wx.ALIGN_CENTER)
                control_box.AddSpacer(2)
                self._ref_lvl_buttons = common.IncrDecrButtons(self, 
self._on_incr_ref_level, self._on_decr_ref_level)
                control_box.Add(self._ref_lvl_buttons, 0, wx.ALIGN_CENTER)
-               control_box.AddStretchSpacer()
 
                #run/stop
                control_box.AddStretchSpacer()
@@ -175,7 +174,6 @@
                self.SetSizerAndFit(main_box)
                #bind internal & external keys
                def bind_controller_keys(controller_master, controller_slave, 
master_key, slave_key):
-                       controller_slave[slave_key] = 
controller_master[master_key]
                        controller_slave.add_listener(slave_key, lambda x: 
controller_master.set(master_key, x))
                        controller_master.add_listener(master_key, lambda x: 
controller_slave.set(slave_key, x))
                for in_key, ext_key in (
@@ -183,6 +181,8 @@
                        (AVG_ALPHA_KEY, avg_alpha_key),
                ): bind_controller_keys(self.ext_controller, self.controller, 
ext_key, in_key)
                #initial setup
+               self.set_average(self.ext_controller[average_key])
+               self.set_avg_alpha(self.ext_controller[avg_alpha_key])
                self.set_baseband_freq(baseband_freq)
                self.set_peak_hold(peak_hold)
                self.set_y_per_div(y_per_div)
@@ -204,6 +204,8 @@
        ##################################################
        # Set parameters on-the-fly
        ##################################################
+       def set_average(self, average): self.controller[AVERAGE_KEY] = average
+       def set_avg_alpha(self, avg_alpha): self.controller[AVG_ALPHA_KEY] = 
avg_alpha
        def set_peak_hold(self, peak_hold): self.controller[PEAK_HOLD_KEY] = 
peak_hold
        def set_y_per_div(self, y_per_div): self.controller[Y_PER_DIV_KEY] = 
y_per_div
        def set_y_divs(self, y_divs): self.controller[Y_DIVS_KEY] = y_divs
@@ -222,8 +224,16 @@
                @param msg the fft array as a character array
                """
                if not self.controller[RUNNING_KEY]: return
+               itemsize = int(msg.arg1())
+               nitems = int(msg.arg2())
+               s = msg.to_string()
+               # There may be more than one frame in the message.
+               # If so, we take only the last one
+               if nitems > 1:
+                       start = itemsize * (nitems - 1)
+                       s = s[start:start+itemsize]
                #convert to floating point numbers
-               samples = numpy.fromstring(msg, numpy.float32)
+               samples = numpy.fromstring(s, numpy.float32)
                num_samps = len(samples)
                #reorder fft
                if self.real: samples = samples[:num_samps/2]

Modified: gnuradio/branches/features/experimental-gui/fftsink.py
===================================================================
--- gnuradio/branches/features/experimental-gui/fftsink.py      2008-07-14 
21:13:26 UTC (rev 8883)
+++ gnuradio/branches/features/experimental-gui/fftsink.py      2008-07-15 
01:02:24 UTC (rev 8884)
@@ -22,282 +22,22 @@
 ##################################################
 # Imports
 ##################################################
-from gnuradio import gr, blks2
-import plotter
+import fft_window
 import common
-import wx
-import numpy
-import math
+from gnuradio import gr, blks2
+from prop_val import prop_val_interface
 
 ##################################################
 # Constants
 ##################################################
-SLIDER_STEPS = 100
-AVG_ALPHA_SLIDER_MIN, AVG_ALPHA_SLIDER_MAX = -4, 0
-DEFAULT_FRAME_RATE = 30
-DEFAULT_WIN_SIZE = (640, 240)
-DIV_LEVELS = (1, 2, 5, 10, 20)
-FFT_PLOT_COLOR_SPEC = (0, 0, 1)
-PEAK_VALS_COLOR_SPEC = (0, 1, 0)
+SAMPLE_RATE_KEY = 'sample_rate'
+AVERAGE_KEY = 'average'
+AVG_ALPHA_KEY = 'avg_alpha'
+MSG_KEY = 'msg'
 
 ##################################################
-# FFT window control panel
+# FFT Sink Class (wrapper for old wxgui)
 ##################################################
-class control_panel(wx.Panel):
-       """!
-       A control panel with wx widgits to control the plotter and fft block 
chain.
-       """
-
-       def __init__(self, parent):
-               """!
-               Create a new control panel.
-               @param parent the wx parent window
-               """
-               self.parent = parent
-               wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER)
-               control_box = wx.BoxSizer(wx.VERTICAL)
-
-               #checkboxes for average and peak hold
-               control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Options'), 0, 
wx.ALIGN_CENTER)
-               self.average_check_box = wx.CheckBox(parent=self, 
style=wx.CHK_2STATE, label="Average")
-               self.average_check_box.Bind(wx.EVT_CHECKBOX, self._on_average)
-               control_box.Add(self.average_check_box, 0, wx.EXPAND)
-               self.peak_hold_check_box = wx.CheckBox(parent=self, 
style=wx.CHK_2STATE, label="Peak Hold")
-               self.peak_hold_check_box.Bind(wx.EVT_CHECKBOX, 
self._on_peak_hold)
-               control_box.Add(self.peak_hold_check_box, 0, wx.EXPAND)
-               control_box.AddSpacer(2)
-               self.avg_alpha_label = wx.StaticText(self, -1, '0'*15)
-               control_box.Add(self.avg_alpha_label, 0, wx.EXPAND)
-               self.avg_alpha_slider = wx.Slider(self, -1, 0, 0, SLIDER_STEPS, 
style=wx.SL_HORIZONTAL)
-               self.avg_alpha_slider.Bind(wx.EVT_SLIDER, self._on_avg_alpha)
-               control_box.Add(self.avg_alpha_slider, 0, wx.EXPAND)
-
-               #radio buttons for div size
-               control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Set dB/div'), 0, 
wx.ALIGN_CENTER)
-               radio_box = wx.BoxSizer(wx.VERTICAL)
-               self.radio_buttons = list()
-               for y_per_div in DIV_LEVELS:
-                       radio_button = wx.RadioButton(self, -1, "%d 
dB/div"%y_per_div)
-                       radio_button.Bind(wx.EVT_RADIOBUTTON, 
self._on_radio_button_change)
-                       self.radio_buttons.append(radio_button)
-                       radio_box.Add(radio_button, 0, wx.ALIGN_LEFT)
-               control_box.Add(radio_box, 0, wx.EXPAND)
-
-               #ref lvl buttons
-               control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Adj Ref Lvl'), 0, 
wx.ALIGN_CENTER)
-               control_box.AddSpacer(2)
-               self._ref_lvl_buttons = common.IncrDecrButtons(self, 
self._on_incr_ref_level, self._on_decr_ref_level)
-               control_box.Add(self._ref_lvl_buttons, 0, wx.ALIGN_CENTER)
-               control_box.AddStretchSpacer()
-
-               #run/stop
-               control_box.AddStretchSpacer()
-               self.run_button = wx.Button(self, -1, '', style=wx.BU_EXACTFIT)
-               self.run_button.Bind(wx.EVT_BUTTON, self._on_run)
-               control_box.Add(self.run_button, 0, wx.EXPAND)
-
-               #set sizer
-               self.SetSizerAndFit(control_box)
-               #update
-               self.update()
-
-       def update(self):
-               """!
-               Read the state of the fft plot settings and update the control 
panel.
-               """
-               #update the run/stop button
-               if self.parent.running: self.run_button.SetLabel('Stop')
-               else: self.run_button.SetLabel('Run')
-               #update checkboxes
-               self.average_check_box.SetValue(self.parent.average)
-               self.peak_hold_check_box.SetValue(self.parent.peak_hold)
-               #update avg alpha
-               self.avg_alpha_label.SetLabel('Avg Alpha: 
%.3g'%self.parent.avg_alpha)
-               slider_value = 
SLIDER_STEPS*(math.log10(self.parent.avg_alpha)-AVG_ALPHA_SLIDER_MIN)/(AVG_ALPHA_SLIDER_MAX-AVG_ALPHA_SLIDER_MIN)
-               if abs(slider_value - self.avg_alpha_slider.GetValue())  > 1:
-                       self.avg_alpha_slider.SetValue(slider_value)
-               if self.parent.average:
-                       self.avg_alpha_label.Enable()
-                       self.avg_alpha_slider.Enable()
-               else:
-                       self.avg_alpha_label.Disable()
-                       self.avg_alpha_slider.Disable()
-               #update radio buttons
-               try:
-                       index = list(DIV_LEVELS).index(self.parent.y_per_div)
-                       self.radio_buttons[index].SetValue(True)
-               except: pass
-
-       ##################################################
-       # Event handlers
-       ##################################################
-       def _on_radio_button_change(self, event):
-               selected_radio_button = filter(lambda rb: rb.GetValue(), 
self.radio_buttons)[0]
-               index = self.radio_buttons.index(selected_radio_button)
-               self.parent.set_y_per_div(DIV_LEVELS[index])
-       def _on_average(self, event): self.parent.set_average(event.IsChecked())
-       def _on_peak_hold(self, event): 
self.parent.set_peak_hold(event.IsChecked())
-       def _on_incr_ref_level(self, event): self.parent.incr_ref_level()
-       def _on_decr_ref_level(self, event): self.parent.decr_ref_level()
-       def _on_avg_alpha(self, event): 
-               
self.parent.set_avg_alpha(10**(float(AVG_ALPHA_SLIDER_MAX-AVG_ALPHA_SLIDER_MIN)*self.avg_alpha_slider.GetValue()/SLIDER_STEPS
 + AVG_ALPHA_SLIDER_MIN))
-       def _on_run(self, event): self.parent.set_run(not self.parent.running)
-
-##################################################
-# FFT window with plotter and control panel
-##################################################
-class fft_window(wx.Panel):
-       def __init__(
-               self,
-               parent,
-               size,
-               title,
-               real,
-               baseband_freq,
-               sample_rate,
-               y_per_div,
-               y_divs,
-               ref_level,
-               average,
-               avg_alpha,
-               peak_hold,
-               ext_set_average,
-               ext_set_avg_alpha,
-               ext_set_sample_rate,
-       ):
-               #ensure y_per_div
-               if y_per_div not in DIV_LEVELS: y_per_div = DIV_LEVELS[0]
-               #setup
-               self.running = True
-               self.real = real
-               self.baseband_freq = baseband_freq
-               self.sample_rate = sample_rate
-               self.x_divs = 8.0 #approximate
-               self.y_per_div = y_per_div
-               self.y_divs = y_divs
-               self.ref_level = ref_level
-               self.average = average
-               self.avg_alpha = avg_alpha
-               self.peak_hold = peak_hold
-               self.ext_set_average = ext_set_average
-               self.ext_set_avg_alpha = ext_set_avg_alpha
-               self.ext_set_sample_rate = ext_set_sample_rate
-               self.peak_vals = []
-               #init panel and plot
-               wx.Panel.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
-               self.plotter = plotter.grid_plotter(self)
-               self.plotter.SetSize(wx.Size(*size))
-               self.plotter.set_title(title)
-               self.plotter.set_y_units('Amplitude (dB)')
-               #setup the box with plot and controls
-               self.control_panel = control_panel(self)
-               main_box = wx.BoxSizer(wx.HORIZONTAL)
-               main_box.Add(self.plotter, 1, wx.EXPAND)
-               main_box.Add(self.control_panel, 0, wx.EXPAND)
-               self.SetSizerAndFit(main_box)
-               #update
-               self.update()
-
-       def plot(self, samples):
-               """!
-               Plot the samples onto the grid as channel 1.
-               If peak hold is enabled, plot peak vals as channel 2.
-               @param samples the fft array
-               """
-               if not self.running: return
-               #peak hold calculation
-               if self.peak_hold:
-                       if len(self.peak_vals) != len(samples): self.peak_vals 
= samples
-                       self.peak_vals = numpy.maximum(samples, self.peak_vals)
-               #plot the fft
-               self.plotter.set_waveform(
-                       channel=1,
-                       samples=samples,
-                       color_spec=FFT_PLOT_COLOR_SPEC,
-               )
-               #plot the peak hold
-               self.plotter.set_waveform(
-                       channel=2,
-                       samples=self.peak_vals,
-                       color_spec=PEAK_VALS_COLOR_SPEC,
-               )
-               #update the plotter
-               self.plotter.update()
-
-       def update(self):
-               #update fft block
-               self.ext_set_average(self.average)
-               self.ext_set_avg_alpha(self.avg_alpha)
-               self.ext_set_sample_rate(self.sample_rate)
-               #update peak hold
-               if not self.peak_hold: self.peak_vals = []
-               #determine best fitting x_per_div
-               if self.real: x_width = self.sample_rate/2.0
-               else: x_width = self.sample_rate
-               x_per_div = common.get_clean_num(x_width/self.x_divs)
-               exp = common.get_exp(x_per_div)
-               #calculate units and scalar
-               if exp > 7: x_units, scalar = 'GHz', 1e-9
-               elif exp > 4: x_units, scalar = 'MHz', 1e-6
-               elif exp > 1: x_units, scalar = 'KHz', 1e-3
-               else: x_units, scalar = 'Hz', 1e-0
-               #update the x grid
-               if self.real:
-                       self.plotter.set_x_grid(
-                               scalar*self.baseband_freq,
-                               scalar*self.baseband_freq + 
scalar*self.sample_rate/2.0,
-                               scalar*x_per_div,
-                       )
-               else:
-                       self.plotter.set_x_grid(
-                               scalar*self.baseband_freq - 
scalar*self.sample_rate/2.0,
-                               scalar*self.baseband_freq + 
scalar*self.sample_rate/2.0,
-                               scalar*x_per_div,
-                       )
-               #update x units
-               self.plotter.set_x_units('Frequency (%s)'%x_units)
-               #update y grid
-               
self.plotter.set_y_grid(self.ref_level-self.y_per_div*self.y_divs, 
self.ref_level, self.y_per_div)
-               #update control panel and plotter
-               self.control_panel.update()
-               self.plotter.update()
-
-       ##################################################
-       # Set parameters on-the-fly
-       ##################################################
-       def set_sample_rate(self, sample_rate):
-               self.sample_rate = sample_rate
-               self.update()
-       def set_baseband_freq(self, baseband_freq):
-               self.baseband_freq = baseband_freq
-               self.update()
-       def set_average(self, average):
-               self.average = average
-               self.update()
-       def set_avg_alpha(self, avg_alpha):
-               self.avg_alpha = avg_alpha
-               self.update()
-       def set_peak_hold(self, peak_hold):
-               self.peak_hold = peak_hold
-               self.update()
-       def set_y_per_div(self, y_per_div):
-               self.y_per_div = y_per_div
-               self.update()
-       def set_ref_level(self, ref_level):
-               self.ref_level = ref_level
-               self.update()
-       def incr_ref_level(self): self.set_ref_level(self.ref_level + 
self.y_per_div)
-       def decr_ref_level(self): self.set_ref_level(self.ref_level - 
self.y_per_div)
-       def set_run(self, running):
-               self.running = running
-               self.update()
-
-##################################################
-# FFT sink base block for real and complex types
-##################################################
 class _fft_sink_base(gr.hier_block2):
        """!
        An fft block with real/complex inputs and a gui window.
@@ -313,11 +53,11 @@
                ref_level=50,
                sample_rate=1,
                fft_size=512,
-               frame_rate=DEFAULT_FRAME_RATE,
+               frame_rate=fft_window.DEFAULT_FRAME_RATE,
                average=False,
                avg_alpha=None,
                title='',
-               size=DEFAULT_WIN_SIZE,
+               size=fft_window.DEFAULT_WIN_SIZE,
                peak_hold=False,
        ):
                #ensure avg alpha
@@ -343,59 +83,48 @@
                sink = gr.message_sink(gr.sizeof_float*fft_size, msgq, True)
                #connect
                self.connect(self, copy, fft, sink)
+               #controller
+               self.controller = prop_val_interface()
+               self.controller.add_listener(AVERAGE_KEY, fft.set_average)
+               self.controller.set_provider(AVERAGE_KEY, lambda: fft.average())
+               self.controller.add_listener(AVG_ALPHA_KEY, fft.set_avg_alpha)
+               self.controller.set_provider(AVG_ALPHA_KEY, lambda: 
fft.avg_alpha())
+               self.controller.add_listener(SAMPLE_RATE_KEY, 
fft.set_sample_rate)
+               self.controller.set_provider(SAMPLE_RATE_KEY, lambda: 
fft._sd.sample_rate()) #FIXME
+               #start input watcher
+               common.input_watcher(msgq, lambda x: 
self.controller.set(MSG_KEY, x))
                #create window
-               self.win = fft_window(
+               self.win = fft_window.fft_window(
                        parent=parent,
+                       controller=self.controller,
                        size=size,
                        title=title,
                        real = self.real,
                        baseband_freq=baseband_freq,
-                       sample_rate=sample_rate,
+                       sample_rate_key=SAMPLE_RATE_KEY,
                        y_per_div=y_per_div,
                        y_divs=y_divs,
                        ref_level=ref_level,
-                       average=average,
-                       avg_alpha=avg_alpha,
+                       average_key=AVERAGE_KEY,
+                       avg_alpha_key=AVG_ALPHA_KEY,
                        peak_hold=peak_hold,
-                       ext_set_average=fft.set_average,
-                       ext_set_avg_alpha=fft.set_avg_alpha,
-                       ext_set_sample_rate=fft.set_sample_rate,
+                       msg_key=MSG_KEY,
                )
                #register callbacks from window for external use
-               self.set_baseband_freq = self.win.set_baseband_freq
                self.set_average = self.win.set_average
+               self.set_avg_alpha = self.win.set_avg_alpha
                self.set_peak_hold = self.win.set_peak_hold
+               self.set_sample_rate = self.set_sample_rate
+               self.set_baseband_freq = self.win.set_baseband_freq
                self.set_y_per_div = self.win.set_y_per_div
                self.set_ref_level = self.win.set_ref_level
-               self.set_avg_alpha = self.win.set_avg_alpha
-               self.set_sample_rate = self.win.set_sample_rate
-               #setup the input watcher
-               common.input_watcher(msgq, self._handle_msg)
+               self.set_y_divs = self.win.set_y_divs
+               self.set_x_divs = self.win.set_x_divs
+               self.set_running = self.win.set_running
+               
+       def set_sample_rate(self, sample_rate):
+               self.controller[SAMPLE_RATE_KEY] = sample_rate
 
-       def _handle_msg(self, msg):
-               """!
-               Handle the message from the fft sink message queue.
-               If complex, reorder the fft samples so the negative bins come 
first.
-               If real, keep take only the positive bins.
-               @param msg the fft array as a character array
-               """
-               itemsize = int(msg.arg1())
-               nitems = int(msg.arg2())
-               s = msg.to_string()
-               # There may be more than one frame in the message.
-               # If so, we take only the last one
-               if nitems > 1:
-                       start = itemsize * (nitems - 1)
-                       s = s[start:start+itemsize]
-               #convert to floating point numbers
-               samples = numpy.fromstring(s, numpy.float32)
-               num_samps = len(samples)
-               #reorder fft
-               if self.real: samples = samples[:num_samps/2]
-               else: samples = numpy.concatenate((samples[num_samps/2+1:], 
samples[:num_samps/2]))
-               #plot
-               self.win.plot(samples)
-
 class fft_sink_f(_fft_sink_base):
        fft_chain = blks2.logpwrfft_f
        item_size = gr.sizeof_float

Added: gnuradio/branches/features/experimental-gui/grc_fftsink_test.py
===================================================================
--- gnuradio/branches/features/experimental-gui/grc_fftsink_test.py             
                (rev 0)
+++ gnuradio/branches/features/experimental-gui/grc_fftsink_test.py     
2008-07-15 01:02:24 UTC (rev 8884)
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+##################################################
+# Gnuradio Python Flow Graph
+# Title: untitled
+# Author: unknown
+# Description: gnuradio flow graph
+# Generated: Mon Jul 14 16:50:47 2008
+##################################################
+
+from gnuradio import gr
+import fftsink
+from grc_gnuradio import wxgui as grc_wxgui
+import wx
+
+ampl = 1
+freq1 = [1000, 2000, 3000][1]
+freq2 = 1000
+samp_rate = 32000
+
+class double_var_test(grc_wxgui.top_block_gui):
+
+       def __init__(self, ampl=ampl, freq1=freq1, freq2=freq2, 
samp_rate=samp_rate):
+               grc_wxgui.top_block_gui.__init__(
+                       self,
+                       title="GRC - Executing: untitled",
+                       
icon="/usr/lib/python2.5/site-packages/grc/data/grc-icon-32.png",
+               )
+
+               ##################################################
+               # Variables
+               ##################################################
+               self.ampl = ampl
+               _ampl_control = grc_wxgui.slider_vertical_control(
+                       window=self.GetWin(), 
+                       callback=self.set_ampl,
+                       label="Amplitude",
+                       value=ampl,
+                       min=0,
+                       max=10,
+                       num_steps=100,
+               )
+               self.GridAdd(_ampl_control, 0, 0, 2, 1)
+               self.freq1 = freq1
+               _freq1_control = grc_wxgui.radio_buttons_horizontal_control(
+                       window=self.GetWin(), 
+                       callback=self.set_freq1,
+                       label="freq1", 
+                       index=1,
+                       choices=[1000, 2000, 3000],
+                       labels=[],
+               )
+               self.GridAdd(_freq1_control, 2, 3, 1, 2)
+               self.freq2 = freq2
+               _freq2_control = grc_wxgui.slider_horizontal_control(
+                       window=self.GetWin(), 
+                       callback=self.set_freq2,
+                       label="freq2", 
+                       value=freq2,
+                       min=0,
+                       max=5000,
+                       num_steps=100,
+               )
+               self.GridAdd(_freq2_control, 2, 1, 1, 2)
+               self.samp_rate = samp_rate
+
+               ##################################################
+               # Blocks
+               ##################################################
+               self.gr_sig_source_x = gr.sig_source_c(samp_rate, 
gr.GR_COS_WAVE, freq1+freq2, ampl, 0)
+               self.gr_throttle = gr.throttle(gr.sizeof_gr_complex*1, 
samp_rate)
+               self.wxgui_fftsink2 = fftsink.fft_sink_c(
+                       self.GetWin(),
+                       baseband_freq=0,
+                       y_per_div=20,
+                       y_divs=10,
+                       ref_level=50,
+                       sample_rate=samp_rate,
+                       fft_size=512,
+                       frame_rate=60,
+                       average=False,
+                       avg_alpha=None,
+                       title="FFT Plot", 
+                       peak_hold=True,
+               )
+               self.GridAdd(self.wxgui_fftsink2.win, 0, 1, 2, 4)
+
+               ##################################################
+               # Connections
+               ##################################################
+               self.connect((self.gr_sig_source_x, 0), (self.gr_throttle, 0))
+               self.connect((self.gr_throttle, 0), (self.wxgui_fftsink2, 0))
+
+       def set_ampl(self, ampl):
+               self.ampl = ampl
+               self.gr_sig_source_x.set_amplitude(self.ampl)
+
+       def set_freq1(self, freq1):
+               self.freq1 = freq1
+               self.gr_sig_source_x.set_frequency(self.freq1+self.freq2)
+
+       def set_freq2(self, freq2):
+               self.freq2 = freq2
+               self.gr_sig_source_x.set_frequency(self.freq1+self.freq2)
+
+       def set_samp_rate(self, samp_rate):
+               self.samp_rate = samp_rate
+               self.gr_sig_source_x.set_sampling_freq(self.samp_rate)
+
+if __name__ == '__main__':
+       tb = double_var_test()
+       tb.Run()
+


Property changes on: 
gnuradio/branches/features/experimental-gui/grc_fftsink_test.py
___________________________________________________________________
Name: svn:executable
   + *

Modified: gnuradio/branches/features/experimental-gui/todo.txt
===================================================================
--- gnuradio/branches/features/experimental-gui/todo.txt        2008-07-14 
21:13:26 UTC (rev 8883)
+++ gnuradio/branches/features/experimental-gui/todo.txt        2008-07-15 
01:02:24 UTC (rev 8884)
@@ -4,3 +4,5 @@
 -controller property with default value for cache
 -use iteritems in cli.py
 -add/remove listener in cli.py
+-logpwrfft needs sample rate
+-logpwrfft has problem when average=True





reply via email to

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