diff options
author | Ben Reynwar <ben@reynwar.net> | 2013-04-02 23:04:08 -0700 |
---|---|---|
committer | Ben Reynwar <ben@reynwar.net> | 2013-04-02 23:04:08 -0700 |
commit | c6dbde23b256a41b3d92cb4ad6b63287095d53c7 (patch) | |
tree | 71db12ea2e1667770c22568dcdf5e0857d5f1e59 /gr-wxgui/python | |
parent | 22b70d0889ef3c51e27a31ee18d153093a55cbb8 (diff) | |
parent | 98758cbfa9a2aff714952d19e773bc370dfa2185 (diff) |
Merged next into uninstalled import branch.
Diffstat (limited to 'gr-wxgui/python')
-rw-r--r-- | gr-wxgui/python/wxgui/__init__.py | 2 | ||||
-rw-r--r-- | gr-wxgui/python/wxgui/common.py | 3 | ||||
-rw-r--r-- | gr-wxgui/python/wxgui/constsink_gl.py | 3 | ||||
-rw-r--r-- | gr-wxgui/python/wxgui/fftsink_nongl.py | 64 | ||||
-rw-r--r-- | gr-wxgui/python/wxgui/histosink_gl.py | 3 | ||||
-rw-r--r-- | gr-wxgui/python/wxgui/scope_window.py | 23 | ||||
-rw-r--r-- | gr-wxgui/python/wxgui/scopesink_gl.py | 13 | ||||
-rw-r--r-- | gr-wxgui/python/wxgui/scopesink_nongl.py | 11 | ||||
-rw-r--r-- | gr-wxgui/python/wxgui/waterfallsink_nongl.py | 9 |
9 files changed, 80 insertions, 51 deletions
diff --git a/gr-wxgui/python/wxgui/__init__.py b/gr-wxgui/python/wxgui/__init__.py index 07dbaf1620..dd81647fe9 100644 --- a/gr-wxgui/python/wxgui/__init__.py +++ b/gr-wxgui/python/wxgui/__init__.py @@ -22,3 +22,5 @@ ''' Provides a GUI interface using the Wx backend. ''' + +from wxgui_swig import * diff --git a/gr-wxgui/python/wxgui/common.py b/gr-wxgui/python/wxgui/common.py index 57fc530f88..48a62a28ab 100644 --- a/gr-wxgui/python/wxgui/common.py +++ b/gr-wxgui/python/wxgui/common.py @@ -24,6 +24,7 @@ ################################################## import wx from gnuradio import gr +from gnuradio import blocks RUN_ALWAYS = gr.prefs().get_bool ('wxgui', 'run_always', False) @@ -47,7 +48,7 @@ class wxgui_hb(object): """ try: assert points[0] == self or points[0][0] == self - copy = gr.copy(self._hb.input_signature().sizeof_stream_item(0)) + copy = blocks.copy(self._hb.input_signature().sizeof_stream_item(0)) handler = self._handler_factory(copy.set_enabled) if RUN_ALWAYS == False: handler(False) #initially disable the copy block diff --git a/gr-wxgui/python/wxgui/constsink_gl.py b/gr-wxgui/python/wxgui/constsink_gl.py index 0313e7fea0..dea76ea753 100644 --- a/gr-wxgui/python/wxgui/constsink_gl.py +++ b/gr-wxgui/python/wxgui/constsink_gl.py @@ -26,6 +26,7 @@ import const_window import common from gnuradio import gr from gnuradio import blocks +from gnuradio import analog from pubsub import pubsub from constants import * import sys @@ -100,7 +101,7 @@ class const_sink_c(gr.hier_block2, common.wxgui_hb): # gain_omega, # omega_limit, #) - agc = gr.feedforward_agc_cc(16, 1) + agc = analog.feedforward_agc_cc(16, 1) msgq = gr.msg_queue(2) sink = blocks.message_sink(gr.sizeof_gr_complex*const_size, msgq, True) #controller diff --git a/gr-wxgui/python/wxgui/fftsink_nongl.py b/gr-wxgui/python/wxgui/fftsink_nongl.py index 73bc7f41b0..f567a22256 100644 --- a/gr-wxgui/python/wxgui/fftsink_nongl.py +++ b/gr-wxgui/python/wxgui/fftsink_nongl.py @@ -20,7 +20,8 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, fft, filter +from gnuradio import gr, gru, fft +import gnuradio.filter as grfilter from gnuradio import blocks from gnuradio import analog from gnuradio.wxgui import stdgui2 @@ -40,7 +41,8 @@ class fft_sink_base(object): y_divs=8, ref_level=50, sample_rate=1, fft_size=512, fft_rate=default_fft_rate, - average=False, avg_alpha=None, title='', peak_hold=False,use_persistence=False,persist_alpha=0.2): + average=False, avg_alpha=None, title='', + peak_hold=False, use_persistence=False, persist_alpha=0.2): # initialize common attributes self.baseband_freq = baseband_freq @@ -102,12 +104,15 @@ class fft_sink_base(object): def _set_n(self): self.one_in_n.set_n(max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + def set_callback(self, callb): + return class fft_sink_f(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_f", gr.io_signature(1, 1, gr.sizeof_float), @@ -118,7 +123,8 @@ class fft_sink_f(gr.hier_block2, fft_sink_base): sample_rate=sample_rate, fft_size=fft_size, fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title, - peak_hold=peak_hold,use_persistence=use_persistence,persist_alpha=persist_alpha) + peak_hold=peak_hold, use_persistence=use_persistence, + persist_alpha=persist_alpha) 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, @@ -131,13 +137,13 @@ class fft_sink_f(gr.hier_block2, fft_sink_base): power += tap*tap self.c2mag = blocks.complex_to_mag(self.fft_size) - self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) + self.avg = grfilter.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 = 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 + -20*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 = 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) @@ -164,7 +170,8 @@ class fft_sink_c(gr.hier_block2, fft_sink_base): sample_rate=sample_rate, fft_size=fft_size, fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title, - peak_hold=peak_hold, use_persistence=use_persistence,persist_alpha=persist_alpha) + peak_hold=peak_hold, use_persistence=use_persistence, + persist_alpha=persist_alpha) 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, @@ -177,13 +184,13 @@ class fft_sink_c(gr.hier_block2, fft_sink_base): power += tap*tap self.c2mag = blocks.complex_to_mag(self.fft_size) - self.avg = filter.single_pole_iir_filter_ff(1.0, self.fft_size) + self.avg = grfilter.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 = 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 + -20*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 = 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) @@ -608,8 +615,10 @@ class test_app_block (stdgui2.std_top_block): input_rate = 100*20.48e3 # Generate a complex sinusoid - #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) + #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) + noise1 = analog.noise_source_c(analog.GR_UNIFORM, 1.0/10) + add1 = blocks.add_cc() # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. @@ -620,17 +629,24 @@ class test_app_block (stdgui2.std_top_block): ref_level=0, y_per_div=20, y_divs=10) vbox.Add(sink1.win, 1, wx.EXPAND) - self.connect(src1, thr1, sink1) + self.connect(src1, (add1,0)) + self.connect(noise1, (add1,1)) + self.connect(add1, thr1, sink1) - #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) + #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) + noise2 = analog.noise_source_f(analog.GR_UNIFORM, 1.0/10) + add2 = blocks.add_ff() + + 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) - self.connect(src2, thr2, sink2) + self.connect(src2, (add2,0)) + self.connect(noise2, (add2,1)) + self.connect(add2, thr2, sink2) def main (): app = stdgui2.stdapp(test_app_block, "FFT Sink Test App") diff --git a/gr-wxgui/python/wxgui/histosink_gl.py b/gr-wxgui/python/wxgui/histosink_gl.py index 6fa7539aa7..2126d63191 100644 --- a/gr-wxgui/python/wxgui/histosink_gl.py +++ b/gr-wxgui/python/wxgui/histosink_gl.py @@ -27,6 +27,7 @@ import common from gnuradio import gr from gnuradio import analog from gnuradio import blocks +from gnuradio import wxgui from pubsub import pubsub from constants import * @@ -55,7 +56,7 @@ class histo_sink_f(gr.hier_block2, common.wxgui_hb): ) #blocks msgq = gr.msg_queue(2) - histo = gr.histo_sink_f(msgq) + histo = wxgui.histo_sink_f(msgq) histo.set_num_bins(num_bins) histo.set_frame_size(frame_size) #controller diff --git a/gr-wxgui/python/wxgui/scope_window.py b/gr-wxgui/python/wxgui/scope_window.py index 306e1757f1..357998bf95 100644 --- a/gr-wxgui/python/wxgui/scope_window.py +++ b/gr-wxgui/python/wxgui/scope_window.py @@ -30,6 +30,7 @@ import time import pubsub from constants import * from gnuradio import gr #for gr.prefs, trigger modes +from gnuradio import wxgui import forms ################################################## @@ -38,21 +39,21 @@ import forms DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'scope_rate', 30) PERSIST_ALPHA_MIN_EXP, PERSIST_ALPHA_MAX_EXP = -2, 0 SLIDER_STEPS = 100 -DEFAULT_TRIG_MODE = gr.prefs().get_long('wxgui', 'trig_mode', gr.gr_TRIG_MODE_AUTO) +DEFAULT_TRIG_MODE = gr.prefs().get_long('wxgui', 'trig_mode', wxgui.TRIG_MODE_AUTO) DEFAULT_WIN_SIZE = (600, 300) COUPLING_MODES = ( ('DC', False), ('AC', True), ) TRIGGER_MODES = ( - ('Freerun', gr.gr_TRIG_MODE_FREE), - ('Auto', gr.gr_TRIG_MODE_AUTO), - ('Normal', gr.gr_TRIG_MODE_NORM), - ('Stripchart', gr.gr_TRIG_MODE_STRIPCHART), + ('Freerun', wxgui.TRIG_MODE_FREE), + ('Auto', wxgui.TRIG_MODE_AUTO), + ('Normal', wxgui.TRIG_MODE_NORM), + ('Stripchart', wxgui.TRIG_MODE_STRIPCHART), ) TRIGGER_SLOPES = ( - ('Pos +', gr.gr_TRIG_SLOPE_POS), - ('Neg -', gr.gr_TRIG_SLOPE_NEG), + ('Pos +', wxgui.TRIG_SLOPE_POS), + ('Neg -', wxgui.TRIG_SLOPE_NEG), ) CHANNEL_COLOR_SPECS = ( (0.3, 0.3, 1.0), @@ -281,7 +282,7 @@ class control_panel(wx.Panel): ) def disable_all(trigger_mode): for widget in (trigger_slope_chooser, trigger_channel_chooser, trigger_level_buttons, trigger_level_button): - widget.Disable(trigger_mode == gr.gr_TRIG_MODE_FREE) + widget.Disable(trigger_mode == wxgui.TRIG_MODE_FREE) parent.subscribe(TRIGGER_MODE_KEY, disable_all) disable_all(parent[TRIGGER_MODE_KEY]) ################################################## @@ -480,12 +481,12 @@ class scope_window(wx.Panel, pubsub.pubsub): self[TRIGGER_CHANNEL_KEY] = 0 self[TRIGGER_MODE_KEY] = trig_mode - self[TRIGGER_SLOPE_KEY] = gr.gr_TRIG_SLOPE_POS + self[TRIGGER_SLOPE_KEY] = wxgui.TRIG_SLOPE_POS self[T_FRAC_OFF_KEY] = 0.5 self[USE_PERSISTENCE_KEY] = use_persistence self[PERSIST_ALPHA_KEY] = persist_alpha - if self[TRIGGER_MODE_KEY] == gr.gr_TRIG_MODE_STRIPCHART: + if self[TRIGGER_MODE_KEY] == wxgui.TRIG_MODE_STRIPCHART: self[T_FRAC_OFF_KEY] = 0.0 for i in range(num_inputs): @@ -639,7 +640,7 @@ class scope_window(wx.Panel, pubsub.pubsub): if self[TRIGGER_LEVEL_KEY] < self.get_y_min(): self[TRIGGER_LEVEL_KEY] = self.get_y_min(); return #disable the trigger channel - if not self[TRIGGER_SHOW_KEY] or self[XY_MODE_KEY] or self[TRIGGER_MODE_KEY] == gr.gr_TRIG_MODE_FREE: + if not self[TRIGGER_SHOW_KEY] or self[XY_MODE_KEY] or self[TRIGGER_MODE_KEY] == wxgui.TRIG_MODE_FREE: self.plotter.clear_waveform(channel='Trig') else: #show trigger channel trigger_level = self[TRIGGER_LEVEL_KEY] diff --git a/gr-wxgui/python/wxgui/scopesink_gl.py b/gr-wxgui/python/wxgui/scopesink_gl.py index 21d7169026..b2d5670c77 100644 --- a/gr-wxgui/python/wxgui/scopesink_gl.py +++ b/gr-wxgui/python/wxgui/scopesink_gl.py @@ -26,6 +26,8 @@ import scope_window import common from gnuradio import gr, filter from gnuradio import blocks +from gnuradio import analog +from gnuradio import wxgui from pubsub import pubsub from constants import * import math @@ -101,7 +103,7 @@ class _scope_sink_base(gr.hier_block2, common.wxgui_hb): ) #scope msgq = gr.msg_queue(2) - scope = gr.oscope_sink_f(sample_rate, msgq) + scope = wxgui.oscope_sink_f(sample_rate, msgq) #controller self.controller = pubsub() self.controller.subscribe(SAMPLE_RATE_KEY, scope.set_sample_rate) @@ -207,12 +209,13 @@ class test_top_block (stdgui2.std_top_block): # Generate a complex sinusoid ampl=1.0e3 - self.src0 = analog.sig_source_c(input_rate, gr.GR_SIN_WAVE, + self.src0 = analog.sig_source_c(input_rate, analog.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.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() + self.combine = blocks.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... diff --git a/gr-wxgui/python/wxgui/scopesink_nongl.py b/gr-wxgui/python/wxgui/scopesink_nongl.py index 2c5ff9278a..28a473860f 100644 --- a/gr-wxgui/python/wxgui/scopesink_nongl.py +++ b/gr-wxgui/python/wxgui/scopesink_nongl.py @@ -23,6 +23,7 @@ from gnuradio import gr, gru, eng_notation from gnuradio import analog from gnuradio import blocks +from gnuradio import wxgui from gnuradio.wxgui import stdgui2 import wx import gnuradio.wxgui.plot as plot @@ -43,7 +44,7 @@ class scope_sink_f(gr.hier_block2): gr.io_signature(0,0,0)) msgq = gr.msg_queue(2) # message queue that holds at most 2 messages - self.guts = gr.oscope_sink_f(sample_rate, msgq) + self.guts = wxgui.oscope_sink_f(sample_rate, msgq) for i in range(num_inputs): self.connect((self, i), (self.guts, i)) @@ -64,7 +65,7 @@ class scope_sink_c(gr.hier_block2): gr.io_signature(0,0,0)) msgq = gr.msg_queue(2) # message queue that holds at most 2 messages - self.guts = gr.oscope_sink_f(sample_rate, msgq) + self.guts = wxgui.oscope_sink_f(sample_rate, msgq) for i in range(num_inputs): c2f = blocks.complex_to_float() self.connect((self, i), c2f) @@ -425,11 +426,11 @@ class scope_window(wx.Panel): sink = self.info.scopesink s = evt.GetString() if s == 'Norm': - sink.set_trigger_mode(gr.gr_TRIG_MODE_NORM) + sink.set_trigger_mode(wxgui.TRIG_MODE_NORM) elif s == 'Auto': - sink.set_trigger_mode(gr.gr_TRIG_MODE_AUTO) + sink.set_trigger_mode(wxgui.TRIG_MODE_AUTO) elif s == 'Free': - sink.set_trigger_mode(gr.gr_TRIG_MODE_FREE) + sink.set_trigger_mode(wxgui.TRIG_MODE_FREE) else: assert 0, "Bad trig_mode_choice string" diff --git a/gr-wxgui/python/wxgui/waterfallsink_nongl.py b/gr-wxgui/python/wxgui/waterfallsink_nongl.py index 37b8281927..5cfcd24413 100644 --- a/gr-wxgui/python/wxgui/waterfallsink_nongl.py +++ b/gr-wxgui/python/wxgui/waterfallsink_nongl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2003-2008,2012 Free Software Foundation, Inc. +# Copyright 2003-2005,2007,2008,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -74,6 +74,9 @@ class waterfall_sink_base(object): def _set_n(self): self.one_in_n.set_n(max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + def set_callback(self, callb): + return + class waterfall_sink_f(gr.hier_block2, waterfall_sink_base): def __init__(self, parent, baseband_freq=0, y_per_div=10, ref_level=50, sample_rate=1, fft_size=512, @@ -89,7 +92,7 @@ class waterfall_sink_f(gr.hier_block2, waterfall_sink_base): fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title) - self.s2p = gr.serial_to_parallel(gr.sizeof_float, self.fft_size) + 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))) @@ -120,7 +123,7 @@ class waterfall_sink_c(gr.hier_block2, waterfall_sink_base): fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title) - self.s2p = gr.serial_to_parallel(gr.sizeof_gr_complex, self.fft_size) + 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))) |