diff options
Diffstat (limited to 'gr-wxgui')
-rw-r--r-- | gr-wxgui/CMakeLists.txt | 5 | ||||
-rw-r--r-- | gr-wxgui/grc/panel.py | 16 | ||||
-rw-r--r-- | gr-wxgui/grc/top_block_gui.py | 26 | ||||
-rw-r--r-- | gr-wxgui/grc/wxgui_fftsink2.xml | 2 | ||||
-rw-r--r-- | gr-wxgui/grc/wxgui_waterfallsink2.xml | 2 | ||||
-rw-r--r-- | gr-wxgui/python/CMakeLists.txt (renamed from gr-wxgui/src/python/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/__init__.py (renamed from gr-wxgui/src/python/__init__.py) | 3 | ||||
-rw-r--r-- | gr-wxgui/python/common.py (renamed from gr-wxgui/src/python/common.py) | 68 | ||||
-rw-r--r-- | gr-wxgui/python/const_window.py (renamed from gr-wxgui/src/python/const_window.py) | 8 | ||||
-rw-r--r-- | gr-wxgui/python/constants.py (renamed from gr-wxgui/src/python/constants.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/constsink_gl.py (renamed from gr-wxgui/src/python/constsink_gl.py) | 7 | ||||
-rw-r--r-- | gr-wxgui/python/fft_window.py (renamed from gr-wxgui/src/python/fft_window.py) | 8 | ||||
-rw-r--r-- | gr-wxgui/python/fftsink2.py (renamed from gr-wxgui/src/python/fftsink2.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/fftsink_gl.py (renamed from gr-wxgui/src/python/fftsink_gl.py) | 57 | ||||
-rw-r--r-- | gr-wxgui/python/fftsink_nongl.py (renamed from gr-wxgui/src/python/fftsink_nongl.py) | 86 | ||||
-rw-r--r-- | gr-wxgui/python/form.py (renamed from gr-wxgui/src/python/form.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/forms/__init__.py (renamed from gr-wxgui/src/python/forms/__init__.py) | 37 | ||||
-rw-r--r-- | gr-wxgui/python/forms/converters.py (renamed from gr-wxgui/src/python/forms/converters.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/forms/forms.py (renamed from gr-wxgui/src/python/forms/forms.py) | 296 | ||||
-rw-r--r-- | gr-wxgui/python/gui.py (renamed from gr-wxgui/src/python/gui.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/histo_window.py (renamed from gr-wxgui/src/python/histo_window.py) | 8 | ||||
-rw-r--r-- | gr-wxgui/python/histosink_gl.py (renamed from gr-wxgui/src/python/histosink_gl.py) | 22 | ||||
-rw-r--r-- | gr-wxgui/python/number_window.py (renamed from gr-wxgui/src/python/number_window.py) | 12 | ||||
-rw-r--r-- | gr-wxgui/python/numbersink2.py (renamed from gr-wxgui/src/python/numbersink2.py) | 60 | ||||
-rw-r--r-- | gr-wxgui/python/plot.py (renamed from gr-wxgui/src/python/plot.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/plotter/__init__.py (renamed from gr-wxgui/src/python/plotter/__init__.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/plotter/bar_plotter.py (renamed from gr-wxgui/src/python/plotter/bar_plotter.py) | 18 | ||||
-rw-r--r-- | gr-wxgui/python/plotter/channel_plotter.py (renamed from gr-wxgui/src/python/plotter/channel_plotter.py) | 34 | ||||
-rw-r--r-- | gr-wxgui/python/plotter/common.py (renamed from gr-wxgui/src/python/plotter/common.py) | 34 | ||||
-rw-r--r-- | gr-wxgui/python/plotter/gltext.py (renamed from gr-wxgui/src/python/plotter/gltext.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/plotter/grid_plotter_base.py (renamed from gr-wxgui/src/python/plotter/grid_plotter_base.py) | 106 | ||||
-rw-r--r-- | gr-wxgui/python/plotter/plotter_base.py (renamed from gr-wxgui/src/python/plotter/plotter_base.py) | 12 | ||||
-rw-r--r-- | gr-wxgui/python/plotter/waterfall_plotter.py (renamed from gr-wxgui/src/python/plotter/waterfall_plotter.py) | 38 | ||||
-rw-r--r-- | gr-wxgui/python/powermate.py (renamed from gr-wxgui/src/python/powermate.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/pubsub.py (renamed from gr-wxgui/src/python/pubsub.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/scope_window.py (renamed from gr-wxgui/src/python/scope_window.py) | 8 | ||||
-rw-r--r-- | gr-wxgui/python/scopesink2.py (renamed from gr-wxgui/src/python/scopesink2.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/scopesink_gl.py (renamed from gr-wxgui/src/python/scopesink_gl.py) | 37 | ||||
-rw-r--r-- | gr-wxgui/python/scopesink_nongl.py (renamed from gr-wxgui/src/python/scopesink_nongl.py) | 446 | ||||
-rw-r--r-- | gr-wxgui/python/slider.py (renamed from gr-wxgui/src/python/slider.py) | 9 | ||||
-rw-r--r-- | gr-wxgui/python/stdgui2.py (renamed from gr-wxgui/src/python/stdgui2.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/termsink.py (renamed from gr-wxgui/src/python/termsink.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/waterfall_window.py (renamed from gr-wxgui/src/python/waterfall_window.py) | 8 | ||||
-rw-r--r-- | gr-wxgui/python/waterfallsink2.py (renamed from gr-wxgui/src/python/waterfallsink2.py) | 0 | ||||
-rw-r--r-- | gr-wxgui/python/waterfallsink_gl.py (renamed from gr-wxgui/src/python/waterfallsink_gl.py) | 43 | ||||
-rw-r--r-- | gr-wxgui/python/waterfallsink_nongl.py (renamed from gr-wxgui/src/python/waterfallsink_nongl.py) | 65 |
46 files changed, 894 insertions, 687 deletions
diff --git a/gr-wxgui/CMakeLists.txt b/gr-wxgui/CMakeLists.txt index 8150c7d802..04c4a26569 100644 --- a/gr-wxgui/CMakeLists.txt +++ b/gr-wxgui/CMakeLists.txt @@ -38,6 +38,9 @@ endif(NOT CMAKE_CROSSCOMPILING) GR_REGISTER_COMPONENT("gr-wxgui" ENABLE_GR_WXGUI ENABLE_GR_CORE + ENABLE_GR_FFT + ENABLE_GR_FILTER + ENABLE_GR_ANALOG ENABLE_PYTHON ${wxgui_python_deps} ) @@ -84,6 +87,6 @@ install( # Add subdirectories ######################################################################## add_subdirectory(grc) -add_subdirectory(src/python) +add_subdirectory(python) endif(ENABLE_GR_WXGUI) diff --git a/gr-wxgui/grc/panel.py b/gr-wxgui/grc/panel.py index e62133cac2..9bcb464701 100644 --- a/gr-wxgui/grc/panel.py +++ b/gr-wxgui/grc/panel.py @@ -33,17 +33,21 @@ class Panel(wx.Panel): def Add(self, win): """ Add a window to the wx vbox. - @param win the wx window + + Args: + win: the wx window """ self._box.Add(win, 0, wx.EXPAND) def GridAdd(self, win, row, col, row_span=1, col_span=1): """ Add a window to the wx grid at the given position. - @param win the wx window - @param row the row specification (integer >= 0) - @param col the column specification (integer >= 0) - @param row_span the row span specification (integer >= 1) - @param col_span the column span specification (integer >= 1) + + Args: + win: the wx window + row: the row specification (integer >= 0) + col: the column specification (integer >= 0) + row_span: the row span specification (integer >= 1) + col_span: the column span specification (integer >= 1) """ self._grid.Add(win, wx.GBPosition(row, col), wx.GBSpan(row_span, col_span), wx.EXPAND) diff --git a/gr-wxgui/grc/top_block_gui.py b/gr-wxgui/grc/top_block_gui.py index 479f55a302..a0d9f94628 100644 --- a/gr-wxgui/grc/top_block_gui.py +++ b/gr-wxgui/grc/top_block_gui.py @@ -31,9 +31,11 @@ class top_block_gui(gr.top_block): """ Initialize the gr top block. Create the wx gui elements. - @param title the main window title - @param size the main window size tuple in pixels - @param icon the file path to an icon or None + + Args: + title: the main window title + size: the main window size tuple in pixels + icon: the file path to an icon or None """ #initialize gr.top_block.__init__(self) @@ -48,12 +50,7 @@ class top_block_gui(gr.top_block): def SetIcon(self, *args, **kwargs): self._frame.SetIcon(*args, **kwargs) - def Run(self, start=True, max_nouts=0): - """ - Setup the wx gui elements. - Start the gr top block. - Block with the wx main loop. - """ + def Start(self, start=True, max_nouts=0): #set minimal window size self._frame.SetSizeHints(*self._size) #create callback for quit @@ -74,5 +71,16 @@ class top_block_gui(gr.top_block): self.start(max_nouts) else: self.start() + + def Run(self, start=True, max_nouts=0): + """ + Setup the wx gui elements. + Start the gr top block. + Block with the wx main loop. + """ #blocking main loop + self.Start(start, max_nouts) + self._app.MainLoop() + + def Wait(self): self._app.MainLoop() diff --git a/gr-wxgui/grc/wxgui_fftsink2.xml b/gr-wxgui/grc/wxgui_fftsink2.xml index 74ee5b173e..ff5c47b85c 100644 --- a/gr-wxgui/grc/wxgui_fftsink2.xml +++ b/gr-wxgui/grc/wxgui_fftsink2.xml @@ -8,7 +8,7 @@ <name>WX GUI FFT Sink</name> <key>wxgui_fftsink2</key> <category>WX GUI Widgets</category> - <import>from gnuradio import window</import> + <import>from gnuradio.fft import window</import> <import>from gnuradio.wxgui import fftsink2</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' fftsink2.$(type.fcn)( diff --git a/gr-wxgui/grc/wxgui_waterfallsink2.xml b/gr-wxgui/grc/wxgui_waterfallsink2.xml index 8921e87f9a..c02901d336 100644 --- a/gr-wxgui/grc/wxgui_waterfallsink2.xml +++ b/gr-wxgui/grc/wxgui_waterfallsink2.xml @@ -8,7 +8,7 @@ <name>WX GUI Waterfall Sink</name> <key>wxgui_waterfallsink2</key> <category>WX GUI Widgets</category> - <import>from gnuradio import window</import> + <import>from gnuradio.fft import window</import> <import>from gnuradio.wxgui import waterfallsink2</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' waterfallsink2.$(type.fcn)( diff --git a/gr-wxgui/src/python/CMakeLists.txt b/gr-wxgui/python/CMakeLists.txt index 24e06acd5e..24e06acd5e 100644 --- a/gr-wxgui/src/python/CMakeLists.txt +++ b/gr-wxgui/python/CMakeLists.txt diff --git a/gr-wxgui/src/python/__init__.py b/gr-wxgui/python/__init__.py index 68f8f4b5ea..07dbaf1620 100644 --- a/gr-wxgui/src/python/__init__.py +++ b/gr-wxgui/python/__init__.py @@ -20,6 +20,5 @@ # ''' -This is the gr-wxgui package. This package provides a GUI interface -using the Wx backend. +Provides a GUI interface using the Wx backend. ''' diff --git a/gr-wxgui/src/python/common.py b/gr-wxgui/python/common.py index 1410d29dfa..57fc530f88 100644 --- a/gr-wxgui/src/python/common.py +++ b/gr-wxgui/python/common.py @@ -64,8 +64,12 @@ class wxgui_hb(object): """ Create a function that will cache the visibility flag, and only call the handler when that flag changes. - @param handler the function to call on a change - @return a function of 1 argument + + Args: + handler: the function to call on a change + + Returns: + a function of 1 argument """ cache = [None] def callback(visible): @@ -84,8 +88,10 @@ class wxgui_hb(object): Bind a handler to a window when its visibility changes. Specifically, call the handler when the window visibility changes. This condition is checked on every update ui event. - @param win the wx window - @param handler a function of 1 param + + Args: + win: the wx window + handler: a function of 1 param """ #is the window visible in the hierarchy def is_wx_window_visible(my_win): @@ -126,8 +132,10 @@ def _register_access_method(destination, controller, key): 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 + + Args: + destination: the object to get new setter and getter methods + controller: the pubsub controller """ for key in controller.keys(): _register_access_method(destination, controller, key) @@ -164,8 +172,12 @@ import math def get_exp(num): """ Get the exponent of the number in base 10. - @param num the floating point number - @return the exponent as an integer + + Args: + num: the floating point number + + Returns: + the exponent as an integer """ if num == 0: return 0 return int(math.floor(math.log10(abs(num)))) @@ -173,8 +185,12 @@ def get_exp(num): def get_clean_num(num): """ Get the closest clean number match to num with bases 1, 2, 5. - @param num the number - @return the closest number + + Args: + num: the number + + Returns: + the closest number """ if num == 0: return 0 sign = num > 0 and 1 or -1 @@ -185,8 +201,12 @@ def get_clean_num(num): def get_clean_incr(num): """ Get the next higher clean number with bases 1, 2, 5. - @param num the number - @return the next higher number + + Args: + num: the number + + Returns: + the next higher number """ num = get_clean_num(num) exp = get_exp(num) @@ -203,8 +223,12 @@ def get_clean_incr(num): def get_clean_decr(num): """ Get the next lower clean number with bases 1, 2, 5. - @param num the number - @return the next lower number + + Args: + num: the number + + Returns: + the next lower number """ num = get_clean_num(num) exp = get_exp(num) @@ -221,8 +245,12 @@ def get_clean_decr(num): def get_min_max(samples): """ Get the minimum and maximum bounds for an array of samples. - @param samples the array of real values - @return a tuple of min, max + + Args: + samples: the array of real values + + Returns: + a tuple of min, max """ factor = 2.0 mean = numpy.average(samples) @@ -235,8 +263,12 @@ def get_min_max(samples): def get_min_max_fft(fft_samps): """ Get the minimum and maximum bounds for an array of fft samples. - @param samples the array of real values - @return a tuple of min, max + + Args: + samples: the array of real values + + Returns: + a tuple of min, max """ #get the peak level (max of the samples) peak_level = numpy.max(fft_samps) diff --git a/gr-wxgui/src/python/const_window.py b/gr-wxgui/python/const_window.py index 2ad89b2a38..1295aff1fa 100644 --- a/gr-wxgui/src/python/const_window.py +++ b/gr-wxgui/python/const_window.py @@ -60,7 +60,9 @@ class control_panel(wx.Panel): def __init__(self, parent): """ Create a new control panel. - @param parent the wx parent window + + Args: + parent: the wx parent window """ self.parent = parent wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER) @@ -174,7 +176,9 @@ class const_window(wx.Panel, pubsub.pubsub): def handle_msg(self, msg): """ Plot the samples onto the complex grid. - @param msg the array of complex samples + + Args: + msg: the array of complex samples """ if not self[RUNNING_KEY]: return #convert to complex floating point numbers diff --git a/gr-wxgui/src/python/constants.py b/gr-wxgui/python/constants.py index 08cc6a6343..08cc6a6343 100644 --- a/gr-wxgui/src/python/constants.py +++ b/gr-wxgui/python/constants.py diff --git a/gr-wxgui/src/python/constsink_gl.py b/gr-wxgui/python/constsink_gl.py index 51434df68f..0313e7fea0 100644 --- a/gr-wxgui/src/python/constsink_gl.py +++ b/gr-wxgui/python/constsink_gl.py @@ -24,7 +24,8 @@ ################################################## import const_window import common -from gnuradio import gr, blks2 +from gnuradio import gr +from gnuradio import blocks from pubsub import pubsub from constants import * import sys @@ -68,7 +69,7 @@ class const_sink_c(gr.hier_block2, common.wxgui_hb): gr.io_signature(0, 0, 0), ) #blocks - sd = blks2.stream_to_vector_decimator( + sd = blocks.stream_to_vector_decimator( item_size=gr.sizeof_gr_complex, sample_rate=sample_rate, vec_rate=frame_rate, @@ -101,7 +102,7 @@ class const_sink_c(gr.hier_block2, common.wxgui_hb): #) agc = gr.feedforward_agc_cc(16, 1) msgq = gr.msg_queue(2) - sink = gr.message_sink(gr.sizeof_gr_complex*const_size, msgq, True) + sink = blocks.message_sink(gr.sizeof_gr_complex*const_size, msgq, True) #controller def setter(p, k, x): p[k] = x self.controller = pubsub() diff --git a/gr-wxgui/src/python/fft_window.py b/gr-wxgui/python/fft_window.py index fac83a4a34..ada926c418 100644 --- a/gr-wxgui/src/python/fft_window.py +++ b/gr-wxgui/python/fft_window.py @@ -61,7 +61,9 @@ class control_panel(wx.Panel): def __init__(self, parent): """ Create a new control panel. - @param parent the wx parent window + + Args: + parent: the wx parent window """ self.parent = parent wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER) @@ -324,7 +326,9 @@ class fft_window(wx.Panel, pubsub.pubsub): If real, keep take only the positive bins. Plot the samples onto the grid as channel 1. If peak hold is enabled, plot peak vals as channel 2. - @param msg the fft array as a character array + + Args: + msg: the fft array as a character array """ if not self[RUNNING_KEY]: return #convert to floating point numbers diff --git a/gr-wxgui/src/python/fftsink2.py b/gr-wxgui/python/fftsink2.py index 3277cd3ffa..3277cd3ffa 100644 --- a/gr-wxgui/src/python/fftsink2.py +++ b/gr-wxgui/python/fftsink2.py diff --git a/gr-wxgui/src/python/fftsink_gl.py b/gr-wxgui/python/fftsink_gl.py index dc31e84a10..272a2456ce 100644 --- a/gr-wxgui/src/python/fftsink_gl.py +++ b/gr-wxgui/python/fftsink_gl.py @@ -1,5 +1,5 @@ # -# Copyright 2008,2009,2010 Free Software Foundation, Inc. +# Copyright 2008-2010,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -26,7 +26,10 @@ from __future__ import division ################################################## import fft_window import common -from gnuradio import gr, blks2 +from gnuradio import gr, fft +from gnuradio import analog +from gnuradio import blocks +from gnuradio.fft import logpwrfft from pubsub import pubsub from constants import * import math @@ -89,7 +92,7 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): win=win, ) msgq = gr.msg_queue(2) - sink = gr.message_sink(gr.sizeof_float*fft_size, msgq, True) + sink = blocks.message_sink(gr.sizeof_float*fft_size, msgq, True) #controller @@ -132,12 +135,12 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): self.win.set_callback(callb) class fft_sink_f(_fft_sink_base): - _fft_chain = blks2.logpwrfft_f + _fft_chain = logpwrfft.logpwrfft_f _item_size = gr.sizeof_float _real = True class fft_sink_c(_fft_sink_base): - _fft_chain = blks2.logpwrfft_c + _fft_chain = logpwrfft.logpwrfft_c _item_size = gr.sizeof_gr_complex _real = False @@ -150,7 +153,7 @@ from gnuradio.wxgui import stdgui2 class test_app_block (stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): - stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) + stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) fft_size = 256 @@ -158,44 +161,44 @@ class test_app_block (stdgui2.std_top_block): input_rate = 2048.0e3 #Generate some noise - noise =gr.noise_source_c(gr.GR_UNIFORM, 1.0/10) + noise = analog.noise_source_c(analog.GR_UNIFORM, 1.0/10) # Generate a complex sinusoid - #src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 2e3, 1) - src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 57.50e3, 1) + #src1 = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 2e3, 1) + src1 = analog.sig_source_c(input_rate, analog.GR_CONST_WAVE, 57.50e3, 1) # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. - thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate) + thr1 = blocks.throttle(gr.sizeof_gr_complex, input_rate) - sink1 = fft_sink_c (panel, title="Complex Data", fft_size=fft_size, - sample_rate=input_rate, baseband_freq=100e3, - ref_level=0, y_per_div=20, y_divs=10) - vbox.Add (sink1.win, 1, wx.EXPAND) + sink1 = fft_sink_c(panel, title="Complex Data", fft_size=fft_size, + sample_rate=input_rate, baseband_freq=100e3, + ref_level=0, y_per_div=20, y_divs=10) + vbox.Add(sink1.win, 1, wx.EXPAND) - combine1=gr.add_cc() + combine1 = blocks.add_cc() self.connect(src1, (combine1,0)) self.connect(noise,(combine1,1)) self.connect(combine1,thr1, sink1) - #src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2e3, 1) - src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 57.50e3, 1) - thr2 = gr.throttle(gr.sizeof_float, input_rate) - sink2 = fft_sink_f (panel, title="Real Data", fft_size=fft_size*2, - sample_rate=input_rate, baseband_freq=100e3, - ref_level=0, y_per_div=20, y_divs=10) - vbox.Add (sink2.win, 1, wx.EXPAND) + #src2 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 2e3, 1) + src2 = analog.sig_source_f (input_rate, analog.GR_CONST_WAVE, 57.50e3, 1) + thr2 = blocks.throttle(gr.sizeof_float, input_rate) + sink2 = fft_sink_f(panel, title="Real Data", fft_size=fft_size*2, + sample_rate=input_rate, baseband_freq=100e3, + ref_level=0, y_per_div=20, y_divs=10) + vbox.Add(sink2.win, 1, wx.EXPAND) - combine2=gr.add_ff() - c2f2=gr.complex_to_float() + combine2 = blocks.add_ff() + c2f2 = blocks.complex_to_float() self.connect(src2, (combine2,0)) self.connect(noise,c2f2,(combine2,1)) self.connect(combine2, thr2,sink2) def main (): - app = stdgui2.stdapp (test_app_block, "FFT Sink Test App") - app.MainLoop () + app = stdgui2.stdapp(test_app_block, "FFT Sink Test App") + app.MainLoop() if __name__ == '__main__': - main () + main() diff --git a/gr-wxgui/src/python/fftsink_nongl.py b/gr-wxgui/python/fftsink_nongl.py index c756d8a3b2..73bc7f41b0 100644 --- a/gr-wxgui/src/python/fftsink_nongl.py +++ b/gr-wxgui/python/fftsink_nongl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2003,2004,2005,2006,2007,2009,2010 Free Software Foundation, Inc. +# Copyright 2003-2007,2009,2010,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,8 +20,11 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, window +from gnuradio import gr, gru, fft, filter +from gnuradio import blocks +from gnuradio import analog from gnuradio.wxgui import stdgui2 +from gnuradio.filter import window import wx import plot import numpy @@ -117,26 +120,26 @@ class fft_sink_f(gr.hier_block2, fft_sink_base): average=average, avg_alpha=avg_alpha, title=title, peak_hold=peak_hold,use_persistence=use_persistence,persist_alpha=persist_alpha) - self.s2p = gr.stream_to_vector(gr.sizeof_float, self.fft_size) - self.one_in_n = gr.keep_one_in_n(gr.sizeof_float * self.fft_size, - max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + self.s2p = blocks.stream_to_vector(gr.sizeof_float, self.fft_size) + self.one_in_n = blocks.keep_one_in_n(gr.sizeof_float * self.fft_size, + max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) - self.fft = gr.fft_vfc(self.fft_size, True, mywindow) + self.fft = fft.fft_vfc(self.fft_size, True, mywindow) power = 0 for tap in mywindow: power += tap*tap - self.c2mag = gr.complex_to_mag(self.fft_size) - self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size) + self.c2mag = blocks.complex_to_mag(self.fft_size) + self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) # FIXME We need to add 3dB to all bins but the DC bin - self.log = gr.nlog10_ff(20, self.fft_size, - -10*math.log10(self.fft_size) # Adjust for number of bins - -10*math.log10(power/self.fft_size) # Adjust for windowing loss - -20*math.log10(ref_scale/2)) # Adjust for reference scale + self.log = blocks.nlog10_ff(20, self.fft_size, + -10*math.log10(self.fft_size) # Adjust for number of bins + -10*math.log10(power/self.fft_size) # Adjust for windowing loss + -20*math.log10(ref_scale/2)) # Adjust for reference scale - self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) + self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) self.win = fft_window(self, parent, size=size) @@ -149,7 +152,8 @@ class fft_sink_c(gr.hier_block2, fft_sink_base): def __init__(self, parent, baseband_freq=0, ref_scale=2.0, y_per_div=10, y_divs=8, ref_level=50, sample_rate=1, fft_size=512, fft_rate=default_fft_rate, average=False, avg_alpha=None, - title='', size=default_fftsink_size, peak_hold=False, use_persistence=False,persist_alpha=0.2, **kwargs): + title='', size=default_fftsink_size, peak_hold=False, + use_persistence=False, persist_alpha=0.2, **kwargs): gr.hier_block2.__init__(self, "fft_sink_c", gr.io_signature(1, 1, gr.sizeof_gr_complex), @@ -162,26 +166,26 @@ class fft_sink_c(gr.hier_block2, fft_sink_base): average=average, avg_alpha=avg_alpha, title=title, peak_hold=peak_hold, use_persistence=use_persistence,persist_alpha=persist_alpha) - self.s2p = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) - self.one_in_n = gr.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size, - max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + self.s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) + self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size, + max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) - self.fft = gr.fft_vcc(self.fft_size, True, mywindow) + self.fft = fft.fft_vcc(self.fft_size, True, mywindow) power = 0 for tap in mywindow: power += tap*tap - self.c2mag = gr.complex_to_mag(self.fft_size) - self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size) + self.c2mag = blocks.complex_to_mag(self.fft_size) + self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) # FIXME We need to add 3dB to all bins but the DC bin - self.log = gr.nlog10_ff(20, self.fft_size, - -10*math.log10(self.fft_size) # Adjust for number of bins - -10*math.log10(power/self.fft_size) # Adjust for windowing loss - -20*math.log10(ref_scale/2)) # Adjust for reference scale + self.log = blocks.nlog10_ff(20, self.fft_size, + -10*math.log10(self.fft_size) # Adjust for number of bins + -10*math.log10(power/self.fft_size) # Adjust for windowing loss + -20*math.log10(ref_scale/2)) # Adjust for reference scale - self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) + self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) self.win = fft_window(self, parent, size=size) @@ -604,33 +608,33 @@ class test_app_block (stdgui2.std_top_block): input_rate = 100*20.48e3 # Generate a complex sinusoid - #src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 100*2e3, 1) - src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 100*5.75e3, 1) + #src1 = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 100*2e3, 1) + src1 = analog.sig_source_c(input_rate, analog.GR_CONST_WAVE, 100*5.75e3, 1) # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. - thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate) + thr1 = blocks.throttle(gr.sizeof_gr_complex, input_rate) - sink1 = fft_sink_c (panel, title="Complex Data", fft_size=fft_size, - sample_rate=input_rate, baseband_freq=100e3, - ref_level=0, y_per_div=20, y_divs=10) - vbox.Add (sink1.win, 1, wx.EXPAND) + sink1 = fft_sink_c(panel, title="Complex Data", fft_size=fft_size, + sample_rate=input_rate, baseband_freq=100e3, + ref_level=0, y_per_div=20, y_divs=10) + vbox.Add(sink1.win, 1, wx.EXPAND) self.connect(src1, thr1, sink1) - #src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 100*2e3, 1) - src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 100*5.75e3, 1) - thr2 = gr.throttle(gr.sizeof_float, input_rate) - sink2 = fft_sink_f (panel, title="Real Data", fft_size=fft_size*2, - sample_rate=input_rate, baseband_freq=100e3, - ref_level=0, y_per_div=20, y_divs=10) - vbox.Add (sink2.win, 1, wx.EXPAND) + #src2 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 100*2e3, 1) + src2 = analog.sig_source_f(input_rate, analog.GR_CONST_WAVE, 100*5.75e3, 1) + thr2 = blocks.throttle(gr.sizeof_float, input_rate) + sink2 = fft_sink_f(panel, title="Real Data", fft_size=fft_size*2, + sample_rate=input_rate, baseband_freq=100e3, + ref_level=0, y_per_div=20, y_divs=10) + vbox.Add(sink2.win, 1, wx.EXPAND) self.connect(src2, thr2, sink2) def main (): - app = stdgui2.stdapp (test_app_block, "FFT Sink Test App") - app.MainLoop () + app = stdgui2.stdapp(test_app_block, "FFT Sink Test App") + app.MainLoop() if __name__ == '__main__': main () diff --git a/gr-wxgui/src/python/form.py b/gr-wxgui/python/form.py index 0442e49c84..0442e49c84 100644 --- a/gr-wxgui/src/python/form.py +++ b/gr-wxgui/python/form.py diff --git a/gr-wxgui/src/python/forms/__init__.py b/gr-wxgui/python/forms/__init__.py index 3068b18fe1..67d3b4a88a 100644 --- a/gr-wxgui/src/python/forms/__init__.py +++ b/gr-wxgui/python/forms/__init__.py @@ -48,13 +48,15 @@ import wx class static_box_sizer(wx.StaticBoxSizer): """ A box sizer with label and border. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param label title label for this widget (optional) - @param bold true to boldify the label - @param orient the sizer orientation wx.VERTICAL or wx.HORIZONTAL (default=wx.VERTICAL) + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + label: title label for this widget (optional) + bold: true to boldify the label + orient: the sizer orientation wx.VERTICAL or wx.HORIZONTAL (default=wx.VERTICAL) """ def __init__(self, parent, label='', bold=False, sizer=None, orient=wx.VERTICAL, proportion=0, flag=wx.EXPAND): box = wx.StaticBox(parent=parent, label=label) @@ -65,20 +67,17 @@ class static_box_sizer(wx.StaticBoxSizer): class incr_decr_buttons(wx.BoxSizer): """ A horizontal box sizer with a increment and a decrement button. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param label title label for this widget (optional) - @param on_incr the callback for pressing the + button - @param on_decr the callback for pressing the - button + + Args: + parent: the parent widget + on_incr: the callback for pressing the + button + on_decr: the callback for pressing the - button + label: title label for this widget (optional) + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) """ def __init__(self, parent, on_incr, on_decr, label='', sizer=None, proportion=0, flag=wx.EXPAND): - """ - @param parent the parent window - @param on_incr the event handler for increment - @param on_decr the event handler for decrement - """ wx.BoxSizer.__init__(self, wx.HORIZONTAL) buttons_box = wx.BoxSizer(wx.HORIZONTAL) self._incr_button = wx.Button(parent, label='+', style=wx.BU_EXACTFIT) diff --git a/gr-wxgui/src/python/forms/converters.py b/gr-wxgui/python/forms/converters.py index db14d2752c..db14d2752c 100644 --- a/gr-wxgui/src/python/forms/converters.py +++ b/gr-wxgui/python/forms/converters.py diff --git a/gr-wxgui/src/python/forms/forms.py b/gr-wxgui/python/forms/forms.py index cabc5860b9..80822ae174 100644 --- a/gr-wxgui/src/python/forms/forms.py +++ b/gr-wxgui/python/forms/forms.py @@ -90,11 +90,13 @@ class _form_base(pubsub, wx.BoxSizer): Bind the update handler to the widget for data events. This ensures that the gui thread handles updating widgets. Setup the pusub triggers for external and internal. - @param widget the main widget - @param label the optional label - @param flag additional flags for widget - @param label_prop the proportion for the label - @param widget_prop the proportion for the widget + + Args: + widget: the main widget + label: the optional label + flag: additional flags for widget + label_prop: the proportion for the label + widget_prop: the proportion for the widget """ #setup data event widget.Bind(EVT_DATA, lambda x: self._update(x.data)) @@ -184,18 +186,20 @@ class _slider_base(_form_base): class static_text(_form_base): """ A text box form. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param label title label for this widget (optional) - @param width the width of the form in px - @param bold true to bold-ify the text (default=False) - @param units a suffix to add after the text - @param converter forms.str_converter(), int_converter(), float_converter()... + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + ps: the pubsub object (optional) + key: the pubsub key (optional) + value: the default value (optional) + label: title label for this widget (optional) + width: the width of the form in px + bold: true to bold-ify the text (default=False) + units: a suffix to add after the text + converter: forms.str_converter(), int_converter(), float_converter()... """ def __init__(self, label='', width=-1, bold=False, units='', converter=converters.str_converter(), **kwargs): self._units = units @@ -214,16 +218,18 @@ class static_text(_form_base): class text_box(_form_base): """ A text box form. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param label title label for this widget (optional) - @param width the width of the form in px - @param converter forms.str_converter(), int_converter(), float_converter()... + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + ps: the pubsub object (optional) + key: the pubsub key (optional) + value: the default value (optional) + label: title label for this widget (optional) + width: the width of the form in px + converter: forms.str_converter(), int_converter(), float_converter()... """ def __init__(self, label='', width=-1, converter=converters.eval_converter(), **kwargs): _form_base.__init__(self, converter=converter, **kwargs) @@ -249,21 +255,23 @@ class text_box(_form_base): class slider(_slider_base): """ A generic linear slider. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param label title label for this widget (optional) - @param length the length of the slider in px (optional) - @param style wx.SL_HORIZONTAL or wx.SL_VERTICAL (default=horizontal) - @param minimum the minimum value - @param maximum the maximum value - @param num_steps the number of slider steps (or specify step_size) - @param step_size the step between slider jumps (or specify num_steps) - @param cast a cast function, int, or float (default=float) + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + ps: the pubsub object (optional) + key: the pubsub key (optional) + value: the default value (optional) + label: title label for this widget (optional) + length: the length of the slider in px (optional) + style: wx.SL_HORIZONTAL or wx.SL_VERTICAL (default=horizontal) + minimum: the minimum value + maximum: the maximum value + num_steps: the number of slider steps (or specify step_size) + step_size: the step between slider jumps (or specify num_steps) + cast: a cast function, int, or float (default=float) """ def __init__(self, minimum=-100, maximum=100, num_steps=100, step_size=None, cast=float, **kwargs): assert step_size or num_steps @@ -275,21 +283,23 @@ class log_slider(_slider_base): """ A generic logarithmic slider. The sliders min and max values are base**min_exp and base**max_exp. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param label title label for this widget (optional) - @param length the length of the slider in px (optional) - @param style wx.SL_HORIZONTAL or wx.SL_VERTICAL (default=horizontal) - @param min_exp the minimum exponent - @param max_exp the maximum exponent - @param base the exponent base in base**exp - @param num_steps the number of slider steps (or specify step_size) - @param step_size the exponent step size (or specify num_steps) + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + ps: the pubsub object (optional) + key: the pubsub key (optional) + value: the default value (optional) + label: title label for this widget (optional) + length: the length of the slider in px (optional) + style: wx.SL_HORIZONTAL or wx.SL_VERTICAL (default=horizontal) + min_exp: the minimum exponent + max_exp: the maximum exponent + base: the exponent base in base**exp + num_steps: the number of slider steps (or specify step_size) + step_size: the exponent step size (or specify num_steps) """ def __init__(self, min_exp=0, max_exp=1, base=10, num_steps=100, step_size=None, **kwargs): assert step_size or num_steps @@ -304,20 +314,22 @@ class gauge(_form_base): """ A gauge bar. The gauge displays floating point values between the minimum and maximum. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param label title label for this widget (optional) - @param length the length of the slider in px (optional) - @param style wx.GA_HORIZONTAL or wx.GA_VERTICAL (default=horizontal) - @param minimum the minimum value - @param maximum the maximum value - @param num_steps the number of slider steps (or specify step_size) - @param step_size the step between slider jumps (or specify num_steps) + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + ps: the pubsub object (optional) + key: the pubsub key (optional) + value: the default value (optional) + label: title label for this widget (optional) + length: the length of the slider in px (optional) + style: wx.GA_HORIZONTAL or wx.GA_VERTICAL (default=horizontal) + minimum: the minimum value + maximum: the maximum value + num_steps: the number of slider steps (or specify step_size) + step_size: the step between slider jumps (or specify num_steps) """ def __init__(self, label='', length=-1, minimum=-100, maximum=100, num_steps=100, step_size=None, style=wx.GA_HORIZONTAL, **kwargs): assert step_size or num_steps @@ -338,16 +350,18 @@ class gauge(_form_base): class check_box(_form_base): """ Create a check box form. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param true the value for form when checked (default=True) - @param false the value for form when unchecked (default=False) - @param label title label for this widget (optional) + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + ps: the pubsub object (optional) + key: the pubsub key (optional) + value: the default value (optional) + true: the value for form when checked (default=True) + false: the value for form when unchecked (default=False) + label: title label for this widget (optional) """ def __init__(self, label='', true=True, false=False, **kwargs): _form_base.__init__(self, converter=converters.bool_converter(true=true, false=false), **kwargs) @@ -364,17 +378,19 @@ class check_box(_form_base): class drop_down(_chooser_base): """ Create a drop down menu form. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param choices list of possible values - @param labels list of labels for each choice (default=choices) - @param label title label for this widget (optional) - @param width the form width in px (optional) + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + ps: the pubsub object (optional) + key: the pubsub key (optional) + value: the default value (optional) + choices: list of possible values + labels: list of labels for each choice (default=choices) + label: title label for this widget (optional) + width: the form width in px (optional) """ def __init__(self, label='', width=-1, **kwargs): _chooser_base.__init__(self, **kwargs) @@ -394,18 +410,18 @@ class drop_down(_chooser_base): class button(_chooser_base): """ Create a multi-state button. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param choices list of possible values - @param labels list of labels for each choice (default=choices) - @param width the width of the button in pixels (optional) - @param style style arguments (optional) - @param label title label for this widget (optional) + parent the parent widget + sizer add this widget to sizer if provided (optional) + proportion the proportion when added to the sizer (default=0) + flag the flag argument when added to the sizer (default=wx.EXPAND) + ps the pubsub object (optional) + key the pubsub key (optional) + value the default value (optional) + choices list of possible values + labels list of labels for each choice (default=choices) + width the width of the button in pixels (optional) + style style arguments (optional) + label title label for this widget (optional) """ def __init__(self, label='', style=0, width=-1, **kwargs): _chooser_base.__init__(self, **kwargs) @@ -420,17 +436,19 @@ class toggle_button(button): """ Create a dual-state button. This button will alternate between True and False when clicked. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param width the width of the button in pixels (optional) - @param style style arguments (optional) - @param true_label the button's label in the true state - @param false_label the button's label in the false state + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + ps: the pubsub object (optional) + key: the pubsub key (optional) + value: the default value (optional) + width: the width of the button in pixels (optional) + style: style arguments (optional) + true_label: the button's label in the true state + false_label: the button's label in the false state """ def __init__(self, true_label='On (click to stop)', false_label='Off (click to start)', **kwargs): button.__init__(self, choices=[True, False], labels=[true_label, false_label], **kwargs) @@ -440,16 +458,18 @@ class single_button(toggle_button): Create a single state button. This button will callback() when clicked. For use when state holding is not important. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param width the width of the button in pixels (optional) - @param style style arguments (optional) - @param label the button's label + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + ps: the pubsub object (optional) + key: the pubsub key (optional) + value: the default value (optional) + width: the width of the button in pixels (optional) + style: style arguments (optional) + label: the button's label """ def __init__(self, label='click for callback', **kwargs): toggle_button.__init__(self, true_label=label, false_label=label, value=True, **kwargs) @@ -460,18 +480,20 @@ class single_button(toggle_button): class radio_buttons(_chooser_base): """ Create a radio button form. - @param parent the parent widget - @param sizer add this widget to sizer if provided (optional) - @param proportion the proportion when added to the sizer (default=0) - @param flag the flag argument when added to the sizer (default=wx.EXPAND) - @param ps the pubsub object (optional) - @param key the pubsub key (optional) - @param value the default value (optional) - @param choices list of possible values - @param labels list of labels for each choice (default=choices) - @param major_dimension the number of rows/cols (default=auto) - @param label title label for this widget (optional) - @param style useful style args: wx.RA_HORIZONTAL, wx.RA_VERTICAL, wx.NO_BORDER (default=wx.RA_HORIZONTAL) + + Args: + parent: the parent widget + sizer: add this widget to sizer if provided (optional) + proportion: the proportion when added to the sizer (default=0) + flag: the flag argument when added to the sizer (default=wx.EXPAND) + ps: the pubsub object (optional) + key: the pubsub key (optional) + value the default value (optional) + choices: list of possible values + labels: list of labels for each choice (default=choices) + major_dimension: the number of rows/cols (default=auto) + label: title label for this widget (optional) + style: useful style args: wx.RA_HORIZONTAL, wx.RA_VERTICAL, wx.NO_BORDER (default=wx.RA_HORIZONTAL) """ def __init__(self, style=wx.RA_HORIZONTAL, label='', major_dimension=0, **kwargs): _chooser_base.__init__(self, **kwargs) diff --git a/gr-wxgui/src/python/gui.py b/gr-wxgui/python/gui.py index ccc773eabf..ccc773eabf 100644 --- a/gr-wxgui/src/python/gui.py +++ b/gr-wxgui/python/gui.py diff --git a/gr-wxgui/src/python/histo_window.py b/gr-wxgui/python/histo_window.py index a1b520f9c1..3e38fdcb64 100644 --- a/gr-wxgui/src/python/histo_window.py +++ b/gr-wxgui/python/histo_window.py @@ -48,7 +48,9 @@ class control_panel(wx.Panel): def __init__(self, parent): """ Create a new control panel. - @param parent the wx parent window + + Args: + parent: the wx parent window """ self.parent = parent wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER) @@ -134,7 +136,9 @@ class histo_window(wx.Panel, pubsub.pubsub): def handle_msg(self, msg): """ Handle the message from the fft sink message queue. - @param msg the frame as a character array + + Args: + msg: the frame as a character array """ if not self[RUNNING_KEY]: return #convert to floating point numbers diff --git a/gr-wxgui/src/python/histosink_gl.py b/gr-wxgui/python/histosink_gl.py index 509f746be6..6fa7539aa7 100644 --- a/gr-wxgui/src/python/histosink_gl.py +++ b/gr-wxgui/python/histosink_gl.py @@ -1,5 +1,5 @@ # -# Copyright 2009 Free Software Foundation, Inc. +# Copyright 2009,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,7 +24,9 @@ ################################################## import histo_window import common -from gnuradio import gr, blks2 +from gnuradio import gr +from gnuradio import analog +from gnuradio import blocks from pubsub import pubsub from constants import * @@ -94,17 +96,17 @@ class test_app_block (stdgui2.std_top_block): # build our flow graph input_rate = 20.48e3 - src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2e3, 1) - #src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1) - thr2 = gr.throttle(gr.sizeof_float, input_rate) - sink2 = histo_sink_f (panel, title="Data", num_bins=31, frame_size=1000) - vbox.Add (sink2.win, 1, wx.EXPAND) + src2 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 2e3, 1) + #src2 = analog.sig_source_f(input_rate, analog.GR_CONST_WAVE, 5.75e3, 1) + thr2 = blocks.throttle(gr.sizeof_float, input_rate) + sink2 = histo_sink_f(panel, title="Data", num_bins=31, frame_size=1000) + vbox.Add(sink2.win, 1, wx.EXPAND) self.connect(src2, thr2, sink2) def main (): - app = stdgui2.stdapp (test_app_block, "Histo Sink Test App") - app.MainLoop () + app = stdgui2.stdapp(test_app_block, "Histo Sink Test App") + app.MainLoop() if __name__ == '__main__': - main () + main() diff --git a/gr-wxgui/src/python/number_window.py b/gr-wxgui/python/number_window.py index ab9d1ebc00..751047db94 100644 --- a/gr-wxgui/src/python/number_window.py +++ b/gr-wxgui/python/number_window.py @@ -54,7 +54,9 @@ class control_panel(wx.Panel): def __init__(self, parent): """ Create a new control panel. - @param parent the wx parent window + + Args: + parent: the wx parent window """ self.parent = parent wx.Panel.__init__(self, parent) @@ -176,7 +178,9 @@ class number_window(wx.Panel, pubsub.pubsub): """ Show or hide the gauges. If this is real, never show the imaginary gauge. - @param show_gauge true to show + + Args: + show_gauge: true to show """ self.gauge_real.ShowItems(show_gauge) self.gauge_imag.ShowItems(show_gauge and not self.real) @@ -187,7 +191,9 @@ class number_window(wx.Panel, pubsub.pubsub): Convert the string based message into a float or complex. If more than one number was read, only take the last number. Perform peak hold operations, set the gauges and display. - @param event event.data is the number sample as a character array + + Args: + event: event.data is the number sample as a character array """ if not self[RUNNING_KEY]: return format_string = "%%.%df"%self.decimal_places diff --git a/gr-wxgui/src/python/numbersink2.py b/gr-wxgui/python/numbersink2.py index 011acdfd5e..62a096e112 100644 --- a/gr-wxgui/src/python/numbersink2.py +++ b/gr-wxgui/python/numbersink2.py @@ -1,5 +1,5 @@ # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,7 +24,9 @@ ################################################## import number_window import common -from gnuradio import gr, blks2 +from gnuradio import gr, filter +from gnuradio import analog +from gnuradio import blocks from pubsub import pubsub from constants import * @@ -65,22 +67,22 @@ class _number_sink_base(gr.hier_block2, common.wxgui_hb): gr.io_signature(0, 0, 0), ) #blocks - sd = blks2.stream_to_vector_decimator( + sd = blocks.stream_to_vector_decimator( item_size=self._item_size, sample_rate=sample_rate, vec_rate=number_rate, vec_len=1, ) if self._real: - mult = gr.multiply_const_ff(factor) - add = gr.add_const_ff(ref_level) - avg = gr.single_pole_iir_filter_ff(1.0) + mult = blocks.multiply_const_ff(factor) + add = blocks.add_const_ff(ref_level) + avg = filter.single_pole_iir_filter_ff(1.0) else: - mult = gr.multiply_const_cc(factor) - add = gr.add_const_cc(ref_level) - avg = gr.single_pole_iir_filter_cc(1.0) + mult = blocks.multiply_const_cc(factor) + add = blocks.add_const_cc(ref_level) + avg = filter.single_pole_iir_filter_cc(1.0) msgq = gr.msg_queue(2) - sink = gr.message_sink(self._item_size, msgq, True) + sink = blocks.message_sink(self._item_size, msgq, True) #controller self.controller = pubsub() self.controller.subscribe(SAMPLE_RATE_KEY, sd.set_sample_rate) @@ -134,38 +136,38 @@ class number_sink_c(_number_sink_base): import wx from gnuradio.wxgui import stdgui2 -class test_app_flow_graph (stdgui2.std_top_block): +class test_app_flow_graph(stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): - stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) + stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) # build our flow graph input_rate = 20.48e3 # Generate a real and complex sinusoids - src1 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2.21e3, 1) - src2 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 2.21e3, 1) + src1 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 2.21e3, 1) + src2 = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 2.21e3, 1) # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. - thr1 = gr.throttle(gr.sizeof_float, input_rate) - thr2 = gr.throttle(gr.sizeof_gr_complex, input_rate) + thr1 = blocks.throttle(gr.sizeof_float, input_rate) + thr2 = blocks.throttle(gr.sizeof_gr_complex, input_rate) - sink1 = number_sink_f (panel, unit='V',label="Real Data", avg_alpha=0.001, - sample_rate=input_rate, minval=-1, maxval=1, - ref_level=0, decimal_places=3) - vbox.Add (sink1.win, 1, wx.EXPAND) - sink2 = number_sink_c (panel, unit='V',label="Complex Data", avg_alpha=0.001, - sample_rate=input_rate, minval=-1, maxval=1, - ref_level=0, decimal_places=3) - vbox.Add (sink2.win, 1, wx.EXPAND) + sink1 = number_sink_f(panel, unit='V',label="Real Data", avg_alpha=0.001, + sample_rate=input_rate, minval=-1, maxval=1, + ref_level=0, decimal_places=3) + vbox.Add(sink1.win, 1, wx.EXPAND) + sink2 = number_sink_c(panel, unit='V',label="Complex Data", avg_alpha=0.001, + sample_rate=input_rate, minval=-1, maxval=1, + ref_level=0, decimal_places=3) + vbox.Add(sink2.win, 1, wx.EXPAND) - self.connect (src1, thr1, sink1) - self.connect (src2, thr2, sink2) + self.connect(src1, thr1, sink1) + self.connect(src2, thr2, sink2) def main (): - app = stdgui2.stdapp (test_app_flow_graph, "Number Sink Test App") - app.MainLoop () + app = stdgui2.stdapp(test_app_flow_graph, "Number Sink Test App") + app.MainLoop() if __name__ == '__main__': - main () + main() diff --git a/gr-wxgui/src/python/plot.py b/gr-wxgui/python/plot.py index 041a2a7a50..041a2a7a50 100644 --- a/gr-wxgui/src/python/plot.py +++ b/gr-wxgui/python/plot.py diff --git a/gr-wxgui/src/python/plotter/__init__.py b/gr-wxgui/python/plotter/__init__.py index 616492a3e6..616492a3e6 100644 --- a/gr-wxgui/src/python/plotter/__init__.py +++ b/gr-wxgui/python/plotter/__init__.py diff --git a/gr-wxgui/src/python/plotter/bar_plotter.py b/gr-wxgui/python/plotter/bar_plotter.py index 3f9259e9df..487db66b64 100644 --- a/gr-wxgui/src/python/plotter/bar_plotter.py +++ b/gr-wxgui/python/plotter/bar_plotter.py @@ -108,9 +108,13 @@ class bar_plotter(grid_plotter_base): Get the text the will populate the point label. Give X and Y values for the current point. Give values for the channel at the X coordinate. - @param x_val the current x value - @param y_val the current y value - @return a string with newlines + + Args: + x_val: the current x value + y_val: the current y value + + Returns: + a string with newlines """ if len(self._bars) == 0: return '' scalar = float(len(self._bars)-1)/(self.x_max - self.x_min) @@ -130,9 +134,11 @@ class bar_plotter(grid_plotter_base): def set_bars(self, bars, bar_width, color_spec): """ Set the bars. - @param bars a list of bars - @param bar_width the fractional width of the bar, between 0 and 1 - @param color_spec the color tuple + + Args: + bars: a list of bars + bar_width: the fractional width of the bar, between 0 and 1 + color_spec: the color tuple """ self.lock() self._bars = bars diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/python/plotter/channel_plotter.py index 4bcc36fd4c..1eac9f5f3a 100644 --- a/gr-wxgui/src/python/plotter/channel_plotter.py +++ b/gr-wxgui/python/plotter/channel_plotter.py @@ -67,8 +67,12 @@ class channel_plotter(grid_plotter_base): def enable_legend(self, enable=None): """ Enable/disable the legend. - @param enable true to enable - @return the enable state when None + + Args: + enable: true to enable + + Returns: + the enable state when None """ if enable is None: return self._enable_legend self.lock() @@ -128,9 +132,13 @@ class channel_plotter(grid_plotter_base): Get the text the will populate the point label. Give X and Y values for the current point. Give values for the channel at the X coordinate. - @param x_val the current x value - @param y_val the current y value - @return a string with newlines + + Args: + x_val: the current x value + y_val: the current y value + + Returns: + a string with newlines """ #create text label_str = '%s: %s\n%s: %s'%( @@ -186,7 +194,9 @@ class channel_plotter(grid_plotter_base): def clear_waveform(self, channel): """ Remove a waveform from the list of waveforms. - @param channel the channel key + + Args: + channel: the channel key """ self.lock() if channel in self._channels.keys(): @@ -198,11 +208,13 @@ class channel_plotter(grid_plotter_base): def set_waveform(self, channel, samples=[], color_spec=(0, 0, 0), marker=None, trig_off=0): """ Set the waveform for a given channel. - @param channel the channel key - @param samples the waveform samples - @param color_spec the 3-tuple for line color - @param marker None for line - @param trig_off fraction of sample for trigger offset + + Args: + channel: the channel key + samples: the waveform samples + color_spec: the 3-tuple for line color + marker: None for line + trig_off: fraction of sample for trigger offset """ self.lock() if channel not in self._channels.keys(): self._legend_cache.changed(True) diff --git a/gr-wxgui/src/python/plotter/common.py b/gr-wxgui/python/plotter/common.py index 88215e039a..9af636245d 100644 --- a/gr-wxgui/src/python/plotter/common.py +++ b/gr-wxgui/python/plotter/common.py @@ -30,8 +30,12 @@ import wx def get_exp(num): """ Get the exponent of the number in base 10. - @param num the floating point number - @return the exponent as an integer + + Args: + num: the floating point number + + Returns: + the exponent as an integer """ if num == 0: return 0 return int(math.floor(math.log10(abs(num)))) @@ -41,8 +45,12 @@ def get_si_components(num): Get the SI units for the number. Extract the coeff and exponent of the number. The exponent will be a multiple of 3. - @param num the floating point number - @return the tuple coeff, exp, prefix + + Args: + num: the floating point number + + Returns: + the tuple coeff, exp, prefix """ num = float(num) exp = get_exp(num) @@ -65,8 +73,12 @@ def get_si_components(num): def sci_format(num): """ Format a floating point number into scientific notation. - @param num the number to format - @return a label string + + Args: + num: the number to format + + Returns: + a label string """ coeff, exp, prefix = get_si_components(num) if -3 <= exp < 3: return '%g'%num @@ -75,9 +87,13 @@ def sci_format(num): def eng_format(num, units=''): """ Format a floating point number into engineering notation. - @param num the number to format - @param units the units to append - @return a label string + + Args: + num: the number to format + units: the units to append + + Returns: + a label string """ coeff, exp, prefix = get_si_components(num) if -3 <= exp < 3: return '%g'%num diff --git a/gr-wxgui/src/python/plotter/gltext.py b/gr-wxgui/python/plotter/gltext.py index 0b6e3f55b3..0b6e3f55b3 100644 --- a/gr-wxgui/src/python/plotter/gltext.py +++ b/gr-wxgui/python/plotter/gltext.py diff --git a/gr-wxgui/src/python/plotter/grid_plotter_base.py b/gr-wxgui/python/plotter/grid_plotter_base.py index f1bc8f546d..a492539575 100644 --- a/gr-wxgui/src/python/plotter/grid_plotter_base.py +++ b/gr-wxgui/python/plotter/grid_plotter_base.py @@ -78,7 +78,9 @@ class grid_plotter_base(plotter_base): def set_point_label_coordinate(self, coor): """ Set the point label coordinate. - @param coor the coordinate x, y tuple or None + + Args: + coor: the coordinate x, y tuple or None """ self.lock() self._point_label_coordinate = coor @@ -103,8 +105,12 @@ class grid_plotter_base(plotter_base): Enable/disable the grid aspect ratio. If enabled, enforce the aspect ratio on the padding: horizontal_padding:vertical_padding == width:height - @param enable true to enable - @return the enable state when None + + Args: + enable: true to enable + + Returns: + the enable state when None """ if enable is None: return self._enable_grid_aspect_ratio self.lock() @@ -115,8 +121,12 @@ class grid_plotter_base(plotter_base): def enable_point_label(self, enable=None): """ Enable/disable the point label. - @param enable true to enable - @return the enable state when None + + Args: + enable: true to enable + + Returns: + the enable state when None """ if enable is None: return self._enable_point_label self.lock() @@ -127,7 +137,9 @@ class grid_plotter_base(plotter_base): def set_title(self, title): """ Set the title. - @param title the title string + + Args: + title the title string """ self.lock() self.title = title @@ -137,8 +149,10 @@ class grid_plotter_base(plotter_base): def set_x_label(self, x_label, x_units=''): """ Set the x label and units. - @param x_label the x label string - @param x_units the x units string + + Args: + x_label: the x label string + x_units: the x units string """ self.lock() self.x_label = x_label @@ -149,8 +163,10 @@ class grid_plotter_base(plotter_base): def set_y_label(self, y_label, y_units=''): """ Set the y label and units. - @param y_label the y label string - @param y_units the y units string + + Args: + y_label: the y label string + y_units: the y units string """ self.lock() self.y_label = y_label @@ -161,10 +177,12 @@ class grid_plotter_base(plotter_base): def set_x_grid(self, minimum, maximum, step, scale=False): """ Set the x grid parameters. - @param minimum the left-most value - @param maximum the right-most value - @param step the grid spacing - @param scale true to scale the x grid + + Args: + minimum: the left-most value + maximum: the right-most value + step: the grid spacing + scale: true to scale the x grid """ self.lock() self.x_min = float(minimum) @@ -183,10 +201,12 @@ class grid_plotter_base(plotter_base): def set_y_grid(self, minimum, maximum, step, scale=False): """ Set the y grid parameters. - @param minimum the bottom-most value - @param maximum the top-most value - @param step the grid spacing - @param scale true to scale the y grid + + Args: + minimum: the bottom-most value + maximum: the top-most value + step: the grid spacing + scale: true to scale the y grid """ self.lock() self.y_min = float(minimum) @@ -305,9 +325,13 @@ class grid_plotter_base(plotter_base): def _get_tick_label(self, tick, unit): """ Format the tick value and create a gl text. - @param tick the floating point tick value - @param unit the axis unit - @return the tick label text + + Args: + tick: the floating point tick value + unit: the axis unit + + Returns: + the tick label text """ if unit: tick_str = common.sci_format(tick) else: tick_str = common.eng_format(tick) @@ -316,11 +340,15 @@ class grid_plotter_base(plotter_base): def _get_ticks(self, min, max, step, scalar): """ Determine the positions for the ticks. - @param min the lower bound - @param max the upper bound - @param step the grid spacing - @param scalar the grid scaling - @return a list of tick positions between min and max + + Args: + min: the lower bound + max: the upper bound + step: the grid spacing + scalar: the grid scaling + + Returns: + a list of tick positions between min and max """ #cast to float min = float(min) @@ -340,8 +368,12 @@ class grid_plotter_base(plotter_base): def enable_grid_lines(self, enable=None): """ Enable/disable the grid lines. - @param enable true to enable - @return the enable state when None + + Args: + enable: true to enable + + Returns: + the enable state when None """ if enable is None: return self._enable_grid_lines self.lock() @@ -352,8 +384,10 @@ class grid_plotter_base(plotter_base): def _draw_grid_line(self, coor1, coor2): """ Draw a dashed line from coor1 to coor2. - @param corr1 a tuple of x, y - @param corr2 a tuple of x, y + + Args: + corr1: a tuple of x, y + corr2: a tuple of x, y """ if not self.enable_grid_lines(): return length = math.sqrt((coor1[0] - coor2[0])**2 + (coor1[1] - coor2[1])**2) @@ -372,11 +406,13 @@ class grid_plotter_base(plotter_base): """ Draw a rectangle on the x, y plane. X and Y are the top-left corner. - @param x the left position of the rectangle - @param y the top position of the rectangle - @param width the width of the rectangle - @param height the height of the rectangle - @param fill true to color inside of rectangle + + Args: + x: the left position of the rectangle + y: the top position of the rectangle + width: the width of the rectangle + height: the height of the rectangle + fill: true to color inside of rectangle """ GL.glBegin(fill and GL.GL_QUADS or GL.GL_LINE_LOOP) GL.glVertex2f(x, y) diff --git a/gr-wxgui/src/python/plotter/plotter_base.py b/gr-wxgui/python/plotter/plotter_base.py index b8a2ce709e..78e21f3c1d 100644 --- a/gr-wxgui/src/python/plotter/plotter_base.py +++ b/gr-wxgui/python/plotter/plotter_base.py @@ -37,7 +37,9 @@ class gl_cache(object): def __init__(self, draw): """ Create a new cache. - @param draw a function to draw gl stuff + + Args: + draw: a function to draw gl stuff """ self.changed(True) self._draw = draw @@ -84,7 +86,9 @@ class plotter_base(wx.glcanvas.GLCanvas, common.mutex): Initialize the GLCanvas with double buffering. Initialize various plotter flags. Bind the paint and size events. - @param parent the parent widgit + + Args: + parent: the parent widgit """ attribList = (wx.glcanvas.WX_GL_DOUBLEBUFFER, wx.glcanvas.WX_GL_RGBA) wx.glcanvas.GLCanvas.__init__(self, parent, attribList=attribList); @@ -111,7 +115,9 @@ class plotter_base(wx.glcanvas.GLCanvas, common.mutex): """ Create a new gl cache. Register its draw and init function. - @return the new cache object + + Returns: + the new cache object """ cache = gl_cache(draw_fcn) self.register_init(cache.init) diff --git a/gr-wxgui/src/python/plotter/waterfall_plotter.py b/gr-wxgui/python/plotter/waterfall_plotter.py index 6a6bf6330e..02ec67ee4c 100644 --- a/gr-wxgui/src/python/plotter/waterfall_plotter.py +++ b/gr-wxgui/python/plotter/waterfall_plotter.py @@ -49,8 +49,12 @@ def _get_rbga(red_pts, green_pts, blue_pts, alpha_pts=[(0, 0), (1, 0)]): The x and y values of the coordinates range from 0 to 1. The coordinates must be specified so that x increases with the index value. Resulting values are calculated along the line formed between 2 coordinates. - @param *_pts an array of x,y coordinates for each color element - @return array of rbga values (4 bytes) each + + Args: + red_pts, green_pts, blue_pts, alpha_pts: an array of x,y coordinates for each color element + + Returns: + array of rbga values (4 bytes) each """ def _fcn(x, pw): for (x1, y1), (x2, y2) in zip(pw, pw[1:]): @@ -167,9 +171,13 @@ class waterfall_plotter(grid_plotter_base): """ Get the text the will populate the point label. Give the X value for the current point. - @param x_val the current x value - @param y_val the current y value - @return a value string with units + + Args: + x_val: the current x value + y_val: the current y value + + Returns: + a value string with units """ return '%s: %s'%(self.x_label, common.eng_format(x_val, self.x_units)) @@ -210,7 +218,9 @@ class waterfall_plotter(grid_plotter_base): def _resize_texture(self, flag=None): """ Create the texture to fit the fft_size X num_lines. - @param flag the set/unset or update flag + + Args: + flag: the set/unset or update flag """ if flag is not None: self._resize_texture_flag = flag @@ -229,7 +239,9 @@ class waterfall_plotter(grid_plotter_base): Set the color mode. New samples will be converted to the new color mode. Old samples will not be recolorized. - @param color_mode the new color mode string + + Args: + color_mode: the new color mode string """ self.lock() if color_mode in COLORS.keys(): @@ -242,7 +254,9 @@ class waterfall_plotter(grid_plotter_base): """ Set number of lines. Powers of two only. - @param num_lines the new number of lines + + Args: + num_lines: the new number of lines """ self.lock() self._num_lines = num_lines @@ -254,9 +268,11 @@ class waterfall_plotter(grid_plotter_base): """ Set the samples to the waterfall. Convert the samples to color data. - @param samples the array of floats - @param minimum the minimum value to scale - @param maximum the maximum value to scale + + Args: + samples: the array of floats + minimum: the minimum value to scale + maximum: the maximum value to scale """ self.lock() #set the min, max values diff --git a/gr-wxgui/src/python/powermate.py b/gr-wxgui/python/powermate.py index 7c324c5d95..7c324c5d95 100644 --- a/gr-wxgui/src/python/powermate.py +++ b/gr-wxgui/python/powermate.py diff --git a/gr-wxgui/src/python/pubsub.py b/gr-wxgui/python/pubsub.py index e55d691978..e55d691978 100644 --- a/gr-wxgui/src/python/pubsub.py +++ b/gr-wxgui/python/pubsub.py diff --git a/gr-wxgui/src/python/scope_window.py b/gr-wxgui/python/scope_window.py index dc90a60459..306e1757f1 100644 --- a/gr-wxgui/src/python/scope_window.py +++ b/gr-wxgui/python/scope_window.py @@ -84,7 +84,9 @@ class control_panel(wx.Panel): def __init__(self, parent): """ Create a new control panel. - @param parent the wx parent window + + Args: + parent: the wx parent window """ WIDTH = 90 self.parent = parent @@ -526,7 +528,9 @@ class scope_window(wx.Panel, pubsub.pubsub): Handle the message from the scope sink message queue. Plot the list of arrays of samples onto the grid. Each samples array gets its own channel. - @param msg the time domain data as a character array + + Args: + msg: the time domain data as a character array """ if not self[RUNNING_KEY]: return #check time elapsed diff --git a/gr-wxgui/src/python/scopesink2.py b/gr-wxgui/python/scopesink2.py index 99e268895a..99e268895a 100644 --- a/gr-wxgui/src/python/scopesink2.py +++ b/gr-wxgui/python/scopesink2.py diff --git a/gr-wxgui/src/python/scopesink_gl.py b/gr-wxgui/python/scopesink_gl.py index e6ff532e76..21d7169026 100644 --- a/gr-wxgui/src/python/scopesink_gl.py +++ b/gr-wxgui/python/scopesink_gl.py @@ -1,5 +1,5 @@ # -# Copyright 2008,2010 Free Software Foundation, Inc. +# Copyright 2008,2010,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,7 +24,8 @@ ################################################## import scope_window import common -from gnuradio import gr +from gnuradio import gr, filter +from gnuradio import blocks from pubsub import pubsub from constants import * import math @@ -43,9 +44,9 @@ class ac_couple_block(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_float), ) #blocks - lpf = gr.single_pole_iir_filter_ff(0.0) - sub = gr.sub_ff() - mute = gr.mute_ff() + lpf = filter.single_pole_iir_filter_ff(0.0) + sub = blocks.sub_ff() + mute = blocks.mute_ff() #connect self.connect(self, sub, self) self.connect(self, lpf, mute, (sub, 1)) @@ -157,7 +158,7 @@ class _scope_sink_base(gr.hier_block2, common.wxgui_hb): ) else: for i in range(num_inputs): - c2f = gr.complex_to_float() + c2f = blocks.complex_to_float() self.wxgui_connect((self, i), c2f) for j in range(2): self.connect( @@ -206,18 +207,20 @@ class test_top_block (stdgui2.std_top_block): # Generate a complex sinusoid ampl=1.0e3 - self.src0 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 25.1e3*input_rate/default_input_rate, ampl) - self.noise =gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 11.1*25.1e3*input_rate/default_input_rate, ampl/10) - #self.noise =gr.noise_source_c(gr.GR_GAUSSIAN, ampl/10) - self.combine=gr.add_cc() + self.src0 = analog.sig_source_c(input_rate, gr.GR_SIN_WAVE, + 25.1e3*input_rate/default_input_rate, ampl) + self.noise = analog.sig_source_c (input_rate, analog.GR_SIN_WAVE, + 11.1*25.1e3*input_rate/default_input_rate, ampl/10) + #self.noise = analog.noise_source_c(analog.GR_GAUSSIAN, ampl/10) + self.combine = analog.add_cc() # We add this throttle block so that this demo doesn't suck down # all the CPU available. You normally wouldn't use it... - self.thr = gr.throttle(gr.sizeof_gr_complex, input_rate) + self.thr = blocks.throttle(gr.sizeof_gr_complex, input_rate) - scope = scope_sink_c (panel,"Secret Data",sample_rate=input_rate, - v_scale=v_scale, t_scale=t_scale) - vbox.Add (scope.win, 1, wx.EXPAND) + scope = scope_sink_c(panel,"Secret Data",sample_rate=input_rate, + v_scale=v_scale, t_scale=t_scale) + vbox.Add(scope.win, 1, wx.EXPAND) # Ultimately this will be # self.connect("src0 throttle scope") @@ -226,8 +229,8 @@ class test_top_block (stdgui2.std_top_block): self.connect(self.combine, self.thr, scope) def main (): - app = stdgui2.stdapp (test_top_block, "O'Scope Test App") - app.MainLoop () + app = stdgui2.stdapp(test_top_block, "O'Scope Test App") + app.MainLoop() if __name__ == '__main__': - main () + main() diff --git a/gr-wxgui/src/python/scopesink_nongl.py b/gr-wxgui/python/scopesink_nongl.py index d45e799060..2c5ff9278a 100644 --- a/gr-wxgui/src/python/scopesink_nongl.py +++ b/gr-wxgui/python/scopesink_nongl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2003,2004,2006,2007 Free Software Foundation, Inc. +# Copyright 2003,2004,2006,2007,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,6 +21,8 @@ # from gnuradio import gr, gru, eng_notation +from gnuradio import analog +from gnuradio import blocks from gnuradio.wxgui import stdgui2 import wx import gnuradio.wxgui.plot as plot @@ -45,7 +47,7 @@ class scope_sink_f(gr.hier_block2): for i in range(num_inputs): self.connect((self, i), (self.guts, i)) - self.win = scope_window(win_info (msgq, sample_rate, frame_decim, + self.win = scope_window(win_info(msgq, sample_rate, frame_decim, v_scale, t_scale, self.guts, title), parent) def set_sample_rate(self, sample_rate): @@ -64,10 +66,10 @@ class scope_sink_c(gr.hier_block2): msgq = gr.msg_queue(2) # message queue that holds at most 2 messages self.guts = gr.oscope_sink_f(sample_rate, msgq) for i in range(num_inputs): - c2f = gr.complex_to_float() + c2f = blocks.complex_to_float() self.connect((self, i), c2f) - self.connect((c2f, 0), (self.guts, 2*i+0)) - self.connect((c2f, 1), (self.guts, 2*i+1)) + self.connect((c2f, 0),(self.guts, 2*i+0)) + self.connect((c2f, 1),(self.guts, 2*i+1)) self.win = scope_window(win_info(msgq, sample_rate, frame_decim, v_scale, t_scale, self.guts, title), parent) @@ -81,7 +83,7 @@ class constellation_sink(scope_sink_c): def __init__(self, parent, title='Constellation', sample_rate=1, size=default_scopesink_size, frame_decim=default_frame_decim): scope_sink_c.__init__(self, parent=parent, title=title, sample_rate=sample_rate, - size=size, frame_decim=frame_decim) + size=size, frame_decim=frame_decim) self.win.info.xy = True #constellation mode # ======================================================================== @@ -141,21 +143,21 @@ def EVT_DATA_EVENT(win, func): class DataEvent(wx.PyEvent): def __init__(self, data): wx.PyEvent.__init__(self) - self.SetEventType (wxDATA_EVENT) + self.SetEventType(wxDATA_EVENT) self.data = data - def Clone (self): - self.__class__ (self.GetId()) + def Clone(self): + self.__class__(self.GetId()) -class win_info (object): +class win_info(object): __slots__ = ['msgq', 'sample_rate', 'frame_decim', 'v_scale', 'scopesink', 'title', 'time_scale_cursor', 'v_scale_cursor', 'marker', 'xy', 'autorange', 'running'] - def __init__ (self, msgq, sample_rate, frame_decim, v_scale, t_scale, - scopesink, title = "Oscilloscope", xy=False): + def __init__(self, msgq, sample_rate, frame_decim, v_scale, t_scale, + scopesink, title = "Oscilloscope", xy=False): self.msgq = msgq self.sample_rate = sample_rate self.frame_decim = frame_decim @@ -170,30 +172,30 @@ class win_info (object): self.autorange = not v_scale self.running = True - def get_time_per_div (self): - return self.time_scale_cursor.current () + def get_time_per_div(self): + return self.time_scale_cursor.current() - def get_volts_per_div (self): - return self.v_scale_cursor.current () + def get_volts_per_div(self): + return self.v_scale_cursor.current() def set_sample_rate(self, sample_rate): self.sample_rate = sample_rate - def get_sample_rate (self): + def get_sample_rate(self): return self.sample_rate - def get_decimation_rate (self): + def get_decimation_rate(self): return 1.0 - def set_marker (self, s): + def set_marker(self, s): self.marker = s - def get_marker (self): + def get_marker(self): return self.marker -class input_watcher (gru.msgq_runner): - def __init__ (self, msgq, event_receiver, frame_decim, **kwds): +class input_watcher(gru.msgq_runner): + def __init__(self, msgq, event_receiver, frame_decim, **kwds): self.event_receiver = event_receiver self.frame_decim = frame_decim self.iscan = 0 @@ -211,166 +213,166 @@ class input_watcher (gru.msgq_runner): bytes_per_chan = nsamples * gr.sizeof_float records = [] - for ch in range (nchan): + for ch in range(nchan): start = ch * bytes_per_chan chan_data = s[start:start+bytes_per_chan] - rec = numpy.fromstring (chan_data, numpy.float32) - records.append (rec) + rec = numpy.fromstring(chan_data, numpy.float32) + records.append(rec) # print "nrecords = %d, reclen = %d" % (len (records),nsamples) - de = DataEvent (records) - wx.PostEvent (self.event_receiver, de) + de = DataEvent(records) + wx.PostEvent(self.event_receiver, de) records = [] del de self.iscan -= 1 -class scope_window (wx.Panel): +class scope_window(wx.Panel): - def __init__ (self, info, parent, id = -1, - pos = wx.DefaultPosition, size = wx.DefaultSize, name = ""): - wx.Panel.__init__ (self, parent, -1) + def __init__(self, info, parent, id = -1, + pos = wx.DefaultPosition, size = wx.DefaultSize, name = ""): + wx.Panel.__init__(self, parent, -1) self.info = info - vbox = wx.BoxSizer (wx.VERTICAL) + vbox = wx.BoxSizer(wx.VERTICAL) - self.graph = graph_window (info, self, -1) + self.graph = graph_window(info, self, -1) - vbox.Add (self.graph, 1, wx.EXPAND) - vbox.Add (self.make_control_box(), 0, wx.EXPAND) - vbox.Add (self.make_control2_box(), 0, wx.EXPAND) + vbox.Add(self.graph, 1, wx.EXPAND) + vbox.Add(self.make_control_box(), 0, wx.EXPAND) + vbox.Add(self.make_control2_box(), 0, wx.EXPAND) self.sizer = vbox - self.SetSizer (self.sizer) - self.SetAutoLayout (True) - self.sizer.Fit (self) + self.SetSizer(self.sizer) + self.SetAutoLayout(True) + self.sizer.Fit(self) self.set_autorange(self.info.autorange) # second row of control buttons etc. appears BELOW control_box - def make_control2_box (self): - ctrlbox = wx.BoxSizer (wx.HORIZONTAL) + def make_control2_box(self): + ctrlbox = wx.BoxSizer(wx.HORIZONTAL) - self.inc_v_button = wx.Button (self, 1101, " < ", style=wx.BU_EXACTFIT) - self.inc_v_button.SetToolTipString ("Increase vertical range") - wx.EVT_BUTTON (self, 1101, self.incr_v_scale) # ID matches button ID above + self.inc_v_button = wx.Button(self, 1101, " < ", style=wx.BU_EXACTFIT) + self.inc_v_button.SetToolTipString("Increase vertical range") + wx.EVT_BUTTON(self, 1101, self.incr_v_scale) # ID matches button ID above - self.dec_v_button = wx.Button (self, 1100, " > ", style=wx.BU_EXACTFIT) - self.dec_v_button.SetToolTipString ("Decrease vertical range") - wx.EVT_BUTTON (self, 1100, self.decr_v_scale) + self.dec_v_button = wx.Button(self, 1100, " > ", style=wx.BU_EXACTFIT) + self.dec_v_button.SetToolTipString("Decrease vertical range") + wx.EVT_BUTTON(self, 1100, self.decr_v_scale) - self.v_scale_label = wx.StaticText (self, 1002, "None") # vertical /div - self.update_v_scale_label () + self.v_scale_label = wx.StaticText(self, 1002, "None") # vertical /div + self.update_v_scale_label() - self.autorange_checkbox = wx.CheckBox (self, 1102, "Autorange") - self.autorange_checkbox.SetToolTipString ("Select autorange on/off") + self.autorange_checkbox = wx.CheckBox(self, 1102, "Autorange") + self.autorange_checkbox.SetToolTipString("Select autorange on/off") wx.EVT_CHECKBOX(self, 1102, self.autorange_checkbox_event) - ctrlbox.Add ((5,0) ,0) # left margin space - ctrlbox.Add (self.inc_v_button, 0, wx.EXPAND) - ctrlbox.Add (self.dec_v_button, 0, wx.EXPAND) - ctrlbox.Add (self.v_scale_label, 0, wx.ALIGN_CENTER) - ctrlbox.Add ((20,0) ,0) # spacer - ctrlbox.Add (self.autorange_checkbox, 0, wx.ALIGN_CENTER) + ctrlbox.Add((5,0) ,0) # left margin space + ctrlbox.Add(self.inc_v_button, 0, wx.EXPAND) + ctrlbox.Add(self.dec_v_button, 0, wx.EXPAND) + ctrlbox.Add(self.v_scale_label, 0, wx.ALIGN_CENTER) + ctrlbox.Add((20,0) ,0) # spacer + ctrlbox.Add(self.autorange_checkbox, 0, wx.ALIGN_CENTER) return ctrlbox - def make_control_box (self): - ctrlbox = wx.BoxSizer (wx.HORIZONTAL) + def make_control_box(self): + ctrlbox = wx.BoxSizer(wx.HORIZONTAL) - tb_left = wx.Button (self, 1001, " < ", style=wx.BU_EXACTFIT) - tb_left.SetToolTipString ("Increase time base") - wx.EVT_BUTTON (self, 1001, self.incr_timebase) + tb_left = wx.Button(self, 1001, " < ", style=wx.BU_EXACTFIT) + tb_left.SetToolTipString("Increase time base") + wx.EVT_BUTTON(self, 1001, self.incr_timebase) - tb_right = wx.Button (self, 1000, " > ", style=wx.BU_EXACTFIT) - tb_right.SetToolTipString ("Decrease time base") - wx.EVT_BUTTON (self, 1000, self.decr_timebase) + tb_right = wx.Button(self, 1000, " > ", style=wx.BU_EXACTFIT) + tb_right.SetToolTipString("Decrease time base") + wx.EVT_BUTTON(self, 1000, self.decr_timebase) - self.time_base_label = wx.StaticText (self, 1002, "") - self.update_timebase_label () + self.time_base_label = wx.StaticText(self, 1002, "") + self.update_timebase_label() - ctrlbox.Add ((5,0) ,0) - # ctrlbox.Add (wx.StaticText (self, -1, "Horiz Scale: "), 0, wx.ALIGN_CENTER) - ctrlbox.Add (tb_left, 0, wx.EXPAND) - ctrlbox.Add (tb_right, 0, wx.EXPAND) - ctrlbox.Add (self.time_base_label, 0, wx.ALIGN_CENTER) + ctrlbox.Add((5,0) ,0) + # ctrlbox.Add(wx.StaticText(self, -1, "Horiz Scale: "), 0, wx.ALIGN_CENTER) + ctrlbox.Add(tb_left, 0, wx.EXPAND) + ctrlbox.Add(tb_right, 0, wx.EXPAND) + ctrlbox.Add(self.time_base_label, 0, wx.ALIGN_CENTER) - ctrlbox.Add ((10,0) ,1) # stretchy space + ctrlbox.Add((10,0) ,1) # stretchy space - ctrlbox.Add (wx.StaticText (self, -1, "Trig: "), 0, wx.ALIGN_CENTER) - self.trig_chan_choice = wx.Choice (self, 1004, - choices = ['Ch1', 'Ch2', 'Ch3', 'Ch4']) - self.trig_chan_choice.SetToolTipString ("Select channel for trigger") - wx.EVT_CHOICE (self, 1004, self.trig_chan_choice_event) - ctrlbox.Add (self.trig_chan_choice, 0, wx.ALIGN_CENTER) + ctrlbox.Add(wx.StaticText(self, -1, "Trig: "), 0, wx.ALIGN_CENTER) + self.trig_chan_choice = wx.Choice(self, 1004, + choices = ['Ch1', 'Ch2', 'Ch3', 'Ch4']) + self.trig_chan_choice.SetToolTipString("Select channel for trigger") + wx.EVT_CHOICE(self, 1004, self.trig_chan_choice_event) + ctrlbox.Add(self.trig_chan_choice, 0, wx.ALIGN_CENTER) - self.trig_mode_choice = wx.Choice (self, 1005, - choices = ['Free', 'Auto', 'Norm']) + self.trig_mode_choice = wx.Choice(self, 1005, + choices = ['Free', 'Auto', 'Norm']) self.trig_mode_choice.SetSelection(1) - self.trig_mode_choice.SetToolTipString ("Select trigger slope or Auto (untriggered roll)") - wx.EVT_CHOICE (self, 1005, self.trig_mode_choice_event) - ctrlbox.Add (self.trig_mode_choice, 0, wx.ALIGN_CENTER) + self.trig_mode_choice.SetToolTipString("Select trigger slope or Auto (untriggered roll)") + wx.EVT_CHOICE(self, 1005, self.trig_mode_choice_event) + ctrlbox.Add(self.trig_mode_choice, 0, wx.ALIGN_CENTER) - trig_level50 = wx.Button (self, 1006, "50%") - trig_level50.SetToolTipString ("Set trigger level to 50%") - wx.EVT_BUTTON (self, 1006, self.set_trig_level50) - ctrlbox.Add (trig_level50, 0, wx.EXPAND) + trig_level50 = wx.Button(self, 1006, "50%") + trig_level50.SetToolTipString("Set trigger level to 50%") + wx.EVT_BUTTON(self, 1006, self.set_trig_level50) + ctrlbox.Add(trig_level50, 0, wx.EXPAND) - run_stop = wx.Button (self, 1007, "Run/Stop") - run_stop.SetToolTipString ("Toggle Run/Stop mode") - wx.EVT_BUTTON (self, 1007, self.run_stop) - ctrlbox.Add (run_stop, 0, wx.EXPAND) + run_stop = wx.Button(self, 1007, "Run/Stop") + run_stop.SetToolTipString("Toggle Run/Stop mode") + wx.EVT_BUTTON(self, 1007, self.run_stop) + ctrlbox.Add(run_stop, 0, wx.EXPAND) - ctrlbox.Add ((10, 0) ,1) # stretchy space + ctrlbox.Add((10, 0) ,1) # stretchy space - ctrlbox.Add (wx.StaticText (self, -1, "Fmt: "), 0, wx.ALIGN_CENTER) - self.marker_choice = wx.Choice (self, 1002, choices = self._marker_choices) - self.marker_choice.SetToolTipString ("Select plotting with lines, pluses or dots") - wx.EVT_CHOICE (self, 1002, self.marker_choice_event) - ctrlbox.Add (self.marker_choice, 0, wx.ALIGN_CENTER) + ctrlbox.Add(wx.StaticText(self, -1, "Fmt: "), 0, wx.ALIGN_CENTER) + self.marker_choice = wx.Choice(self, 1002, choices = self._marker_choices) + self.marker_choice.SetToolTipString("Select plotting with lines, pluses or dots") + wx.EVT_CHOICE(self, 1002, self.marker_choice_event) + ctrlbox.Add(self.marker_choice, 0, wx.ALIGN_CENTER) - self.xy_choice = wx.Choice (self, 1003, choices = ['X:t', 'X:Y']) - self.xy_choice.SetToolTipString ("Select X vs time or X vs Y display") - wx.EVT_CHOICE (self, 1003, self.xy_choice_event) - ctrlbox.Add (self.xy_choice, 0, wx.ALIGN_CENTER) + self.xy_choice = wx.Choice(self, 1003, choices = ['X:t', 'X:Y']) + self.xy_choice.SetToolTipString("Select X vs time or X vs Y display") + wx.EVT_CHOICE(self, 1003, self.xy_choice_event) + ctrlbox.Add(self.xy_choice, 0, wx.ALIGN_CENTER) return ctrlbox _marker_choices = ['line', 'plus', 'dot'] - def update_timebase_label (self): - time_per_div = self.info.get_time_per_div () - s = ' ' + eng_notation.num_to_str (time_per_div) + 's/div' - self.time_base_label.SetLabel (s) + def update_timebase_label(self): + time_per_div = self.info.get_time_per_div() + s = ' ' + eng_notation.num_to_str(time_per_div) + 's/div' + self.time_base_label.SetLabel(s) - def decr_timebase (self, evt): - self.info.time_scale_cursor.prev () - self.update_timebase_label () + def decr_timebase(self, evt): + self.info.time_scale_cursor.prev() + self.update_timebase_label() - def incr_timebase (self, evt): - self.info.time_scale_cursor.next () - self.update_timebase_label () + def incr_timebase(self, evt): + self.info.time_scale_cursor.next() + self.update_timebase_label() - def update_v_scale_label (self): - volts_per_div = self.info.get_volts_per_div () - s = ' ' + eng_notation.num_to_str (volts_per_div) + '/div' # Not V/div - self.v_scale_label.SetLabel (s) + def update_v_scale_label(self): + volts_per_div = self.info.get_volts_per_div() + s = ' ' + eng_notation.num_to_str(volts_per_div) + '/div' # Not V/div + self.v_scale_label.SetLabel(s) - def decr_v_scale (self, evt): - self.info.v_scale_cursor.prev () - self.update_v_scale_label () + def decr_v_scale(self, evt): + self.info.v_scale_cursor.prev() + self.update_v_scale_label() - def incr_v_scale (self, evt): - self.info.v_scale_cursor.next () - self.update_v_scale_label () + def incr_v_scale(self, evt): + self.info.v_scale_cursor.next() + self.update_v_scale_label() - def marker_choice_event (self, evt): - s = evt.GetString () - self.set_marker (s) + def marker_choice_event(self, evt): + s = evt.GetString() + self.set_marker(s) def set_autorange(self, on): if on: @@ -395,64 +397,64 @@ class scope_window (wx.Panel): else: self.set_autorange(False) - def set_marker (self, s): - self.info.set_marker (s) # set info for drawing routines - i = self.marker_choice.FindString (s) + def set_marker(self, s): + self.info.set_marker(s) # set info for drawing routines + i = self.marker_choice.FindString(s) assert i >= 0, "Hmmm, set_marker problem" - self.marker_choice.SetSelection (i) + self.marker_choice.SetSelection(i) - def set_format_line (self): - self.set_marker ('line') + def set_format_line(self): + self.set_marker('line') - def set_format_dot (self): - self.set_marker ('dot') + def set_format_dot(self): + self.set_marker('dot') - def set_format_plus (self): - self.set_marker ('plus') + def set_format_plus(self): + self.set_marker('plus') - def xy_choice_event (self, evt): - s = evt.GetString () + def xy_choice_event(self, evt): + s = evt.GetString() self.info.xy = s == 'X:Y' - def trig_chan_choice_event (self, evt): - s = evt.GetString () - ch = int (s[-1]) - 1 - self.info.scopesink.set_trigger_channel (ch) + def trig_chan_choice_event(self, evt): + s = evt.GetString() + ch = int(s[-1]) - 1 + self.info.scopesink.set_trigger_channel(ch) - def trig_mode_choice_event (self, evt): + def trig_mode_choice_event(self, evt): sink = self.info.scopesink - s = evt.GetString () + s = evt.GetString() if s == 'Norm': - sink.set_trigger_mode (gr.gr_TRIG_MODE_NORM) + sink.set_trigger_mode(gr.gr_TRIG_MODE_NORM) elif s == 'Auto': - sink.set_trigger_mode (gr.gr_TRIG_MODE_AUTO) + sink.set_trigger_mode(gr.gr_TRIG_MODE_AUTO) elif s == 'Free': - sink.set_trigger_mode (gr.gr_TRIG_MODE_FREE) + sink.set_trigger_mode(gr.gr_TRIG_MODE_FREE) else: assert 0, "Bad trig_mode_choice string" - def set_trig_level50 (self, evt): - self.info.scopesink.set_trigger_level_auto () + def set_trig_level50(self, evt): + self.info.scopesink.set_trigger_level_auto() - def run_stop (self, evt): + def run_stop(self, evt): self.info.running = not self.info.running -class graph_window (plot.PlotCanvas): +class graph_window(plot.PlotCanvas): channel_colors = ['BLUE', 'RED', 'CYAN', 'MAGENTA', 'GREEN', 'YELLOW'] - def __init__ (self, info, parent, id = -1, + def __init__(self, info, parent, id = -1, pos = wx.DefaultPosition, size = (640, 240), style = wx.DEFAULT_FRAME_STYLE, name = ""): - plot.PlotCanvas.__init__ (self, parent, id, pos, size, style, name) + plot.PlotCanvas.__init__(self, parent, id, pos, size, style, name) - self.SetXUseScopeTicks (True) - self.SetEnableGrid (True) - self.SetEnableZoom (True) + self.SetXUseScopeTicks(True) + self.SetEnableGrid(True) + self.SetEnableZoom(True) self.SetEnableLegend(True) - # self.SetBackgroundColour ('black') + # self.SetBackgroundColour('black') self.info = info; self.y_range = None @@ -462,38 +464,38 @@ class graph_window (plot.PlotCanvas): self.avg_x_min = None self.avg_x_max = None - EVT_DATA_EVENT (self, self.format_data) + EVT_DATA_EVENT(self, self.format_data) - self.input_watcher = input_watcher (info.msgq, self, info.frame_decim) + self.input_watcher = input_watcher(info.msgq, self, info.frame_decim) - def channel_color (self, ch): + def channel_color(self, ch): return self.channel_colors[ch % len(self.channel_colors)] - def format_data (self, evt): + def format_data(self, evt): if not self.info.running: return if self.info.xy: - self.format_xy_data (evt) + self.format_xy_data(evt) return info = self.info records = evt.data - nchannels = len (records) - npoints = len (records[0]) + nchannels = len(records) + npoints = len(records[0]) objects = [] - Ts = 1.0 / (info.get_sample_rate () / info.get_decimation_rate ()) - x_vals = Ts * numpy.arange (-npoints/2, npoints/2) + Ts = 1.0 / (info.get_sample_rate() / info.get_decimation_rate()) + x_vals = Ts * numpy.arange(-npoints/2, npoints/2) # preliminary clipping based on time axis here, instead of in graphics code - time_per_window = self.info.get_time_per_div () * 10 - n = int (time_per_window / Ts + 0.5) + time_per_window = self.info.get_time_per_div() * 10 + n = int(time_per_window / Ts + 0.5) n = n & ~0x1 # make even - n = max (2, min (n, npoints)) + n = max(2, min(n, npoints)) - self.SetXUseScopeTicks (True) # use 10 divisions, no labels + self.SetXUseScopeTicks(True) # use 10 divisions, no labels for ch in range(nchannels): r = records[ch] @@ -502,74 +504,74 @@ class graph_window (plot.PlotCanvas): lb = npoints/2 - n/2 ub = npoints/2 + n/2 - # points = zip (x_vals[lb:ub], r[lb:ub]) - points = numpy.zeros ((ub-lb, 2), numpy.float64) + # points = zip(x_vals[lb:ub], r[lb:ub]) + points = numpy.zeros((ub-lb, 2), numpy.float64) points[:,0] = x_vals[lb:ub] points[:,1] = r[lb:ub] - m = info.get_marker () + m = info.get_marker() if m == 'line': - objects.append (plot.PolyLine (points, - colour=self.channel_color (ch), - legend=('Ch%d' % (ch+1,)))) + objects.append(plot.PolyLine(points, + colour=self.channel_color(ch), + legend=('Ch%d' % (ch+1,)))) else: - objects.append (plot.PolyMarker (points, - marker=m, - colour=self.channel_color (ch), - legend=('Ch%d' % (ch+1,)))) + objects.append(plot.PolyMarker(points, + marker=m, + colour=self.channel_color(ch), + legend=('Ch%d' % (ch+1,)))) - graphics = plot.PlotGraphics (objects, - title=self.info.title, - xLabel = '', yLabel = '') + graphics = plot.PlotGraphics(objects, + title=self.info.title, + xLabel = '', yLabel = '') - time_per_div = info.get_time_per_div () + time_per_div = info.get_time_per_div() x_range = (-5.0 * time_per_div, 5.0 * time_per_div) # ranges are tuples! - volts_per_div = info.get_volts_per_div () + volts_per_div = info.get_volts_per_div() if not self.info.autorange: self.y_range = (-4.0 * volts_per_div, 4.0 * volts_per_div) - self.Draw (graphics, xAxis=x_range, yAxis=self.y_range) - self.update_y_range () # autorange to self.y_range + self.Draw(graphics, xAxis=x_range, yAxis=self.y_range) + self.update_y_range() # autorange to self.y_range - def format_xy_data (self, evt): + def format_xy_data(self, evt): info = self.info records = evt.data - nchannels = len (records) - npoints = len (records[0]) + nchannels = len(records) + npoints = len(records[0]) if nchannels < 2: return objects = [] - # points = zip (records[0], records[1]) - points = numpy.zeros ((len(records[0]), 2), numpy.float32) + # points = zip(records[0], records[1]) + points = numpy.zeros((len(records[0]), 2), numpy.float32) points[:,0] = records[0] points[:,1] = records[1] - self.SetXUseScopeTicks (False) + self.SetXUseScopeTicks(False) - m = info.get_marker () + m = info.get_marker() if m == 'line': - objects.append (plot.PolyLine (points, - colour=self.channel_color (0))) + objects.append(plot.PolyLine(points, + colour=self.channel_color(0))) else: - objects.append (plot.PolyMarker (points, - marker=m, - colour=self.channel_color (0))) + objects.append(plot.PolyMarker(points, + marker=m, + colour=self.channel_color(0))) - graphics = plot.PlotGraphics (objects, - title=self.info.title, - xLabel = 'I', yLabel = 'Q') + graphics = plot.PlotGraphics(objects, + title=self.info.title, + xLabel = 'I', yLabel = 'Q') - self.Draw (graphics, xAxis=self.x_range, yAxis=self.y_range) - self.update_y_range () - self.update_x_range () + self.Draw(graphics, xAxis=self.x_range, yAxis=self.y_range) + self.update_y_range() + self.update_x_range() - def update_y_range (self): + def update_y_range(self): alpha = 1.0/25 graphics = self.last_draw[0] - p1, p2 = graphics.boundingBox () # min, max points of graphics + p1, p2 = graphics.boundingBox() # min, max points of graphics if self.avg_y_min: # prevent vertical scale from jumping abruptly --? self.avg_y_min = p1[1] * alpha + self.avg_y_min * (1 - alpha) @@ -578,15 +580,15 @@ class graph_window (plot.PlotCanvas): self.avg_y_min = p1[1] # -500.0 workaround, sometimes p1 is ~ 10^35 self.avg_y_max = p2[1] # 500.0 - self.y_range = self._axisInterval ('auto', self.avg_y_min, self.avg_y_max) + self.y_range = self._axisInterval('auto', self.avg_y_min, self.avg_y_max) # print "p1 %s p2 %s y_min %s y_max %s y_range %s" \ # % (p1, p2, self.avg_y_min, self.avg_y_max, self.y_range) - def update_x_range (self): + def update_x_range(self): alpha = 1.0/25 graphics = self.last_draw[0] - p1, p2 = graphics.boundingBox () # min, max points of graphics + p1, p2 = graphics.boundingBox() # min, max points of graphics if self.avg_x_min: self.avg_x_min = p1[0] * alpha + self.avg_x_min * (1 - alpha) @@ -595,16 +597,16 @@ class graph_window (plot.PlotCanvas): self.avg_x_min = p1[0] self.avg_x_max = p2[0] - self.x_range = self._axisInterval ('auto', self.avg_x_min, self.avg_x_max) + self.x_range = self._axisInterval('auto', self.avg_x_min, self.avg_x_max) # ---------------------------------------------------------------- # Stand-alone test application # ---------------------------------------------------------------- -class test_top_block (stdgui2.std_top_block): +class test_top_block(stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): - stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) + stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) if len(argv) > 1: frame_decim = int(argv[1]) @@ -626,26 +628,26 @@ class test_top_block (stdgui2.std_top_block): input_rate = 1e6 # Generate a complex sinusoid - self.src0 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 25.1e3, 1e3) + self.src0 = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 25.1e3, 1e3) # We add this throttle block so that this demo doesn't suck down # all the CPU available. You normally wouldn't use it... - self.thr = gr.throttle(gr.sizeof_gr_complex, input_rate) + self.thr = blocks.throttle(gr.sizeof_gr_complex, input_rate) - scope = scope_sink_c (panel,"Secret Data",sample_rate=input_rate, - frame_decim=frame_decim, - v_scale=v_scale, t_scale=t_scale) - vbox.Add (scope.win, 1, wx.EXPAND) + scope = scope_sink_c(panel,"Secret Data",sample_rate=input_rate, + frame_decim=frame_decim, + v_scale=v_scale, t_scale=t_scale) + vbox.Add(scope.win, 1, wx.EXPAND) # Ultimately this will be # self.connect("src0 throttle scope") self.connect(self.src0, self.thr, scope) -def main (): - app = stdgui2.stdapp (test_top_block, "O'Scope Test App") - app.MainLoop () +def main(): + app = stdgui2.stdapp(test_top_block, "O'Scope Test App") + app.MainLoop() if __name__ == '__main__': - main () + main() # ---------------------------------------------------------------- diff --git a/gr-wxgui/src/python/slider.py b/gr-wxgui/python/slider.py index e8cdcfcaca..7194de47c2 100644 --- a/gr-wxgui/src/python/slider.py +++ b/gr-wxgui/python/slider.py @@ -6,11 +6,10 @@ def slider(parent, min, max, callback): """ Return a wx.Slider object. - @param min: minimum slider value - @type min: float - @param max: maximum slider value - @type max: float - @param callback: function of one arg invoked when slider moves. + Args: + min: minimum slider value (float) + max: maximum slider value (float) + callback: function of one arg invoked when slider moves. @rtype: wx.Slider """ new_id = wx.NewId() diff --git a/gr-wxgui/src/python/stdgui2.py b/gr-wxgui/python/stdgui2.py index 71436d72c4..71436d72c4 100644 --- a/gr-wxgui/src/python/stdgui2.py +++ b/gr-wxgui/python/stdgui2.py diff --git a/gr-wxgui/src/python/termsink.py b/gr-wxgui/python/termsink.py index a0cfd575d6..a0cfd575d6 100644 --- a/gr-wxgui/src/python/termsink.py +++ b/gr-wxgui/python/termsink.py diff --git a/gr-wxgui/src/python/waterfall_window.py b/gr-wxgui/python/waterfall_window.py index cd60104d7a..7d401223c2 100644 --- a/gr-wxgui/src/python/waterfall_window.py +++ b/gr-wxgui/python/waterfall_window.py @@ -61,7 +61,9 @@ class control_panel(wx.Panel): def __init__(self, parent): """ Create a new control panel. - @param parent the wx parent window + + Args: + parent: the wx parent window """ self.parent = parent wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER) @@ -259,7 +261,9 @@ class waterfall_window(wx.Panel, pubsub.pubsub): If complex, reorder the fft samples so the negative bins come first. If real, keep take only the positive bins. Send the data to the plotter. - @param msg the fft array as a character array + + Args: + msg: the fft array as a character array """ if not self[RUNNING_KEY]: return #convert to floating point numbers diff --git a/gr-wxgui/src/python/waterfallsink2.py b/gr-wxgui/python/waterfallsink2.py index 0b876fc3e2..0b876fc3e2 100644 --- a/gr-wxgui/src/python/waterfallsink2.py +++ b/gr-wxgui/python/waterfallsink2.py diff --git a/gr-wxgui/src/python/waterfallsink_gl.py b/gr-wxgui/python/waterfallsink_gl.py index b69c5dda0c..ead97df1e7 100644 --- a/gr-wxgui/src/python/waterfallsink_gl.py +++ b/gr-wxgui/python/waterfallsink_gl.py @@ -1,5 +1,5 @@ # -# Copyright 2008,2009 Free Software Foundation, Inc. +# Copyright 2008,2009,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,7 +24,10 @@ ################################################## import waterfall_window import common -from gnuradio import gr, blks2 +from gnuradio import gr, fft +from gnuradio import analog +from gnuradio import blocks +from gnuradio.fft import logpwrfft from pubsub import pubsub from constants import * @@ -74,7 +77,7 @@ class _waterfall_sink_base(gr.hier_block2, common.wxgui_hb): win=win, ) msgq = gr.msg_queue(2) - sink = gr.message_sink(gr.sizeof_float*fft_size, msgq, True) + sink = blocks.message_sink(gr.sizeof_float*fft_size, msgq, True) #controller self.controller = pubsub() self.controller.subscribe(AVERAGE_KEY, fft.set_average) @@ -117,12 +120,12 @@ class _waterfall_sink_base(gr.hier_block2, common.wxgui_hb): self.win.set_callback(callb) class waterfall_sink_f(_waterfall_sink_base): - _fft_chain = blks2.logpwrfft_f + _fft_chain = logpwrfft.logpwrfft_f _item_size = gr.sizeof_float _real = True class waterfall_sink_c(_waterfall_sink_base): - _fft_chain = blks2.logpwrfft_c + _fft_chain = logpwrfft.logpwrfft_c _item_size = gr.sizeof_gr_complex _real = False @@ -133,9 +136,9 @@ class waterfall_sink_c(_waterfall_sink_base): import wx from gnuradio.wxgui import stdgui2 -class test_top_block (stdgui2.std_top_block): +class test_top_block(stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): - stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) + stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) fft_size = 512 @@ -143,30 +146,30 @@ class test_top_block (stdgui2.std_top_block): input_rate = 20.000e3 # Generate a complex sinusoid - self.src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000) - #src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1000) + self.src1 = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 5.75e3, 1000) + #src1 = analog.sig_source_c(input_rate, analog.GR_CONST_WAVE, 5.75e3, 1000) # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. - self.thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate) + self.thr1 = blocks.throttle(gr.sizeof_gr_complex, input_rate) - sink1 = waterfall_sink_c (panel, title="Complex Data", fft_size=fft_size, - sample_rate=input_rate, baseband_freq=100e3) + sink1 = waterfall_sink_c(panel, title="Complex Data", fft_size=fft_size, + sample_rate=input_rate, baseband_freq=100e3) self.connect(self.src1, self.thr1, sink1) - vbox.Add (sink1.win, 1, wx.EXPAND) + vbox.Add(sink1.win, 1, wx.EXPAND) # generate a real sinusoid - self.src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000) - self.thr2 = gr.throttle(gr.sizeof_float, input_rate) - sink2 = waterfall_sink_f (panel, title="Real Data", fft_size=fft_size, - sample_rate=input_rate, baseband_freq=100e3) + self.src2 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 5.75e3, 1000) + self.thr2 = blocks.throttle(gr.sizeof_float, input_rate) + sink2 = waterfall_sink_f(panel, title="Real Data", fft_size=fft_size, + sample_rate=input_rate, baseband_freq=100e3) self.connect(self.src2, self.thr2, sink2) - vbox.Add (sink2.win, 1, wx.EXPAND) + vbox.Add(sink2.win, 1, wx.EXPAND) def main (): - app = stdgui2.stdapp (test_top_block, "Waterfall Sink Test App") - app.MainLoop () + app = stdgui2.stdapp(test_top_block, "Waterfall Sink Test App") + app.MainLoop() if __name__ == '__main__': main () diff --git a/gr-wxgui/src/python/waterfallsink_nongl.py b/gr-wxgui/python/waterfallsink_nongl.py index 213415c82c..37b8281927 100644 --- a/gr-wxgui/src/python/waterfallsink_nongl.py +++ b/gr-wxgui/python/waterfallsink_nongl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2003,2004,2005,2007,2008 Free Software Foundation, Inc. +# Copyright 2003-2008,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,8 +20,11 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, window +from gnuradio import gr, gru, fft, filter +from gnuradio import blocks +from gnuradio import analog from gnuradio.wxgui import stdgui2 +from gnuradio.filter import window import wx import gnuradio.wxgui.plot as plot import numpy @@ -87,15 +90,15 @@ class waterfall_sink_f(gr.hier_block2, waterfall_sink_base): average=average, avg_alpha=avg_alpha, title=title) self.s2p = gr.serial_to_parallel(gr.sizeof_float, self.fft_size) - self.one_in_n = gr.keep_one_in_n(gr.sizeof_float * self.fft_size, - max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + self.one_in_n = blocks.keep_one_in_n(gr.sizeof_float * self.fft_size, + max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) - self.fft = gr.fft_vfc(self.fft_size, True, mywindow) - self.c2mag = gr.complex_to_mag(self.fft_size) - self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size) - self.log = gr.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) - self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) + self.fft = fft.fft_vfc(self.fft_size, True, mywindow) + self.c2mag = blocks.complex_to_mag(self.fft_size) + self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) + self.log = blocks.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) + self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) self.win = waterfall_window(self, parent, size=size) @@ -118,15 +121,15 @@ class waterfall_sink_c(gr.hier_block2, waterfall_sink_base): average=average, avg_alpha=avg_alpha, title=title) self.s2p = gr.serial_to_parallel(gr.sizeof_gr_complex, self.fft_size) - self.one_in_n = gr.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size, - max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size, + max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) mywindow = window.blackmanharris(self.fft_size) - self.fft = gr.fft_vcc(self.fft_size, True, mywindow) - self.c2mag = gr.complex_to_mag(self.fft_size) - self.avg = gr.single_pole_iir_filter_ff(1.0, self.fft_size) - self.log = gr.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) - self.sink = gr.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) + self.fft = fft.fft_vcc(self.fft_size, True, mywindow) + self.c2mag = blocks.complex_to_mag(self.fft_size) + self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) + self.log = blocks.nlog10_ff(20, self.fft_size, -20*math.log10(self.fft_size)) + self.sink = blocks.message_sink(gr.sizeof_float * self.fft_size, self.msgq, True) self.connect(self, self.s2p, self.one_in_n, self.fft, self.c2mag, self.avg, self.log, self.sink) self.win = waterfall_window(self, parent, size=size) @@ -391,7 +394,7 @@ def next_down(v, seq): class test_top_block (stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): - stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) + stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) fft_size = 512 @@ -399,30 +402,30 @@ class test_top_block (stdgui2.std_top_block): input_rate = 20.000e3 # Generate a complex sinusoid - self.src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000) - #src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1000) + self.src1 = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 5.75e3, 1000) + #src1 = analog.sig_source_c(input_rate, analog.GR_CONST_WAVE, 5.75e3, 1000) # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. - self.thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate) + self.thr1 = blocks.throttle(gr.sizeof_gr_complex, input_rate) - sink1 = waterfall_sink_c (panel, title="Complex Data", fft_size=fft_size, - sample_rate=input_rate, baseband_freq=100e3) + sink1 = waterfall_sink_c(panel, title="Complex Data", fft_size=fft_size, + sample_rate=input_rate, baseband_freq=100e3) self.connect(self.src1, self.thr1, sink1) - vbox.Add (sink1.win, 1, wx.EXPAND) + vbox.Add(sink1.win, 1, wx.EXPAND) # generate a real sinusoid - self.src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000) - self.thr2 = gr.throttle(gr.sizeof_float, input_rate) - sink2 = waterfall_sink_f (panel, title="Real Data", fft_size=fft_size, - sample_rate=input_rate, baseband_freq=100e3) + self.src2 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 5.75e3, 1000) + self.thr2 = blocks.throttle(gr.sizeof_float, input_rate) + sink2 = waterfall_sink_f(panel, title="Real Data", fft_size=fft_size, + sample_rate=input_rate, baseband_freq=100e3) self.connect(self.src2, self.thr2, sink2) - vbox.Add (sink2.win, 1, wx.EXPAND) + vbox.Add(sink2.win, 1, wx.EXPAND) def main (): - app = stdgui2.stdapp (test_top_block, "Waterfall Sink Test App") - app.MainLoop () + app = stdgui2.stdapp(test_top_block, "Waterfall Sink Test App") + app.MainLoop() if __name__ == '__main__': - main () + main() |