summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--cmake/Modules/FindGnuradio.cmake3
-rw-r--r--cmake/Modules/GnuradioConfig.cmake.in1
-rw-r--r--docs/doxygen/Doxyfile.in5
-rw-r--r--docs/doxygen/other/build_guide.dox2
-rw-r--r--docs/doxygen/other/group_defs.dox1
-rw-r--r--docs/sphinx/source/index.rst14
-rw-r--r--docs/sphinx/source/wxgui.rst5
-rw-r--r--docs/sphinx/source/wxgui_blocks.rst7
-rw-r--r--gnuradio-runtime/python/gnuradio/__init__.py1
-rw-r--r--gr-audio/examples/python/CMakeLists.txt1
-rwxr-xr-xgr-audio/examples/python/audio_fft.py138
-rw-r--r--gr-blocks/python/grc_gnuradio/README3
-rw-r--r--gr-uhd/CMakeLists.txt1
-rw-r--r--gr-uhd/apps/CMakeLists.txt47
-rw-r--r--gr-uhd/apps/hf_explorer/README28
-rwxr-xr-xgr-uhd/apps/hf_explorer/hfx.py755
-rw-r--r--gr-uhd/apps/hf_explorer/hfx_help180
-rw-r--r--gr-uhd/apps/hf_radio/README.TXT60
-rw-r--r--gr-uhd/apps/hf_radio/hfir.sci59
-rw-r--r--gr-uhd/apps/hf_radio/input.py78
-rw-r--r--gr-uhd/apps/hf_radio/output.py43
-rwxr-xr-xgr-uhd/apps/hf_radio/radio.py320
-rw-r--r--gr-uhd/apps/hf_radio/radio.xml441
-rw-r--r--gr-uhd/apps/hf_radio/ssb_taps1023
-rw-r--r--gr-uhd/apps/hf_radio/ssbagc.py72
-rw-r--r--gr-uhd/apps/hf_radio/ssbdemod.py118
-rw-r--r--gr-uhd/apps/hf_radio/startup.py1
-rwxr-xr-xgr-uhd/apps/hf_radio/ui.py316
-rwxr-xr-xgr-uhd/apps/uhd_fft_wx348
-rw-r--r--gr-uhd/examples/python/CMakeLists.txt41
-rwxr-xr-xgr-uhd/examples/python/fm_tx4.py211
-rwxr-xr-xgr-uhd/examples/python/fm_tx_2_daughterboards.py216
-rwxr-xr-xgr-uhd/examples/python/freq_hopping.py220
-rwxr-xr-xgr-uhd/examples/python/max_power.py142
-rwxr-xr-xgr-uhd/examples/python/usrp_am_mw_rcv.py316
-rwxr-xr-xgr-uhd/examples/python/usrp_nbfm_ptt.py494
-rwxr-xr-xgr-uhd/examples/python/usrp_nbfm_rcv.py384
-rwxr-xr-xgr-uhd/examples/python/usrp_spectrum_sense.py318
-rwxr-xr-xgr-uhd/examples/python/usrp_tv_rcv.py446
-rwxr-xr-xgr-uhd/examples/python/usrp_tv_rcv_nogui.py215
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv.py290
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv2_nogui.py157
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv_fmdet.py353
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv_nogui.py179
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv_pll.py350
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv_sca.py407
-rwxr-xr-xgr-uhd/examples/python/usrp_wxapt_rcv.py286
-rw-r--r--gr-wxgui/CMakeLists.txt91
-rw-r--r--gr-wxgui/README1
-rw-r--r--gr-wxgui/README.gl29
-rw-r--r--gr-wxgui/gr-wxgui.conf13
-rw-r--r--gr-wxgui/gr-wxgui.pc.in11
-rw-r--r--gr-wxgui/grc/CMakeLists.txt35
-rw-r--r--gr-wxgui/grc/__init__.py22
-rw-r--r--gr-wxgui/grc/notebook.xml70
-rw-r--r--gr-wxgui/grc/panel.py53
-rw-r--r--gr-wxgui/grc/top_block_gui.py87
-rw-r--r--gr-wxgui/grc/variable_check_box.xml85
-rw-r--r--gr-wxgui/grc/variable_chooser.xml123
-rw-r--r--gr-wxgui/grc/variable_slider.xml139
-rw-r--r--gr-wxgui/grc/variable_static_text.xml98
-rw-r--r--gr-wxgui/grc/variable_text_box.xml102
-rw-r--r--gr-wxgui/grc/wxgui_constellationsink2.xml141
-rw-r--r--gr-wxgui/grc/wxgui_fftsink2.xml246
-rw-r--r--gr-wxgui/grc/wxgui_histosink2.xml79
-rw-r--r--gr-wxgui/grc/wxgui_numbersink2.xml194
-rw-r--r--gr-wxgui/grc/wxgui_scopesink2.xml187
-rw-r--r--gr-wxgui/grc/wxgui_termsink.xml57
-rw-r--r--gr-wxgui/grc/wxgui_waterfallsink2.xml203
-rw-r--r--gr-wxgui/include/gnuradio/wxgui/CMakeLists.txt31
-rw-r--r--gr-wxgui/include/gnuradio/wxgui/api.h33
-rw-r--r--gr-wxgui/include/gnuradio/wxgui/histo_sink_f.h55
-rw-r--r--gr-wxgui/include/gnuradio/wxgui/oscope_guts.h131
-rw-r--r--gr-wxgui/include/gnuradio/wxgui/oscope_sink_f.h53
-rw-r--r--gr-wxgui/include/gnuradio/wxgui/oscope_sink_x.h91
-rw-r--r--gr-wxgui/include/gnuradio/wxgui/trigger_mode.h44
-rw-r--r--gr-wxgui/lib/CMakeLists.txt98
-rw-r--r--gr-wxgui/lib/gnuradio-wxgui.rc.in54
-rw-r--r--gr-wxgui/lib/histo_sink_f_impl.cc186
-rw-r--r--gr-wxgui/lib/histo_sink_f_impl.h63
-rw-r--r--gr-wxgui/lib/oscope_guts.cc439
-rw-r--r--gr-wxgui/lib/oscope_sink_f_impl.cc83
-rw-r--r--gr-wxgui/lib/oscope_sink_f_impl.h51
-rw-r--r--gr-wxgui/lib/oscope_sink_x.cc161
-rw-r--r--gr-wxgui/python/wxgui/CMakeLists.txt85
-rw-r--r--gr-wxgui/python/wxgui/__init__.py32
-rw-r--r--gr-wxgui/python/wxgui/common.py296
-rw-r--r--gr-wxgui/python/wxgui/const_window.py211
-rw-r--r--gr-wxgui/python/wxgui/constants.py76
-rw-r--r--gr-wxgui/python/wxgui/constsink_gl.py142
-rw-r--r--gr-wxgui/python/wxgui/fft_window.py412
-rw-r--r--gr-wxgui/python/wxgui/fftsink2.py41
-rw-r--r--gr-wxgui/python/wxgui/fftsink_gl.py204
-rw-r--r--gr-wxgui/python/wxgui/fftsink_nongl.py656
-rw-r--r--gr-wxgui/python/wxgui/form.py391
-rw-r--r--gr-wxgui/python/wxgui/forms/__init__.py102
-rw-r--r--gr-wxgui/python/wxgui/forms/converters.py154
-rw-r--r--gr-wxgui/python/wxgui/forms/forms.py675
-rw-r--r--gr-wxgui/python/wxgui/gui.py135
-rw-r--r--gr-wxgui/python/wxgui/histo_window.py168
-rw-r--r--gr-wxgui/python/wxgui/histosink_gl.py113
-rw-r--r--gr-wxgui/python/wxgui/number_window.py219
-rw-r--r--gr-wxgui/python/wxgui/numbersink2.py173
-rw-r--r--gr-wxgui/python/wxgui/plot.py1834
-rw-r--r--gr-wxgui/python/wxgui/plotter/__init__.py24
-rw-r--r--gr-wxgui/python/wxgui/plotter/bar_plotter.py150
-rw-r--r--gr-wxgui/python/wxgui/plotter/channel_plotter.py249
-rw-r--r--gr-wxgui/python/wxgui/plotter/common.py149
-rw-r--r--gr-wxgui/python/wxgui/plotter/gltext.py507
-rw-r--r--gr-wxgui/python/wxgui/plotter/grid_plotter_base.py458
-rw-r--r--gr-wxgui/python/wxgui/plotter/plotter_base.py220
-rw-r--r--gr-wxgui/python/wxgui/plotter/waterfall_plotter.py294
-rw-r--r--gr-wxgui/python/wxgui/powermate.py448
-rw-r--r--gr-wxgui/python/wxgui/pubsub.py153
-rw-r--r--gr-wxgui/python/wxgui/scope_window.py691
-rw-r--r--gr-wxgui/python/wxgui/scopesink2.py41
-rw-r--r--gr-wxgui/python/wxgui/scopesink_gl.py239
-rw-r--r--gr-wxgui/python/wxgui/scopesink_nongl.py654
-rw-r--r--gr-wxgui/python/wxgui/slider.py48
-rw-r--r--gr-wxgui/python/wxgui/stdgui2.py107
-rw-r--r--gr-wxgui/python/wxgui/termsink.py77
-rw-r--r--gr-wxgui/python/wxgui/waterfall_window.py328
-rw-r--r--gr-wxgui/python/wxgui/waterfallsink2.py41
-rw-r--r--gr-wxgui/python/wxgui/waterfallsink_gl.py176
-rw-r--r--gr-wxgui/python/wxgui/waterfallsink_nongl.py434
-rw-r--r--gr-wxgui/swig/CMakeLists.txt55
-rw-r--r--gr-wxgui/swig/wxgui_swig.i43
128 files changed, 2 insertions, 24439 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8d9e4de33d..8880155b71 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -410,7 +410,6 @@ add_subdirectory(gr-utils)
add_subdirectory(gr-video-sdl)
add_subdirectory(gr-vocoder)
add_subdirectory(gr-wavelet)
-add_subdirectory(gr-wxgui)
add_subdirectory(gr-zeromq)
add_subdirectory(grc)
diff --git a/cmake/Modules/FindGnuradio.cmake b/cmake/Modules/FindGnuradio.cmake
index 72b7313737..3e899f5d26 100644
--- a/cmake/Modules/FindGnuradio.cmake
+++ b/cmake/Modules/FindGnuradio.cmake
@@ -1,4 +1,4 @@
-# Copyright 2013 Free Software Foundation, Inc.
+# Copyright 2013,2016 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -115,5 +115,4 @@ GR_MODULE(TRELLIS gnuradio-trellis gnuradio/trellis/api.h gnuradio-trellis)
GR_MODULE(UHD gnuradio-uhd gnuradio/uhd/api.h gnuradio-uhd)
GR_MODULE(VOCODER gnuradio-vocoder gnuradio/vocoder/api.h gnuradio-vocoder)
GR_MODULE(WAVELET gnuradio-wavelet gnuradio/wavelet/api.h gnuradio-wavelet)
-GR_MODULE(WXGUI gnuradio-wxgui gnuradio/wxgui/api.h gnuradio-wxgui)
GR_MODULE(PMT gnuradio-pmt pmt/pmt.h gnuradio-pmt)
diff --git a/cmake/Modules/GnuradioConfig.cmake.in b/cmake/Modules/GnuradioConfig.cmake.in
index d9ca22dd7a..b323a0d911 100644
--- a/cmake/Modules/GnuradioConfig.cmake.in
+++ b/cmake/Modules/GnuradioConfig.cmake.in
@@ -135,7 +135,6 @@ GR_MODULE(TRELLIS gnuradio-trellis gnuradio/trellis/api.h gnuradio-trellis)
GR_MODULE(UHD gnuradio-uhd gnuradio/uhd/api.h gnuradio-uhd)
GR_MODULE(VOCODER gnuradio-vocoder gnuradio/vocoder/api.h gnuradio-vocoder)
GR_MODULE(WAVELET gnuradio-wavelet gnuradio/wavelet/api.h gnuradio-wavelet)
-GR_MODULE(WXGUI gnuradio-wxgui gnuradio/wxgui/api.h gnuradio-wxgui)
GR_MODULE(ZEROMQ gnuradio-zeromq gnuradio/zeromq/api.h gnuradio-zeromq)
GR_MODULE(PMT gnuradio-runtime pmt/pmt.h gnuradio-pmt)
GR_MODULE(VOLK volk volk/volk.h volk)
diff --git a/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in
index c5795dfa1f..731c0dfed8 100644
--- a/docs/doxygen/Doxyfile.in
+++ b/docs/doxygen/Doxyfile.in
@@ -181,8 +181,6 @@ STRIP_FROM_INC_PATH = @CMAKE_SOURCE_DIR@/gnuradio-runtime/include \
@CMAKE_BINARY_DIR@/gr-vocoder/include \
@CMAKE_SOURCE_DIR@/gr-wavelet/include \
@CMAKE_BINARY_DIR@/gr-wavelet/include \
- @CMAKE_SOURCE_DIR@/gr-wxgui/include \
- @CMAKE_BINARY_DIR@/gr-wxgui/include \
@CMAKE_SOURCE_DIR@/gr-zeromq/include \
@CMAKE_BINARY_DIR@/gr-zeromq/include \
@CMAKE_SOURCE_DIR@/volk/include \
@@ -754,7 +752,6 @@ EXCLUDE = @abs_top_srcdir@/volk \
@abs_top_builddir@/gr-trellis/doc \
@abs_top_builddir@/gr-trellis/swig/trellis_swig.py \
@abs_top_builddir@/gr-video-sdl/swig/video_sdl_swig.py \
- @abs_top_builddir@/gr-wxgui/python \
@abs_top_builddir@/grc \
@abs_top_builddir@/_CPack_Packages \
@abs_top_srcdir@/cmake \
@@ -813,8 +810,6 @@ EXCLUDE = @abs_top_srcdir@/volk \
@abs_top_builddir@/gr-vocoder/lib \
@abs_top_srcdir@/gr-wavelet/lib \
@abs_top_builddir@/gr-wavelet/lib \
- @abs_top_srcdir@/gr-wxgui/lib \
- @abs_top_builddir@/gr-wxgui/lib \
@abs_top_srcdir@/gr-zeromq/lib \
@abs_top_builddir@/gr-zeromq/lib \
@abs_top_srcdir@/volk/cmake/msvc \
diff --git a/docs/doxygen/other/build_guide.dox b/docs/doxygen/other/build_guide.dox
index 87e5a456f3..b7218a2dbe 100644
--- a/docs/doxygen/other/build_guide.dox
+++ b/docs/doxygen/other/build_guide.dox
@@ -52,8 +52,6 @@ first. Most recent systems have these packages available.
\li qwt (>= 5.2.0) http://sourceforge.net/projects/qwt/
\li pyqt (>= 4.10.0) http://www.riverbankcomputing.co.uk/software/pyqt/download
-\subsection dep_gr_wxgui gr-wxgui: The WX-based Graphical User Interface
-\li wxpython (>= 2.8) http://www.wxpython.org/
\li python-lxml (>= 1.3.6) http://lxml.de/
\subsection dep_gr_audio gr-audio: Audio Subsystems (system/OS dependent)
diff --git a/docs/doxygen/other/group_defs.dox b/docs/doxygen/other/group_defs.dox
index 1cb3ff9f97..a534473ee4 100644
--- a/docs/doxygen/other/group_defs.dox
+++ b/docs/doxygen/other/group_defs.dox
@@ -48,7 +48,6 @@
/*! \defgroup uhd_blk UHD Interface */
/*! \defgroup waveform_generators_blk Waveform Generators */
/*! \defgroup wavelet_blk Wavelet Transforms */
-/*! \defgroup wxgui_blk WX Graphical Interfaces */
/*!
* \defgroup base_blk Base classes for GR Blocks
diff --git a/docs/sphinx/source/index.rst b/docs/sphinx/source/index.rst
index 5c14d22cce..137c17a6ba 100644
--- a/docs/sphinx/source/index.rst
+++ b/docs/sphinx/source/index.rst
@@ -25,7 +25,6 @@ gnuradio
blocks_video_sdl <video_sdl_blocks>
blocks_vocoder <vocoder_blocks>
blocks_wavelet <wavelet_blocks>
- blocks_wxgui <wxgui_blocks>
blocks_zeromq <zeromq_blocks>
analog <analog>
channels <channels>
@@ -37,7 +36,6 @@ gnuradio
trellis <trellis>
uhd <uhd>
vocoder <vocoder>
- wxgui <wxgui>
.. automodule:: gnuradio
.. automodule:: pmt
@@ -656,8 +654,6 @@ Instrumentation Blocks
gnuradio.qtgui.vector_sink_f
gnuradio.qtgui.waterfall_sink_c
gnuradio.qtgui.waterfall_sink_f
- gnuradio.wxgui.histo_sink_f
- gnuradio.wxgui.oscope_sink_f
@@ -1464,13 +1460,3 @@ Helper Classes: Vocoder
gnuradio.vocoder.codec2
gnuradio.vocoder.cvsd_encode_fb
gnuradio.vocoder.cvsd_decode_bf
-
-
-Helper Classes: WXGUI
----------------------
-
-.. autosummary::
- :nosignatures:
-
- gnuradio.wxgui.oscope_sink_x
- gnuradio.wxgui.histo_sink_f
diff --git a/docs/sphinx/source/wxgui.rst b/docs/sphinx/source/wxgui.rst
deleted file mode 100644
index dcaa4a8e4a..0000000000
--- a/docs/sphinx/source/wxgui.rst
+++ /dev/null
@@ -1,5 +0,0 @@
-gnuradio.wxgui
-==============
-
-.. autoclass:: gnuradio.wxgui.oscope_sink_x
-.. autoclass:: gnuradio.wxgui.histo_sink_f
diff --git a/docs/sphinx/source/wxgui_blocks.rst b/docs/sphinx/source/wxgui_blocks.rst
deleted file mode 100644
index ccccd854da..0000000000
--- a/docs/sphinx/source/wxgui_blocks.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-gnuradio.wxgui
-==============
-
-.. automodule:: gnuradio.wxgui
-
-.. autoblock:: gnuradio.wxgui.histo_sink_f
-.. autoblock:: gnuradio.wxgui.oscope_sink_f
diff --git a/gnuradio-runtime/python/gnuradio/__init__.py b/gnuradio-runtime/python/gnuradio/__init__.py
index 43274dbd1c..062450cb5f 100644
--- a/gnuradio-runtime/python/gnuradio/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/__init__.py
@@ -37,7 +37,6 @@ if path.endswith(path_ending):
__path__.append(os.path.join(build_path, 'gr-wavelet', 'python'))
__path__.append(os.path.join(build_path, 'gr-audio', 'python'))
__path__.append(os.path.join(build_path, 'gr-qtgui', 'python'))
- __path__.append(os.path.join(build_path, 'gr-wxgui', 'python'))
__path__.append(os.path.join(build_path, 'gr-video-sdl', 'python'))
__path__.append(os.path.join(build_path, 'gr-vocoder', 'python'))
__path__.append(os.path.join(build_path, 'gr-comedi', 'python'))
diff --git a/gr-audio/examples/python/CMakeLists.txt b/gr-audio/examples/python/CMakeLists.txt
index 01a03fefcd..6e90b0ef5a 100644
--- a/gr-audio/examples/python/CMakeLists.txt
+++ b/gr-audio/examples/python/CMakeLists.txt
@@ -21,7 +21,6 @@ include(GrPython)
GR_PYTHON_INSTALL(PROGRAMS
audio_copy.py
- audio_fft.py
audio_play.py
audio_to_file.py
dial_tone.py
diff --git a/gr-audio/examples/python/audio_fft.py b/gr-audio/examples/python/audio_fft.py
deleted file mode 100755
index 519963da54..0000000000
--- a/gr-audio/examples/python/audio_fft.py
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2004,2005,2007 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, gru, audio
-from gnuradio import eng_notation
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, scopesink2, form, slider
-from optparse import OptionParser
-import wx
-import sys
-
-class app_top_block(stdgui2.std_top_block):
- def __init__(self, frame, panel, vbox, argv):
- stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
-
- self.frame = frame
- self.panel = panel
-
- parser = OptionParser(option_class=eng_option)
- parser.add_option("-W", "--waterfall", action="store_true", default=False,
- help="Enable waterfall display")
- parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
- help="Enable oscilloscope display")
- parser.add_option("-I", "--audio-input", type="string", default="",
- help="pcm input device name. E.g., hw:0,0 or /dev/dsp")
- parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
- help="set sample rate to RATE (48000)")
-
- (options, args) = parser.parse_args()
- sample_rate = int(options.sample_rate)
-
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- self.show_debug_info = True
-
- # build the graph
- if options.waterfall:
- self.scope = \
- waterfallsink2.waterfall_sink_f (panel, fft_size=1024, sample_rate=sample_rate)
- elif options.oscilloscope:
- self.scope = scopesink2.scope_sink_f(panel, sample_rate=sample_rate)
- else:
- self.scope = fftsink2.fft_sink_f (panel, fft_size=1024, sample_rate=sample_rate, fft_rate=30,
- ref_scale=1.0, ref_level=0, y_divs=12)
-
- self.src = audio.source (sample_rate, options.audio_input)
-
- self.connect(self.src, self.scope)
-
- self._build_gui(vbox)
-
- # set initial values
-
- def _set_status_msg(self, msg):
- self.frame.GetStatusBar().SetStatusText(msg, 0)
-
- def _build_gui(self, vbox):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
- vbox.Add(self.scope.win, 10, wx.EXPAND)
-
- #self._build_subpanel(vbox)
-
- def _build_subpanel(self, vbox_arg):
- # build a secondary information panel (sometimes hidden)
-
- # FIXME figure out how to have this be a subpanel that is always
- # created, but has its visibility controlled by foo.Show(True/False)
-
- def _form_set_decim(kv):
- return self.set_decim(kv['decim'])
-
- if not(self.show_debug_info):
- return
-
- panel = self.panel
- vbox = vbox_arg
- myform = self.myform
-
- #panel = wx.Panel(self.panel, -1)
- #vbox = wx.BoxSizer(wx.VERTICAL)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['decim'] = form.int_field(
- parent=panel, sizer=hbox, label="Decim",
- callback=myform.check_input_and_call(_form_set_decim, self._set_status_msg))
-
- hbox.Add((5,0), 1)
- myform['fs@usb'] = form.static_float_field(
- parent=panel, sizer=hbox, label="Fs@USB")
-
- hbox.Add((5,0), 1)
- myform['dbname'] = form.static_text_field(
- parent=panel, sizer=hbox)
-
- hbox.Add((5,0), 1)
- myform['baseband'] = form.static_float_field(
- parent=panel, sizer=hbox, label="Analog BB")
-
- hbox.Add((5,0), 1)
- myform['ddc'] = form.static_float_field(
- parent=panel, sizer=hbox, label="DDC")
-
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
-
-def main ():
- app = stdgui2.stdapp(app_top_block, "Audio FFT", nstatus=1)
- app.MainLoop()
-
-if __name__ == '__main__':
- main ()
diff --git a/gr-blocks/python/grc_gnuradio/README b/gr-blocks/python/grc_gnuradio/README
index 897eed65ca..e27b01af54 100644
--- a/gr-blocks/python/grc_gnuradio/README
+++ b/gr-blocks/python/grc_gnuradio/README
@@ -6,6 +6,3 @@ These will be phased-out as new functionaility is merged into gnuradio.
The blk2s module wraps many blocks in blks2 and gives them streaming outputs.
Will be phased-out by new message passing implementations.
Other blks2 blocks will hopefully make their way into blks2impl.
-
-The wxgui module contains a top_block + wxgui frame.
-Will be phased-out by gui.py in wxgui and a new top block template.
diff --git a/gr-uhd/CMakeLists.txt b/gr-uhd/CMakeLists.txt
index 6310822cf4..cb4fda82af 100644
--- a/gr-uhd/CMakeLists.txt
+++ b/gr-uhd/CMakeLists.txt
@@ -61,7 +61,6 @@ if(ENABLE_PYTHON)
add_subdirectory(python/uhd)
add_subdirectory(grc)
add_subdirectory(apps)
- add_subdirectory(examples/python)
add_subdirectory(examples/grc)
endif(ENABLE_PYTHON)
diff --git a/gr-uhd/apps/CMakeLists.txt b/gr-uhd/apps/CMakeLists.txt
index ce94a43cff..0d49b4ca9e 100644
--- a/gr-uhd/apps/CMakeLists.txt
+++ b/gr-uhd/apps/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2016 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -38,48 +38,3 @@ GR_PYTHON_INSTALL(
uhd_rx_nogui
DESTINATION ${GR_RUNTIME_DIR}
)
-
-########################################################################
-# Install hf radio apps
-########################################################################
-install(
- FILES
- hf_radio/hfir.sci
- hf_radio/radio.xml
- hf_radio/README.TXT
- hf_radio/ssb_taps
- DESTINATION ${GR_PKG_DATA_DIR}/examples/hf_radio
-)
-
-GR_PYTHON_INSTALL(
- PROGRAMS
- hf_radio/input.py
- hf_radio/output.py
- hf_radio/ssbagc.py
- hf_radio/ssbdemod.py
- hf_radio/startup.py
- DESTINATION ${GR_PKG_DATA_DIR}/examples/hf_radio
-)
-
-GR_PYTHON_INSTALL(
- PROGRAMS
- hf_radio/radio.py
- hf_radio/ui.py
- DESTINATION ${GR_PKG_DATA_DIR}/examples/hf_radio
-)
-
-########################################################################
-# Install hf explorer
-########################################################################
-install(
- FILES
- hf_explorer/README
- hf_explorer/hfx_help
- DESTINATION ${GR_PKG_DATA_DIR}/examples/hf_explorer
-)
-
-GR_PYTHON_INSTALL(
- PROGRAMS
- hf_explorer/hfx.py
- DESTINATION ${GR_PKG_DATA_DIR}/examples/hf_explorer
-)
diff --git a/gr-uhd/apps/hf_explorer/README b/gr-uhd/apps/hf_explorer/README
deleted file mode 100644
index 39b6b66cd0..0000000000
--- a/gr-uhd/apps/hf_explorer/README
+++ /dev/null
@@ -1,28 +0,0 @@
-hfx.py is meant to be a full-featured Long Wave / Medium Wave
-and Short Wave (250kHz to 30Mhz) AM and Single Sideband receiver.
-It uses the USRP with a Basic RX board, and will need an
-antenna and some preamps, about 30db gain will work. See the
-'Help' menu or hfx_help for more info.
-
-----------------------------------------------------------
-
-Powermate knob supported but not required, tooltip frequency display,
-single click tuning, AGC, record to disk, play from disk and record
-audio. Ability to tailor the audio passband with two sliders over the
-spectrum display. The sliders almost align with the actual
-frequency. Preset filter settings for LSB (-3000 to 0kHz), USB (0 to
-+3000kHz), CW (-400 to -800Hz) and AM (-5kHz from carrier to +5kHz).
-
-AM now switches in a synchronous PLL detector with the carriers at
-7.5kHz. Everything gets shifted up 7.5kHz in AM, center frequency,
-tooltips, etc. The target AM carrier needs to be closely tuned in, it
-will have a hollow sound until it is locked. The filter in AM is
-preset to 2500/12500 (7.5kHz +/- 5kHz) and is handy for removing
-adjacent channel interference.
-
-There is code for Web based control of frequency and volume - so
-I can tune the radio with a handheld device. Disabled by default - it
-takes a web server, some directories and scripts to use.
-
-
-
diff --git a/gr-uhd/apps/hf_explorer/hfx.py b/gr-uhd/apps/hf_explorer/hfx.py
deleted file mode 100755
index 043ab2ca92..0000000000
--- a/gr-uhd/apps/hf_explorer/hfx.py
+++ /dev/null
@@ -1,755 +0,0 @@
-#!/usr/bin/python
-#!/usr/bin/env python
-# generated by wxGlade 0.4 on Tue Mar 14 10:16:06 2006
-#
-# Copyright 2006,2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-#-----------------------------------------------------------------
-#
-# +-->(fft)
-# |
-# (src)->(xlate)--+->(audio filter)--+-->(sel_am)-+--------------+
-# | | |
-# | (pll) |
-# | | |
-# | (pll_carrier_scale) |
-# | | |
-# | (pll_carrier_filter) |
-# | | |
-# | +--(fft2) |
-# | | |
-# | +--(c2f3)--+ |
-# | | | |
-# | (phaser1) (phaser2) |
-# | | | |
-# | +--(f2c)---+ |
-# | | V
-# V +---------->(am_det)
-# (c2f) |
-# | (c2f2)
-# | |
-# +-->(sel_sb)------------>(combine)
-# |
-# V
-# +--------------------------(scale)
-# | |
-# | |
-# | +++
-# V | |
-# (agc)<--(offset)<--(intr)<---(sqr1)
-# |
-# V
-# (dst)
-#
-#----------------------------------------------------------------------
-#
-# 3.0.1 - updated to support uhd correctly, old code for usrp had display negative, removed antenna tuner controls
-#
-
-# Web server control disabled by default. Do not enable
-# until directory structure and scripts are in place.
-WEB_CONTROL = False
-
-import os, wx, sys, math
-import wx.lib.evtmgr as em
-from gnuradio.wxgui import powermate, fftsink2
-from gnuradio import gr, audio, eng_notation
-from gnuradio import analog
-from gnuradio import filter
-from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from gnuradio import uhd
-from optparse import OptionParser
-
-n2s = eng_notation.num_to_str
-
-ID_BUTTON_1 = wx.NewId() # LSB button
-ID_BUTTON_2 = wx.NewId() # USB
-ID_BUTTON_3 = wx.NewId() # AM
-ID_BUTTON_4 = wx.NewId() # CW
-ID_BUTTON_5 = wx.NewId() # Powermate controls: Upper audio freq cutoff
-ID_BUTTON_6 = wx.NewId() # " Lower audio freq cutoff
-ID_BUTTON_7 = wx.NewId() # " Frequency
-ID_BUTTON_8 = wx.NewId() # " Volume
-ID_BUTTON_9 = wx.NewId() # " Time
-ID_BUTTON_10 = wx.NewId() # Time Seek Forwards
-ID_BUTTON_11 = wx.NewId() # Time Seek Backwards
-ID_TEXT_1 = wx.NewId() # Band Center, USRP ddc Freq
-ID_SPIN_1 = wx.NewId() # Frequency display and control
-ID_SLIDER_1 = wx.NewId() # Upper audio freq cutoff
-ID_SLIDER_2 = wx.NewId() # Lower audio freq cutoff
-ID_SLIDER_3 = wx.NewId() # Frequency
-ID_SLIDER_4 = wx.NewId() # Volume
-ID_SLIDER_5 = wx.NewId() # Programmable Gain Amp, PGA, RF gain
-ID_SLIDER_7 = wx.NewId() # AT control voltage output
-ID_EXIT = wx.NewId() # Menu Exit
-
-
-class MyFrame(wx.Frame):
- def __init__(self, *args, **kwds):
- # begin wxGlade: MyFrame.__init__
- kwds["style"] = wx.DEFAULT_FRAME_STYLE
- wx.Frame.__init__(self, *args, **kwds)
-
- # Menu Bar
- self.frame_1_menubar = wx.MenuBar()
- self.SetMenuBar(self.frame_1_menubar)
- wxglade_tmp_menu = wx.Menu()
- self.Exit = wx.MenuItem(wxglade_tmp_menu, ID_EXIT, "Exit",
- "Exit", wx.ITEM_NORMAL)
- wxglade_tmp_menu.AppendItem(self.Exit)
- self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
- # Menu Bar end
- self.panel_1 = wx.Panel(self, -1)
- self.button_1 = wx.Button(self, ID_BUTTON_1, "LSB")
- self.button_2 = wx.Button(self, ID_BUTTON_2, "USB")
- self.button_3 = wx.Button(self, ID_BUTTON_3, "AM")
- self.button_4 = wx.Button(self, ID_BUTTON_4, "CW")
- self.button_5 = wx.ToggleButton(self, ID_BUTTON_5, "Upper")
- self.slider_fcutoff_hi = wx.Slider(self, ID_SLIDER_1, 0, -15798, 15799,
- style=wx.SL_HORIZONTAL|wx.SL_LABELS)
- self.button_6 = wx.ToggleButton(self, ID_BUTTON_6, "Lower")
- self.slider_fcutoff_lo = wx.Slider(self, ID_SLIDER_2, 0, -15799, 15798,
- style=wx.SL_HORIZONTAL|wx.SL_LABELS)
- self.panel_5 = wx.Panel(self, -1)
- self.label_1 = wx.StaticText(self, -1, " Band\nCenter")
- self.text_ctrl_1 = wx.TextCtrl(self, ID_TEXT_1, "")
- self.panel_6 = wx.Panel(self, -1)
- self.panel_7 = wx.Panel(self, -1)
- self.panel_2 = wx.Panel(self, -1)
- self.button_7 = wx.ToggleButton(self, ID_BUTTON_7, "Freq")
- self.slider_3 = wx.Slider(self, ID_SLIDER_3, 3000, 0, 6000)
- self.spin_ctrl_1 = wx.SpinCtrl(self, ID_SPIN_1, "", min=0, max=100)
- self.button_8 = wx.ToggleButton(self, ID_BUTTON_8, "Vol")
- self.slider_4 = wx.Slider(self, ID_SLIDER_4, 0, 0, 500)
- self.slider_5 = wx.Slider(self, ID_SLIDER_5, 0, 0, 20)
- self.button_9 = wx.ToggleButton(self, ID_BUTTON_9, "Time")
- self.button_11 = wx.Button(self, ID_BUTTON_11, "Rew")
- self.button_10 = wx.Button(self, ID_BUTTON_10, "Fwd")
- self.panel_3 = wx.Panel(self, -1)
- self.label_2 = wx.StaticText(self, -1, "PGA ")
- self.panel_4 = wx.Panel(self, -1)
- self.panel_8 = wx.Panel(self, -1)
- self.panel_9 = wx.Panel(self, -1)
- self.panel_10 = wx.Panel(self, -1)
- self.panel_11 = wx.Panel(self, -1)
- self.panel_12 = wx.Panel(self, -1)
-
- self.__set_properties()
- self.__do_layout()
- # end wxGlade
-
- parser = OptionParser (option_class=eng_option)
- parser.add_option("", "--args", type="string", default="addr=''",
- help="Arguments for UHD device, [default=%default]")
- parser.add_option("", "--spec", type="string", default="A:0",
- help="UHD device subdev spec, [default=%default]")
- parser.add_option ("-c", "--ddc-freq", type="eng_float", default=3.9e6,
- help="set Rx DDC frequency to FREQ", metavar="FREQ")
- parser.add_option ("-s", "--samp-rate", type="eng_float", default=256000,
- help="set sample rate (bandwidth) [default=%default]")
- parser.add_option ("-a", "--audio_file", default="",
- help="audio output file", metavar="FILE")
- parser.add_option ("-r", "--radio_file", default="",
- help="radio output file", metavar="FILE")
- parser.add_option ("-i", "--input_file", default="",
- help="radio input file", metavar="FILE")
- parser.add_option ("-O", "--audio-output", type="string", default="",
- help="audio output device name. E.g., hw:0,0, /dev/dsp, or pulse")
- parser.add_option ("", "--audio-rate", type="int", default=32000,
- help="audio output sample rate [default=%default]")
-
- (options, args) = parser.parse_args ()
-
- self.usrp_center = options.ddc_freq
- self.input_rate = input_rate = options.samp_rate
- self.slider_range = input_rate * 0.9375
- self.f_lo = self.usrp_center - (self.slider_range/2)
- self.f_hi = self.usrp_center + (self.slider_range/2)
- self.af_sample_rate = options.audio_rate
- self.tb = gr.top_block()
-
- # radio variables, initial conditions
- self.frequency = self.usrp_center
- # these map the frequency slider (0-6000) to the actual range
- self.f_slider_offset = self.f_lo
- self.f_slider_scale = 10000/250
- self.spin_ctrl_1.SetRange(self.f_lo,self.f_hi)
- self.text_ctrl_1.SetValue(str(int(self.usrp_center)))
- self.slider_5.SetValue(0)
- self.AM_mode = False
-
- self.slider_3.SetValue((self.frequency-self.f_slider_offset)/self.f_slider_scale)
- self.spin_ctrl_1.SetValue(int(self.frequency))
-
- POWERMATE = True
- try:
- self.pm = powermate.powermate(self)
- except:
- sys.stderr.write("Unable to find PowerMate or Contour Shuttle\n")
- POWERMATE = False
-
- if POWERMATE:
- powermate.EVT_POWERMATE_ROTATE(self, self.on_rotate)
- powermate.EVT_POWERMATE_BUTTON(self, self.on_pmButton)
- self.active_button = 7
-
- # command line options
- if options.audio_file == "": SAVE_AUDIO_TO_FILE = False
- else: SAVE_AUDIO_TO_FILE = True
- if options.radio_file == "": SAVE_RADIO_TO_FILE = False
- else: SAVE_RADIO_TO_FILE = True
- if options.input_file == "": self.PLAY_FROM_USRP = True
- else: self.PLAY_FROM_USRP = False
-
- if self.PLAY_FROM_USRP:
- self.src = uhd.usrp_source(options.args, stream_args=uhd.stream_args('fc32'))
- self.src.set_samp_rate(input_rate)
- self.src.set_subdev_spec(options.spec)
- self.input_rate = input_rate = self.src.get_samp_rate()
-
- self.src.set_center_freq(self.usrp_center, 0)
- self.tune_offset = 0
-
- fir_decim = long(self.input_rate / self.af_sample_rate)
- rrate = self.af_sample_rate / (self.input_rate / float(fir_decim))
-
-
- print "Actual Input Rate: ", self.input_rate
- print "FIR DECIM: ", fir_decim
- print "Remaining resampling: ", rrate
- print "Sampling Rate at Audio Sink: ", (self.input_rate / fir_decim) * rrate
- print "Request Rate at Audio Sink: ", self.af_sample_rate
-
- else:
- self.src = blocks.file_source (gr.sizeof_short,options.input_file)
- self.tune_offset = 2200 # 2200 works for 3.5-4Mhz band
-
- # convert rf data in interleaved short int form to complex
- s2ss = blocks.stream_to_streams(gr.sizeof_short,2)
- s2f1 = blocks.short_to_float()
- s2f2 = blocks.short_to_float()
- src_f2c = blocks.float_to_complex()
- self.tb.connect(self.src,s2ss)
- self.tb.connect((s2ss,0),s2f1)
- self.tb.connect((s2ss,1),s2f2)
- self.tb.connect(s2f1,(src_f2c,0))
- self.tb.connect(s2f2,(src_f2c,1))
-
- fir_decim = long(self.input_rate / self.af_sample_rate)
- rrate = self.af_sample_rate / (self.input_rate / float(fir_decim))
-
- print "FIR DECIM: ", fir_decim
- print "Remaining resampling: ", rrate
- print "Sampling Rate at Audio Sink: ", (self.input_rate / fir_decim) * rrate
- print "Request Rate at Audio Sink: ", self.af_sample_rate
-
- # save radio data to a file
- if SAVE_RADIO_TO_FILE:
- radio_file = blocks.file_sink(gr.sizeof_short, options.radio_file)
- self.tb.connect (self.src, radio_file)
-
- # 2nd DDC
- xlate_taps = filter.firdes.low_pass ( \
- 1.0, input_rate, 16e3, 4e3, filter.firdes.WIN_HAMMING )
- self.xlate = filter.freq_xlating_fir_filter_ccf ( \
- fir_decim, xlate_taps, self.tune_offset, input_rate )
-
- nflts = 32
- audio_coeffs = filter.firdes.complex_band_pass (
- nflts, # gain
- self.input_rate*nflts, # sample rate
- -3000.0, # low cutoff
- 0.0, # high cutoff
- 100.0, # transition
- filter.firdes.WIN_KAISER, 7.0) # window
- self.slider_fcutoff_hi.SetValue(0)
- self.slider_fcutoff_lo.SetValue(-3000)
-
- # Filter and resample based on actual radio's sample rate
- self.audio_filter = filter.pfb.arb_resampler_ccc(rrate, audio_coeffs)
-
- # Main +/- 16Khz spectrum display
- self.fft = fftsink2.fft_sink_c(self.panel_2, fft_size=512,
- sample_rate=self.af_sample_rate,
- average=True, size=(640,240),
- baseband_freq=self.usrp_center)
- c2f = blocks.complex_to_float()
-
-
- # AM branch
- self.sel_am = blocks.multiply_const_cc(0)
- # the following frequencies turn out to be in radians/sample
- # analog.pll_refout_cc(alpha,beta,min_freq,max_freq)
- # suggested alpha = X, beta = .25 * X * X
- pll = analog.pll_refout_cc(.05,(2.*math.pi*7.5e3/self.af_sample_rate),
- (2.*math.pi*6.5e3/self.af_sample_rate))
- self.pll_carrier_scale = blocks.multiply_const_cc(complex(10,0))
- am_det = blocks.multiply_cc()
- # these are for converting +7.5kHz to -7.5kHz
- # for some reason blocks.conjugate_cc() adds noise ??
- c2f2 = blocks.complex_to_float()
- c2f3 = blocks.complex_to_float()
- f2c = blocks.float_to_complex()
- phaser1 = blocks.multiply_const_ff(1)
- phaser2 = blocks.multiply_const_ff(-1)
-
- # filter for pll generated carrier
- pll_carrier_coeffs = filter.firdes.complex_band_pass (
- 2.0, # gain
- self.af_sample_rate, # sample rate
- 7400, # low cutoff
- 7600, # high cutoff
- 100, # transition
- filter.firdes.WIN_HAMMING) # window
-
- self.pll_carrier_filter = filter.fir_filter_ccc (1, pll_carrier_coeffs)
-
- self.sel_sb = blocks.multiply_const_ff(1)
- combine = blocks.add_ff()
-
- #AGC
- sqr1 = blocks.multiply_ff()
- intr = filter.iir_filter_ffd( [.004, 0], [0, .999] )
- offset = blocks.add_const_ff(1)
- agc = blocks.divide_ff()
-
- self.scale = blocks.multiply_const_ff(0.00001)
- dst = audio.sink(long(self.af_sample_rate),
- options.audio_output)
-
-
- if self.PLAY_FROM_USRP:
- self.tb.connect(self.src, self.xlate, self.fft)
- else:
- self.tb.connect(src_f2c, self.xlate, self.fft)
-
- self.tb.connect(self.xlate,self.audio_filter,self.sel_am,(am_det,0))
- self.tb.connect(self.sel_am,pll,self.pll_carrier_scale,
- self.pll_carrier_filter,c2f3)
- self.tb.connect((c2f3,0),phaser1,(f2c,0))
- self.tb.connect((c2f3,1),phaser2,(f2c,1))
- self.tb.connect(f2c,(am_det,1))
- self.tb.connect(am_det,c2f2,(combine,0))
- self.tb.connect(self.audio_filter,c2f,
- self.sel_sb,(combine,1))
-
-
- self.tb.connect(combine,self.scale)
- self.tb.connect(self.scale,(sqr1,0))
- self.tb.connect(self.scale,(sqr1,1))
- self.tb.connect(sqr1, intr, offset, (agc, 1))
- self.tb.connect(self.scale,(agc, 0))
- self.tb.connect(agc, blocks.null_sink(gr.sizeof_float))
- self.tb.connect(c2f3, dst)
-
- if SAVE_AUDIO_TO_FILE:
- f_out = blocks.file_sink(gr.sizeof_short,options.audio_file)
- sc1 = blocks.multiply_const_ff(64000)
- f2s1 = blocks.float_to_short()
- self.tb.connect(agc,sc1,f2s1,f_out)
-
- self.tb.start()
-
- # left click to re-tune
- self.fft.win.plotter.Bind(wx.EVT_LEFT_DOWN, self.Click)
-
- # start a timer to check for web commands
- if WEB_CONTROL:
- self.timer = UpdateTimer(self, 1000) # every 1000 mSec, 1 Sec
-
-
- wx.EVT_BUTTON(self,ID_BUTTON_1,self.set_lsb)
- wx.EVT_BUTTON(self,ID_BUTTON_2,self.set_usb)
- wx.EVT_BUTTON(self,ID_BUTTON_3,self.set_am)
- wx.EVT_BUTTON(self,ID_BUTTON_4,self.set_cw)
- wx.EVT_BUTTON(self,ID_BUTTON_10,self.fwd)
- wx.EVT_BUTTON(self,ID_BUTTON_11,self.rew)
- wx.EVT_TOGGLEBUTTON(self,ID_BUTTON_5,self.on_button)
- wx.EVT_TOGGLEBUTTON(self,ID_BUTTON_6,self.on_button)
- wx.EVT_TOGGLEBUTTON(self,ID_BUTTON_7,self.on_button)
- wx.EVT_TOGGLEBUTTON(self,ID_BUTTON_8,self.on_button)
- wx.EVT_TOGGLEBUTTON(self,ID_BUTTON_9,self.on_button)
- wx.EVT_SLIDER(self,ID_SLIDER_1,self.set_filter)
- wx.EVT_SLIDER(self,ID_SLIDER_2,self.set_filter)
- wx.EVT_SLIDER(self,ID_SLIDER_3,self.slide_tune)
- wx.EVT_SLIDER(self,ID_SLIDER_4,self.set_volume)
- wx.EVT_SLIDER(self,ID_SLIDER_5,self.set_pga)
- wx.EVT_SPINCTRL(self,ID_SPIN_1,self.spin_tune)
-
- wx.EVT_MENU(self, ID_EXIT, self.TimeToQuit)
-
- def __set_properties(self):
- # begin wxGlade: MyFrame.__set_properties
- self.SetTitle("HF Explorer")
- self.slider_fcutoff_hi.SetMinSize((650, 38))
- self.slider_fcutoff_lo.SetMinSize((650, 38))
- self.panel_2.SetMinSize((800, 400))
- self.button_7.SetValue(1)
- self.slider_3.SetMinSize((650, 19))
- self.slider_4.SetMinSize((275, 19))
- self.slider_5.SetMinSize((275, 19))
- # end wxGlade
-
- def __do_layout(self):
- # begin wxGlade: MyFrame.__do_layout
- sizer_1 = wx.BoxSizer(wx.VERTICAL)
- grid_sizer_1 = wx.FlexGridSizer(11, 2, 0, 0)
- sizer_7 = wx.BoxSizer(wx.HORIZONTAL)
- sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
- sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
- sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
- sizer_6 = wx.BoxSizer(wx.VERTICAL)
- sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
- grid_sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
- sizer_2.Add(self.button_1, 0, wx.ADJUST_MINSIZE, 0)
- sizer_2.Add(self.button_2, 0, wx.ADJUST_MINSIZE, 0)
- sizer_2.Add(self.button_3, 0, wx.ADJUST_MINSIZE, 0)
- sizer_2.Add(self.button_4, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.button_5, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_1.Add(self.slider_fcutoff_hi, 0,
- wx.ALIGN_LEFT|wx.ADJUST_MINSIZE, 0)
- grid_sizer_1.Add(self.button_6, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_1.Add(self.slider_fcutoff_lo, 0,
- wx.ALIGN_LEFT|wx.ADJUST_MINSIZE, 0)
- sizer_6.Add(self.panel_5, 1, wx.EXPAND, 0)
- sizer_6.Add(self.label_1, 0,
- wx.ALIGN_CENTER_HORIZONTAL|wx.ADJUST_MINSIZE, 0)
- sizer_6.Add(self.text_ctrl_1, 0, wx.ADJUST_MINSIZE, 0)
- sizer_6.Add(self.panel_6, 1, wx.EXPAND, 0)
- sizer_6.Add(self.panel_7, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(sizer_6, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.panel_2, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.button_7, 0, wx.ADJUST_MINSIZE, 0)
- sizer_3.Add(self.slider_3, 0, wx.ADJUST_MINSIZE, 0)
- sizer_3.Add(self.spin_ctrl_1, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_1.Add(sizer_3, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.button_8, 0, wx.ADJUST_MINSIZE, 0)
- sizer_4.Add(self.slider_4, 0, wx.ADJUST_MINSIZE, 0)
- sizer_4.Add(self.slider_5, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_1.Add(sizer_4, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.button_9, 0, wx.ADJUST_MINSIZE, 0)
- sizer_5.Add(self.button_11, 0, wx.ADJUST_MINSIZE, 0)
- sizer_5.Add(self.button_10, 0, wx.ADJUST_MINSIZE, 0)
- sizer_5.Add(self.panel_3, 1, wx.EXPAND, 0)
- sizer_5.Add(self.label_2, 0, wx.ADJUST_MINSIZE, 0)
- sizer_5.Add(self.panel_4, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(sizer_5, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.panel_8, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.panel_9, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.panel_10, 1, wx.EXPAND, 0)
- sizer_7.Add(self.panel_11, 1, wx.EXPAND, 0)
- sizer_7.Add(self.panel_12, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(sizer_7, 1, wx.EXPAND, 0)
- sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
- self.SetAutoLayout(True)
- self.SetSizer(sizer_1)
- sizer_1.Fit(self)
- sizer_1.SetSizeHints(self)
- self.Layout()
- # end wxGlade
-
- # Menu exit
- def TimeToQuit(self, event):
- self.tb.stop()
- self.Close(True)
-
- # Powermate being turned
- def on_rotate(self, event):
- if self.active_button == 5:
- self.slider_fcutoff_hi.SetValue(self.slider_fcutoff_hi.GetValue()+event.delta)
- if self.slider_fcutoff_lo.GetValue() > (self.slider_fcutoff_hi.GetValue() - 200) :
- self.slider_fcutoff_lo.SetValue(self.slider_fcutoff_hi.GetValue() - 200)
- self.filter()
- if self.active_button == 6:
- self.slider_fcutoff_lo.SetValue(self.slider_fcutoff_lo.GetValue()+event.delta)
- if self.slider_fcutoff_hi.GetValue() < (self.slider_fcutoff_lo.GetValue() + 200) :
- self.slider_fcutoff_hi.SetValue(self.slider_fcutoff_lo.GetValue() + 200)
- self.filter()
- if self.active_button == 7:
- new = max(0, min(6000, self.slider_3.GetValue() + event.delta))
- self.slider_3.SetValue(new)
- self.frequency = (self.f_slider_scale * new) + self.f_slider_offset
- self.spin_ctrl_1.SetValue(self.frequency)
- if self.AM_mode == False:
- self.xlate.set_center_freq( (self.frequency - self.tune_offset) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset )
- else:
- self.xlate.set_center_freq( (self.frequency - self.tune_offset - 7.5e3) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset - 7.5e3 )
- if self.active_button == 8:
- new = max(0, min(500, self.slider_4.GetValue() + event.delta))
- self.slider_4.SetValue(new)
- self.scale.set_k(math.pow(10.,((self.slider_4.GetValue()-500.)/100.)))
- if self.active_button == 9:
- if self.PLAY_FROM_USRP == False:
- if event.delta == -1:
- self.src.seek(-1000000,gr.SEEK_CUR)
- elif event.delta == 1:
- self.src.seek(1000000,gr.SEEK_CUR)
-
-
- # Powermate pressed to switch controlled function
- def on_pmButton(self, event):
- if event.value == 0:
- if self.active_button == 5:
- self.active_button = 6
- self.button_5.SetValue(False)
- self.button_6.SetValue(True)
- elif self.active_button == 6:
- self.active_button = 7
- self.button_6.SetValue(False)
- self.button_7.SetValue(True)
- elif self.active_button == 7:
- self.active_button = 8
- self.button_7.SetValue(False)
- self.button_8.SetValue(True)
- elif self.active_button == 8:
- self.active_button = 9
- self.button_8.SetValue(False)
- self.button_9.SetValue(True)
- elif self.active_button == 9:
- self.active_button = 5
- self.button_9.SetValue(False)
- self.button_5.SetValue(True)
-
- # Clicking one PM control button turns the rest off
- def on_button(self, event):
- id = event.GetId()
- if id == ID_BUTTON_5:
- self.active_button = 5
- self.button_6.SetValue(False)
- self.button_7.SetValue(False)
- self.button_8.SetValue(False)
- self.button_9.SetValue(False)
- if id == ID_BUTTON_6:
- self.active_button = 6
- self.button_5.SetValue(False)
- self.button_7.SetValue(False)
- self.button_8.SetValue(False)
- self.button_9.SetValue(False)
- if id == ID_BUTTON_7:
- self.active_button = 7
- self.button_5.SetValue(False)
- self.button_6.SetValue(False)
- self.button_8.SetValue(False)
- self.button_9.SetValue(False)
- if id == ID_BUTTON_8:
- self.active_button = 8
- self.button_5.SetValue(False)
- self.button_6.SetValue(False)
- self.button_7.SetValue(False)
- self.button_9.SetValue(False)
- if id == ID_BUTTON_9:
- self.active_button = 9
- self.button_5.SetValue(False)
- self.button_6.SetValue(False)
- self.button_7.SetValue(False)
- self.button_8.SetValue(False)
-
- # Make sure filter settings are legal
- def set_filter(self, event):
- slider = event.GetId()
- slider1 = self.slider_fcutoff_hi.GetValue()
- slider2 = self.slider_fcutoff_lo.GetValue()
- if slider == ID_SLIDER_1:
- if slider2 > (self.slider_fcutoff_hi.GetValue() - 200) :
- self.slider_fcutoff_lo.SetValue(slider1 - 200)
- elif slider == ID_SLIDER_2:
- if slider1 < (self.slider_fcutoff_lo.GetValue() + 200) :
- self.slider_fcutoff_hi.SetValue(slider2 + 200)
- self.filter()
-
- # Calculate taps and apply
- def filter(self):
- nflts = 32
- audio_coeffs = filter.firdes.complex_band_pass (
- nflts, # gain
- self.input_rate*nflts, # sample rate
- self.slider_fcutoff_lo.GetValue(), # low cutoff
- self.slider_fcutoff_hi.GetValue(), # high cutoff
- 100.0, # transition
- filter.firdes.WIN_KAISER, 7.0) # window
- self.audio_filter.set_taps(audio_coeffs)
-
- def set_lsb(self, event):
- self.AM_mode = False
- self.xlate.set_center_freq( (self.frequency - self.tune_offset) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset )
- self.sel_sb.set_k(1)
- self.sel_am.set_k(0)
- self.slider_fcutoff_hi.SetValue(0)
- self.slider_fcutoff_lo.SetValue(-3000)
- self.filter()
-
- def set_usb(self, event):
- self.AM_mode = False
- self.xlate.set_center_freq( (self.frequency - self.tune_offset) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset )
- self.sel_sb.set_k(1)
- self.sel_am.set_k(0)
- self.slider_fcutoff_hi.SetValue(3000)
- self.slider_fcutoff_lo.SetValue(0)
- self.filter()
-
- def set_am(self, event):
- self.AM_mode = True
- self.xlate.set_center_freq( (self.frequency - self.tune_offset - 7.5e3) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset - 7.5e3 )
- self.sel_sb.set_k(0)
- self.sel_am.set_k(1)
- self.slider_fcutoff_hi.SetValue(12500)
- self.slider_fcutoff_lo.SetValue(2500)
- self.filter()
-
- def set_cw(self, event):
- self.AM_mode = False
- self.xlate.set_center_freq( (self.frequency - self.tune_offset) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset )
- self.AM_mode = False
- self.sel_sb.set_k(1)
- self.sel_am.set_k(0)
- self.slider_fcutoff_hi.SetValue(-400)
- self.slider_fcutoff_lo.SetValue(-800)
- self.filter()
-
- def set_volume(self, event):
- self.scale.set_k(math.pow(10.,((self.slider_4.GetValue()-500.)/100.)))
-
- def set_pga(self,event):
- if self.PLAY_FROM_USRP:
- self.src.set_gain(self.slider_5.GetValue())
-
- def slide_tune(self, event):
- self.frequency = (self.f_slider_scale * self.slider_3.GetValue()) + self.f_slider_offset
- if self.AM_mode == False:
- self.xlate.set_center_freq( (self.frequency - self.tune_offset) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset )
- else:
- self.xlate.set_center_freq( (self.frequency - self.tune_offset - 7.5e3) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset - 7.5e3 )
- self.spin_ctrl_1.SetValue(self.frequency)
-
- def spin_tune(self, event):
- self.frequency = self.spin_ctrl_1.GetValue()
- if self.AM_mode == False:
- self.xlate.set_center_freq( (self.frequency - self.tune_offset) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset )
- else:
- self.xlate.set_center_freq( (self.frequency - self.tune_offset - 7.5e3) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset - 7.5e3 )
- self.slider_3.SetValue(int((self.frequency-self.f_slider_offset)/self.f_slider_scale))
-
- # Seek forwards in file
- def fwd(self, event):
- if self.PLAY_FROM_USRP == False:
- self.src.seek(10000000,gr.SEEK_CUR)
-
- # Seek backwards in file
- def rew(self, event):
- if self.PLAY_FROM_USRP == False:
- self.src.seek(-10000000,gr.SEEK_CUR)
-
- # Mouse clicked on fft display - change frequency
- def Click(self,event):
- fRel = ( event.GetX() - 340. ) / 18.125
- if self.AM_mode == False:
- self.frequency = self.frequency + (fRel*1e3)
- else:
- self.frequency = self.frequency + (fRel*1e3) - 7.5e3
- self.spin_ctrl_1.SetValue(int(self.frequency))
- self.slider_3.SetValue(int((self.frequency-self.f_slider_offset)/self.f_slider_scale))
- if self.AM_mode == False:
- self.xlate.set_center_freq ( ( self.frequency - self.tune_offset ) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset )
- else:
- self.xlate.set_center_freq( (self.frequency - self.tune_offset - 7.5e3) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset - 7.5e3 )
-
-
- # Timer events - check for web commands
- def OnUpdate(self):
- cmds = os.listdir("/var/www/cgi-bin/commands/")
- if cmds!=[]:
- if cmds[0]=='chfreq':
- fd=open("/var/www/cgi-bin/commands/chfreq","r")
- new=fd.readline()
- fd.close()
- if new!='':
- os.unlink("/var/www/cgi-bin/commands/chfreq")
- if ( int(new) >= self.f_lo ) & ( int(new) <= self.f_hi ):
- self.frequency = int(new)
- self.slider_3.SetValue(( self.frequency - self.f_slider_offset) / self.f_slider_scale )
- self.spin_ctrl_1.SetValue(self.frequency)
- if self.AM_mode:
- self.xlate.set_center_freq ( ( self.frequency - self.tune_offset - 7.5e3 ) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset )
- else:
- self.xlate.set_center_freq ( ( self.frequency - self.tune_offset ) - self.usrp_center)
- self.fft.set_baseband_freq( self.frequency - self.tune_offset - 7.5e3 )
-
- if cmds[0]=='chvolume':
- fd=open("/var/www/cgi-bin/commands/chvolume","r")
- new=fd.readline()
- fd.close()
- if new!='':
- os.unlink("/var/www/cgi-bin/commands/chvolume")
- if ( int(new) >= 0 ) & ( int(new) <= 500 ):
- self.volume = int(new)
- self.slider_4.SetValue(self.volume)
- self.scale.set_k(math.pow(10.,((self.slider_4.GetValue()-500.)/100.)))
-
- else: # no new web commands, update state
- fh = open("/var/www/cgi-bin/state/freq","w")
- fh.write(str(int(self.frequency))+'\n')
- fh.close()
- fh = open("/var/www/cgi-bin/state/volume","w")
- fh.write(str(self.slider_4.GetValue())+'\n')
- fh.close()
-
-
-# end of class MyFrame
-
-# wx.Timer to check for web updates
-class UpdateTimer(wx.Timer):
- def __init__(self, target, dur=1000):
- wx.Timer.__init__(self)
- self.target = target
- self.Start(dur)
-
- def Notify(self):
- """Called every timer interval"""
- if self.target:
- self.target.OnUpdate()
-
-
-class MyApp(wx.App):
- def OnInit(self):
- frame = MyFrame(None, -1, "HF Explorer")
- frame.Show(True)
- self.SetTopWindow(frame)
- return True
-
-
-if __name__ == "__main__":
- app = MyApp(0)
- app.MainLoop()
-
diff --git a/gr-uhd/apps/hf_explorer/hfx_help b/gr-uhd/apps/hf_explorer/hfx_help
deleted file mode 100644
index c8fa28dbd1..0000000000
--- a/gr-uhd/apps/hf_explorer/hfx_help
+++ /dev/null
@@ -1,180 +0,0 @@
-
- HF Explorer Help
-
- -----------------------------------------------------------------------
-
- Command Line Switches:
-
- -c DDC center frequency, set band.
- -c 7.2e6 or -c 7.2M for 40 meter ham band.
- Default is 3.9e6 80 meter ham band.
- Example:
-
- hfx.py -c 9500k
-
- starts up in the 31 meter band.
-
- -a Audio output file. Output file for 32kHz two channel
- signed word audio. Two channels are used for
- independent sideband. This file can be converted
- to a wav file with sox. Example:
-
- sox -c 2 -r 3200 file.sw file.wav
-
- sox needs the .sw extension to indicate file type.
- If not specified no audio file is created.
-
- -r Radio output file. File to write RF data to for later
- demodulation. Records the entire band to disk, width
- determined by sample rate/decimation. Be sure to
- note the decimation and center freq for later use!
- Example:
-
- hfx.py -c 900e3 -d 80 -r rf_data_AM-c900e3-d80
-
- writes a pre-demod rf file centered on 900kHz with a
- bandwidth of 800kHz (That's 80 AM stations!). The
- center and decimation could be put in the filename for
- proper use later.
- If not specified no rf data file is created.
- At default 250 decimation disk usage is about
- 8Gb / hour.
-
- -i Radio input file. Use to play back a previously
- recorded rf data file. Example:
-
- hfx.py -c 900e3 -d 80 -i rf_data_AM-c900e3-d80
-
- plays back the previously recorded band, no
- usrp hardware needed. Tune about the 800kHz wide band.
- When playing a recorded file, time controls
- fast-forward and rewind are available.
-
- -d Decimation. Sets sample rate and bandwidth.
- This is the factor that the usrp sample rate, 64e6,
- is divided by. Default is 250 for 256kHz bandwidth
- which is enough to record a ham band without
- eating up disk space too fast. The 64e6 sample
- rate limits the upper practical frequency to 32MHz.
- The Basic RX transformer limits the lower frequency
- to about 200kHz.
-
-
- Powermate Knob:
-
- A Powermate knob is recommended but not necessary. If a knob
- is used, it is in one of 3 or 4 modes controlling frequency,
- volume, filter and (if playing a recorded file) time.
- Pushing the knob switches mode and the buttons on the HFX panel
- change to show which mode is in effect. Then just turn the knob
- to set frequency, volume, filter or go fast forward or rewind.
-
-
- Bandswitch:
-
- Across the top are a set of predefined bands and buttons
- to rapidly switch to the center of that band. To change a band,
- type the frequency in Hz into the box under "Center Frequency",
- then press "Set" on the left, then the button you want to
- program. From then on (untill the program is exited) pushing
- that button takes you to that band. To make a band button
- permenant edit the hfx.py script with whatever frequency you
- want assigned to what button.
-
-
- Frequency:
-
- There are 6 ways to set the frequency.
- 1) Move the slider with the mouse
- 2) Use the Spin Control up/down arrows (very fine 1Hz control)
- 3) Type the frequency in Hz into the Spin Control
- 4) Turn the Powermate knob
- 5) Web control.
- 6) Clicking on the FFT display to set demod center. This is very
- convenient for tuning +-15kHz when you see a signal on the
- display. If in Lower Sideband, clicking just to the right of
- a signal will tune to it immediately. Clicking several times
- on the far right right or left of the display will rapidly
- tune up or down the band.
-
-
- Volume:
-
- Move the volume slider with the mouse, or push the Powermate knob
- untill the volume button is active, or click on the volume button,
- then turn the knob. Volume can also be set by web control if web
- control is setup and enabled.
-
-
- Filter:
-
- Similar to volume, switches in any of 30 audio filters from 600
- to 3600Hz in Sideband or up to 5kHz in AM.
-
-
- Mode:
-
- Demodulation modes are chosen by clicking on the buttons for
- Lower Sideband, Upper Sideband, or AM.
-
-
- PGA:
-
- PGA slider sets the rf gain in the Analog-to-Digital converter
- before digitizing. 0 to 20db gain easily shows up on the FFT
- display.
-
-
- Time:
-
- When playing back a recorded RF data file, you can enjoy the
- freedom of rewinding or fast-forwarding. Replay a weak signal
- or skip through annoying AM commercials.
-
-
- Antennas and Preamps:
-
- The USRP Basic RX board is not sensitive enough for anything but
- the strongest signals. In my experience about 40 db of small
- signal gain is required to make the HFX as sensitive as other
- receivers. Some working amplifiers are the Ramsey PR-2 with 20db
- gain, fairly low noise and more bandwidth than we can use here.
- Also the amp modules from Advanced Receiver Research are nice.
- I use an ARR 7-7.4MHz GaAsFET 29db amp with .5db noise at the
- apex of a 40 meter dipole with excellent results. Another
- amp I like is a Minicircuits ZHL-32A 29db amp but they are
- expensive and hard to find. Also it may help to use some filters
- to keep strong local signals from the ADC, or limit rf input
- to the band of interest, etc.
- Resonant outdoor antennas, like a dipole, in a low-noise (away
- from consumer electronics) environment are nice. Long random wires
- with a tuner work. I like a small indoor tuned loop made from 10ft
- of 1/4" copper tube, a 365pf tuning cap and a pickup loop connected
- to rg-58.
-
-
- Web Control:
-
- To control your radio remotely, ensure you have a web server
- (Apache, etc) working and a compatible directory structure in
- place. Directories /var/www/cgi-bin/commands and
- /var/www/cgi-bin/state must already exist. You will need a
- home page with forms and a set of scripts to put commands in
- and put the current state on the home page. email me for further
- help. Setting WEB_CONTROL to True in hfx.py turns on the timers
- that check for commands and update the state.
-
-
- IF Output:
-
- There is a provision for outputting un-demodulated complex
- through the audio out in stereo for use with Digital Radio
- Mondial (DRM) or using a seperate demodulation program like
- SDRadio (by I2PHD).
- Set IF_OUTPUT to True in weaver_isb_am1_usrp4.py.
-
-
- --Good luck and happy LW/MW/SW Exploring.
- Chuck
- chuckek@musicriver.homeunix.com
-
diff --git a/gr-uhd/apps/hf_radio/README.TXT b/gr-uhd/apps/hf_radio/README.TXT
deleted file mode 100644
index c5c57f8479..0000000000
--- a/gr-uhd/apps/hf_radio/README.TXT
+++ /dev/null
@@ -1,60 +0,0 @@
-# 2008-02-07
-#
-# These files have not yet been update to use the new top_block/hier_block2
-# interfaces. Until someone does that, this files will no longer run.
-#
-
-
-The files in this directory implement a fairly simple HF radio that works
-with the basic rx daughter board on the USRP.
-
-Many thanks to the Gnu Radio folks for a great new way to waste large blocks
-of time in infinitely tweaking a huge number of free parameters.
-
-Start the receiver by running the radio.py in this directory. Or from the
-Python prompt type "from radio import *" and you'll get the prompt back
-with the receiver running. You can then poke around to see what's going on.
-
-There are two spectrum displays. One is the output of the USRP and displays
-about 300KHz of bandwidth centered at the current tuning freq. The other
-displays the output spectrum of the demodulator.
-
-The demodulator does AM demod using the complex modulus block from gr. It
-does SSB demod using the frequency translating fir filter as a complex
-hilbert transformer. The taps for this filter were generated using a program
-called Scilab and the Scilab program in the file hfir.sci. More details in
-the associated files.
-
-Tune the receiver using the spin buttons under the big frequency display.
-
-The agc block is a roll your own. The standard agc in the newer CVS updates
-seems to work but doesn't seem to have adjustable time constants or provide
-access to internal signal nodes which are used for the RSSI.
-
-The AGC authority (a sort of gain parameter) and the reference level used
-in the power to dB computagion can be adjusted using the spin buttons.
-
-The audio bandwidth can be similarly adjusted from about 50Hz to 10KHz.
-
-The GUI layout was produced using wxGlade. The file radio.xml is the GUI
-specification. It will produce a file called ui.py which is subclassed
-by classes defined in radio.py. The ui.py is purely generated by wxGlade
-all app specific code for the GUI is in radio.py.
-
-Most of the actual signal processing code is built up in the other included
-files using the hierarchical block facilities. This organization should
-make it easier to tweak to your heart's content.
-
-Known bugs weakness and other
-
-wxPython and wxGlade seem to conspire to insure that the layout can never
-be exactly what you have in mind.
-
-Some of the controls don't behave as one might like. wx spin controls
-and spin boxes only support integers so it is rather a nuisance to make
-units come out nice. In the process of development I came up with a reasonable
-kluge so there is a mixture of approaches.
-
-Enjoy.
-
-M. Revnell 2006-Jan-06
diff --git a/gr-uhd/apps/hf_radio/hfir.sci b/gr-uhd/apps/hf_radio/hfir.sci
deleted file mode 100644
index 64f5385d73..0000000000
--- a/gr-uhd/apps/hf_radio/hfir.sci
+++ /dev/null
@@ -1,59 +0,0 @@
-// designs a complex tap fir filter akin to the hilbert transformer.
-//
-// The hilbert transformer is classified as a linear phase fir
-// with allpass magnitude response and 90 degree phase response for
-// positive frequencies and -90 degrees phase for negative frequencies.
-// Or, if you prefer, normalized frequencies between .5 and 1 since
-// negative frequencies don't really have much meaning outside the complex
-// domain.
-//
-// Normally one would use the hilbert transformer in one leg of a complex
-// processing block and a compensating delay in the other.
-//
-// This one differs in the following respects:
-// It is low pass with a cutoff of .078125
-// The filter is a lowpass kaiser windowed filter with parameter 3
-// The phase response is 45 degrees for positive frequencies and -45
-// for negative frequencies.
-// The coefficent set is used in one path and the same coefficients
-// are used time reversed in the other. This results in the net effect
-// of +/- 90 degrees as in the usual hilbert application.
-//
-// The coefficient set can be used in the gnuradio frequency translating
-// fir filter for ssb demodulation.
-//
-// This isn't as computationally efficient as using the hilbert transformer
-// and compensating delay but fascinating none the less.
-//
-// This program is for the scilab language a very powerful free math
-// package similar to Matlab with infinitely better price/performace.
-//
-// compute the prototype lowpass fir
-// length is 255 (odd) for the same symmetry reasons as the hilbert transformer
-
-len = 1023;
-l2 = floor(len/2);
-md = l2 + 1;
-l3 = md + 1;
-
-h = wfir( 'lp', len, [10.0/256 0], 'kr', [3 0] );
-
-H = fft(h);
-
-H(1:l2)=H(1:l2)*exp(%i*%pi/4);
-H(md)=0+%i*0;
-H(l3:len)=H(l3:len)*exp(-%i*%pi/4);
-
-j=real(ifft(H));
-k(1:len)=j(len:-1:1);
-x=j+%i.*k;
-X=fft(x);
-plot(abs(X))
-
-f = file('open','taps')
-for i=(1:len)
- fprintf( f, '%f%+fj', j(i), k(i) )
-end
-
-file('close',f)
-
diff --git a/gr-uhd/apps/hf_radio/input.py b/gr-uhd/apps/hf_radio/input.py
deleted file mode 100644
index 49df347e8b..0000000000
--- a/gr-uhd/apps/hf_radio/input.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-# Basic USRP setup and control.
-# It's only ever been tried with a basic rx daughter card.
-#
-# Imagine that the gnuradio boilerplate is here.
-#
-# M. Revnell 2005-Dec
-
-from gnuradio import gr
-from gnuradio import uhd
-
-class uhd_input(gr.hier_block2):
- def __init__( self, address, samp_rate):
- gr.hier_block2.__init__(self, "uhd_input",
- gr.io_signature(0,0,0),
- gr.io_signature(1,1,gr.sizeof_gr_complex))
-
- self.src = uhd.usrp_source(device_addr=address,
- io_type=uhd.io_type.COMPLEX_FLOAT32,
- num_channels=1)
-
- self.src.set_samp_rate(samp_rate)
- self.usrp_rate = self.src.get_samp_rate()
-
- self.connect(self.src, self)
-
- def set_freq(self, target_freq):
- """
- Set the center frequency.
-
- Args:
- target_freq: frequency in Hz
- """
- r = self.src.set_center_freq(target_freq, 0)
-
- if r:
- self.freq = target_freq
- return True
- else:
- return False
-
- def get_freq(self):
- return self.src.get_center_freq(0)
-
- def set_gain(self, gain):
- self.gain = gain
- self.src.set_gain(gain, 0)
-
- @staticmethod
- def add_options(parser):
- parser.add_option("-a", "--address", type="string",
- default="addr=192.168.10.2",
- help="Address of UHD device, [default=%default]")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-f", "--freq", type="eng_float", default=None,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
diff --git a/gr-uhd/apps/hf_radio/output.py b/gr-uhd/apps/hf_radio/output.py
deleted file mode 100644
index 3e80c8d315..0000000000
--- a/gr-uhd/apps/hf_radio/output.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-
-# Audio output with a volume control.
-#
-# M. Revnell 2005-Dec
-
-from gnuradio import gr, gru
-from gnuradio import blocks
-from gnuradio import audio
-
-class output( gr.hier_block2 ):
- def __init__( self, rate, device ):
- gr.hier_block2.__init__(self, "output",
- gr.io_signature(1,1,gr.sizeof_float),
- gr.io_signature(0,0,0))
-
- self.vol = blocks.multiply_const_ff( 0.1 )
- self.out = audio.sink( int(rate), device )
-
- self.connect( self, self.vol, self.out )
-
- def set( self, val ):
- self.vol.set_k( val )
-
diff --git a/gr-uhd/apps/hf_radio/radio.py b/gr-uhd/apps/hf_radio/radio.py
deleted file mode 100755
index 970ec01a38..0000000000
--- a/gr-uhd/apps/hf_radio/radio.py
+++ /dev/null
@@ -1,320 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-# GUI interactions and high level connections handled here.
-#
-# Interacts with classes defined by wxGlade in ui.py.
-#
-# M. Revnell 2006-Jan
-
-from threading import *
-import wx
-import wx.lib.evtmgr as em
-import time
-
-from gnuradio import gr, gru, eng_notation
-from gnuradio import audio
-from gnuradio import blocks
-from gnuradio import uhd
-from gnuradio import blks2
-from gnuradio.wxgui import fftsink2
-from gnuradio.wxgui import waterfallsink2
-from gnuradio.wxgui import scopesink2
-
-from input import *
-from output import *
-from ssbdemod import *
-from ssbagc import *
-from ui import *
-from math import log10
-
-class radio_top_block( gr.top_block ):
- def __init__( self ):
- gr.top_block.__init__(self, "radio_top_block")
-
- self.address = "addr=192.168.11.2"
- self.samp_rate = 256e3
- self.freq = -2.5e6
- self.gain = 0
- self.src = uhd_input( self.address,
- self.samp_rate)
- self.src.set_freq(self.freq)
- self.src.set_gain(self.gain)
-
- self.fe_rate = self.src.usrp_rate
- self.filter_decim = 1
- self.audio_decim = 16
- self.demod_rate = self.fe_rate / self.filter_decim
- self.audio_rate = self.demod_rate / self.audio_decim
- self.audio_dev = "pulse"
-
- self.demod = ssb_demod( self.demod_rate, self.audio_rate )
- self.agc = agc()
- self.out = output( self.audio_rate, self.audio_dev )
-
- self.connect( self.src, self.demod, self.agc, self.out )
-
- def tune( self, freq ):
- fe_target = -freq
- self.src.set_freq( fe_target )
- demod_cf = fe_target - self.src.get_freq()
- self.demod.tune( demod_cf )
-
-class radio_frame( ui_frame ):
- def __init__( self, block, *args, **kwds ):
- ui_frame.__init__( self, *args, **kwds )
- self.block = block
- self.freq_disp.SetRange(0, 30e6)
- f = self.block.src.freq
- self.freq_disp.SetValue( -f )
- self.volume.SetRange( 0, 20 )
- self.pga.SetRange( 0, 20 )
- self.rssi_range = 1
- self.rssi.SetRange( self.rssi_range )
- self.agc_max.SetValue( str( self.rssi_range ) )
- self.spin_e0.SetValue( 50 )
- self.spin_e1.SetValue( 50 )
- self.spin_e2.SetValue( 50 )
- self.spin_e3.SetValue( 50 )
- self.spin_e4.SetValue( 50 )
- self.spin_e5.SetValue( 50 )
- self.spin_e6.SetValue( 50 )
- bw = 3.3e3
- self.bandwidth.SetValue( str( bw ) )
- self.block.demod.set_bw( bw )
- self.bw_spin.SetValue( 5 )
- agc_gain = self.block.agc.gain.k()
- self.agc_gain_s.SetValue( 5 )
- self.agc_gain.SetValue( str( agc_gain ) )
- agc_ref = self.block.agc.offs.k()
- self.agc_ref.SetValue( str( agc_ref ) )
- self.agc_ref_s.SetValue( 5 )
-
- self.fespectrum = fftsink2.fft_sink_c(
- self.fe_panel,
- fft_size=512,
- sample_rate = block.fe_rate,
- ref_scale = 1.0,
- ref_level = 20.0,
- y_divs = 12,
- avg_alpha = 0.1)
-
- self.ifspectrum = fftsink2.fft_sink_c(
- self.if_panel,
- fft_size=512,
- sample_rate = block.audio_rate,
- ref_scale = 1.0,
- ref_level = 20.0,
- y_divs = 12,
- avg_alpha = 0.1)
-
- self.fespectrum.win.Bind( wx.EVT_MOTION, self.fe_mouse)
- self.fespectrum.win.Bind( wx.EVT_LEFT_DOWN, self.fe_click)
-
- block.connect( block.src.src, self.fespectrum )
- block.connect( block.demod.xlate, self.ifspectrum )
-
- def agc_ref_up( self, event ):
- self.agc_ref_s.SetValue( 5 )
- r = float( self.agc_ref.GetValue() )
- r = r + 5
- self.agc_ref.SetValue( str( r ) )
- self.block.agc.offs.set_k( r )
-
- def agc_ref_down( self, event ):
- self.agc_ref_s.SetValue( 5 )
- r = float( self.agc_ref.GetValue() )
- r = r - 5
- self.agc_ref.SetValue( str( r ) )
- self.block.agc.offs.set_k( r )
-
- def agc_gain_up( self, event ):
- self.agc_gain_s.SetValue( 5 )
- g = float(self.agc_gain.GetValue())
- g = g + 10
- self.agc_gain.SetValue( str( g ) )
- self.block.agc.gain.set_k( g )
-
- def agc_gain_down( self, event ):
- self.agc_gain_s.SetValue( 5 )
- g = float(self.agc_gain.GetValue())
- g = g - 10
- self.agc_gain.SetValue( str( g ) )
- self.block.agc.gain.set_k( g )
-
- def fe_mouse( self, event ):
- f = int(self.freq_disp.GetValue())
- f = f+((event.GetX()-346.)*(400./610.))*1000
- self.fespectrum.win.SetToolTip(
- wx.ToolTip( eng_notation.num_to_str(f)))
-
- def fe_click( self, event ):
- f = int(self.freq_disp.GetValue())
- f = f+((event.GetX()-346.)*(400./610.))*1000
- self.tune( f )
-
- def setrssi( self, level ):
- if level < 0:
- level = 0
- if level > self.rssi_range:
- self.rssi_range = level
- self.rssi.SetRange( level )
- self.agc_max.SetValue( str( level ))
- self.rssi.SetValue( level )
- self.agc_level.SetValue( str( level ))
-
- def tune_evt( self, event ):
- f = self.freq_disp.GetValue()
- self.tune( f )
-
- def tune( self, frequency ):
- self.freq_disp.SetValue( frequency )
- self.block.tune( frequency )
-
- def up_e0( self, event ):
- self.spin_e0.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() + 1e0 )
-
- def down_e0( self, event ):
- self.spin_e0.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() - 1e0 )
-
- def up_e1( self, event ):
- self.spin_e1.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() + 1e1 )
-
- def down_e1( self, event ):
- self.spin_e1.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() - 1e1 )
-
- def up_e2( self, event ):
- self.spin_e2.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() + 1e2 )
-
- def down_e2( self, event ):
- self.spin_e2.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() - 1e2 )
-
- def up_e3( self, event ):
- self.spin_e3.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() + 1e3 )
-
- def down_e3( self, event ):
- self.spin_e3.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() - 1e3 )
-
- def up_e4( self, event ):
- self.spin_e4.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() + 1e4 )
-
- def down_e4( self, event ):
- self.spin_e4.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() - 1e4 )
-
- def up_e5( self, event ):
- self.spin_e5.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() + 1e5 )
-
- def down_e5( self, event ):
- self.spin_e5.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() - 1e5 )
-
- def up_e6( self, event ):
- self.spin_e6.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() + 1e6 )
-
- def down_e6( self, event ):
- self.spin_e6.SetValue( 50 )
- self.tune( self.freq_disp.GetValue() - 1e6 )
-
- def event_pga( self, event ):
- self.block.src.set_gain(self.pga.GetValue())
-
- def event_vol( self, event ):
- self.block.out.set( self.volume.GetValue()/20.0 )
-
- def set_usb( self, event ):
- self.block.demod.upper_sb()
-
- def set_lsb( self, event ):
- self.block.demod.lower_sb()
-
- def set_am( self, event ):
- self.block.demod.set_am()
-
- def bw_up( self, event ):
- self.bw_spin.SetValue( 5 )
- bw = float(self.bandwidth.GetValue())
- bw = bw + 20.0
- if bw > 10e3:
- bw = 10e3
- self.bandwidth.SetValue( str( bw ) )
- self.block.demod.set_bw( bw )
-
- def bw_down( self, event ):
- self.bw_spin.SetValue( 5 )
- bw = float(self.bandwidth.GetValue())
- bw = bw - 20.0
- if bw < 50:
- bw = 50
- self.bandwidth.SetValue( str( bw ) )
- self.block.demod.set_bw( bw )
-
-
-class radio( wx.App ):
- def OnInit( self ):
- self.block = radio_top_block()
- self.frame = radio_frame( self.block, None, -1, "HF Receiver" )
- self.frame.Show( True )
- self.SetTopWindow( self.frame )
- self.block.start()
- return True
-
-def rssi_function():
- global radio_obj
- global sig_probe
-
- go = True
- while go:
- try:
- level = sig_probe.level()
- wx.CallAfter( radio_obj.frame.setrssi, level )
- time.sleep( .1 )
- except:
- go = False
-
-def main():
- global radio_obj, sig_probe
-
- radio_obj = radio( 0 )
- sig_probe = blocks.probe_signal_f()
- radio_obj.block.connect(radio_obj.block.agc.offs, sig_probe)
-
- thread2 = Thread( target = rssi_function )
- thread2.start()
-
- radio_obj.MainLoop()
-
-
-if __name__ == "__main__":
- main()
-
diff --git a/gr-uhd/apps/hf_radio/radio.xml b/gr-uhd/apps/hf_radio/radio.xml
deleted file mode 100644
index 81daa19b0d..0000000000
--- a/gr-uhd/apps/hf_radio/radio.xml
+++ /dev/null
@@ -1,441 +0,0 @@
-<?xml version="1.0"?>
-<!-- generated by wxGlade 0.4 on Fri Jan 6 09:51:36 2006 -->
-
-<application path="/root/radio/ui.py" name="" class="" option="0" language="python" top_window="" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.6">
- <object class="ui_frame" name="frame_1" base="EditFrame">
- <style>wxDEFAULT_FRAME_STYLE</style>
- <title>frame_1</title>
- <object class="wxStaticBoxSizer" name="sizer_1" base="EditStaticBoxSizer">
- <orient>wxVERTICAL</orient>
- <label>sizer_1</label>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer">
- <orient>wxHORIZONTAL</orient>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxBoxSizer" name="sizer_3" base="EditBoxSizer">
- <orient>wxVERTICAL</orient>
- <object class="sizeritem">
- <flag>wxEXPAND|wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxSpinCtrl" name="freq_disp" base="EditSpinCtrl">
- <font>
- <size>32</size>
- <family>default</family>
- <style>normal</style>
- <weight>normal</weight>
- <underlined>0</underlined>
- <face></face>
- </font>
- <events>
- <handler event="EVT_SPINCTRL">tune_evt</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxGridSizer" name="grid_sizer_1" base="EditGridSizer">
- <hgap>0</hgap>
- <rows>2</rows>
- <cols>3</cols>
- <vgap>0</vgap>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxGridSizer" name="grid_sizer_2" base="EditGridSizer">
- <hgap>0</hgap>
- <rows>1</rows>
- <cols>7</cols>
- <vgap>0</vgap>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinButton" name="spin_e6" base="EditSpinButton">
- <events>
- <handler event="EVT_SPIN_UP">up_e6</handler>
- <handler event="EVT_SPIN_DOWN">down_e6</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinButton" name="spin_e5" base="EditSpinButton">
- <events>
- <handler event="EVT_SPIN_UP">up_e5</handler>
- <handler event="EVT_SPIN_DOWN">down_e5</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinButton" name="spin_e4" base="EditSpinButton">
- <events>
- <handler event="EVT_SPIN_UP">up_e4</handler>
- <handler event="EVT_SPIN_DOWN">down_e4</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinButton" name="spin_e3" base="EditSpinButton">
- <events>
- <handler event="EVT_SPIN_UP">up_e3</handler>
- <handler event="EVT_SPIN_DOWN">down_e3</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinButton" name="spin_e2" base="EditSpinButton">
- <events>
- <handler event="EVT_SPIN_UP">up_e2</handler>
- <handler event="EVT_SPIN_DOWN">down_e2</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinButton" name="spin_e1" base="EditSpinButton">
- <events>
- <handler event="EVT_SPIN_UP">up_e1</handler>
- <handler event="EVT_SPIN_DOWN">down_e1</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinButton" name="spin_e0" base="EditSpinButton">
- <events>
- <handler event="EVT_SPIN_UP">up_e0</handler>
- <handler event="EVT_SPIN_DOWN">down_e0</handler>
- </events>
- </object>
- </object>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxPanel" name="panel_1" base="EditPanel">
- <style>wxTAB_TRAVERSAL</style>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxPanel" name="panel_2" base="EditPanel">
- <style>wxTAB_TRAVERSAL</style>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxButton" name="button_lsb" base="EditButton">
- <label>LSB</label>
- <events>
- <handler event="EVT_BUTTON">set_lsb</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxButton" name="button_usb" base="EditButton">
- <label>USB</label>
- <events>
- <handler event="EVT_BUTTON">set_usb</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxButton" name="button_am" base="EditButton">
- <label>AM</label>
- <events>
- <handler event="EVT_BUTTON">set_am</handler>
- </events>
- </object>
- </object>
- </object>
- </object>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxBoxSizer" name="sizer_4" base="EditBoxSizer">
- <orient>wxVERTICAL</orient>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxGridSizer" name="grid_sizer_3" base="EditGridSizer">
- <hgap>0</hgap>
- <rows>2</rows>
- <cols>4</cols>
- <vgap>0</vgap>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxStaticText" name="label_1" base="EditStaticText">
- <attribute>1</attribute>
- <label>VOLUME</label>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxStaticText" name="label_2" base="EditStaticText">
- <attribute>1</attribute>
- <label>PGA</label>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxTextCtrl" name="agc_level" base="EditTextCtrl">
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxStaticText" name="label_6" base="EditStaticText">
- <attribute>1</attribute>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinCtrl" name="volume" base="EditSpinCtrl">
- <events>
- <handler event="EVT_SPINCTRL">event_vol</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinCtrl" name="pga" base="EditSpinCtrl">
- <events>
- <handler event="EVT_SPINCTRL">event_pga</handler>
- </events>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxTextCtrl" name="agc_max" base="EditTextCtrl">
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxStaticText" name="label_7" base="EditStaticText">
- <attribute>1</attribute>
- </object>
- </object>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxGridSizer" name="grid_sizer_4" base="EditGridSizer">
- <hgap>0</hgap>
- <rows>2</rows>
- <cols>4</cols>
- <vgap>0</vgap>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxStaticText" name="label_4" base="EditStaticText">
- <attribute>1</attribute>
- <label>AGC AUTHORITY</label>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxStaticText" name="label_5" base="EditStaticText">
- <attribute>1</attribute>
- <label>AGC REF LVL</label>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxStaticText" name="label_3" base="EditStaticText">
- <attribute>1</attribute>
- <label>BANDWIDTH</label>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxStaticText" name="label_8" base="EditStaticText">
- <attribute>1</attribute>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxBoxSizer" name="sizer_6" base="EditBoxSizer">
- <orient>wxHORIZONTAL</orient>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxTextCtrl" name="agc_gain" base="EditTextCtrl">
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinButton" name="agc_gain_s" base="EditSpinButton">
- <events>
- <handler event="EVT_SPIN_UP">agc_gain_up</handler>
- <handler event="EVT_SPIN_DOWN">agc_gain_down</handler>
- </events>
- </object>
- </object>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxBoxSizer" name="sizer_7" base="EditBoxSizer">
- <orient>wxHORIZONTAL</orient>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxTextCtrl" name="agc_ref" base="EditTextCtrl">
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinButton" name="agc_ref_s" base="EditSpinButton">
- <events>
- <handler event="EVT_SPIN_UP">agc_ref_up</handler>
- <handler event="EVT_SPIN_DOWN">agc_ref_down</handler>
- </events>
- </object>
- </object>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxBoxSizer" name="sizer_5" base="EditBoxSizer">
- <orient>wxHORIZONTAL</orient>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxTextCtrl" name="bandwidth" base="EditTextCtrl">
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxSpinButton" name="bw_spin" base="EditSpinButton">
- <events>
- <handler event="EVT_SPIN_UP">bw_up</handler>
- <handler event="EVT_SPIN_DOWN">bw_down</handler>
- </events>
- </object>
- </object>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>0</option>
- <object class="wxStaticText" name="label_9" base="EditStaticText">
- <attribute>1</attribute>
- </object>
- </object>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND|wxADJUST_MINSIZE</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxGauge" name="rssi" base="EditGauge">
- <foreground>#ff0000</foreground>
- <style>wxGA_HORIZONTAL|wxGA_SMOOTH</style>
- <range>10</range>
- <size>315, 10</size>
- </object>
- </object>
- </object>
- </object>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxPanel" name="fe_panel" base="EditPanel">
- <style>wxTAB_TRAVERSAL</style>
- </object>
- </object>
- <object class="sizeritem">
- <flag>wxEXPAND</flag>
- <border>0</border>
- <option>1</option>
- <object class="wxPanel" name="if_panel" base="EditPanel">
- <style>wxTAB_TRAVERSAL</style>
- </object>
- </object>
- </object>
- </object>
-</application>
diff --git a/gr-uhd/apps/hf_radio/ssb_taps b/gr-uhd/apps/hf_radio/ssb_taps
deleted file mode 100644
index 0ef3bbf267..0000000000
--- a/gr-uhd/apps/hf_radio/ssb_taps
+++ /dev/null
@@ -1,1023 +0,0 @@
--0.000035-0.000009j
--0.000066-0.000020j
--0.000080-0.000044j
--0.000084-0.000071j
--0.000077-0.000100j
--0.000063-0.000127j
--0.000041-0.000150j
--0.000013-0.000167j
-0.000020-0.000177j
-0.000054-0.000180j
-0.000089-0.000174j
-0.000121-0.000161j
-0.000150-0.000140j
-0.000173-0.000113j
-0.000188-0.000081j
-0.000196-0.000046j
-0.000194-0.000011j
-0.000184+0.000022j
-0.000165+0.000052j
-0.000139+0.000077j
-0.000107+0.000093j
-0.000071+0.000102j
-0.000034+0.000101j
--0.000002+0.000090j
--0.000036+0.000070j
--0.000064+0.000042j
--0.000086+0.000006j
--0.000098-0.000034j
--0.000101-0.000077j
--0.000093-0.000120j
--0.000076-0.000161j
--0.000049-0.000197j
--0.000014-0.000227j
-0.000026-0.000248j
-0.000071-0.000259j
-0.000117-0.000259j
-0.000162-0.000249j
-0.000203-0.000228j
-0.000237-0.000199j
-0.000263-0.000162j
-0.000279-0.000120j
-0.000284-0.000075j
-0.000278-0.000031j
-0.000260+0.000010j
-0.000232+0.000045j
-0.000196+0.000073j
-0.000153+0.000090j
-0.000106+0.000095j
-0.000059+0.000089j
-0.000014+0.000071j
--0.000027+0.000041j
--0.000059+0.000002j
--0.000082-0.000046j
--0.000093-0.000098j
--0.000091-0.000152j
--0.000077-0.000206j
--0.000050-0.000255j
--0.000012-0.000298j
-0.000034-0.000330j
-0.000088-0.000351j
-0.000145-0.000359j
-0.000202-0.000354j
-0.000256-0.000335j
-0.000304-0.000304j
-0.000343-0.000262j
-0.000370-0.000213j
-0.000384-0.000158j
-0.000384-0.000102j
-0.000369-0.000048j
-0.000341+0.000002j
-0.000302+0.000042j
-0.000252+0.000072j
-0.000196+0.000088j
-0.000137+0.000089j
-0.000078+0.000075j
-0.000024+0.000047j
--0.000023+0.000005j
--0.000059-0.000048j
--0.000082-0.000109j
--0.000090-0.000175j
--0.000081-0.000242j
--0.000058-0.000306j
--0.000019-0.000364j
-0.000032-0.000411j
-0.000093-0.000445j
-0.000161-0.000465j
-0.000232-0.000467j
-0.000301-0.000453j
-0.000365-0.000423j
-0.000419-0.000379j
-0.000461-0.000323j
-0.000487-0.000259j
-0.000497-0.000190j
-0.000489-0.000121j
-0.000464-0.000056j
-0.000423+0.000001j
-0.000369+0.000046j
-0.000304+0.000076j
-0.000233+0.000089j
-0.000160+0.000083j
-0.000089+0.000060j
-0.000025+0.000018j
--0.000027-0.000038j
--0.000065-0.000107j
--0.000086-0.000185j
--0.000088-0.000266j
--0.000071-0.000347j
--0.000035-0.000422j
-0.000019-0.000487j
-0.000086-0.000538j
-0.000164-0.000573j
-0.000248-0.000588j
-0.000334-0.000582j
-0.000415-0.000557j
-0.000488-0.000513j
-0.000548-0.000452j
-0.000592-0.000379j
-0.000616-0.000297j
-0.000619-0.000213j
-0.000600-0.000130j
-0.000561-0.000054j
-0.000504+0.000010j
-0.000432+0.000058j
-0.000350+0.000086j
-0.000261+0.000093j
-0.000173+0.000078j
-0.000090+0.000040j
-0.000017-0.000017j
--0.000040-0.000092j
--0.000078-0.000180j
--0.000095-0.000275j
--0.000088-0.000374j
--0.000058-0.000469j
--0.000006-0.000555j
-0.000065-0.000627j
-0.000152-0.000681j
-0.000250-0.000712j
-0.000352-0.000720j
-0.000454-0.000703j
-0.000548-0.000663j
-0.000630-0.000601j
-0.000694-0.000521j
-0.000737-0.000428j
-0.000755-0.000327j
-0.000748-0.000225j
-0.000715-0.000128j
-0.000659-0.000042j
-0.000582+0.000028j
-0.000490+0.000077j
-0.000387+0.000101j
-0.000280+0.000099j
-0.000175+0.000070j
-0.000080+0.000015j
--0.000001-0.000063j
--0.000061-0.000159j
--0.000097-0.000268j
--0.000106-0.000385j
--0.000087-0.000501j
--0.000040-0.000611j
-0.000032-0.000708j
-0.000125-0.000786j
-0.000235-0.000839j
-0.000354-0.000866j
-0.000477-0.000863j
-0.000595-0.000831j
-0.000702-0.000772j
-0.000792-0.000688j
-0.000859-0.000585j
-0.000898-0.000469j
-0.000907-0.000347j
-0.000886-0.000227j
-0.000835-0.000115j
-0.000757-0.000019j
-0.000657+0.000055j
-0.000540+0.000102j
-0.000415+0.000119j
-0.000287+0.000103j
-0.000165+0.000056j
-0.000058-0.000020j
--0.000029-0.000122j
--0.000090-0.000243j
--0.000121-0.000378j
--0.000118-0.000517j
--0.000082-0.000653j
--0.000014-0.000778j
-0.000082-0.000885j
-0.000201-0.000966j
-0.000337-0.001017j
-0.000481-0.001034j
-0.000626-0.001016j
-0.000762-0.000965j
-0.000882-0.000882j
-0.000978-0.000772j
-0.001044-0.000643j
-0.001076-0.000501j
-0.001072-0.000355j
-0.001032-0.000215j
-0.000958-0.000089j
-0.000854+0.000016j
-0.000726+0.000091j
-0.000582+0.000133j
-0.000431+0.000138j
-0.000281+0.000105j
-0.000143+0.000035j
-0.000024-0.000068j
--0.000068-0.000199j
--0.000126-0.000350j
--0.000147-0.000513j
--0.000128-0.000677j
--0.000070-0.000834j
-0.000024-0.000974j
-0.000150-0.001089j
-0.000300-0.001171j
-0.000465-0.001216j
-0.000637-0.001219j
-0.000805-0.001182j
-0.000960-0.001105j
-0.001091-0.000993j
-0.001191-0.000853j
-0.001253-0.000692j
-0.001274-0.000521j
-0.001252-0.000350j
-0.001188-0.000189j
-0.001085-0.000049j
-0.000950+0.000062j
-0.000790+0.000136j
-0.000614+0.000168j
-0.000435+0.000156j
-0.000261+0.000099j
-0.000105+0.000000j
--0.000024-0.000136j
--0.000117-0.000301j
--0.000169-0.000486j
--0.000175-0.000680j
--0.000134-0.000872j
--0.000048-0.001051j
-0.000079-0.001206j
-0.000240-0.001326j
-0.000426-0.001406j
-0.000626-0.001439j
-0.000829-0.001424j
-0.001022-0.001361j
-0.001195-0.001252j
-0.001336-0.001106j
-0.001437-0.000929j
-0.001491-0.000733j
-0.001496-0.000529j
-0.001449-0.000330j
-0.001354-0.000148j
-0.001217+0.000005j
-0.001044+0.000120j
-0.000846+0.000188j
-0.000635+0.000206j
-0.000424+0.000170j
-0.000226+0.000083j
-0.000053-0.000053j
--0.000084-0.000228j
--0.000176-0.000434j
--0.000216-0.000659j
--0.000201-0.000889j
--0.000131-0.001111j
--0.000009-0.001312j
-0.000158-0.001480j
-0.000362-0.001604j
-0.000590-0.001677j
-0.000829-0.001694j
-0.001066-0.001653j
-0.001286-0.001556j
-0.001477-0.001408j
-0.001626-0.001219j
-0.001724-0.001000j
-0.001765-0.000762j
-0.001746-0.000522j
-0.001668-0.000293j
-0.001534-0.000090j
-0.001353+0.000075j
-0.001135+0.000190j
-0.000893+0.000247j
-0.000642+0.000243j
-0.000396+0.000176j
-0.000172+0.000049j
--0.000017-0.000131j
--0.000159-0.000355j
--0.000244-0.000609j
--0.000266-0.000880j
--0.000222-0.001151j
--0.000114-0.001406j
-0.000053-0.001630j
-0.000270-0.001810j
-0.000524-0.001934j
-0.000802-0.001994j
-0.001087-0.001987j
-0.001362-0.001911j
-0.001611-0.001772j
-0.001819-0.001576j
-0.001973-0.001336j
-0.002063-0.001065j
-0.002084-0.000779j
-0.002033-0.000497j
-0.001914-0.000236j
-0.001732-0.000011j
-0.001498+0.000162j
-0.001225+0.000272j
-0.000931+0.000312j
-0.000633+0.000277j
-0.000349+0.000168j
-0.000097-0.000009j
--0.000107-0.000246j
--0.000250-0.000528j
--0.000322-0.000841j
--0.000316-0.001166j
--0.000233-0.001484j
--0.000076-0.001775j
-0.000148-0.002024j
-0.000426-0.002213j
-0.000743-0.002332j
-0.001080-0.002373j
-0.001418-0.002332j
-0.001736-0.002211j
-0.002017-0.002017j
-0.002241-0.001760j
-0.002397-0.001457j
-0.002473-0.001124j
-0.002464-0.000783j
-0.002371-0.000453j
-0.002198-0.000156j
-0.001954+0.000091j
-0.001654+0.000269j
-0.001316+0.000369j
-0.000959+0.000381j
-0.000606+0.000303j
-0.000279+0.000139j
--0.000003-0.000103j
--0.000220-0.000411j
--0.000359-0.000768j
--0.000408-0.001152j
--0.000365-0.001542j
--0.000229-0.001915j
--0.000006-0.002248j
-0.000292-0.002522j
-0.000648-0.002719j
-0.001042-0.002826j
-0.001452-0.002837j
-0.001853-0.002750j
-0.002223-0.002569j
-0.002537-0.002304j
-0.002778-0.001971j
-0.002930-0.001588j
-0.002984-0.001179j
-0.002933-0.000770j
-0.002782-0.000384j
-0.002538-0.000046j
-0.002215+0.000222j
-0.001831+0.000402j
-0.001410+0.000481j
-0.000976+0.000452j
-0.000557+0.000316j
-0.000179+0.000077j
--0.000134-0.000252j
--0.000362-0.000654j
--0.000490-0.001105j
--0.000506-0.001580j
--0.000407-0.002052j
--0.000197-0.002492j
-0.000113-0.002875j
-0.000508-0.003176j
-0.000966-0.003377j
-0.001460-0.003464j
-0.001963-0.003432j
-0.002444-0.003281j
-0.002876-0.003019j
-0.003231-0.002659j
-0.003488-0.002224j
-0.003631-0.001739j
-0.003649-0.001233j
-0.003540-0.000737j
-0.003309-0.000282j
-0.002969+0.000103j
-0.002539+0.000393j
-0.002044+0.000568j
-0.001515+0.000614j
-0.000982+0.000525j
-0.000480+0.000304j
-0.000039-0.000039j
--0.000311-0.000487j
--0.000547-0.001016j
--0.000652-0.001595j
--0.000615-0.002193j
--0.000436-0.002773j
--0.000122-0.003301j
-0.000311-0.003746j
-0.000842-0.004081j
-0.001440-0.004282j
-0.002071-0.004338j
-0.002700-0.004243j
-0.003289-0.004000j
-0.003803-0.003622j
-0.004210-0.003132j
-0.004485-0.002556j
-0.004610-0.001930j
-0.004574-0.001291j
-0.004379-0.000679j
-0.004034-0.000133j
-0.003558+0.000313j
-0.002977+0.000627j
-0.002327+0.000787j
-0.001647+0.000779j
-0.000977+0.000598j
-0.000360+0.000250j
--0.000163-0.000249j
--0.000559-0.000872j
--0.000799-0.001587j
--0.000864-0.002354j
--0.000744-0.003129j
--0.000442-0.003866j
-0.000031-0.004522j
-0.000651-0.005057j
-0.001385-0.005437j
-0.002193-0.005637j
-0.003030-0.005643j
-0.003848-0.005451j
-0.004597-0.005069j
-0.005234-0.004519j
-0.005718-0.003830j
-0.006019-0.003044j
-0.006114-0.002206j
-0.005997-0.001368j
-0.005669-0.000583j
-0.005147+0.000099j
-0.004460+0.000631j
-0.003647+0.000975j
-0.002757+0.001105j
-0.001842+0.001003j
-0.000961+0.000668j
-0.000168+0.000111j
--0.000482-0.000643j
--0.000944-0.001555j
--0.001183-0.002578j
--0.001176-0.003656j
--0.000912-0.004727j
--0.000397-0.005728j
-0.000346-0.006601j
-0.001284-0.007292j
-0.002368-0.007755j
-0.003540-0.007959j
-0.004735-0.007886j
-0.005885-0.007535j
-0.006922-0.006922j
-0.007782-0.006078j
-0.008412-0.005050j
-0.008769-0.003898j
-0.008825-0.002691j
-0.008572-0.001504j
-0.008016-0.000412j
-0.007185+0.000510j
-0.006123+0.001196j
-0.004891+0.001591j
-0.003560+0.001657j
-0.002212+0.001372j
-0.000933+0.000734j
--0.000192-0.000236j
--0.001083-0.001500j
--0.001672-0.002998j
--0.001905-0.004655j
--0.001747-0.006384j
--0.001182-0.008090j
--0.000222-0.009676j
-0.001101-0.011045j
-0.002732-0.012114j
-0.004593-0.012810j
-0.006591-0.013081j
-0.008621-0.012896j
-0.010571-0.012253j
-0.012328-0.011175j
-0.013785-0.009712j
-0.014847-0.007941j
-0.015438-0.005962j
-0.015507-0.003893j
-0.015029-0.001863j
-0.014011-0.000011j
-0.012494+0.001529j
-0.010549+0.002630j
-0.008277+0.003179j
-0.005809+0.003090j
-0.003294+0.002304j
-0.000896+0.000795j
--0.001212-0.001423j
--0.002859-0.004299j
--0.003886-0.007744j
--0.004151-0.011630j
--0.003539-0.015799j
--0.001969-0.020066j
-0.000601-0.024225j
-0.004168-0.028064j
-0.008684-0.031367j
-0.014056-0.033927j
-0.020145-0.035558j
-0.026775-0.036101j
-0.033735-0.035433j
-0.040789-0.033475j
-0.047684-0.030197j
-0.054164-0.025619j
-0.059974-0.019815j
-0.064878-0.012907j
-0.068665-0.005067j
-0.071159+0.003494j
-0.072228+0.012531j
-0.071791+0.021776j
-0.069818+0.030947j
-0.066339+0.039761j
-0.061435+0.047944j
-0.055243+0.055243j
-0.047944+0.061435j
-0.039761+0.066339j
-0.030947+0.069818j
-0.021776+0.071791j
-0.012531+0.072228j
-0.003494+0.071159j
--0.005067+0.068665j
--0.012907+0.064878j
--0.019815+0.059974j
--0.025619+0.054164j
--0.030197+0.047684j
--0.033475+0.040789j
--0.035433+0.033735j
--0.036101+0.026775j
--0.035558+0.020145j
--0.033927+0.014056j
--0.031367+0.008684j
--0.028064+0.004168j
--0.024225+0.000601j
--0.020066-0.001969j
--0.015799-0.003539j
--0.011630-0.004151j
--0.007744-0.003886j
--0.004299-0.002859j
--0.001423-0.001212j
-0.000795+0.000896j
-0.002304+0.003294j
-0.003090+0.005809j
-0.003179+0.008277j
-0.002630+0.010549j
-0.001529+0.012494j
--0.000011+0.014011j
--0.001863+0.015029j
--0.003893+0.015507j
--0.005962+0.015438j
--0.007941+0.014847j
--0.009712+0.013785j
--0.011175+0.012328j
--0.012253+0.010571j
--0.012896+0.008621j
--0.013081+0.006591j
--0.012810+0.004593j
--0.012114+0.002732j
--0.011045+0.001101j
--0.009676-0.000222j
--0.008090-0.001182j
--0.006384-0.001747j
--0.004655-0.001905j
--0.002998-0.001672j
--0.001500-0.001083j
--0.000236-0.000192j
-0.000734+0.000933j
-0.001372+0.002212j
-0.001657+0.003560j
-0.001591+0.004891j
-0.001196+0.006123j
-0.000510+0.007185j
--0.000412+0.008016j
--0.001504+0.008572j
--0.002691+0.008825j
--0.003898+0.008769j
--0.005050+0.008412j
--0.006078+0.007782j
--0.006922+0.006922j
--0.007535+0.005885j
--0.007886+0.004735j
--0.007959+0.003540j
--0.007755+0.002368j
--0.007292+0.001284j
--0.006601+0.000346j
--0.005728-0.000397j
--0.004727-0.000912j
--0.003656-0.001176j
--0.002578-0.001183j
--0.001555-0.000944j
--0.000643-0.000482j
-0.000111+0.000168j
-0.000668+0.000961j
-0.001003+0.001842j
-0.001105+0.002757j
-0.000975+0.003647j
-0.000631+0.004460j
-0.000099+0.005147j
--0.000583+0.005669j
--0.001368+0.005997j
--0.002206+0.006114j
--0.003044+0.006019j
--0.003830+0.005718j
--0.004519+0.005234j
--0.005069+0.004597j
--0.005451+0.003848j
--0.005643+0.003030j
--0.005637+0.002193j
--0.005437+0.001385j
--0.005057+0.000651j
--0.004522+0.000031j
--0.003866-0.000442j
--0.003129-0.000744j
--0.002354-0.000864j
--0.001587-0.000799j
--0.000872-0.000559j
--0.000249-0.000163j
-0.000250+0.000360j
-0.000598+0.000977j
-0.000779+0.001647j
-0.000787+0.002327j
-0.000627+0.002977j
-0.000313+0.003558j
--0.000133+0.004034j
--0.000679+0.004379j
--0.001291+0.004574j
--0.001930+0.004610j
--0.002556+0.004485j
--0.003132+0.004210j
--0.003622+0.003803j
--0.004000+0.003289j
--0.004243+0.002700j
--0.004338+0.002071j
--0.004282+0.001440j
--0.004081+0.000842j
--0.003746+0.000311j
--0.003301-0.000122j
--0.002773-0.000436j
--0.002193-0.000615j
--0.001595-0.000652j
--0.001016-0.000547j
--0.000487-0.000311j
--0.000039+0.000039j
-0.000304+0.000480j
-0.000525+0.000982j
-0.000614+0.001515j
-0.000568+0.002044j
-0.000393+0.002539j
-0.000103+0.002969j
--0.000282+0.003309j
--0.000737+0.003540j
--0.001233+0.003649j
--0.001739+0.003631j
--0.002224+0.003488j
--0.002659+0.003231j
--0.003019+0.002876j
--0.003281+0.002444j
--0.003432+0.001963j
--0.003464+0.001460j
--0.003377+0.000966j
--0.003176+0.000508j
--0.002875+0.000113j
--0.002492-0.000197j
--0.002052-0.000407j
--0.001580-0.000506j
--0.001105-0.000490j
--0.000654-0.000362j
--0.000252-0.000134j
-0.000077+0.000179j
-0.000316+0.000557j
-0.000452+0.000976j
-0.000481+0.001410j
-0.000402+0.001831j
-0.000222+0.002215j
--0.000046+0.002538j
--0.000384+0.002782j
--0.000770+0.002933j
--0.001179+0.002984j
--0.001588+0.002930j
--0.001971+0.002778j
--0.002304+0.002537j
--0.002569+0.002223j
--0.002750+0.001853j
--0.002837+0.001452j
--0.002826+0.001042j
--0.002719+0.000648j
--0.002522+0.000292j
--0.002248-0.000006j
--0.001915-0.000229j
--0.001542-0.000365j
--0.001152-0.000408j
--0.000768-0.000359j
--0.000411-0.000220j
--0.000103-0.000003j
-0.000139+0.000279j
-0.000303+0.000606j
-0.000381+0.000959j
-0.000369+0.001316j
-0.000269+0.001654j
-0.000091+0.001954j
--0.000156+0.002198j
--0.000453+0.002371j
--0.000783+0.002464j
--0.001124+0.002473j
--0.001457+0.002397j
--0.001760+0.002241j
--0.002017+0.002017j
--0.002211+0.001736j
--0.002332+0.001418j
--0.002373+0.001080j
--0.002332+0.000743j
--0.002213+0.000426j
--0.002024+0.000148j
--0.001775-0.000076j
--0.001484-0.000233j
--0.001166-0.000316j
--0.000841-0.000322j
--0.000528-0.000250j
--0.000246-0.000107j
--0.000009+0.000097j
-0.000168+0.000349j
-0.000277+0.000633j
-0.000312+0.000931j
-0.000272+0.001225j
-0.000162+0.001498j
--0.000011+0.001732j
--0.000236+0.001914j
--0.000497+0.002033j
--0.000779+0.002084j
--0.001065+0.002063j
--0.001336+0.001973j
--0.001576+0.001819j
--0.001772+0.001611j
--0.001911+0.001362j
--0.001987+0.001087j
--0.001994+0.000802j
--0.001934+0.000524j
--0.001810+0.000270j
--0.001630+0.000053j
--0.001406-0.000114j
--0.001151-0.000222j
--0.000880-0.000266j
--0.000609-0.000244j
--0.000355-0.000159j
--0.000131-0.000017j
-0.000049+0.000172j
-0.000176+0.000396j
-0.000243+0.000642j
-0.000247+0.000893j
-0.000190+0.001135j
-0.000075+0.001353j
--0.000090+0.001534j
--0.000293+0.001668j
--0.000522+0.001746j
--0.000762+0.001765j
--0.001000+0.001724j
--0.001219+0.001626j
--0.001408+0.001477j
--0.001556+0.001286j
--0.001653+0.001066j
--0.001694+0.000829j
--0.001677+0.000590j
--0.001604+0.000362j
--0.001480+0.000158j
--0.001312-0.000009j
--0.001111-0.000131j
--0.000889-0.000201j
--0.000659-0.000216j
--0.000434-0.000176j
--0.000228-0.000084j
--0.000053+0.000053j
-0.000083+0.000226j
-0.000170+0.000424j
-0.000206+0.000635j
-0.000188+0.000846j
-0.000120+0.001044j
-0.000005+0.001217j
--0.000148+0.001354j
--0.000330+0.001449j
--0.000529+0.001496j
--0.000733+0.001491j
--0.000929+0.001437j
--0.001106+0.001336j
--0.001252+0.001195j
--0.001361+0.001022j
--0.001424+0.000829j
--0.001439+0.000626j
--0.001406+0.000426j
--0.001326+0.000240j
--0.001206+0.000079j
--0.001051-0.000048j
--0.000872-0.000134j
--0.000680-0.000175j
--0.000486-0.000169j
--0.000301-0.000117j
--0.000136-0.000024j
-0.000000+0.000105j
-0.000099+0.000261j
-0.000156+0.000435j
-0.000168+0.000614j
-0.000136+0.000790j
-0.000062+0.000950j
--0.000049+0.001085j
--0.000189+0.001188j
--0.000350+0.001252j
--0.000521+0.001274j
--0.000692+0.001253j
--0.000853+0.001191j
--0.000993+0.001091j
--0.001105+0.000960j
--0.001182+0.000805j
--0.001219+0.000637j
--0.001216+0.000465j
--0.001171+0.000300j
--0.001089+0.000150j
--0.000974+0.000024j
--0.000834-0.000070j
--0.000677-0.000128j
--0.000513-0.000147j
--0.000350-0.000126j
--0.000199-0.000068j
--0.000068+0.000024j
-0.000035+0.000143j
-0.000105+0.000281j
-0.000138+0.000431j
-0.000133+0.000582j
-0.000091+0.000726j
-0.000016+0.000854j
--0.000089+0.000958j
--0.000215+0.001032j
--0.000355+0.001072j
--0.000501+0.001076j
--0.000643+0.001044j
--0.000772+0.000978j
--0.000882+0.000882j
--0.000965+0.000762j
--0.001016+0.000626j
--0.001034+0.000481j
--0.001017+0.000337j
--0.000966+0.000201j
--0.000885+0.000082j
--0.000778-0.000014j
--0.000653-0.000082j
--0.000517-0.000118j
--0.000378-0.000121j
--0.000243-0.000090j
--0.000122-0.000029j
--0.000020+0.000058j
-0.000056+0.000165j
-0.000103+0.000287j
-0.000119+0.000415j
-0.000102+0.000540j
-0.000055+0.000657j
--0.000019+0.000757j
--0.000115+0.000835j
--0.000227+0.000886j
--0.000347+0.000907j
--0.000469+0.000898j
--0.000585+0.000859j
--0.000688+0.000792j
--0.000772+0.000702j
--0.000831+0.000595j
--0.000863+0.000477j
--0.000866+0.000354j
--0.000839+0.000235j
--0.000786+0.000125j
--0.000708+0.000032j
--0.000611-0.000040j
--0.000501-0.000087j
--0.000385-0.000106j
--0.000268-0.000097j
--0.000159-0.000061j
--0.000063-0.000001j
-0.000015+0.000080j
-0.000070+0.000175j
-0.000099+0.000280j
-0.000101+0.000387j
-0.000077+0.000490j
-0.000028+0.000582j
--0.000042+0.000659j
--0.000128+0.000715j
--0.000225+0.000748j
--0.000327+0.000755j
--0.000428+0.000737j
--0.000521+0.000694j
--0.000601+0.000630j
--0.000663+0.000548j
--0.000703+0.000454j
--0.000720+0.000352j
--0.000712+0.000250j
--0.000681+0.000152j
--0.000627+0.000065j
--0.000555-0.000006j
--0.000469-0.000058j
--0.000374-0.000088j
--0.000275-0.000095j
--0.000180-0.000078j
--0.000092-0.000040j
--0.000017+0.000017j
-0.000040+0.000090j
-0.000078+0.000173j
-0.000093+0.000261j
-0.000086+0.000350j
-0.000058+0.000432j
-0.000010+0.000504j
--0.000054+0.000561j
--0.000130+0.000600j
--0.000213+0.000619j
--0.000297+0.000616j
--0.000379+0.000592j
--0.000452+0.000548j
--0.000513+0.000488j
--0.000557+0.000415j
--0.000582+0.000334j
--0.000588+0.000248j
--0.000573+0.000164j
--0.000538+0.000086j
--0.000487+0.000019j
--0.000422-0.000035j
--0.000347-0.000071j
--0.000266-0.000088j
--0.000185-0.000086j
--0.000107-0.000065j
--0.000038-0.000027j
-0.000018+0.000025j
-0.000060+0.000089j
-0.000083+0.000160j
-0.000089+0.000233j
-0.000076+0.000304j
-0.000046+0.000369j
-0.000001+0.000423j
--0.000056+0.000464j
--0.000121+0.000489j
--0.000190+0.000497j
--0.000259+0.000487j
--0.000323+0.000461j
--0.000379+0.000419j
--0.000423+0.000365j
--0.000453+0.000301j
--0.000467+0.000232j
--0.000465+0.000161j
--0.000445+0.000093j
--0.000411+0.000032j
--0.000364-0.000019j
--0.000306-0.000058j
--0.000242-0.000081j
--0.000175-0.000090j
--0.000109-0.000082j
--0.000048-0.000059j
-0.000005-0.000023j
-0.000047+0.000024j
-0.000075+0.000078j
-0.000089+0.000137j
-0.000088+0.000196j
-0.000072+0.000252j
-0.000042+0.000302j
-0.000002+0.000341j
--0.000048+0.000369j
--0.000102+0.000384j
--0.000158+0.000384j
--0.000213+0.000370j
--0.000262+0.000343j
--0.000304+0.000304j
--0.000335+0.000256j
--0.000354+0.000202j
--0.000359+0.000145j
--0.000351+0.000088j
--0.000330+0.000034j
--0.000298-0.000012j
--0.000255-0.000050j
--0.000206-0.000077j
--0.000152-0.000091j
--0.000098-0.000093j
--0.000046-0.000082j
-0.000002-0.000059j
-0.000041-0.000027j
-0.000071+0.000014j
-0.000089+0.000059j
-0.000095+0.000106j
-0.000090+0.000153j
-0.000073+0.000196j
-0.000045+0.000232j
-0.000010+0.000260j
--0.000031+0.000278j
--0.000075+0.000284j
--0.000120+0.000279j
--0.000162+0.000263j
--0.000199+0.000237j
--0.000228+0.000203j
--0.000249+0.000162j
--0.000259+0.000117j
--0.000259+0.000071j
--0.000248+0.000026j
--0.000227-0.000014j
--0.000197-0.000049j
--0.000161-0.000076j
--0.000120-0.000093j
--0.000077-0.000101j
--0.000034-0.000098j
-0.000006-0.000086j
-0.000042-0.000064j
-0.000070-0.000036j
-0.000090-0.000002j
-0.000101+0.000034j
-0.000102+0.000071j
-0.000093+0.000107j
-0.000077+0.000139j
-0.000052+0.000165j
-0.000022+0.000184j
--0.000011+0.000194j
--0.000046+0.000196j
--0.000081+0.000188j
--0.000113+0.000173j
--0.000140+0.000150j
--0.000161+0.000121j
--0.000174+0.000089j
--0.000180+0.000054j
--0.000177+0.000020j
--0.000167-0.000013j
--0.000150-0.000041j
--0.000127-0.000063j
--0.000100-0.000077j
--0.000071-0.000084j
--0.000044-0.000080j
--0.000020-0.000066j
--0.000009-0.000035j
diff --git a/gr-uhd/apps/hf_radio/ssbagc.py b/gr-uhd/apps/hf_radio/ssbagc.py
deleted file mode 100644
index 48cc009101..0000000000
--- a/gr-uhd/apps/hf_radio/ssbagc.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-
-
-# post detection agc processing
-#
-# This agc strategy is copied more or less verbatim from
-# weaver_isb_am1_usrp3.py by cswiger.
-#
-# Thanks.
-#
-# Then modified in a variety of ways.
-#
-# There doesn't appear to be a way to hook multiple blocks to the
-# input port when building a hier block like this. Thus the
-# split below.
-#
-# Basic operation.
-# Power is estimated by squaring the input.
-# Low pass filter using a 1 pole iir.
-# The time constant can be tweaked by changing the taps.
-# Currently there is no implementation to change this while operating
-# a potentially useful addition.
-# The log block turns this into dB
-# gain adjusts the agc authority.
-#
-# M. Revnell 2006-Jan
-
-from gnuradio import gr
-from gnuradio import blocks
-from gnuradio import filter
-
-class agc( gr.hier_block2 ):
- def __init__( self ):
- gr.hier_block2.__init__(self, "agc",
- gr.io_signature(1,1,gr.sizeof_float),
- gr.io_signature(1,1,gr.sizeof_float))
-
- self.split = blocks.multiply_const_ff( 1 )
- self.sqr = blocks.multiply_ff( )
- self.int0 = filter.iir_filter_ffd( [.004, 0], [0, .999] )
- self.offs = blocks.add_const_ff( -30 )
- self.gain = blocks.multiply_const_ff( 70 )
- self.log = blocks.nlog10_ff( 10, 1 )
- self.agc = blocks.divide_ff( )
-
- self.connect(self, self.split)
- self.connect(self.split, (self.agc, 0))
- self.connect(self.split, (self.sqr, 0))
- self.connect(self.split, (self.sqr, 1))
- self.connect(self.sqr, self.int0)
- self.connect(self.int0, self.log)
- self.connect(self.log, self.offs)
- self.connect(self.offs, self.gain)
- self.connect(self.gain, (self.agc, 1))
- self.connect(self.agc, self)
diff --git a/gr-uhd/apps/hf_radio/ssbdemod.py b/gr-uhd/apps/hf_radio/ssbdemod.py
deleted file mode 100644
index d364f5e0ec..0000000000
--- a/gr-uhd/apps/hf_radio/ssbdemod.py
+++ /dev/null
@@ -1,118 +0,0 @@
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-# This tries to push the hilbert transform for ssb demod back into the
-# freq. xlating filter.
-#
-# The starting point for this was weaver_isb_am1_usrp3.py.
-#
-# The tap coefficients for freq_xlating_fir_filter_ccf were generated
-# externally and are read from a file because I didn't want to learn how
-# to make fir filters with arbitrary phase response using python numeric
-# facilities.
-#
-# They were generated using Scilab which I am already familiar with.
-# M. Revnell Jan 06
-
-from gnuradio import gr
-from gnuradio import blocks
-from gnuradio import filter
-
-class ssb_demod( gr.hier_block2 ):
- def __init__( self, if_rate, af_rate ):
- gr.hier_block2.__init__(self, "ssb_demod",
- gr.io_signature(1,1,gr.sizeof_gr_complex),
- gr.io_signature(1,1,gr.sizeof_float))
-
- self.if_rate = int(if_rate)
- self.af_rate = int(af_rate)
- self.if_decim = int(if_rate / af_rate)
- self.sideband = 1
-
- self.xlate_taps = ([complex(v) for v in file('ssb_taps').readlines()])
-
- self.audio_taps = filter.firdes.low_pass(
- 1.0,
- self.af_rate,
- 3e3,
- 600,
- filter.firdes.WIN_HAMMING )
-
- self.xlate = filter.freq_xlating_fir_filter_ccc(
- self.if_decim,
- self.xlate_taps,
- 0,
- self.if_rate )
-
- self.split = blocks.complex_to_float()
-
- self.lpf = filter.fir_filter_fff(
- 1, self.audio_taps )
-
- self.sum = blocks.add_ff( )
- self.am_sel = blocks.multiply_const_ff( 0 )
- self.sb_sel = blocks.multiply_const_ff( 1 )
- self.mixer = blocks.add_ff()
- self.am_det = blocks.complex_to_mag()
-
- self.connect(self, self.xlate)
- self.connect(self.xlate, self.split)
- self.connect((self.split, 0), (self.sum, 0))
- self.connect((self.split, 1), (self.sum, 1))
- self.connect(self.sum, self.sb_sel)
- self.connect(self.xlate, self.am_det)
- self.connect(self.sb_sel, (self.mixer, 0))
- self.connect(self.am_det, self.am_sel)
- self.connect(self.am_sel, (self.mixer, 1))
- self.connect(self.mixer, self.lpf)
- self.connect(self.lpf, self)
-
- def upper_sb( self ):
- self.xlate.set_taps([v.conjugate() for v in self.xlate_taps])
- self.sb_sel.set_k( 1.0 )
- self.am_sel.set_k( 0.0 )
-
- def lower_sb( self ):
- self.xlate.set_taps(self.xlate_taps)
- self.sb_sel.set_k( 1.0 )
- self.am_sel.set_k( 0.0 )
-
- def set_am( self ):
- taps = filter.firdes.low_pass( 1.0,
- self.if_rate,
- 5e3,
- 2e3,
- filter.firdes.WIN_HAMMING )
- self.xlate.set_taps( taps )
- self.sb_sel.set_k( 0.0 )
- self.am_sel.set_k( 1.0 )
-
- def set_bw( self, bw ):
- self.audio_taps = filter.firdes.low_pass(
- 1.0,
- self.af_rate,
- bw,
- 600,
- filter.firdes.WIN_HAMMING )
- self.lpf.set_taps( self.audio_taps )
-
- def tune( self, freq ):
- self.xlate.set_center_freq( freq )
-
diff --git a/gr-uhd/apps/hf_radio/startup.py b/gr-uhd/apps/hf_radio/startup.py
deleted file mode 100644
index 093369b577..0000000000
--- a/gr-uhd/apps/hf_radio/startup.py
+++ /dev/null
@@ -1 +0,0 @@
-from radio import *
diff --git a/gr-uhd/apps/hf_radio/ui.py b/gr-uhd/apps/hf_radio/ui.py
deleted file mode 100755
index a20ba4faba..0000000000
--- a/gr-uhd/apps/hf_radio/ui.py
+++ /dev/null
@@ -1,316 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-# -*- coding: UTF-8 -*-
-# generated by wxGlade 0.4 on Mon Jan 2 19:02:03 2006
-
-import wx
-
-class ui_frame(wx.Frame):
- def __init__(self, *args, **kwds):
- # begin wxGlade: ui_frame.__init__
- kwds["style"] = wx.DEFAULT_FRAME_STYLE
- wx.Frame.__init__(self, *args, **kwds)
- self.sizer_1_staticbox = wx.StaticBox(self, -1, "sizer_1")
- self.freq_disp = wx.SpinCtrl(self, -1, "", min=0, max=100)
- self.spin_e6 = wx.SpinButton(self, -1 )
- self.spin_e5 = wx.SpinButton(self, -1 )
- self.spin_e4 = wx.SpinButton(self, -1 )
- self.spin_e3 = wx.SpinButton(self, -1 )
- self.spin_e2 = wx.SpinButton(self, -1 )
- self.spin_e1 = wx.SpinButton(self, -1 )
- self.spin_e0 = wx.SpinButton(self, -1 )
- self.panel_1 = wx.Panel(self, -1)
- self.panel_2 = wx.Panel(self, -1)
- self.button_lsb = wx.Button(self, -1, "LSB")
- self.button_usb = wx.Button(self, -1, "USB")
- self.button_am = wx.Button(self, -1, "AM")
- self.label_1 = wx.StaticText(self, -1, "VOLUME")
- self.label_2 = wx.StaticText(self, -1, "PGA")
- self.agc_level = wx.TextCtrl(self, -1, "")
- self.label_6 = wx.StaticText(self, -1, "")
- self.volume = wx.SpinCtrl(self, -1, "", min=0, max=100)
- self.pga = wx.SpinCtrl(self, -1, "", min=0, max=100)
- self.agc_max = wx.TextCtrl(self, -1, "")
- self.label_7 = wx.StaticText(self, -1, "")
- self.label_4 = wx.StaticText(self, -1, "AGC AUTHORITY")
- self.label_5 = wx.StaticText(self, -1, "AGC REF LVL")
- self.label_3 = wx.StaticText(self, -1, "BANDWIDTH")
- self.label_8 = wx.StaticText(self, -1, "")
- self.agc_gain = wx.TextCtrl(self, -1, "")
- self.agc_gain_s = wx.SpinButton(self, -1 )
- self.agc_ref = wx.TextCtrl(self, -1, "")
- self.agc_ref_s = wx.SpinButton(self, -1 )
- self.bandwidth = wx.TextCtrl(self, -1, "")
- self.bw_spin = wx.SpinButton(self, -1 )
- self.label_9 = wx.StaticText(self, -1, "")
- self.rssi = wx.Gauge(self, -1, 10, style=wx.GA_HORIZONTAL|wx.GA_SMOOTH)
- self.fe_panel = wx.Panel(self, -1)
- self.if_panel = wx.Panel(self, -1)
-
- self.__set_properties()
- self.__do_layout()
-
- self.Bind(wx.EVT_SPINCTRL, self.tune_evt, self.freq_disp)
- self.Bind(wx.EVT_SPIN_DOWN, self.down_e6, self.spin_e6)
- self.Bind(wx.EVT_SPIN_UP, self.up_e6, self.spin_e6)
- self.Bind(wx.EVT_SPIN_DOWN, self.down_e5, self.spin_e5)
- self.Bind(wx.EVT_SPIN_UP, self.up_e5, self.spin_e5)
- self.Bind(wx.EVT_SPIN_DOWN, self.down_e4, self.spin_e4)
- self.Bind(wx.EVT_SPIN_UP, self.up_e4, self.spin_e4)
- self.Bind(wx.EVT_SPIN_DOWN, self.down_e3, self.spin_e3)
- self.Bind(wx.EVT_SPIN_UP, self.up_e3, self.spin_e3)
- self.Bind(wx.EVT_SPIN_DOWN, self.down_e2, self.spin_e2)
- self.Bind(wx.EVT_SPIN_UP, self.up_e2, self.spin_e2)
- self.Bind(wx.EVT_SPIN_DOWN, self.down_e1, self.spin_e1)
- self.Bind(wx.EVT_SPIN_UP, self.up_e1, self.spin_e1)
- self.Bind(wx.EVT_SPIN_DOWN, self.down_e0, self.spin_e0)
- self.Bind(wx.EVT_SPIN_UP, self.up_e0, self.spin_e0)
- self.Bind(wx.EVT_BUTTON, self.set_lsb, self.button_lsb)
- self.Bind(wx.EVT_BUTTON, self.set_usb, self.button_usb)
- self.Bind(wx.EVT_BUTTON, self.set_am, self.button_am)
- self.Bind(wx.EVT_SPINCTRL, self.event_vol, self.volume)
- self.Bind(wx.EVT_SPINCTRL, self.event_pga, self.pga)
- self.Bind(wx.EVT_SPIN_DOWN, self.agc_gain_down, self.agc_gain_s)
- self.Bind(wx.EVT_SPIN_UP, self.agc_gain_up, self.agc_gain_s)
- self.Bind(wx.EVT_SPIN_DOWN, self.agc_ref_down, self.agc_ref_s)
- self.Bind(wx.EVT_SPIN_UP, self.agc_ref_up, self.agc_ref_s)
- self.Bind(wx.EVT_SPIN_DOWN, self.bw_down, self.bw_spin)
- self.Bind(wx.EVT_SPIN_UP, self.bw_up, self.bw_spin)
- # end wxGlade
-
- def __set_properties(self):
- # begin wxGlade: ui_frame.__set_properties
- self.SetTitle("frame_1")
- self.freq_disp.SetFont(wx.Font(32, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
- self.rssi.SetMinSize((315, 10))
- self.rssi.SetForegroundColour(wx.Colour(255, 0, 0))
- # end wxGlade
-
- def __do_layout(self):
- # begin wxGlade: ui_frame.__do_layout
- sizer_1 = wx.StaticBoxSizer(self.sizer_1_staticbox, wx.VERTICAL)
- sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
- sizer_4 = wx.BoxSizer(wx.VERTICAL)
- grid_sizer_4 = wx.GridSizer(2, 4, 0, 0)
- sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
- sizer_7 = wx.BoxSizer(wx.HORIZONTAL)
- sizer_6 = wx.BoxSizer(wx.HORIZONTAL)
- grid_sizer_3 = wx.GridSizer(2, 4, 0, 0)
- sizer_3 = wx.BoxSizer(wx.VERTICAL)
- grid_sizer_1 = wx.GridSizer(2, 3, 0, 0)
- grid_sizer_2 = wx.GridSizer(1, 7, 0, 0)
- sizer_3.Add(self.freq_disp, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
- grid_sizer_2.Add(self.spin_e6, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_2.Add(self.spin_e5, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_2.Add(self.spin_e4, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_2.Add(self.spin_e3, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_2.Add(self.spin_e2, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_2.Add(self.spin_e1, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_2.Add(self.spin_e0, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.panel_2, 1, wx.EXPAND, 0)
- grid_sizer_1.Add(self.button_lsb, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_1.Add(self.button_usb, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_1.Add(self.button_am, 0, wx.ADJUST_MINSIZE, 0)
- sizer_3.Add(grid_sizer_1, 1, wx.EXPAND, 0)
- sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
- grid_sizer_3.Add(self.label_1, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_3.Add(self.label_2, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_3.Add(self.agc_level, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_3.Add(self.label_6, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_3.Add(self.volume, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_3.Add(self.pga, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_3.Add(self.agc_max, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_3.Add(self.label_7, 0, wx.ADJUST_MINSIZE, 0)
- sizer_4.Add(grid_sizer_3, 1, wx.EXPAND, 0)
- grid_sizer_4.Add(self.label_4, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_4.Add(self.label_5, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_4.Add(self.label_3, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_4.Add(self.label_8, 0, wx.ADJUST_MINSIZE, 0)
- sizer_6.Add(self.agc_gain, 0, wx.ADJUST_MINSIZE, 0)
- sizer_6.Add(self.agc_gain_s, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_4.Add(sizer_6, 1, wx.EXPAND, 0)
- sizer_7.Add(self.agc_ref, 0, wx.ADJUST_MINSIZE, 0)
- sizer_7.Add(self.agc_ref_s, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_4.Add(sizer_7, 1, wx.EXPAND, 0)
- sizer_5.Add(self.bandwidth, 0, wx.ADJUST_MINSIZE, 0)
- sizer_5.Add(self.bw_spin, 0, wx.ADJUST_MINSIZE, 0)
- grid_sizer_4.Add(sizer_5, 1, wx.EXPAND, 0)
- grid_sizer_4.Add(self.label_9, 0, wx.ADJUST_MINSIZE, 0)
- sizer_4.Add(grid_sizer_4, 1, wx.EXPAND, 0)
- sizer_4.Add(self.rssi, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
- sizer_2.Add(sizer_4, 1, wx.EXPAND, 0)
- sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
- sizer_1.Add(self.fe_panel, 1, wx.EXPAND, 0)
- sizer_1.Add(self.if_panel, 1, wx.EXPAND, 0)
- self.SetAutoLayout(True)
- self.SetSizer(sizer_1)
- sizer_1.Fit(self)
- sizer_1.SetSizeHints(self)
- self.Layout()
- # end wxGlade
-
- def down_e6(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `down_e6' not implemented"
- event.Skip()
-
- def up_e6(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `up_e6' not implemented"
- event.Skip()
-
- def down_e5(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `down_e5' not implemented"
- event.Skip()
-
- def up_e5(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `up_e5' not implemented"
- event.Skip()
-
- def down_e4(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `down_e4' not implemented"
- event.Skip()
-
- def up_e4(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `up_e4' not implemented"
- event.Skip()
-
- def down_e3(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `down_e3' not implemented"
- event.Skip()
-
- def up_e3(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `up_e3' not implemented"
- event.Skip()
-
- def down_e2(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `down_e2' not implemented"
- event.Skip()
-
- def up_e2(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `up_e2' not implemented"
- event.Skip()
-
- def down_e1(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `down_e1' not implemented"
- event.Skip()
-
- def up_e1(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `up_e1' not implemented"
- event.Skip()
-
- def down_e0(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `down_e0' not implemented"
- event.Skip()
-
- def up_e0(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `up_e0' not implemented"
- event.Skip()
-
- def event_vol(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `event_vol' not implemented"
- event.Skip()
-
- def event_pga(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `event_pga' not implemented"
- event.Skip()
-
- def set_lsb(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `set_lsb' not implemented"
- event.Skip()
-
- def set_usb(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `set_usb' not implemented"
- event.Skip()
-
- def set_am(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `set_am' not implemented"
- event.Skip()
-
- def set_bw(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `set_bw' not implemented"
- event.Skip()
-
- def tune_evt(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `tune_evt' not implemented"
- event.Skip()
-
- def bw_down(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `bw_down' not implemented"
- event.Skip()
-
- def bw_up(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `bw_up' not implemented"
- event.Skip()
-
- def agc_gain_down(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `agc_gain_down' not implemented"
- event.Skip()
-
- def agc_gain_up(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `agc_gain_up' not implemented"
- event.Skip()
-
- def agc_ref_down(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `agc_ref_down' not implemented"
- event.Skip()
-
- def agc_ref_up(self, event): # wxGlade: ui_frame.<event_handler>
- print "Event handler `agc_ref_up' not implemented"
- event.Skip()
-
-# end of class ui_frame
-
-
-class RadioFrame(wx.Frame):
- def __init__(self, *args, **kwds):
- # content of this block not found: did you rename this class?
- pass
-
- def __set_properties(self):
- # content of this block not found: did you rename this class?
- pass
-
- def __do_layout(self):
- # content of this block not found: did you rename this class?
- pass
-
-# end of class RadioFrame
-
-
-class MyFrame(wx.Frame):
- def __init__(self, *args, **kwds):
- # content of this block not found: did you rename this class?
- pass
-
- def __set_properties(self):
- # content of this block not found: did you rename this class?
- pass
-
- def __do_layout(self):
- # content of this block not found: did you rename this class?
- pass
-
-# end of class MyFrame
-
-
diff --git a/gr-uhd/apps/uhd_fft_wx b/gr-uhd/apps/uhd_fft_wx
deleted file mode 100755
index 0e80de6bd8..0000000000
--- a/gr-uhd/apps/uhd_fft_wx
+++ /dev/null
@@ -1,348 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, gru
-from gnuradio import uhd
-from gnuradio import eng_notation
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-
-import sys
-import numpy
-
-try:
- from gnuradio.wxgui import stdgui2, form, slider
- from gnuradio.wxgui import forms
- from gnuradio.wxgui import fftsink2, waterfallsink2, scopesink2
- import wx
-except ImportError:
- sys.stderr.write("Error importing GNU Radio's wxgui. Please make sure gr-wxgui is installed.\n")
- sys.exit(1)
-
-class app_top_block(stdgui2.std_top_block):
- def __init__(self, frame, panel, vbox, argv):
- stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
-
- self.frame = frame
- self.panel = panel
-
- parser = OptionParser(option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args , [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6,
- help="set sample rate (bandwidth) [default=%default]")
- parser.add_option("-f", "--freq", type="eng_float", default=None,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-W", "--waterfall", action="store_true", default=False,
- help="Enable waterfall display")
- parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
- help="Enable oscilloscope display")
- parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1,
- help="Set fftsink averaging factor, default=[%default]")
- parser.add_option ("", "--averaging", action="store_true", default=False,
- help="Enable fftsink averaging, default=[%default]")
- parser.add_option("", "--ref-scale", type="eng_float", default=1.0,
- help="Set dBFS=0dB input value, default=[%default]")
- parser.add_option("", "--fft-size", type="int", default=1024,
- help="Set number of FFT bins [default=%default]")
- parser.add_option("", "--fft-rate", type="int", default=30,
- help="Set FFT update rate, [default=%default]")
- parser.add_option("", "--wire-format", type="string", default="sc16",
- help="Set wire format from USRP [default=%default]")
- parser.add_option("", "--stream-args", type="string", default="",
- help="Set additional stream args [default=%default]")
- parser.add_option("", "--show-async-msg", action="store_true", default=False,
- help="Show asynchronous message notifications from UHD [default=%default]")
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
- self.options = options
- self.show_debug_info = True
-
- self.u = uhd.usrp_source(device_addr=options.args,
- stream_args=uhd.stream_args(cpu_format='fc32',
- otw_format=options.wire_format, args=options.stream_args))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- self.u.set_samp_rate(options.samp_rate)
- input_rate = self.u.get_samp_rate()
-
- if options.waterfall:
- self.scope = \
- waterfallsink2.waterfall_sink_c (panel, fft_size=1024,
- sample_rate=input_rate)
- self.frame.SetMinSize((800, 420))
- elif options.oscilloscope:
- self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate)
- self.frame.SetMinSize((800, 600))
- else:
- self.scope = fftsink2.fft_sink_c (panel,
- fft_size=options.fft_size,
- sample_rate=input_rate,
- ref_scale=options.ref_scale,
- ref_level=20.0,
- y_divs = 12,
- average=options.averaging,
- avg_alpha=options.avg_alpha,
- fft_rate=options.fft_rate)
- def fftsink_callback(x, y):
- self.set_freq(x)
-
- self.scope.set_callback(fftsink_callback)
- self.frame.SetMinSize((800, 420))
-
- self.connect(self.u, self.scope)
-
- self._build_gui(vbox)
- self._setup_events()
-
-
- # set initial values
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2
-
- if options.freq is None:
- # if no freq was specified, use the mid-point
- r = self.u.get_freq_range()
- options.freq = float(r.start()+r.stop())/2
-
- self.set_gain(options.gain)
-
- if self.show_debug_info:
- self.myform['samprate'].set_value(self.u.get_samp_rate())
- self.myform['rffreq'].set_value(0)
- self.myform['dspfreq'].set_value(0)
-
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
- # Direct asynchronous notifications to callback function
- if self.options.show_async_msg:
- self.async_msgq = gr.msg_queue(0)
- self.async_src = uhd.amsg_source("", self.async_msgq)
- self.async_rcv = gru.msgq_runner(self.async_msgq, self.async_callback)
-
- def async_callback(self, msg):
- md = self.async_src.msg_to_async_metadata_t(msg)
- print "Channel: %i Time: %f Event: %i" % (md.channel, md.time_spec.get_real_secs(), md.event_code)
-
- def _set_status_msg(self, msg):
- self.frame.GetStatusBar().SetStatusText(msg, 0)
-
- def _build_gui(self, vbox):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
- vbox.Add(self.scope.win, 10, wx.EXPAND)
-
- # add control area at the bottom
- self.myform = myform = form.form()
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0, 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Center freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq,
- self._set_status_msg))
-
- hbox.Add((5,0), 0, 0)
- g = self.u.get_gain_range()
-
- # some configurations don't have gain control
- if g.stop() <= g.start():
- glow = 0.0
- ghigh = 1.0
-
- else:
- glow = g.start()
- ghigh = g.stop()
-
- myform['gain'] = form.slider_field(parent=self.panel,
- sizer=hbox, label="Gain",
- weight=3,
- min=int(glow), max=int(ghigh),
- callback=self.set_gain)
-
- try:
- mboard_id = self.u.get_usrp_info()["mboard_id"]
- mboard_serial = self.u.get_usrp_info()["mboard_serial"]
- if mboard_serial == "":
- mboard_serial = "no serial"
- dboard_subdev_name = self.u.get_usrp_info()["rx_subdev_name"]
- dboard_serial = self.u.get_usrp_info()["rx_serial"]
- if dboard_serial == "":
- dboard_serial = "no serial"
- subdev = self.u.get_subdev_spec()
- antenna = self.u.get_antenna()
-
- if "B200" in mboard_id or "B210" in mboard_id:
- usrp_config_val = "%s (%s), %s (%s, %s)" % (mboard_id, mboard_serial, dboard_subdev_name, subdev, antenna)
- else:
- usrp_config_val = "%s (%s), %s (%s, %s, %s)" % (mboard_id, mboard_serial, dboard_subdev_name, dboard_serial, subdev, antenna)
- except:
- usrp_config_val = "Not implemented in this version."
-
- uhd_box = forms.static_box_sizer(parent=self.panel,
- label="UHD (%s)" % (uhd.get_version_string()),
- orient=wx.HORIZONTAL)
- usrp_config_form = forms.static_text(
- parent=self.panel,
- sizer=uhd_box,
- value=usrp_config_val,
- label="USRP",
- converter=forms.str_converter(),
- )
- vbox.Add(uhd_box, 0, wx.EXPAND)
- vbox.AddSpacer(5)
-
- hbox.Add((5,0), 0, 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- self._build_subpanel(vbox)
-
- def _build_subpanel(self, vbox_arg):
- # build a secondary information panel (sometimes hidden)
-
- # FIXME figure out how to have this be a subpanel that is always
- # created, but has its visibility controlled by foo.Show(True/False)
-
- def _form_set_samp_rate(kv):
- return self.set_samp_rate(kv['samprate'])
-
- if not(self.show_debug_info):
- return
-
- panel = self.panel
- vbox = vbox_arg
- myform = self.myform
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
-
- hbox.Add((5,0), 0)
- myform['samprate'] = form.float_field(
- parent=panel, sizer=hbox, label="Sample Rate",
- callback=myform.check_input_and_call(_form_set_samp_rate,
- self._set_status_msg))
-
- hbox.Add((5,0), 1)
- myform['rffreq'] = form.static_float_field(
- parent=panel, sizer=hbox, label="RF Freq.")
-
- hbox.Add((5,0), 1)
- myform['dspfreq'] = form.static_float_field(
- parent=panel, sizer=hbox, label="DSP Freq.")
-
- vbox.AddSpacer(5)
-
- vbox.Add(hbox, 0, wx.EXPAND)
- vbox.AddSpacer(5)
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- @param target_freq: frequency in Hz
- @rypte: bool
- """
- r = self.u.set_center_freq(target_freq, 0)
-
- if r:
- self.myform['freq'].set_value(self.u.get_center_freq())
- self.myform['rffreq'].set_value(r.actual_rf_freq)
- self.myform['dspfreq'].set_value(r.actual_dsp_freq)
-
- if not self.options.oscilloscope:
- self.scope.set_baseband_freq(target_freq)
- return True
-
- return False
-
- def set_gain(self, gain):
- if self.myform.has_key('gain'):
- self.myform['gain'].set_value(gain) # update displayed value
- self.u.set_gain(gain, 0)
-
- def set_samp_rate(self, samp_rate):
- ok = self.u.set_samp_rate(samp_rate)
- input_rate = self.u.get_samp_rate()
- self.scope.set_sample_rate(input_rate)
- if self.show_debug_info: # update displayed values
- self.myform['samprate'].set_value(self.u.get_samp_rate())
-
- # uhd set_samp_rate never fails; always falls back to closest requested.
- return True
-
- def _setup_events(self):
- if not self.options.waterfall and not self.options.oscilloscope:
- self.scope.win.Bind(wx.EVT_LEFT_DCLICK, self.evt_left_dclick)
-
- def evt_left_dclick(self, event):
- (ux, uy) = self.scope.win.GetXY(event)
- if event.CmdDown():
- # Re-center on maximum power
- points = self.scope.win._points
- if self.scope.win.peak_hold:
- if self.scope.win.peak_vals is not None:
- ind = numpy.argmax(self.scope.win.peak_vals)
- else:
- ind = int(points.shape()[0]/2)
- else:
- ind = numpy.argmax(points[:,1])
-
- (freq, pwr) = points[ind]
- target_freq = freq/self.scope.win._scale_factor
- print ind, freq, pwr
- self.set_freq(target_freq)
- else:
- # Re-center on clicked frequency
- target_freq = ux/self.scope.win._scale_factor
- self.set_freq(target_freq)
-
-
-def main ():
- try:
- app = stdgui2.stdapp(app_top_block, "UHD FFT", nstatus=1)
- app.MainLoop()
-
- except RuntimeError, e:
- print e
- sys.exit(1)
-
-if __name__ == '__main__':
- main ()
diff --git a/gr-uhd/examples/python/CMakeLists.txt b/gr-uhd/examples/python/CMakeLists.txt
deleted file mode 100644
index cf50feb148..0000000000
--- a/gr-uhd/examples/python/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-
-include(GrPython)
-
-GR_PYTHON_INSTALL(
- PROGRAMS
- fm_tx4.py
- fm_tx_2_daughterboards.py
- max_power.py
- usrp_am_mw_rcv.py
- usrp_nbfm_ptt.py
- usrp_nbfm_rcv.py
- usrp_spectrum_sense.py
- usrp_tv_rcv_nogui.py
- usrp_tv_rcv.py
- usrp_wfm_rcv2_nogui.py
- usrp_wfm_rcv_fmdet.py
- usrp_wfm_rcv_nogui.py
- usrp_wfm_rcv_pll.py
- usrp_wfm_rcv.py
- usrp_wfm_rcv_sca.py
- usrp_wxapt_rcv.py
- DESTINATION ${GR_PKG_UHD_EXAMPLES_DIR}
-)
diff --git a/gr-uhd/examples/python/fm_tx4.py b/gr-uhd/examples/python/fm_tx4.py
deleted file mode 100755
index 516033dae1..0000000000
--- a/gr-uhd/examples/python/fm_tx4.py
+++ /dev/null
@@ -1,211 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-"""
-Transmit N simultaneous narrow band FM signals.
-
-They will be centered at the frequency specified on the command line,
-and will spaced at 25kHz steps from there.
-
-The program opens N files with names audio-N.dat where N is in [0,7].
-These files should contain floating point audio samples in the range [-1,1]
-sampled at 32kS/sec. You can create files like this using
-audio_to_file.py
-"""
-
-from gnuradio import gr, eng_notation
-from gnuradio import uhd
-from gnuradio import analog
-from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-import math
-import sys
-
-from gnuradio.wxgui import stdgui2, fftsink2
-import wx
-
-
-########################################################
-# instantiate one transmit chain for each call
-
-class pipeline(gr.hier_block2):
- def __init__(self, filename, lo_freq, audio_rate, if_rate):
-
- gr.hier_block2.__init__(self, "pipeline",
- gr.io_signature(0, 0, 0),
- gr.io_signature(1, 1, gr.sizeof_gr_complex))
-
- try:
- src = blocks.file_source (gr.sizeof_float, filename, True)
- except RuntimeError:
- sys.stderr.write(("\nError: Could not open file '%s'\n\n" % \
- filename))
- sys.exit(1)
-
- print audio_rate, if_rate
- fmtx = analog.nbfm_tx(audio_rate, if_rate, max_dev=5e3,
- tau=75e-6, fh=0.925*if_rate/2.0)
-
- # Local oscillator
- lo = analog.sig_source_c(if_rate, # sample rate
- analog.GR_SIN_WAVE, # waveform type
- lo_freq, # frequency
- 1.0, # amplitude
- 0) # DC Offset
- mixer = blocks.multiply_cc()
-
- self.connect(src, fmtx, (mixer, 0))
- self.connect(lo, (mixer, 1))
- self.connect(mixer, self)
-
-class fm_tx_block(stdgui2.std_top_block):
- def __init__(self, frame, panel, vbox, argv):
- MAX_CHANNELS = 7
- stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)
-
- parser = OptionParser (option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-s", "--samp-rate", type="eng_float", default=400e3,
- help="set sample rate (bandwidth) [default=%default]")
- parser.add_option("-f", "--freq", type="eng_float", default=None,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-n", "--nchannels", type="int", default=4,
- help="number of Tx channels [1,4]")
- #parser.add_option("","--debug", action="store_true", default=False,
- # help="Launch Tx debugger")
- (options, args) = parser.parse_args ()
-
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- if options.nchannels < 1 or options.nchannels > MAX_CHANNELS:
- sys.stderr.write ("fm_tx4: nchannels out of range. Must be in [1,%d]\n" % MAX_CHANNELS)
- sys.exit(1)
-
- if options.freq is None:
- sys.stderr.write("fm_tx4: must specify frequency with -f FREQ\n")
- parser.print_help()
- sys.exit(1)
-
- # ----------------------------------------------------------------
- # Set up constants and parameters
-
- self.u = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- self.usrp_rate = options.samp_rate
- self.u.set_samp_rate(self.usrp_rate)
- self.usrp_rate = self.u.get_samp_rate()
-
- self.sw_interp = 10
- self.audio_rate = self.usrp_rate / self.sw_interp # 32 kS/s
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2
-
- self.set_gain(options.gain)
- self.set_freq(options.freq)
-
- self.sum = blocks.add_cc ()
-
- # Instantiate N NBFM channels
- step = 25e3
- offset = (0 * step, 1 * step, -1 * step,
- 2 * step, -2 * step, 3 * step, -3 * step)
-
- for i in range (options.nchannels):
- t = pipeline("audio-%d.dat" % (i % 4), offset[i],
- self.audio_rate, self.usrp_rate)
- self.connect(t, (self.sum, i))
-
- self.gain = blocks.multiply_const_cc (1.0 / options.nchannels)
-
- # connect it all
- self.connect (self.sum, self.gain)
- self.connect (self.gain, self.u)
-
- # plot an FFT to verify we are sending what we want
- if 1:
- post_mod = fftsink2.fft_sink_c(panel, title="Post Modulation",
- fft_size=512,
- sample_rate=self.usrp_rate,
- y_per_div=20,
- ref_level=40)
- self.connect (self.gain, post_mod)
- vbox.Add (post_mod.win, 1, wx.EXPAND)
-
-
- #if options.debug:
- # self.debugger = tx_debug_gui.tx_debug_gui(self.subdev)
- # self.debugger.Show(True)
-
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
-
- Tuning is a two step process. First we ask the front-end to
- tune as close to the desired frequency as it can. Then we use
- the result of that operation and our target_frequency to
- determine the value for the digital up converter. Finally, we feed
- any residual_freq to the s/w freq translater.
- """
-
- r = self.u.set_center_freq(target_freq, 0)
- if r:
- print "Frequency =", eng_notation.num_to_str(self.u.get_center_freq())
- return True
-
- return False
-
- def set_gain(self, gain):
- self.u.set_gain(gain, 0)
-
-
-def main ():
- app = stdgui2.stdapp(fm_tx_block, "Multichannel FM Tx", nstatus=1)
- app.MainLoop ()
-
-if __name__ == '__main__':
- main ()
diff --git a/gr-uhd/examples/python/fm_tx_2_daughterboards.py b/gr-uhd/examples/python/fm_tx_2_daughterboards.py
deleted file mode 100755
index b4958b8596..0000000000
--- a/gr-uhd/examples/python/fm_tx_2_daughterboards.py
+++ /dev/null
@@ -1,216 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-"""
-Transmit 2 signals, one out each daughterboard.
-
-Outputs SSB (USB) signals on side A and side B at frequencies
-specified on command line.
-
-Side A is 600 Hz tone.
-Side B is 350 + 440 Hz tones.
-"""
-
-from gnuradio import gr, uhd
-from gnuradio import filter
-from gnuradio import analog
-from gnuradio import blocks
-from gnuradio.eng_notation import num_to_str, str_to_num
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-import math
-import sys
-
-
-class example_signal_0(gr.hier_block2):
- """
- Sinusoid at 600 Hz.
- """
- def __init__(self, sample_rate):
- gr.hier_block2.__init__(self, "example_signal_0",
- gr.io_signature(0, 0, 0), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- src = analog.sig_source_c(sample_rate, # sample rate
- analog.GR_SIN_WAVE, # waveform type
- 600, # frequency
- 1.0, # amplitude
- 0) # DC Offset
-
- self.connect(src, self)
-
-
-class example_signal_1(gr.hier_block2):
- """
- North American dial tone (350 + 440 Hz).
- """
- def __init__(self, sample_rate):
- gr.hier_block2.__init__(self, "example_signal_1",
- gr.io_signature(0, 0, 0), # Input signature
- gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- src0 = analog.sig_source_c(sample_rate, # sample rate
- analog.GR_SIN_WAVE, # waveform type
- 350, # frequency
- 1.0, # amplitude
- 0) # DC Offset
-
- src1 = analog.sig_source_c(sample_rate, # sample rate
- analog.GR_SIN_WAVE, # waveform type
- 440, # frequency
- 1.0, # amplitude
- 0) # DC Offset
- sum = blocks.add_cc()
- self.connect(src0, (sum, 0))
- self.connect(src1, (sum, 1))
- self.connect(sum, self)
-
-class my_top_block(gr.top_block):
-
- def __init__(self):
- gr.top_block.__init__(self)
-
- usage = "%prog: [options] tx-freq0 tx-freq1"
- parser = OptionParser (option_class=eng_option, usage=usage)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-s", "--samp-rate", type="eng_float", default=320e3,
- help="set sample rate [default=%default]")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- (options, args) = parser.parse_args ()
-
- if len(args) != 2:
- parser.print_help()
- raise SystemExit
- else:
- freq0 = str_to_num(args[0])
- freq1 = str_to_num(args[1])
-
- # ----------------------------------------------------------------
- # Set up USRP to transmit on both daughterboards
-
- d = uhd.find_devices(uhd.device_addr(options.args))
- uhd_type = d[0].get('type')
-
- stream_args = uhd.stream_args('fc32', channels=range(2))
- self.u = uhd.usrp_sink(device_addr=options.args, stream_args=stream_args)
-
- # Set up USRP system based on type
- if(uhd_type == "usrp"):
- self.u.set_subdev_spec("A:0 B:0")
- tr0 = uhd.tune_request(freq0)
- tr1 = uhd.tune_request(freq1)
-
- else:
- if abs(freq0 - freq1) > 5.5e6:
- sys.stderr.write("\nError: When not using two separate d'boards, frequencies must bewithin 5.5MHz of each other.\n")
- raise SystemExit
-
- self.u.set_subdev_spec("A:0 A:0")
-
- mid_freq = (freq0 + freq1)/2.0
- tr0 = uhd.tune_request(freq0, rf_freq=mid_freq,
- rf_freq_policy=uhd.tune_request.POLICY_MANUAL)
-
- tr1 = uhd.tune_request(freq1, rf_freq=mid_freq,
- rf_freq_policy=uhd.tune_request.POLICY_MANUAL)
-
- # Use the tune requests to tune each channel
- self.set_freq(tr0, 0)
- self.set_freq(tr1, 1)
-
- self.usrp_rate = options.samp_rate
-
- self.u.set_samp_rate(self.usrp_rate)
- dev_rate = self.u.get_samp_rate()
-
- # ----------------------------------------------------------------
- # build two signal sources, interleave them, amplify and
- # connect them to usrp
-
- sig0 = example_signal_0(self.usrp_rate)
- sig1 = example_signal_1(self.usrp_rate)
-
- intl = blocks.interleave(gr.sizeof_gr_complex)
- self.connect(sig0, (intl, 0))
- self.connect(sig1, (intl, 1))
-
- # Correct for any difference in requested and actual rates
- rrate = self.usrp_rate / dev_rate
- resamp = filter.pfb.arb_resampler_ccf(rrate)
-
- # and wire them up
- self.connect(intl, resamp, self.u)
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2.0
-
- self.set_gain(options.gain, 0)
- self.set_gain(options.gain, 1)
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
- self.u.set_antenna(options.antenna, 1)
-
- def set_freq(self, target_freq, chan):
- """
- Set the center frequency we're interested in.
-
- Args:
- side: 0 = side A, 1 = side B
- target_freq: frequency in Hz
- @rtype: bool
- """
-
- print "Tuning channel %s to %sHz" % \
- (chan, num_to_str(target_freq))
-
- r = self.u.set_center_freq(target_freq, chan)
-
- if r:
- return True
-
- else:
- print " Set Frequency Failed!"
-
- return False
-
- def set_gain(self, gain, chan):
- self.u.set_gain(gain, chan)
-
-if __name__ == '__main__':
- try:
- my_top_block().run()
- except KeyboardInterrupt:
- pass
diff --git a/gr-uhd/examples/python/freq_hopping.py b/gr-uhd/examples/python/freq_hopping.py
deleted file mode 100755
index ce33a92a51..0000000000
--- a/gr-uhd/examples/python/freq_hopping.py
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2014 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-"""
-TXs a waveform (either from a file, or a sinusoid) in a frequency-hopping manner.
-"""
-
-import numpy
-import argparse
-import pmt
-from gnuradio import gr
-from gnuradio import blocks
-from gnuradio import uhd
-
-def setup_parser():
- """ Setup the parser for the frequency hopper. """
- parser = argparse.ArgumentParser(
- description="Transmit a signal in a frequency-hopping manner, using tx_freq tags."
- )
- parser.add_argument('-i', '--input-file', type=file, default=None,
- help="File with samples to transmit. If left out, will transmit a sinusoid.")
- parser.add_argument("-a", "--args", default="",
- help="UHD device address args.")
- parser.add_argument("--spec", default="",
- help="UHD subdev spec.")
- parser.add_argument("--antenna", default="",
- help="UHD antenna settings.")
- parser.add_argument("--gain", default=None, type=float,
- help="USRP gain (defaults to mid-point in dB).")
- parser.add_argument("-r", "--rate", type=float, default=1e6,
- help="Sampling rate")
- parser.add_argument("-N", "--samp-per-burst", type=int, default=10000,
- help="Samples per burst")
- parser.add_argument("-t", "--hop-time", type=float, default=1000,
- help="Time between hops in milliseconds. This must be larger than or equal to the burst duration as set by --samp-per-burst")
- parser.add_argument("-f", "--freq", type=float, default=2.45e9,
- help="Base frequency. This is the middle channel frequency at which the USRP will Tx.")
- parser.add_argument("--dsp", action='store_true',
- help="DSP tuning only.")
- parser.add_argument("-d", "--freq-delta", type=float, default=1e6,
- help="Channel spacing.")
- parser.add_argument("-c", "--num-channels", type=int, default=5,
- help="Number of channels.")
- parser.add_argument("-B", "--num-bursts", type=int, default=30,
- help="Number of bursts to transmit before terminating.")
- parser.add_argument("-p", "--post-tuning", action='count',
- help="Tune after transmitting. Default is to tune immediately before transmitting.")
- parser.add_argument("-v", "--verbose", action='count',
- help="Print more information. The morer the printier.")
- return parser
-
-
-class FrequencyHopperSrc(gr.hier_block2):
- """ Provides tags for frequency hopping """
- def __init__(
- self,
- n_bursts, n_channels,
- freq_delta, base_freq, dsp_tuning,
- burst_length, base_time, hop_time,
- post_tuning=False,
- tx_gain=0,
- verbose=False
- ):
- gr.hier_block2.__init__(self,
- "FrequencyHopperSrc",
- gr.io_signature(1, 1, gr.sizeof_gr_complex),
- gr.io_signature(1, 1, gr.sizeof_gr_complex),
- )
- n_samples_total = n_bursts * burst_length
- lowest_frequency = base_freq - numpy.floor(n_channels/2) * freq_delta
- self.hop_sequence = [lowest_frequency + n * freq_delta for n in xrange(n_channels)]
- numpy.random.shuffle(self.hop_sequence)
- # Repeat that:
- self.hop_sequence = [self.hop_sequence[x % n_channels] for x in xrange(n_bursts)]
- if verbose:
- print "Hop Frequencies | Hop Pattern"
- print "=================|================================"
- for f in self.hop_sequence:
- print "{:6.3f} MHz | ".format(f/1e6),
- if n_channels < 50:
- print " " * int((f - base_freq) / freq_delta) + "#"
- else:
- print "\n"
- print "=================|================================"
- # There's no real point in setting the gain via tag for this application,
- # but this is an example to show you how to do it.
- gain_tag = gr.tag_t()
- gain_tag.offset = 0
- gain_tag.key = pmt.string_to_symbol('tx_command')
- gain_tag.value = pmt.to_pmt({'gain': tx_gain})
- tag_list = [gain_tag,]
- for i in xrange(len(self.hop_sequence)):
- tune_tag = gr.tag_t()
- tune_tag.offset = i * burst_length
- if i > 0 and post_tuning and not dsp_tuning: # TODO dsp_tuning should also be able to do post_tuning
- tune_tag.offset -= 1 # Move it to last sample of previous burst
- if dsp_tuning:
- tune_tag.key = pmt.string_to_symbol('tx_command')
- tune_tag.value = pmt.to_pmt({'lo_freq': base_freq, 'dsp_freq': base_freq - self.hop_sequence[i]})
- else:
- tune_tag.key = pmt.string_to_symbol('tx_freq')
- tune_tag.value = pmt.to_pmt(self.hop_sequence[i])
- tag_list.append(tune_tag)
- length_tag = gr.tag_t()
- length_tag.offset = i * burst_length
- length_tag.key = pmt.string_to_symbol('packet_len')
- length_tag.value = pmt.from_long(burst_length)
- tag_list.append(length_tag)
- time_tag = gr.tag_t()
- time_tag.offset = i * burst_length
- time_tag.key = pmt.string_to_symbol('tx_time')
- time_tag.value = pmt.make_tuple(
- pmt.from_uint64(int(base_time + i * hop_time)),
- pmt.from_double((base_time + i * hop_time) % 1),
- )
- tag_list.append(time_tag)
- tag_source = blocks.vector_source_c((1.0,) * n_samples_total, repeat=False, tags=tag_list)
- mult = blocks.multiply_cc()
- self.connect(self, mult, self)
- self.connect(tag_source, (mult, 1))
-
-
-class FlowGraph(gr.top_block):
- """ Flow graph that does the frequency hopping. """
- def __init__(self, options):
- gr.top_block.__init__(self)
-
- if options.input_file is not None:
- src = blocks.file_source(gr.sizeof_gr_complex, options.filename, repeat=True)
- else:
- src = blocks.vector_source_c((.5,) * int(1e6) * 2, repeat=True)
- # Setup USRP
- self.u = uhd.usrp_sink(options.args, uhd.stream_args('fc32'), "packet_len")
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
- self.u.set_samp_rate(options.rate)
- # Gain is set in the hopper block
- if options.gain is None:
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2.0
- print "-- Setting gain to {} dB".format(options.gain)
- r = self.u.set_center_freq(options.freq)
- if not r:
- print '[ERROR] Failed to set base frequency.'
- raise SystemExit, 1
- hopper_block = FrequencyHopperSrc(
- options.num_bursts, options.num_channels,
- options.freq_delta, options.freq, options.dsp,
- options.samp_per_burst, 1.0, options.hop_time / 1000.,
- options.post_tuning,
- options.gain,
- options.verbose,
- )
- self.connect(src, hopper_block, self.u)
-
-def print_hopper_stats(args):
- """ Nothing to do with Grace Hopper """
- print """
-Parameter | Value
-===================+=========================
-Hop Interval | {hop_time} ms
-Burst duration | {hop_duration} ms
-Lowest Frequency | {lowest_freq:6.3f} MHz
-Highest Frequency | {highest_freq:6.3f} MHz
-Frequency spacing | {freq_delta:6.4f} MHz
-Number of channels | {num_channels}
-Sampling rate | {rate} Msps
-Transmit Gain | {gain} dB
-===================+=========================
- """.format(
- hop_time=args.hop_time,
- hop_duration=1000.0/args.rate*args.samp_per_burst,
- gain=args.gain,
- lowest_freq=args.freq/1e6,
- highest_freq=(args.freq + (args.num_channels-1) * args.freq_delta)/1e6,
- freq_delta=args.freq_delta/1e6,
- num_channels=args.num_channels,
- rate=args.rate/1e6,
- )
-
-def main():
- """ Go, go, go! """
- args = setup_parser().parse_args()
- if (1.0 * args.samp_per_burst / args.rate) > args.hop_time * 1e-3:
- print "Burst duration must be smaller than hop time."
- exit(1)
- if args.verbose:
- print_hopper_stats(args)
- top_block = FlowGraph(args)
- print "Starting to hop, skip and jump... press Ctrl+C to exit."
- top_block.u.set_time_now(uhd.time_spec(0.0))
- top_block.run()
-
-if __name__ == '__main__':
- try:
- main()
- except KeyboardInterrupt:
- pass
-
diff --git a/gr-uhd/examples/python/max_power.py b/gr-uhd/examples/python/max_power.py
deleted file mode 100755
index e1504e5ea2..0000000000
--- a/gr-uhd/examples/python/max_power.py
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2004,2007,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-"""
-Setup USRP for maximum power consumption.
-"""
-
-
-from gnuradio import gr
-from gnuradio import analog
-from gnuradio import blocks
-from gnuradio import uhd
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-
-from gnuradio import eng_notation
-
-n2s = eng_notation.num_to_str
-
-# Set this to a huge number; UHD will adjust to the
-# maximum the USRP xxxx device can handle
-MAX_RATE = 1000e6
-
-class build_block(gr.top_block):
- def __init__(self, args, tx_enable, rx_enable):
- gr.top_block.__init__(self)
-
- d = uhd.find_devices(uhd.device_addr(args))
- uhd_type = d[0].get('type')
-
- print "\nFound '%s' at args '%s'" % \
- (uhd_type, args)
-
- # Test the type of USRP; if it's a USRP (v1), it has
- # 2 channels; otherwise, it has 1 channel
- if uhd_type == "usrp":
- tx_nchan = 2
- rx_nchan = 2
- else:
- tx_nchan = 1
- rx_nchan = 1
-
- if tx_enable:
- print "\nTRANSMIT CHAIN"
- stream_args = uhd.stream_args('fc32', channels=range(tx_nchan))
- self.u_tx = uhd.usrp_sink(device_addr=args, stream_args=stream_args)
- self.u_tx.set_samp_rate(MAX_RATE)
-
- self.tx_src0 = analog.sig_source_c(self.u_tx.get_samp_rate(),
- analog.GR_CONST_WAVE,
- 0, 1.0, 0)
-
- # Get dboard gain range and select maximum
- tx_gain_range = self.u_tx.get_gain_range()
- tx_gain = tx_gain_range.stop()
-
- # Get dboard freq range and select midpoint
- tx_freq_range = self.u_tx.get_freq_range()
- tx_freq_mid = (tx_freq_range.start() + tx_freq_range.stop())/2.0
-
- for i in xrange(tx_nchan):
- self.u_tx.set_center_freq (tx_freq_mid + i*1e6, i)
- self.u_tx.set_gain(tx_gain, i)
-
- print "\nTx Sample Rate: %ssps" % (n2s(self.u_tx.get_samp_rate()))
- for i in xrange(tx_nchan):
- print "Tx Channel %d: " % (i)
- print "\tFrequency = %sHz" % \
- (n2s(self.u_tx.get_center_freq(i)))
- print "\tGain = %f dB" % (self.u_tx.get_gain(i))
- print ""
-
- self.connect (self.tx_src0, self.u_tx)
-
- if rx_enable:
- print "\nRECEIVE CHAIN"
- self.u_rx = uhd.usrp_source(device_addr=args,
- io_type=uhd.io_type.COMPLEX_FLOAT32,
- num_channels=rx_nchan)
- self.rx_dst0 = blocks.null_sink(gr.sizeof_gr_complex)
-
- self.u_rx.set_samp_rate(MAX_RATE)
-
- # Get dboard gain range and select maximum
- rx_gain_range = self.u_rx.get_gain_range()
- rx_gain = rx_gain_range.stop()
-
- # Get dboard freq range and select midpoint
- rx_freq_range = self.u_rx.get_freq_range()
- rx_freq_mid = (rx_freq_range.start() + rx_freq_range.stop())/2.0
-
- for i in xrange(tx_nchan):
- self.u_rx.set_center_freq (rx_freq_mid + i*1e6, i)
- self.u_rx.set_gain(rx_gain, i)
-
- print "\nRx Sample Rate: %ssps" % (n2s(self.u_rx.get_samp_rate()))
- for i in xrange(rx_nchan):
- print "Rx Channel %d: " % (i)
- print "\tFrequency = %sHz" % \
- (n2s(self.u_rx.get_center_freq(i)))
- print "\tGain = %f dB" % (self.u_rx.get_gain(i))
- print ""
-
- self.connect (self.u_rx, self.rx_dst0)
-
-def main ():
- parser = OptionParser (option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("-t", action="store_true", dest="tx_enable",
- default=False, help="enable Tx path")
- parser.add_option("-r", action="store_true", dest="rx_enable",
- default=False, help="enable Rx path")
- (options, args) = parser.parse_args ()
-
- tb = build_block (options.args, options.tx_enable, options.rx_enable)
-
- tb.start ()
- raw_input ('Press Enter to quit: ')
- tb.stop ()
-
-if __name__ == '__main__':
- main ()
diff --git a/gr-uhd/examples/python/usrp_am_mw_rcv.py b/gr-uhd/examples/python/usrp_am_mw_rcv.py
deleted file mode 100755
index eebbd7c041..0000000000
--- a/gr-uhd/examples/python/usrp_am_mw_rcv.py
+++ /dev/null
@@ -1,316 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, eng_notation
-from gnuradio import blocks
-from gnuradio import filter
-from gnuradio import analog
-from gnuradio import audio
-from gnuradio import uhd
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import slider, powermate
-from gnuradio.wxgui import stdgui2, fftsink2, form
-from optparse import OptionParser
-import sys
-import math
-import wx
-
-class wfm_rx_block (stdgui2.std_top_block):
- def __init__(self, frame, panel, vbox, argv):
- stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)
-
- parser=OptionParser(option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6,
- help="set sample rate (bandwidth) [default=%default]")
- parser.add_option("-f", "--freq", type="eng_float", default=1008.0e3,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-I", "--use-if-freq", action="store_true", default=False,
- help="use intermediate freq (compensates DC problems in quadrature boards)" )
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is maximum)")
- parser.add_option("-V", "--volume", type="eng_float", default=None,
- help="set volume (default is midpoint)")
- parser.add_option("-O", "--audio-output", type="string", default="default",
- help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp")
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- self.frame = frame
- self.panel = panel
- self.use_IF=options.use_if_freq
- if self.use_IF:
- self.IF_freq=64000.0
- else:
- self.IF_freq=0.0
-
- self.vol = 0
- self.state = "FREQ"
- self.freq = 0
-
- # build graph
- self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- usrp_rate = 256e3
- demod_rate = 64e3
- audio_rate = 32e3
- chanfilt_decim = int(usrp_rate // demod_rate)
- audio_decim = int(demod_rate // audio_rate)
-
- self.u.set_samp_rate(usrp_rate)
- dev_rate = self.u.get_samp_rate()
-
- # Resample signal to exactly self.usrp_rate
- # FIXME: make one of the follow-on filters an arb resampler
- rrate = usrp_rate / dev_rate
- self.resamp = filter.pfb.arb_resampler_ccf(rrate)
-
- chan_filt_coeffs = filter.firdes.low_pass_2(1, # gain
- usrp_rate, # sampling rate
- 8e3, # passband cutoff
- 4e3, # transition bw
- 60) # stopband attenuation
-
- if self.use_IF:
- # Turn If to baseband and filter.
- self.chan_filt = filter.freq_xlating_fir_filter_ccf(chanfilt_decim,
- chan_filt_coeffs,
- self.IF_freq,
- usrp_rate)
- else:
- self.chan_filt = filter.fir_filter_ccf(chanfilt_decim, chan_filt_coeffs)
-
- self.agc = analog.agc_cc(0.1, 1, 1, 100000)
- self.am_demod = blocks.complex_to_mag()
- self.volume_control = blocks.multiply_const_ff(self.vol)
-
- audio_filt_coeffs = filter.firdes.low_pass_2(1, # gain
- demod_rate, # sampling rate
- 8e3, # passband cutoff
- 2e3, # transition bw
- 60) # stopband attenuation
- self.audio_filt = filter.fir_filter_fff(audio_decim, audio_filt_coeffs)
-
- # sound card as final sink
- self.audio_sink = audio.sink(int (audio_rate),
- options.audio_output,
- False) # ok_to_block
-
- # now wire it all together
- self.connect (self.u, self.resamp, self.chan_filt, self.agc,
- self.am_demod, self.audio_filt,
- self.volume_control, self.audio_sink)
-
- self._build_gui(vbox, usrp_rate, demod_rate, audio_rate)
-
- if options.gain is None:
- g = self.u.get_gain_range()
- # if no gain was specified, use the mid gain
- options.gain = (g.start() + g.stop())/2.0
-
- if options.volume is None:
- v = self.volume_range()
- options.volume = float(v[0]*3+v[1])/4.0
-
- if abs(options.freq) < 1e3:
- options.freq *= 1e3
-
- # set initial values
-
- self.set_gain(options.gain)
- self.set_vol(options.volume)
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
- def _set_status_msg(self, msg, which=0):
- self.frame.GetStatusBar().SetStatusText(msg, which)
-
-
- def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
-
- if 0:
- self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP",
- fft_size=512, sample_rate=usrp_rate,
- ref_scale=32768.0, ref_level=0.0, y_divs=12)
- self.connect (self.u, self.src_fft)
- vbox.Add (self.src_fft.win, 4, wx.EXPAND)
-
- if 0:
- self.post_filt_fft = fftsink2.fft_sink_c(self.panel, title="Post Channel filter",
- fft_size=512, sample_rate=demod_rate)
- self.connect (self.chan_filt, self.post_filt_fft)
- vbox.Add (self.post_filt_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post Demod",
- fft_size=1024, sample_rate=demod_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.am_demod, post_demod_fft)
- vbox.Add (post_demod_fft.win, 4, wx.EXPAND)
-
- if 1:
- audio_fft = fftsink2.fft_sink_f(self.panel, title="Audio",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=20)
- self.connect (self.audio_filt, audio_fft)
- vbox.Add (audio_fft.win, 4, wx.EXPAND)
-
-
- # control area form at bottom
- self.myform = myform = form.form()
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0)
- myform['freq_slider'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3,
- range=(520.0e3, 1611.0e3, 1.0e3),
- callback=self.set_freq)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['volume'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume",
- weight=3, range=self.volume_range(),
- callback=self.set_vol)
- hbox.Add((5,0), 1)
-
- g = self.u.get_gain_range()
- myform['gain'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3, range=(g.start(), g.stop(), g.step()),
- callback=self.set_gain)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- try:
- self.knob = powermate.powermate(self.frame)
- self.rot = 0
- powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate)
- powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button)
- except:
- print "FYI: No Powermate or Contour Knob found"
-
-
- def on_rotate (self, event):
- self.rot += event.delta
- if (self.state == "FREQ"):
- if self.rot >= 3:
- self.set_freq(self.freq + .1e6)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_freq(self.freq - .1e6)
- self.rot += 3
- else:
- step = self.volume_range()[2]
- if self.rot >= 3:
- self.set_vol(self.vol + step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_vol(self.vol - step)
- self.rot += 3
-
- def on_button (self, event):
- if event.value == 0: # button up
- return
- self.rot = 0
- if self.state == "FREQ":
- self.state = "VOL"
- else:
- self.state = "FREQ"
- self.update_status_bar ()
-
-
- def set_vol (self, vol):
- g = self.volume_range()
- self.vol = max(g[0], min(g[1], vol))
- self.volume_control.set_k(10**(self.vol/10))
- self.myform['volume'].set_value(self.vol)
- self.update_status_bar ()
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
- """
- r = self.u.set_center_freq(target_freq + self.IF_freq, 0)
-
- if r:
- self.freq = target_freq
- self.myform['freq'].set_value(target_freq) # update displayed value
- self.myform['freq_slider'].set_value(target_freq) # update displayed value
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
-
- self._set_status_msg("Failed", 0)
- return False
-
- def set_gain(self, gain):
- self.myform['gain'].set_value(gain) # update displayed value
- self.u.set_gain(gain)
-
- def update_status_bar (self):
- msg = "Volume:%r Setting:%s" % (self.vol, self.state)
- self._set_status_msg(msg, 1)
- try:
- self.src_fft.set_baseband_freq(self.freq)
- except:
- None
-
- def volume_range(self):
- return (-40.0, 0.0, 0.5)
-
-
-if __name__ == '__main__':
- app = stdgui2.stdapp (wfm_rx_block, "USRP Broadcast AM MW RX")
- app.MainLoop ()
diff --git a/gr-uhd/examples/python/usrp_nbfm_ptt.py b/gr-uhd/examples/python/usrp_nbfm_ptt.py
deleted file mode 100755
index 76e1f47c3c..0000000000
--- a/gr-uhd/examples/python/usrp_nbfm_ptt.py
+++ /dev/null
@@ -1,494 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005,2007,2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import math
-import sys
-import wx
-from optparse import OptionParser
-
-from gnuradio import gr, audio, uhd
-from gnuradio import analog
-from gnuradio import blocks
-from gnuradio import filter
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import stdgui2, fftsink2, scopesink2, slider, form
-
-from numpy import convolve, array
-
-#import os
-#print "pid =", os.getpid()
-#raw_input('Press Enter to continue: ')
-
-# ////////////////////////////////////////////////////////////////////////
-# Control Stuff
-# ////////////////////////////////////////////////////////////////////////
-
-class ptt_block(stdgui2.std_top_block):
- def __init__(self, frame, panel, vbox, argv):
- stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)
-
- self.frame = frame
- self.space_bar_pressed = False
-
- parser = OptionParser (option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option ("-f", "--freq", type="eng_float", default=442.1e6,
- help="set Tx and Rx frequency to FREQ", metavar="FREQ")
- parser.add_option ("-g", "--rx-gain", type="eng_float", default=None,
- help="set rx gain [default=midpoint in dB]")
- parser.add_option ("", "--tx-gain", type="eng_float", default=None,
- help="set tx gain [default=midpoint in dB]")
- parser.add_option("-I", "--audio-input", type="string", default="default",
- help="pcm input device name. E.g., hw:0,0 or /dev/dsp")
- parser.add_option("-O", "--audio-output", type="string", default="default",
- help="pcm output device name. E.g., hw:0,0 or /dev/dsp")
- parser.add_option ("-N", "--no-gui", action="store_true", default=False)
- (options, args) = parser.parse_args ()
-
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- if options.freq < 1e6:
- options.freq *= 1e6
-
- self.txpath = transmit_path(options.args, options.spec,
- options.antenna, options.tx_gain,
- options.audio_input)
- self.rxpath = receive_path(options.args, options.spec,
- options.antenna, options.rx_gain,
- options.audio_output)
- self.connect(self.txpath)
- self.connect(self.rxpath)
-
- self._build_gui(frame, panel, vbox, argv, options.no_gui)
-
- self.set_transmit(False)
- self.set_freq(options.freq)
- self.set_rx_gain(self.rxpath.gain) # update gui
- self.set_volume(self.rxpath.volume) # update gui
- self.set_squelch(self.rxpath.threshold()) # update gui
-
-
- def set_transmit(self, enabled):
- self.txpath.set_enable(enabled)
- self.rxpath.set_enable(not(enabled))
- if enabled:
- self.frame.SetStatusText ("Transmitter ON", 1)
- else:
- self.frame.SetStatusText ("Receiver ON", 1)
-
-
- def set_rx_gain(self, gain):
- self.myform['rx_gain'].set_value(gain) # update displayed value
- self.rxpath.set_gain(gain)
-
- def set_tx_gain(self, gain):
- self.txpath.set_gain(gain)
-
- def set_squelch(self, threshold):
- self.rxpath.set_squelch(threshold)
- self.myform['squelch'].set_value(self.rxpath.threshold())
-
- def set_volume (self, vol):
- self.rxpath.set_volume(vol)
- self.myform['volume'].set_value(self.rxpath.volume)
- #self.update_status_bar ()
-
- def set_freq(self, freq):
- r1 = self.txpath.set_freq(freq)
- r2 = self.rxpath.set_freq(freq)
- #print "txpath.set_freq =", r1
- #print "rxpath.set_freq =", r2
- if r1 and r2:
- self.myform['freq'].set_value(freq) # update displayed value
- return r1 and r2
-
- def _build_gui(self, frame, panel, vbox, argv, no_gui):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
- self.panel = panel
-
- # FIXME This REALLY needs to be replaced with a hand-crafted button
- # that sends both button down and button up events
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((10,0), 1)
- self.status_msg = wx.StaticText(panel, -1, "Press Space Bar to Transmit")
- of = self.status_msg.GetFont()
- self.status_msg.SetFont(wx.Font(15, of.GetFamily(), of.GetStyle(), of.GetWeight()))
- hbox.Add(self.status_msg, 0, wx.ALIGN_CENTER)
- hbox.Add((10,0), 1)
- vbox.Add(hbox, 0, wx.EXPAND | wx.ALIGN_CENTER)
-
- panel.Bind(wx.EVT_KEY_DOWN, self._on_key_down)
- panel.Bind(wx.EVT_KEY_UP, self._on_key_up)
- panel.Bind(wx.EVT_KILL_FOCUS, self._on_kill_focus)
- panel.SetFocus()
-
- if 1 and not(no_gui):
- rx_fft = fftsink2.fft_sink_c(panel, title="Rx Input", fft_size=512,
- sample_rate=self.rxpath.if_rate,
- ref_level=80, y_per_div=20)
- self.connect (self.rxpath.u, rx_fft)
- vbox.Add (rx_fft.win, 1, wx.EXPAND)
-
- if 1 and not(no_gui):
- rx_fft = fftsink2.fft_sink_c(panel, title="Post s/w Resampler",
- fft_size=512, sample_rate=self.rxpath.quad_rate,
- ref_level=80, y_per_div=20)
- self.connect (self.rxpath.resamp, rx_fft)
- vbox.Add (rx_fft.win, 1, wx.EXPAND)
-
- if 0 and not(no_gui):
- foo = scopesink2.scope_sink_f(panel, title="Squelch",
- sample_rate=32000)
- self.connect (self.rxpath.fmrx.div, (foo,0))
- self.connect (self.rxpath.fmrx.gate, (foo,1))
- self.connect (self.rxpath.fmrx.squelch_lpf, (foo,2))
- vbox.Add (foo.win, 1, wx.EXPAND)
-
- if 0 and not(no_gui):
- tx_fft = fftsink2.fft_sink_c(panel, title="Tx Output",
- fft_size=512, sample_rate=self.txpath.usrp_rate)
- self.connect (self.txpath.amp, tx_fft)
- vbox.Add (tx_fft.win, 1, wx.EXPAND)
-
-
- # add control area at the bottom
-
- self.myform = myform = form.form()
-
- # first row
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0, 0)
- myform['freq'] = form.float_field(
- parent=panel, sizer=hbox, label="Freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0, 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
-
- # second row
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- myform['volume'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume",
- weight=3, range=self.rxpath.volume_range(),
- callback=self.set_volume)
- hbox.Add((5,0), 0)
- myform['squelch'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Squelch",
- weight=3, range=self.rxpath.squelch_range(),
- callback=self.set_squelch)
-
- g = self.rxpath.u.get_gain_range()
- hbox.Add((5,0), 0)
- myform['rx_gain'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Rx Gain",
- weight=3, range=(g.start(), g.stop(), g.step()),
- callback=self.set_rx_gain)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
-
- self._build_subpanel(vbox)
-
- def _build_subpanel(self, vbox_arg):
- # build a secondary information panel (sometimes hidden)
-
- # FIXME figure out how to have this be a subpanel that is always
- # created, but has its visibility controlled by foo.Show(True/False)
-
- #if not(self.show_debug_info):
- # return
-
- panel = self.panel
- vbox = vbox_arg
- myform = self.myform
-
- #panel = wx.Panel(self.panel, -1)
- #vbox = wx.BoxSizer(wx.VERTICAL)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- #myform['decim'] = form.static_float_field(
- # parent=panel, sizer=hbox, label="Decim")
-
- #hbox.Add((5,0), 1)
- #myform['fs@usb'] = form.static_float_field(
- # parent=panel, sizer=hbox, label="Fs@USB")
-
- #hbox.Add((5,0), 1)
- #myform['dbname'] = form.static_text_field(
- # parent=panel, sizer=hbox)
-
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
-
- def _set_status_msg(self, msg, which=0):
- self.frame.GetStatusBar().SetStatusText(msg, which)
-
- def _on_key_down(self, evt):
- # print "key_down:", evt.m_keyCode
- if evt.m_keyCode == wx.WXK_SPACE and not(self.space_bar_pressed):
- self.space_bar_pressed = True
- self.set_transmit(True)
-
- def _on_key_up(self, evt):
- # print "key_up", evt.m_keyCode
- if evt.m_keyCode == wx.WXK_SPACE:
- self.space_bar_pressed = False
- self.set_transmit(False)
-
- def _on_kill_focus(self, evt):
- # if we lose the keyboard focus, turn off the transmitter
- self.space_bar_pressed = False
- self.set_transmit(False)
-
-
-# ////////////////////////////////////////////////////////////////////////
-# Transmit Path
-# ////////////////////////////////////////////////////////////////////////
-
-class transmit_path(gr.hier_block2):
- def __init__(self, args, spec, antenna, gain, audio_input):
- gr.hier_block2.__init__(self, "transmit_path",
- gr.io_signature(0, 0, 0), # Input signature
- gr.io_signature(0, 0, 0)) # Output signature
-
- self.u = uhd.usrp_sink(device_addr=args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(spec):
- self.u.set_subdev_spec(spec, 0)
-
- # Set the antenna
- if(antenna):
- self.u.set_antenna(antenna, 0)
-
- self.if_rate = 320e3
- self.audio_rate = 32e3
-
- self.u.set_samp_rate(self.if_rate)
- dev_rate = self.u.get_samp_rate()
-
- self.audio_gain = 10
- self.normal_gain = 32000
-
- self.audio = audio.source(int(self.audio_rate), audio_input)
- self.audio_amp = blocks.multiply_const_ff(self.audio_gain)
-
- lpf = filter.firdes.low_pass(1, # gain
- self.audio_rate, # sampling rate
- 3800, # low pass cutoff freq
- 300, # width of trans. band
- filter.firdes.WIN_HANN) # filter type
-
- hpf = filter.firdes.high_pass(1, # gain
- self.audio_rate, # sampling rate
- 325, # low pass cutoff freq
- 50, # width of trans. band
- filter.firdes.WIN_HANN) # filter type
-
- audio_taps = convolve(array(lpf),array(hpf))
- self.audio_filt = filter.fir_filter_fff(1,audio_taps)
-
- self.pl = analog.ctcss_gen_f(self.audio_rate,123.0)
- self.add_pl = blocks.add_ff()
- self.connect(self.pl,(self.add_pl,1))
-
- self.fmtx = analog.nbfm_tx(self.audio_rate, self.if_rate)
- self.amp = blocks.multiply_const_cc (self.normal_gain)
-
- rrate = dev_rate / self.if_rate
- self.resamp = filter.pfb.arb_resampler_ccf(rrate)
-
- self.connect(self.audio, self.audio_amp, self.audio_filt,
- (self.add_pl,0), self.fmtx, self.amp,
- self.resamp, self.u)
-
- if gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- gain = float(g.start() + g.stop())/2.0
-
- self.set_gain(gain)
-
- self.set_enable(False)
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
- """
- r = self.u.set_center_freq(target_freq)
- if r:
- return True
- return False
-
- def set_gain(self, gain):
- self.gain = gain
- self.u.set_gain(gain)
-
- def set_enable(self, enable):
- if enable:
- self.amp.set_k (self.normal_gain)
- else:
- self.amp.set_k (0)
-
-
-
-# ////////////////////////////////////////////////////////////////////////
-# Receive Path
-# ////////////////////////////////////////////////////////////////////////
-
-class receive_path(gr.hier_block2):
- def __init__(self, args, spec, antenna, gain, audio_output):
- gr.hier_block2.__init__(self, "receive_path",
- gr.io_signature(0, 0, 0), # Input signature
- gr.io_signature(0, 0, 0)) # Output signature
-
- self.u = uhd.usrp_source(device_addr=args,
- io_type=uhd.io_type.COMPLEX_FLOAT32,
- num_channels=1)
-
- self.if_rate = 256e3
- self.quad_rate = 64e3
- self.audio_rate = 32e3
-
- self.u.set_samp_rate(self.if_rate)
- dev_rate = self.u.get_samp_rate()
-
- # Create filter to get actual channel we want
- nfilts = 32
- chan_coeffs = filter.firdes.low_pass(nfilts, # gain
- nfilts*dev_rate, # sampling rate
- 13e3, # low pass cutoff freq
- 4e3, # width of trans. band
- filter.firdes.WIN_HANN) # filter type
-
- rrate = self.quad_rate / dev_rate
- self.resamp = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
-
- # instantiate the guts of the single channel receiver
- self.fmrx = analog.nbfm_rx(self.audio_rate, self.quad_rate)
-
- # standard squelch block
- self.squelch = analog.standard_squelch(self.audio_rate)
-
- # audio gain / mute block
- self._audio_gain = blocks.multiply_const_ff(1.0)
-
- # sound card as final sink
- audio_sink = audio.sink(int(self.audio_rate), audio_output)
-
- # now wire it all together
- self.connect(self.u, self.resamp, self.fmrx, self.squelch,
- self._audio_gain, audio_sink)
-
- if gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- gain = float(g.start() + g.stop())/2.0
-
- self.enabled = True
- self.set_gain(gain)
- v = self.volume_range()
- self.set_volume((v[0]+v[1])/2)
- s = self.squelch_range()
- self.set_squelch((s[0]+s[1])/2)
-
- # Set the subdevice spec
- if(spec):
- self.u.set_subdev_spec(spec, 0)
-
- # Set the antenna
- if(antenna):
- self.u.set_antenna(antenna, 0)
-
- def volume_range(self):
- return (-20.0, 0.0, 0.5)
-
- def set_volume (self, vol):
- g = self.volume_range()
- self.volume = max(g[0], min(g[1], vol))
- self._update_audio_gain()
-
- def set_enable(self, enable):
- self.enabled = enable
- self._update_audio_gain()
-
- def _update_audio_gain(self):
- if self.enabled:
- self._audio_gain.set_k(10**(self.volume/10))
- else:
- self._audio_gain.set_k(0)
-
- def squelch_range(self):
- return self.squelch.squelch_range()
-
- def set_squelch(self, threshold):
- print "SQL =", threshold
- self.squelch.set_threshold(threshold)
-
- def threshold(self):
- return self.squelch.threshold()
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
- """
- r = self.u.set_center_freq(target_freq)
- if r:
- return True
- return False
-
- def set_gain(self, gain):
- self.gain = gain
- self.u.set_gain(gain)
-
-
-# ////////////////////////////////////////////////////////////////////////
-# Main
-# ////////////////////////////////////////////////////////////////////////
-
-def main():
- app = stdgui2.stdapp(ptt_block, "NBFM Push to Talk")
- app.MainLoop()
-
-if __name__ == '__main__':
- main()
diff --git a/gr-uhd/examples/python/usrp_nbfm_rcv.py b/gr-uhd/examples/python/usrp_nbfm_rcv.py
deleted file mode 100755
index e3dc7eac6b..0000000000
--- a/gr-uhd/examples/python/usrp_nbfm_rcv.py
+++ /dev/null
@@ -1,384 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005,2007,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, audio, uhd
-from gnuradio import blocks
-from gnuradio import filter
-from gnuradio import analog
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import slider, powermate
-from gnuradio.wxgui import stdgui2, fftsink2, form
-from optparse import OptionParser
-import sys
-import math
-import wx
-
-#////////////////////////////////////////////////////////////////////////
-# Control Stuff
-#////////////////////////////////////////////////////////////////////////
-
-class my_top_block (stdgui2.std_top_block):
- def __init__(self,frame,panel,vbox,argv):
- stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv)
-
- parser=OptionParser(option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-f", "--freq", type="eng_float", default=146.585e6,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-V", "--volume", type="eng_float", default=None,
- help="set volume (default is midpoint)")
- parser.add_option("-O", "--audio-output", type="string", default="default",
- help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp")
- parser.add_option("-N", "--no-gui", action="store_true", default=False)
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- if options.freq < 1e6:
- options.freq *= 1e6
-
- self.frame = frame
- self.panel = panel
-
- self.state = "FREQ"
- self.freq = 0
- self.freq_step = 25e3
-
- self.rxpath = receive_path(options.args, options.spec, options.antenna,
- options.gain, options.audio_output)
- self.connect(self.rxpath)
-
- self._build_gui(vbox, options.no_gui)
-
- # set initial values
-
- if options.volume is not None:
- self.set_volume(options.volume)
-
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
- self.set_gain(self.rxpath.gain) # update gui
- self.set_volume(self.rxpath.volume) # update gui
- self.set_squelch(self.rxpath.threshold()) # update gui
-
-
- def _set_status_msg(self, msg, which=0):
- self.frame.GetStatusBar().SetStatusText(msg, which)
-
-
- def _build_gui(self, vbox, no_gui):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
-
- self.src_fft = None
- if 0 and not(no_gui):
- self.src_fft = fftsink2.fft_sink_c(self.panel,
- title="Data from USRP",
- fft_size=512,
- sample_rate=self.rxpath.if_rate,
- ref_scale=32768.0,
- ref_level=0,
- y_per_div=10,
- y_divs=12)
- self.connect (self.rxpath.u, self.src_fft)
- vbox.Add (self.src_fft.win, 4, wx.EXPAND)
- if 1 and not(no_gui):
- rx_fft = fftsink2.fft_sink_c(self.panel,
- title="Post s/w Resampling",
- fft_size=512,
- sample_rate=self.rxpath.quad_rate,
- ref_level=80,
- y_per_div=20)
- self.connect (self.rxpath.resamp, rx_fft)
- vbox.Add (rx_fft.win, 4, wx.EXPAND)
-
- if 1 and not(no_gui):
- post_deemph_fft = fftsink2.fft_sink_f(self.panel,
- title="Post Deemph",
- fft_size=512,
- sample_rate=self.rxpath.audio_rate,
- y_per_div=10,
- ref_level=-40)
- self.connect (self.rxpath.fmrx.deemph, post_deemph_fft)
- vbox.Add (post_deemph_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_filt_fft = fftsink2.fft_sink_f(self.panel,
- title="Post Filter",
- fft_size=512,
- sample_rate=audio_rate,
- y_per_div=10,
- ref_level=-40)
- self.connect (self.guts.audio_filter, post_filt)
- vbox.Add (fft_win4, 4, wx.EXPAND)
-
- # control area form at bottom
- self.myform = myform = form.form()
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq,
- self._set_status_msg))
-
- #hbox.Add((5,0), 0)
- #myform['freq_slider'] = \
- # form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3,
- # range=(87.9e6, 108.1e6, 0.1e6),
- # callback=self.set_freq)
-
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['volume'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume",
- weight=3, range=self.volume_range(),
- callback=self.set_volume)
- hbox.Add((5,0), 0)
- myform['squelch'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Squelch",
- weight=3, range=self.rxpath.squelch_range(),
- callback=self.set_squelch)
- g = self.rxpath.u.get_gain_range()
- hbox.Add((5,0), 0)
- myform['gain'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3, range=(g.start(), g.stop(), g.step()),
- callback=self.set_gain)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- try:
- self.knob = powermate.powermate(self.frame)
- self.rot = 0
- powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate)
- powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button)
- except:
- print "FYI: No Powermate or Contour Knob found"
-
-
- def on_rotate (self, event):
- self.rot += event.delta
- if (self.state == "FREQ"):
- if self.rot >= 3:
- self.set_freq(self.freq + self.freq_step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_freq(self.freq - self.freq_step)
- self.rot += 3
- else:
- step = self.volume_range()[2]
- if self.rot >= 3:
- self.set_volume(self.rxpath.volume + step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_volume(self.rxpath.volume - step)
- self.rot += 3
-
- def on_button (self, event):
- if event.value == 0: # button up
- return
- self.rot = 0
- if self.state == "FREQ":
- self.state = "VOL"
- else:
- self.state = "FREQ"
- self.update_status_bar ()
-
-
- def set_squelch(self, threshold_in_db):
- self.rxpath.set_squelch(threshold_in_db)
- self.myform['squelch'].set_value(self.rxpath.threshold())
-
- def set_volume (self, vol):
- self.rxpath.set_volume(vol)
- self.myform['volume'].set_value(self.rxpath.volume)
- self.update_status_bar ()
-
- def set_freq(self, target_freq):
- r = self.rxpath.set_freq(target_freq)
- if r:
- self.freq = target_freq
- self.myform['freq'].set_value(target_freq) # update displayed value
- #self.myform['freq_slider'].set_value(target_freq) # update displayed value
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
-
- self._set_status_msg("Failed", 0)
- return False
-
- def set_gain(self, gain):
- self.myform['gain'].set_value(gain) # update displayed value
- self.rxpath.set_gain(gain)
-
- def update_status_bar (self):
- msg = "Volume:%r Setting:%s" % (self.rxpath.volume, self.state)
- self._set_status_msg(msg, 1)
- if self.src_fft:
- self.src_fft.set_baseband_freq(self.freq)
-
- def volume_range(self):
- return (-20.0, 0.0, 0.5)
-
-
-#////////////////////////////////////////////////////////////////////////
-# Receive Path
-#////////////////////////////////////////////////////////////////////////
-
-USE_SIMPLE_SQUELCH = False
-
-class receive_path(gr.hier_block2):
- def __init__(self, args, spec, antenna, gain, audio_output):
- gr.hier_block2.__init__(self, "receive_path",
- gr.io_signature(0, 0, 0), # Input signature
- gr.io_signature(0, 0, 0)) # Output signature
-
- self.u = uhd.usrp_source(device_addr=args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(spec):
- self.u.set_subdev_spec(spec, 0)
-
- # Set the antenna
- if(antenna):
- self.u.set_antenna(antenna, 0)
-
- self.if_rate = 256e3
- self.quad_rate = 64e3
- self.audio_rate = 32e3
-
- self.u.set_samp_rate(self.if_rate)
- dev_rate = self.u.get_samp_rate()
-
- # Create filter to get actual channel we want
- nfilts = 32
- chan_coeffs = filter.firdes.low_pass(nfilts, # gain
- nfilts*dev_rate, # sampling rate
- 8e3, # low pass cutoff freq
- 2e3, # width of trans. band
- filter.firdes.WIN_HANN) # filter type
- rrate = self.quad_rate / dev_rate
- self.resamp = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
-
- if USE_SIMPLE_SQUELCH:
- self.squelch = analog.simple_squelch_cc(20)
- else:
- self.squelch = analog.standard_squelch(self.audio_rate)
-
- # instantiate the guts of the single channel receiver
- self.fmrx = analog.nbfm_rx(self.audio_rate, self.quad_rate)
-
- # audio gain / mute block
- self._audio_gain = blocks.multiply_const_ff(1.0)
-
- # sound card as final sink
- audio_sink = audio.sink (int(self.audio_rate), audio_output)
-
- # now wire it all together
- if USE_SIMPLE_SQUELCH:
- self.connect (self.u, self.resamp, self.squelch, self.fmrx,
- self._audio_gain, audio_sink)
- else:
- self.connect (self.u, self.resamp, self.fmrx, self.squelch,
- self._audio_gain, audio_sink)
-
- if gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- gain = float(g.start()+g.stop())/2
-
- self.set_gain(gain)
-
- v = self.volume_range()
- self.set_volume((v[0]+v[1])/2)
-
- s = self.squelch_range()
- self.set_squelch((s[0]+s[1])/2)
-
- def volume_range(self):
- return (-20.0, 0.0, 0.5)
-
- def set_volume (self, vol):
- g = self.volume_range()
- self.volume = max(g[0], min(g[1], vol))
- self._update_audio_gain()
-
- def _update_audio_gain(self):
- self._audio_gain.set_k(10**(self.volume/10))
-
- def squelch_range(self):
- r = self.squelch.squelch_range()
- #print "squelch_range: ", r
- return r
-
- def set_squelch(self, threshold):
- #print "SQL =", threshold
- self.squelch.set_threshold(threshold)
-
- def threshold(self):
- t = self.squelch.threshold()
- #print "t =", t
- return t
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
- """
-
- r = self.u.set_center_freq(target_freq)
- if r:
- return True
- return False
-
- def set_gain(self, gain):
- self.gain = gain
- self.u.set_gain(gain)
-
-
-# ////////////////////////////////////////////////////////////////////////
-# Main
-# ////////////////////////////////////////////////////////////////////////
-
-if __name__ == '__main__':
- app = stdgui2.stdapp (my_top_block, "USRP NBFM RX")
- app.MainLoop ()
diff --git a/gr-uhd/examples/python/usrp_spectrum_sense.py b/gr-uhd/examples/python/usrp_spectrum_sense.py
deleted file mode 100755
index b1ea6b44d8..0000000000
--- a/gr-uhd/examples/python/usrp_spectrum_sense.py
+++ /dev/null
@@ -1,318 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005,2007,2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, eng_notation
-from gnuradio import blocks
-from gnuradio import audio
-from gnuradio import filter
-from gnuradio import fft
-from gnuradio import uhd
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-import sys
-import math
-import struct
-import threading
-from datetime import datetime
-import time
-
-sys.stderr.write("Warning: this may have issues on some machines+Python version combinations to seg fault due to the callback in bin_statitics.\n\n")
-
-class ThreadClass(threading.Thread):
- def run(self):
- return
-
-class tune(gr.feval_dd):
- """
- This class allows C++ code to callback into python.
- """
- def __init__(self, tb):
- gr.feval_dd.__init__(self)
- self.tb = tb
-
- def eval(self, ignore):
- """
- This method is called from blocks.bin_statistics_f when it wants
- to change the center frequency. This method tunes the front
- end to the new center frequency, and returns the new frequency
- as its result.
- """
-
- try:
- # We use this try block so that if something goes wrong
- # from here down, at least we'll have a prayer of knowing
- # what went wrong. Without this, you get a very
- # mysterious:
- #
- # terminate called after throwing an instance of
- # 'Swig::DirectorMethodException' Aborted
- #
- # message on stderr. Not exactly helpful ;)
-
- new_freq = self.tb.set_next_freq()
-
- # wait until msgq is empty before continuing
- while(self.tb.msgq.full_p()):
- #print "msgq full, holding.."
- time.sleep(0.1)
-
- return new_freq
-
- except Exception, e:
- print "tune: Exception: ", e
-
-
-class parse_msg(object):
- def __init__(self, msg):
- self.center_freq = msg.arg1()
- self.vlen = int(msg.arg2())
- assert(msg.length() == self.vlen * gr.sizeof_float)
-
- # FIXME consider using NumPy array
- t = msg.to_string()
- self.raw_data = t
- self.data = struct.unpack('%df' % (self.vlen,), t)
-
-
-class my_top_block(gr.top_block):
-
- def __init__(self):
- gr.top_block.__init__(self)
-
- usage = "usage: %prog [options] min_freq max_freq"
- parser = OptionParser(option_class=eng_option, usage=usage)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6,
- help="set sample rate [default=%default]")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("", "--tune-delay", type="eng_float",
- default=0.25, metavar="SECS",
- help="time to delay (in seconds) after changing frequency [default=%default]")
- parser.add_option("", "--dwell-delay", type="eng_float",
- default=0.25, metavar="SECS",
- help="time to dwell (in seconds) at a given frequency [default=%default]")
- parser.add_option("-b", "--channel-bandwidth", type="eng_float",
- default=6.25e3, metavar="Hz",
- help="channel bandwidth of fft bins in Hz [default=%default]")
- parser.add_option("-l", "--lo-offset", type="eng_float",
- default=0, metavar="Hz",
- help="lo_offset in Hz [default=%default]")
- parser.add_option("-q", "--squelch-threshold", type="eng_float",
- default=None, metavar="dB",
- help="squelch threshold in dB [default=%default]")
- parser.add_option("-F", "--fft-size", type="int", default=None,
- help="specify number of FFT bins [default=samp_rate/channel_bw]")
- parser.add_option("", "--real-time", action="store_true", default=False,
- help="Attempt to enable real-time scheduling")
-
- (options, args) = parser.parse_args()
- if len(args) != 2:
- parser.print_help()
- sys.exit(1)
-
- self.channel_bandwidth = options.channel_bandwidth
-
- self.min_freq = eng_notation.str_to_num(args[0])
- self.max_freq = eng_notation.str_to_num(args[1])
-
- if self.min_freq > self.max_freq:
- # swap them
- self.min_freq, self.max_freq = self.max_freq, self.min_freq
-
- if not options.real_time:
- realtime = False
- else:
- # Attempt to enable realtime scheduling
- r = gr.enable_realtime_scheduling()
- if r == gr.RT_OK:
- realtime = True
- else:
- realtime = False
- print "Note: failed to enable realtime scheduling"
-
- # build graph
- self.u = uhd.usrp_source(device_addr=options.args,
- stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- self.u.set_samp_rate(options.samp_rate)
- self.usrp_rate = usrp_rate = self.u.get_samp_rate()
-
- self.lo_offset = options.lo_offset
-
- if options.fft_size is None:
- self.fft_size = int(self.usrp_rate/self.channel_bandwidth)
- else:
- self.fft_size = options.fft_size
-
- self.squelch_threshold = options.squelch_threshold
-
- s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
-
- mywindow = filter.window.blackmanharris(self.fft_size)
- ffter = fft.fft_vcc(self.fft_size, True, mywindow, True)
- power = 0
- for tap in mywindow:
- power += tap*tap
-
- c2mag = blocks.complex_to_mag_squared(self.fft_size)
-
- # FIXME the log10 primitive is dog slow
- #log = blocks.nlog10_ff(10, self.fft_size,
- # -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
-
- # Set the freq_step to 75% of the actual data throughput.
- # This allows us to discard the bins on both ends of the spectrum.
-
- self.freq_step = self.nearest_freq((0.75 * self.usrp_rate), self.channel_bandwidth)
- self.min_center_freq = self.min_freq + (self.freq_step/2)
- nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step)
- self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step)
-
- self.next_freq = self.min_center_freq
-
- tune_delay = max(0, int(round(options.tune_delay * usrp_rate / self.fft_size))) # in fft_frames
- dwell_delay = max(1, int(round(options.dwell_delay * usrp_rate / self.fft_size))) # in fft_frames
-
- self.msgq = gr.msg_queue(1)
- self._tune_callback = tune(self) # hang on to this to keep it from being GC'd
- stats = blocks.bin_statistics_f(self.fft_size, self.msgq,
- self._tune_callback, tune_delay,
- dwell_delay)
-
- # FIXME leave out the log10 until we speed it up
- #self.connect(self.u, s2v, ffter, c2mag, log, stats)
- self.connect(self.u, s2v, ffter, c2mag, stats)
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2.0
-
- self.set_gain(options.gain)
- print "gain =", options.gain
-
- def set_next_freq(self):
- target_freq = self.next_freq
- self.next_freq = self.next_freq + self.freq_step
- if self.next_freq >= self.max_center_freq:
- self.next_freq = self.min_center_freq
-
- if not self.set_freq(target_freq):
- print "Failed to set frequency to", target_freq
- sys.exit(1)
-
- return target_freq
-
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
- """
-
- r = self.u.set_center_freq(uhd.tune_request(target_freq, rf_freq=(target_freq + self.lo_offset),rf_freq_policy=uhd.tune_request.POLICY_MANUAL))
- if r:
- return True
-
- return False
-
- def set_gain(self, gain):
- self.u.set_gain(gain)
-
- def nearest_freq(self, freq, channel_bandwidth):
- freq = round(freq / channel_bandwidth, 0) * channel_bandwidth
- return freq
-
-def main_loop(tb):
-
- def bin_freq(i_bin, center_freq):
- #hz_per_bin = tb.usrp_rate / tb.fft_size
- freq = center_freq - (tb.usrp_rate / 2) + (tb.channel_bandwidth * i_bin)
- #print "freq original:",freq
- #freq = nearest_freq(freq, tb.channel_bandwidth)
- #print "freq rounded:",freq
- return freq
-
- bin_start = int(tb.fft_size * ((1 - 0.75) / 2))
- bin_stop = int(tb.fft_size - bin_start)
-
- timestamp = 0
- centerfreq = 0
- while 1:
-
- # Get the next message sent from the C++ code (blocking call).
- # It contains the center frequency and the mag squared of the fft
- m = parse_msg(tb.msgq.delete_head())
-
- # m.center_freq is the center frequency at the time of capture
- # m.data are the mag_squared of the fft output
- # m.raw_data is a string that contains the binary floats.
- # You could write this as binary to a file.
-
- # Scanning rate
- if timestamp == 0:
- timestamp = time.time()
- centerfreq = m.center_freq
- if m.center_freq < centerfreq:
- sys.stderr.write("scanned %.1fMHz in %.1fs\n" % ((centerfreq - m.center_freq)/1.0e6, time.time() - timestamp))
- timestamp = time.time()
- centerfreq = m.center_freq
-
- for i_bin in range(bin_start, bin_stop):
-
- center_freq = m.center_freq
- freq = bin_freq(i_bin, center_freq)
- #noise_floor_db = -174 + 10*math.log10(tb.channel_bandwidth)
- noise_floor_db = 10*math.log10(min(m.data)/tb.usrp_rate)
- power_db = 10*math.log10(m.data[i_bin]/tb.usrp_rate) - noise_floor_db
-
- if (power_db > tb.squelch_threshold) and (freq >= tb.min_freq) and (freq <= tb.max_freq):
- print datetime.now(), "center_freq", center_freq, "freq", freq, "power_db", power_db, "noise_floor_db", noise_floor_db
-
-if __name__ == '__main__':
- t = ThreadClass()
- t.start()
-
- tb = my_top_block()
- try:
- tb.start()
- main_loop(tb)
-
- except KeyboardInterrupt:
- pass
diff --git a/gr-uhd/examples/python/usrp_tv_rcv.py b/gr-uhd/examples/python/usrp_tv_rcv.py
deleted file mode 100755
index 301840f41d..0000000000
--- a/gr-uhd/examples/python/usrp_tv_rcv.py
+++ /dev/null
@@ -1,446 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2011-2013 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-"""
-Realtime capture and display of analog Tv stations.
-
-Can also use a file as source or sink
-
-When you use an output file you can show the results frame-by-frame
-using ImageMagick
-
-When you want to use the realtime sdl display window you must first
-install gr-video-sdl.
-
-When you use a file source, instead of the usrp, make sure you
-capture interleaved shorts. (Use usrp_rx_file.py, or use
-usrp_rx_cfile.py --output-shorts if you have a recent enough
-usrp_rx_cfile.py)
-
-There is no synchronisation yet. The sync blocks are in development
-but not yet in cvs.
-"""
-
-from gnuradio import gr
-try:
- from gnuradio import video_sdl
-except:
- print "FYI: gr-video-sdl is not installed"
- print "realtime SDL video output window will not be available"
-from gnuradio import uhd
-from gnuradio import analog
-from gnuradio import blocks
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import slider, powermate
-from gnuradio.wxgui import stdgui2, fftsink2, form
-from optparse import OptionParser
-import sys
-import wx
-
-
-class tv_rx_block (stdgui2.std_top_block):
- def __init__(self,frame,panel,vbox,argv):
- stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv)
-
- usage="%prog: [options] [input_filename]. \n If you don't specify an input filename the usrp will be used as source\n " \
- "Make sure your input capture file containes interleaved shorts not complex floats"
- parser=OptionParser(option_class=eng_option, usage=usage)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6,
- help="set sample rate")
- parser.add_option("-f", "--freq", type="eng_float", default=519.25e6,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-c", "--contrast", type="eng_float", default=1.0,
- help="set contrast (default is 1.0)")
- parser.add_option("-b", "--brightness", type="eng_float", default=0.0,
- help="set brightness (default is 0)")
- parser.add_option("-p", "--pal", action="store_true", default=False,
- help="PAL video format (this is the default)")
- parser.add_option("-n", "--ntsc", action="store_true", default=False,
- help="NTSC video format")
- parser.add_option("-o", "--out-filename", type="string", default="sdl",
- help="For example out_raw_uchar.gray. If you don't specify an output filename you will get a video_sink_sdl realtime output window. You then need to have gr-video-sdl installed)")
- parser.add_option("-r", "--repeat", action="store_false", default=True,
- help="repeat file in a loop")
- parser.add_option("", "--freq-min", type="eng_float", default=50.25e6,
- help="Set a minimum frequency [default=%default]")
- parser.add_option("", "--freq-max", type="eng_float", default=900.25e6,
- help="Set a maximum frequency [default=%default]")
-
- (options, args) = parser.parse_args()
- if not ((len(args) == 1) or (len(args) == 0)):
- parser.print_help()
- sys.exit(1)
-
- if len(args) == 1:
- filename = args[0]
- else:
- filename = None
-
- self.frame = frame
- self.panel = panel
-
- self.contrast = options.contrast
- self.brightness = options.brightness
- self.state = "FREQ"
- self.freq = 0
-
- self.tv_freq_min = options.freq_min
- self.tv_freq_max = options.freq_max
-
- # build graph
- self.u=None
-
- if not (options.out_filename=="sdl"):
- options.repeat=False
-
- usrp_rate = options.samp_rate
-
- if not ((filename is None) or (filename=="usrp")):
- # file is data source
- self.filesource = blocks.file_source(gr.sizeof_short,filename,options.repeat)
- self.istoc = blocks.interleaved_short_to_complex()
- self.connect(self.filesource,self.istoc)
- self.src=self.istoc
-
- options.gain=0.0
- self.gain=0.0
-
- else: # use a UHD device
- self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- self.u.set_samp_rate(usrp_rate)
- dev_rate = self.u.get_samp_rate()
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2.0
-
- self.src=self.u
-
- self.gain = options.gain
-
- f2uc = blocks.float_to_uchar()
-
- # sdl window as final sink
- if not (options.pal or options.ntsc):
- options.pal=True #set default to PAL
-
- if options.pal:
- lines_per_frame=625.0
- frames_per_sec=25.0
- show_width=768
-
- elif options.ntsc:
- lines_per_frame=525.0
- frames_per_sec=29.97002997
- show_width=640
-
- width=int(usrp_rate/(lines_per_frame*frames_per_sec))
- height=int(lines_per_frame)
-
- if (options.out_filename=="sdl"):
- #Here comes the tv screen, you have to build and install
- #gr-video-sdl for this (subproject of gnuradio, only in cvs
- #for now)
- try:
- video_sink = video_sdl.sink_uc ( frames_per_sec, width, height, 0,
- show_width, height)
- except:
- print "gr-video-sdl is not installed"
- print "realtime \"sdl\" video output window is not available"
- raise SystemExit, 1
- self.dst=video_sink
- else:
- print "You can use the imagemagick display tool to show the resulting imagesequence"
- print "use the following line to show the demodulated TV-signal:"
- print "display -depth 8 -size " +str(width)+ "x" + str(height) \
- + " gray:" + options.out_filename
- print "(Use the spacebar to advance to next frames)"
- options.repeat=False
- file_sink = blocks.file_sink(gr.sizeof_char, options.out_filename)
- self.dst =file_sink
-
- self.agc = analog.agc_cc(1e-7,1.0,1.0) #1e-7
- self.am_demod = blocks.complex_to_mag ()
- self.set_blacklevel = blocks.add_const_ff(0.0)
- self.invert_and_scale = blocks.multiply_const_ff (0.0) #-self.contrast *128.0*255.0/(200.0)
-
- # now wire it all together
- #sample_rate=options.width*options.height*options.framerate
-
- process_type='do_no_sync'
- if process_type=='do_no_sync':
- self.connect (self.src, self.agc,self.am_demod,
- self.invert_and_scale, self.set_blacklevel,
- f2uc,self.dst)
- elif process_type=='do_tv_sync_adv':
- #defaults: gr.tv_sync_adv (double sampling_freq, unsigned
- #int tv_format,bool output_active_video_only=false, bool
- #do_invert=false, double wanted_black_level=0.0, double
- #wanted_white_level=255.0, double avg_alpha=0.1, double
- #initial_gain=1.0, double initial_offset=0.0,bool
- #debug=false)
-
- #note, this block is not yet in cvs
- self.tv_sync_adv=gr.tv_sync_adv(usrp_rate, 0, False, False,
- 0.0, 255.0, 0.01, 1.0, 0.0, False)
- self.connect (self.src, self.am_demod, self.invert_and_scale,
- self.tv_sync_adv, s2f, f2uc, self.dst)
-
- elif process_type=='do_nullsink':
- #self.connect (self.src, self.am_demod,self.invert_and_scale,f2uc,video_sink)
- c2r=blocks.complex_to_real()
- nullsink=blocks.null_sink(gr.sizeof_float)
- self.connect (self.src, c2r,nullsink) #video_sink)
- elif process_type=='do_tv_sync_corr':
- frame_size=width*height #int(usrp_rate/25.0)
- nframes=10# 32
- search_window=20*nframes
- debug=False
- video_alpha=0.3 #0.1
- corr_alpha=0.3
-
- #Note: this block is not yet in cvs
- tv_corr=gr.tv_correlator_ff(frame_size,nframes, search_window,
- video_alpha, corr_alpha,debug)
- shift = blocks.add_const_ff(-0.7)
-
- self.connect (self.src, self.agc, self.am_demod, tv_corr,
- self.invert_and_scale, self.set_blacklevel,
- f2uc, self.dst)
- else: # process_type=='do_test_image':
- src_vertical_bars = analog.sig_source_f(usrp_rate, analog.GR_SIN_WAVE,
- 10.0 *usrp_rate/320, 255,128)
- self.connect(src_vertical_bars, f2uc, self.dst)
-
- self._build_gui(vbox, usrp_rate, usrp_rate, usrp_rate)
-
-
- frange = self.u.get_freq_range()
- if(frange.start() > self.tv_freq_max or frange.stop() < self.tv_freq_min):
- sys.stderr.write("Radio does not support required frequency range.\n")
- sys.exit(1)
- if(options.freq < self.tv_freq_min or options.freq > self.tv_freq_max):
- sys.stderr.write("Requested frequency is outside of required frequency range.\n")
- sys.exit(1)
-
- # set initial values
- self.set_gain(options.gain)
- self.set_contrast(self.contrast)
- self.set_brightness(options.brightness)
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
-
- def _set_status_msg(self, msg, which=0):
- self.frame.GetStatusBar().SetStatusText(msg, which)
-
-
- def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
-
- if 0:
- self.src_fft = fftsink.fft_sink_c (self, self.panel, title="Data from USRP",
- fft_size=512, sample_rate=usrp_rate)
- self.connect (self.src, self.src_fft)
- vbox.Add (self.src_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_demod_fft = fftsink.fft_sink_f (self, self.panel, title="Post Demod",
- fft_size=512, sample_rate=demod_rate,
- y_per_div=10, ref_level=-40)
- self.connect (self.am_demod, post_demod_fft)
- vbox.Add (post_demod_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_filt_fft = fftsink.fft_sink_f (self, self.panel, title="Post Filter",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=-40)
- self.connect (self.set_blacklevel, post_filt)
- vbox.Add (fft_win4, 4, wx.EXPAND)
-
-
- # control area form at bottom
- self.myform = myform = form.form()
-
- if not (self.u is None):
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0)
- myform['freq_slider'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3,
- range=(self.tv_freq_min, self.tv_freq_max, 0.25e6),
- callback=self.set_freq)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['contrast'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Contrast",
- weight=3, range=(-2.0, 2.0, 0.1),
- callback=self.set_contrast)
- hbox.Add((5,0), 1)
-
- myform['brightness'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Brightness",
- weight=3, range=(-255.0, 255.0, 1.0),
- callback=self.set_brightness)
- hbox.Add((5,0), 0)
-
- if not (self.u is None):
- g = self.u.get_gain_range()
- myform['gain'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3, range=(g.start(), g.stop(), g.step()),
- callback=self.set_gain)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- try:
- self.knob = powermate.powermate(self.frame)
- self.rot = 0
- powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate)
- powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button)
- except:
- print "FYI: No Powermate or Contour Knob found"
-
-
- def on_rotate (self, event):
- self.rot += event.delta
- if (self.state == "FREQ"):
- if self.rot >= 3:
- self.set_freq(self.freq + .1e6)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_freq(self.freq - .1e6)
- self.rot += 3
- elif (self.state == "CONTRAST"):
- step = 0.1
- if self.rot >= 3:
- self.set_contrast(self.contrast + step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_contrast(self.contrast - step)
- self.rot += 3
- else:
- step = 1
- if self.rot >= 3:
- self.set_brightness(self.brightness + step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_brightness(self.brightness - step)
- self.rot += 3
-
- def on_button (self, event):
- if event.value == 0: # button up
- return
- self.rot = 0
- if self.state == "FREQ":
- self.state = "CONTRAST"
- elif self.state == "CONTRAST":
- self.state = "BRIGHTNESS"
- else:
- self.state = "FREQ"
- self.update_status_bar ()
-
-
- def set_contrast (self, contrast):
- self.contrast = contrast
- self.invert_and_scale.set_k(-self.contrast *128.0*255.0/(200.0))
- self.myform['contrast'].set_value(self.contrast)
- self.update_status_bar ()
-
- def set_brightness (self, brightness):
- self.brightness = brightness
- self.set_blacklevel.set_k(self.brightness +255.0)
- self.myform['brightness'].set_value(self.brightness)
- self.update_status_bar ()
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
-
- Tuning is a two step process. First we ask the front-end to
- tune as close to the desired frequency as it can. Then we use
- the result of that operation and our target_frequency to
- determine the value for the digital down converter.
- """
- if not (self.u is None):
- r = self.u.set_center_freq(target_freq)
- if r:
- self.freq = target_freq
- self.myform['freq'].set_value(target_freq) # update displayed value
- self.myform['freq_slider'].set_value(target_freq) # update displayed value
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
-
- self._set_status_msg("Failed", 0)
- return False
-
- def set_gain(self, gain):
- if not (self.u is None):
- self.gain=gain
- self.myform['gain'].set_value(gain) # update displayed value
- self.u.set_gain(gain)
- self.update_status_bar()
-
- def update_status_bar (self):
- msg = "Setting:%s Contrast:%r Brightness:%r Gain: %r" % \
- (self.state, self.contrast,self.brightness,self.gain)
- self._set_status_msg(msg, 1)
- #self.src_fft.set_baseband_freq(self.freq)
-
-
-if __name__ == '__main__':
- app = stdgui2.stdapp (tv_rx_block, "USRP TV RX black-and-white")
- app.MainLoop ()
diff --git a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py
deleted file mode 100755
index 80e2e1c17a..0000000000
--- a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py
+++ /dev/null
@@ -1,215 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2011,2013 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-"""
-Reads from a file and generates PAL TV pictures in black and white
-which can be displayed using ImageMagick or realtime using
-gr-video-sdl (To capture the input file Use usrp_rx_file.py, or use
-usrp_rx_cfile.py --output-shorts if you have a recent enough
-usrp_rx_cfile.py)
-
-Can also use usrp directly as capture source, but then you need a
-higher decimation factor (64) and thus get a lower horizontal
-resulution. There is no synchronisation yet. The sync blocks are in
-development but not yet in cvs.
-
-"""
-
-from gnuradio import gr, eng_notation
-from gnuradio import analog
-from gnuradio import blocks
-from gnuradio import audio
-from gnuradio import uhd
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-import sys
-
-try:
- from gnuradio import video_sdl
-except:
- print "FYI: gr-video-sdl is not installed"
- print "realtime \"sdl\" video output window will not be available"
-
-
-class my_top_block(gr.top_block):
-
- def __init__(self):
- gr.top_block.__init__(self)
-
- usage=("%prog: [options] output_filename.\nSpecial output_filename" + \
- "\"sdl\" will use video_sink_sdl as realtime output window. " + \
- "You then need to have gr-video-sdl installed.\n" +\
- "Make sure your input capture file containes interleaved " + \
- "shorts not complex floats")
- parser = OptionParser(option_class=eng_option, usage=usage)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6,
- help="set sample rate")
- parser.add_option("-c", "--contrast", type="eng_float", default=1.0,
- help="set contrast (default is 1.0)")
- parser.add_option("-b", "--brightness", type="eng_float", default=0.0,
- help="set brightness (default is 0)")
- parser.add_option("-i", "--in-filename", type="string", default=None,
- help="Use input file as source. samples must be " + \
- "interleaved shorts \n Use usrp_rx_file.py or " + \
- "usrp_rx_cfile.py --output-shorts.\n Special " + \
- "name \"usrp\" results in realtime capturing " + \
- "and processing using usrp.\n" + \
- "You then probably need a decimation factor of 64 or higher.")
- parser.add_option("-f", "--freq", type="eng_float", default=519.25e6,
- help="set frequency to FREQ.\nNote that the frequency of the video carrier is not at the middle of the TV channel", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-p", "--pal", action="store_true", default=False,
- help="PAL video format (this is the default)")
- parser.add_option("-n", "--ntsc", action="store_true", default=False,
- help="NTSC video format")
- parser.add_option("-r", "--repeat", action="store_false", default=True,
- help="repeat in_file in a loop")
- parser.add_option("-N", "--nframes", type="eng_float", default=None,
- help="number of frames to collect [default=+inf]")
- parser.add_option("", "--freq-min", type="eng_float", default=50.25e6,
- help="Set a minimum frequency [default=%default]")
- parser.add_option("", "--freq-max", type="eng_float", default=900.25e6,
- help="Set a maximum frequency [default=%default]")
- (options, args) = parser.parse_args ()
- if not (len(args) == 1):
- parser.print_help()
- sys.stderr.write('You must specify the output. FILENAME or sdl \n');
- sys.exit(1)
-
- filename = args[0]
-
- self.tv_freq_min = options.freq_min
- self.tv_freq_max = options.freq_max
-
- if options.in_filename is None:
- parser.print_help()
- sys.stderr.write('You must specify the input -i FILENAME or -i usrp\n');
- raise SystemExit, 1
-
- if not (filename=="sdl"):
- options.repeat=False
-
- input_rate = options.samp_rate
- print "video sample rate %s" % (eng_notation.num_to_str(input_rate))
-
- if not (options.in_filename=="usrp"):
- # file is data source, capture with usr_rx_csfile.py
- self.filesource = blocks.file_source(gr.sizeof_short,
- options.in_filename,
- options.repeat)
- self.istoc = blocks.interleaved_short_to_complex()
- self.connect(self.filesource,self.istoc)
- self.src=self.istoc
- else:
- if options.freq is None:
- parser.print_help()
- sys.stderr.write('You must specify the frequency with -f FREQ\n');
- raise SystemExit, 1
-
- # build the graph
- self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- self.u.set_samp_rate(input_rate)
- dev_rate = self.u.get_samp_rate()
-
- self.src=self.u
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2.0
- self.u.set_gain(options.gain)
-
- r = self.u.set_center_freq(options.freq)
- if not r:
- sys.stderr.write('Failed to set frequency\n')
- raise SystemExit, 1
-
-
- self.agc = analog.agc_cc(1e-7,1.0,1.0) #1e-7
- self.am_demod = blocks.complex_to_mag ()
- self.set_blacklevel = blocks.add_const_ff(options.brightness +255.0)
- self.invert_and_scale = blocks.multiply_const_ff(-options.contrast *128.0*255.0/(200.0))
- self.f2uc = blocks.float_to_uchar()
-
- # sdl window as final sink
- if not (options.pal or options.ntsc):
- options.pal=True #set default to PAL
- if options.pal:
- lines_per_frame=625.0
- frames_per_sec=25.0
- show_width=768
- elif options.ntsc:
- lines_per_frame=525.0
- frames_per_sec=29.97002997
- show_width=640
- width=int(input_rate/(lines_per_frame*frames_per_sec))
- height=int(lines_per_frame)
-
- if filename=="sdl":
- #Here comes the tv screen, you have to build and install
- #gr-video-sdl for this (subproject of gnuradio)
- try:
- video_sink = video_sdl.sink_uc(frames_per_sec, width, height, 0,
- show_width,height)
- except:
- print "gr-video-sdl is not installed"
- print "realtime \"sdl\" video output window is not available"
- raise SystemExit, 1
- self.dst=video_sink
- else:
- print "You can use the imagemagick display tool to show the resulting imagesequence"
- print "use the following line to show the demodulated TV-signal:"
- print "display -depth 8 -size " +str(width)+ "x" + str(height) + " gray:" +filename
- print "(Use the spacebar to advance to next frames)"
- file_sink = blocks.file_sink(gr.sizeof_char, filename)
- self.dst =file_sink
-
- if options.nframes is None:
- self.connect(self.src, self.agc)
- else:
- self.head = blocks.head(gr.sizeof_gr_complex, int(options.nframes*width*height))
- self.connect(self.src, self.head, self.agc)
-
- self.connect (self.agc, self.am_demod, self.invert_and_scale,
- self.set_blacklevel, self.f2uc, self.dst)
-
-if __name__ == '__main__':
- try:
- my_top_block().run()
- except KeyboardInterrupt:
- pass
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv.py b/gr-uhd/examples/python/usrp_wfm_rcv.py
deleted file mode 100755
index c11c18980c..0000000000
--- a/gr-uhd/examples/python/usrp_wfm_rcv.py
+++ /dev/null
@@ -1,290 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2009,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, audio, uhd
-from gnuradio import blocks
-from gnuradio import filter
-from gnuradio import analog
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import slider, powermate
-from gnuradio.wxgui import stdgui2, fftsink2, form
-from optparse import OptionParser
-import sys
-import wx
-
-
-class wfm_rx_block (stdgui2.std_top_block):
- def __init__(self,frame,panel,vbox,argv):
- stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv)
-
- parser=OptionParser(option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-f", "--freq", type="eng_float", default=100.1e6,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-V", "--volume", type="eng_float", default=None,
- help="set volume (default is midpoint)")
- parser.add_option("-O", "--audio-output", type="string", default="default",
- help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp")
- parser.add_option("", "--freq-min", type="eng_float", default=87.9e6,
- help="Set a minimum frequency [default=%default]")
- parser.add_option("", "--freq-max", type="eng_float", default=108.1e6,
- help="Set a maximum frequency [default=%default]")
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- self.frame = frame
- self.panel = panel
-
- self.vol = 0
- self.state = "FREQ"
- self.freq = 0
-
- self.fm_freq_min = options.freq_min
- self.fm_freq_max = options.freq_max
-
- # build graph
- self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- usrp_rate = 320e3
- demod_rate = 320e3
- audio_rate = 32e3
- audio_decim = int(demod_rate / audio_rate)
-
- self.u.set_samp_rate(usrp_rate)
- dev_rate = self.u.get_samp_rate()
-
- nfilts = 32
- chan_coeffs = filter.optfir.low_pass(nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 80e3, # passband cutoff
- 115e3, # stopband cutoff
- 0.1, # passband ripple
- 60) # stopband attenuation
- rrate = usrp_rate / dev_rate
- self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
-
- self.guts = analog.wfm_rcv(demod_rate, audio_decim)
-
- self.volume_control = blocks.multiply_const_ff(self.vol)
-
- # sound card as final sink
- self.audio_sink = audio.sink(int (audio_rate),
- options.audio_output,
- False) # ok_to_block
-
- # now wire it all together
- self.connect(self.u, self.chan_filt, self.guts,
- self.volume_control, self.audio_sink)
-
- self._build_gui(vbox, usrp_rate, demod_rate, audio_rate)
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2
-
- if options.volume is None:
- g = self.volume_range()
- options.volume = float(g[0]+g[1])/2
-
- frange = self.u.get_freq_range()
- if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min):
- sys.stderr.write("Radio does not support required frequency range.\n")
- sys.exit(1)
- if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max):
- sys.stderr.write("Requested frequency is outside of required frequency range.\n")
- sys.exit(1)
-
-
- # set initial values
-
- self.set_gain(options.gain)
- self.set_vol(options.volume)
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
- def _set_status_msg(self, msg, which=0):
- self.frame.GetStatusBar().SetStatusText(msg, which)
-
-
- def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
-
- if 1:
- self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP",
- fft_size=512, sample_rate=usrp_rate,
- ref_scale=32768.0, ref_level=0, y_divs=12)
- self.connect (self.u, self.src_fft)
- vbox.Add (self.src_fft.win, 4, wx.EXPAND)
-
- if 1:
- post_filt_fft = fftsink2.fft_sink_f(self.panel, title="Post Demod",
- fft_size=1024, sample_rate=usrp_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.guts.fm_demod, post_filt_fft)
- vbox.Add (post_filt_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_deemph_fft = fftsink2.fft_sink_f(self.panel, title="Post Deemph",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=-20)
- self.connect (self.guts.deemph, post_deemph_fft)
- vbox.Add (post_deemph_fft.win, 4, wx.EXPAND)
-
-
- # control area form at bottom
- self.myform = myform = form.form()
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0)
- myform['freq_slider'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3,
- range=(self.fm_freq_min, self.fm_freq_max, 0.1e6),
- callback=self.set_freq)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['volume'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume",
- weight=3, range=self.volume_range(),
- callback=self.set_vol)
- hbox.Add((5,0), 1)
-
- g = self.u.get_gain_range()
- myform['gain'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3, range=(g.start(), g.stop(), g.step()),
- callback=self.set_gain)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- try:
- self.knob = powermate.powermate(self.frame)
- self.rot = 0
- powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate)
- powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button)
- except:
- print "FYI: No Powermate or Contour Knob found"
-
-
- def on_rotate (self, event):
- self.rot += event.delta
- if (self.state == "FREQ"):
- if self.rot >= 3:
- self.set_freq(self.freq + .1e6)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_freq(self.freq - .1e6)
- self.rot += 3
- else:
- step = self.volume_range()[2]
- if self.rot >= 3:
- self.set_vol(self.vol + step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_vol(self.vol - step)
- self.rot += 3
-
- def on_button (self, event):
- if event.value == 0: # button up
- return
- self.rot = 0
- if self.state == "FREQ":
- self.state = "VOL"
- else:
- self.state = "FREQ"
- self.update_status_bar ()
-
-
- def set_vol (self, vol):
- g = self.volume_range()
- self.vol = max(g[0], min(g[1], vol))
- self.volume_control.set_k(10**(self.vol/10))
- self.myform['volume'].set_value(self.vol)
- self.update_status_bar ()
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
- """
-
- r = self.u.set_center_freq(target_freq)
- if r:
- self.freq = target_freq
- self.myform['freq'].set_value(target_freq) # update displayed value
- self.myform['freq_slider'].set_value(target_freq) # update displayed value
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
-
- self._set_status_msg("Failed", 0)
- return False
-
- def set_gain(self, gain):
- self.myform['gain'].set_value(gain) # update displayed value
- self.u.set_gain(gain)
-
- def update_status_bar (self):
- msg = "Volume:%r Setting:%s" % (self.vol, self.state)
- self._set_status_msg(msg, 1)
- self.src_fft.set_baseband_freq(self.freq)
-
- def volume_range(self):
- return (-20.0, 0.0, 0.5)
-
-
-if __name__ == '__main__':
- app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX")
- app.MainLoop ()
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py b/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py
deleted file mode 100755
index c5b42cbf08..0000000000
--- a/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py
+++ /dev/null
@@ -1,157 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, audio, uhd
-from gnuradio import blocks
-from gnuradio import filter
-from gnuradio import analog
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-import sys
-import math
-
-class wfm_rx_block (gr.top_block):
-
- def __init__(self):
- gr.top_block.__init__(self)
-
- parser=OptionParser(option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default="A:0 A:0",
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("", "--f1", type="eng_float", default=100.7e6,
- help="set 1st station frequency to FREQ", metavar="FREQ")
- parser.add_option("", "--f2", type="eng_float", default=102.5e6,
- help="set 2nd station freq to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-O", "--audio-output", type="string", default="default",
- help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp")
- parser.add_option("", "--freq-min", type="eng_float", default=87.9e6,
- help="Set a minimum frequency [default=%default]")
- parser.add_option("", "--freq-max", type="eng_float", default=108.1e6,
- help="Set a maximum frequency [default=%default]")
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- if abs(options.f1 - options.f2) > 5.5e6:
- print "Sorry, two stations must be within 5.5MHz of each other"
- raise SystemExit
-
- f = (options.f1, options.f2)
-
- self.vol = .1
- self.state = "FREQ"
-
- self.fm_freq_min = options.freq_min
- self.fm_freq_max = options.freq_max
-
- # build graph
- stream_args = uhd.stream_args('fc32', channels=range(2))
- self.u = uhd.usrp_source(device_addr=options.args, stream_args=stream_args)
-
- # Set front end channel mapping
- self.u.set_subdev_spec(options.spec)
-
- usrp_rate = 320e3
- demod_rate = 320e3
- audio_rate = 32e3
- audio_decim = int(demod_rate / audio_rate)
-
- self.u.set_samp_rate(usrp_rate)
- dev_rate = self.u.get_samp_rate()
-
- # Make sure dboard can suppor the required frequencies
- frange = self.u.get_freq_range()
- if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min):
- sys.stderr.write("Radio does not support required frequency range.\n")
- sys.exit(1)
-
- # sound card as final sink
- self.audio_sink = audio.sink(int(audio_rate), options.audio_output)
-
- # taps for channel filter
- nfilts = 32
- chan_coeffs = filter.optfir.low_pass(nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 80e3, # passband cutoff
- 115e3, # stopband cutoff
- 0.1, # passband ripple
- 60) # stopband attenuation
- rrate = usrp_rate / dev_rate
-
- # set front end PLL to middle frequency
- mid_freq = (f[0] + f[1]) / 2.0
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2.0
-
- for n in range(2):
- chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
- guts = analog.wfm_rcv(demod_rate, audio_decim)
- volume_control = blocks.multiply_const_ff(self.vol)
-
- #self.connect((self.di, n), chan_filt)
- self.connect((self.u, n), chan_filt)
- self.connect(chan_filt, guts, volume_control)
- self.connect(volume_control, (self.audio_sink, n))
-
- # Test the the requested frequencies are in range
- if(f[n] < self.fm_freq_min or f[n] > self.fm_freq_max):
- sys.stderr.write("Requested frequency is outside of required frequency range.\n")
- sys.exit(1)
-
- # Tune each channel by setting the RF freq to mid_freq and the
- # DDC freq to f[n].
- tr = uhd.tune_request(f[n], rf_freq=mid_freq,
- rf_freq_policy=uhd.tune_request.POLICY_MANUAL)
- self.u.set_center_freq(tr, n)
-
- # Set gain for each channel
- self.set_gain(options.gain, n)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, n)
-
- def set_vol (self, vol):
- self.vol = vol
- self.volume_control.set_k(self.vol)
-
-
- def set_gain(self, gain, n):
- self.u.set_gain(gain, n)
-
-if __name__ == '__main__':
- tb = wfm_rx_block()
- try:
- tb.run()
- except KeyboardInterrupt:
- pass
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py b/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py
deleted file mode 100755
index 599f0bc460..0000000000
--- a/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py
+++ /dev/null
@@ -1,353 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, audio, uhd
-from gnuradio import blocks
-from gnuradio import filter
-from gnuradio import analog
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import slider, powermate
-from gnuradio.wxgui import stdgui2, fftsink2, form, scopesink2
-from optparse import OptionParser
-import sys
-import wx
-
-class wfm_rx_block (stdgui2.std_top_block):
- def __init__(self,frame,panel,vbox,argv):
- stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv)
-
- parser=OptionParser(option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-f", "--freq", type="eng_float", default=100.1e6,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-s", "--squelch", type="eng_float", default=0,
- help="set squelch level (default is 0)")
- parser.add_option("-V", "--volume", type="eng_float", default=None,
- help="set volume (default is midpoint)")
- parser.add_option("-O", "--audio-output", type="string", default="default",
- help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp")
- parser.add_option("", "--freq-min", type="eng_float", default=87.9e6,
- help="Set a minimum frequency [default=%default]")
- parser.add_option("", "--freq-max", type="eng_float", default=108.1e6,
- help="Set a maximum frequency [default=%default]")
-
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- self.frame = frame
- self.panel = panel
-
- self.vol = 0
- self.state = "FREQ"
- self.freq = 0
-
- self.fm_freq_min = options.freq_min
- self.fm_freq_max = options.freq_max
-
- # build graph
- self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- usrp_rate = 320e3
- demod_rate = 320e3
- audio_rate = 48e3
- audio_decim = 10
-
- self.u.set_samp_rate(usrp_rate)
- dev_rate = self.u.get_samp_rate()
-
- nfilts = 32
- chan_coeffs = filter.firdes.low_pass_2(10*nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 90e3, # passband cutoff
- 30e3, # transition bw
- 70) # stopband attenuation
- rrate = usrp_rate / dev_rate
- self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
-
- self.guts = analog.wfm_rcv_fmdet (demod_rate, audio_decim)
-
- chan_rate = audio_rate / (demod_rate/audio_decim)
- self.rchan_filt = filter.pfb.arb_resampler_fff(chan_rate)
- self.lchan_filt = filter.pfb.arb_resampler_fff(chan_rate)
-
- # FIXME rework {add,multiply}_const_* to handle multiple streams
- self.volume_control_l = blocks.multiply_const_ff(self.vol)
- self.volume_control_r = blocks.multiply_const_ff(self.vol)
-
- # sound card as final sink
- self.audio_sink = audio.sink(int (audio_rate),
- options.audio_output,
- False) # ok_to_block
-
- # now wire it all together
- self.connect(self.u, self.chan_filt, self.guts)
- self.connect((self.guts, 0), self.lchan_filt,
- self.volume_control_l, (self.audio_sink,0))
- self.connect((self.guts, 1), self.rchan_filt,
- self.volume_control_r, (self.audio_sink,1))
-
- try:
- self.guts.stereo_carrier_pll_recovery.squelch_enable(True)
- except:
- print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet"
-
-
- self._build_gui(vbox, usrp_rate, demod_rate, audio_rate)
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2.0
-
- if options.volume is None:
- g = self.volume_range()
- options.volume = float(g[0]+g[1])/2
-
- if abs(options.freq) < 1e6:
- options.freq *= 1e6
-
- frange = self.u.get_freq_range()
- if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min):
- sys.stderr.write("Radio does not support required frequency range.\n")
- sys.exit(1)
- if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max):
- sys.stderr.write("Requested frequency is outside of required frequency range.\n")
- sys.exit(1)
-
- # set initial values
- self.set_gain(options.gain)
- self.set_vol(options.volume)
- try:
- self.guts.stereo_carrier_pll_recovery.set_lock_threshold(options.squelch)
- except:
- print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet"
-
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
- def _set_status_msg(self, msg, which=0):
- self.frame.GetStatusBar().SetStatusText(msg, which)
-
-
- def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
-
- if 1:
- self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP",
- fft_size=512, sample_rate=usrp_rate,
- ref_scale=32768.0, ref_level=0, y_divs=12)
- self.connect (self.u, self.src_fft)
- vbox.Add (self.src_fft.win, 4, wx.EXPAND)
-
- if 1:
- post_fm_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod",
- fft_size=512, sample_rate=demod_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.guts.fm_demod, post_fm_demod_fft)
- vbox.Add (post_fm_demod_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_stereo_carrier_generator_fft = fftsink2.fft_sink_c (self.panel, title="Post Stereo_carrier_generator",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.guts.stereo_carrier_generator, post_stereo_carrier_generator_fft)
- vbox.Add (post_stereo_carrier_generator_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_deemphasis_left = fftsink2.fft_sink_f (self.panel, title="Post_Deemphasis_Left",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.guts.deemph_Left, post_deemphasis_left)
- vbox.Add (post_deemphasis_left.win, 4, wx.EXPAND)
-
- if 0:
- post_deemphasis_right = fftsink2.fft_sink_f(self.panel, title="Post_Deemphasis_Right",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=-20)
- self.connect (self.guts.deemph_Left, post_deemphasis_right)
- vbox.Add (post_deemphasis_right.win, 4, wx.EXPAND)
-
-
- if 0:
- LmR_fft = fftsink2.fft_sink_f(self.panel, title="LmR",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=-20)
- self.connect (self.guts.LmR_real,LmR_fft)
- vbox.Add (LmR_fft.win, 4, wx.EXPAND)
-
- if 0:
- self.scope = scopesink2.scope_sink_f(self.panel, sample_rate=demod_rate)
- self.connect (self.guts.fm_demod,self.scope)
- vbox.Add (self.scope.win,4,wx.EXPAND)
-
- # control area form at bottom
- self.myform = myform = form.form()
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0)
- myform['freq_slider'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3,
- range=(self.fm_freq_min, self.fm_freq_max, 0.1e6),
- callback=self.set_freq)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['volume'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume",
- weight=3, range=self.volume_range(),
- callback=self.set_vol)
- hbox.Add((5,0), 1)
-
- g = self.u.get_gain_range()
- myform['gain'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3, range=(g.start(), g.stop(), g.step()),
- callback=self.set_gain)
- hbox.Add((5,0), 0)
-
- myform['sqlch_thrsh'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Stereo Squelch Threshold",
- weight=3, range=(0.0,1.0,0.01),
- callback=self.set_squelch)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- try:
- self.knob = powermate.powermate(self.frame)
- self.rot = 0
- powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate)
- powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button)
- except:
- print "FYI: No Powermate or Contour Knob found"
-
-
- def on_rotate (self, event):
- self.rot += event.delta
- if (self.state == "FREQ"):
- if self.rot >= 3:
- self.set_freq(self.freq + .1e6)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_freq(self.freq - .1e6)
- self.rot += 3
- else:
- step = self.volume_range()[2]
- if self.rot >= 3:
- self.set_vol(self.vol + step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_vol(self.vol - step)
- self.rot += 3
-
- def on_button (self, event):
- if event.value == 0: # button up
- return
- self.rot = 0
- if self.state == "FREQ":
- self.state = "VOL"
- else:
- self.state = "FREQ"
- self.update_status_bar ()
-
-
- def set_vol (self, vol):
- g = self.volume_range()
- self.vol = max(g[0], min(g[1], vol))
- self.volume_control_l.set_k(10**(self.vol/10))
- self.volume_control_r.set_k(10**(self.vol/10))
- self.myform['volume'].set_value(self.vol)
- self.update_status_bar ()
-
- def set_squelch(self,squelch_threshold):
- try:
- self.guts.stereo_carrier_pll_recovery.set_lock_threshold(squelch_threshold);
- except:
- print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet"
-
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
- """
-
- r = self.u.set_center_freq(target_freq)
-
- if r:
- self.freq = target_freq
- self.myform['freq'].set_value(target_freq) # update displayed value
- self.myform['freq_slider'].set_value(target_freq) # update displayed value
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
-
- self._set_status_msg("Failed", 0)
- return False
-
- def set_gain(self, gain):
- self.myform['gain'].set_value(gain) # update displayed value
- self.u.set_gain(gain)
-
- def update_status_bar (self):
- msg = "Volume:%r Setting:%s" % (self.vol, self.state)
- self._set_status_msg(msg, 1)
- self.src_fft.set_baseband_freq(self.freq)
-
- def volume_range(self):
- return (-20.0, 0.0, 0.5)
-
-
-if __name__ == '__main__':
- app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX")
- app.MainLoop ()
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py b/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py
deleted file mode 100755
index 134df3b39e..0000000000
--- a/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py
+++ /dev/null
@@ -1,179 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, audio, uhd
-from gnuradio import blocks
-from gnuradio import filter
-from gnuradio import analog
-from gnuradio import eng_notation
-from gnuradio.eng_option import eng_option
-from optparse import OptionParser
-import sys
-
-class wfm_rx_block (gr.top_block):
-
- def __init__(self):
- gr.top_block.__init__(self)
-
- parser=OptionParser(option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-f", "--freq", type="eng_float", default=100.1e6,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-V", "--volume", type="eng_float", default=None,
- help="set volume (default is midpoint)")
- parser.add_option("-O", "--audio-output", type="string", default="default",
- help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp")
- parser.add_option("", "--freq-min", type="eng_float", default=87.9e6,
- help="Set a minimum frequency [default=%default]")
- parser.add_option("", "--freq-max", type="eng_float", default=108.1e6,
- help="Set a maximum frequency [default=%default]")
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- self.state = "FREQ"
- self.freq = 0
-
- self.fm_freq_min = options.freq_min
- self.fm_freq_max = options.freq_max
-
- # build graph
- self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- usrp_rate = 320e3
- demod_rate = 320e3
- audio_rate = 32e3
- audio_decim = int(demod_rate / audio_rate)
-
- self.u.set_samp_rate(usrp_rate)
- dev_rate = self.u.get_samp_rate()
-
- nfilts = 32
- chan_coeffs = filter.optfir.low_pass(nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 80e3, # passband cutoff
- 115e3, # stopband cutoff
- 0.1, # passband ripple
- 60) # stopband attenuation
- rrate = usrp_rate / dev_rate
- self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
-
- self.guts = analog.wfm_rcv(demod_rate, audio_decim)
-
- self.volume_control = blocks.multiply_const_ff(1)
-
- # sound card as final sink
- self.audio_sink = audio.sink(int(audio_rate),
- options.audio_output,
- False) # ok_to_block
-
- # now wire it all together
- self.connect(self.u, self.chan_filt, self.guts,
- self.volume_control, self.audio_sink)
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2.0
-
- if options.volume is None:
- g = self.volume_range()
- options.volume = float(g[0]+g[1])/2
-
- frange = self.u.get_freq_range()
- if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min):
- sys.stderr.write("Radio does not support required frequency range.\n")
- sys.exit(1)
- if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max):
- sys.stderr.write("Requested frequency is outside of required frequency range.\n")
- sys.exit(1)
-
- # set initial values
- self.set_gain(options.gain)
- self.set_vol(options.volume)
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
- def set_vol (self, vol):
- g = self.volume_range()
- self.vol = max(g[0], min(g[1], vol))
- self.volume_control.set_k(10**(self.vol/10))
- self.update_status_bar ()
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
- """
-
- r = self.u.set_center_freq(target_freq)
-
- if r:
- self.freq = target_freq
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
-
- self._set_status_msg("Failed", 0)
- return False
-
- def set_gain(self, gain):
- self.u.set_gain(gain)
-
- def update_status_bar (self):
- msg = "Freq: %s Volume:%f Setting:%s" % (
- eng_notation.num_to_str(self.freq), self.vol, self.state)
- self._set_status_msg(msg, 1)
-
- def _set_status_msg(self, msg, which=0):
- print msg
-
- def volume_range(self):
- return (-20.0, 0.0, 0.5)
-
-
-if __name__ == '__main__':
- tb = wfm_rx_block()
- try:
- tb.run()
- except KeyboardInterrupt:
- pass
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_pll.py b/gr-uhd/examples/python/usrp_wfm_rcv_pll.py
deleted file mode 100755
index 4b33cdcbb3..0000000000
--- a/gr-uhd/examples/python/usrp_wfm_rcv_pll.py
+++ /dev/null
@@ -1,350 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, audio, uhd
-from gnuradio import blocks
-from gnuradio import filter
-from gnuradio import analog
-from gnuradio import eng_notation
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import slider, powermate
-from gnuradio.wxgui import stdgui2, fftsink2, form, scopesink2
-from optparse import OptionParser
-import sys
-import wx
-
-class wfm_rx_block (stdgui2.std_top_block):
- def __init__(self,frame,panel,vbox,argv):
- stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv)
-
- parser=OptionParser(option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-f", "--freq", type="eng_float", default=100.1e6,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-s", "--squelch", type="eng_float", default=0,
- help="set squelch level (default is 0)")
- parser.add_option("-V", "--volume", type="eng_float", default=None,
- help="set volume (default is midpoint)")
- parser.add_option("-O", "--audio-output", type="string", default="default",
- help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp")
- parser.add_option("", "--freq-min", type="eng_float", default=87.9e6,
- help="Set a minimum frequency [default=%default]")
- parser.add_option("", "--freq-max", type="eng_float", default=108.1e6,
- help="Set a maximum frequency [default=%default]")
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- self.frame = frame
- self.panel = panel
-
- self.vol = 0
- self.state = "FREQ"
- self.freq = 0
-
- self.fm_freq_min = options.freq_min
- self.fm_freq_max = options.freq_max
-
- # build graph
- self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- usrp_rate = 320e3
- demod_rate = 320e3
- audio_rate = 48e3
- audio_decim = 10
-
- self.u.set_samp_rate(usrp_rate)
- dev_rate = self.u.get_samp_rate()
-
- nfilts = 32
- chan_coeffs = filter.firdes.low_pass_2(nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 90e3, # passband cutoff
- 30e3, # stopband cutoff
- 70) # stopband attenuation
- rrate = usrp_rate / dev_rate
- self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
-
-
- self.guts = analog.wfm_rcv_pll(demod_rate, audio_decim)
-
- chan_rate = audio_rate / (demod_rate/audio_decim)
- self.rchan_filt = filter.pfb.arb_resampler_fff(chan_rate)
- self.lchan_filt = filter.pfb.arb_resampler_fff(chan_rate)
-
- # FIXME rework {add,multiply}_const_* to handle multiple streams
- self.volume_control_l = blocks.multiply_const_ff(self.vol)
- self.volume_control_r = blocks.multiply_const_ff(self.vol)
-
- # sound card as final sink
- self.audio_sink = audio.sink (int (audio_rate),
- options.audio_output,
- False) # ok_to_block
-
- # now wire it all together
- self.connect (self.u, self.chan_filt, self.guts)
- self.connect((self.guts, 0), self.lchan_filt,
- self.volume_control_l, (self.audio_sink,0))
- self.connect((self.guts, 1), self.rchan_filt,
- self.volume_control_r, (self.audio_sink,1))
-
- try:
- self.guts.stereo_carrier_pll_recovery.squelch_enable(True)
- except:
- print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet"
-
-
- self._build_gui(vbox, usrp_rate, demod_rate, audio_rate)
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2.0
-
- if options.volume is None:
- g = self.volume_range()
- options.volume = float(g[0]+g[1])/2
-
- frange = self.u.get_freq_range()
- if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min):
- sys.stderr.write("Radio does not support required frequency range.\n")
- sys.exit(1)
- if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max):
- sys.stderr.write("Requested frequency is outside of required frequency range.\n")
- sys.exit(1)
-
- # set initial values
- self.set_gain(options.gain)
- self.set_vol(options.volume)
- try:
- self.guts.stereo_carrier_pll_recovery.set_lock_threshold(options.squelch)
- except:
- print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet"
-
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
- def _set_status_msg(self, msg, which=0):
- self.frame.GetStatusBar().SetStatusText(msg, which)
-
-
- def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
-
- if 1:
- self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP",
- fft_size=512, sample_rate=usrp_rate,
- ref_scale=32768.0, ref_level=0, y_divs=12)
- self.connect (self.u, self.src_fft)
- vbox.Add (self.src_fft.win, 4, wx.EXPAND)
-
- if 1:
- post_fm_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod",
- fft_size=512, sample_rate=demod_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.guts.fm_demod, post_fm_demod_fft)
- vbox.Add (post_fm_demod_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_stereo_carrier_generator_fft = fftsink2.fft_sink_c (self.panel, title="Post Stereo_carrier_generator",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.guts.stereo_carrier_generator, post_stereo_carrier_generator_fft)
- vbox.Add (post_stereo_carrier_generator_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_deemphasis_left = fftsink2.fft_sink_f (self.panel, title="Post_Deemphasis_Left",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.guts.deemph_Left, post_deemphasis_left)
- vbox.Add (post_deemphasis_left.win, 4, wx.EXPAND)
-
- if 0:
- post_deemphasis_right = fftsink2.fft_sink_f(self.panel, title="Post_Deemphasis_Right",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=-20)
- self.connect (self.guts.deemph_Left, post_deemphasis_right)
- vbox.Add (post_deemphasis_right.win, 4, wx.EXPAND)
-
-
- if 0:
- LmR_fft = fftsink2.fft_sink_f(self.panel, title="LmR",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=-20)
- self.connect (self.guts.LmR_real,LmR_fft)
- vbox.Add (LmR_fft.win, 4, wx.EXPAND)
-
- if 0:
- self.scope = scopesink2.scope_sink_f(self.panel, sample_rate=demod_rate)
- self.connect (self.guts.fm_demod,self.scope)
- vbox.Add (self.scope.win,4,wx.EXPAND)
-
- # control area form at bottom
- self.myform = myform = form.form()
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0)
- myform['freq_slider'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3,
- range=(self.fm_freq_min, self.fm_freq_max, 0.1e6),
- callback=self.set_freq)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['volume'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume",
- weight=3, range=self.volume_range(),
- callback=self.set_vol)
- hbox.Add((5,0), 1)
-
- g = self.u.get_gain_range()
- myform['gain'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3, range=(g.start(), g.stop(), g.step()),
- callback=self.set_gain)
- hbox.Add((5,0), 0)
-
- myform['sqlch_thrsh'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Stereo Squelch Threshold",
- weight=3, range=(0.0,1.0,0.01),
- callback=self.set_squelch)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- try:
- self.knob = powermate.powermate(self.frame)
- self.rot = 0
- powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate)
- powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button)
- except:
- print "FYI: No Powermate or Contour Knob found"
-
-
- def on_rotate (self, event):
- self.rot += event.delta
- if (self.state == "FREQ"):
- if self.rot >= 3:
- self.set_freq(self.freq + .1e6)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_freq(self.freq - .1e6)
- self.rot += 3
- else:
- step = self.volume_range()[2]
- if self.rot >= 3:
- self.set_vol(self.vol + step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_vol(self.vol - step)
- self.rot += 3
-
- def on_button (self, event):
- if event.value == 0: # button up
- return
- self.rot = 0
- if self.state == "FREQ":
- self.state = "VOL"
- else:
- self.state = "FREQ"
- self.update_status_bar ()
-
-
- def set_vol (self, vol):
- g = self.volume_range()
- self.vol = max(g[0], min(g[1], vol))
- self.volume_control_l.set_k(10**(self.vol/10))
- self.volume_control_r.set_k(10**(self.vol/10))
- self.myform['volume'].set_value(self.vol)
- self.update_status_bar ()
-
- def set_squelch(self,squelch_threshold):
- try:
- self.guts.stereo_carrier_pll_recovery.set_lock_threshold(squelch_threshold);
- except:
- print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet"
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
- """
-
- r = self.u.set_center_freq(target_freq)
-
- if r:
- self.freq = target_freq
- self.myform['freq'].set_value(target_freq) # update displayed value
- self.myform['freq_slider'].set_value(target_freq) # update displayed value
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
-
- self._set_status_msg("Failed", 0)
- return False
-
- def set_gain(self, gain):
- self.myform['gain'].set_value(gain) # update displayed value
- self.u.set_gain(gain)
-
- def update_status_bar (self):
- msg = "Volume:%r Setting:%s" % (self.vol, self.state)
- self._set_status_msg(msg, 1)
- self.src_fft.set_baseband_freq(self.freq)
-
- def volume_range(self):
- return (-20.0, 0.0, 0.5)
-
-
-if __name__ == '__main__':
- app = stdgui2.stdapp (wfm_rx_block, "USRP WFM RX")
- app.MainLoop ()
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_sca.py b/gr-uhd/examples/python/usrp_wfm_rcv_sca.py
deleted file mode 100755
index 9069a745f9..0000000000
--- a/gr-uhd/examples/python/usrp_wfm_rcv_sca.py
+++ /dev/null
@@ -1,407 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2006,2007,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-
-"""
-Here is a bit of code that will receive SCA analog subcarriers of FM
-Broadcast Stations using the USRP. It is a modified version of
-usrp_wfm_rcv.py.
-
-Common SCA frequencies are 67 kHz and 92 kHz. SCA is used for Reading
-Services for the Blind, Background Music, Foreign Language Services, and
-other services. Remember you may hear static when tuned to a FM station
-because this code only outputs SCA audio.
-
-The USRP gain is critical for good decoding. Adjust for minimum noise.
- I use the Post FM Demod FFT to check for SCA subcarriers and to adjust
-the USRP gain for the lowest noise floor. The stereo pilot at 19 KHz,
-the stereo difference signal around 38 KHz, and RDS at 57 KHz are also
-displayed on the Post FM Demod FFT if present.
-
-The range below 67 kHz is used for SCA only when Stereo is not used.
-
-The SCA recieve range is not as far as the main FM carrier receive range
-so tune in strong local stations first.
-
-I tried to comment the code with the various parameters. There seems to
-be several choices for a couple of them. I coded the common ones I see
-here.
-
-In the local area there are a couple of stations using digital SCA.
-These look similar to narrow DRM signals and I wonder if they are using
-OFDM.
-"""
-
-
-from gnuradio import gr, audio, uhd
-from gnuradio import blocks
-from gnuradio import filter
-from gnuradio import analog
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import slider, powermate
-from gnuradio.wxgui import stdgui2, fftsink2, form
-from optparse import OptionParser
-import sys
-import math
-import wx
-
-class wfm_rx_sca_block (stdgui2.std_top_block):
- def __init__(self,frame,panel,vbox,argv):
- stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv)
-
- parser=OptionParser(option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-f", "--freq", type="eng_float", default=100.1e6,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-V", "--volume", type="eng_float", default=None,
- help="set volume (default is midpoint)")
- parser.add_option("-O", "--audio-output", type="string", default="default",
- help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp")
- parser.add_option("", "--freq-min", type="eng_float", default=87.9e6,
- help="Set a minimum frequency [default=%default]")
- parser.add_option("", "--freq-max", type="eng_float", default=108.1e6,
- help="Set a maximum frequency [default=%default]")
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- self.frame = frame
- self.panel = panel
-
- self.vol = 0
- self.state = "FREQ"
- self.freq = 0
-
- self.fm_freq_min = options.freq_min
- self.fm_freq_max = options.freq_max
-
- # build graph
-
- self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- usrp_rate = 320e3
- demod_rate = 320e3
- audio_rate = 32e3
- sca_demod_rate = 64e3
- audio_decim = int(demod_rate / audio_rate)
- sca_chanfilt_decim = int(demod_rate / sca_demod_rate)
-
- self.u.set_samp_rate(usrp_rate)
- dev_rate = self.u.get_samp_rate()
-
- nfilts = 32
- chan_coeffs = filter.optfir.low_pass(nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 100e3, # passband cutoff
- 140e3, # stopband cutoff
- 0.1, # passband ripple
- 60) # stopband attenuation
- rrate = usrp_rate / dev_rate
- self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
-
- #Create demodulator block for Main FM Channel
- max_dev = 75e3
- fm_demod_gain = demod_rate/(2*math.pi*max_dev)
- self.fm_demod = analog.quadrature_demod_cf(fm_demod_gain)
-
- # Note - deemphasis is not applied to the Main FM Channel as
- # main audio is not decoded
-
- # SCA Devation is 10% of carrier but some references say 20%
- # if mono with one SCA (6 KHz seems typical)
- max_sca_dev = 6e3
-
- # Create filter to get SCA channel we want
- sca_chan_coeffs = filter.firdes.low_pass(1.0, # gain
- demod_rate, # sampling rate
- max_sca_dev, # cutoff freq
- max_sca_dev/3, # trans. band
- filter.firdes.WIN_HANN) # filter type
-
- self.ddc = filter.freq_xlating_fir_filter_fcf(sca_chanfilt_decim, # decim rate
- sca_chan_coeffs, # taps
- 0, # freq translation amount (Gets set by the UI)
- demod_rate) # input sample rate
-
- #Create demodulator block for SCA Channel
- sca_demod_gain = sca_demod_rate/(2*math.pi*max_sca_dev)
- self.fm_demod_sca = analog.quadrature_demod_cf(sca_demod_gain)
-
-
- # SCA analog audio is bandwidth limited to 5 KHz
- max_sca_audio_freq = 5.0e3
-
- # SCA analog deephasis is 150 uS (75 uS may be used)
- sca_tau = 150e-6
-
- # compute FIR filter taps for SCA audio filter
- audio_coeffs = filter.firdes.low_pass(1.0, # gain
- sca_demod_rate, # sampling rate
- max_sca_audio_freq, # cutoff freq
- max_sca_audio_freq/2.5, # trans. band
- filter.firdes.WIN_HAMMING)
-
- # input: float; output: float
- self.audio_filter = filter.fir_filter_fff(audio_decim, audio_coeffs)
-
- # Create deemphasis block that is applied after SCA demodulation
- self.deemph = analog.fm_deemph(audio_rate, sca_tau)
-
- self.volume_control = blocks.multiply_const_ff(self.vol)
-
- # sound card as final sink
- self.audio_sink = audio.sink(int (audio_rate),
- options.audio_output,
- False) # ok_to_block
-
- # now wire it all together
- self.connect(self.u, self.chan_filt, self.fm_demod,
- self.ddc, self.fm_demod_sca)
- self.connect(self.fm_demod_sca, self.audio_filter,
- self.deemph, self.volume_control,
- self.audio_sink)
-
- self._build_gui(vbox, usrp_rate, demod_rate, sca_demod_rate, audio_rate)
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2
-
- if options.volume is None:
- g = self.volume_range()
- options.volume = float(g[0]+g[1])/2
-
- frange = self.u.get_freq_range()
- if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min):
- sys.stderr.write("Radio does not support required frequency range.\n")
- sys.exit(1)
- if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max):
- sys.stderr.write("Requested frequency is outside of required frequency range.\n")
- sys.exit(1)
-
- # set initial values
-
- self.set_gain(options.gain)
- self.set_vol(options.volume)
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
- self.set_sca_freq(67000) # A common SCA Frequency
-
- def _set_status_msg(self, msg, which=0):
- self.frame.GetStatusBar().SetStatusText(msg, which)
-
-
- def _build_gui(self, vbox, usrp_rate, demod_rate, sca_demod_rate, audio_rate):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
- def _form_set_sca_freq(kv):
- return self.set_sca_freq(kv['sca_freq'])
-
- if 1:
- self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from USRP",
- fft_size=512, sample_rate=usrp_rate,
- ref_scale=32768.0, ref_level=0, y_divs=12)
- self.connect (self.u, self.src_fft)
- vbox.Add (self.src_fft.win, 4, wx.EXPAND)
-
- if 1:
- post_demod_fft = fftsink2.fft_sink_f(self.panel, title="Post FM Demod",
- fft_size=2048, sample_rate=demod_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.fm_demod, post_demod_fft)
- vbox.Add (post_demod_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_demod_sca_fft = fftsink2.fft_sink_f(self.panel, title="Post SCA Demod",
- fft_size=1024, sample_rate=sca_demod_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.fm_demod_sca, post_demod_sca_fft)
- vbox.Add (post_demod_sca_fft.win, 4, wx.EXPAND)
-
- if 0:
- post_deemph_fft = fftsink2.fft_sink_f (self.panel, title="Post SCA Deemph",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=-20)
- self.connect (self.deemph, post_deemph_fft)
- vbox.Add (post_deemph_fft.win, 4, wx.EXPAND)
-
-
- # control area form at bottom
- self.myform = myform = form.form()
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0)
- myform['freq_slider'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3,
- range=(self.fm_freq_min, self.fm_freq_max, 0.1e6),
- callback=self.set_freq)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- myform['sca_freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="SCA", weight=1,
- callback=myform.check_input_and_call(_form_set_sca_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0)
- myform['sca_freq_slider'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3,
- range=(38e3, 100e3, 1.0e3),
- callback=self.set_sca_freq)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['volume'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume",
- weight=3, range=self.volume_range(),
- callback=self.set_vol)
- hbox.Add((5,0), 1)
-
- g = self.u.get_gain_range()
- myform['gain'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3, range=(g.start(), g.stop(), g.step()),
- callback=self.set_gain)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- try:
- self.knob = powermate.powermate(self.frame)
- self.rot = 0
- powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate)
- powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button)
- except:
- print "FYI: No Powermate or Contour Knob found"
-
-
- def on_rotate (self, event):
- self.rot += event.delta
- if (self.state == "FREQ"):
- if self.rot >= 3:
- self.set_freq(self.freq + .1e6)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_freq(self.freq - .1e6)
- self.rot += 3
- else:
- step = self.volume_range()[2]
- if self.rot >= 3:
- self.set_vol(self.vol + step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_vol(self.vol - step)
- self.rot += 3
-
- def on_button (self, event):
- if event.value == 0: # button up
- return
- self.rot = 0
- if self.state == "FREQ":
- self.state = "VOL"
- else:
- self.state = "FREQ"
- self.update_status_bar ()
-
-
- def set_vol (self, vol):
- g = self.volume_range()
- self.vol = max(g[0], min(g[1], vol))
- self.volume_control.set_k(10**(self.vol/10))
- self.myform['volume'].set_value(self.vol)
- self.update_status_bar ()
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
-
- Tuning is a two step process. First we ask the front-end to
- tune as close to the desired frequency as it can. Then we use
- the result of that operation and our target_frequency to
- determine the value for the digital down converter.
- """
- r = self.u.set_center_freq(target_freq)
- if r:
- self.freq = target_freq
- self.myform['freq'].set_value(target_freq) # update displayed value
- self.myform['freq_slider'].set_value(target_freq) # update displayed value
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
- self._set_status_msg("Failed", 0)
- return False
-
- def set_sca_freq(self, target_sca_freq):
-
- self.ddc.set_center_freq(-target_sca_freq)
- self.myform['sca_freq'].set_value(target_sca_freq) # update displayed value
- self.myform['sca_freq_slider'].set_value(target_sca_freq) # update displayed value
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
-
- def set_gain(self, gain):
- self.myform['gain'].set_value(gain) # update displayed value
- self.u.set_gain(gain)
-
- def update_status_bar (self):
- msg = "Volume:%r Setting:%s" % (self.vol, self.state)
- self._set_status_msg(msg, 1)
- self.src_fft.set_baseband_freq(self.freq)
-
- def volume_range(self):
- return (-20.0, 0.0, 0.5)
-
-
-if __name__ == '__main__':
- app = stdgui2.stdapp (wfm_rx_sca_block, "USRP WFM SCA RX")
- app.MainLoop ()
diff --git a/gr-uhd/examples/python/usrp_wxapt_rcv.py b/gr-uhd/examples/python/usrp_wxapt_rcv.py
deleted file mode 100755
index 305149b682..0000000000
--- a/gr-uhd/examples/python/usrp_wxapt_rcv.py
+++ /dev/null
@@ -1,286 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, audio, uhd
-from gnuradio import blocks
-from gnuradio import filter
-from gnuradio import analog
-from gnuradio.eng_option import eng_option
-from gnuradio.wxgui import slider, powermate
-from gnuradio.wxgui import stdgui2, fftsink2, form
-from optparse import OptionParser
-import sys
-import wx
-
-
-class wxapt_rx_block (stdgui2.std_top_block):
- def __init__(self,frame,panel,vbox,argv):
- stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv)
-
- parser=OptionParser(option_class=eng_option)
- parser.add_option("-a", "--args", type="string", default="",
- help="UHD device address args, [default=%default]")
- parser.add_option("", "--spec", type="string", default=None,
- help="Subdevice of UHD device where appropriate")
- parser.add_option("-A", "--antenna", type="string", default=None,
- help="select Rx Antenna where appropriate")
- parser.add_option("-f", "--freq", type="eng_float", default=137.5e6,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("-V", "--volume", type="eng_float", default=None,
- help="set volume (default is midpoint)")
- parser.add_option("-O", "--audio-output", type="string", default="default",
- help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp")
- parser.add_option("", "--freq-min", type="eng_float", default=137e6,
- help="Set a minimum frequency [default=%default]")
- parser.add_option("", "--freq-max", type="eng_float", default=138e6,
- help="Set a maximum frequency [default=%default]")
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
-
- self.frame = frame
- self.panel = panel
-
- self.vol = 0
- self.state = "FREQ"
- self.freq = 0
-
- self.freq_min = options.freq_min
- self.freq_max = options.freq_max
-
- # build graph
- self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))
-
- # Set the subdevice spec
- if(options.spec):
- self.u.set_subdev_spec(options.spec, 0)
-
- # Set the antenna
- if(options.antenna):
- self.u.set_antenna(options.antenna, 0)
-
- usrp_rate = 320e3
- demod_rate = 320e3
- audio_rate = 32e3
- audio_decim = int(demod_rate / audio_rate)
-
- self.u.set_samp_rate(usrp_rate)
- dev_rate = self.u.get_samp_rate()
-
- nfilts = 32
- chan_coeffs = filter.firdes.low_pass_2(nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 40e3, # passband cutoff
- 20e3, # transition bw
- 60) # stopband attenuation
- rrate = usrp_rate / dev_rate
- self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
-
- self.guts = analog.wfm_rcv(demod_rate, audio_decim)
-
- self.volume_control = blocks.multiply_const_ff(self.vol)
-
- # sound card as final sink
- self.audio_sink = audio.sink(int (audio_rate), options.audio_output)
-
- # now wire it all together
- self.connect(self.u, self.chan_filt, self.guts,
- self.volume_control, self.audio_sink)
-
- self._build_gui(vbox, usrp_rate, demod_rate, audio_rate)
-
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self.u.get_gain_range()
- options.gain = float(g.start()+g.stop())/2.0
-
- if options.volume is None:
- g = self.volume_range()
- options.volume = float(g[0]+g[1])/2
-
- frange = self.u.get_freq_range()
- if(frange.start() > self.freq_max or frange.stop() < self.freq_min):
- sys.stderr.write("Radio does not support required frequency range.\n")
- sys.exit(1)
- if(options.freq < self.freq_min or options.freq > self.freq_max):
- sys.stderr.write("Requested frequency is outside of required frequency range.\n")
- sys.exit(1)
-
- # set initial values
- self.set_gain(options.gain)
- self.set_vol(options.volume)
- if not(self.set_freq(options.freq)):
- self._set_status_msg("Failed to set initial frequency")
-
- def _set_status_msg(self, msg, which=0):
- self.frame.GetStatusBar().SetStatusText(msg, which)
-
-
- def _build_gui(self, vbox, usrp_rate, demod_rate, audio_rate):
-
- def _form_set_freq(kv):
- return self.set_freq(kv['freq'])
-
-
- if 1:
- self.src_fft = fftsink2.fft_sink_c (self.panel, title="Data from USRP",
- fft_size=512, sample_rate=usrp_rate,
- ref_scale=32768.0, ref_level=0, y_divs=12)
- self.connect (self.u, self.src_fft)
- vbox.Add (self.src_fft.win, 4, wx.EXPAND)
-
- if 1:
- post_deemph_fft = fftsink2.fft_sink_f (self.panel, title="Post Deemph",
- fft_size=512, sample_rate=demod_rate,
- y_per_div=10, ref_level=-20)
- self.connect (self.guts.deemph, post_deemph_fft)
- vbox.Add (post_deemph_fft.win, 4, wx.EXPAND)
-
- if 1:
- post_filt_fft = fftsink2.fft_sink_f (self.panel, title="Post Filter",
- fft_size=512, sample_rate=audio_rate,
- y_per_div=10, ref_level=0)
- self.connect (self.guts.audio_filter, post_filt_fft)
- vbox.Add (post_filt_fft.win, 4, wx.EXPAND)
-
-
- # control area form at bottom
- self.myform = myform = form.form()
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
- myform['freq'] = form.float_field(
- parent=self.panel, sizer=hbox, label="Freq", weight=1,
- callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
-
- hbox.Add((5,0), 0)
- myform['freq_slider'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3,
- range=(self.freq_min, self.freq_max, 0.0005e6),
- callback=self.set_freq)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- hbox.Add((5,0), 0)
-
- myform['volume'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume",
- weight=3, range=self.volume_range(),
- callback=self.set_vol)
- hbox.Add((5,0), 1)
-
- g = self.u.get_gain_range()
- myform['gain'] = \
- form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain",
- weight=3, range=(g.start(), g.start(), g.step()),
- callback=self.set_gain)
- hbox.Add((5,0), 0)
- vbox.Add(hbox, 0, wx.EXPAND)
-
- try:
- self.knob = powermate.powermate(self.frame)
- self.rot = 0
- powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate)
- powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button)
- except:
- print "FYI: No Powermate or Contour Knob found"
-
-
- def on_rotate (self, event):
- self.rot += event.delta
- if (self.state == "FREQ"):
- if self.rot >= 3:
- self.set_freq(self.freq + .1e6)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_freq(self.freq - .1e6)
- self.rot += 3
- else:
- step = self.volume_range()[2]
- if self.rot >= 3:
- self.set_vol(self.vol + step)
- self.rot -= 3
- elif self.rot <=-3:
- self.set_vol(self.vol - step)
- self.rot += 3
-
- def on_button (self, event):
- if event.value == 0: # button up
- return
- self.rot = 0
- if self.state == "FREQ":
- self.state = "VOL"
- else:
- self.state = "FREQ"
- self.update_status_bar ()
-
-
- def set_vol (self, vol):
- g = self.volume_range()
- self.vol = max(g[0], min(g[1], vol))
- self.volume_control.set_k(10**(self.vol/10))
- self.myform['volume'].set_value(self.vol)
- self.update_status_bar ()
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
-
- Args:
- target_freq: frequency in Hz
- @rypte: bool
- """
-
- r = self.u.set_center_freq(target_freq)
-
- if r:
- self.freq = target_freq
- self.myform['freq'].set_value(target_freq) # update displayed value
- self.myform['freq_slider'].set_value(target_freq) # update displayed value
- self.update_status_bar()
- self._set_status_msg("OK", 0)
- return True
-
- self._set_status_msg("Failed", 0)
- return False
-
- def set_gain(self, gain):
- self.myform['gain'].set_value(gain) # update displayed value
- self.u.set_gain(gain)
-
- def update_status_bar (self):
- msg = "Volume:%r Setting:%s" % (self.vol, self.state)
- self._set_status_msg(msg, 1)
- self.src_fft.set_baseband_freq(self.freq)
-
- def volume_range(self):
- return (-20.0, 0.0, 0.5)
-
-
-if __name__ == '__main__':
- app = stdgui2.stdapp (wxapt_rx_block, "USRP WXAPT RX")
- app.MainLoop ()
diff --git a/gr-wxgui/CMakeLists.txt b/gr-wxgui/CMakeLists.txt
deleted file mode 100644
index d77e36ad4a..0000000000
--- a/gr-wxgui/CMakeLists.txt
+++ /dev/null
@@ -1,91 +0,0 @@
-# Copyright 2011,2013 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-
-########################################################################
-# Setup dependencies
-########################################################################
-include(GrBoost)
-include(GrPython)
-
-GR_PYTHON_CHECK_MODULE("wx >= 2.8" wx "wx.version().split()[0] >= '2.8'" WX_FOUND)
-GR_PYTHON_CHECK_MODULE("numpy" numpy True NUMPY_FOUND)
-
-########################################################################
-# Register component
-########################################################################
-include(GrComponent)
-if(NOT CMAKE_CROSSCOMPILING)
- set(wxgui_python_deps
- NUMPY_FOUND
- WX_FOUND
- )
-endif(NOT CMAKE_CROSSCOMPILING)
-
-GR_REGISTER_COMPONENT("gr-wxgui" ENABLE_GR_WXGUI
- ENABLE_GNURADIO_RUNTIME
- ENABLE_GR_FFT
- ENABLE_GR_FILTER
- ENABLE_GR_ANALOG
- ENABLE_PYTHON
- ${wxgui_python_deps}
-)
-
-########################################################################
-# Begin conditional configuration
-########################################################################
-if(ENABLE_GR_WXGUI)
-
-GR_SET_GLOBAL(GR_WXGUI_INCLUDE_DIRS
- ${CMAKE_CURRENT_SOURCE_DIR}/lib
- ${CMAKE_CURRENT_SOURCE_DIR}/include
- ${CMAKE_CURRENT_BINARY_DIR}/lib
- ${CMAKE_CURRENT_BINARY_DIR}/include
-)
-
-########################################################################
-# Create Pkg Config File
-########################################################################
-configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/gr-wxgui.pc.in
- ${CMAKE_CURRENT_BINARY_DIR}/gr-wxgui.pc
-@ONLY)
-
-install(
- FILES ${CMAKE_CURRENT_BINARY_DIR}/gr-wxgui.pc
- DESTINATION ${GR_LIBRARY_DIR}/pkgconfig
-)
-
-########################################################################
-# Install the conf file
-########################################################################
-install(
- FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr-wxgui.conf
- DESTINATION ${GR_PREFSDIR}
-)
-
-########################################################################
-# Add subdirectories
-########################################################################
-add_subdirectory(include/gnuradio/wxgui)
-add_subdirectory(lib)
-add_subdirectory(grc)
-add_subdirectory(python/wxgui)
-add_subdirectory(swig)
-
-endif(ENABLE_GR_WXGUI)
diff --git a/gr-wxgui/README b/gr-wxgui/README
deleted file mode 100644
index ebd0d23977..0000000000
--- a/gr-wxgui/README
+++ /dev/null
@@ -1 +0,0 @@
-This requires wxPython 2.5.2.7 or later. See http://www.wxpython.org
diff --git a/gr-wxgui/README.gl b/gr-wxgui/README.gl
deleted file mode 100644
index 1d3eec60be..0000000000
--- a/gr-wxgui/README.gl
+++ /dev/null
@@ -1,29 +0,0 @@
-To use the OpenGL versions of the graphical display sinks, you must ensure
-that you have Python wrappers for OpenGL installed and are using a version
-of wxPython that supports it. Then you must enable this mode by creating or
-editing an entry in the GNU Radio preferences file at:
-
-~/.gnuradio/config.conf
-
-[wxgui]
-style=gl
-fft_rate=30
-waterfall_rate=30
-scope_rate=30
-number_rate=5
-const_rate=5
-const_size=2048
-
->>>The style parameter accepts 'nongl', 'gl', and 'auto', and defaults to 'auto'.
-
-'nongl' forces the use of the non-GL (current) sinks.
-
-'gl' forces the use of the new GL based sinks, and will raise an exception if the
-appropriate GL support does not exist.
-
-'auto' currently equates to 'nongl'; however, in release 3.2, this will change to
-use GL if possible and if not, fallback to the non-GL versions.
-
->>>The *_rate parameter sets the frame rate for various gl sinks.
-
->>>The const_size parameter sets the number of constellation points per frame.
diff --git a/gr-wxgui/gr-wxgui.conf b/gr-wxgui/gr-wxgui.conf
deleted file mode 100644
index da458238fd..0000000000
--- a/gr-wxgui/gr-wxgui.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# This file contains system wide configuration data for GNU Radio.
-# You may override any setting on a per-user basis by editing
-# ~/.gnuradio/config.conf
-
-[wxgui]
-# 'gl', 'nongl', or 'auto'
-style = auto
-
-# fftsink and waterfallsink
-fft_rate = 15
-
-# scopesink
-frame_decim = 1
diff --git a/gr-wxgui/gr-wxgui.pc.in b/gr-wxgui/gr-wxgui.pc.in
deleted file mode 100644
index ec4d66c9fc..0000000000
--- a/gr-wxgui/gr-wxgui.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: gr-wxgui
-Description: A simple wx gui for GNU Radio applications
-Requires: gnuradio-runtime
-Version: @LIBVER@
-Libs:
-Cflags:
diff --git a/gr-wxgui/grc/CMakeLists.txt b/gr-wxgui/grc/CMakeLists.txt
deleted file mode 100644
index 52c9bbda43..0000000000
--- a/gr-wxgui/grc/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-
-########################################################################
-file(GLOB xml_files "*.xml")
-install(FILES ${xml_files} DESTINATION ${GRC_BLOCKS_DIR})
-
-########################################################################
-#The wxgui module contains a top_block + wxgui frame.
-########################################################################
-include(GrPython)
-
-GR_PYTHON_INSTALL(
- FILES
- __init__.py
- panel.py
- top_block_gui.py
- DESTINATION ${GR_PYTHON_DIR}/grc_gnuradio/wxgui
-)
diff --git a/gr-wxgui/grc/__init__.py b/gr-wxgui/grc/__init__.py
deleted file mode 100644
index 81427253b6..0000000000
--- a/gr-wxgui/grc/__init__.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2008, 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from top_block_gui import top_block_gui
-from panel import Panel
diff --git a/gr-wxgui/grc/notebook.xml b/gr-wxgui/grc/notebook.xml
deleted file mode 100644
index 1e4b0d0679..0000000000
--- a/gr-wxgui/grc/notebook.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##WX GUI Notebook
-###################################################
- -->
-<block>
- <name>WX GUI Notebook</name>
- <key>notebook</key>
- <category>[Core]/GUI Widgets/WX</category>
- <import>from grc_gnuradio import wxgui as grc_wxgui</import>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-self.$(id) = wx.Notebook($(parent).GetWin(), style=$style)
-#for $label in $labels()
-self.$(id).AddPage(grc_wxgui.Panel(self.$(id)), "$label")
-#end for
-#if not $grid_pos()
-$(parent).Add(self.$(id))
-#else
-$(parent).GridAdd(self.$(id), $(', '.join(map(str, $grid_pos()))))
-#end if</make>
- <param>
- <name>Tab Orientation</name>
- <key>style</key>
- <value>wx.NB_TOP</value>
- <type>enum</type>
- <option>
- <name>Top</name>
- <key>wx.NB_TOP</key>
- </option>
- <option>
- <name>Right</name>
- <key>wx.NB_RIGHT</key>
- </option>
- <option>
- <name>Bottom</name>
- <key>wx.NB_BOTTOM</key>
- </option>
- <option>
- <name>Left</name>
- <key>wx.NB_LEFT</key>
- </option>
- </param>
- <param>
- <name>Labels</name>
- <key>labels</key>
- <value>['tab1', 'tab2', 'tab3']</value>
- <type>raw</type>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <check>isinstance($labels, (list, tuple))</check>
- <check>all(map(lambda x: isinstance(x, str), $labels))</check>
- <check>len($labels) &gt; 0</check>
- <doc>
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/panel.py b/gr-wxgui/grc/panel.py
deleted file mode 100644
index 8ca426e098..0000000000
--- a/gr-wxgui/grc/panel.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import wx
-
-class Panel(wx.Panel):
- def __init__(self, parent, orient=wx.VERTICAL):
- wx.Panel.__init__(self, parent)
- self._box = wx.BoxSizer(orient)
- self._grid = wx.GridBagSizer(5, 5)
- self.Add(self._grid)
- self.SetSizer(self._box)
-
- def GetWin(self): return self
-
- def Add(self, win):
- """
- Add a window to the wx vbox.
-
- 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.
-
- 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
deleted file mode 100644
index 24b462d7ad..0000000000
--- a/gr-wxgui/grc/top_block_gui.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright 2008, 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import wx
-from gnuradio import gr
-import panel
-
-default_gui_size = (200, 100)
-
-class top_block_gui(gr.top_block):
- """gr top block with wx gui app and grid sizer."""
-
- def __init__(self, title='', size=default_gui_size):
- """
- Initialize the gr top block.
- Create the wx gui elements.
-
- 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)
- self._size = size
- #create gui elements
- self._app = wx.App()
- self._frame = wx.Frame(None, title=title)
- self._panel = panel.Panel(self._frame)
- self.Add = self._panel.Add
- self.GridAdd = self._panel.GridAdd
- self.GetWin = self._panel.GetWin
- self.Start(False)
-
- def SetIcon(self, *args, **kwargs): self._frame.SetIcon(*args, **kwargs)
-
- def Start(self, start=True, max_nouts=0):
- #set minimal window size
- self._frame.SetSizeHints(*self._size)
- #create callback for quit
- def _quit(event):
- self.stop(); self.wait()
- self._frame.Destroy()
- #setup app
- self._frame.Bind(wx.EVT_CLOSE, _quit)
- self._sizer = wx.BoxSizer(wx.VERTICAL)
- self._sizer.Add(self._panel, 0, wx.EXPAND)
- self._frame.SetSizerAndFit(self._sizer)
- self._frame.SetAutoLayout(True)
- self._frame.Show(True)
- self._app.SetTopWindow(self._frame)
- #start flow graph
- if start:
- if max_nouts != 0:
- 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/variable_check_box.xml b/gr-wxgui/grc/variable_check_box.xml
deleted file mode 100644
index da8bb8b8d5..0000000000
--- a/gr-wxgui/grc/variable_check_box.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Variable Check Box:
-## a gui check box form
-###################################################
- -->
-<block>
- <name>WX GUI Check Box</name>
- <key>variable_check_box</key>
- <category>[Core]/GUI Widgets/WX</category>
- <import>from gnuradio.wxgui import forms</import>
- <var_make>self.$(id) = $(id) = $value</var_make>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-#set $win = 'self._%s_check_box'%$id
-$win = forms.check_box(
- parent=$(parent).GetWin(),
- value=self.$id,
- callback=self.set_$(id),
- #if $label()
- label=$label,
- #else
- label='$id',
- #end if
- true=$true,
- false=$false,
-)
-#if not $grid_pos()
-$(parent).Add($win)
-#else
-$(parent).GridAdd($win, $(', '.join(map(str, $grid_pos()))))
-#end if</make>
- <callback>self.set_$(id)($value)</callback>
- <callback>self._$(id)_check_box.set_value($id)</callback>
- <param>
- <name>Label</name>
- <key>label</key>
- <value></value>
- <type>string</type>
- <hide>#if $label() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Default Value</name>
- <key>value</key>
- <value>True</value>
- <type>raw</type>
- </param>
- <param>
- <name>True</name>
- <key>true</key>
- <value>True</value>
- <type>raw</type>
- </param>
- <param>
- <name>False</name>
- <key>false</key>
- <value>False</value>
- <type>raw</type>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <check>$value in ($true, $false)</check>
- <doc>
-This block creates a variable with a check box form. \
-Leave the label blank to use the variable id as the label.
-
-A check box form can switch between two states; \
-the default being True and False. \
-Override True and False to use alternative states.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/variable_chooser.xml b/gr-wxgui/grc/variable_chooser.xml
deleted file mode 100644
index 216be01e08..0000000000
--- a/gr-wxgui/grc/variable_chooser.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Variable Chooser:
-## a gui form with enumerated choices
-## radio buttons, drop down, or button
-###################################################
- -->
-<block>
- <name>WX GUI Chooser</name>
- <key>variable_chooser</key>
- <category>[Core]/GUI Widgets/WX</category>
- <import>from gnuradio.wxgui import forms</import>
- <var_make>self.$(id) = $(id) = $value</var_make>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-#set $win = 'self._%s_chooser'%$id
-$win = forms.$(type)(
- parent=$(parent).GetWin(),
- value=self.$id,
- callback=self.set_$(id),
- #if $label()
- label=$label,
- #else
- label='$id',
- #end if
- choices=$choices,
- labels=$labels,
-#if $type() == 'radio_buttons'
- style=$style,
-#end if
-)
-#if not $grid_pos()
-$(parent).Add($win)
-#else
-$(parent).GridAdd($win, $(', '.join(map(str, $grid_pos()))))
-#end if</make>
- <callback>self.set_$(id)($value)</callback>
- <callback>self._$(id)_chooser.set_value($id)</callback>
- <param>
- <name>Label</name>
- <key>label</key>
- <value></value>
- <type>string</type>
- <hide>#if $label() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Default Value</name>
- <key>value</key>
- <value>1</value>
- <type>raw</type>
- </param>
- <param>
- <name>Choices</name>
- <key>choices</key>
- <value>[1, 2, 3]</value>
- <type>raw</type>
- </param>
- <param>
- <name>Labels</name>
- <key>labels</key>
- <value>[]</value>
- <type>raw</type>
- </param>
- <param>
- <name>Type</name>
- <key>type</key>
- <value>drop_down</value>
- <type>enum</type>
- <option>
- <name>Drop Down</name>
- <key>drop_down</key>
- </option>
- <option>
- <name>Radio Buttons</name>
- <key>radio_buttons</key>
- </option>
- <option>
- <name>Button</name>
- <key>button</key>
- </option>
- </param>
- <param>
- <name>Style</name>
- <key>style</key>
- <value>wx.RA_HORIZONTAL</value>
- <type>enum</type>
- <hide>#if $type() == 'radio_buttons' then 'part' else 'all'#</hide>
- <option>
- <name>Horizontal</name>
- <key>wx.RA_HORIZONTAL</key>
- </option>
- <option>
- <name>Vertical</name>
- <key>wx.RA_VERTICAL</key>
- </option>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <check>$value in $choices</check>
- <check>not $labels or len($labels) == len($choices)</check>
- <doc>
-This block creates a variable with a drop down, radio buttons, or a button. \
-Leave the label blank to use the variable id as the label. \
-The value index is the index of a particular choice, \
-which defines the default choice when the flow graph starts. \
-The choices must be a list of possible values. \
-Leave labels empty to use the choices as the labels.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/variable_slider.xml b/gr-wxgui/grc/variable_slider.xml
deleted file mode 100644
index 29f3182d0a..0000000000
--- a/gr-wxgui/grc/variable_slider.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Variable Slider:
-## a combined slider and text box form
-###################################################
- -->
-<block>
- <name>WX GUI Slider</name>
- <key>variable_slider</key>
- <category>[Core]/GUI Widgets/WX</category>
- <import>from gnuradio.wxgui import forms</import>
- <var_make>self.$(id) = $(id) = $value</var_make>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-#set $win = '_%s_sizer'%$id
-$win = wx.BoxSizer(wx.VERTICAL)
-self._$(id)_text_box = forms.text_box(
- parent=$(parent).GetWin(),
- sizer=$win,
- value=self.$id,
- callback=self.set_$(id),
- #if $label()
- label=$label,
- #else
- label='$id',
- #end if
- converter=forms.$(converver)(),
- proportion=0,
-)
-self._$(id)_slider = forms.slider(
- parent=$(parent).GetWin(),
- sizer=$win,
- value=self.$id,
- callback=self.set_$(id),
- minimum=$min,
- maximum=$max,
- num_steps=$num_steps,
- style=$style,
- cast=$(converver.slider_cast),
- proportion=1,
-)
-#if not $grid_pos()
-$(parent).Add($win)
-#else
-$(parent).GridAdd($win, $(', '.join(map(str, $grid_pos()))))
-#end if</make>
- <callback>self.set_$(id)($value)</callback>
- <callback>self._$(id)_slider.set_value($id)</callback>
- <callback>self._$(id)_text_box.set_value($id)</callback>
- <param>
- <name>Label</name>
- <key>label</key>
- <value></value>
- <type>string</type>
- <hide>#if $label() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Default Value</name>
- <key>value</key>
- <value>50</value>
- <type>real</type>
- </param>
- <param>
- <name>Minimum</name>
- <key>min</key>
- <value>0</value>
- <type>real</type>
- </param>
- <param>
- <name>Maximum</name>
- <key>max</key>
- <value>100</value>
- <type>real</type>
- </param>
- <param>
- <name>Num Steps</name>
- <key>num_steps</key>
- <value>100</value>
- <type>int</type>
- <hide>part</hide>
- </param>
- <param>
- <name>Style</name>
- <key>style</key>
- <value>wx.SL_HORIZONTAL</value>
- <type>enum</type>
- <hide>part</hide>
- <option>
- <name>Horizontal</name>
- <key>wx.SL_HORIZONTAL</key>
- </option>
- <option>
- <name>Vertical</name>
- <key>wx.SL_VERTICAL</key>
- </option>
- </param>
- <param>
- <name>Converter</name>
- <key>converver</key>
- <value>float_converter</value>
- <type>enum</type>
- <option>
- <name>Float</name>
- <key>float_converter</key>
- <opt>slider_cast:float</opt>
- </option>
- <option>
- <name>Integer</name>
- <key>int_converter</key>
- <opt>slider_cast:int</opt>
- </option>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <check>$min &lt;= $value &lt;= $max</check>
- <check>$min &lt; $max</check>
- <check>0 &lt; $num_steps &lt;= 1000</check>
- <doc>
-This block creates a variable with a slider. \
-Leave the label blank to use the variable id as the label. \
-The value must be a real number. \
-The value must be between the minimum and the maximum. \
-The number of steps must be between 0 and 1000.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/variable_static_text.xml b/gr-wxgui/grc/variable_static_text.xml
deleted file mode 100644
index e47f5c3731..0000000000
--- a/gr-wxgui/grc/variable_static_text.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Variable Static Text:
-## a gui static text form
-###################################################
- -->
-<block>
- <name>WX GUI Static Text</name>
- <key>variable_static_text</key>
- <category>[Core]/GUI Widgets/WX</category>
- <import>from gnuradio.wxgui import forms</import>
- <var_make>self.$(id) = $(id) = $value</var_make>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-#set $win = 'self._%s_static_text'%$id
-$win = forms.static_text(
- parent=$(parent).GetWin(),
- value=self.$id,
- callback=self.set_$(id),
- #if $label()
- label=$label,
- #else
- label='$id',
- #end if
- #if $formatter()
- converter=forms.$(converver)(formatter=$formatter),
- #else
- converter=forms.$(converver)(),
- #end if
-)
-#if not $grid_pos()
-$(parent).Add($win)
-#else
-$(parent).GridAdd($win, $(', '.join(map(str, $grid_pos()))))
-#end if</make>
- <callback>self.set_$(id)($value)</callback>
- <callback>self._$(id)_static_text.set_value($id)</callback>
- <param>
- <name>Label</name>
- <key>label</key>
- <value></value>
- <type>string</type>
- <hide>#if $label() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Default Value</name>
- <key>value</key>
- <value>0</value>
- <type>raw</type>
- </param>
- <param>
- <name>Converter</name>
- <key>converver</key>
- <value>float_converter</value>
- <type>enum</type>
- <option>
- <name>Float</name>
- <key>float_converter</key>
- </option>
- <option>
- <name>Integer</name>
- <key>int_converter</key>
- </option>
- <option>
- <name>String</name>
- <key>str_converter</key>
- </option>
- </param>
- <param>
- <name>Formatter</name>
- <key>formatter</key>
- <value>None</value>
- <type>raw</type>
- <hide>part</hide>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <doc>
-This block creates a variable with a static text form. \
-Leave the label blank to use the variable id as the label.
-
-Format should be a function/lambda that converts a value into a string or None for the default formatter.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/variable_text_box.xml b/gr-wxgui/grc/variable_text_box.xml
deleted file mode 100644
index 8c8119433a..0000000000
--- a/gr-wxgui/grc/variable_text_box.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Variable Text Box:
-## a gui text box form
-###################################################
- -->
-<block>
- <name>WX GUI Text Box</name>
- <key>variable_text_box</key>
- <category>[Core]/GUI Widgets/WX</category>
- <import>from gnuradio.wxgui import forms</import>
- <var_make>self.$(id) = $(id) = $value</var_make>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-#set $win = 'self._%s_text_box'%$id
-$win = forms.text_box(
- parent=$(parent).GetWin(),
- value=self.$id,
- callback=self.set_$(id),
- #if $label()
- label=$label,
- #else
- label='$id',
- #end if
- #if $formatter()
- converter=forms.$(converver)(formatter=$formatter),
- #else
- converter=forms.$(converver)(),
- #end if
-)
-#if not $grid_pos()
-$(parent).Add($win)
-#else
-$(parent).GridAdd($win, $(', '.join(map(str, $grid_pos()))))
-#end if</make>
- <callback>self.set_$(id)($value)</callback>
- <callback>self._$(id)_text_box.set_value($id)</callback>
- <param>
- <name>Label</name>
- <key>label</key>
- <value></value>
- <type>string</type>
- <hide>#if $label() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Default Value</name>
- <key>value</key>
- <value>0</value>
- <type>raw</type>
- </param>
- <param>
- <name>Converter</name>
- <key>converver</key>
- <value>float_converter</value>
- <type>enum</type>
- <option>
- <name>Float</name>
- <key>float_converter</key>
- </option>
- <option>
- <name>Integer</name>
- <key>int_converter</key>
- </option>
- <option>
- <name>String</name>
- <key>str_converter</key>
- </option>
- <option>
- <name>Evaluate</name>
- <key>eval_converter</key>
- </option>
- </param>
- <param>
- <name>Formatter</name>
- <key>formatter</key>
- <value>None</value>
- <type>raw</type>
- <hide>part</hide>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <doc>
-This block creates a variable with a text box. \
-Leave the label blank to use the variable id as the label.
-
-Format should be a function/lambda that converts a value into a string or None for the default formatter.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/wxgui_constellationsink2.xml b/gr-wxgui/grc/wxgui_constellationsink2.xml
deleted file mode 100644
index 999ebbe2cf..0000000000
--- a/gr-wxgui/grc/wxgui_constellationsink2.xml
+++ /dev/null
@@ -1,141 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Constellation Sink
-###################################################
- -->
-<block>
- <name>WX GUI Constellation Sink</name>
- <key>wxgui_constellationsink2</key>
- <category>[Core]/Instrumentation/WX</category>
- <import>from gnuradio.wxgui import constsink_gl</import>
- <import>from gnuradio import wxgui</import>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-constsink_gl.const_sink_c(
- $(parent).GetWin(),
- title=$title,
- sample_rate=$samp_rate,
- frame_rate=$frame_rate,
- const_size=$const_size,
- M=$M,
- theta=$theta,
- loop_bw=$loop_bw,
- fmax=$fmax,
- mu=$mu,
- gain_mu=$gain_mu,
- symbol_rate=$symbol_rate,
- omega_limit=$omega_limit,
-#if $win_size()
- size=$win_size,
-#end if
-)
-#if not $grid_pos()
-$(parent).Add(self.$(id).win)
-#else
-$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
-#end if</make>
- <callback>set_sample_rate($samp_rate)</callback>
- <param>
- <name>Title</name>
- <key>title</key>
- <value>Constellation Plot</value>
- <type>string</type>
- </param>
- <param>
- <name>Sample Rate</name>
- <key>samp_rate</key>
- <value>samp_rate</value>
- <type>real</type>
- </param>
- <param>
- <name>Frame Rate</name>
- <key>frame_rate</key>
- <value>5</value>
- <type>real</type>
- </param>
- <param>
- <name>Constellation Size</name>
- <key>const_size</key>
- <value>2048</value>
- <type>real</type>
- </param>
- <param>
- <name>M</name>
- <key>M</key>
- <value>4</value>
- <type>int</type>
- </param>
- <param>
- <name>Theta</name>
- <key>theta</key>
- <value>0</value>
- <type>real</type>
- </param>
- <param>
- <name>Loop Bandwidth</name>
- <key>loop_bw</key>
- <value>6.28/100.0</value>
- <type>real</type>
- </param>
- <param>
- <name>Max Freq</name>
- <key>fmax</key>
- <value>0.06</value>
- <type>real</type>
- </param>
- <param>
- <name>Mu</name>
- <key>mu</key>
- <value>0.5</value>
- <type>real</type>
- </param>
- <param>
- <name>Gain Mu</name>
- <key>gain_mu</key>
- <value>0.005</value>
- <type>real</type>
- </param>
- <param>
- <name>Symbol Rate</name>
- <key>symbol_rate</key>
- <value>samp_rate/4.</value>
- <type>real</type>
- </param>
- <param>
- <name>Omega Limit</name>
- <key>omega_limit</key>
- <value>0.005</value>
- <type>real</type>
- </param>
- <param>
- <name>Window Size</name>
- <key>win_size</key>
- <value></value>
- <type>int_vector</type>
- <hide>#if $win_size() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <check>not $win_size or len($win_size) == 2</check>
- <sink>
- <name>in</name>
- <type>complex</type>
- </sink>
- <doc>
-Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/wxgui_fftsink2.xml b/gr-wxgui/grc/wxgui_fftsink2.xml
deleted file mode 100644
index 11e9c7255e..0000000000
--- a/gr-wxgui/grc/wxgui_fftsink2.xml
+++ /dev/null
@@ -1,246 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##FFT Sink
-###################################################
- -->
-<block>
- <name>WX GUI FFT Sink</name>
- <key>wxgui_fftsink2</key>
- <category>[Core]/Instrumentation/WX</category>
- <import>from gnuradio.fft import window</import>
- <import>from gnuradio.wxgui import fftsink2</import>
- <import>from gnuradio import wxgui</import>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-fftsink2.$(type.fcn)(
- $(parent).GetWin(),
- baseband_freq=$baseband_freq,
- y_per_div=$y_per_div,
- y_divs=$y_divs,
- ref_level=$ref_level,
- ref_scale=$ref_scale,
- sample_rate=$samp_rate,
- fft_size=$fft_size,
- fft_rate=$fft_rate,
- average=$average,
- avg_alpha=#if $avg_alpha() then $avg_alpha else 'None'#,
- title=$title,
- peak_hold=$peak_hold,
-#if $win()
- win=$win,
-#end if
-#if $win_size()
- size=$win_size,
-#end if
-)
-#if not $grid_pos()
-$(parent).Add(self.$(id).win)
-#else
-$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
-#end if
-#if $freqvar() is not None
-def $(id)_callback(x, y):
- self.set_$(freqvar)(x)
-
-self.$(id).set_callback($(id)_callback)
-#end if</make>
- <callback>set_baseband_freq($baseband_freq)</callback>
- <callback>set_sample_rate($samp_rate)</callback>
- <param>
- <name>Type</name>
- <key>type</key>
- <value>complex</value>
- <type>enum</type>
- <option>
- <name>Complex</name>
- <key>complex</key>
- <opt>fcn:fft_sink_c</opt>
- </option>
- <option>
- <name>Float</name>
- <key>float</key>
- <opt>fcn:fft_sink_f</opt>
- </option>
- </param>
- <param>
- <name>Title</name>
- <key>title</key>
- <value>FFT Plot</value>
- <type>string</type>
- </param>
- <param>
- <name>Sample Rate</name>
- <key>samp_rate</key>
- <value>samp_rate</value>
- <type>real</type>
- </param>
- <param>
- <name>Baseband Freq</name>
- <key>baseband_freq</key>
- <value>0</value>
- <type>real</type>
- </param>
- <param>
- <name>Y per Div</name>
- <key>y_per_div</key>
- <value>10</value>
- <type>enum</type>
- <option>
- <name>1 dB</name>
- <key>1</key>
- </option>
- <option>
- <name>2 dB</name>
- <key>2</key>
- </option>
- <option>
- <name>5 dB</name>
- <key>5</key>
- </option>
- <option>
- <name>10 dB</name>
- <key>10</key>
- </option>
- <option>
- <name>20 dB</name>
- <key>20</key>
- </option>
- </param>
- <param>
- <name>Y Divs</name>
- <key>y_divs</key>
- <value>10</value>
- <type>int</type>
- </param>
- <param>
- <name>Ref Level (dB)</name>
- <key>ref_level</key>
- <value>0</value>
- <type>real</type>
- </param>
- <param>
- <name>Ref Scale (p2p)</name>
- <key>ref_scale</key>
- <value>2.0</value>
- <type>real</type>
- </param>
- <param>
- <name>FFT Size</name>
- <key>fft_size</key>
- <value>1024</value>
- <type>int</type>
- </param>
- <param>
- <name>Refresh Rate</name>
- <key>fft_rate</key>
- <value>15</value>
- <type>int</type>
- </param>
- <param>
- <name>Peak Hold</name>
- <key>peak_hold</key>
- <value>False</value>
- <type>enum</type>
- <hide>#if $peak_hold() == 'True' then 'none' else 'part'#</hide>
- <option>
- <name>On</name>
- <key>True</key>
- </option>
- <option>
- <name>Off</name>
- <key>False</key>
- </option>
- </param>
- <param>
- <name>Average</name>
- <key>average</key>
- <value>False</value>
- <type>enum</type>
- <hide>part</hide>
- <option>
- <name>On</name>
- <key>True</key>
- </option>
- <option>
- <name>Off</name>
- <key>False</key>
- </option>
- </param>
- <param>
- <name>Average Alpha</name>
- <key>avg_alpha</key>
- <value>0</value>
- <type>real</type>
- <hide>#if $average() == 'True' then 'none' else 'all'#</hide>
- </param>
- <param>
- <name>Window</name>
- <key>win</key>
- <value>None</value>
- <type>raw</type>
- <hide>#if $win() is None then 'part' else 'none'#</hide>
- <option>
- <name>Automatic</name>
- <key>None</key>
- </option>
- <option>
- <name>Blackman-Harris</name>
- <key>window.blackmanharris</key>
- </option>
- <option>
- <name>Hamming</name>
- <key>window.hamming</key>
- </option>
- <option>
- <name>Hanning</name>
- <key>window.hanning</key>
- </option>
- <option>
- <name>Rectangular</name>
- <key>window.rectangular</key>
- </option>
- <option>
- <name>Flattop</name>
- <key>window.flattop</key>
- </option>
- </param>
- <param>
- <name>Window Size</name>
- <key>win_size</key>
- <value></value>
- <type>int_vector</type>
- <hide>#if $win_size() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <param>
- <name>Freq Set Varname</name>
- <key>freqvar</key>
- <value>None</value>
- <type>raw</type>
- </param>
- <check>not $win_size or len($win_size) == 2</check>
- <sink>
- <name>in</name>
- <type>$type</type>
- </sink>
- <doc>
-Set Average Alpha to 0 for automatic setting.
-
-Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/wxgui_histosink2.xml b/gr-wxgui/grc/wxgui_histosink2.xml
deleted file mode 100644
index 63bfc000ae..0000000000
--- a/gr-wxgui/grc/wxgui_histosink2.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Histogram Sink
-###################################################
- -->
-<block>
- <name>WX GUI Histo Sink</name>
- <key>wxgui_histosink2</key>
- <category>[Core]/Instrumentation/WX</category>
- <import>from gnuradio.wxgui import histosink_gl</import>
- <import>from gnuradio import wxgui</import>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-histosink_gl.histo_sink_f(
- $(parent).GetWin(),
- title=$title,
- num_bins=$num_bins,
- frame_size=$frame_size,
-#if $win_size()
- size=$win_size,
-#end if
-)
-#if not $grid_pos()
-$(parent).Add(self.$(id).win)
-#else
-$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
-#end if</make>
- <callback>set_num_bins($num_bins)</callback>
- <callback>set_frame_size($frame_size)</callback>
- <param>
- <name>Title</name>
- <key>title</key>
- <value>Histogram Plot</value>
- <type>string</type>
- </param>
- <param>
- <name>Num Bins</name>
- <key>num_bins</key>
- <value>27</value>
- <type>int</type>
- </param>
- <param>
- <name>Frame Size</name>
- <key>frame_size</key>
- <value>1000</value>
- <type>int</type>
- </param>
- <param>
- <name>Window Size</name>
- <key>win_size</key>
- <value></value>
- <type>int_vector</type>
- <hide>#if $win_size() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <check>not $win_size or len($win_size) == 2</check>
- <sink>
- <name>in</name>
- <type>float</type>
- </sink>
- <doc>
-Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/wxgui_numbersink2.xml b/gr-wxgui/grc/wxgui_numbersink2.xml
deleted file mode 100644
index 6f4d4a574a..0000000000
--- a/gr-wxgui/grc/wxgui_numbersink2.xml
+++ /dev/null
@@ -1,194 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Number Sink
-###################################################
- -->
-<block>
- <name>WX GUI Number Sink</name>
- <key>wxgui_numbersink2</key>
- <category>[Core]/Instrumentation/WX</category>
- <import>from gnuradio.wxgui import numbersink2</import>
- <import>from gnuradio import wxgui</import>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-numbersink2.$(type.fcn)(
- $(parent).GetWin(),
- unit=$units,
- minval=$min_value,
- maxval=$max_value,
- factor=$factor,
- decimal_places=$decimal_places,
- ref_level=$ref_level,
- sample_rate=$samp_rate,
- number_rate=$number_rate,
- average=$average,
- avg_alpha=#if $avg_alpha() then $avg_alpha else 'None'#,
- label=$title,
- peak_hold=$peak_hold,
- show_gauge=$show_gauge,
-#if $win_size()
- size=$win_size,
-#end if
-)
-#if not $grid_pos()
-$(parent).Add(self.$(id).win)
-#else
-$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
-#end if</make>
- <param>
- <name>Type</name>
- <key>type</key>
- <value>complex</value>
- <type>enum</type>
- <option>
- <name>Complex</name>
- <key>complex</key>
- <opt>fcn:number_sink_c</opt>
- </option>
- <option>
- <name>Float</name>
- <key>float</key>
- <opt>fcn:number_sink_f</opt>
- </option>
- </param>
- <param>
- <name>Title</name>
- <key>title</key>
- <value>Number Plot</value>
- <type>string</type>
- </param>
- <param>
- <name>Units</name>
- <key>units</key>
- <value>Units</value>
- <type>string</type>
- </param>
- <param>
- <name>Sample Rate</name>
- <key>samp_rate</key>
- <value>samp_rate</value>
- <type>real</type>
- </param>
- <param>
- <name>Min Value</name>
- <key>min_value</key>
- <value>-100</value>
- <type>real</type>
- </param>
- <param>
- <name>Max Value</name>
- <key>max_value</key>
- <value>100</value>
- <type>real</type>
- </param>
- <param>
- <name>Factor</name>
- <key>factor</key>
- <value>1.0</value>
- <type>real</type>
- </param>
- <param>
- <name>Decimal Places</name>
- <key>decimal_places</key>
- <value>10</value>
- <type>int</type>
- </param>
- <param>
- <name>Reference Level</name>
- <key>ref_level</key>
- <value>0</value>
- <type>real</type>
- </param>
- <param>
- <name>Number Rate</name>
- <key>number_rate</key>
- <value>15</value>
- <type>int</type>
- </param>
- <param>
- <name>Peak Hold</name>
- <key>peak_hold</key>
- <value>False</value>
- <type>enum</type>
- <hide>#if $peak_hold() == 'True' then 'none' else 'part'#</hide>
- <option>
- <name>On</name>
- <key>True</key>
- </option>
- <option>
- <name>Off</name>
- <key>False</key>
- </option>
- </param>
- <param>
- <name>Average</name>
- <key>average</key>
- <value>False</value>
- <type>enum</type>
- <hide>part</hide>
- <option>
- <name>On</name>
- <key>True</key>
- </option>
- <option>
- <name>Off</name>
- <key>False</key>
- </option>
- </param>
- <param>
- <name>Average Alpha</name>
- <key>avg_alpha</key>
- <value>0</value>
- <type>real</type>
- <hide>#if $average() == 'True' then 'none' else 'all'#</hide>
- </param>
- <param>
- <name>Show Gauge</name>
- <key>show_gauge</key>
- <value>True</value>
- <type>enum</type>
- <option>
- <name>Show</name>
- <key>True</key>
- </option>
- <option>
- <name>Hide</name>
- <key>False</key>
- </option>
- </param>
- <param>
- <name>Window Size</name>
- <key>win_size</key>
- <value></value>
- <type>int_vector</type>
- <hide>#if $win_size() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <check>not $win_size or len($win_size) == 2</check>
- <sink>
- <name>in</name>
- <type>$type</type>
- </sink>
- <doc>
-Set Average Alpha to 0 for automatic setting.
-
-Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
-
-Incoming numbers are multiplied by the factor, and then added-to by the reference level.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/wxgui_scopesink2.xml b/gr-wxgui/grc/wxgui_scopesink2.xml
deleted file mode 100644
index 7e896897d6..0000000000
--- a/gr-wxgui/grc/wxgui_scopesink2.xml
+++ /dev/null
@@ -1,187 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Scope Sink
-###################################################
- -->
-<block>
- <name>WX GUI Scope Sink</name>
- <key>wxgui_scopesink2</key>
- <category>[Core]/Instrumentation/WX</category>
- <import>from gnuradio.wxgui import scopesink2</import>
- <import>from gnuradio import wxgui</import>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-scopesink2.$(type.fcn)(
- $(parent).GetWin(),
- title=$title,
- sample_rate=$samp_rate,
- v_scale=$v_scale,
- v_offset=$v_offset,
- t_scale=$t_scale,
- ac_couple=$ac_couple,
- xy_mode=$xy_mode,
- num_inputs=$num_inputs,
- trig_mode=$trig_mode,
- y_axis_label=$y_axis_label,
-#if $win_size()
- size=$win_size,
-#end if
-)
-#if not $grid_pos()
-$(parent).Add(self.$(id).win)
-#else
-$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
-#end if</make>
- <callback>set_sample_rate($samp_rate)</callback>
- <param>
- <name>Type</name>
- <key>type</key>
- <value>complex</value>
- <type>enum</type>
- <option>
- <name>Complex</name>
- <key>complex</key>
- <opt>fcn:scope_sink_c</opt>
- </option>
- <option>
- <name>Float</name>
- <key>float</key>
- <opt>fcn:scope_sink_f</opt>
- </option>
- </param>
- <param>
- <name>Title</name>
- <key>title</key>
- <value>Scope Plot</value>
- <type>string</type>
- </param>
- <param>
- <name>Sample Rate</name>
- <key>samp_rate</key>
- <value>samp_rate</value>
- <type>real</type>
- </param>
- <param>
- <name>V Scale</name>
- <key>v_scale</key>
- <value>0</value>
- <type>real</type>
- <hide>#if $v_scale() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>V Offset</name>
- <key>v_offset</key>
- <value>0</value>
- <type>real</type>
- <hide>#if $v_offset() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>T Scale</name>
- <key>t_scale</key>
- <value>0</value>
- <type>real</type>
- <hide>#if $t_scale() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>AC Couple</name>
- <key>ac_couple</key>
- <value>False</value>
- <type>bool</type>
- <hide>#if $ac_couple() then 'none' else 'part'#</hide>
- <option>
- <name>Off</name>
- <key>False</key>
- </option>
- <option>
- <name>On</name>
- <key>True</key>
- </option>
- </param>
- <param>
- <name>XY Mode</name>
- <key>xy_mode</key>
- <value>False</value>
- <type>enum</type>
- <hide>#if $xy_mode() == 'True' then 'none' else 'part'#</hide>
- <option>
- <name>Off</name>
- <key>False</key>
- </option>
- <option>
- <name>On</name>
- <key>True</key>
- </option>
- </param>
- <param>
- <name>Num Inputs</name>
- <key>num_inputs</key>
- <value>1</value>
- <type>int</type>
- </param>
- <param>
- <name>Window Size</name>
- <key>win_size</key>
- <value></value>
- <type>int_vector</type>
- <hide>#if $win_size() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <param>
- <name>Trigger Mode</name>
- <key>trig_mode</key>
- <type>enum</type>
- <option>
- <name>Auto</name>
- <key>wxgui.TRIG_MODE_AUTO</key>
- </option>
- <option>
- <name>Normal</name>
- <key>wxgui.TRIG_MODE_NORM</key>
- </option>
- <option>
- <name>Freerun</name>
- <key>wxgui.TRIG_MODE_FREE</key>
- </option>
- <option>
- <name>Stripchart</name>
- <key>wxgui.TRIG_MODE_STRIPCHART</key>
- </option>
- </param>
- <param>
- <name>Y Axis Label</name>
- <key>y_axis_label</key>
- <value>Counts</value>
- <type>string</type>
- </param>
- <check>not $win_size or len($win_size) == 2</check>
- <check>not $xy_mode or '$type' == 'complex' or $num_inputs != 1</check>
- <sink>
- <name>in</name>
- <type>$type</type>
- <nports>$num_inputs</nports>
- </sink>
- <doc>
-Set the V Scale to 0 for the scope to auto-scale.
-
-Set the T Scale to 0 for automatic setting.
-
-XY Mode allows the scope to initialize as an XY plotter.
-
-Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/grc/wxgui_termsink.xml b/gr-wxgui/grc/wxgui_termsink.xml
deleted file mode 100644
index 54fedde081..0000000000
--- a/gr-wxgui/grc/wxgui_termsink.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Terminal window
-###################################################
- -->
-<block>
- <name>WX GUI Terminal Sink</name>
- <key>wxgui_termsink</key>
- <category>[Core]/Instrumentation/WX</category>
-
- <import>from gnuradio.wxgui import termsink</import>
- <import>from gnuradio import wxgui</import>
-
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-termsink.termsink(
- parent=$(parent).GetWin(),
-#if $win_size()
- size=$win_size,
-#end if
- msgq=$(id)_msgq_in,
-)
-#if not $grid_pos()
-$(parent).Add(self.$(id))
-#else
-$(parent).GridAdd(self.$(id), $(', '.join(map(str, $grid_pos()))))
-#end if</make>
-
- <param>
- <name>Window Size</name>
- <key>win_size</key>
- <value></value>
- <type>int_vector</type>
- <hide>#if $win_size() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
-
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
-
- <check>not $win_size or len($win_size) == 2</check>
-
- <sink>
- <name>in</name>
- <type>msg</type>
- </sink>
-
-</block>
diff --git a/gr-wxgui/grc/wxgui_waterfallsink2.xml b/gr-wxgui/grc/wxgui_waterfallsink2.xml
deleted file mode 100644
index 5b56f98ebe..0000000000
--- a/gr-wxgui/grc/wxgui_waterfallsink2.xml
+++ /dev/null
@@ -1,203 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Waterfall Sink
-###################################################
- -->
-<block>
- <name>WX GUI Waterfall Sink</name>
- <key>wxgui_waterfallsink2</key>
- <category>[Core]/Instrumentation/WX</category>
- <import>from gnuradio.fft import window</import>
- <import>from gnuradio.wxgui import waterfallsink2</import>
- <import>from gnuradio import wxgui</import>
- <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
-waterfallsink2.$(type.fcn)(
- $(parent).GetWin(),
- baseband_freq=$baseband_freq,
- dynamic_range=$dynamic_range,
- ref_level=$ref_level,
- ref_scale=$ref_scale,
- sample_rate=$samp_rate,
- fft_size=$fft_size,
- fft_rate=$fft_rate,
- average=$average,
- avg_alpha=#if $avg_alpha() then $avg_alpha else 'None'#,
- title=$title,
-#if $win()
- win=$win,
-#end if
-#if $win_size()
- size=$win_size,
-#end if
-)
-#if not $grid_pos()
-$(parent).Add(self.$(id).win)
-#else
-$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
-#end if
-#if $freqvar() is not None
-def $(id)_callback(x, y):
- self.set_$(freqvar)(x)
-
-self.$(id).set_callback($(id)_callback)
-#end if</make>
- <callback>set_baseband_freq($baseband_freq)</callback>
- <callback>set_sample_rate($samp_rate)</callback>
- <param>
- <name>Type</name>
- <key>type</key>
- <value>complex</value>
- <type>enum</type>
- <option>
- <name>Complex</name>
- <key>complex</key>
- <opt>fcn:waterfall_sink_c</opt>
- </option>
- <option>
- <name>Float</name>
- <key>float</key>
- <opt>fcn:waterfall_sink_f</opt>
- </option>
- </param>
- <param>
- <name>Title</name>
- <key>title</key>
- <value>Waterfall Plot</value>
- <type>string</type>
- </param>
- <param>
- <name>Sample Rate</name>
- <key>samp_rate</key>
- <value>samp_rate</value>
- <type>real</type>
- </param>
- <param>
- <name>Baseband Freq</name>
- <key>baseband_freq</key>
- <value>0</value>
- <type>real</type>
- </param>
- <param>
- <name>Dynamic Range</name>
- <key>dynamic_range</key>
- <value>100</value>
- <type>real</type>
- </param>
- <param>
- <name>Reference Level</name>
- <key>ref_level</key>
- <value>0</value>
- <type>real</type>
- </param>
- <param>
- <name>Ref Scale (p2p)</name>
- <key>ref_scale</key>
- <value>2.0</value>
- <type>real</type>
- </param>
- <param>
- <name>FFT Size</name>
- <key>fft_size</key>
- <value>512</value>
- <type>int</type>
- </param>
- <param>
- <name>FFT Rate</name>
- <key>fft_rate</key>
- <value>15</value>
- <type>int</type>
- </param>
- <param>
- <name>Average</name>
- <key>average</key>
- <value>False</value>
- <type>enum</type>
- <hide>part</hide>
- <option>
- <name>On</name>
- <key>True</key>
- </option>
- <option>
- <name>Off</name>
- <key>False</key>
- </option>
- </param>
- <param>
- <name>Average Alpha</name>
- <key>avg_alpha</key>
- <value>0</value>
- <type>real</type>
- <hide>#if $average() == 'True' then 'none' else 'all'#</hide>
- </param>
- <param>
- <name>Window</name>
- <key>win</key>
- <value>None</value>
- <type>raw</type>
- <hide>#if $win() is None then 'part' else 'none'#</hide>
- <option>
- <name>Automatic</name>
- <key>None</key>
- </option>
- <option>
- <name>Blackman-Harris</name>
- <key>window.blackmanharris</key>
- </option>
- <option>
- <name>Hamming</name>
- <key>window.hamming</key>
- </option>
- <option>
- <name>Hanning</name>
- <key>window.hanning</key>
- </option>
- <option>
- <name>Rectangular</name>
- <key>window.rectangular</key>
- </option>
- <option>
- <name>Flattop</name>
- <key>window.flattop</key>
- </option>
- </param>
- <param>
- <name>Window Size</name>
- <key>win_size</key>
- <value></value>
- <type>int_vector</type>
- <hide>#if $win_size() then 'none' else 'part'#</hide>
- </param>
- <param>
- <name>Grid Position</name>
- <key>grid_pos</key>
- <value></value>
- <type>grid_pos</type>
- </param>
- <param>
- <name>Notebook</name>
- <key>notebook</key>
- <value></value>
- <type>notebook</type>
- </param>
- <param>
- <name>Freq Set Varname</name>
- <key>freqvar</key>
- <value>None</value>
- <type>raw</type>
- </param>
- <check>not $win_size or len($win_size) == 2</check>
- <sink>
- <name>in</name>
- <type>$type</type>
- </sink>
- <doc>
-Set Average Alpha to 0 for automatic setting.
-
-Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
-
-Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
-
-Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
- </doc>
-</block>
diff --git a/gr-wxgui/include/gnuradio/wxgui/CMakeLists.txt b/gr-wxgui/include/gnuradio/wxgui/CMakeLists.txt
deleted file mode 100644
index 468d9b7992..0000000000
--- a/gr-wxgui/include/gnuradio/wxgui/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2013 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-
-########################################################################
-# Install header files
-########################################################################
-install(FILES
- api.h
- histo_sink_f.h
- oscope_guts.h
- oscope_sink_f.h
- oscope_sink_x.h
- trigger_mode.h
- DESTINATION ${GR_INCLUDE_DIR}/gnuradio/wxgui
-)
diff --git a/gr-wxgui/include/gnuradio/wxgui/api.h b/gr-wxgui/include/gnuradio/wxgui/api.h
deleted file mode 100644
index 6439c8e591..0000000000
--- a/gr-wxgui/include/gnuradio/wxgui/api.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_WXGUI_API_H
-#define INCLUDED_WXGUI_API_H
-
-#include <gnuradio/attributes.h>
-
-#ifdef gnuradio_wxgui_EXPORTS
-# define WXGUI_API __GR_ATTR_EXPORT
-#else
-# define WXGUI_API __GR_ATTR_IMPORT
-#endif
-
-#endif /* INCLUDED_WXGUI_API_H */
diff --git a/gr-wxgui/include/gnuradio/wxgui/histo_sink_f.h b/gr-wxgui/include/gnuradio/wxgui/histo_sink_f.h
deleted file mode 100644
index 30f0bc7c0d..0000000000
--- a/gr-wxgui/include/gnuradio/wxgui/histo_sink_f.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_HISTO_SINK_F_H
-#define INCLUDED_GR_HISTO_SINK_F_H
-
-#include <gnuradio/wxgui/api.h>
-#include <gnuradio/sync_block.h>
-#include <gnuradio/msg_queue.h>
-
-namespace gr {
- namespace wxgui {
-
- /*!
- * \brief Histogram module.
- * \ingroup sink_blk
- */
- class WXGUI_API histo_sink_f : virtual public sync_block
- {
- public:
- // gr::blocks::histo_sink_f::sptr
- typedef boost::shared_ptr<histo_sink_f> sptr;
-
- static sptr make(msg_queue::sptr msgq);
-
- virtual unsigned int get_frame_size(void) = 0;
- virtual unsigned int get_num_bins(void) = 0;
-
- virtual void set_frame_size(unsigned int frame_size) = 0;
- virtual void set_num_bins(unsigned int num_bins) = 0;
- };
-
- } /* namespace wxgui */
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_HISTO_SINK_F_H */
diff --git a/gr-wxgui/include/gnuradio/wxgui/oscope_guts.h b/gr-wxgui/include/gnuradio/wxgui/oscope_guts.h
deleted file mode 100644
index 2870d219f6..0000000000
--- a/gr-wxgui/include/gnuradio/wxgui/oscope_guts.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2005,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-
-#ifndef INCLUDED_GR_OSCOPE_GUTS_H
-#define INCLUDED_GR_OSCOPE_GUTS_H
-
-#include <gnuradio/wxgui/api.h>
-#include <gnuradio/wxgui/trigger_mode.h>
-#include <gnuradio/msg_queue.h>
-
-namespace gr {
- namespace wxgui {
-
- /*!
- * \brief guts of oscilloscope trigger and buffer module
- *
- * This module processes sets of samples provided the \p
- * process_sample method. When appropriate given the updateRate,
- * sampleRate and trigger conditions, process_sample will
- * periodically write output records of captured data to
- * output_fd. For each trigger event, nchannels records will be
- * written. Each record consists of get_samples_per_output_record
- * binary floats. The trigger instant occurs at the 1/2 way point
- * in the buffer. Thus, output records consist of 50% pre-trigger
- * data and 50% post-trigger data.
- */
-
- class WXGUI_API oscope_guts
- {
- public:
- static const int MAX_CHANNELS = 8;
-
- private:
- enum scope_state { HOLD_OFF, LOOK_FOR_TRIGGER, POST_TRIGGER };
-
- int d_nchannels; // how many channels
- msg_queue::sptr d_msgq; // message queue we stuff output records into
- trigger_mode d_trigger_mode;
- trigger_slope d_trigger_slope;
- int d_trigger_channel; // which channel to watch for trigger condition
- double d_sample_rate; // input sample rate in Hz
- double d_update_rate; // approx freq to produce an output record (Hz)
- double d_trigger_level;
-
- int d_obi; // output buffer index
- float *d_buffer[MAX_CHANNELS];
-
- scope_state d_state;
- int d_decimator_count;
- int d_decimator_count_init;
- int d_hold_off_count;
- int d_hold_off_count_init;
- int d_pre_trigger_count;
- int d_post_trigger_count;
- int d_post_trigger_count_init;
- float d_trigger_off; //%sample trigger is off
-
- // NOT IMPLEMENTED
- oscope_guts(const oscope_guts &rhs); // no copy constructor
- oscope_guts &operator= (const oscope_guts &rhs); // no assignment operator
-
- void trigger_changed();
- void update_rate_or_decimation_changed();
- bool found_trigger(); // returns true if found
- void write_output_records();
-
- void enter_hold_off(); // called on state entry
- void enter_look_for_trigger();
- void enter_post_trigger();
-
- public:
- // CREATORS
- oscope_guts(double sample_rate, msg_queue::sptr msgq);
- ~oscope_guts();
-
- // MANIPULATORS
-
- /*!
- * \param channel_data points to nchannels float values. These
- * are the values for each channel at this sample time.
- */
- void process_sample(const float *channel_data);
-
- bool set_update_rate(double update_rate);
- bool set_decimation_count(int decimation_count);
- bool set_trigger_channel(int channel);
- bool set_trigger_mode(trigger_mode mode);
- bool set_trigger_slope(trigger_slope slope);
- bool set_trigger_level(double trigger_level);
- bool set_trigger_level_auto(); // set to 50% level
- bool set_sample_rate(double sample_rate);
- bool set_num_channels(int nchannels);
-
- // ACCESSORS
- int num_channels() const;
- double sample_rate() const;
- double update_rate() const;
- int get_decimation_count() const;
- int get_trigger_channel() const;
- trigger_mode get_trigger_mode() const;
- trigger_slope get_trigger_slope() const;
- double get_trigger_level() const;
-
- // # of samples written to each output record.
- int get_samples_per_output_record() const;
- };
-
- } /* namespace wxgui */
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_OSCOPE_GUTS_H */
diff --git a/gr-wxgui/include/gnuradio/wxgui/oscope_sink_f.h b/gr-wxgui/include/gnuradio/wxgui/oscope_sink_f.h
deleted file mode 100644
index 9e86442055..0000000000
--- a/gr-wxgui/include/gnuradio/wxgui/oscope_sink_f.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003-2005,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_OSCOPE_SINK_F_H
-#define INCLUDED_GR_OSCOPE_SINK_F_H
-
-#include <gnuradio/wxgui/api.h>
-#include <gnuradio/wxgui/oscope_sink_x.h>
-#include <gnuradio/msg_queue.h>
-
-namespace gr {
- namespace wxgui {
-
- /*!
- * \brief Building block for python oscilloscope module.
- * \ingroup sink_blk
- *
- * Accepts multiple float streams.
- */
- class WXGUI_API oscope_sink_f
- : virtual public oscope_sink_x
- {
- public:
- // gr::blocks::oscope_sink_f::sptr
- typedef boost::shared_ptr<oscope_sink_f> sptr;
-
- static sptr make(double sampling_rate, msg_queue::sptr msgq);
- };
-
- } /* namespace wxgui */
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_OSCOPE_SINK_F_H */
-
diff --git a/gr-wxgui/include/gnuradio/wxgui/oscope_sink_x.h b/gr-wxgui/include/gnuradio/wxgui/oscope_sink_x.h
deleted file mode 100644
index b72c1dd370..0000000000
--- a/gr-wxgui/include/gnuradio/wxgui/oscope_sink_x.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_OSCOPE_SINK_X_H
-#define INCLUDED_GR_OSCOPE_SINK_X_H
-
-#include <gnuradio/wxgui/api.h>
-#include <gnuradio/wxgui/trigger_mode.h>
-#include <gnuradio/wxgui/oscope_guts.h>
-#include <gnuradio/sync_block.h>
-
-namespace gr {
- namespace wxgui {
-
- /*!
- * \brief Abstract class for python oscilloscope module.
- * \ingroup sink_blk
- *
- * Don't instantiate this. Use gr::blocks::oscope_sink_f instead.
- */
- class WXGUI_API oscope_sink_x : public sync_block
- {
- protected:
- double d_sampling_rate;
- oscope_guts *d_guts;
-
- oscope_sink_x() {};
- oscope_sink_x(const std::string name,
- gr::io_signature::sptr input_sig,
- double sampling_rate);
- public:
- virtual ~oscope_sink_x();
-
- //// gr::blocks::oscope_sink_x::sptr
- //typedef boost::shared_ptr<oscope_sink_x> sptr;
- //
- //static sptr make(const std::string name,
- // gnuradio/io_signature.h_sptr input_sig,
- // double sampling_rate);
-
- bool set_update_rate(double update_rate);
- bool set_decimation_count(int decimation_count);
- bool set_trigger_channel(int channel);
- bool set_trigger_mode(trigger_mode mode);
- bool set_trigger_slope(trigger_slope slope);
- bool set_trigger_level(double trigger_level);
- bool set_trigger_level_auto();
- bool set_sample_rate(double sample_rate);
- bool set_num_channels(int nchannels);
-
- // ACCESSORS
- int num_channels() const;
- double sample_rate() const;
- double update_rate() const;
- int get_decimation_count() const;
- int get_trigger_channel() const;
- trigger_mode get_trigger_mode() const;
- trigger_slope get_trigger_slope() const;
- double get_trigger_level() const;
-
- // # of samples written to each output record.
- int get_samples_per_output_record() const;
-
- virtual int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items) = 0;
- };
-
- } /* namespace wxgui */
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_OSCOPE_SINK_X_H */
diff --git a/gr-wxgui/include/gnuradio/wxgui/trigger_mode.h b/gr-wxgui/include/gnuradio/wxgui/trigger_mode.h
deleted file mode 100644
index 11654ef6c5..0000000000
--- a/gr-wxgui/include/gnuradio/wxgui/trigger_mode.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_TRIGGER_MODE_H
-#define INCLUDED_GR_TRIGGER_MODE_H
-
-namespace gr {
- namespace wxgui {
-
- enum trigger_mode {
- TRIG_MODE_FREE,
- TRIG_MODE_AUTO,
- TRIG_MODE_NORM,
- TRIG_MODE_STRIPCHART,
- };
-
- enum trigger_slope {
- TRIG_SLOPE_POS,
- TRIG_SLOPE_NEG,
- };
-
- } /* namespace wxgui */
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_TRIGGER_MODE_H */
diff --git a/gr-wxgui/lib/CMakeLists.txt b/gr-wxgui/lib/CMakeLists.txt
deleted file mode 100644
index 2f1f6135f3..0000000000
--- a/gr-wxgui/lib/CMakeLists.txt
+++ /dev/null
@@ -1,98 +0,0 @@
-# Copyright 2012-2013 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-
-########################################################################
-# Setup the include and linker paths
-########################################################################
-include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/../include
- ${GR_WXGUI_INCLUDE_DIRS}
- ${GNURADIO_RUNTIME_INCLUDE_DIRS}
- ${VOLK_INCLUDE_DIRS}
- ${Boost_INCLUDE_DIRS}
-)
-
-link_directories(${Boost_LIBRARY_DIRS})
-
-if(ENABLE_GR_CTRLPORT)
- ADD_DEFINITIONS(-DGR_CTRLPORT)
-endif(ENABLE_GR_CTRLPORT)
-
-########################################################################
-# Setup library
-########################################################################
-list(APPEND gr_wxgui_sources
- histo_sink_f_impl.cc
- oscope_guts.cc
- oscope_sink_x.cc
- oscope_sink_f_impl.cc
-)
-
-#Add Windows DLL resource file if using MSVC
-IF(MSVC)
- include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake)
-
- configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-wxgui.rc.in
- ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-wxgui.rc
- @ONLY)
-
- list(APPEND gr_wxgui_sources
- ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-wxgui.rc
- )
-ENDIF(MSVC)
-
-list(APPEND wxgui_libs
- gnuradio-runtime
- ${VOLK_LIBRARIES}
- ${Boost_LIBRARIES}
- ${BLOCKS_LIBRARIES}
- ${LOG4CPP_LIBRARIES}
-)
-
-add_library(gnuradio-wxgui SHARED ${gr_wxgui_sources})
-
-target_link_libraries(gnuradio-wxgui ${wxgui_libs})
-GR_LIBRARY_FOO(gnuradio-wxgui)
-
-if(ENABLE_STATIC_LIBS)
- if(ENABLE_GR_CTRLPORT)
- # Remove GR_CTRLPORT set this target's definitions.
- # Makes sure we don't try to use ControlPort stuff in source files
- GET_DIRECTORY_PROPERTY(STATIC_DEFS COMPILE_DEFINITIONS)
- list(REMOVE_ITEM STATIC_DEFS "GR_CTRLPORT")
- SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS "${STATIC_DEFS}")
-
- # readd it to the target since we removed it from the directory-wide list.
- SET_PROPERTY(TARGET gnuradio-wxgui APPEND PROPERTY COMPILE_DEFINITIONS "GR_CTRLPORT")
- endif(ENABLE_GR_CTRLPORT)
-
- add_library(gnuradio-wxgui_static STATIC ${gr_wxgui_sources})
-
- if(NOT WIN32)
- set_target_properties(gnuradio-wxgui_static
- PROPERTIES OUTPUT_NAME gnuradio-wxgui)
- endif(NOT WIN32)
-
- install(TARGETS gnuradio-wxgui_static
- ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
- )
-endif(ENABLE_STATIC_LIBS)
diff --git a/gr-wxgui/lib/gnuradio-wxgui.rc.in b/gr-wxgui/lib/gnuradio-wxgui.rc.in
deleted file mode 100644
index 126db75091..0000000000
--- a/gr-wxgui/lib/gnuradio-wxgui.rc.in
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-#include <afxres.h>
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
- PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@
- FILEFLAGSMASK 0x3fL
-#ifndef NDEBUG
- FILEFLAGS 0x0L
-#else
- FILEFLAGS 0x1L
-#endif
- FILEOS VOS__WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_DRV_INSTALLABLE
- BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "FileDescription", "gnuradio-blocks"
- VALUE "FileVersion", "@VERSION@"
- VALUE "InternalName", "gnuradio-blocks.dll"
- VALUE "LegalCopyright", "Licensed under GPLv3 or any later version"
- VALUE "OriginalFilename", "gnuradio-blocks.dll"
- VALUE "ProductName", "gnuradio-blocks"
- VALUE "ProductVersion", "@VERSION@"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
- END
diff --git a/gr-wxgui/lib/histo_sink_f_impl.cc b/gr-wxgui/lib/histo_sink_f_impl.cc
deleted file mode 100644
index f10540fa36..0000000000
--- a/gr-wxgui/lib/histo_sink_f_impl.cc
+++ /dev/null
@@ -1,186 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009-2011,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "histo_sink_f_impl.h"
-#include <gnuradio/io_signature.h>
-#include <boost/math/special_functions/round.hpp>
-
-namespace gr {
- namespace wxgui {
-
- static float get_clean_num(float num)
- {
- if(num == 0)
- return 0;
- /* extract sign and exponent from num */
- int sign = (num < 0) ? -1 : 1; num = fabs(num);
- float exponent = floor(log10(num));
- /* search for closest number with base 1, 2, 5, 10 */
- float closest_num = 10*pow(10, exponent);
- if(fabs(num - 1*pow(10, exponent)) < fabs(num - closest_num))
- closest_num = 1*pow(10, exponent);
- if(fabs(num - 2*pow(10, exponent)) < fabs(num - closest_num))
- closest_num = 2*pow(10, exponent);
- if(fabs(num - 5*pow(10, exponent)) < fabs(num - closest_num))
- closest_num = 5*pow(10, exponent);
- return sign*closest_num;
- }
-
- histo_sink_f::sptr
- histo_sink_f::make(msg_queue::sptr msgq)
- {
- return gnuradio::get_initial_sptr
- (new histo_sink_f_impl(msgq));
- }
-
- histo_sink_f_impl::histo_sink_f_impl(msg_queue::sptr msgq)
- : sync_block("histo_sink_f",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make(0, 0, 0)),
- d_msgq(msgq), d_num_bins(11), d_frame_size(1000),
- d_sample_count(0), d_bins(NULL), d_samps(NULL)
- {
- //allocate arrays and clear
- set_num_bins(d_num_bins);
- set_frame_size(d_frame_size);
- }
-
- histo_sink_f_impl::~histo_sink_f_impl(void)
- {
- delete [] d_samps;
- delete [] d_bins;
- }
-
- int
- histo_sink_f_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- const float *in = (const float*)input_items[0];
- gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this function
- for(unsigned int i = 0; i < (unsigned int)noutput_items; i++) {
- d_samps[d_sample_count] = in[i];
- d_sample_count++;
- /* processed a frame? */
- if(d_sample_count == d_frame_size) {
- send_frame();
- clear();
- }
- }
- return noutput_items;
- }
-
- void
- histo_sink_f_impl::send_frame(void)
- {
- /* output queue full, drop the data */
- if(d_msgq->full_p())
- return;
- /* find the minimum and maximum */
- float minimum = d_samps[0];
- float maximum = d_samps[0];
- for(unsigned int i = 0; i < d_frame_size; i++) {
- if(d_samps[i] < minimum) minimum = d_samps[i];
- if(d_samps[i] > maximum) maximum = d_samps[i];
- }
- minimum = get_clean_num(minimum);
- maximum = get_clean_num(maximum);
- if(minimum == maximum || minimum > maximum)
- return; //useless data or screw up?
- /* load the bins */
- int index;
- float bin_width = (maximum - minimum)/(d_num_bins-1);
- for(unsigned int i = 0; i < d_sample_count; i++) {
- index = boost::math::iround((d_samps[i] - minimum)/bin_width);
- /* ensure the index range in case a small floating point error is involed */
- if(index < 0)
- index = 0;
- if(index >= (int)d_num_bins)
- index = d_num_bins-1;
- d_bins[index]++;
- }
- /* Build a message to hold the output records */
- message::sptr msg = message::make(0, minimum, maximum, d_num_bins*sizeof(float));
- float *out = (float *)msg->msg(); // get pointer to raw message buffer
- /* normalize the bins and put into message */
- for(unsigned int i = 0; i < d_num_bins; i++) {
- out[i] = ((float)d_bins[i])/d_frame_size;
- }
- /* send the message */
- d_msgq->handle(msg);
- }
-
- void
- histo_sink_f_impl::clear(void)
- {
- d_sample_count = 0;
- /* zero the bins */
- for(unsigned int i = 0; i < d_num_bins; i++) {
- d_bins[i] = 0;
- }
- }
-
- /**************************************************
- * Getters
- **************************************************/
- unsigned int
- histo_sink_f_impl::get_frame_size(void)
- {
- return d_frame_size;
- }
-
- unsigned int
- histo_sink_f_impl::get_num_bins(void)
- {
- return d_num_bins;
- }
-
- /**************************************************
- * Setters
- **************************************************/
- void
- histo_sink_f_impl::set_frame_size(unsigned int frame_size)
- {
- gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this function
- d_frame_size = frame_size;
- /* allocate a new sample array */
- delete [] d_samps;
- d_samps = new float[d_frame_size];
- clear();
- }
-
- void
- histo_sink_f_impl::set_num_bins(unsigned int num_bins) {
- gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this function
- d_num_bins = num_bins;
- /* allocate a new bin array */
- delete [] d_bins;
- d_bins = new unsigned int[d_num_bins];
- clear();
- }
-
- } /* namespace wxgui */
-} /* namespace gr */
diff --git a/gr-wxgui/lib/histo_sink_f_impl.h b/gr-wxgui/lib/histo_sink_f_impl.h
deleted file mode 100644
index 6c16a8a465..0000000000
--- a/gr-wxgui/lib/histo_sink_f_impl.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_HISTO_SINK_F_IMPL_H
-#define INCLUDED_GR_HISTO_SINK_F_IMPL_H
-
-#include <gnuradio/wxgui/histo_sink_f.h>
-
-namespace gr {
- namespace wxgui {
-
- class histo_sink_f_impl : public histo_sink_f
- {
- private:
- msg_queue::sptr d_msgq;
- unsigned int d_num_bins;
- unsigned int d_frame_size;
- unsigned int d_sample_count;
- unsigned int *d_bins;
- float *d_samps;
- gr::thread::mutex d_mutex;
-
- void send_frame(void);
- void clear(void);
-
- public:
- histo_sink_f_impl(msg_queue::sptr msgq);
- ~histo_sink_f_impl(void);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
- unsigned int get_frame_size(void);
- unsigned int get_num_bins(void);
-
- void set_frame_size(unsigned int frame_size);
- void set_num_bins(unsigned int num_bins);
- };
-
- } /* namespace wxgui */
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_HISTO_SINK_F_IMPL_H */
diff --git a/gr-wxgui/lib/oscope_guts.cc b/gr-wxgui/lib/oscope_guts.cc
deleted file mode 100644
index 3e826ff386..0000000000
--- a/gr-wxgui/lib/oscope_guts.cc
+++ /dev/null
@@ -1,439 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2005,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gnuradio/wxgui/oscope_guts.h>
-#include <stdexcept>
-#include <stdio.h>
-#include <algorithm>
-#include <unistd.h>
-#include <math.h>
-#include <assert.h>
-
-namespace gr {
- namespace wxgui {
-
- /*
- * Bad performance if it's large, and flaky triggering if it's too small
- */
- static const int OUTPUT_RECORD_SIZE = 1024; // Must be power of 2
-
- /*
- * For (slow-updated) STRIPCHART triggering, we make the record
- * size larger, since we potentially want to be able to "see"
- * hours of data. This works as long as the update rates to a
- * STRIPCHART are low, which they generally are--that's rather
- * what a stripchart is all about!
- */
- static const int SCHART_MULT = 8;
-
-
- static inline int
- wrap_bi(int buffer_index, int mx) // wrap buffer index
- {
- return buffer_index & (mx - 1);
- }
-
- static inline int
- incr_bi(int buffer_index, int mx) // increment buffer index
- {
- return wrap_bi(buffer_index + 1, mx);
- }
-
- static inline int
- decr_bi(int buffer_index, int mx) // decrement buffer index
- {
- return wrap_bi(buffer_index - 1, mx);
- }
-
- oscope_guts::oscope_guts(double sample_rate, msg_queue::sptr msgq)
- : d_nchannels(1),
- d_msgq(msgq),
- d_trigger_mode(TRIG_MODE_AUTO),
- d_trigger_slope(TRIG_SLOPE_POS),
- d_trigger_channel(0),
- d_sample_rate(sample_rate),
- d_update_rate(20),
- d_trigger_level(0),
- d_obi(0),
- d_state(HOLD_OFF),
- d_decimator_count(0),
- d_decimator_count_init(1),
- d_hold_off_count(0),
- d_hold_off_count_init(OUTPUT_RECORD_SIZE/2-1),
- d_pre_trigger_count(0),
- d_post_trigger_count(0),
- d_post_trigger_count_init(OUTPUT_RECORD_SIZE/2)
- {
- for(int i = 0; i < MAX_CHANNELS; i++)
- d_buffer[i] = 0;
-
- for(int i = 0; i < MAX_CHANNELS; i++) {
- d_buffer[i] = new float[OUTPUT_RECORD_SIZE*SCHART_MULT];
- for(int j = 0; j < OUTPUT_RECORD_SIZE*SCHART_MULT; j++)
- d_buffer[i][j] = 0.0;
- }
-
- // be sure buffer is full before first write
- enter_hold_off();
- update_rate_or_decimation_changed();
- }
-
- oscope_guts::~oscope_guts()
- {
- for(int i = 0; i < MAX_CHANNELS; i++)
- delete [] d_buffer[i];
- }
-
- // MANIPULATORS
- void
- oscope_guts::process_sample(const float *channel_data)
- {
- d_decimator_count--;
- if(d_decimator_count > 0)
- return;
-
- d_decimator_count = d_decimator_count_init;
-
- if(d_trigger_mode != TRIG_MODE_STRIPCHART) {
- for(int i = 0; i < d_nchannels; i++)
- d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer
-
- switch(d_state) {
- case HOLD_OFF:
- d_hold_off_count--;
- if(d_hold_off_count <= 0)
- enter_look_for_trigger ();
- break;
-
- case LOOK_FOR_TRIGGER:
- if(found_trigger())
- enter_post_trigger();
- break;
-
- case POST_TRIGGER:
- d_post_trigger_count--;
- if(d_post_trigger_count <= 0) {
- write_output_records();
- enter_hold_off();
- }
- break;
-
- default:
- assert(0);
- }
-
- d_obi = incr_bi(d_obi, OUTPUT_RECORD_SIZE);
- }
- else {
- for(int i = 0; i < d_nchannels; i++) {
- for(int j = (OUTPUT_RECORD_SIZE*SCHART_MULT)-1; j > 0; j--) {
- d_buffer[i][j] = d_buffer[i][j-1];
- }
- d_buffer[i][0] = channel_data[i];
- }
- d_trigger_off = 0;
- write_output_records();
- }
- }
-
- /*
- * Functions called on state entry
- */
-
- void
- oscope_guts::enter_hold_off()
- {
- d_state = HOLD_OFF;
- d_hold_off_count = d_hold_off_count_init;
- }
-
- void
- oscope_guts::enter_look_for_trigger()
- {
- d_pre_trigger_count = 0;
- d_state = LOOK_FOR_TRIGGER;
- }
-
- void
- oscope_guts::enter_post_trigger()
- {
- d_state = POST_TRIGGER;
- d_post_trigger_count = d_post_trigger_count_init;
- //ensure that the trigger offset is no more than than half a sample
- if(d_trigger_off > .5)
- d_trigger_off -= 1;
- else
- d_post_trigger_count--;
- }
-
- // ----------------------------------------------------------------
- // returns true if trigger found
-
- bool
- oscope_guts::found_trigger()
- {
- int mx = d_trigger_mode == TRIG_MODE_STRIPCHART ? OUTPUT_RECORD_SIZE*SCHART_MULT :
- OUTPUT_RECORD_SIZE;
-
- float prev_sample = d_buffer[d_trigger_channel][decr_bi(d_obi, mx)];
- float new_sample = d_buffer[d_trigger_channel][d_obi];
-
- switch(d_trigger_mode) {
-
- case TRIG_MODE_AUTO: //too many samples without a trigger
- d_pre_trigger_count++;
- if(d_pre_trigger_count > OUTPUT_RECORD_SIZE/2)
- return true;
-
- case TRIG_MODE_NORM: //look for trigger
- switch(d_trigger_slope) {
-
- case TRIG_SLOPE_POS: //trigger point in pos slope?
- if(new_sample < d_trigger_level || prev_sample >= d_trigger_level)
- return false;
- break;
-
- case TRIG_SLOPE_NEG: //trigger point in neg slope?
- if(new_sample > d_trigger_level || prev_sample <= d_trigger_level)
- return false;
- break;
- }
-
- //calculate the trigger offset in % sample
- d_trigger_off = (d_trigger_level - prev_sample)/(new_sample - prev_sample);
- return true;
-
- case TRIG_MODE_FREE: //free run mode, always trigger
- d_trigger_off = 0;
- return true;
-
- default:
- assert(0);
- return false;
- }
- }
-
- // ----------------------------------------------------------------
- // write output records (duh!)
-
- void
- oscope_guts::write_output_records()
- {
- int mx;
-
- mx = d_trigger_mode == TRIG_MODE_STRIPCHART ?
- OUTPUT_RECORD_SIZE*SCHART_MULT : OUTPUT_RECORD_SIZE;
-
- // if the output queue if full, drop the data like its hot.
- if(d_msgq->full_p())
- return;
- // Build a message to hold the output records
- message::sptr msg =
- message::make(0, // msg type
- d_nchannels, // arg1 for other side
- mx, // arg2 for other side
- ((d_nchannels * mx) + 1) * sizeof(float)); // sizeof payload
-
- float *out = (float *)msg->msg(); // get pointer to raw message buffer
-
- for(int ch = 0; ch < d_nchannels; ch++) {
- // note that d_obi + 1 points at the oldest sample in the buffer
- for(int i = 0; i < mx; i++) {
- out[i] = d_buffer[ch][wrap_bi(d_obi + 1 + i, mx)];
- }
- out += mx;
- }
- //Set the last sample as the trigger offset:
- // The non gl scope sink will not look at this last sample.
- // The gl scope sink will use this last sample as an offset.
- out[0] = d_trigger_off;
- d_msgq->handle(msg); // send the msg
- }
-
- // ----------------------------------------------------------------
-
- bool
- oscope_guts::set_update_rate(double update_rate)
- {
- d_update_rate = std::min(std::max (1./10., update_rate), d_sample_rate);
- update_rate_or_decimation_changed();
- return true;
- }
-
- bool
- oscope_guts::set_decimation_count(int decimator_count)
- {
- decimator_count = std::max(1, decimator_count);
- d_decimator_count_init = decimator_count;
- update_rate_or_decimation_changed();
- return true;
- }
-
- bool
- oscope_guts::set_sample_rate(double sample_rate)
- {
- d_sample_rate = sample_rate;
- return set_update_rate(update_rate());
- }
-
- void
- oscope_guts::update_rate_or_decimation_changed()
- {
- d_hold_off_count_init =
- (int)rint(d_sample_rate / d_update_rate / d_decimator_count_init);
- }
-
- bool
- oscope_guts::set_trigger_channel(int channel)
- {
- if(channel >= 0 && channel < d_nchannels) {
- d_trigger_channel = channel;
- trigger_changed ();
- return true;
- }
-
- return false;
- }
-
- bool
- oscope_guts::set_trigger_mode(trigger_mode mode)
- {
- d_trigger_mode = mode;
- trigger_changed();
- return true;
- }
-
- bool
- oscope_guts::set_trigger_slope(trigger_slope slope)
- {
- d_trigger_slope = slope;
- trigger_changed();
- return true;
- }
-
- bool
- oscope_guts::set_trigger_level(double trigger_level)
- {
- d_trigger_level = trigger_level;
- trigger_changed();
- return true;
- }
-
- bool
- oscope_guts::set_trigger_level_auto()
- {
- // find the level 1/2 way between the min and the max
-
- float min_v = d_buffer[d_trigger_channel][0];
- float max_v = d_buffer[d_trigger_channel][0];
-
- for(int i = 1; i < OUTPUT_RECORD_SIZE; i++) {
- min_v = std::min (min_v, d_buffer[d_trigger_channel][i]);
- max_v = std::max (max_v, d_buffer[d_trigger_channel][i]);
- }
- return set_trigger_level((min_v + max_v) * 0.5);
- }
-
- bool
- oscope_guts::set_num_channels(int nchannels)
- {
- if(nchannels > 0 && nchannels <= MAX_CHANNELS) {
- d_nchannels = nchannels;
- return true;
- }
- return false;
- }
-
- void
- oscope_guts::trigger_changed()
- {
- enter_look_for_trigger();
- }
-
- // ACCESSORS
-
- int
- oscope_guts::num_channels() const
- {
- return d_nchannels;
- }
-
- double
- oscope_guts::sample_rate() const
- {
- return d_sample_rate;
- }
-
- double
- oscope_guts::update_rate() const
- {
- return d_update_rate;
- }
-
- int
- oscope_guts::get_decimation_count() const
- {
- return d_decimator_count_init;
- }
-
- int
- oscope_guts::get_trigger_channel() const
- {
- return d_trigger_channel;
- }
-
- trigger_mode
- oscope_guts::get_trigger_mode() const
- {
- return d_trigger_mode;
- }
-
- trigger_slope
- oscope_guts::get_trigger_slope() const
- {
- return d_trigger_slope;
- }
-
- double
- oscope_guts::get_trigger_level() const
- {
- return d_trigger_level;
- }
-
- int
- oscope_guts::get_samples_per_output_record() const
- {
- int mx;
-
- mx = OUTPUT_RECORD_SIZE;
- if(d_trigger_mode == TRIG_MODE_STRIPCHART) {
- mx = OUTPUT_RECORD_SIZE*SCHART_MULT;
- }
- return mx;
- }
-
- } /* namespace wxgui */
-} /* namespace gr */
diff --git a/gr-wxgui/lib/oscope_sink_f_impl.cc b/gr-wxgui/lib/oscope_sink_f_impl.cc
deleted file mode 100644
index 9993040ffd..0000000000
--- a/gr-wxgui/lib/oscope_sink_f_impl.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003-2005,2010,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "oscope_sink_f_impl.h"
-#include <gnuradio/wxgui/oscope_sink_x.h>
-#include <gnuradio/wxgui/oscope_guts.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace wxgui {
-
- oscope_sink_f::sptr
- oscope_sink_f::make(double sampling_rate, msg_queue::sptr msgq)
- {
- return gnuradio::get_initial_sptr
- (new oscope_sink_f_impl(sampling_rate, msgq));
- }
-
- oscope_sink_f_impl::oscope_sink_f_impl(double sampling_rate, msg_queue::sptr msgq)
- : oscope_sink_x("oscope_sink_f",
- io_signature::make(1, oscope_guts::MAX_CHANNELS,
- sizeof(float)),
- sampling_rate),
- d_msgq(msgq)
- {
- d_guts = new oscope_guts(d_sampling_rate, d_msgq);
- }
-
- oscope_sink_f_impl::~oscope_sink_f_impl()
- {
- }
-
- bool
- oscope_sink_f_impl::check_topology(int ninputs, int noutputs)
- {
- return d_guts->set_num_channels(ninputs);
- }
-
- int
- oscope_sink_f_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
- {
- int ni = input_items.size();
- float tmp[oscope_guts::MAX_CHANNELS];
-
- for(int i = 0; i < noutput_items; i++) {
-
- // FIXME for now, copy the data. Fix later if reqd
- for(int ch = 0; ch < ni; ch++)
- tmp[ch] = ((const float*)input_items[ch])[i];
-
- d_guts->process_sample(tmp);
- }
-
- return noutput_items;
- }
-
- } /* namespace wxgui */
-} /* namespace gr */
diff --git a/gr-wxgui/lib/oscope_sink_f_impl.h b/gr-wxgui/lib/oscope_sink_f_impl.h
deleted file mode 100644
index 81688f53a5..0000000000
--- a/gr-wxgui/lib/oscope_sink_f_impl.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003-2005,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_OSCOPE_SINK_F_IMPL_H
-#define INCLUDED_GR_OSCOPE_SINK_F_IMPL_H
-
-#include <gnuradio/wxgui/oscope_sink_f.h>
-
-namespace gr {
- namespace wxgui {
-
- class oscope_sink_f_impl : public oscope_sink_f
- {
- private:
- msg_queue::sptr d_msgq;
-
- public:
- oscope_sink_f_impl(double sampling_rate, msg_queue::sptr msgq);
- ~oscope_sink_f_impl();
-
- bool check_topology(int ninputs, int noutputs);
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- };
-
- } /* namespace wxgui */
-} /* namespace gr */
-
-#endif /* INCLUDED_GR_OSCOPE_SINK_F_IMPL_H */
-
diff --git a/gr-wxgui/lib/oscope_sink_x.cc b/gr-wxgui/lib/oscope_sink_x.cc
deleted file mode 100644
index ac865318ec..0000000000
--- a/gr-wxgui/lib/oscope_sink_x.cc
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gnuradio/wxgui/oscope_sink_x.h>
-#include <gnuradio/wxgui/oscope_guts.h>
-#include <gnuradio/io_signature.h>
-
-namespace gr {
- namespace wxgui {
-
- oscope_sink_x::oscope_sink_x(const std::string name,
- gr::io_signature::sptr input_sig,
- double sampling_rate)
- : sync_block(name, input_sig,
- io_signature::make(0, 0, 0)),
- d_sampling_rate(sampling_rate), d_guts(0)
- {
- }
-
- oscope_sink_x::~oscope_sink_x()
- {
- delete d_guts;
- }
-
- // ----------------------------------------------------------------
-
- bool
- oscope_sink_x::set_update_rate(double update_rate)
- {
- return d_guts->set_update_rate(update_rate);
- }
-
- bool
- oscope_sink_x::set_decimation_count(int decimation_count)
- {
- return d_guts->set_decimation_count(decimation_count);
- }
-
- bool
- oscope_sink_x::set_trigger_channel(int channel)
- {
- return d_guts->set_trigger_channel(channel);
- }
-
- bool
- oscope_sink_x::set_trigger_mode(trigger_mode mode)
- {
- return d_guts->set_trigger_mode(mode);
- }
-
- bool
- oscope_sink_x::set_trigger_slope(trigger_slope slope)
- {
- return d_guts->set_trigger_slope(slope);
- }
-
- bool
- oscope_sink_x::set_trigger_level(double trigger_level)
- {
- return d_guts->set_trigger_level(trigger_level);
- }
-
- bool
- oscope_sink_x::set_trigger_level_auto()
- {
- return d_guts->set_trigger_level_auto();
- }
-
- bool
- oscope_sink_x::set_sample_rate(double sample_rate)
- {
- return d_guts->set_sample_rate(sample_rate);
- }
-
- bool
- oscope_sink_x::set_num_channels(int nchannels)
- {
- return d_guts->set_num_channels(nchannels);
- }
-
- // ACCESSORS
-
- int
- oscope_sink_x::num_channels() const
- {
- return d_guts->num_channels();
- }
-
- double
- oscope_sink_x::sample_rate() const
- {
- return d_guts->sample_rate();
- }
-
- double
- oscope_sink_x::update_rate() const
- {
- return d_guts->update_rate();
- }
-
- int
- oscope_sink_x::get_decimation_count() const
- {
- return d_guts->get_decimation_count();
- }
-
- int
- oscope_sink_x::get_trigger_channel() const
- {
- return d_guts->get_trigger_channel();
- }
-
- trigger_mode
- oscope_sink_x::get_trigger_mode() const
- {
- return d_guts->get_trigger_mode();
- }
-
- trigger_slope
- oscope_sink_x::get_trigger_slope() const
- {
- return d_guts->get_trigger_slope();
- }
-
- double
- oscope_sink_x::get_trigger_level() const
- {
- return d_guts->get_trigger_level();
- }
-
- int
- oscope_sink_x::get_samples_per_output_record() const
- {
- return d_guts->get_samples_per_output_record();
- }
-
- } /* namespace wxgui */
-} /* namespace gr */
diff --git a/gr-wxgui/python/wxgui/CMakeLists.txt b/gr-wxgui/python/wxgui/CMakeLists.txt
deleted file mode 100644
index a06cba70b7..0000000000
--- a/gr-wxgui/python/wxgui/CMakeLists.txt
+++ /dev/null
@@ -1,85 +0,0 @@
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-
-########################################################################
-include(GrPython)
-
-########################################################################
-# Install python files into wxgui module
-########################################################################
-GR_PYTHON_INSTALL(
- FILES
- __init__.py
- common.py
- constants.py
- constsink_gl.py
- const_window.py
- form.py
- fftsink2.py
- fftsink_nongl.py
- fftsink_gl.py
- fft_window.py
- gui.py
- histosink_gl.py
- histo_window.py
- numbersink2.py
- number_window.py
- plot.py
- powermate.py
- pubsub.py
- scopesink2.py
- scopesink_nongl.py
- scopesink_gl.py
- scope_window.py
- termsink.py
- waterfallsink2.py
- waterfallsink_nongl.py
- waterfallsink_gl.py
- waterfall_window.py
- slider.py
- stdgui2.py
- DESTINATION ${GR_PYTHON_DIR}/gnuradio/wxgui
-)
-
-########################################################################
-# Install python files into wxgui forms sub-module
-########################################################################
-GR_PYTHON_INSTALL(
- FILES
- forms/__init__.py
- forms/forms.py
- forms/converters.py
- DESTINATION ${GR_PYTHON_DIR}/gnuradio/wxgui/forms
-)
-
-########################################################################
-# Install python files into wxgui plotter sub-module
-########################################################################
-GR_PYTHON_INSTALL(
- FILES
- plotter/__init__.py
- plotter/bar_plotter.py
- plotter/channel_plotter.py
- plotter/common.py
- plotter/gltext.py
- plotter/grid_plotter_base.py
- plotter/plotter_base.py
- plotter/waterfall_plotter.py
- DESTINATION ${GR_PYTHON_DIR}/gnuradio/wxgui/plotter
-)
diff --git a/gr-wxgui/python/wxgui/__init__.py b/gr-wxgui/python/wxgui/__init__.py
deleted file mode 100644
index 1c707434c0..0000000000
--- a/gr-wxgui/python/wxgui/__init__.py
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-'''
-Provides a GUI interface using the Wx backend.
-'''
-
-try:
- from wxgui_swig import *
-except ImportError:
- import os
- dirname, filename = os.path.split(os.path.abspath(__file__))
- __path__.append(os.path.join(dirname, "..", "..", "swig"))
- from wxgui_swig import *
diff --git a/gr-wxgui/python/wxgui/common.py b/gr-wxgui/python/wxgui/common.py
deleted file mode 100644
index de2648466b..0000000000
--- a/gr-wxgui/python/wxgui/common.py
+++ /dev/null
@@ -1,296 +0,0 @@
-#
-# Copyright 2008, 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# conditional disconnections of wx flow graph
-##################################################
-import wx
-from gnuradio import gr
-from gnuradio import blocks
-
-RUN_ALWAYS = gr.prefs().get_bool('wxgui', 'run_always', False)
-
-
-class wxgui_hb(object):
- """
- The wxgui hier block helper/wrapper class:
- A hier block should inherit from this class to make use of the wxgui connect method.
- To use, call wxgui_connect in place of regular connect; self.win must be defined.
- The implementation will conditionally enable the copy block after the source (self).
- This condition depends on weather or not the window is visible with the parent notebooks.
- This condition will be re-checked on every ui update event.
- """
-
- def wxgui_connect(self, *points):
- """
- Use wxgui connect when the first point is the self source of the hb.
- The win property of this object should be set to the wx window.
- When this method tries to connect self to the next point,
- it will conditionally make this connection based on the visibility state.
- All other points will be connected normally.
- """
- try:
- assert points[0] == self or points[0][0] == self
- copy = blocks.copy(self.input_signature().sizeof_stream_item(0))
- handler = self._handler_factory(copy.set_enabled)
- if not RUN_ALWAYS:
- handler(False) # initially disable the copy block
- else:
- handler(True) # initially enable the copy block
- self._bind_to_visible_event(win=self.win, handler=handler)
- points = list(points)
- points.insert(1, copy) # insert the copy block into the chain
- except (AssertionError, IndexError): pass
- self.connect(*points) # actually connect the blocks
-
- @staticmethod
- def _handler_factory(handler):
- """
- Create a function that will cache the visibility flag,
- and only call the handler when that flag changes.
-
- Args:
- handler: the function to call on a change
-
- Returns:
- a function of 1 argument
- """
- cache = [None]
-
- def callback(visible):
- if cache[0] == visible: return
- cache[0] = visible
- # print visible, handler
- if not RUN_ALWAYS:
- handler(visible)
- else:
- handler(True)
- return callback
-
- @staticmethod
- def _bind_to_visible_event(win, handler):
- """
- 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.
-
- 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):
- while True:
- parent = my_win.GetParent()
- if not parent: return True # reached the top of the hierarchy
- # if we are hidden, then finish, otherwise keep traversing up
- if isinstance(parent, wx.Notebook) and parent.GetCurrentPage() != my_win: return False
- my_win = parent
- # call the handler, the arg is shown or not
- def handler_factory(my_win, my_handler):
- def callback(evt):
- my_handler(is_wx_window_visible(my_win))
- evt.Skip() # skip so all bound handlers are called
- return callback
- handler = handler_factory(win, handler)
- # bind the handler to all the parent notebooks
- win.Bind(wx.EVT_UPDATE_UI, handler)
-
-##################################################
-# Helpful Functions
-##################################################
-
-# A macro to apply an index to a key
-index_key = lambda key, i: "%s_%d" % (key, i+1)
-
-
-def _register_access_method(destination, controller, key):
- """
- Helper function for register access methods.
- This helper creates distinct set and get methods for each key
- and adds them to the destination object.
- """
- def set(value): controller[key] = value
- setattr(destination, 'set_'+key, set)
- def get(): return controller[key]
- setattr(destination, 'get_'+key, get)
-
-
-def register_access_methods(destination, controller):
- """
- Register setter and getter functions in the destination object for all keys in the 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)
-
-##################################################
-# Input Watcher Thread
-##################################################
-from gnuradio import gru
-
-
-class input_watcher(gru.msgq_runner):
- """
- Input watcher thread runs forever.
- Read messages from the message queue.
- Forward messages to the message handler.
- """
- def __init__ (self, msgq, controller, msg_key, arg1_key='', arg2_key=''):
- self._controller = controller
- self._msg_key = msg_key
- self._arg1_key = arg1_key
- self._arg2_key = arg2_key
- gru.msgq_runner.__init__(self, msgq, self.handle_msg)
-
- def handle_msg(self, msg):
- if self._arg1_key: self._controller[self._arg1_key] = msg.arg1()
- if self._arg2_key: self._controller[self._arg2_key] = msg.arg2()
- self._controller[self._msg_key] = msg.to_string()
-
-
-##################################################
-# Shared Functions
-##################################################
-import numpy
-import math
-
-
-def get_exp(num):
- """
- Get the exponent of the number in base 10.
-
- 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))))
-
-
-def get_clean_num(num):
- """
- Get the closest clean number match to num with bases 1, 2, 5.
-
- Args:
- num: the number
-
- Returns:
- the closest number
- """
- if num == 0: return 0
- sign = num > 0 and 1 or -1
- exp = get_exp(num)
- nums = numpy.array((1, 2, 5, 10))*(10**exp)
- return sign*nums[numpy.argmin(numpy.abs(nums - abs(num)))]
-
-
-def get_clean_incr(num):
- """
- Get the next higher clean number with bases 1, 2, 5.
-
- Args:
- num: the number
-
- Returns:
- the next higher number
- """
- num = get_clean_num(num)
- exp = get_exp(num)
- coeff = int(round(num/10**exp))
- return {
- -5: -2,
- -2: -1,
- -1: -.5,
- 1: 2,
- 2: 5,
- 5: 10,
- }[coeff]*(10**exp)
-
-
-def get_clean_decr(num):
- """
- Get the next lower clean number with bases 1, 2, 5.
-
- Args:
- num: the number
-
- Returns:
- the next lower number
- """
- num = get_clean_num(num)
- exp = get_exp(num)
- coeff = int(round(num/10**exp))
- return {
- -5: -10,
- -2: -5,
- -1: -2,
- 1: .5,
- 2: 1,
- 5: 2,
- }[coeff]*(10**exp)
-
-
-def get_min_max(samples):
- """
- Get the minimum and maximum bounds for an array of samples.
-
- Args:
- samples: the array of real values
-
- Returns:
- a tuple of min, max
- """
- factor = 2.0
- mean = numpy.average(samples)
- std = numpy.std(samples)
- fft = numpy.abs(numpy.fft.fft(samples - mean))
- envelope = 2*numpy.max(fft)/len(samples)
- ampl = max(std, envelope) or 0.1
- return mean - factor*ampl, mean + factor*ampl
-
-
-def get_min_max_fft(fft_samps):
- """
- Get the minimum and maximum bounds for an array of fft samples.
-
- 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)
- # separate noise samples
- noise_samps = numpy.sort(fft_samps)[:len(fft_samps)/2]
- # get the noise floor
- noise_floor = numpy.average(noise_samps)
- # get the noise deviation
- noise_dev = numpy.std(noise_samps)
- # determine the maximum and minimum levels
- max_level = peak_level
- min_level = noise_floor - abs(2*noise_dev)
- return min_level, max_level
diff --git a/gr-wxgui/python/wxgui/const_window.py b/gr-wxgui/python/wxgui/const_window.py
deleted file mode 100644
index 2c499b54bd..0000000000
--- a/gr-wxgui/python/wxgui/const_window.py
+++ /dev/null
@@ -1,211 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-import plotter
-import common
-import wx
-import numpy
-import math
-import pubsub
-from constants import *
-from gnuradio import gr #for gr.prefs
-import forms
-
-##################################################
-# Constants
-##################################################
-SLIDER_STEPS = 200
-LOOP_BW_MIN_EXP, LOOP_BW_MAX_EXP = -6, 0.0
-GAIN_MU_MIN_EXP, GAIN_MU_MAX_EXP = -6, -0.301
-DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'const_rate', 5)
-DEFAULT_WIN_SIZE = (500, 400)
-DEFAULT_CONST_SIZE = gr.prefs().get_long('wxgui', 'const_size', 2048)
-CONST_PLOT_COLOR_SPEC = (0, 0, 1)
-MARKER_TYPES = (
- ('Dot Small', 1.0),
- ('Dot Medium', 2.0),
- ('Dot Large', 3.0),
- ('Line Link', None),
-)
-DEFAULT_MARKER_TYPE = 2.0
-
-##################################################
-# Constellation window control panel
-##################################################
-class control_panel(wx.Panel):
- """
- A control panel with wx widgits to control the plotter.
- """
- def __init__(self, parent):
- """
- Create a new control panel.
-
- Args:
- parent: the wx parent window
- """
- self.parent = parent
- wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
- parent[SHOW_CONTROL_PANEL_KEY] = True
- parent.subscribe(SHOW_CONTROL_PANEL_KEY, self.Show)
- control_box = forms.static_box_sizer(
- parent=self, label='Options',
- bold=True, orient=wx.VERTICAL,
- )
- #loop_bw
- control_box.AddStretchSpacer()
- forms.text_box(
- sizer=control_box, parent=self, label='Loop Bandwidth',
- converter=forms.float_converter(),
- ps=parent, key=LOOP_BW_KEY,
- )
- forms.log_slider(
- sizer=control_box, parent=self,
- min_exp=LOOP_BW_MIN_EXP,
- max_exp=LOOP_BW_MAX_EXP,
- num_steps=SLIDER_STEPS,
- ps=parent, key=LOOP_BW_KEY,
- )
- #gain_mu
- control_box.AddStretchSpacer()
- forms.text_box(
- sizer=control_box, parent=self, label='Gain Mu',
- converter=forms.float_converter(),
- ps=parent, key=GAIN_MU_KEY,
- )
- forms.log_slider(
- sizer=control_box, parent=self,
- min_exp=GAIN_MU_MIN_EXP,
- max_exp=GAIN_MU_MAX_EXP,
- num_steps=SLIDER_STEPS,
- ps=parent, key=GAIN_MU_KEY,
- )
- #marker
- control_box.AddStretchSpacer()
- forms.drop_down(
- sizer=control_box, parent=self,
- ps=parent, key=MARKER_KEY, label='Marker',
- choices=map(lambda x: x[1], MARKER_TYPES),
- labels=map(lambda x: x[0], MARKER_TYPES),
- )
- #run/stop
- control_box.AddStretchSpacer()
- forms.toggle_button(
- sizer=control_box, parent=self,
- true_label='Stop', false_label='Run',
- ps=parent, key=RUNNING_KEY,
- )
- #set sizer
- self.SetSizerAndFit(control_box)
-
-##################################################
-# Constellation window with plotter and control panel
-##################################################
-class const_window(wx.Panel, pubsub.pubsub):
- def __init__(
- self,
- parent,
- controller,
- size,
- title,
- msg_key,
- loop_bw_key,
- gain_mu_key,
- gain_omega_key,
- omega_key,
- sample_rate_key,
- ):
- pubsub.pubsub.__init__(self)
- #proxy the keys
- self.proxy(MSG_KEY, controller, msg_key)
- self.proxy(LOOP_BW_KEY, controller, loop_bw_key)
- self.proxy(GAIN_MU_KEY, controller, gain_mu_key)
- self.proxy(GAIN_OMEGA_KEY, controller, gain_omega_key)
- self.proxy(OMEGA_KEY, controller, omega_key)
- self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
- #initialize values
- self[RUNNING_KEY] = True
- self[X_DIVS_KEY] = 8
- self[Y_DIVS_KEY] = 8
- self[MARKER_KEY] = DEFAULT_MARKER_TYPE
- #init panel and plot
- wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
- self.plotter = plotter.channel_plotter(self)
- self.plotter.SetSize(wx.Size(*size))
- self.plotter.SetSizeHints(*size)
- self.plotter.set_title(title)
- self.plotter.set_x_label('Inphase')
- self.plotter.set_y_label('Quadrature')
- self.plotter.enable_point_label(True)
- self.plotter.enable_grid_lines(True)
- #setup the box with plot and controls
- self.control_panel = control_panel(self)
- main_box = wx.BoxSizer(wx.HORIZONTAL)
- main_box.Add(self.plotter, 1, wx.EXPAND)
- main_box.Add(self.control_panel, 0, wx.EXPAND)
- self.SetSizerAndFit(main_box)
- #alpha and gain mu 2nd orders
- def set_gain_omega(gain_mu): self[GAIN_OMEGA_KEY] = .25*gain_mu**2
- self.subscribe(GAIN_MU_KEY, set_gain_omega)
- #register events
- self.subscribe(MSG_KEY, self.handle_msg)
- self.subscribe(X_DIVS_KEY, self.update_grid)
- self.subscribe(Y_DIVS_KEY, self.update_grid)
- #initial update
- self.update_grid()
-
- def handle_msg(self, msg):
- """
- Plot the samples onto the complex grid.
-
- Args:
- msg: the array of complex samples
- """
- if not self[RUNNING_KEY]: return
- #convert to complex floating point numbers
- samples = numpy.fromstring(msg, numpy.complex64)
- real = numpy.real(samples)
- imag = numpy.imag(samples)
- #plot
- self.plotter.set_waveform(
- channel=0,
- samples=(real, imag),
- color_spec=CONST_PLOT_COLOR_SPEC,
- marker=self[MARKER_KEY],
- )
- #update the plotter
- self.plotter.update()
-
- def update_grid(self):
- #update the x axis
- x_max = 2.0
- self.plotter.set_x_grid(-x_max, x_max, common.get_clean_num(2.0*x_max/self[X_DIVS_KEY]))
- #update the y axis
- y_max = 2.0
- self.plotter.set_y_grid(-y_max, y_max, common.get_clean_num(2.0*y_max/self[Y_DIVS_KEY]))
- #update plotter
- self.plotter.update()
-
-
-
-
diff --git a/gr-wxgui/python/wxgui/constants.py b/gr-wxgui/python/wxgui/constants.py
deleted file mode 100644
index 08cc6a6343..0000000000
--- a/gr-wxgui/python/wxgui/constants.py
+++ /dev/null
@@ -1,76 +0,0 @@
-#
-# Copyright 2008,2010 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Controller Keys
-##################################################
-AC_COUPLE_KEY = 'ac_couple'
-ALPHA_KEY = 'alpha'
-AUTORANGE_KEY = 'autorange'
-AVERAGE_KEY = 'average'
-AVG_ALPHA_KEY = 'avg_alpha'
-USE_PERSISTENCE_KEY = 'use_persistence'
-PERSIST_ALPHA_KEY = 'persist_alpha'
-BASEBAND_FREQ_KEY = 'baseband_freq'
-BETA_KEY = 'beta'
-COLOR_MODE_KEY = 'color_mode'
-DECIMATION_KEY = 'decimation'
-DYNAMIC_RANGE_KEY = 'dynamic_range'
-FRAME_RATE_KEY = 'frame_rate'
-GAIN_MU_KEY = 'gain_mu'
-GAIN_OMEGA_KEY = 'gain_omega'
-MARKER_KEY = 'marker'
-XY_MARKER_KEY = 'xy_marker'
-MSG_KEY = 'msg'
-NUM_LINES_KEY = 'num_lines'
-OMEGA_KEY = 'omega'
-PEAK_HOLD_KEY = 'peak_hold'
-TRACE_STORE_KEY = 'trace_store'
-TRACE_SHOW_KEY = 'trace_show'
-REF_LEVEL_KEY = 'ref_level'
-RUNNING_KEY = 'running'
-SAMPLE_RATE_KEY = 'sample_rate'
-TRIGGER_CHANNEL_KEY = 'trigger_channel'
-TRIGGER_LEVEL_KEY = 'trigger_level'
-TRIGGER_MODE_KEY = 'trigger_mode'
-TRIGGER_SLOPE_KEY = 'trigger_slope'
-TRIGGER_SHOW_KEY = 'trigger_show'
-XY_MODE_KEY = 'xy_mode'
-X_CHANNEL_KEY = 'x_channel'
-Y_CHANNEL_KEY = 'y_channel'
-T_FRAC_OFF_KEY = 't_frac_off'
-T_DIVS_KEY = 't_divs'
-T_OFF_KEY = 't_off'
-T_PER_DIV_KEY = 't_per_div'
-X_DIVS_KEY = 'x_divs'
-X_OFF_KEY = 'x_off'
-X_PER_DIV_KEY = 'x_per_div'
-Y_DIVS_KEY = 'y_divs'
-Y_OFF_KEY = 'y_off'
-Y_PER_DIV_KEY = 'y_per_div'
-Y_AXIS_LABEL = 'y_axis_label'
-MAXIMUM_KEY = 'maximum'
-MINIMUM_KEY = 'minimum'
-NUM_BINS_KEY = 'num_bins'
-FRAME_SIZE_KEY = 'frame_size'
-CHANNEL_OPTIONS_KEY = 'channel_options'
-SHOW_CONTROL_PANEL_KEY = 'show_control_panel'
-LOOP_BW_KEY = 'loop_bw'
diff --git a/gr-wxgui/python/wxgui/constsink_gl.py b/gr-wxgui/python/wxgui/constsink_gl.py
deleted file mode 100644
index dea76ea753..0000000000
--- a/gr-wxgui/python/wxgui/constsink_gl.py
+++ /dev/null
@@ -1,142 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-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
-try:
- from gnuradio import digital
-except ImportError:
- sys.stderr.write("Error: could not import gnuradio.digital, please install gr-digitial.\n")
- sys.exit(1)
-
-##################################################
-# Constellation sink block (wrapper for old wxgui)
-##################################################
-class const_sink_c(gr.hier_block2, common.wxgui_hb):
- """
- A constellation block with a gui window.
- """
-
- def __init__(
- self,
- parent,
- title='',
- sample_rate=1,
- size=const_window.DEFAULT_WIN_SIZE,
- frame_rate=const_window.DEFAULT_FRAME_RATE,
- const_size=const_window.DEFAULT_CONST_SIZE,
- #mpsk recv params
- M=4,
- theta=0,
- loop_bw=6.28/100.0,
- fmax=0.06,
- mu=0.5,
- gain_mu=0.005,
- symbol_rate=1,
- omega_limit=0.005,
- ):
- #init
- gr.hier_block2.__init__(
- self,
- "const_sink",
- gr.io_signature(1, 1, gr.sizeof_gr_complex),
- gr.io_signature(0, 0, 0),
- )
- #blocks
- sd = blocks.stream_to_vector_decimator(
- item_size=gr.sizeof_gr_complex,
- sample_rate=sample_rate,
- vec_rate=frame_rate,
- vec_len=const_size,
- )
- fmin = -fmax
- gain_omega = .25*gain_mu**2 #redundant, will be updated
- omega = 1 #set_sample_rate will update this
- # Costas frequency/phase recovery loop
- # Critically damped 2nd order PLL
- self._costas = digital.costas_loop_cc(loop_bw, M)
- # Timing recovery loop
- # Critically damped 2nd order DLL
- self._retime = digital.clock_recovery_mm_cc(omega,
- gain_omega,
- mu, gain_mu,
- omega_limit)
- #sync = gr.mpsk_receiver_cc(
- # M, #psk order
- # theta,
- # alpha,
- # beta,
- # fmin,
- # fmax,
- # mu,
- # gain_mu,
- # omega,
- # gain_omega,
- # omega_limit,
- #)
- 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
- def setter(p, k, x): p[k] = x
- self.controller = pubsub()
- self.controller.subscribe(LOOP_BW_KEY, self._costas.set_loop_bandwidth)
- self.controller.publish(LOOP_BW_KEY, self._costas.get_loop_bandwidth)
- self.controller.subscribe(GAIN_MU_KEY, self._retime.set_gain_mu)
- self.controller.publish(GAIN_MU_KEY, self._retime.gain_mu)
- self.controller.subscribe(OMEGA_KEY, self._retime.set_omega)
- self.controller.publish(OMEGA_KEY, self._retime.omega)
- self.controller.subscribe(GAIN_OMEGA_KEY, self._retime.set_gain_omega)
- self.controller.publish(GAIN_OMEGA_KEY, self._retime.gain_omega)
- self.controller.subscribe(SAMPLE_RATE_KEY, sd.set_sample_rate)
- self.controller.subscribe(SAMPLE_RATE_KEY, lambda x: setter(self.controller, OMEGA_KEY, float(x)/symbol_rate))
- self.controller.publish(SAMPLE_RATE_KEY, sd.sample_rate)
- #initial update
- self.controller[SAMPLE_RATE_KEY] = sample_rate
- #start input watcher
- common.input_watcher(msgq, self.controller, MSG_KEY)
- #create window
- self.win = const_window.const_window(
- parent=parent,
- controller=self.controller,
- size=size,
- title=title,
- msg_key=MSG_KEY,
- loop_bw_key=LOOP_BW_KEY,
- gain_mu_key=GAIN_MU_KEY,
- gain_omega_key=GAIN_OMEGA_KEY,
- omega_key=OMEGA_KEY,
- sample_rate_key=SAMPLE_RATE_KEY,
- )
- common.register_access_methods(self, self.win)
- #connect
- self.wxgui_connect(self, self._costas, self._retime, agc, sd, sink)
-
-
diff --git a/gr-wxgui/python/wxgui/fft_window.py b/gr-wxgui/python/wxgui/fft_window.py
deleted file mode 100644
index 024200556e..0000000000
--- a/gr-wxgui/python/wxgui/fft_window.py
+++ /dev/null
@@ -1,412 +0,0 @@
-#
-# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-import plotter
-import common
-import wx
-import numpy
-import math
-import pubsub
-from constants import *
-from gnuradio import gr #for gr.prefs
-import forms
-
-##################################################
-# Constants
-##################################################
-SLIDER_STEPS = 100
-AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0
-PERSIST_ALPHA_MIN_EXP, PERSIST_ALPHA_MAX_EXP = -2, 0
-DEFAULT_WIN_SIZE = (600, 300)
-DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'fft_rate', 30)
-DB_DIV_MIN, DB_DIV_MAX = 1, 20
-FFT_PLOT_COLOR_SPEC = (0.3, 0.3, 1.0)
-PEAK_VALS_COLOR_SPEC = (0.0, 0.8, 0.0)
-EMPTY_TRACE = list()
-TRACES = ('A', 'B')
-TRACES_COLOR_SPEC = {
- 'A': (1.0, 0.0, 0.0),
- 'B': (0.8, 0.0, 0.8),
-}
-
-##################################################
-# FFT window control panel
-##################################################
-class control_panel(wx.Panel):
- """
- A control panel with wx widgits to control the plotter and fft block chain.
- """
-
- def __init__(self, parent):
- """
- Create a new control panel.
-
- Args:
- parent: the wx parent window
- """
- self.parent = parent
- wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
- parent[SHOW_CONTROL_PANEL_KEY] = True
- parent.subscribe(SHOW_CONTROL_PANEL_KEY, self.Show)
- control_box = wx.BoxSizer(wx.VERTICAL)
- control_box.AddStretchSpacer()
- #checkboxes for average and peak hold
- options_box = forms.static_box_sizer(
- parent=self, sizer=control_box, label='Trace Options',
- bold=True, orient=wx.VERTICAL,
- )
- forms.check_box(
- sizer=options_box, parent=self, label='Peak Hold',
- ps=parent, key=PEAK_HOLD_KEY,
- )
- forms.check_box(
- sizer=options_box, parent=self, label='Average',
- ps=parent, key=AVERAGE_KEY,
- )
- #static text and slider for averaging
- avg_alpha_text = forms.static_text(
- sizer=options_box, parent=self, label='Avg Alpha',
- converter=forms.float_converter(lambda x: '%.4f'%x),
- ps=parent, key=AVG_ALPHA_KEY, width=50,
- )
- avg_alpha_slider = forms.log_slider(
- sizer=options_box, parent=self,
- min_exp=AVG_ALPHA_MIN_EXP,
- max_exp=AVG_ALPHA_MAX_EXP,
- num_steps=SLIDER_STEPS,
- ps=parent, key=AVG_ALPHA_KEY,
- )
- for widget in (avg_alpha_text, avg_alpha_slider):
- parent.subscribe(AVERAGE_KEY, widget.Enable)
- widget.Enable(parent[AVERAGE_KEY])
- parent.subscribe(AVERAGE_KEY, widget.ShowItems)
- #allways show initially, so room is reserved for them
- widget.ShowItems(True) # (parent[AVERAGE_KEY])
-
- parent.subscribe(AVERAGE_KEY, self._update_layout)
-
- forms.check_box(
- sizer=options_box, parent=self, label='Persistence',
- ps=parent, key=USE_PERSISTENCE_KEY,
- )
- #static text and slider for persist alpha
- persist_alpha_text = forms.static_text(
- sizer=options_box, parent=self, label='Persist Alpha',
- converter=forms.float_converter(lambda x: '%.4f'%x),
- ps=parent, key=PERSIST_ALPHA_KEY, width=50,
- )
- persist_alpha_slider = forms.log_slider(
- sizer=options_box, parent=self,
- min_exp=PERSIST_ALPHA_MIN_EXP,
- max_exp=PERSIST_ALPHA_MAX_EXP,
- num_steps=SLIDER_STEPS,
- ps=parent, key=PERSIST_ALPHA_KEY,
- )
- for widget in (persist_alpha_text, persist_alpha_slider):
- parent.subscribe(USE_PERSISTENCE_KEY, widget.Enable)
- widget.Enable(parent[USE_PERSISTENCE_KEY])
- parent.subscribe(USE_PERSISTENCE_KEY, widget.ShowItems)
- #allways show initially, so room is reserved for them
- widget.ShowItems(True) # (parent[USE_PERSISTENCE_KEY])
-
- parent.subscribe(USE_PERSISTENCE_KEY, self._update_layout)
-
- #trace menu
- for trace in TRACES:
- trace_box = wx.BoxSizer(wx.HORIZONTAL)
- options_box.Add(trace_box, 0, wx.EXPAND)
- forms.check_box(
- sizer=trace_box, parent=self,
- ps=parent, key=TRACE_SHOW_KEY+trace,
- label='Trace %s'%trace,
- )
- trace_box.AddSpacer(10)
- forms.single_button(
- sizer=trace_box, parent=self,
- ps=parent, key=TRACE_STORE_KEY+trace,
- label='Store', style=wx.BU_EXACTFIT,
- )
- trace_box.AddSpacer(10)
- #radio buttons for div size
- control_box.AddStretchSpacer()
- y_ctrl_box = forms.static_box_sizer(
- parent=self, sizer=control_box, label='Axis Options',
- bold=True, orient=wx.VERTICAL,
- )
- forms.incr_decr_buttons(
- parent=self, sizer=y_ctrl_box, label='dB/Div',
- on_incr=self._on_incr_db_div, on_decr=self._on_decr_db_div,
- )
- #ref lvl buttons
- forms.incr_decr_buttons(
- parent=self, sizer=y_ctrl_box, label='Ref Level',
- on_incr=self._on_incr_ref_level, on_decr=self._on_decr_ref_level,
- )
- y_ctrl_box.AddSpacer(2)
- #autoscale
- forms.single_button(
- sizer=y_ctrl_box, parent=self, label='Autoscale',
- callback=self.parent.autoscale,
- )
- #run/stop
- control_box.AddStretchSpacer()
- forms.toggle_button(
- sizer=control_box, parent=self,
- true_label='Stop', false_label='Run',
- ps=parent, key=RUNNING_KEY,
- )
- #set sizer
- self.SetSizerAndFit(control_box)
-
- #mouse wheel event
- def on_mouse_wheel(event):
- if event.GetWheelRotation() < 0: self._on_incr_ref_level(event)
- else: self._on_decr_ref_level(event)
- parent.plotter.Bind(wx.EVT_MOUSEWHEEL, on_mouse_wheel)
-
- ##################################################
- # Event handlers
- ##################################################
- def _on_incr_ref_level(self, event):
- self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] + self.parent[Y_PER_DIV_KEY]
- def _on_decr_ref_level(self, event):
- self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] - self.parent[Y_PER_DIV_KEY]
- def _on_incr_db_div(self, event):
- self.parent[Y_PER_DIV_KEY] = min(DB_DIV_MAX, common.get_clean_incr(self.parent[Y_PER_DIV_KEY]))
- def _on_decr_db_div(self, event):
- self.parent[Y_PER_DIV_KEY] = max(DB_DIV_MIN, common.get_clean_decr(self.parent[Y_PER_DIV_KEY]))
- ##################################################
- # subscriber handlers
- ##################################################
- def _update_layout(self,key):
- # Just ignore the key value we get
- # we only need to now that the visability or size of something has changed
- self.parent.Layout()
- #self.parent.Fit()
-
-##################################################
-# FFT window with plotter and control panel
-##################################################
-class fft_window(wx.Panel, pubsub.pubsub):
- def __init__(
- self,
- parent,
- controller,
- size,
- title,
- real,
- fft_size,
- baseband_freq,
- sample_rate_key,
- y_per_div,
- y_divs,
- ref_level,
- average_key,
- avg_alpha_key,
- peak_hold,
- msg_key,
- use_persistence,
- persist_alpha,
- ):
-
- pubsub.pubsub.__init__(self)
- #setup
- self.samples = EMPTY_TRACE
- self.real = real
- self.fft_size = fft_size
- self._reset_peak_vals()
- self._traces = dict()
- #proxy the keys
- self.proxy(MSG_KEY, controller, msg_key)
- self.proxy(AVERAGE_KEY, controller, average_key)
- self.proxy(AVG_ALPHA_KEY, controller, avg_alpha_key)
- self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
- #initialize values
- self[PEAK_HOLD_KEY] = peak_hold
- self[Y_PER_DIV_KEY] = y_per_div
- self[Y_DIVS_KEY] = y_divs
- self[X_DIVS_KEY] = 8 #approximate
- self[REF_LEVEL_KEY] = ref_level
- self[BASEBAND_FREQ_KEY] = baseband_freq
- self[RUNNING_KEY] = True
- self[USE_PERSISTENCE_KEY] = use_persistence
- self[PERSIST_ALPHA_KEY] = persist_alpha
- for trace in TRACES:
- #a function that returns a function
- #so the function wont use local trace
- def new_store_trace(my_trace):
- def store_trace(*args):
- self._traces[my_trace] = self.samples
- self.update_grid()
- return store_trace
- def new_toggle_trace(my_trace):
- def toggle_trace(toggle):
- #do an automatic store if toggled on and empty trace
- if toggle and not len(self._traces[my_trace]):
- self._traces[my_trace] = self.samples
- self.update_grid()
- return toggle_trace
- self._traces[trace] = EMPTY_TRACE
- self[TRACE_STORE_KEY+trace] = False
- self[TRACE_SHOW_KEY+trace] = False
- self.subscribe(TRACE_STORE_KEY+trace, new_store_trace(trace))
- self.subscribe(TRACE_SHOW_KEY+trace, new_toggle_trace(trace))
- #init panel and plot
- wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
- self.plotter = plotter.channel_plotter(self)
- self.plotter.SetSize(wx.Size(*size))
- self.plotter.SetSizeHints(*size)
- self.plotter.set_title(title)
- self.plotter.enable_legend(True)
- self.plotter.enable_point_label(True)
- self.plotter.enable_grid_lines(True)
- self.plotter.set_use_persistence(use_persistence)
- self.plotter.set_persist_alpha(persist_alpha)
- #setup the box with plot and controls
- self.control_panel = control_panel(self)
- main_box = wx.BoxSizer(wx.HORIZONTAL)
- main_box.Add(self.plotter, 1, wx.EXPAND)
- main_box.Add(self.control_panel, 0, wx.EXPAND)
- self.SetSizerAndFit(main_box)
- #register events
- self.subscribe(AVERAGE_KEY, self._reset_peak_vals)
- self.subscribe(MSG_KEY, self.handle_msg)
- self.subscribe(SAMPLE_RATE_KEY, self.update_grid)
- for key in (
- BASEBAND_FREQ_KEY,
- Y_PER_DIV_KEY, X_DIVS_KEY,
- Y_DIVS_KEY, REF_LEVEL_KEY,
- ): self.subscribe(key, self.update_grid)
- self.subscribe(USE_PERSISTENCE_KEY, self.plotter.set_use_persistence)
- self.subscribe(PERSIST_ALPHA_KEY, self.plotter.set_persist_alpha)
- #initial update
- self.update_grid()
-
- def set_callback(self,callb):
- self.plotter.set_callback(callb)
-
- def autoscale(self, *args):
- """
- Autoscale the fft plot to the last frame.
- Set the dynamic range and reference level.
- """
- if not len(self.samples): return
- min_level, max_level = common.get_min_max_fft(self.samples)
- #set the range to a clean number of the dynamic range
- self[Y_PER_DIV_KEY] = common.get_clean_num(1+(max_level - min_level)/self[Y_DIVS_KEY])
- #set the reference level to a multiple of y per div
- self[REF_LEVEL_KEY] = self[Y_PER_DIV_KEY]*round(.5+max_level/self[Y_PER_DIV_KEY])
-
- def _reset_peak_vals(self, *args): self.peak_vals = EMPTY_TRACE
-
- def handle_msg(self, msg):
- """
- Handle the message from the fft sink message queue.
- If complex, reorder the fft samples so the negative bins come first.
- If real, keep take only the positive bins.
- Plot the samples onto the grid as channel 1.
- If peak hold is enabled, plot peak vals as channel 2.
-
- Args:
- msg: the fft array as a character array
- """
- if not self[RUNNING_KEY]: return
- #convert to floating point numbers
- samples = numpy.fromstring(msg, numpy.float32)[:self.fft_size] #only take first frame
- num_samps = len(samples)
- #reorder fft
- if self.real: samples = samples[:(num_samps+2)/2]
- else: samples = numpy.concatenate((samples[(num_samps+1)/2:], samples[:(num_samps+2)/2]))
- self.samples = samples
- #peak hold calculation
- if self[PEAK_HOLD_KEY]:
- if len(self.peak_vals) != len(samples): self.peak_vals = samples
- self.peak_vals = numpy.maximum(samples, self.peak_vals)
- #plot the peak hold
- self.plotter.set_waveform(
- channel='Peak',
- samples=self.peak_vals,
- color_spec=PEAK_VALS_COLOR_SPEC,
- )
- else:
- self._reset_peak_vals()
- self.plotter.clear_waveform(channel='Peak')
- #plot the fft
- self.plotter.set_waveform(
- channel='FFT',
- samples=samples,
- color_spec=FFT_PLOT_COLOR_SPEC,
- )
- #update the plotter
- self.plotter.update()
-
- def update_grid(self, *args):
- """
- Update the plotter grid.
- This update method is dependent on the variables below.
- Determine the x and y axis grid parameters.
- The x axis depends on sample rate, baseband freq, and x divs.
- The y axis depends on y per div, y divs, and ref level.
- """
- for trace in TRACES:
- channel = '%s'%trace.upper()
- if self[TRACE_SHOW_KEY+trace]:
- self.plotter.set_waveform(
- channel=channel,
- samples=self._traces[trace],
- color_spec=TRACES_COLOR_SPEC[trace],
- )
- else: self.plotter.clear_waveform(channel=channel)
- #grid parameters
- sample_rate = self[SAMPLE_RATE_KEY]
- baseband_freq = self[BASEBAND_FREQ_KEY]
- y_per_div = self[Y_PER_DIV_KEY]
- y_divs = self[Y_DIVS_KEY]
- x_divs = self[X_DIVS_KEY]
- ref_level = self[REF_LEVEL_KEY]
- #determine best fitting x_per_div
- if self.real: x_width = sample_rate/2.0
- else: x_width = sample_rate/1.0
- x_per_div = common.get_clean_num(x_width/x_divs)
- #update the x grid
- if self.real:
- self.plotter.set_x_grid(
- baseband_freq,
- baseband_freq + sample_rate/2.0,
- x_per_div, True,
- )
- else:
- self.plotter.set_x_grid(
- baseband_freq - sample_rate/2.0,
- baseband_freq + sample_rate/2.0,
- x_per_div, True,
- )
- #update x units
- self.plotter.set_x_label('Frequency', 'Hz')
- #update y grid
- self.plotter.set_y_grid(ref_level-y_per_div*y_divs, ref_level, y_per_div)
- #update y units
- self.plotter.set_y_label('Power', 'dB')
- #update plotter
- self.plotter.update()
diff --git a/gr-wxgui/python/wxgui/fftsink2.py b/gr-wxgui/python/wxgui/fftsink2.py
deleted file mode 100644
index 3277cd3ffa..0000000000
--- a/gr-wxgui/python/wxgui/fftsink2.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright 2008,2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr
-
-p = gr.prefs()
-style = p.get_string('wxgui', 'style', 'auto')
-
-if style == 'auto' or style == 'gl':
- try:
- import wx.glcanvas
- from OpenGL.GL import *
- from fftsink_gl import fft_sink_f, fft_sink_c
- except ImportError:
- if style == 'gl':
- raise RuntimeError("Unable to import OpenGL. Are Python wrappers for OpenGL installed?")
- else:
- # Fall backto non-gl sinks
- from fftsink_nongl import fft_sink_f, fft_sink_c
-elif style == 'nongl':
- from fftsink_nongl import fft_sink_f, fft_sink_c
-else:
- raise RuntimeError("Unknown wxgui style")
diff --git a/gr-wxgui/python/wxgui/fftsink_gl.py b/gr-wxgui/python/wxgui/fftsink_gl.py
deleted file mode 100644
index a0b245c98a..0000000000
--- a/gr-wxgui/python/wxgui/fftsink_gl.py
+++ /dev/null
@@ -1,204 +0,0 @@
-#
-# Copyright 2008-2010,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from __future__ import division
-
-##################################################
-# Imports
-##################################################
-import fft_window
-import common
-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
-
-##################################################
-# FFT sink block (wrapper for old wxgui)
-##################################################
-class _fft_sink_base(gr.hier_block2, common.wxgui_hb):
- """
- An fft block with real/complex inputs and a gui window.
- """
-
- 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=fft_window.DEFAULT_FRAME_RATE,
- average=False,
- avg_alpha=None,
- title='',
- size=fft_window.DEFAULT_WIN_SIZE,
- peak_hold=False,
- win=None,
- use_persistence=False,
- persist_alpha=None,
- **kwargs #do not end with a comma
- ):
- #ensure avg alpha
- if avg_alpha is None: avg_alpha = 2.0/fft_rate
- #ensure analog alpha
- if persist_alpha is None:
- actual_fft_rate=float(sample_rate/fft_size)/float(max(1,int(float((sample_rate/fft_size)/fft_rate))))
- #print "requested_fft_rate ",fft_rate
- #print "actual_fft_rate ",actual_fft_rate
- analog_cutoff_freq=0.5 # Hertz
- #calculate alpha from wanted cutoff freq
- persist_alpha = 1.0 - math.exp(-2.0*math.pi*analog_cutoff_freq/actual_fft_rate)
-
- #init
- gr.hier_block2.__init__(
- self,
- "fft_sink",
- gr.io_signature(1, 1, self._item_size),
- gr.io_signature(0, 0, 0),
- )
- #blocks
- fft = self._fft_chain(
- sample_rate=sample_rate,
- fft_size=fft_size,
- frame_rate=fft_rate,
- ref_scale=ref_scale,
- avg_alpha=avg_alpha,
- average=average,
- win=win,
- )
- msgq = gr.msg_queue(2)
- sink = blocks.message_sink(gr.sizeof_float*fft_size, msgq, True)
-
-
- #controller
- self.controller = pubsub()
- self.controller.subscribe(AVERAGE_KEY, fft.set_average)
- self.controller.publish(AVERAGE_KEY, fft.average)
- self.controller.subscribe(AVG_ALPHA_KEY, fft.set_avg_alpha)
- self.controller.publish(AVG_ALPHA_KEY, fft.avg_alpha)
- self.controller.subscribe(SAMPLE_RATE_KEY, fft.set_sample_rate)
- self.controller.publish(SAMPLE_RATE_KEY, fft.sample_rate)
- #start input watcher
- common.input_watcher(msgq, self.controller, MSG_KEY)
- #create window
- self.win = fft_window.fft_window(
- parent=parent,
- controller=self.controller,
- size=size,
- title=title,
- real=self._real,
- fft_size=fft_size,
- baseband_freq=baseband_freq,
- sample_rate_key=SAMPLE_RATE_KEY,
- y_per_div=y_per_div,
- y_divs=y_divs,
- ref_level=ref_level,
- average_key=AVERAGE_KEY,
- avg_alpha_key=AVG_ALPHA_KEY,
- peak_hold=peak_hold,
- msg_key=MSG_KEY,
- use_persistence=use_persistence,
- persist_alpha=persist_alpha,
- )
- common.register_access_methods(self, self.win)
- setattr(self.win, 'set_baseband_freq', getattr(self, 'set_baseband_freq')) #BACKWARDS
- setattr(self.win, 'set_peak_hold', getattr(self, 'set_peak_hold')) #BACKWARDS
- #connect
- self.wxgui_connect(self, fft, sink)
-
- def set_callback(self,callb):
- self.win.set_callback(callb)
-
-class fft_sink_f(_fft_sink_base):
- _fft_chain = logpwrfft.logpwrfft_f
- _item_size = gr.sizeof_float
- _real = True
-
-class fft_sink_c(_fft_sink_base):
- _fft_chain = logpwrfft.logpwrfft_c
- _item_size = gr.sizeof_gr_complex
- _real = False
-
-# ----------------------------------------------------------------
-# Standalone test app
-# ----------------------------------------------------------------
-
-import wx
-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)
-
- fft_size = 256
-
- # build our flow graph
- input_rate = 2048.0e3
-
- #Generate some noise
- noise = analog.noise_source_c(analog.GR_UNIFORM, 1.0/10)
-
- # Generate a complex sinusoid
- #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 = 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)
-
- combine1 = blocks.add_cc()
- self.connect(src1, (combine1,0))
- self.connect(noise,(combine1,1))
- self.connect(combine1,thr1, sink1)
-
- #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 = 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()
-
-if __name__ == '__main__':
- main()
diff --git a/gr-wxgui/python/wxgui/fftsink_nongl.py b/gr-wxgui/python/wxgui/fftsink_nongl.py
deleted file mode 100644
index c63f0fb268..0000000000
--- a/gr-wxgui/python/wxgui/fftsink_nongl.py
+++ /dev/null
@@ -1,656 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2003-2007,2009,2010,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, gru, fft
-import gnuradio.filter as grfilter
-from gnuradio import blocks
-from gnuradio import analog
-from gnuradio.wxgui import stdgui2
-from gnuradio.filter import window
-import wx
-import plot
-import numpy
-import math
-
-DIV_LEVELS = (1, 2, 5, 10, 20)
-
-default_fftsink_size = (640,240)
-default_fft_rate = gr.prefs().get_long('wxgui', 'fft_rate', 15)
-
-class fft_sink_base(object):
- def __init__(self, input_is_real=False, baseband_freq=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='',
- peak_hold=False, use_persistence=False, persist_alpha=0.2):
-
- # initialize common attributes
- self.baseband_freq = baseband_freq
- self.y_per_div=y_per_div
- self.y_divs = y_divs
- self.ref_level = ref_level
- self.sample_rate = sample_rate
- self.fft_size = fft_size
- self.fft_rate = fft_rate
- self.average = average
- if avg_alpha is None:
- self.avg_alpha = 2.0 / fft_rate
- else:
- self.avg_alpha = avg_alpha
- self.use_persistence = use_persistence
- self.persist_alpha = persist_alpha
-
- self.title = title
- self.peak_hold = peak_hold
- self.input_is_real = input_is_real
- self.msgq = gr.msg_queue(2) # queue that holds a maximum of 2 messages
-
- def set_y_per_div(self, y_per_div):
- self.y_per_div = y_per_div
-
- def set_ref_level(self, ref_level):
- self.ref_level = ref_level
-
- def set_average(self, average):
- self.average = average
- if average:
- self.avg.set_taps(self.avg_alpha)
- else:
- self.avg.set_taps(1.0)
- self.win.peak_vals = None
-
- def set_peak_hold(self, enable):
- self.peak_hold = enable
- self.win.set_peak_hold(enable)
-
- def set_use_persistence(self, enable):
- self.use_persistence = enable
- self.win.set_use_persistence(enable)
-
- def set_persist_alpha(self, persist_alpha):
- self.persist_alpha = persist_alpha
- self.win.set_persist_alpha(persist_alpha)
-
- def set_avg_alpha(self, avg_alpha):
- self.avg_alpha = avg_alpha
-
- def set_baseband_freq(self, baseband_freq):
- self.baseband_freq = baseband_freq
-
- def set_sample_rate(self, sample_rate):
- self.sample_rate = sample_rate
- self._set_n()
-
- 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):
-
- gr.hier_block2.__init__(self, "fft_sink_f",
- gr.io_signature(1, 1, gr.sizeof_float),
- gr.io_signature(0,0,0))
-
- fft_sink_base.__init__(self, input_is_real=True, baseband_freq=baseband_freq,
- y_per_div=y_per_div, y_divs=y_divs, ref_level=ref_level,
- 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)
-
- 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 = fft.fft_vfc(self.fft_size, True, mywindow)
- power = 0
- for tap in mywindow:
- power += tap*tap
-
- self.c2magsq = blocks.complex_to_mag_squared(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(10, self.fft_size,
- -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.c2magsq, self.avg, self.log, self.sink)
-
- self.win = fft_window(self, parent, size=size)
- self.set_average(self.average)
- self.set_peak_hold(self.peak_hold)
- self.set_use_persistence(self.use_persistence)
- self.set_persist_alpha(self.persist_alpha)
-
-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):
-
- gr.hier_block2.__init__(self, "fft_sink_c",
- gr.io_signature(1, 1, gr.sizeof_gr_complex),
- gr.io_signature(0,0,0))
-
- fft_sink_base.__init__(self, input_is_real=False, baseband_freq=baseband_freq,
- y_per_div=y_per_div, y_divs=y_divs, ref_level=ref_level,
- 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)
-
- 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 = fft.fft_vcc(self.fft_size, True, mywindow)
- power = 0
- for tap in mywindow:
- power += tap*tap
-
- self.c2magsq = blocks.complex_to_mag_squared(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(10, self.fft_size,
- -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.c2magsq, self.avg, self.log, self.sink)
-
- self.win = fft_window(self, parent, size=size)
- self.set_average(self.average)
- self.set_use_persistence(self.use_persistence)
- self.set_persist_alpha(self.persist_alpha)
- self.set_peak_hold(self.peak_hold)
-
-
-# ------------------------------------------------------------------------
-
-myDATA_EVENT = wx.NewEventType()
-EVT_DATA_EVENT = wx.PyEventBinder (myDATA_EVENT, 0)
-
-
-class DataEvent(wx.PyEvent):
- def __init__(self, data):
- wx.PyEvent.__init__(self)
- self.SetEventType (myDATA_EVENT)
- self.data = data
-
- def Clone (self):
- self.__class__ (self.GetId())
-
-
-class input_watcher (gru.msgq_runner):
- def __init__ (self, msgq, fft_size, event_receiver, **kwds):
- self.fft_size = fft_size
- self.event_receiver = event_receiver
- gru.msgq_runner.__init__(self, msgq, self.handle_msg)
-
- def handle_msg(self, msg):
- itemsize = int(msg.arg1())
- nitems = int(msg.arg2())
-
- s = msg.to_string() # get the body of the msg as a string
-
- # There may be more than one FFT frame in the message.
- # If so, we take only the last one
- if nitems > 1:
- start = itemsize * (nitems - 1)
- s = s[start:start+itemsize]
-
- complex_data = numpy.fromstring (s, numpy.float32)
- de = DataEvent (complex_data)
- wx.PostEvent (self.event_receiver, de)
- del de
-
-class control_panel(wx.Panel):
-
- class LabelText(wx.StaticText):
- def __init__(self, window, label):
- wx.StaticText.__init__(self, window, -1, label)
- font = self.GetFont()
- font.SetWeight(wx.FONTWEIGHT_BOLD)
- font.SetUnderlined(True)
- self.SetFont(font)
-
- def __init__(self, parent):
- self.parent = parent
- wx.Panel.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
- control_box = wx.BoxSizer(wx.VERTICAL)
-
- #checkboxes for average and peak hold
- control_box.AddStretchSpacer()
- control_box.Add(self.LabelText(self, 'Options'), 0, wx.ALIGN_CENTER)
- self.average_check_box = wx.CheckBox(parent=self, style=wx.CHK_2STATE, label="Average")
- self.average_check_box.Bind(wx.EVT_CHECKBOX, parent.on_average)
- control_box.Add(self.average_check_box, 0, wx.EXPAND)
- self.use_persistence_check_box = wx.CheckBox(parent=self, style=wx.CHK_2STATE, label="Persistence")
- self.use_persistence_check_box.Bind(wx.EVT_CHECKBOX, parent.on_use_persistence)
- control_box.Add(self.use_persistence_check_box, 0, wx.EXPAND)
- self.peak_hold_check_box = wx.CheckBox(parent=self, style=wx.CHK_2STATE, label="Peak Hold")
- self.peak_hold_check_box.Bind(wx.EVT_CHECKBOX, parent.on_peak_hold)
- control_box.Add(self.peak_hold_check_box, 0, wx.EXPAND)
-
- #radio buttons for div size
- control_box.AddStretchSpacer()
- control_box.Add(self.LabelText(self, 'Set dB/div'), 0, wx.ALIGN_CENTER)
- radio_box = wx.BoxSizer(wx.VERTICAL)
- self.radio_buttons = list()
- for y_per_div in DIV_LEVELS:
- radio_button = wx.RadioButton(self, -1, "%d dB/div"%y_per_div)
- radio_button.Bind(wx.EVT_RADIOBUTTON, self.on_radio_button_change)
- self.radio_buttons.append(radio_button)
- radio_box.Add(radio_button, 0, wx.ALIGN_LEFT)
- control_box.Add(radio_box, 0, wx.EXPAND)
-
- #ref lvl buttons
- control_box.AddStretchSpacer()
- control_box.Add(self.LabelText(self, 'Adj Ref Lvl'), 0, wx.ALIGN_CENTER)
- control_box.AddSpacer(2)
- button_box = wx.BoxSizer(wx.HORIZONTAL)
- self.ref_plus_button = wx.Button(self, -1, '+', style=wx.BU_EXACTFIT)
- self.ref_plus_button.Bind(wx.EVT_BUTTON, parent.on_incr_ref_level)
- button_box.Add(self.ref_plus_button, 0, wx.ALIGN_CENTER)
- self.ref_minus_button = wx.Button(self, -1, ' - ', style=wx.BU_EXACTFIT)
- self.ref_minus_button.Bind(wx.EVT_BUTTON, parent.on_decr_ref_level)
- button_box.Add(self.ref_minus_button, 0, wx.ALIGN_CENTER)
- control_box.Add(button_box, 0, wx.ALIGN_CENTER)
- control_box.AddStretchSpacer()
- #set sizer
- self.SetSizerAndFit(control_box)
- #update
- self.update()
-
- def update(self):
- """
- Read the state of the fft plot settings and update the control panel.
- """
- #update checkboxes
- self.average_check_box.SetValue(self.parent.fftsink.average)
- self.use_persistence_check_box.SetValue(self.parent.fftsink.use_persistence)
- self.peak_hold_check_box.SetValue(self.parent.fftsink.peak_hold)
- #update radio buttons
- try:
- index = list(DIV_LEVELS).index(self.parent.fftsink.y_per_div)
- self.radio_buttons[index].SetValue(True)
- except: pass
-
- def on_radio_button_change(self, evt):
- selected_radio_button = filter(lambda rb: rb.GetValue(), self.radio_buttons)[0]
- index = self.radio_buttons.index(selected_radio_button)
- self.parent.fftsink.set_y_per_div(DIV_LEVELS[index])
-
-class fft_window (wx.Panel):
- def __init__ (self, fftsink, parent, id = -1,
- pos = wx.DefaultPosition, size = wx.DefaultSize,
- style = wx.DEFAULT_FRAME_STYLE, name = ""):
-
- self.fftsink = fftsink
- #init panel and plot
- wx.Panel.__init__(self, parent, -1)
- self.plot = plot.PlotCanvas(self, id, pos, size, style, name)
- #setup the box with plot and controls
- self.control_panel = control_panel(self)
- main_box = wx.BoxSizer (wx.HORIZONTAL)
- main_box.Add (self.plot, 1, wx.EXPAND)
- main_box.Add (self.control_panel, 0, wx.EXPAND)
- self.SetSizerAndFit(main_box)
-
- self.peak_hold = False
- self.peak_vals = None
-
- self.use_persistence=False
- self.persist_alpha=0.2
-
-
- self.plot.SetEnableGrid (True)
- # self.SetEnableZoom (True)
- # self.SetBackgroundColour ('black')
-
- self.build_popup_menu()
- self.set_baseband_freq(self.fftsink.baseband_freq)
-
- EVT_DATA_EVENT (self, self.set_data)
- wx.EVT_CLOSE (self, self.on_close_window)
- self.plot.Bind(wx.EVT_RIGHT_UP, self.on_right_click)
- self.plot.Bind(wx.EVT_MOTION, self.evt_motion)
-
- self.input_watcher = input_watcher(fftsink.msgq, fftsink.fft_size, self)
-
- def set_scale(self, freq):
- x = max(abs(self.fftsink.sample_rate), abs(self.fftsink.baseband_freq))
- if x >= 1e9:
- self._scale_factor = 1e-9
- self._units = "GHz"
- self._format = "%3.6f"
- elif x >= 1e6:
- self._scale_factor = 1e-6
- self._units = "MHz"
- self._format = "%3.3f"
- else:
- self._scale_factor = 1e-3
- self._units = "kHz"
- self._format = "%3.3f"
-
- def set_baseband_freq(self, baseband_freq):
- if self.peak_hold:
- self.peak_vals = None
- self.set_scale(baseband_freq)
- self.fftsink.set_baseband_freq(baseband_freq)
-
- def on_close_window (self, event):
- print "fft_window:on_close_window"
- self.keep_running = False
-
-
- def set_data (self, evt):
- dB = evt.data
- L = len (dB)
-
- if self.peak_hold:
- if self.peak_vals is None:
- self.peak_vals = dB
- else:
- self.peak_vals = numpy.maximum(dB, self.peak_vals)
-
- if self.fftsink.input_is_real: # only plot 1/2 the points
- x_vals = ((numpy.arange (L/2) * (self.fftsink.sample_rate
- * self._scale_factor / L))
- + self.fftsink.baseband_freq * self._scale_factor)
- self._points = numpy.zeros((len(x_vals), 2), numpy.float64)
- self._points[:,0] = x_vals
- self._points[:,1] = dB[0:L/2]
- if self.peak_hold:
- self._peak_points = numpy.zeros((len(x_vals), 2), numpy.float64)
- self._peak_points[:,0] = x_vals
- self._peak_points[:,1] = self.peak_vals[0:L/2]
- else:
- # the "negative freqs" are in the second half of the array
- x_vals = ((numpy.arange (-L/2, L/2)
- * (self.fftsink.sample_rate * self._scale_factor / L))
- + self.fftsink.baseband_freq * self._scale_factor)
- self._points = numpy.zeros((len(x_vals), 2), numpy.float64)
- self._points[:,0] = x_vals
- self._points[:,1] = numpy.concatenate ((dB[L/2:], dB[0:L/2]))
- if self.peak_hold:
- self._peak_points = numpy.zeros((len(x_vals), 2), numpy.float64)
- self._peak_points[:,0] = x_vals
- self._peak_points[:,1] = numpy.concatenate ((self.peak_vals[L/2:], self.peak_vals[0:L/2]))
-
- lines = [plot.PolyLine (self._points, colour='BLUE'),]
- if self.peak_hold:
- lines.append(plot.PolyLine (self._peak_points, colour='GREEN'))
-
- graphics = plot.PlotGraphics (lines,
- title=self.fftsink.title,
- xLabel = self._units, yLabel = "dB")
- x_range = x_vals[0], x_vals[-1]
- ymax = self.fftsink.ref_level
- ymin = self.fftsink.ref_level - self.fftsink.y_per_div * self.fftsink.y_divs
- y_range = ymin, ymax
- self.plot.Draw (graphics, xAxis=x_range, yAxis=y_range, step=self.fftsink.y_per_div)
-
- def set_use_persistence(self, enable):
- self.use_persistence = enable
- self.plot.set_use_persistence( enable)
-
- def set_persist_alpha(self, persist_alpha):
- self.persist_alpha = persist_alpha
- self.plot.set_persist_alpha(persist_alpha)
-
- def set_peak_hold(self, enable):
- self.peak_hold = enable
- self.peak_vals = None
-
- def on_average(self, evt):
- # print "on_average"
- self.fftsink.set_average(evt.IsChecked())
- self.control_panel.update()
-
- def on_use_persistence(self, evt):
- # print "on_analog"
- self.fftsink.set_use_persistence(evt.IsChecked())
- self.control_panel.update()
-
- def on_peak_hold(self, evt):
- # print "on_peak_hold"
- self.fftsink.set_peak_hold(evt.IsChecked())
- self.control_panel.update()
-
- def on_incr_ref_level(self, evt):
- # print "on_incr_ref_level"
- self.fftsink.set_ref_level(self.fftsink.ref_level
- + self.fftsink.y_per_div)
-
- def on_decr_ref_level(self, evt):
- # print "on_decr_ref_level"
- self.fftsink.set_ref_level(self.fftsink.ref_level
- - self.fftsink.y_per_div)
-
- def on_incr_y_per_div(self, evt):
- # print "on_incr_y_per_div"
- self.fftsink.set_y_per_div(next_up(self.fftsink.y_per_div, DIV_LEVELS))
- self.control_panel.update()
-
- def on_decr_y_per_div(self, evt):
- # print "on_decr_y_per_div"
- self.fftsink.set_y_per_div(next_down(self.fftsink.y_per_div, DIV_LEVELS))
- self.control_panel.update()
-
- def on_y_per_div(self, evt):
- # print "on_y_per_div"
- Id = evt.GetId()
- if Id == self.id_y_per_div_1:
- self.fftsink.set_y_per_div(1)
- elif Id == self.id_y_per_div_2:
- self.fftsink.set_y_per_div(2)
- elif Id == self.id_y_per_div_5:
- self.fftsink.set_y_per_div(5)
- elif Id == self.id_y_per_div_10:
- self.fftsink.set_y_per_div(10)
- elif Id == self.id_y_per_div_20:
- self.fftsink.set_y_per_div(20)
- self.control_panel.update()
-
- def on_right_click(self, event):
- menu = self.popup_menu
- for id, pred in self.checkmarks.items():
- item = menu.FindItemById(id)
- item.Check(pred())
- self.plot.PopupMenu(menu, event.GetPosition())
-
- def evt_motion(self, event):
- if not hasattr(self, "_points"):
- return # Got here before first window data update
-
- # Clip to plotted values
- (ux, uy) = self.plot.GetXY(event) # Scaled position
- x_vals = numpy.array(self._points[:,0])
- if ux < x_vals[0] or ux > x_vals[-1]:
- tip = self.GetToolTip()
- if tip:
- tip.Enable(False)
- return
-
- # Get nearest X value (is there a better way)?
- ind = numpy.argmin(numpy.abs(x_vals-ux))
- x_val = x_vals[ind]
- db_val = self._points[ind, 1]
- text = (self._format+" %s dB=%3.3f") % (x_val, self._units, db_val)
-
- # Display the tooltip
- tip = wx.ToolTip(text)
- tip.Enable(True)
- tip.SetDelay(0)
- self.SetToolTip(tip)
-
- def build_popup_menu(self):
- self.id_incr_ref_level = wx.NewId()
- self.id_decr_ref_level = wx.NewId()
- self.id_incr_y_per_div = wx.NewId()
- self.id_decr_y_per_div = wx.NewId()
- self.id_y_per_div_1 = wx.NewId()
- self.id_y_per_div_2 = wx.NewId()
- self.id_y_per_div_5 = wx.NewId()
- self.id_y_per_div_10 = wx.NewId()
- self.id_y_per_div_20 = wx.NewId()
- self.id_average = wx.NewId()
- self.id_use_persistence = wx.NewId()
- self.id_peak_hold = wx.NewId()
-
- self.plot.Bind(wx.EVT_MENU, self.on_average, id=self.id_average)
- self.plot.Bind(wx.EVT_MENU, self.on_use_persistence, id=self.id_use_persistence)
- self.plot.Bind(wx.EVT_MENU, self.on_peak_hold, id=self.id_peak_hold)
- self.plot.Bind(wx.EVT_MENU, self.on_incr_ref_level, id=self.id_incr_ref_level)
- self.plot.Bind(wx.EVT_MENU, self.on_decr_ref_level, id=self.id_decr_ref_level)
- self.plot.Bind(wx.EVT_MENU, self.on_incr_y_per_div, id=self.id_incr_y_per_div)
- self.plot.Bind(wx.EVT_MENU, self.on_decr_y_per_div, id=self.id_decr_y_per_div)
- self.plot.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_1)
- self.plot.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_2)
- self.plot.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_5)
- self.plot.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_10)
- self.plot.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_20)
-
- # make a menu
- menu = wx.Menu()
- self.popup_menu = menu
- menu.AppendCheckItem(self.id_average, "Average")
- menu.AppendCheckItem(self.id_use_persistence, "Persistence")
- menu.AppendCheckItem(self.id_peak_hold, "Peak Hold")
- menu.Append(self.id_incr_ref_level, "Incr Ref Level")
- menu.Append(self.id_decr_ref_level, "Decr Ref Level")
- # menu.Append(self.id_incr_y_per_div, "Incr dB/div")
- # menu.Append(self.id_decr_y_per_div, "Decr dB/div")
- menu.AppendSeparator()
- # we'd use RadioItems for these, but they're not supported on Mac
- menu.AppendCheckItem(self.id_y_per_div_1, "1 dB/div")
- menu.AppendCheckItem(self.id_y_per_div_2, "2 dB/div")
- menu.AppendCheckItem(self.id_y_per_div_5, "5 dB/div")
- menu.AppendCheckItem(self.id_y_per_div_10, "10 dB/div")
- menu.AppendCheckItem(self.id_y_per_div_20, "20 dB/div")
-
- self.checkmarks = {
- self.id_average : lambda : self.fftsink.average,
- self.id_use_persistence : lambda : self.fftsink.use_persistence,
- self.id_peak_hold : lambda : self.fftsink.peak_hold,
- self.id_y_per_div_1 : lambda : self.fftsink.y_per_div == 1,
- self.id_y_per_div_2 : lambda : self.fftsink.y_per_div == 2,
- self.id_y_per_div_5 : lambda : self.fftsink.y_per_div == 5,
- self.id_y_per_div_10 : lambda : self.fftsink.y_per_div == 10,
- self.id_y_per_div_20 : lambda : self.fftsink.y_per_div == 20,
- }
-
-
-def next_up(v, seq):
- """
- Return the first item in seq that is > v.
- """
- for s in seq:
- if s > v:
- return s
- return v
-
-def next_down(v, seq):
- """
- Return the last item in seq that is < v.
- """
- rseq = list(seq[:])
- rseq.reverse()
-
- for s in rseq:
- if s < v:
- return s
- return v
-
-
-# ----------------------------------------------------------------
-# Standalone test app
-# ----------------------------------------------------------------
-
-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)
-
- fft_size = 256
-
- # build our flow graph
- 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)
- 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.
- 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)
-
- self.connect(src1, (add1,0))
- self.connect(noise1, (add1,1))
- self.connect(add1, 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)
- 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, (add2,0))
- self.connect(noise2, (add2,1))
- self.connect(add2, thr2, sink2)
-
-def main ():
- app = stdgui2.stdapp(test_app_block, "FFT Sink Test App")
- app.MainLoop()
-
-if __name__ == '__main__':
- main ()
diff --git a/gr-wxgui/python/wxgui/form.py b/gr-wxgui/python/wxgui/form.py
deleted file mode 100644
index 0442e49c84..0000000000
--- a/gr-wxgui/python/wxgui/form.py
+++ /dev/null
@@ -1,391 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import wx
-from gnuradio import eng_notation
-
-# ----------------------------------------------------------------
-# Wrappers for certain widgets
-# ----------------------------------------------------------------
-
-def button_with_callback(parent, label, callback):
- new_id = wx.NewId()
- btn = wx.Button(parent, new_id, label)
- wx.EVT_BUTTON(parent, new_id, lambda evt: callback())
- return btn
-
-
-# ----------------------------------------------------------------
-# Format converters
-# ----------------------------------------------------------------
-
-class abstract_converter(object):
- def value_to_prim(self, v):
- """
- Convert from user specified value to value acceptable to underlying primitive.
- The underlying primitive usually expects strings.
- """
- raise NotImplementedError
- def prim_to_value(self, s):
- """
- Convert from underlying primitive value to user specified value.
- The underlying primitive usually expects strings.
- """
- raise NotImplementedError
- def help(self):
- return "Any string is acceptable"
-
-class identity_converter(abstract_converter):
- def value_to_prim(self,v):
- return v
- def prim_to_value(self, s):
- return s
-
-class int_converter(abstract_converter):
- def value_to_prim(self, v):
- return str(v)
- def prim_to_value(self, s):
- return int(s, 0)
- def help(self):
- return "Enter an integer. Leading 0x indicates hex"
-
-class float_converter(abstract_converter):
- def value_to_prim(self, v):
- return eng_notation.num_to_str(v)
- def prim_to_value(self, s):
- return eng_notation.str_to_num(s)
- def help(self):
- return "Enter a float with optional scale suffix. E.g., 100.1M"
-
-
-# ----------------------------------------------------------------
-# Various types of data entry fields
-# ----------------------------------------------------------------
-
-class field(object):
- """
- A field in a form.
- """
- def __init__(self, converter, value):
- self.converter = converter
- if value is not None:
- self.set_value(value)
-
- def set_value(self, v):
- self._set_prim_value(self.converter.value_to_prim(v))
-
- def get_value(self):
- return self.converter.prim_to_value(self._get_prim_value())
-
- def get_value_with_check(self):
- """
- Returns (value, error_msg), where error_msg is not None if there was problem
- """
- try:
- return (self.get_value(), None)
- except:
- return (None, self._error_msg())
-
- def _set_prim_value(self, v):
- raise NotImplementedError
-
- def _get_prim_value(self):
- raise NotImplementedError
-
- def _pair_with_label(self, widget, parent=None, sizer=None, label=None, weight=1):
- self.label = label
- if label is None:
- sizer.Add (widget, weight, wx.EXPAND)
- return widget
- elif 0:
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- label_widget = wx.StaticText(parent, -1, label + ': ')
- hbox.Add(label_widget, 0, wx.EXPAND)
- hbox.Add(widget, 1, wx.EXPAND)
- sizer.Add(hbox, weight, wx.EXPAND)
- return widget
- else:
- label_widget = wx.StaticText(parent, -1, label + ': ')
- sizer.Add(label_widget, 0, wx.EXPAND)
- sizer.Add(widget, weight, wx.EXPAND)
- return widget
-
- def _error_msg(self):
- prefix = ''
- if self.label:
- prefix = self.label + ': '
- return "%s%s is invalid. %s" % (prefix, self._get_prim_value(),
- self.converter.help())
-
-# static (display-only) text fields
-
-class static_text_field(field):
- def __init__(self, parent=None, sizer=None, label=None, value=None,
- converter=identity_converter(), weight=0):
- self.f = self._pair_with_label(wx.StaticText(parent, -1, ""),
- parent=parent, sizer=sizer, label=label, weight=weight)
- field.__init__(self, converter, value)
-
- def _get_prim_value(self):
- return self.f.GetLabel()
-
- def _set_prim_value(self, v):
- self.f.SetLabel(v)
-
-
-class static_int_field(static_text_field):
- def __init__(self, parent=None, sizer=None, label=None, value=None, weight=0):
- static_text_field.__init__(self, parent, sizer, label, value, int_converter(), weight)
-
-class static_float_field(static_text_field):
- def __init__(self, parent=None, sizer=None, label=None, value=None, weight=0):
- static_text_field.__init__(self, parent, sizer, label, value, float_converter(), weight)
-
-
-# editable text fields
-
-class text_field(field):
- def __init__(self, parent=None, sizer=None, label=None, value=None,
- converter=identity_converter(), callback=None, weight=1):
- style = 0
- if callback:
- style = wx.TE_PROCESS_ENTER
-
- new_id = wx.NewId()
- w = wx.TextCtrl(parent, new_id, "", style=style)
- self.f = self._pair_with_label(w, parent=parent, sizer=sizer, label=label, weight=weight)
- if callback:
- wx.EVT_TEXT_ENTER(w, new_id, lambda evt: callback())
- field.__init__(self, converter, value)
-
- def _get_prim_value(self):
- return self.f.GetValue()
-
- def _set_prim_value(self, v):
- self.f.SetValue(v)
-
-
-class int_field(text_field):
- def __init__(self, parent=None, sizer=None, label=None, value=None,
- callback=None, weight=1):
- text_field.__init__(self, parent, sizer, label, value, int_converter(), callback, weight)
-
-class float_field(text_field):
- def __init__(self, parent=None, sizer=None, label=None, value=None,
- callback=None, weight=1):
- text_field.__init__(self, parent, sizer, label, value, float_converter(), callback, weight)
-
-# other fields
-
-class slider_field(field):
- def __init__(self, parent=None, sizer=None, label=None, value=None,
- converter=identity_converter(), callback=None, min=0, max=100, weight=1):
- new_id = wx.NewId()
- w = wx.Slider(parent, new_id, (max+min)/2, min, max,
- size=wx.Size(250, -1), style=wx.SL_HORIZONTAL | wx.SL_LABELS)
- self.f = self._pair_with_label(w, parent=parent, sizer=sizer, label=label, weight=weight)
- if callback:
- wx.EVT_COMMAND_SCROLL(w, new_id, lambda evt: callback(evt.GetInt()))
- field.__init__(self, converter, value)
-
- def _get_prim_value(self):
- return self.f.GetValue()
-
- def _set_prim_value(self, v):
- self.f.SetValue(int(v))
-
-class quantized_slider_field(field):
- def __init__(self, parent=None, sizer=None, label=None, value=None,
- converter=identity_converter(), callback=None, range=None, weight=1):
- if not isinstance(range, (tuple, list)) or len(range) != 3:
- raise ValueError, range
-
- self.min = range[0]
- self.max = range[1]
- self.step_size = float(range[2])
- nsteps = int((self.max-self.min)/self.step_size)
-
- new_id = wx.NewId()
- w = wx.Slider(parent, new_id, 0, 0, nsteps,
- size=wx.Size(250, -1), style=wx.SL_HORIZONTAL)
- self.f = self._pair_with_label(w, parent=parent, sizer=sizer, label=label, weight=weight)
- if callback:
- wx.EVT_COMMAND_SCROLL(w, new_id,
- lambda evt: callback(self._map_out(evt.GetInt())))
- field.__init__(self, converter, value)
-
- def _get_prim_value(self):
- return self._map_out(self.f.GetValue())
-
- def _set_prim_value(self, v):
- self.f.SetValue(self._map_in(v))
-
- def _map_in(self, x):
- return int((x-self.min) / self.step_size)
-
- def _map_out(self, x):
- return x * self.step_size + self.min
-
-class checkbox_field(field):
- def __init__(self, parent=None, sizer=None, label=None, value=None,
- converter=identity_converter(), callback=None, weight=1):
- new_id = wx.NewId()
- w = wx.CheckBox(parent, new_id, label, style=wx.CHK_2STATE)
- self.f = self._pair_with_label(w, parent=parent, sizer=sizer, label=None, weight=weight)
- if callback:
- wx.EVT_CHECKBOX(w, new_id, lambda evt: callback(evt.GetInt()))
- field.__init__(self, converter, value)
-
- def _get_prim_value(self):
- return self.f.GetValue()
-
- def _set_prim_value(self, v):
- self.f.SetValue(int(v))
-
-
-class radiobox_field(field):
- def __init__(self, parent=None, sizer=None, label=None, value=None,
- converter=identity_converter(), callback=None, weight=1,
- choices=None, major_dimension=1, specify_rows=False):
- new_id = wx.NewId()
-
- if specify_rows:
- style=wx.RA_SPECIFY_ROWS | wx.RA_HORIZONTAL
- else:
- style=wx.RA_SPECIFY_COLS | wx.RA_HORIZONTAL
-
- w = wx.RadioBox(parent, new_id, label=label, style=style, majorDimension=major_dimension,
- choices=choices)
- self.f = self._pair_with_label(w, parent=parent, sizer=sizer, label=None, weight=weight)
- if callback:
- wx.EVT_RADIOBOX(w, new_id, lambda evt: callback(evt.GetString()))
- field.__init__(self, converter, value)
-
- def _get_prim_value(self):
- return self.f.GetStringSelection()
-
- def _set_prim_value(self, v):
- self.f.SetStringSelection(str(v))
-
-# ----------------------------------------------------------------
-# the form class
-# ----------------------------------------------------------------
-
-class form(dict):
- def __init__(self):
- dict.__init__(self)
-
- def check_input_for_errors(self):
- """
- Returns list of error messages if there's trouble,
- else empty list.
- """
- vals = [f.get_value_with_check() for f in self.values()]
- return [t[1] for t in vals if t[1] is not None]
-
- def get_key_vals(self):
- d = {}
- for (key, f) in self.items():
- d[key] = f.get_value()
- return d
-
-
- def _nop(*args): pass
-
- def check_input_and_call(self, callback, status_handler=_nop):
- """
- Return a function that checks the form for errors, and then if it's OK,
- invokes the user specified callback, passing it the form key/value dictionary.
- status_handler is called with a string indicating results.
- """
- def doit_callback(*ignore):
- errors = self.check_input_for_errors()
- if errors:
- status_handler(errors[0])
- #print '\n'.join(tuple(errors))
- else:
- kv = self.get_key_vals()
- if callback(kv):
- status_handler("OK")
- else:
- status_handler("Failed")
-
- return doit_callback
-
-
-
-# ----------------------------------------------------------------
-# Stand-alone example code
-# ----------------------------------------------------------------
-
-import sys
-from gnuradio.wxgui import stdgui2
-
-class demo_app_flow_graph (stdgui2.std_top_block):
- def __init__(self, frame, panel, vbox, argv):
- stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)
-
- self.frame = frame
- self.panel = panel
-
- def _print_kv(kv):
- print "kv =", kv
- return True
-
- self.form = form()
-
- self.form['static1'] = \
- static_text_field(parent=panel, sizer=vbox,
- label="Static Text",
- value="The Static Value")
-
- self.form['text1'] = \
- text_field(parent=panel, sizer=vbox,
- label="TextCtrl",
- value="The Editable Value")
-
- self.form['int1'] = \
- int_field(parent=panel, sizer=vbox,
- label="Int Field",
- value=1234)
-
- self.form['float1'] = \
- float_field(parent=panel, sizer=vbox,
- label="Float Field",
- value=3.14159)
-
- self.doit = button_with_callback(
- panel, "Do It!",
- self.form.check_input_and_call(_print_kv, self._set_status_msg))
-
- vbox.Add(self.doit, 0, wx.CENTER)
-
- def _set_status_msg(self, msg):
- self.frame.GetStatusBar().SetStatusText(msg, 0)
-
-
-def main ():
- app = stdgui2.stdapp(demo_app_flow_graph, "wxgui form demo", nstatus=1)
- app.MainLoop ()
-
-if __name__ == '__main__':
- main ()
diff --git a/gr-wxgui/python/wxgui/forms/__init__.py b/gr-wxgui/python/wxgui/forms/__init__.py
deleted file mode 100644
index 058fa2ec28..0000000000
--- a/gr-wxgui/python/wxgui/forms/__init__.py
+++ /dev/null
@@ -1,102 +0,0 @@
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-"""
-The following classes will be available through gnuradio.wxgui.forms:
-"""
-
-########################################################################
-# External Converters
-########################################################################
-from converters import \
- eval_converter, str_converter, \
- float_converter, int_converter
-
-########################################################################
-# External Forms
-########################################################################
-from forms import \
- radio_buttons, drop_down, notebook, \
- button, toggle_button, single_button, \
- check_box, text_box, static_text, \
- slider, log_slider, gauge, \
- make_bold, DataEvent, EVT_DATA
-
-########################################################################
-# Helpful widgets
-########################################################################
-import wx
-
-class static_box_sizer(wx.StaticBoxSizer):
- """
- A box sizer with label and border.
-
- 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)
- if bold: make_bold(box)
- wx.StaticBoxSizer.__init__(self, box=box, orient=orient)
- if sizer: sizer.Add(self, proportion, flag)
-
-class incr_decr_buttons(wx.BoxSizer):
- """
- A horizontal box sizer with a increment and a decrement 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):
- wx.BoxSizer.__init__(self, wx.HORIZONTAL)
- buttons_box = wx.BoxSizer(wx.HORIZONTAL)
- self._incr_button = wx.Button(parent, label='+', style=wx.BU_EXACTFIT)
- self._incr_button.Bind(wx.EVT_BUTTON, on_incr)
- buttons_box.Add(self._incr_button, 0, wx.ALIGN_CENTER_VERTICAL)
- self._decr_button = wx.Button(parent, label=' - ', style=wx.BU_EXACTFIT)
- self._decr_button.Bind(wx.EVT_BUTTON, on_decr)
- buttons_box.Add(self._decr_button, 0, wx.ALIGN_CENTER_VERTICAL)
- if label: #add label
- self.Add(wx.StaticText(parent, label='%s: '%label), 1, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
- self.Add(buttons_box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
- else: self.Add(buttons_box, 0, wx.ALIGN_CENTER_VERTICAL)
- if sizer: sizer.Add(self, proportion, flag)
-
- def Disable(self, disable=True): self.Enable(not disable)
- def Enable(self, enable=True):
- if enable:
- self._incr_button.Enable()
- self._decr_button.Enable()
- else:
- self._incr_button.Disable()
- self._decr_button.Disable()
diff --git a/gr-wxgui/python/wxgui/forms/converters.py b/gr-wxgui/python/wxgui/forms/converters.py
deleted file mode 100644
index db14d2752c..0000000000
--- a/gr-wxgui/python/wxgui/forms/converters.py
+++ /dev/null
@@ -1,154 +0,0 @@
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import eng_notation
-import math
-
-class abstract_converter(object):
- def external_to_internal(self, v):
- """
- Convert from user specified value to value acceptable to underlying primitive.
- The underlying primitive usually expects strings.
- """
- raise NotImplementedError
- def internal_to_external(self, s):
- """
- Convert from underlying primitive value to user specified value.
- The underlying primitive usually expects strings.
- """
- raise NotImplementedError
- def help(self):
- return "Any string is acceptable"
-
-class identity_converter(abstract_converter):
- def external_to_internal(self,v):
- return v
- def internal_to_external(self, s):
- return s
-
-########################################################################
-# Commonly used converters
-########################################################################
-class chooser_converter(abstract_converter):
- """
- Convert between a set of possible choices and an index.
- Used in the chooser base and all sub-classes.
- """
- def __init__(self, choices):
- #choices must be a list because tuple does not have .index() in python2.5
- self._choices = list(choices)
- def external_to_internal(self, choice):
- return self._choices.index(choice)
- def internal_to_external(self, index):
- return self._choices[index]
- def help(self):
- return 'Enter a possible value in choices: "%s"'%str(self._choices)
-
-class bool_converter(abstract_converter):
- """
- The internal representation is boolean.
- The external representation is specified.
- Used in the check box form.
- """
- def __init__(self, true, false):
- self._true = true
- self._false = false
- def external_to_internal(self, v):
- if v == self._true: return True
- if v == self._false: return False
- raise Exception, 'Value "%s" is not a possible option.'%v
- def internal_to_external(self, v):
- if v: return self._true
- else: return self._false
- def help(self):
- return "Value must be in (%s, %s)."%(self._true, self._false)
-
-class eval_converter(abstract_converter):
- """
- A catchall converter when int and float are not enough.
- Evaluate the internal representation with python's eval().
- Possible uses, set a complex number, constellation points.
- Used in text box.
- """
- def __init__(self, formatter=lambda x: '%s'%(x)):
- self._formatter = formatter
- def external_to_internal(self, v):
- return self._formatter(v)
- def internal_to_external(self, s):
- return eval(s)
- def help(self):
- return "Value must be evaluatable by python's eval."
-
-class str_converter(abstract_converter):
- def __init__(self, formatter=lambda x: '%s'%(x)):
- self._formatter = formatter
- def external_to_internal(self, v):
- return self._formatter(v)
- def internal_to_external(self, s):
- return str(s)
-
-class int_converter(abstract_converter):
- def __init__(self, formatter=lambda x: '%d'%round(x)):
- self._formatter = formatter
- def external_to_internal(self, v):
- return self._formatter(v)
- def internal_to_external(self, s):
- return int(s, 0)
- def help(self):
- return "Enter an integer. Leading 0x indicates hex"
-
-class float_converter(abstract_converter):
- def __init__(self, formatter=eng_notation.num_to_str):
- self._formatter = formatter
- def external_to_internal(self, v):
- return self._formatter(v)
- def internal_to_external(self, s):
- return eng_notation.str_to_num(s)
- def help(self):
- return "Enter a float with optional scale suffix. E.g., 100.1M"
-
-class slider_converter(abstract_converter):
- """
- Scale values to and from the slider.
- """
- def __init__(self, minimum, maximum, num_steps, cast):
- assert minimum < maximum
- assert num_steps > 0
- self._offset = minimum
- self._scaler = float(maximum - minimum)/num_steps
- self._cast = cast
- def external_to_internal(self, v):
- return (v - self._offset)/self._scaler
- def internal_to_external(self, v):
- return self._cast(v*self._scaler + self._offset)
- def help(self):
- return "Value should be within slider range"
-
-class log_slider_converter(slider_converter):
- def __init__(self, min_exp, max_exp, num_steps, base):
- assert min_exp < max_exp
- assert num_steps > 0
- self._base = base
- slider_converter.__init__(self, minimum=min_exp, maximum=max_exp, num_steps=num_steps, cast=float)
- def external_to_internal(self, v):
- return slider_converter.external_to_internal(self, math.log(v, self._base))
- def internal_to_external(self, v):
- return self._base**slider_converter.internal_to_external(self, v)
diff --git a/gr-wxgui/python/wxgui/forms/forms.py b/gr-wxgui/python/wxgui/forms/forms.py
deleted file mode 100644
index f819f13397..0000000000
--- a/gr-wxgui/python/wxgui/forms/forms.py
+++ /dev/null
@@ -1,675 +0,0 @@
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-"""
-The forms module contains general purpose wx-gui forms for gnuradio apps.
-
-The forms follow a layered model:
- * internal layer
- * deals with the wxgui objects directly
- * implemented in event handler and update methods
- * translation layer
- * translates the between the external and internal layers
- * handles parsing errors between layers
- * external layer
- * provided external access to the user
- * set_value, get_value, and optional callback
- * set and get through optional pubsub and key
-
-Known problems:
- * An empty label in the radio box still consumes space.
- * The static text cannot resize the parent at runtime.
-"""
-
-EXT_KEY = 'external'
-INT_KEY = 'internal'
-
-import wx
-import sys
-from gnuradio.gr.pubsub import pubsub
-import converters
-
-EVT_DATA = wx.PyEventBinder(wx.NewEventType())
-class DataEvent(wx.PyEvent):
- def __init__(self, data):
- wx.PyEvent.__init__(self, wx.NewId(), EVT_DATA.typeId)
- self.data = data
-
-def make_bold(widget):
- font = widget.GetFont()
- font.SetWeight(wx.FONTWEIGHT_BOLD)
- widget.SetFont(font)
-
-########################################################################
-# Base Class Form
-########################################################################
-class _form_base(pubsub, wx.BoxSizer):
- def __init__(self, parent=None, sizer=None, proportion=0, flag=wx.EXPAND, ps=None, key='', value=None, callback=None, converter=converters.identity_converter()):
- pubsub.__init__(self)
- wx.BoxSizer.__init__(self, wx.HORIZONTAL)
- self._parent = parent
- self._key = key
- self._converter = converter
- self._callback = callback
- self._widgets = list()
- #add to the sizer if provided
- if sizer: sizer.Add(self, proportion, flag)
- #proxy the pubsub and key into this form
- if ps is not None:
- assert key
- self.proxy(EXT_KEY, ps, key)
- #no pubsub passed, must set initial value
- else: self.set_value(value)
-
- def __str__(self):
- return "Form: %s -> %s"%(self.__class__, self._key)
-
- def _add_widget(self, widget, label='', flag=0, label_prop=0, widget_prop=1):
- """
- Add the main widget to this object sizer.
- If label is passed, add a label as well.
- Register the widget and the label in the widgets list (for enable/disable).
- 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.
-
- 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))
- update = lambda x: wx.PostEvent(widget, DataEvent(x))
- #register widget
- self._widgets.append(widget)
- #create optional label
- if not label: self.Add(widget, widget_prop, wx.ALIGN_CENTER_VERTICAL | flag)
- else:
- label_text = wx.StaticText(self._parent, label='%s: '%label)
- self._widgets.append(label_text)
- self.Add(label_text, label_prop, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
- self.Add(widget, widget_prop, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | flag)
- #initialize without triggering pubsubs
- self._translate_external_to_internal(self[EXT_KEY])
- update(self[INT_KEY])
- #subscribe all the functions
- self.subscribe(INT_KEY, update)
- self.subscribe(INT_KEY, self._translate_internal_to_external)
- self.subscribe(EXT_KEY, self._translate_external_to_internal)
-
- def _translate_external_to_internal(self, external):
- try:
- internal = self._converter.external_to_internal(external)
- #prevent infinite loop between internal and external pubsub keys by only setting if changed
- if self[INT_KEY] != internal: self[INT_KEY] = internal
- except Exception, e:
- self._err_msg(external, e)
- self[INT_KEY] = self[INT_KEY] #reset to last good setting
-
- def _translate_internal_to_external(self, internal):
- try:
- external = self._converter.internal_to_external(internal)
- #prevent infinite loop between internal and external pubsub keys by only setting if changed
- if self[EXT_KEY] != external: self[EXT_KEY] = external
- except Exception, e:
- self._err_msg(internal, e)
- self[EXT_KEY] = self[EXT_KEY] #reset to last good setting
- if self._callback: self._callback(self[EXT_KEY])
-
- def _err_msg(self, value, e):
- print >> sys.stderr, self, 'Error translating value: "%s"\n\t%s\n\t%s'%(value, e, self._converter.help())
-
- #override in subclasses to handle the wxgui object
- def _update(self, value): raise NotImplementedError
- def _handle(self, event): raise NotImplementedError
-
- #provide a set/get interface for this form
- def get_value(self): return self[EXT_KEY]
- def set_value(self, value): self[EXT_KEY] = value
-
- def Disable(self, disable=True): self.Enable(not disable)
- def Enable(self, enable=True):
- if enable:
- for widget in self._widgets: widget.Enable()
- else:
- for widget in self._widgets: widget.Disable()
-
-########################################################################
-# Base Class Chooser Form
-########################################################################
-class _chooser_base(_form_base):
- def __init__(self, choices=[], labels=None, **kwargs):
- _form_base.__init__(self, converter=converters.chooser_converter(choices), **kwargs)
- self._choices = choices
- self._labels = map(str, labels or choices)
-
-########################################################################
-# Base Class Slider Form
-########################################################################
-class _slider_base(_form_base):
- def __init__(self, label='', length=-1, converter=None, num_steps=100, style=wx.SL_HORIZONTAL, **kwargs):
- _form_base.__init__(self, converter=converter, **kwargs)
- if style & wx.SL_HORIZONTAL: slider_size = wx.Size(length, -1)
- elif style & wx.SL_VERTICAL: slider_size = wx.Size(-1, length)
- else: raise NotImplementedError
- self._slider = wx.Slider(self._parent, minValue=0, maxValue=num_steps, size=slider_size, style=style)
- self._slider.Bind(wx.EVT_SCROLL, self._handle)
- self._add_widget(self._slider, label, flag=wx.EXPAND)
-
- def _handle(self, event): self[INT_KEY] = self._slider.GetValue()
- def _update(self, value): self._slider.SetValue(int(round(value)))
-
-########################################################################
-# Static Text Form
-########################################################################
-class static_text(_form_base):
- """
- A text box form.
-
- 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
- _form_base.__init__(self, converter=converter, **kwargs)
- self._static_text = wx.StaticText(self._parent, size=wx.Size(width, -1))
- if bold: make_bold(self._static_text)
- self._add_widget(self._static_text, label)
-
- def _update(self, label):
- if self._units: label += ' ' + self._units
- self._static_text.SetLabel(label); self._parent.Layout()
-
-########################################################################
-# Text Box Form
-########################################################################
-class text_box(_form_base):
- """
- A text box form.
-
- 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)
- self._text_box = wx.TextCtrl(self._parent, size=wx.Size(width, -1), style=wx.TE_PROCESS_ENTER)
- self._default_bg_colour = self._text_box.GetBackgroundColour()
- self._text_box.Bind(wx.EVT_TEXT_ENTER, self._handle)
- self._text_box.Bind(wx.EVT_TEXT, self._update_color)
- self._add_widget(self._text_box, label)
-
- def _update_color(self, *args):
- if self._text_box.GetValue() == self[INT_KEY]:
- self._text_box.SetBackgroundColour(self._default_bg_colour)
- else: self._text_box.SetBackgroundColour('#EEDDDD')
-
- def _handle(self, event): self[INT_KEY] = self._text_box.GetValue()
- def _update(self, value): self._text_box.SetValue(value); self._update_color()
-
-########################################################################
-# Slider Form
-# Linear Slider
-# Logarithmic Slider
-########################################################################
-class slider(_slider_base):
- """
- A generic linear slider.
-
- 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
- if step_size is not None: num_steps = (maximum - minimum)/step_size
- converter = converters.slider_converter(minimum=minimum, maximum=maximum, num_steps=num_steps, cast=cast)
- _slider_base.__init__(self, converter=converter, num_steps=num_steps, **kwargs)
-
-class log_slider(_slider_base):
- """
- A generic logarithmic slider.
- The sliders min and max values are base**min_exp and base**max_exp.
-
- 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
- if step_size is not None: num_steps = (max_exp - min_exp)/step_size
- converter = converters.log_slider_converter(min_exp=min_exp, max_exp=max_exp, num_steps=num_steps, base=base)
- _slider_base.__init__(self, converter=converter, num_steps=num_steps, **kwargs)
-
-########################################################################
-# Gauge Form
-########################################################################
-class gauge(_form_base):
- """
- A gauge bar.
- The gauge displays floating point values between the minimum and maximum.
-
- 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
- if step_size is not None: num_steps = (maximum - minimum)/step_size
- converter = converters.slider_converter(minimum=minimum, maximum=maximum, num_steps=num_steps, cast=float)
- _form_base.__init__(self, converter=converter, **kwargs)
- if style & wx.SL_HORIZONTAL: gauge_size = wx.Size(length, -1)
- elif style & wx.SL_VERTICAL: gauge_size = wx.Size(-1, length)
- else: raise NotImplementedError
- self._gauge = wx.Gauge(self._parent, range=num_steps, size=gauge_size, style=style)
- self._add_widget(self._gauge, label, flag=wx.EXPAND)
-
- def _update(self, value): self._gauge.SetValue(value)
-
-########################################################################
-# Check Box Form
-########################################################################
-class check_box(_form_base):
- """
- Create a check box form.
-
- 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)
- self._check_box = wx.CheckBox(self._parent, style=wx.CHK_2STATE, label=label)
- self._check_box.Bind(wx.EVT_CHECKBOX, self._handle)
- self._add_widget(self._check_box)
-
- def _handle(self, event): self[INT_KEY] = self._check_box.IsChecked()
- def _update(self, checked): self._check_box.SetValue(checked)
-
-########################################################################
-# Drop Down Chooser Form
-########################################################################
-class drop_down(_chooser_base):
- """
- Create a drop down menu form.
-
- 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)
- self._drop_down = wx.Choice(self._parent, choices=self._labels, size=wx.Size(width, -1))
- self._drop_down.Bind(wx.EVT_CHOICE, self._handle)
- self._add_widget(self._drop_down, label, widget_prop=0, label_prop=1)
-
- def _handle(self, event): self[INT_KEY] = self._drop_down.GetSelection()
- def _update(self, i): self._drop_down.SetSelection(i)
-
-########################################################################
-# Button Chooser Form
-# Circularly move through the choices with each click.
-# Can be a single-click button with one choice.
-# Can be a 2-state button with two choices.
-########################################################################
-class button(_chooser_base):
- """
- Create a multi-state button.
- 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)
- self._button = wx.Button(self._parent, size=wx.Size(width, -1), style=style)
- self._button.Bind(wx.EVT_BUTTON, self._handle)
- self._add_widget(self._button, label, widget_prop=((not style&wx.BU_EXACTFIT) and 1 or 0))
-
- def _handle(self, event): self[INT_KEY] = (self[INT_KEY] + 1)%len(self._choices) #circularly increment index
- def _update(self, i): self._button.SetLabel(self._labels[i]); self.Layout()
-
-class toggle_button(button):
- """
- Create a dual-state button.
- This button will alternate between True and False when clicked.
-
- 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)
-
-class single_button(toggle_button):
- """
- Create a single state button.
- This button will callback() when clicked.
- For use when state holding is not important.
-
- 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)
-
-########################################################################
-# Radio Buttons Chooser Form
-########################################################################
-class radio_buttons(_chooser_base):
- """
- Create a radio button form.
-
- 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)
- #create radio buttons
- self._radio_buttons = wx.RadioBox(self._parent, choices=self._labels, style=style, label=label, majorDimension=major_dimension)
- self._radio_buttons.Bind(wx.EVT_RADIOBOX, self._handle)
- self._add_widget(self._radio_buttons)
-
- def _handle(self, event): self[INT_KEY] = self._radio_buttons.GetSelection()
- def _update(self, i): self._radio_buttons.SetSelection(i)
-
-########################################################################
-# Notebook Chooser Form
-# The notebook pages/tabs are for selecting between choices.
-# A page must be added to the notebook for each choice.
-########################################################################
-class notebook(_chooser_base):
- def __init__(self, pages, notebook, **kwargs):
- _chooser_base.__init__(self, **kwargs)
- assert len(pages) == len(self._choices)
- self._notebook = notebook
- self._notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self._handle)
- #add pages, setting the label on each tab
- for i, page in enumerate(pages):
- self._notebook.AddPage(page, self._labels[i])
- self._add_widget(self._notebook)
-
- def _handle(self, event): self[INT_KEY] = event.GetSelection()
- # SetSelection triggers a page change event (deprecated, breaks on Windows) and ChangeSelection does not
- def _update(self, i): self._notebook.ChangeSelection(i)
-
-# ----------------------------------------------------------------
-# Stand-alone test application
-# ----------------------------------------------------------------
-
-import wx
-from gnuradio.wxgui import gui
-
-class app_gui (object):
- def __init__(self, frame, panel, vbox, top_block, options, args):
-
- def callback(v): print v
-
- radio_buttons(
- sizer=vbox,
- parent=panel,
- choices=[2, 4, 8, 16],
- labels=['two', 'four', 'eight', 'sixteen'],
- value=4,
- style=wx.RA_HORIZONTAL,
- label='test radio long string',
- callback=callback,
- #major_dimension = 2,
- )
-
- radio_buttons(
- sizer=vbox,
- parent=panel,
- choices=[2, 4, 8, 16],
- labels=['two', 'four', 'eight', 'sixteen'],
- value=4,
- style=wx.RA_VERTICAL,
- label='test radio long string',
- callback=callback,
- #major_dimension = 2,
- )
-
- radio_buttons(
- sizer=vbox,
- parent=panel,
- choices=[2, 4, 8, 16],
- labels=['two', 'four', 'eight', 'sixteen'],
- value=4,
- style=wx.RA_VERTICAL | wx.NO_BORDER,
- callback=callback,
- #major_dimension = 2,
- )
-
- button(
- sizer=vbox,
- parent=panel,
- choices=[2, 4, 8, 16],
- labels=['two', 'four', 'eight', 'sixteen'],
- value=2,
- label='button value',
- callback=callback,
- #width=100,
- )
-
-
- drop_down(
- sizer=vbox,
- parent=panel,
- choices=[2, 4, 8, 16],
- value=2,
- label='Choose One',
- callback=callback,
- )
- check_box(
- sizer=vbox,
- parent=panel,
- value=False,
- label='check me',
- callback=callback,
- )
- text_box(
- sizer=vbox,
- parent=panel,
- value=3,
- label='text box',
- callback=callback,
- width=200,
- )
-
- static_text(
- sizer=vbox,
- parent=panel,
- value='bob',
- label='static text',
- width=-1,
- bold=True,
- )
-
- slider(
- sizer=vbox,
- parent=panel,
- value=12,
- label='slider',
- callback=callback,
- )
-
- log_slider(
- sizer=vbox,
- parent=panel,
- value=12,
- label='slider',
- callback=callback,
- )
-
- slider(
- sizer=vbox,
- parent=panel,
- value=12,
- label='slider',
- callback=callback,
- style=wx.SL_VERTICAL,
- length=30,
- )
-
- toggle_button(
- sizer=vbox,
- parent=panel,
- value=True,
- label='toggle it',
- callback=callback,
- )
-
- single_button(
- sizer=vbox,
- parent=panel,
- label='sig test',
- callback=callback,
- )
-
-if __name__ == "__main__":
- try:
-
- # Create the GUI application
- app = gui.app(
- gui=app_gui, # User interface class
- title="Test Forms", # Top window title
- )
-
- # And run it
- app.MainLoop()
-
- except RuntimeError, e:
- print e
- sys.exit(1)
diff --git a/gr-wxgui/python/wxgui/gui.py b/gr-wxgui/python/wxgui/gui.py
deleted file mode 100644
index ccc773eabf..0000000000
--- a/gr-wxgui/python/wxgui/gui.py
+++ /dev/null
@@ -1,135 +0,0 @@
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import wx
-from gnuradio import gr
-
-#
-# Top-level display panel with vertical box sizer. User does not create or
-# subclass this class; rather, the user supplies his own class constructor
-# that gets invoked with needed parameters.
-#
-class top_panel(wx.Panel):
- def __init__(self, frame, top_block, gui, options, args):
- wx.Panel.__init__(self, frame, -1)
- vbox = wx.BoxSizer(wx.VERTICAL)
-
- # Create the user's GUI class
- if gui is not None:
- self.gui = gui(frame, # Top-level window frame
- self, # Parent class for user created windows
- vbox, # Sizer for user to add windows to
- top_block, # GUI-unaware flowgraph to manipulate
- options, # Command-line options
- args) # Command-line arguments
-
- else:
- # User hasn't made their own GUI, create our default
- # We don't have a default GUI yet either :)
- p = wx.Panel(self)
- p.SetSize((640,480))
- vbox.Add(p, 1, wx.EXPAND)
-
- self.SetSizer(vbox)
- self.SetAutoLayout(True)
- vbox.Fit(self)
-
- def shutdown(self):
- try:
- self.gui.shutdown()
- except AttributeError:
- pass
-
-#
-# Top-level window frame with menu and status bars.
-#
-class top_frame(wx.Frame):
- def __init__ (self, top_block, gui, options, args,
- title, nstatus, start, realtime):
-
- wx.Frame.__init__(self, None, -1, title)
- self.top_block = top_block
-
- self.CreateStatusBar(nstatus)
- mainmenu = wx.MenuBar()
- self.SetMenuBar(mainmenu)
-
- menu = wx.Menu()
-
- item = menu.Append(200, 'E&xit', 'Exit Application') # FIXME magic ID
- self.Bind(wx.EVT_MENU, self.OnCloseWindow, item)
- mainmenu.Append(menu, "&File")
- self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
-
- # Create main panel, creates user GUI class with supplied parameters
- self.panel = top_panel(self, top_block, gui, options, args)
-
- vbox = wx.BoxSizer(wx.VERTICAL)
- vbox.Add(self.panel, 1, wx.EXPAND)
- self.SetSizer(vbox)
- self.SetAutoLayout(True)
- vbox.Fit(self)
-
- if realtime:
- if gr.enable_realtime_scheduling() != gr.RT_OK:
- self.SetStatusText("Failed to enable realtime scheduling")
-
- if start and self.top_block is not None:
- self.top_block.start()
-
- def OnCloseWindow(self, event):
- # Give user API a chance to do something
- self.panel.shutdown()
-
- # Stop flowgraph as a convenience
- self.SetStatusText("Ensuring flowgraph has completed before exiting...")
- if self.top_block is not None:
- self.top_block.stop()
- self.top_block.wait()
-
- self.Destroy()
-
-
-#
-# Top-level wxPython application object. User creates or subclasses this
-# in their GUI script.
-#
-class app(wx.App):
- def __init__ (self, top_block=None, gui=None, options=None, args=None,
- title="GNU Radio", nstatus=1, start=False, realtime=False):
- self.top_block = top_block
- self.gui = gui
- self.options = options
- self.args = args
- self.title = title
- self.nstatus = nstatus
- self.start = start
- self.realtime = realtime
-
- wx.App.__init__ (self, redirect=False)
-
- def OnInit(self):
- # Pass user parameters to top window frame
- frame = top_frame(self.top_block, self.gui, self.options, self.args,
- self.title, self.nstatus, self.start, self.realtime)
- frame.Show(True)
- self.SetTopWindow(frame)
- return True
diff --git a/gr-wxgui/python/wxgui/histo_window.py b/gr-wxgui/python/wxgui/histo_window.py
deleted file mode 100644
index 424ee7bbdb..0000000000
--- a/gr-wxgui/python/wxgui/histo_window.py
+++ /dev/null
@@ -1,168 +0,0 @@
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-import plotter
-import common
-import wx
-import numpy
-import math
-import pubsub
-from constants import *
-from gnuradio import gr #for gr.prefs
-import forms
-
-##################################################
-# Constants
-##################################################
-DEFAULT_WIN_SIZE = (600, 300)
-
-##################################################
-# histo window control panel
-##################################################
-class control_panel(wx.Panel):
- """
- A control panel with wx widgits to control the plotter and histo sink.
- """
-
- def __init__(self, parent):
- """
- Create a new control panel.
-
- Args:
- parent: the wx parent window
- """
- self.parent = parent
- wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
- parent[SHOW_CONTROL_PANEL_KEY] = True
- parent.subscribe(SHOW_CONTROL_PANEL_KEY, self.Show)
- control_box = wx.BoxSizer(wx.VERTICAL)
- SIZE = (100, -1)
- control_box = forms.static_box_sizer(
- parent=self, label='Options',
- bold=True, orient=wx.VERTICAL,
- )
- #num bins
- control_box.AddStretchSpacer()
- forms.text_box(
- sizer=control_box, parent=self, label='Num Bins',
- converter=forms.int_converter(),
- ps=parent, key=NUM_BINS_KEY,
- )
- #frame size
- control_box.AddStretchSpacer()
- forms.text_box(
- sizer=control_box, parent=self, label='Frame Size',
- converter=forms.int_converter(),
- ps=parent, key=FRAME_SIZE_KEY,
- )
- #run/stop
- control_box.AddStretchSpacer()
- forms.toggle_button(
- sizer=control_box, parent=self,
- true_label='Stop', false_label='Run',
- ps=parent, key=RUNNING_KEY,
- )
- #set sizer
- self.SetSizerAndFit(control_box)
-
-##################################################
-# histo window with plotter and control panel
-##################################################
-class histo_window(wx.Panel, pubsub.pubsub):
- def __init__(
- self,
- parent,
- controller,
- size,
- title,
- maximum_key,
- minimum_key,
- num_bins_key,
- frame_size_key,
- msg_key,
- ):
- pubsub.pubsub.__init__(self)
- #setup
- self.samples = list()
- #proxy the keys
- self.proxy(MAXIMUM_KEY, controller, maximum_key)
- self.proxy(MINIMUM_KEY, controller, minimum_key)
- self.proxy(NUM_BINS_KEY, controller, num_bins_key)
- self.proxy(FRAME_SIZE_KEY, controller, frame_size_key)
- self.proxy(MSG_KEY, controller, msg_key)
- #initialize values
- self[RUNNING_KEY] = True
- self[X_DIVS_KEY] = 8
- self[Y_DIVS_KEY] = 4
- #init panel and plot
- wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
- self.plotter = plotter.bar_plotter(self)
- self.plotter.SetSize(wx.Size(*size))
- self.plotter.SetSizeHints(*size)
- self.plotter.set_title(title)
- self.plotter.enable_point_label(True)
- self.plotter.enable_grid_lines(False)
- #setup the box with plot and controls
- self.control_panel = control_panel(self)
- main_box = wx.BoxSizer(wx.HORIZONTAL)
- main_box.Add(self.plotter, 1, wx.EXPAND)
- main_box.Add(self.control_panel, 0, wx.EXPAND)
- self.SetSizerAndFit(main_box)
- #register events
- self.subscribe(MSG_KEY, self.handle_msg)
- self.subscribe(X_DIVS_KEY, self.update_grid)
- self.subscribe(Y_DIVS_KEY, self.update_grid)
-
- def handle_msg(self, msg):
- """
- Handle the message from the fft sink message queue.
-
- Args:
- msg: the frame as a character array
- """
- if not self[RUNNING_KEY]: return
- #convert to floating point numbers
- self.samples = 100*numpy.fromstring(msg, numpy.float32)[:self[NUM_BINS_KEY]] #only take first frame
- self.plotter.set_bars(
- bars=self.samples,
- bar_width=0.6,
- color_spec=(0, 0, 1),
- )
- self.update_grid()
-
- def update_grid(self):
- if not len(self.samples): return
- #calculate the maximum y value
- y_off = math.ceil(numpy.max(self.samples))
- y_off = min(max(y_off, 1.0), 100.0) #between 1% and 100%
- #update the x grid
- self.plotter.set_x_grid(
- self[MINIMUM_KEY], self[MAXIMUM_KEY],
- common.get_clean_num((self[MAXIMUM_KEY] - self[MINIMUM_KEY])/self[X_DIVS_KEY]),
- )
- self.plotter.set_x_label('Counts')
- #update the y grid
- self.plotter.set_y_grid(0, y_off, y_off/self[Y_DIVS_KEY])
- self.plotter.set_y_label('Frequency', '%')
- self.plotter.update()
diff --git a/gr-wxgui/python/wxgui/histosink_gl.py b/gr-wxgui/python/wxgui/histosink_gl.py
deleted file mode 100644
index 2126d63191..0000000000
--- a/gr-wxgui/python/wxgui/histosink_gl.py
+++ /dev/null
@@ -1,113 +0,0 @@
-#
-# Copyright 2009,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-import histo_window
-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 *
-
-##################################################
-# histo sink block (wrapper for old wxgui)
-##################################################
-class histo_sink_f(gr.hier_block2, common.wxgui_hb):
- """
- A histogram block and a gui window.
- """
-
- def __init__(
- self,
- parent,
- size=histo_window.DEFAULT_WIN_SIZE,
- title='',
- num_bins=11,
- frame_size=1000,
- ):
- #init
- gr.hier_block2.__init__(
- self,
- "histo_sink",
- gr.io_signature(1, 1, gr.sizeof_float),
- gr.io_signature(0, 0, 0),
- )
- #blocks
- msgq = gr.msg_queue(2)
- histo = wxgui.histo_sink_f(msgq)
- histo.set_num_bins(num_bins)
- histo.set_frame_size(frame_size)
- #controller
- self.controller = pubsub()
- self.controller.subscribe(NUM_BINS_KEY, histo.set_num_bins)
- self.controller.publish(NUM_BINS_KEY, histo.get_num_bins)
- self.controller.subscribe(FRAME_SIZE_KEY, histo.set_frame_size)
- self.controller.publish(FRAME_SIZE_KEY, histo.get_frame_size)
- #start input watcher
- common.input_watcher(msgq, self.controller, MSG_KEY, arg1_key=MINIMUM_KEY, arg2_key=MAXIMUM_KEY)
- #create window
- self.win = histo_window.histo_window(
- parent=parent,
- controller=self.controller,
- size=size,
- title=title,
- maximum_key=MAXIMUM_KEY,
- minimum_key=MINIMUM_KEY,
- num_bins_key=NUM_BINS_KEY,
- frame_size_key=FRAME_SIZE_KEY,
- msg_key=MSG_KEY,
- )
- common.register_access_methods(self, self.win)
- #connect
- self.wxgui_connect(self, histo)
-
-# ----------------------------------------------------------------
-# Standalone test app
-# ----------------------------------------------------------------
-
-import wx
-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)
-
- # build our flow graph
- input_rate = 20.48e3
-
- 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()
-
-if __name__ == '__main__':
- main()
diff --git a/gr-wxgui/python/wxgui/number_window.py b/gr-wxgui/python/wxgui/number_window.py
deleted file mode 100644
index 2e54f8460f..0000000000
--- a/gr-wxgui/python/wxgui/number_window.py
+++ /dev/null
@@ -1,219 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-import common
-import numpy
-import wx
-import pubsub
-from constants import *
-from gnuradio import gr #for gr.prefs
-import forms
-
-##################################################
-# Constants
-##################################################
-NEG_INF = float('-inf')
-SLIDER_STEPS = 100
-AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0
-DEFAULT_NUMBER_RATE = gr.prefs().get_long('wxgui', 'number_rate', 5)
-DEFAULT_WIN_SIZE = (300, 300)
-DEFAULT_GAUGE_RANGE = 1000
-VALUE_REPR_KEY = 'value_repr'
-VALUE_REAL_KEY = 'value_real'
-VALUE_IMAG_KEY = 'value_imag'
-
-##################################################
-# Number window control panel
-##################################################
-class control_panel(wx.Panel):
- """
- A control panel with wx widgits to control the averaging.
- """
-
- def __init__(self, parent):
- """
- Create a new control panel.
-
- Args:
- parent: the wx parent window
- """
- self.parent = parent
- wx.Panel.__init__(self, parent)
- parent[SHOW_CONTROL_PANEL_KEY] = True
- parent.subscribe(SHOW_CONTROL_PANEL_KEY, self.Show)
- control_box = wx.BoxSizer(wx.VERTICAL)
- #checkboxes for average and peak hold
- control_box.AddStretchSpacer()
- options_box = forms.static_box_sizer(
- parent=self, sizer=control_box, label='Options',
- bold=True, orient=wx.VERTICAL,
- )
- forms.check_box(
- sizer=options_box, parent=self, label='Peak Hold',
- ps=parent, key=PEAK_HOLD_KEY,
- )
- forms.check_box(
- sizer=options_box, parent=self, label='Average',
- ps=parent, key=AVERAGE_KEY,
- )
- #static text and slider for averaging
- avg_alpha_text = forms.static_text(
- sizer=options_box, parent=self, label='Avg Alpha',
- converter=forms.float_converter(lambda x: '%.4f'%x),
- ps=parent, key=AVG_ALPHA_KEY, width=50,
- )
- avg_alpha_slider = forms.log_slider(
- sizer=options_box, parent=self,
- min_exp=AVG_ALPHA_MIN_EXP,
- max_exp=AVG_ALPHA_MAX_EXP,
- num_steps=SLIDER_STEPS,
- ps=parent, key=AVG_ALPHA_KEY,
- )
- for widget in (avg_alpha_text, avg_alpha_slider):
- parent.subscribe(AVERAGE_KEY, widget.Enable)
- widget.Enable(parent[AVERAGE_KEY])
- #run/stop
- control_box.AddStretchSpacer()
- forms.toggle_button(
- sizer=control_box, parent=self,
- true_label='Stop', false_label='Run',
- ps=parent, key=RUNNING_KEY,
- )
- #set sizer
- self.SetSizerAndFit(control_box)
-
-##################################################
-# Numbersink window with label and gauges
-##################################################
-class number_window(wx.Panel, pubsub.pubsub):
- def __init__(
- self,
- parent,
- controller,
- size,
- title,
- units,
- show_gauge,
- real,
- minval,
- maxval,
- decimal_places,
- average_key,
- avg_alpha_key,
- peak_hold,
- msg_key,
- sample_rate_key,
- ):
- pubsub.pubsub.__init__(self)
- wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
- #setup
- self.peak_val_real = NEG_INF
- self.peak_val_imag = NEG_INF
- self.real = real
- self.units = units
- self.decimal_places = decimal_places
- #proxy the keys
- self.proxy(MSG_KEY, controller, msg_key)
- self.proxy(AVERAGE_KEY, controller, average_key)
- self.proxy(AVG_ALPHA_KEY, controller, avg_alpha_key)
- self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
- #initialize values
- self[PEAK_HOLD_KEY] = peak_hold
- self[RUNNING_KEY] = True
- self[VALUE_REAL_KEY] = minval
- self[VALUE_IMAG_KEY] = minval
- #setup the box with display and controls
- self.control_panel = control_panel(self)
- main_box = wx.BoxSizer(wx.HORIZONTAL)
- sizer = forms.static_box_sizer(
- parent=self, sizer=main_box, label=title,
- bold=True, orient=wx.VERTICAL, proportion=1,
- )
- main_box.Add(self.control_panel, 0, wx.EXPAND)
- sizer.AddStretchSpacer()
- forms.static_text(
- parent=self, sizer=sizer,
- ps=self, key=VALUE_REPR_KEY, width=size[0],
- converter=forms.str_converter(),
- )
- sizer.AddStretchSpacer()
- self.gauge_real = forms.gauge(
- parent=self, sizer=sizer, style=wx.GA_HORIZONTAL,
- ps=self, key=VALUE_REAL_KEY, length=size[0],
- minimum=minval, maximum=maxval, num_steps=DEFAULT_GAUGE_RANGE,
- )
- self.gauge_imag = forms.gauge(
- parent=self, sizer=sizer, style=wx.GA_HORIZONTAL,
- ps=self, key=VALUE_IMAG_KEY, length=size[0],
- minimum=minval, maximum=maxval, num_steps=DEFAULT_GAUGE_RANGE,
- )
- #hide/show gauges
- self.show_gauges(show_gauge)
- self.SetSizerAndFit(main_box)
- #register events
- self.subscribe(MSG_KEY, self.handle_msg)
-
- def show_gauges(self, show_gauge):
- """
- Show or hide the gauges.
- If this is real, never show the imaginary gauge.
-
- Args:
- show_gauge: true to show
- """
- self.gauge_real.ShowItems(show_gauge)
- self.gauge_imag.ShowItems(show_gauge and not self.real)
-
- def handle_msg(self, msg):
- """
- Handle a message from the message queue.
- 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.
-
- Args:
- event: event.data is the number sample as a character array
- """
- if not self[RUNNING_KEY]: return
- format_string = "%%.%df"%self.decimal_places
- if self.real:
- sample = numpy.fromstring(msg, numpy.float32)[-1]
- if self[PEAK_HOLD_KEY]: sample = self.peak_val_real = max(self.peak_val_real, sample)
- label_text = "%s %s"%(format_string%sample, self.units)
- self[VALUE_REAL_KEY] = sample
- else:
- sample = numpy.fromstring(msg, numpy.complex64)[-1]
- if self[PEAK_HOLD_KEY]:
- self.peak_val_real = max(self.peak_val_real, sample.real)
- self.peak_val_imag = max(self.peak_val_imag, sample.imag)
- sample = self.peak_val_real + self.peak_val_imag*1j
- label_text = "%s + %sj %s"%(format_string%sample.real, format_string%sample.imag, self.units)
- self[VALUE_REAL_KEY] = sample.real
- self[VALUE_IMAG_KEY] = sample.imag
- #set label text
- self[VALUE_REPR_KEY] = label_text
- #clear peak hold
- if not self[PEAK_HOLD_KEY]:
- self.peak_val_real = NEG_INF
- self.peak_val_imag = NEG_INF
diff --git a/gr-wxgui/python/wxgui/numbersink2.py b/gr-wxgui/python/wxgui/numbersink2.py
deleted file mode 100644
index 62a096e112..0000000000
--- a/gr-wxgui/python/wxgui/numbersink2.py
+++ /dev/null
@@ -1,173 +0,0 @@
-#
-# Copyright 2008,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-import number_window
-import common
-from gnuradio import gr, filter
-from gnuradio import analog
-from gnuradio import blocks
-from pubsub import pubsub
-from constants import *
-
-##################################################
-# Number sink block (wrapper for old wxgui)
-##################################################
-class _number_sink_base(gr.hier_block2, common.wxgui_hb):
- """
- An decimator block with a number window display
- """
-
- def __init__(
- self,
- parent,
- unit='units',
- minval=0,
- maxval=1,
- factor=1,
- decimal_places=3,
- ref_level=0,
- sample_rate=1,
- number_rate=number_window.DEFAULT_NUMBER_RATE,
- average=False,
- avg_alpha=None,
- label='Number Plot',
- size=number_window.DEFAULT_WIN_SIZE,
- peak_hold=False,
- show_gauge=True,
- **kwargs #catchall for backwards compatibility
- ):
- #ensure avg alpha
- if avg_alpha is None: avg_alpha = 2.0/number_rate
- #init
- gr.hier_block2.__init__(
- self,
- "number_sink",
- gr.io_signature(1, 1, self._item_size),
- gr.io_signature(0, 0, 0),
- )
- #blocks
- 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 = blocks.multiply_const_ff(factor)
- add = blocks.add_const_ff(ref_level)
- avg = filter.single_pole_iir_filter_ff(1.0)
- else:
- 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 = blocks.message_sink(self._item_size, msgq, True)
- #controller
- self.controller = pubsub()
- self.controller.subscribe(SAMPLE_RATE_KEY, sd.set_sample_rate)
- self.controller.publish(SAMPLE_RATE_KEY, sd.sample_rate)
- self.controller[AVERAGE_KEY] = average
- self.controller[AVG_ALPHA_KEY] = avg_alpha
- def update_avg(*args):
- if self.controller[AVERAGE_KEY]: avg.set_taps(self.controller[AVG_ALPHA_KEY])
- else: avg.set_taps(1.0)
- update_avg()
- self.controller.subscribe(AVERAGE_KEY, update_avg)
- self.controller.subscribe(AVG_ALPHA_KEY, update_avg)
- #start input watcher
- common.input_watcher(msgq, self.controller, MSG_KEY)
- #create window
- self.win = number_window.number_window(
- parent=parent,
- controller=self.controller,
- size=size,
- title=label,
- units=unit,
- real=self._real,
- minval=minval,
- maxval=maxval,
- decimal_places=decimal_places,
- show_gauge=show_gauge,
- average_key=AVERAGE_KEY,
- avg_alpha_key=AVG_ALPHA_KEY,
- peak_hold=peak_hold,
- msg_key=MSG_KEY,
- sample_rate_key=SAMPLE_RATE_KEY,
- )
- common.register_access_methods(self, self.controller)
- #backwards compadibility
- self.set_show_gauge = self.win.show_gauges
- #connect
- self.wxgui_connect(self, sd, mult, add, avg, sink)
-
-class number_sink_f(_number_sink_base):
- _item_size = gr.sizeof_float
- _real = True
-
-class number_sink_c(_number_sink_base):
- _item_size = gr.sizeof_gr_complex
- _real = False
-
-# ----------------------------------------------------------------
-# Standalone test app
-# ----------------------------------------------------------------
-
-import wx
-from gnuradio.wxgui import stdgui2
-
-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)
-
- # build our flow graph
- input_rate = 20.48e3
-
- # Generate a real and complex sinusoids
- 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 = 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)
-
- 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()
-
-if __name__ == '__main__':
- main()
-
diff --git a/gr-wxgui/python/wxgui/plot.py b/gr-wxgui/python/wxgui/plot.py
deleted file mode 100644
index 041a2a7a50..0000000000
--- a/gr-wxgui/python/wxgui/plot.py
+++ /dev/null
@@ -1,1834 +0,0 @@
-#-----------------------------------------------------------------------------
-# Name: wx.lib.plot.py
-# Purpose: Line, Bar and Scatter Graphs
-#
-# Author: Gordon Williams
-#
-# Created: 2003/11/03
-# RCS-ID: $Id$
-# Copyright: (c) 2002,2007,2010
-# Licence: Use as you wish.
-#-----------------------------------------------------------------------------
-# 12/15/2003 - Jeff Grimmett (grimmtooth@softhome.net)
-#
-# o 2.5 compatability update.
-# o Renamed to plot.py in the wx.lib directory.
-# o Reworked test frame to work with wx demo framework. This saves a bit
-# of tedious cut and paste, and the test app is excellent.
-#
-# 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net)
-#
-# o wxScrolledMessageDialog -> ScrolledMessageDialog
-#
-# Oct 6, 2004 Gordon Williams (g_will@cyberus.ca)
-# - Added bar graph demo
-# - Modified line end shape from round to square.
-# - Removed FloatDCWrapper for conversion to ints and ints in arguments
-#
-# Oct 15, 2004 Gordon Williams (g_will@cyberus.ca)
-# - Imported modules given leading underscore to name.
-# - Added Cursor Line Tracking and User Point Labels.
-# - Demo for Cursor Line Tracking and Point Labels.
-# - Size of plot preview frame adjusted to show page better.
-# - Added helper functions PositionUserToScreen and PositionScreenToUser in PlotCanvas.
-# - Added functions GetClosestPoints (all curves) and GetClosestPoint (only closest curve)
-# can be in either user coords or screen coords.
-#
-# May 27, 2007 Johnathan Corgan (jcorgan@corganenterprises.com)
-# - Converted from numarray to numpy
-#
-# Apr 23, 2010 Martin Dudok van Heel (http://www.olifantasia.com/gnuradio/contact_olifantasia.gif)
-# - Added Persistence option (emulate after glow of an analog CRT display using IIR)
-
-"""
-This is a simple light weight plotting module that can be used with
-Boa or easily integrated into your own wxPython application. The
-emphasis is on small size and fast plotting for large data sets. It
-has a reasonable number of features to do line and scatter graphs
-easily as well as simple bar graphs. It is not as sophisticated or
-as powerful as SciPy Plt or Chaco. Both of these are great packages
-but consume huge amounts of computer resources for simple plots.
-They can be found at http://scipy.com
-
-This file contains two parts; first the re-usable library stuff, then,
-after a "if __name__=='__main__'" test, a simple frame and a few default
-plots for examples and testing.
-
-Based on wxPlotCanvas
-Written by K.Hinsen, R. Srinivasan;
-Ported to wxPython Harm van der Heijden, feb 1999
-
-Major Additions Gordon Williams Feb. 2003 (g_will@cyberus.ca)
- -More style options
- -Zooming using mouse 'rubber band'
- -Scroll left, right
- -Grid(graticule)
- -Printing, preview, and page set up (margins)
- -Axis and title labels
- -Cursor xy axis values
- -Doc strings and lots of comments
- -Optimizations for large number of points
- -Legends
-
-Did a lot of work here to speed markers up. Only a factor of 4
-improvement though. Lines are much faster than markers, especially
-filled markers. Stay away from circles and triangles unless you
-only have a few thousand points.
-
-Times for 25,000 points
-Line - 0.078 sec
-Markers
-Square - 0.22 sec
-dot - 0.10
-circle - 0.87
-cross,plus - 0.28
-triangle, triangle_down - 0.90
-
-Thanks to Chris Barker for getting this version working on Linux.
-
-Zooming controls with mouse (when enabled):
- Left mouse drag - Zoom box.
- Left mouse double click - reset zoom.
- Right mouse click - zoom out centred on click location.
-"""
-
-import string as _string
-import time as _time
-import wx
-
-# Needs numpy or numarray
-try:
- import numpy as _numpy
-except:
- try:
- import numarray as _numpy #if numarray is used it is renamed numpy
- except:
- msg= """
- This module requires the numpy or numarray module,
- which could not be imported. It probably is not installed
- (it's not part of the standard Python distribution). See the
- Python site (http://www.python.org) for information on
- downloading source or binaries."""
- raise ImportError, "numpy or numarray not found. \n" + msg
-
-
-
-#
-# Plotting classes...
-#
-class PolyPoints:
- """Base Class for lines and markers
- - All methods are private.
- """
-
- def __init__(self, points, attr):
- self.points = _numpy.array(points)
- self.currentScale= (1,1)
- self.currentShift= (0,0)
- self.scaled = self.points
- self.attributes = {}
- self.attributes.update(self._attributes)
- for name, value in attr.items():
- if name not in self._attributes.keys():
- raise KeyError, "Style attribute incorrect. Should be one of %s" % self._attributes.keys()
- self.attributes[name] = value
-
- def boundingBox(self):
- if len(self.points) == 0:
- # no curves to draw
- # defaults to (-1,-1) and (1,1) but axis can be set in Draw
- minXY= _numpy.array([-1,-1])
- maxXY= _numpy.array([ 1, 1])
- else:
- minXY= _numpy.minimum.reduce(self.points)
- maxXY= _numpy.maximum.reduce(self.points)
- return minXY, maxXY
-
- def scaleAndShift(self, scale=(1,1), shift=(0,0)):
- if len(self.points) == 0:
- # no curves to draw
- return
- if (scale is not self.currentScale) or (shift is not self.currentShift):
- # update point scaling
- self.scaled = scale*self.points+shift
- self.currentScale= scale
- self.currentShift= shift
- # else unchanged use the current scaling
-
- def getLegend(self):
- return self.attributes['legend']
-
- def getClosestPoint(self, pntXY, pointScaled= True):
- """Returns the index of closest point on the curve, pointXY, scaledXY, distance
- x, y in user coords
- if pointScaled == True based on screen coords
- if pointScaled == False based on user coords
- """
- if pointScaled == True:
- #Using screen coords
- p = self.scaled
- pxy = self.currentScale * _numpy.array(pntXY)+ self.currentShift
- else:
- #Using user coords
- p = self.points
- pxy = _numpy.array(pntXY)
- #determine distance for each point
- d= _numpy.sqrt(_numpy.add.reduce((p-pxy)**2,1)) #sqrt(dx^2+dy^2)
- pntIndex = _numpy.argmin(d)
- dist = d[pntIndex]
- return [pntIndex, self.points[pntIndex], self.scaled[pntIndex], dist]
-
-
-class PolyLine(PolyPoints):
- """Class to define line type and style
- - All methods except __init__ are private.
- """
-
- _attributes = {'colour': 'black',
- 'width': 1,
- 'style': wx.SOLID,
- 'legend': ''}
-
- def __init__(self, points, **attr):
- """Creates PolyLine object
- points - sequence (array, tuple or list) of (x,y) points making up line
- **attr - key word attributes
- Defaults:
- 'colour'= 'black', - wx.Pen Colour any wx.NamedColour
- 'width'= 1, - Pen width
- 'style'= wx.SOLID, - wx.Pen style
- 'legend'= '' - Line Legend to display
- """
- PolyPoints.__init__(self, points, attr)
-
- def draw(self, dc, printerScale, coord= None):
- colour = self.attributes['colour']
- width = self.attributes['width'] * printerScale
- style= self.attributes['style']
- pen = wx.Pen(wx.NamedColour(colour), width, style)
- pen.SetCap(wx.CAP_BUTT)
- dc.SetPen(pen)
- if coord == None:
- dc.DrawLines(self.scaled)
- else:
- dc.DrawLines(coord) # draw legend line
-
- def getSymExtent(self, printerScale):
- """Width and Height of Marker"""
- h= self.attributes['width'] * printerScale
- w= 5 * h
- return (w,h)
-
-
-class PolyMarker(PolyPoints):
- """Class to define marker type and style
- - All methods except __init__ are private.
- """
-
- _attributes = {'colour': 'black',
- 'width': 1,
- 'size': 2,
- 'fillcolour': None,
- 'fillstyle': wx.SOLID,
- 'marker': 'circle',
- 'legend': ''}
-
- def __init__(self, points, **attr):
- """Creates PolyMarker object
- points - sequence (array, tuple or list) of (x,y) points
- **attr - key word attributes
- Defaults:
- 'colour'= 'black', - wx.Pen Colour any wx.NamedColour
- 'width'= 1, - Pen width
- 'size'= 2, - Marker size
- 'fillcolour'= same as colour, - wx.Brush Colour any wx.NamedColour
- 'fillstyle'= wx.SOLID, - wx.Brush fill style (use wx.TRANSPARENT for no fill)
- 'marker'= 'circle' - Marker shape
- 'legend'= '' - Marker Legend to display
-
- Marker Shapes:
- - 'circle'
- - 'dot'
- - 'square'
- - 'triangle'
- - 'triangle_down'
- - 'cross'
- - 'plus'
- """
-
- PolyPoints.__init__(self, points, attr)
-
- def draw(self, dc, printerScale, coord= None):
- colour = self.attributes['colour']
- width = self.attributes['width'] * printerScale
- size = self.attributes['size'] * printerScale
- fillcolour = self.attributes['fillcolour']
- fillstyle = self.attributes['fillstyle']
- marker = self.attributes['marker']
-
- dc.SetPen(wx.Pen(wx.NamedColour(colour), width))
- if fillcolour:
- dc.SetBrush(wx.Brush(wx.NamedColour(fillcolour),fillstyle))
- else:
- dc.SetBrush(wx.Brush(wx.NamedColour(colour), fillstyle))
- if coord == None:
- self._drawmarkers(dc, self.scaled, marker, size)
- else:
- self._drawmarkers(dc, coord, marker, size) # draw legend marker
-
- def getSymExtent(self, printerScale):
- """Width and Height of Marker"""
- s= 5*self.attributes['size'] * printerScale
- return (s,s)
-
- def _drawmarkers(self, dc, coords, marker,size=1):
- f = eval('self._' +marker)
- f(dc, coords, size)
-
- def _circle(self, dc, coords, size=1):
- fact= 2.5*size
- wh= 5.0*size
- rect= _numpy.zeros((len(coords),4),_numpy.float)+[0.0,0.0,wh,wh]
- rect[:,0:2]= coords-[fact,fact]
- dc.DrawEllipseList(rect.astype(_numpy.int32))
-
- def _dot(self, dc, coords, size=1):
- dc.DrawPointList(coords)
-
- def _square(self, dc, coords, size=1):
- fact= 2.5*size
- wh= 5.0*size
- rect= _numpy.zeros((len(coords),4),_numpy.float)+[0.0,0.0,wh,wh]
- rect[:,0:2]= coords-[fact,fact]
- dc.DrawRectangleList(rect.astype(_numpy.int32))
-
- def _triangle(self, dc, coords, size=1):
- shape= [(-2.5*size,1.44*size), (2.5*size,1.44*size), (0.0,-2.88*size)]
- poly= _numpy.repeat(coords,3)
- poly.shape= (len(coords),3,2)
- poly += shape
- dc.DrawPolygonList(poly.astype(_numpy.int32))
-
- def _triangle_down(self, dc, coords, size=1):
- shape= [(-2.5*size,-1.44*size), (2.5*size,-1.44*size), (0.0,2.88*size)]
- poly= _numpy.repeat(coords,3)
- poly.shape= (len(coords),3,2)
- poly += shape
- dc.DrawPolygonList(poly.astype(_numpy.int32))
-
- def _cross(self, dc, coords, size=1):
- fact= 2.5*size
- for f in [[-fact,-fact,fact,fact],[-fact,fact,fact,-fact]]:
- lines= _numpy.concatenate((coords,coords),axis=1)+f
- dc.DrawLineList(lines.astype(_numpy.int32))
-
- def _plus(self, dc, coords, size=1):
- fact= 2.5*size
- for f in [[-fact,0,fact,0],[0,-fact,0,fact]]:
- lines= _numpy.concatenate((coords,coords),axis=1)+f
- dc.DrawLineList(lines.astype(_numpy.int32))
-
-class PlotGraphics:
- """Container to hold PolyXXX objects and graph labels
- - All methods except __init__ are private.
- """
-
- def __init__(self, objects, title='', xLabel='', yLabel= ''):
- """Creates PlotGraphics object
- objects - list of PolyXXX objects to make graph
- title - title shown at top of graph
- xLabel - label shown on x-axis
- yLabel - label shown on y-axis
- """
- if type(objects) not in [list,tuple]:
- raise TypeError, "objects argument should be list or tuple"
- self.objects = objects
- self.title= title
- self.xLabel= xLabel
- self.yLabel= yLabel
-
- def boundingBox(self):
- p1, p2 = self.objects[0].boundingBox()
- for o in self.objects[1:]:
- p1o, p2o = o.boundingBox()
- p1 = _numpy.minimum(p1, p1o)
- p2 = _numpy.maximum(p2, p2o)
- return p1, p2
-
- def scaleAndShift(self, scale=(1,1), shift=(0,0)):
- for o in self.objects:
- o.scaleAndShift(scale, shift)
-
- def setPrinterScale(self, scale):
- """Thickens up lines and markers only for printing"""
- self.printerScale= scale
-
- def setXLabel(self, xLabel= ''):
- """Set the X axis label on the graph"""
- self.xLabel= xLabel
-
- def setYLabel(self, yLabel= ''):
- """Set the Y axis label on the graph"""
- self.yLabel= yLabel
-
- def setTitle(self, title= ''):
- """Set the title at the top of graph"""
- self.title= title
-
- def getXLabel(self):
- """Get x axis label string"""
- return self.xLabel
-
- def getYLabel(self):
- """Get y axis label string"""
- return self.yLabel
-
- def getTitle(self, title= ''):
- """Get the title at the top of graph"""
- return self.title
-
- def draw(self, dc):
- for o in self.objects:
- #t=_time.clock() # profile info
- o.draw(dc, self.printerScale)
- #dt= _time.clock()-t
- #print o, "time=", dt
-
- def getSymExtent(self, printerScale):
- """Get max width and height of lines and markers symbols for legend"""
- symExt = self.objects[0].getSymExtent(printerScale)
- for o in self.objects[1:]:
- oSymExt = o.getSymExtent(printerScale)
- symExt = _numpy.maximum(symExt, oSymExt)
- return symExt
-
- def getLegendNames(self):
- """Returns list of legend names"""
- lst = [None]*len(self)
- for i in range(len(self)):
- lst[i]= self.objects[i].getLegend()
- return lst
-
- def __len__(self):
- return len(self.objects)
-
- def __getitem__(self, item):
- return self.objects[item]
-
-
-#-------------------------------------------------------------------------------
-# Main window that you will want to import into your application.
-
-class PlotCanvas(wx.Window):
- """Subclass of a wx.Window to allow simple general plotting
- of data with zoom, labels, and automatic axis scaling."""
-
- def __init__(self, parent, id = -1, pos=wx.DefaultPosition,
- size=wx.DefaultSize, style= wx.DEFAULT_FRAME_STYLE, name= ""):
-
- self.use_persistence=False
- self.alpha=0.3
- self.decimation=10
- self.decim_counter=0
- """Constucts a window, which can be a child of a frame, dialog or
- any other non-control window"""
-
- wx.Window.__init__(self, parent, id, pos, size, style, name)
- self.border = (1,1)
-
- self.SetBackgroundColour("white")
-
- # Create some mouse events for zooming
- self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)
- self.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp)
- self.Bind(wx.EVT_MOTION, self.OnMotion)
- self.Bind(wx.EVT_LEFT_DCLICK, self.OnMouseDoubleClick)
- self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown)
-
- # set curser as cross-hairs
- self.SetCursor(wx.CROSS_CURSOR)
-
- # Things for printing
- self.print_data = wx.PrintData()
- self.print_data.SetPaperId(wx.PAPER_LETTER)
- self.print_data.SetOrientation(wx.LANDSCAPE)
- self.pageSetupData= wx.PageSetupDialogData()
- self.pageSetupData.SetMarginBottomRight((25,25))
- self.pageSetupData.SetMarginTopLeft((25,25))
- self.pageSetupData.SetPrintData(self.print_data)
- self.printerScale = 1
- self.parent= parent
-
- # Zooming variables
- self._zoomInFactor = 0.5
- self._zoomOutFactor = 2
- self._zoomCorner1= _numpy.array([0.0, 0.0]) # left mouse down corner
- self._zoomCorner2= _numpy.array([0.0, 0.0]) # left mouse up corner
- self._zoomEnabled= False
- self._hasDragged= False
-
- # Drawing Variables
- self.last_draw = None
- self._pointScale= 1
- self._pointShift= 0
- self._xSpec= 'auto'
- self._ySpec= 'auto'
- self._gridEnabled= False
- self._legendEnabled= False
- self._xUseScopeTicks= False
-
- # Fonts
- self._fontCache = {}
- self._fontSizeAxis= 10
- self._fontSizeTitle= 15
- self._fontSizeLegend= 7
-
- # pointLabels
- self._pointLabelEnabled= False
- self.last_PointLabel= None
- self._pointLabelFunc= None
- self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
-
- self.Bind(wx.EVT_PAINT, self.OnPaint)
- self.Bind(wx.EVT_SIZE, self.OnSize)
- # OnSize called to make sure the buffer is initialized.
- # This might result in OnSize getting called twice on some
- # platforms at initialization, but little harm done.
- self.OnSize(None) # sets the initial size based on client size
- # UNCONDITIONAL, needed to create self._Buffer
-
-
- def set_use_persistence(self, enable):
- self.use_persistence = enable
-
- def set_persist_alpha(self, persist_alpha):
- self.alpha = persist_alpha
-
-
- # SaveFile
- def SaveFile(self, fileName= ''):
- """Saves the file to the type specified in the extension. If no file
- name is specified a dialog box is provided. Returns True if sucessful,
- otherwise False.
-
- .bmp Save a Windows bitmap file.
- .xbm Save an X bitmap file.
- .xpm Save an XPM bitmap file.
- .png Save a Portable Network Graphics file.
- .jpg Save a Joint Photographic Experts Group file.
- """
- if _string.lower(fileName[-3:]) not in ['bmp','xbm','xpm','png','jpg']:
- dlg1 = wx.FileDialog(
- self,
- "Choose a file with extension bmp, gif, xbm, xpm, png, or jpg", ".", "",
- "BMP files (*.bmp)|*.bmp|XBM files (*.xbm)|*.xbm|XPM file (*.xpm)|*.xpm|PNG files (*.png)|*.png|JPG files (*.jpg)|*.jpg",
- wx.SAVE|wx.OVERWRITE_PROMPT
- )
- try:
- while 1:
- if dlg1.ShowModal() == wx.ID_OK:
- fileName = dlg1.GetPath()
- # Check for proper exension
- if _string.lower(fileName[-3:]) not in ['bmp','xbm','xpm','png','jpg']:
- dlg2 = wx.MessageDialog(self, 'File name extension\n'
- 'must be one of\n'
- 'bmp, xbm, xpm, png, or jpg',
- 'File Name Error', wx.OK | wx.ICON_ERROR)
- try:
- dlg2.ShowModal()
- finally:
- dlg2.Destroy()
- else:
- break # now save file
- else: # exit without saving
- return False
- finally:
- dlg1.Destroy()
-
- # File name has required extension
- fType = _string.lower(fileName[-3:])
- if fType == "bmp":
- tp= wx.BITMAP_TYPE_BMP # Save a Windows bitmap file.
- elif fType == "xbm":
- tp= wx.BITMAP_TYPE_XBM # Save an X bitmap file.
- elif fType == "xpm":
- tp= wx.BITMAP_TYPE_XPM # Save an XPM bitmap file.
- elif fType == "jpg":
- tp= wx.BITMAP_TYPE_JPEG # Save a JPG file.
- else:
- tp= wx.BITMAP_TYPE_PNG # Save a PNG file.
- # Save Bitmap
- res= self._Buffer.SaveFile(fileName, tp)
- return res
-
- def PageSetup(self):
- """Brings up the page setup dialog"""
- data = self.pageSetupData
- data.SetPrintData(self.print_data)
- dlg = wx.PageSetupDialog(self.parent, data)
- try:
- if dlg.ShowModal() == wx.ID_OK:
- data = dlg.GetPageSetupData() # returns wx.PageSetupDialogData
- # updates page parameters from dialog
- self.pageSetupData.SetMarginBottomRight(data.GetMarginBottomRight())
- self.pageSetupData.SetMarginTopLeft(data.GetMarginTopLeft())
- self.pageSetupData.SetPrintData(data.GetPrintData())
- self.print_data=data.GetPrintData() # updates print_data
- finally:
- dlg.Destroy()
-
- def Printout(self, paper=None):
- """Print current plot."""
- if paper != None:
- self.print_data.SetPaperId(paper)
- pdd = wx.PrintDialogData()
- pdd.SetPrintData(self.print_data)
- printer = wx.Printer(pdd)
- out = PlotPrintout(self)
- print_ok = printer.Print(self.parent, out)
- if print_ok:
- self.print_data = printer.GetPrintDialogData().GetPrintData()
- out.Destroy()
-
- def PrintPreview(self):
- """Print-preview current plot."""
- printout = PlotPrintout(self)
- printout2 = PlotPrintout(self)
- self.preview = wx.PrintPreview(printout, printout2, self.print_data)
- if not self.preview.Ok():
- wx.MessageDialog(self, "Print Preview failed.\n" \
- "Check that default printer is configured\n", \
- "Print error", wx.OK|wx.CENTRE).ShowModal()
- self.preview.SetZoom(40)
- # search up tree to find frame instance
- frameInst= self
- while not isinstance(frameInst, wx.Frame):
- frameInst= frameInst.GetParent()
- frame = wx.PreviewFrame(self.preview, frameInst, "Preview")
- frame.Initialize()
- frame.SetPosition(self.GetPosition())
- frame.SetSize((600,550))
- frame.Centre(wx.BOTH)
- frame.Show(True)
-
- def SetFontSizeAxis(self, point= 10):
- """Set the tick and axis label font size (default is 10 point)"""
- self._fontSizeAxis= point
-
- def GetFontSizeAxis(self):
- """Get current tick and axis label font size in points"""
- return self._fontSizeAxis
-
- def SetFontSizeTitle(self, point= 15):
- """Set Title font size (default is 15 point)"""
- self._fontSizeTitle= point
-
- def GetFontSizeTitle(self):
- """Get current Title font size in points"""
- return self._fontSizeTitle
-
- def SetFontSizeLegend(self, point= 7):
- """Set Legend font size (default is 7 point)"""
- self._fontSizeLegend= point
-
- def GetFontSizeLegend(self):
- """Get current Legend font size in points"""
- return self._fontSizeLegend
-
- def SetEnableZoom(self, value):
- """Set True to enable zooming."""
- if value not in [True,False]:
- raise TypeError, "Value should be True or False"
- self._zoomEnabled= value
-
- def GetEnableZoom(self):
- """True if zooming enabled."""
- return self._zoomEnabled
-
- def SetEnableGrid(self, value):
- """Set True to enable grid."""
- if value not in [True,False]:
- raise TypeError, "Value should be True or False"
- self._gridEnabled= value
- self.Redraw()
-
- def GetEnableGrid(self):
- """True if grid enabled."""
- return self._gridEnabled
-
- def SetEnableLegend(self, value):
- """Set True to enable legend."""
- if value not in [True,False]:
- raise TypeError, "Value should be True or False"
- self._legendEnabled= value
- self.Redraw()
-
- def GetEnableLegend(self):
- """True if Legend enabled."""
- return self._legendEnabled
-
- def SetEnablePointLabel(self, value):
- """Set True to enable pointLabel."""
- if value not in [True,False]:
- raise TypeError, "Value should be True or False"
- self._pointLabelEnabled= value
- self.Redraw() #will erase existing pointLabel if present
- self.last_PointLabel = None
-
- def GetEnablePointLabel(self):
- """True if pointLabel enabled."""
- return self._pointLabelEnabled
-
- def SetPointLabelFunc(self, func):
- """Sets the function with custom code for pointLabel drawing
- ******** more info needed ***************
- """
- self._pointLabelFunc= func
-
- def GetPointLabelFunc(self):
- """Returns pointLabel Drawing Function"""
- return self._pointLabelFunc
-
- def Reset(self):
- """Unzoom the plot."""
- self.last_PointLabel = None #reset pointLabel
- if self.last_draw is not None:
- self.Draw(self.last_draw[0])
-
- def ScrollRight(self, units):
- """Move view right number of axis units."""
- self.last_PointLabel = None #reset pointLabel
- if self.last_draw is not None:
- graphics, xAxis, yAxis= self.last_draw
- xAxis= (xAxis[0]+units, xAxis[1]+units)
- self.Draw(graphics,xAxis,yAxis)
-
- def ScrollUp(self, units):
- """Move view up number of axis units."""
- self.last_PointLabel = None #reset pointLabel
- if self.last_draw is not None:
- graphics, xAxis, yAxis= self.last_draw
- yAxis= (yAxis[0]+units, yAxis[1]+units)
- self.Draw(graphics,xAxis,yAxis)
-
- def GetXY(self,event):
- """Takes a mouse event and returns the XY user axis values."""
- x,y= self.PositionScreenToUser(event.GetPosition())
- return x,y
-
- def PositionUserToScreen(self, pntXY):
- """Converts User position to Screen Coordinates"""
- userPos= _numpy.array(pntXY)
- x,y= userPos * self._pointScale + self._pointShift
- return x,y
-
- def PositionScreenToUser(self, pntXY):
- """Converts Screen position to User Coordinates"""
- screenPos= _numpy.array(pntXY)
- x,y= (screenPos-self._pointShift)/self._pointScale
- return x,y
-
- def SetXSpec(self, type= 'auto'):
- """xSpec- defines x axis type. Can be 'none', 'min' or 'auto'
- where:
- 'none' - shows no axis or tick mark values
- 'min' - shows min bounding box values
- 'auto' - rounds axis range to sensible values
- """
- self._xSpec= type
-
- def SetYSpec(self, type= 'auto'):
- """ySpec- defines x axis type. Can be 'none', 'min' or 'auto'
- where:
- 'none' - shows no axis or tick mark values
- 'min' - shows min bounding box values
- 'auto' - rounds axis range to sensible values
- """
- self._ySpec= type
-
- def GetXSpec(self):
- """Returns current XSpec for axis"""
- return self._xSpec
-
- def GetYSpec(self):
- """Returns current YSpec for axis"""
- return self._ySpec
-
- def GetXMaxRange(self):
- """Returns (minX, maxX) x-axis range for displayed graph"""
- graphics= self.last_draw[0]
- p1, p2 = graphics.boundingBox() # min, max points of graphics
- xAxis = self._axisInterval(self._xSpec, p1[0], p2[0]) # in user units
- return xAxis
-
- def GetYMaxRange(self):
- """Returns (minY, maxY) y-axis range for displayed graph"""
- graphics= self.last_draw[0]
- p1, p2 = graphics.boundingBox() # min, max points of graphics
- yAxis = self._axisInterval(self._ySpec, p1[1], p2[1])
- return yAxis
-
- def GetXCurrentRange(self):
- """Returns (minX, maxX) x-axis for currently displayed portion of graph"""
- return self.last_draw[1]
-
- def GetYCurrentRange(self):
- """Returns (minY, maxY) y-axis for currently displayed portion of graph"""
- return self.last_draw[2]
-
- def SetXUseScopeTicks(self, v=False):
- """Always 10 divisions, no labels"""
- self._xUseScopeTicks = v
-
- def GetXUseScopeTicks(self):
- return self._xUseScopeTicks
-
- def Draw(self, graphics, xAxis = None, yAxis = None, dc = None, step=None):
- """Draw objects in graphics with specified x and y axis.
- graphics- instance of PlotGraphics with list of PolyXXX objects
- xAxis - tuple with (min, max) axis range to view
- yAxis - same as xAxis
- dc - drawing context - doesn't have to be specified.
- If it's not, the offscreen buffer is used
- """
- # check Axis is either tuple or none
- if type(xAxis) not in [type(None),tuple]:
- raise TypeError, "xAxis should be None or (minX,maxX)"
- if type(yAxis) not in [type(None),tuple]:
- raise TypeError, "yAxis should be None or (minY,maxY)"
-
- # check case for axis = (a,b) where a==b caused by improper zooms
- if xAxis != None:
- if xAxis[0] == xAxis[1]:
- return
- if yAxis != None:
- if yAxis[0] == yAxis[1]:
- return
-
- if dc == None:
- # sets new dc and clears it
- if self.use_persistence:
- dc = wx.MemoryDC()
- dc.SelectObject(self._Buffer)
- dc.Clear()
- else:
- dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
- dc.Clear()
-
- dc.BeginDrawing()
- # dc.Clear()
-
-
-
- # set font size for every thing but title and legend
- dc.SetFont(self._getFont(self._fontSizeAxis))
-
- # sizes axis to axis type, create lower left and upper right corners of plot
- if xAxis == None or yAxis == None:
- # One or both axis not specified in Draw
- p1, p2 = graphics.boundingBox() # min, max points of graphics
- if xAxis == None:
- xAxis = self._axisInterval(self._xSpec, p1[0], p2[0]) # in user units
- if yAxis == None:
- yAxis = self._axisInterval(self._ySpec, p1[1], p2[1])
- # Adjust bounding box for axis spec
- p1[0],p1[1] = xAxis[0], yAxis[0] # lower left corner user scale (xmin,ymin)
- p2[0],p2[1] = xAxis[1], yAxis[1] # upper right corner user scale (xmax,ymax)
- else:
- # Both axis specified in Draw
- p1= _numpy.array([xAxis[0], yAxis[0]]) # lower left corner user scale (xmin,ymin)
- p2= _numpy.array([xAxis[1], yAxis[1]]) # upper right corner user scale (xmax,ymax)
-
- self.last_draw = (graphics, xAxis, yAxis) # saves most recient values
-
- if False:
- ptx,pty,rectWidth,rectHeight= self._point2ClientCoord(p1, p2)
- #dc.SetPen(wx.Pen(wx.BLACK))
- dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) ) #wx.SOLID wx.TRANSPARENT ) )
- #dc.SetLogicalFunction(wx.INVERT) #wx.XOR wx.INVERT
- dc.DrawRectangle( ptx,pty, rectWidth,rectHeight)
- #dc.SetBrush(wx.Brush( wx.WHITE, wx.SOLID ) )
- #dc.SetLogicalFunction(wx.COPY)
-
- # Get ticks and textExtents for axis if required
- if self._xSpec is not 'none':
- if self._xUseScopeTicks:
- xticks = self._scope_ticks(xAxis[0], xAxis[1])
- else:
- xticks = self._ticks(xAxis[0], xAxis[1])
- xTextExtent = dc.GetTextExtent(xticks[-1][1])# w h of x axis text last number on axis
- else:
- xticks = None
- xTextExtent= (0,0) # No text for ticks
- if self._ySpec is not 'none':
- yticks = self._ticks(yAxis[0], yAxis[1], step)
- yTextExtentBottom= dc.GetTextExtent(yticks[0][1])
- yTextExtentTop = dc.GetTextExtent(yticks[-1][1])
- yTextExtent= (max(yTextExtentBottom[0],yTextExtentTop[0]),
- max(yTextExtentBottom[1],yTextExtentTop[1]))
- else:
- yticks = None
- yTextExtent= (0,0) # No text for ticks
-
- # TextExtents for Title and Axis Labels
- titleWH, xLabelWH, yLabelWH= self._titleLablesWH(dc, graphics)
-
- # TextExtents for Legend
- legendBoxWH, legendSymExt, legendTextExt = self._legendWH(dc, graphics)
-
- # room around graph area
- rhsW= max(xTextExtent[0], legendBoxWH[0]) # use larger of number width or legend width
- lhsW= yTextExtent[0]+ yLabelWH[1]
- bottomH= max(xTextExtent[1], yTextExtent[1]/2.)+ xLabelWH[1]
- topH= yTextExtent[1]/2. + titleWH[1]
- textSize_scale= _numpy.array([rhsW+lhsW,bottomH+topH]) # make plot area smaller by text size
- textSize_shift= _numpy.array([lhsW, bottomH]) # shift plot area by this amount
-
- # drawing title and labels text
- dc.SetFont(self._getFont(self._fontSizeTitle))
- titlePos= (self.plotbox_origin[0]+ lhsW + (self.plotbox_size[0]-lhsW-rhsW)/2.- titleWH[0]/2.,
- self.plotbox_origin[1]- self.plotbox_size[1])
- dc.DrawText(graphics.getTitle(),titlePos[0],titlePos[1])
- dc.SetFont(self._getFont(self._fontSizeAxis))
- xLabelPos= (self.plotbox_origin[0]+ lhsW + (self.plotbox_size[0]-lhsW-rhsW)/2.- xLabelWH[0]/2.,
- self.plotbox_origin[1]- xLabelWH[1])
- dc.DrawText(graphics.getXLabel(),xLabelPos[0],xLabelPos[1])
- yLabelPos= (self.plotbox_origin[0],
- self.plotbox_origin[1]- bottomH- (self.plotbox_size[1]-bottomH-topH)/2.+ yLabelWH[0]/2.)
- if graphics.getYLabel(): # bug fix for Linux
- dc.DrawRotatedText(graphics.getYLabel(),yLabelPos[0],yLabelPos[1],90)
-
- # drawing legend makers and text
- if self._legendEnabled:
- self._drawLegend(dc,graphics,rhsW,topH,legendBoxWH, legendSymExt, legendTextExt)
-
- # allow for scaling and shifting plotted points
- scale = (self.plotbox_size-textSize_scale) / (p2-p1)* _numpy.array((1,-1))
- shift = -p1*scale + self.plotbox_origin + textSize_shift * _numpy.array((1,-1))
- self._pointScale= scale # make available for mouse events
- self._pointShift= shift
-
- #dc.SetLogicalFunction(wx.INVERT) #wx.XOR wx.INVERT
- self._drawAxes(dc, p1, p2, scale, shift, xticks, yticks)
- #dc.SetLogicalFunction(wx.COPY)
-
- graphics.scaleAndShift(scale, shift)
- graphics.setPrinterScale(self.printerScale) # thicken up lines and markers if printing
-
- # set clipping area so drawing does not occur outside axis box
- ptx,pty,rectWidth,rectHeight= self._point2ClientCoord(p1, p2)
- dc.SetClippingRegion(ptx,pty,rectWidth,rectHeight)
- # Draw the lines and markers
- #start = _time.clock()
-
- graphics.draw(dc)
- # print "entire graphics drawing took: %f second"%(_time.clock() - start)
- # remove the clipping region
- dc.DestroyClippingRegion()
- dc.EndDrawing()
-
-
- if self.use_persistence:
- dc=None
- self._Buffer.CopyToBuffer(self._Bufferarray) #, format=wx.BitmapBufferFormat_RGB, stride=-1)
- ## do the IIR filter
- alpha_int=int(float(self.alpha*256))
- if True:
- _numpy.add(self._Bufferarray,0,self._Buffer3array)
- _numpy.multiply(self._Buffer3array,alpha_int,self._Buffer3array)
- _numpy.multiply(self._Buffer2array,(256-alpha_int),self._Buffer2array)
- _numpy.add(self._Buffer3array,self._Buffer2array,self._Buffer2array)
- _numpy.right_shift(self._Buffer2array,8,self._Buffer2array)
- elif False:
- self._Buffer2array=(self._Bufferarray.astype(_numpy.uint32) *alpha_int + self._Buffer2array*(256-alpha_int)).__rshift__(8)
- elif False:
- self._Buffer2array *=(256-alpha_int)
- self._Buffer2array +=self._Bufferarray.astype(_numpy.uint32)*alpha_int
- self._Buffer2array /=256
-
- ##copy back to image buffer
- self._Buffer2.CopyFromBuffer(self._Buffer2array.astype(_numpy.uint8)) #, format=wx.BitmapBufferFormat_RGB, stride=-1)
-
- #draw to the screen
- #self.decim_counter=self.decim_counter+1
- if True: #self.decim_counter>self.decimation:
- #self.decim_counter=0
- dc2 = wx.ClientDC( self )
- dc2.BeginDrawing()
- dc2.DrawBitmap(self._Buffer2, 0, 0, False)
- #dc2.DrawBitmap(self._Buffer, 0, 0, False)
- dc2.EndDrawing()
-
- def Redraw(self, dc= None):
- """Redraw the existing plot."""
- if self.last_draw is not None:
- graphics, xAxis, yAxis= self.last_draw
- self.Draw(graphics,xAxis,yAxis,dc)
-
- def Clear(self):
- """Erase the window."""
- self.last_PointLabel = None #reset pointLabel
- dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
- dc.Clear()
- self.last_draw = None
-
- def Zoom(self, Center, Ratio):
- """ Zoom on the plot
- Centers on the X,Y coords given in Center
- Zooms by the Ratio = (Xratio, Yratio) given
- """
- self.last_PointLabel = None #reset maker
- x,y = Center
- if self.last_draw != None:
- (graphics, xAxis, yAxis) = self.last_draw
- w = (xAxis[1] - xAxis[0]) * Ratio[0]
- h = (yAxis[1] - yAxis[0]) * Ratio[1]
- xAxis = ( x - w/2, x + w/2 )
- yAxis = ( y - h/2, y + h/2 )
- self.Draw(graphics, xAxis, yAxis)
-
- def GetClosestPoints(self, pntXY, pointScaled= True):
- """Returns list with
- [curveNumber, legend, index of closest point, pointXY, scaledXY, distance]
- list for each curve.
- Returns [] if no curves are being plotted.
-
- x, y in user coords
- if pointScaled == True based on screen coords
- if pointScaled == False based on user coords
- """
- if self.last_draw == None:
- #no graph available
- return []
- graphics, xAxis, yAxis= self.last_draw
- l = []
- for curveNum,obj in enumerate(graphics):
- #check there are points in the curve
- if len(obj.points) == 0:
- continue #go to next obj
- #[curveNumber, legend, index of closest point, pointXY, scaledXY, distance]
- cn = [curveNum]+ [obj.getLegend()]+ obj.getClosestPoint( pntXY, pointScaled)
- l.append(cn)
- return l
-
- def GetClosetPoint(self, pntXY, pointScaled= True):
- """Returns list with
- [curveNumber, legend, index of closest point, pointXY, scaledXY, distance]
- list for only the closest curve.
- Returns [] if no curves are being plotted.
-
- x, y in user coords
- if pointScaled == True based on screen coords
- if pointScaled == False based on user coords
- """
- #closest points on screen based on screen scaling (pointScaled= True)
- #list [curveNumber, index, pointXY, scaledXY, distance] for each curve
- closestPts= self.GetClosestPoints(pntXY, pointScaled)
- if closestPts == []:
- return [] #no graph present
- #find one with least distance
- dists = [c[-1] for c in closestPts]
- mdist = min(dists) #Min dist
- i = dists.index(mdist) #index for min dist
- return closestPts[i] #this is the closest point on closest curve
-
- def UpdatePointLabel(self, mDataDict):
- """Updates the pointLabel point on screen with data contained in
- mDataDict.
-
- mDataDict will be passed to your function set by
- SetPointLabelFunc. It can contain anything you
- want to display on the screen at the scaledXY point
- you specify.
-
- This function can be called from parent window with onClick,
- onMotion events etc.
- """
- if self.last_PointLabel != None:
- #compare pointXY
- if mDataDict["pointXY"] != self.last_PointLabel["pointXY"]:
- #closest changed
- self._drawPointLabel(self.last_PointLabel) #erase old
- self._drawPointLabel(mDataDict) #plot new
- else:
- #just plot new with no erase
- self._drawPointLabel(mDataDict) #plot new
- #save for next erase
- self.last_PointLabel = mDataDict
-
- # event handlers **********************************
- def OnMotion(self, event):
- if self._zoomEnabled and event.LeftIsDown():
- if self._hasDragged:
- self._drawRubberBand(self._zoomCorner1, self._zoomCorner2) # remove old
- else:
- self._hasDragged= True
- self._zoomCorner2[0], self._zoomCorner2[1] = self.GetXY(event)
- self._drawRubberBand(self._zoomCorner1, self._zoomCorner2) # add new
-
- def OnMouseLeftDown(self,event):
- self._zoomCorner1[0], self._zoomCorner1[1]= self.GetXY(event)
-
- def OnMouseLeftUp(self, event):
- if self._zoomEnabled:
- if self._hasDragged == True:
- self._drawRubberBand(self._zoomCorner1, self._zoomCorner2) # remove old
- self._zoomCorner2[0], self._zoomCorner2[1]= self.GetXY(event)
- self._hasDragged = False # reset flag
- minX, minY= _numpy.minimum( self._zoomCorner1, self._zoomCorner2)
- maxX, maxY= _numpy.maximum( self._zoomCorner1, self._zoomCorner2)
- self.last_PointLabel = None #reset pointLabel
- if self.last_draw != None:
- self.Draw(self.last_draw[0], xAxis = (minX,maxX), yAxis = (minY,maxY), dc = None)
- #else: # A box has not been drawn, zoom in on a point
- ## this interfered with the double click, so I've disables it.
- # X,Y = self.GetXY(event)
- # self.Zoom( (X,Y), (self._zoomInFactor,self._zoomInFactor) )
-
- def OnMouseDoubleClick(self,event):
- if self._zoomEnabled:
- self.Reset()
-
- def OnMouseRightDown(self,event):
- if self._zoomEnabled:
- X,Y = self.GetXY(event)
- self.Zoom( (X,Y), (self._zoomOutFactor, self._zoomOutFactor) )
-
- def OnPaint(self, event):
- # All that is needed here is to draw the buffer to screen
- if self.last_PointLabel != None:
- self._drawPointLabel(self.last_PointLabel) #erase old
- self.last_PointLabel = None
-
- #paint current buffer to screen
- dc = wx.BufferedPaintDC(self, self._Buffer)
-
- def OnSize(self,event):
- # The Buffer init is done here, to make sure the buffer is always
- # the same size as the Window
- Size = self.GetClientSize()
-
- # Make new offscreen bitmap: this bitmap will always have the
- # current drawing in it, so it can be used to save the image to
- # a file, or whatever.
- self._Buffer = wx.EmptyBitmap(Size[0],Size[1],24)
-
-
- if True: #self.use_persistence:
- #self._Bufferarray = _numpy.zeros((Size[0], Size[1],3), dtype=_numpy.uint8)
- self._Bufferarray = _numpy.zeros((Size[0]* Size[1]*3), dtype=_numpy.uint8)
-
- # Make new second offscreen bitmap: this bitmap will always have the
- # last drawing in it, so it can be used to do display time dependent processing
- # like averaging (IIR) or show differences between updates
- self._Buffer2 = wx.EmptyBitmap(Size[0],Size[1],24)
- # now the extra buffers for the IIR processing
- # note the different datatype uint32
- self._Buffer2array = _numpy.zeros((Size[0]* Size[1]*3), dtype=_numpy.uint32) #dtype=_numpy.float
- self._Buffer3array = _numpy.zeros((Size[0]* Size[1]*3), dtype=_numpy.uint32) #dtype=_numpy.float
- # optional you can set the ufunct buffer size to improve speed
- #_numpy.setbufsize(16*((Size[0]* Size[1]*3)/16 +1))
- self._setSize()
-
- self.last_PointLabel = None #reset pointLabel
-
- if self.last_draw is None:
- self.Clear()
- else:
- graphics, xSpec, ySpec = self.last_draw
- self.Draw(graphics,xSpec,ySpec)
-
- def OnLeave(self, event):
- """Used to erase pointLabel when mouse outside window"""
- if self.last_PointLabel != None:
- self._drawPointLabel(self.last_PointLabel) #erase old
- self.last_PointLabel = None
-
-
- # Private Methods **************************************************
- def _setSize(self, width=None, height=None):
- """DC width and height."""
- if width == None:
- (self.width,self.height) = self.GetClientSize()
- else:
- self.width, self.height= width,height
- self.plotbox_size = 0.97*_numpy.array([self.width, self.height])
- xo = 0.5*(self.width-self.plotbox_size[0])
- yo = self.height-0.5*(self.height-self.plotbox_size[1])
- self.plotbox_origin = _numpy.array([xo, yo])
-
- def _setPrinterScale(self, scale):
- """Used to thicken lines and increase marker size for print out."""
- # line thickness on printer is very thin at 600 dot/in. Markers small
- self.printerScale= scale
-
- def _printDraw(self, printDC):
- """Used for printing."""
- if self.last_draw != None:
- graphics, xSpec, ySpec= self.last_draw
- self.Draw(graphics,xSpec,ySpec,printDC)
-
- def _drawPointLabel(self, mDataDict):
- """Draws and erases pointLabels"""
- width = self._Buffer.GetWidth()
- height = self._Buffer.GetHeight()
- tmp_Buffer = wx.EmptyBitmap(width,height)
- dcs = wx.MemoryDC()
- dcs.SelectObject(tmp_Buffer)
- dcs.Clear()
- dcs.BeginDrawing()
- self._pointLabelFunc(dcs,mDataDict) #custom user pointLabel function
- dcs.EndDrawing()
-
- dc = wx.ClientDC( self )
- #this will erase if called twice
- dc.Blit(0, 0, width, height, dcs, 0, 0, wx.EQUIV) #(NOT src) XOR dst
-
-
- def _drawLegend(self,dc,graphics,rhsW,topH,legendBoxWH, legendSymExt, legendTextExt):
- """Draws legend symbols and text"""
- # top right hand corner of graph box is ref corner
- trhc= self.plotbox_origin+ (self.plotbox_size-[rhsW,topH])*[1,-1]
- legendLHS= .091* legendBoxWH[0] # border space between legend sym and graph box
- lineHeight= max(legendSymExt[1], legendTextExt[1]) * 1.1 #1.1 used as space between lines
- dc.SetFont(self._getFont(self._fontSizeLegend))
- for i in range(len(graphics)):
- o = graphics[i]
- s= i*lineHeight
- if isinstance(o,PolyMarker):
- # draw marker with legend
- pnt= (trhc[0]+legendLHS+legendSymExt[0]/2., trhc[1]+s+lineHeight/2.)
- o.draw(dc, self.printerScale, coord= _numpy.array([pnt]))
- elif isinstance(o,PolyLine):
- # draw line with legend
- pnt1= (trhc[0]+legendLHS, trhc[1]+s+lineHeight/2.)
- pnt2= (trhc[0]+legendLHS+legendSymExt[0], trhc[1]+s+lineHeight/2.)
- o.draw(dc, self.printerScale, coord= _numpy.array([pnt1,pnt2]))
- else:
- raise TypeError, "object is neither PolyMarker or PolyLine instance"
- # draw legend txt
- pnt= (trhc[0]+legendLHS+legendSymExt[0], trhc[1]+s+lineHeight/2.-legendTextExt[1]/2)
- dc.DrawText(o.getLegend(),pnt[0],pnt[1])
- dc.SetFont(self._getFont(self._fontSizeAxis)) # reset
-
- def _titleLablesWH(self, dc, graphics):
- """Draws Title and labels and returns width and height for each"""
- # TextExtents for Title and Axis Labels
- dc.SetFont(self._getFont(self._fontSizeTitle))
- title= graphics.getTitle()
- titleWH= dc.GetTextExtent(title)
- dc.SetFont(self._getFont(self._fontSizeAxis))
- xLabel, yLabel= graphics.getXLabel(),graphics.getYLabel()
- xLabelWH= dc.GetTextExtent(xLabel)
- yLabelWH= dc.GetTextExtent(yLabel)
- return titleWH, xLabelWH, yLabelWH
-
- def _legendWH(self, dc, graphics):
- """Returns the size in screen units for legend box"""
- if self._legendEnabled != True:
- legendBoxWH= symExt= txtExt= (0,0)
- else:
- # find max symbol size
- symExt= graphics.getSymExtent(self.printerScale)
- # find max legend text extent
- dc.SetFont(self._getFont(self._fontSizeLegend))
- txtList= graphics.getLegendNames()
- txtExt= dc.GetTextExtent(txtList[0])
- for txt in graphics.getLegendNames()[1:]:
- txtExt= _numpy.maximum(txtExt,dc.GetTextExtent(txt))
- maxW= symExt[0]+txtExt[0]
- maxH= max(symExt[1],txtExt[1])
- # padding .1 for lhs of legend box and space between lines
- maxW= maxW* 1.1
- maxH= maxH* 1.1 * len(txtList)
- dc.SetFont(self._getFont(self._fontSizeAxis))
- legendBoxWH= (maxW,maxH)
- return (legendBoxWH, symExt, txtExt)
-
- def _drawRubberBand(self, corner1, corner2):
- """Draws/erases rect box from corner1 to corner2"""
- ptx,pty,rectWidth,rectHeight= self._point2ClientCoord(corner1, corner2)
- # draw rectangle
- dc = wx.ClientDC( self )
- dc.BeginDrawing()
- dc.SetPen(wx.Pen(wx.BLACK))
- dc.SetBrush(wx.Brush( wx.WHITE, wx.TRANSPARENT ) )
- dc.SetLogicalFunction(wx.INVERT)
- dc.DrawRectangle( ptx,pty, rectWidth,rectHeight)
- dc.SetLogicalFunction(wx.COPY)
- dc.EndDrawing()
-
- def _getFont(self,size):
- """Take font size, adjusts if printing and returns wx.Font"""
- s = size*self.printerScale
- of = self.GetFont()
- # Linux speed up to get font from cache rather than X font server
- key = (int(s), of.GetFamily (), of.GetStyle (), of.GetWeight ())
- font = self._fontCache.get (key, None)
- if font:
- return font # yeah! cache hit
- else:
- font = wx.Font(int(s), of.GetFamily(), of.GetStyle(), of.GetWeight())
- self._fontCache[key] = font
- return font
-
-
- def _point2ClientCoord(self, corner1, corner2):
- """Converts user point coords to client screen int coords x,y,width,height"""
- c1= _numpy.array(corner1)
- c2= _numpy.array(corner2)
- # convert to screen coords
- pt1= c1*self._pointScale+self._pointShift
- pt2= c2*self._pointScale+self._pointShift
- # make height and width positive
- pul= _numpy.minimum(pt1,pt2) # Upper left corner
- plr= _numpy.maximum(pt1,pt2) # Lower right corner
- rectWidth, rectHeight= plr-pul
- ptx,pty= pul
- return ptx, pty, rectWidth, rectHeight
-
- def _axisInterval(self, spec, lower, upper):
- """Returns sensible axis range for given spec"""
- if spec == 'none' or spec == 'min':
- if lower == upper:
- return lower-0.5, upper+0.5
- else:
- return lower, upper
- elif spec == 'auto':
- range = upper-lower
- # if range == 0.:
- if abs(range) < 1e-36:
- return lower-0.5, upper+0.5
- log = _numpy.log10(range)
- power = _numpy.floor(log)
- fraction = log-power
- if fraction <= 0.05:
- power = power-1
- grid = 10.**power
- lower = lower - lower % grid
- mod = upper % grid
- if mod != 0:
- upper = upper - mod + grid
- return lower, upper
- elif type(spec) == type(()):
- lower, upper = spec
- if lower <= upper:
- return lower, upper
- else:
- return upper, lower
- else:
- raise ValueError, str(spec) + ': illegal axis specification'
-
- def _drawAxes(self, dc, p1, p2, scale, shift, xticks, yticks):
-
- penWidth= self.printerScale # increases thickness for printing only
- dc.SetPen(wx.Pen(wx.NamedColour('BLACK'), penWidth))
-
- # set length of tick marks--long ones make grid
- if self._gridEnabled:
- x,y,width,height= self._point2ClientCoord(p1,p2)
- yTickLength= width/2.0 +1
- xTickLength= height/2.0 +1
- else:
- yTickLength= 3 * self.printerScale # lengthens lines for printing
- xTickLength= 3 * self.printerScale
-
- if self._xSpec is not 'none':
- lower, upper = p1[0],p2[0]
- text = 1
- for y, d in [(p1[1], -xTickLength), (p2[1], xTickLength)]: # miny, maxy and tick lengths
- a1 = scale*_numpy.array([lower, y])+shift
- a2 = scale*_numpy.array([upper, y])+shift
- dc.DrawLine(a1[0],a1[1],a2[0],a2[1]) # draws upper and lower axis line
- for x, label in xticks:
- pt = scale*_numpy.array([x, y])+shift
- dc.DrawLine(pt[0],pt[1],pt[0],pt[1] + d) # draws tick mark d units
- if text:
- dc.DrawText(label,pt[0],pt[1])
- text = 0 # axis values not drawn on top side
-
- if self._ySpec is not 'none':
- lower, upper = p1[1],p2[1]
- text = 1
- h = dc.GetCharHeight()
- for x, d in [(p1[0], -yTickLength), (p2[0], yTickLength)]:
- a1 = scale*_numpy.array([x, lower])+shift
- a2 = scale*_numpy.array([x, upper])+shift
- dc.DrawLine(a1[0],a1[1],a2[0],a2[1])
- for y, label in yticks:
- pt = scale*_numpy.array([x, y])+shift
- dc.DrawLine(pt[0],pt[1],pt[0]-d,pt[1])
- if text:
- dc.DrawText(label,pt[0]-dc.GetTextExtent(label)[0],
- pt[1]-0.5*h)
- text = 0 # axis values not drawn on right side
-
- def _ticks(self, lower, upper, step=None):
- ideal = (upper-lower)/7.
- log = _numpy.log10(ideal)
- power = _numpy.floor(log)
- fraction = log-power
- factor = 1.
- error = fraction
- for f, lf in self._multiples:
- e = _numpy.fabs(fraction-lf)
- if e < error:
- error = e
- factor = f
- grid = factor * 10.**power
- if power > 4 or power < -4:
- format = '%+7.1e'
- elif power >= 0:
- digits = max(1, int(power))
- format = '%' + `digits`+'.0f'
- else:
- digits = -int(power)
- format = '%'+`digits+2`+'.'+`digits`+'f'
- #force grid when step is not None
- if step is not None: grid = step
- ticks = []
- t = -grid*_numpy.floor(-lower/grid)
- while t <= upper:
- if t == -0: t = 0 #remove neg zero condition
- ticks.append( (t, format % (t,)) )
- t = t + grid
- return ticks
-
- def _scope_ticks (self, lower, upper):
- '''Always 10 divisions, no labels'''
- grid = (upper - lower) / 10.0
- ticks = []
- t = lower
- while t <= upper:
- ticks.append( (t, ""))
- t = t + grid
- return ticks
-
- _multiples = [(2., _numpy.log10(2.)), (5., _numpy.log10(5.))]
-
-
-#-------------------------------------------------------------------------------
-# Used to layout the printer page
-
-class PlotPrintout(wx.Printout):
- """Controls how the plot is made in printing and previewing"""
- # Do not change method names in this class,
- # we have to override wx.Printout methods here!
- def __init__(self, graph):
- """graph is instance of plotCanvas to be printed or previewed"""
- wx.Printout.__init__(self)
- self.graph = graph
-
- def HasPage(self, page):
- if page == 1:
- return True
- else:
- return False
-
- def GetPageInfo(self):
- return (1, 1, 1, 1) # disable page numbers
-
- def OnPrintPage(self, page):
- dc = self.GetDC() # allows using floats for certain functions
-## print "PPI Printer",self.GetPPIPrinter()
-## print "PPI Screen", self.GetPPIScreen()
-## print "DC GetSize", dc.GetSize()
-## print "GetPageSizePixels", self.GetPageSizePixels()
- # Note PPIScreen does not give the correct number
- # Calulate everything for printer and then scale for preview
- PPIPrinter= self.GetPPIPrinter() # printer dots/inch (w,h)
- #PPIScreen= self.GetPPIScreen() # screen dots/inch (w,h)
- dcSize= dc.GetSize() # DC size
- pageSize= self.GetPageSizePixels() # page size in terms of pixcels
- clientDcSize= self.graph.GetClientSize()
-
- # find what the margins are (mm)
- margLeftSize,margTopSize= self.graph.pageSetupData.GetMarginTopLeft()
- margRightSize, margBottomSize= self.graph.pageSetupData.GetMarginBottomRight()
-
- # calculate offset and scale for dc
- pixLeft= margLeftSize*PPIPrinter[0]/25.4 # mm*(dots/in)/(mm/in)
- pixRight= margRightSize*PPIPrinter[0]/25.4
- pixTop= margTopSize*PPIPrinter[1]/25.4
- pixBottom= margBottomSize*PPIPrinter[1]/25.4
-
- plotAreaW= pageSize[0]-(pixLeft+pixRight)
- plotAreaH= pageSize[1]-(pixTop+pixBottom)
-
- # ratio offset and scale to screen size if preview
- if self.IsPreview():
- ratioW= float(dcSize[0])/pageSize[0]
- ratioH= float(dcSize[1])/pageSize[1]
- pixLeft *= ratioW
- pixTop *= ratioH
- plotAreaW *= ratioW
- plotAreaH *= ratioH
-
- # rescale plot to page or preview plot area
- self.graph._setSize(plotAreaW,plotAreaH)
-
- # Set offset and scale
- dc.SetDeviceOrigin(pixLeft,pixTop)
-
- # Thicken up pens and increase marker size for printing
- ratioW= float(plotAreaW)/clientDcSize[0]
- ratioH= float(plotAreaH)/clientDcSize[1]
- aveScale= (ratioW+ratioH)/2
- self.graph._setPrinterScale(aveScale) # tickens up pens for printing
-
- self.graph._printDraw(dc)
- # rescale back to original
- self.graph._setSize()
- self.graph._setPrinterScale(1)
- self.graph.Redraw() #to get point label scale and shift correct
-
- return True
-
-
-
-
-#---------------------------------------------------------------------------
-# if running standalone...
-#
-# ...a sample implementation using the above
-#
-
-def _draw1Objects():
- # 100 points sin function, plotted as green circles
- data1 = 2.*_numpy.pi*_numpy.arange(200)/200.
- data1.shape = (100, 2)
- data1[:,1] = _numpy.sin(data1[:,0])
- markers1 = PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1)
-
- # 50 points cos function, plotted as red line
- data1 = 2.*_numpy.pi*_numpy.arange(100)/100.
- data1.shape = (50,2)
- data1[:,1] = _numpy.cos(data1[:,0])
- lines = PolyLine(data1, legend= 'Red Line', colour='red')
-
- # A few more points...
- pi = _numpy.pi
- markers2 = PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
- (3.*pi/4., -1)], legend='Cross Legend', colour='blue',
- marker='cross')
-
- return PlotGraphics([markers1, lines, markers2],"Graph Title", "X Axis", "Y Axis")
-
-def _draw2Objects():
- # 100 points sin function, plotted as green dots
- data1 = 2.*_numpy.pi*_numpy.arange(200)/200.
- data1.shape = (100, 2)
- data1[:,1] = _numpy.sin(data1[:,0])
- line1 = PolyLine(data1, legend='Green Line', colour='green', width=6, style=wx.DOT)
-
- # 50 points cos function, plotted as red dot-dash
- data1 = 2.*_numpy.pi*_numpy.arange(100)/100.
- data1.shape = (50,2)
- data1[:,1] = _numpy.cos(data1[:,0])
- line2 = PolyLine(data1, legend='Red Line', colour='red', width=3, style= wx.DOT_DASH)
-
- # A few more points...
- pi = _numpy.pi
- markers1 = PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
- (3.*pi/4., -1)], legend='Cross Hatch Square', colour='blue', width= 3, size= 6,
- fillcolour= 'red', fillstyle= wx.CROSSDIAG_HATCH,
- marker='square')
-
- return PlotGraphics([markers1, line1, line2], "Big Markers with Different Line Styles")
-
-def _draw3Objects():
- markerList= ['circle', 'dot', 'square', 'triangle', 'triangle_down',
- 'cross', 'plus', 'circle']
- m=[]
- for i in range(len(markerList)):
- m.append(PolyMarker([(2*i+.5,i+.5)], legend=markerList[i], colour='blue',
- marker=markerList[i]))
- return PlotGraphics(m, "Selection of Markers", "Minimal Axis", "No Axis")
-
-def _draw4Objects():
- # 25,000 point line
- data1 = _numpy.arange(5e5,1e6,10)
- data1.shape = (25000, 2)
- line1 = PolyLine(data1, legend='Wide Line', colour='green', width=5)
-
- # A few more points...
- markers2 = PolyMarker(data1, legend='Square', colour='blue',
- marker='square')
- return PlotGraphics([line1, markers2], "25,000 Points", "Value X", "")
-
-def _draw5Objects():
- # Empty graph with axis defined but no points/lines
- points=[]
- line1 = PolyLine(points, legend='Wide Line', colour='green', width=5)
- return PlotGraphics([line1], "Empty Plot With Just Axes", "Value X", "Value Y")
-
-def _draw6Objects():
- # Bar graph
- points1=[(1,0), (1,10)]
- line1 = PolyLine(points1, colour='green', legend='Feb.', width=10)
- points1g=[(2,0), (2,4)]
- line1g = PolyLine(points1g, colour='red', legend='Mar.', width=10)
- points1b=[(3,0), (3,6)]
- line1b = PolyLine(points1b, colour='blue', legend='Apr.', width=10)
-
- points2=[(4,0), (4,12)]
- line2 = PolyLine(points2, colour='Yellow', legend='May', width=10)
- points2g=[(5,0), (5,8)]
- line2g = PolyLine(points2g, colour='orange', legend='June', width=10)
- points2b=[(6,0), (6,4)]
- line2b = PolyLine(points2b, colour='brown', legend='July', width=10)
-
- return PlotGraphics([line1, line1g, line1b, line2, line2g, line2b],
- "Bar Graph - (Turn on Grid, Legend)", "Months", "Number of Students")
-
-
-class TestFrame(wx.Frame):
- def __init__(self, parent, id, title):
- wx.Frame.__init__(self, parent, id, title,
- wx.DefaultPosition, (600, 400))
-
- # Now Create the menu bar and items
- self.mainmenu = wx.MenuBar()
-
- menu = wx.Menu()
- menu.Append(200, 'Page Setup...', 'Setup the printer page')
- self.Bind(wx.EVT_MENU, self.OnFilePageSetup, id=200)
-
- menu.Append(201, 'Print Preview...', 'Show the current plot on page')
- self.Bind(wx.EVT_MENU, self.OnFilePrintPreview, id=201)
-
- menu.Append(202, 'Print...', 'Print the current plot')
- self.Bind(wx.EVT_MENU, self.OnFilePrint, id=202)
-
- menu.Append(203, 'Save Plot...', 'Save current plot')
- self.Bind(wx.EVT_MENU, self.OnSaveFile, id=203)
-
- menu.Append(205, 'E&xit', 'Enough of this already!')
- self.Bind(wx.EVT_MENU, self.OnFileExit, id=205)
- self.mainmenu.Append(menu, '&File')
-
- menu = wx.Menu()
- menu.Append(206, 'Draw1', 'Draw plots1')
- self.Bind(wx.EVT_MENU,self.OnPlotDraw1, id=206)
- menu.Append(207, 'Draw2', 'Draw plots2')
- self.Bind(wx.EVT_MENU,self.OnPlotDraw2, id=207)
- menu.Append(208, 'Draw3', 'Draw plots3')
- self.Bind(wx.EVT_MENU,self.OnPlotDraw3, id=208)
- menu.Append(209, 'Draw4', 'Draw plots4')
- self.Bind(wx.EVT_MENU,self.OnPlotDraw4, id=209)
- menu.Append(210, 'Draw5', 'Draw plots5')
- self.Bind(wx.EVT_MENU,self.OnPlotDraw5, id=210)
- menu.Append(260, 'Draw6', 'Draw plots6')
- self.Bind(wx.EVT_MENU,self.OnPlotDraw6, id=260)
-
-
- menu.Append(211, '&Redraw', 'Redraw plots')
- self.Bind(wx.EVT_MENU,self.OnPlotRedraw, id=211)
- menu.Append(212, '&Clear', 'Clear canvas')
- self.Bind(wx.EVT_MENU,self.OnPlotClear, id=212)
- menu.Append(213, '&Scale', 'Scale canvas')
- self.Bind(wx.EVT_MENU,self.OnPlotScale, id=213)
- menu.Append(214, 'Enable &Zoom', 'Enable Mouse Zoom', kind=wx.ITEM_CHECK)
- self.Bind(wx.EVT_MENU,self.OnEnableZoom, id=214)
- menu.Append(215, 'Enable &Grid', 'Turn on Grid', kind=wx.ITEM_CHECK)
- self.Bind(wx.EVT_MENU,self.OnEnableGrid, id=215)
- menu.Append(220, 'Enable &Legend', 'Turn on Legend', kind=wx.ITEM_CHECK)
- self.Bind(wx.EVT_MENU,self.OnEnableLegend, id=220)
- menu.Append(222, 'Enable &Point Label', 'Show Closest Point', kind=wx.ITEM_CHECK)
- self.Bind(wx.EVT_MENU,self.OnEnablePointLabel, id=222)
-
- menu.Append(225, 'Scroll Up 1', 'Move View Up 1 Unit')
- self.Bind(wx.EVT_MENU,self.OnScrUp, id=225)
- menu.Append(230, 'Scroll Rt 2', 'Move View Right 2 Units')
- self.Bind(wx.EVT_MENU,self.OnScrRt, id=230)
- menu.Append(235, '&Plot Reset', 'Reset to original plot')
- self.Bind(wx.EVT_MENU,self.OnReset, id=235)
-
- self.mainmenu.Append(menu, '&Plot')
-
- menu = wx.Menu()
- menu.Append(300, '&About', 'About this thing...')
- self.Bind(wx.EVT_MENU, self.OnHelpAbout, id=300)
- self.mainmenu.Append(menu, '&Help')
-
- self.SetMenuBar(self.mainmenu)
-
- # A status bar to tell people what's happening
- self.CreateStatusBar(1)
-
- self.client = PlotCanvas(self)
- #define the function for drawing pointLabels
- self.client.SetPointLabelFunc(self.DrawPointLabel)
- # Create mouse event for showing cursor coords in status bar
- self.client.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)
- # Show closest point when enabled
- self.client.Bind(wx.EVT_MOTION, self.OnMotion)
-
- self.Show(True)
-
- def DrawPointLabel(self, dc, mDataDict):
- """This is the fuction that defines how the pointLabels are plotted
- dc - DC that will be passed
- mDataDict - Dictionary of data that you want to use for the pointLabel
-
- As an example I have decided I want a box at the curve point
- with some text information about the curve plotted below.
- Any wxDC method can be used.
- """
- # ----------
- dc.SetPen(wx.Pen(wx.BLACK))
- dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
-
- sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
- dc.DrawRectangle( sx-5,sy-5, 10, 10) #10by10 square centered on point
- px,py = mDataDict["pointXY"]
- cNum = mDataDict["curveNum"]
- pntIn = mDataDict["pIndex"]
- legend = mDataDict["legend"]
- #make a string to display
- s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
- dc.DrawText(s, sx , sy+1)
- # -----------
-
- def OnMouseLeftDown(self,event):
- s= "Left Mouse Down at Point: (%.4f, %.4f)" % self.client.GetXY(event)
- self.SetStatusText(s)
- event.Skip() #allows plotCanvas OnMouseLeftDown to be called
-
- def OnMotion(self, event):
- #show closest point (when enbled)
- if self.client.GetEnablePointLabel() == True:
- #make up dict with info for the pointLabel
- #I've decided to mark the closest point on the closest curve
- dlst= self.client.GetClosetPoint( self.client.GetXY(event), pointScaled= True)
- if dlst != []: #returns [] if none
- curveNum, legend, pIndex, pointXY, scaledXY, distance = dlst
- #make up dictionary to pass to my user function (see DrawPointLabel)
- mDataDict= {"curveNum":curveNum, "legend":legend, "pIndex":pIndex,\
- "pointXY":pointXY, "scaledXY":scaledXY}
- #pass dict to update the pointLabel
- self.client.UpdatePointLabel(mDataDict)
- event.Skip() #go to next handler
-
- def OnFilePageSetup(self, event):
- self.client.PageSetup()
-
- def OnFilePrintPreview(self, event):
- self.client.PrintPreview()
-
- def OnFilePrint(self, event):
- self.client.Printout()
-
- def OnSaveFile(self, event):
- self.client.SaveFile()
-
- def OnFileExit(self, event):
- self.Close()
-
- def OnPlotDraw1(self, event):
- self.resetDefaults()
- self.client.Draw(_draw1Objects())
-
- def OnPlotDraw2(self, event):
- self.resetDefaults()
- self.client.Draw(_draw2Objects())
-
- def OnPlotDraw3(self, event):
- self.resetDefaults()
- self.client.SetFont(wx.Font(10,wx.SCRIPT,wx.NORMAL,wx.NORMAL))
- self.client.SetFontSizeAxis(20)
- self.client.SetFontSizeLegend(12)
- self.client.SetXSpec('min')
- self.client.SetYSpec('none')
- self.client.Draw(_draw3Objects())
-
- def OnPlotDraw4(self, event):
- self.resetDefaults()
- drawObj= _draw4Objects()
- self.client.Draw(drawObj)
-## # profile
-## start = _time.clock()
-## for x in range(10):
-## self.client.Draw(drawObj)
-## print "10 plots of Draw4 took: %f sec."%(_time.clock() - start)
-## # profile end
-
- def OnPlotDraw5(self, event):
- # Empty plot with just axes
- self.resetDefaults()
- drawObj= _draw5Objects()
- # make the axis X= (0,5), Y=(0,10)
- # (default with None is X= (-1,1), Y= (-1,1))
- self.client.Draw(drawObj, xAxis= (0,5), yAxis= (0,10))
-
- def OnPlotDraw6(self, event):
- #Bar Graph Example
- self.resetDefaults()
- #self.client.SetEnableLegend(True) #turn on Legend
- #self.client.SetEnableGrid(True) #turn on Grid
- self.client.SetXSpec('none') #turns off x-axis scale
- self.client.SetYSpec('auto')
- self.client.Draw(_draw6Objects(), xAxis= (0,7))
-
- def OnPlotRedraw(self,event):
- self.client.Redraw()
-
- def OnPlotClear(self,event):
- self.client.Clear()
-
- def OnPlotScale(self, event):
- if self.client.last_draw != None:
- graphics, xAxis, yAxis= self.client.last_draw
- self.client.Draw(graphics,(1,3.05),(0,1))
-
- def OnEnableZoom(self, event):
- self.client.SetEnableZoom(event.IsChecked())
-
- def OnEnableGrid(self, event):
- self.client.SetEnableGrid(event.IsChecked())
-
- def OnEnableLegend(self, event):
- self.client.SetEnableLegend(event.IsChecked())
-
- def OnEnablePointLabel(self, event):
- self.client.SetEnablePointLabel(event.IsChecked())
-
- def OnScrUp(self, event):
- self.client.ScrollUp(1)
-
- def OnScrRt(self,event):
- self.client.ScrollRight(2)
-
- def OnReset(self,event):
- self.client.Reset()
-
- def OnHelpAbout(self, event):
- from wx.lib.dialogs import ScrolledMessageDialog
- about = ScrolledMessageDialog(self, __doc__, "About...")
- about.ShowModal()
-
- def resetDefaults(self):
- """Just to reset the fonts back to the PlotCanvas defaults"""
- self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
- self.client.SetFontSizeAxis(10)
- self.client.SetFontSizeLegend(7)
- self.client.SetXSpec('auto')
- self.client.SetYSpec('auto')
-
-
-def __test():
-
- class MyApp(wx.App):
- def OnInit(self):
- wx.InitAllImageHandlers()
- frame = TestFrame(None, -1, "PlotCanvas")
- #frame.Show(True)
- self.SetTopWindow(frame)
- return True
-
-
- app = MyApp(0)
- app.MainLoop()
-
-if __name__ == '__main__':
- __test()
diff --git a/gr-wxgui/python/wxgui/plotter/__init__.py b/gr-wxgui/python/wxgui/plotter/__init__.py
deleted file mode 100644
index 616492a3e6..0000000000
--- a/gr-wxgui/python/wxgui/plotter/__init__.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from channel_plotter import channel_plotter
-from waterfall_plotter import waterfall_plotter
-from bar_plotter import bar_plotter
diff --git a/gr-wxgui/python/wxgui/plotter/bar_plotter.py b/gr-wxgui/python/wxgui/plotter/bar_plotter.py
deleted file mode 100644
index 487db66b64..0000000000
--- a/gr-wxgui/python/wxgui/plotter/bar_plotter.py
+++ /dev/null
@@ -1,150 +0,0 @@
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import wx
-from grid_plotter_base import grid_plotter_base
-from OpenGL import GL
-import common
-import numpy
-
-LEGEND_TEXT_FONT_SIZE = 8
-LEGEND_BOX_PADDING = 3
-MIN_PADDING = 0, 0, 0, 70 #top, right, bottom, left
-#constants for the waveform storage
-SAMPLES_KEY = 'samples'
-COLOR_SPEC_KEY = 'color_spec'
-MARKERY_KEY = 'marker'
-TRIG_OFF_KEY = 'trig_off'
-
-##################################################
-# Bar Plotter for histogram waveforms
-##################################################
-class bar_plotter(grid_plotter_base):
-
- def __init__(self, parent):
- """
- Create a new bar plotter.
- """
- #init
- grid_plotter_base.__init__(self, parent, MIN_PADDING)
- self._bars = list()
- self._bar_width = .5
- self._color_spec = (0, 0, 0)
- #setup bar cache
- self._bar_cache = self.new_gl_cache(self._draw_bars)
- #setup bar plotter
- self.register_init(self._init_bar_plotter)
-
- def _init_bar_plotter(self):
- """
- Run gl initialization tasks.
- """
- GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
-
- def _draw_bars(self):
- """
- Draw the vertical bars.
- """
- bars = self._bars
- num_bars = len(bars)
- if num_bars == 0: return
- #use scissor to prevent drawing outside grid
- GL.glEnable(GL.GL_SCISSOR_TEST)
- GL.glScissor(
- self.padding_left,
- self.padding_bottom+1,
- self.width-self.padding_left-self.padding_right-1,
- self.height-self.padding_top-self.padding_bottom-1,
- )
- #load the points
- points = list()
- width = self._bar_width/2
- for i, bar in enumerate(bars):
- points.extend([
- (i-width, 0),
- (i+width, 0),
- (i+width, bar),
- (i-width, bar),
- ]
- )
- GL.glColor3f(*self._color_spec)
- #matrix transforms
- GL.glPushMatrix()
- GL.glTranslatef(self.padding_left, self.padding_top, 0)
- GL.glScalef(
- (self.width-self.padding_left-self.padding_right),
- (self.height-self.padding_top-self.padding_bottom),
- 1,
- )
- GL.glTranslatef(0, 1, 0)
- GL.glScalef(1.0/(num_bars-1), -1.0/(self.y_max-self.y_min), 1)
- GL.glTranslatef(0, -self.y_min, 0)
- #draw the bars
- GL.glVertexPointerf(points)
- GL.glDrawArrays(GL.GL_QUADS, 0, len(points))
- GL.glPopMatrix()
- GL.glDisable(GL.GL_SCISSOR_TEST)
-
- def _populate_point_label(self, x_val, y_val):
- """
- 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.
-
- 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)
- #convert x val to bar #
- bar_index = scalar*(x_val - self.x_min)
- #if abs(bar_index - round(bar_index)) > self._bar_width/2: return ''
- bar_index = int(round(bar_index))
- bar_start = (bar_index - self._bar_width/2)/scalar + self.x_min
- bar_end = (bar_index + self._bar_width/2)/scalar + self.x_min
- bar_value = self._bars[bar_index]
- return '%s to %s\n%s: %s'%(
- common.eng_format(bar_start, self.x_units),
- common.eng_format(bar_end, self.x_units),
- self.y_label, common.eng_format(bar_value, self.y_units),
- )
-
- def set_bars(self, bars, bar_width, color_spec):
- """
- Set the bars.
-
- 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
- self._bar_width = float(bar_width)
- self._color_spec = color_spec
- self._bar_cache.changed(True)
- self.unlock()
-
-
diff --git a/gr-wxgui/python/wxgui/plotter/channel_plotter.py b/gr-wxgui/python/wxgui/plotter/channel_plotter.py
deleted file mode 100644
index db174c7b28..0000000000
--- a/gr-wxgui/python/wxgui/plotter/channel_plotter.py
+++ /dev/null
@@ -1,249 +0,0 @@
-#
-# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import wx
-from grid_plotter_base import grid_plotter_base
-from OpenGL import GL
-import common
-import numpy
-import gltext
-import math
-
-LEGEND_TEXT_FONT_SIZE = 8
-LEGEND_BOX_PADDING = 3
-MIN_PADDING = 35, 10, 0, 0 #top, right, bottom, left
-#constants for the waveform storage
-SAMPLES_KEY = 'samples'
-COLOR_SPEC_KEY = 'color_spec'
-MARKERY_KEY = 'marker'
-TRIG_OFF_KEY = 'trig_off'
-
-##################################################
-# Channel Plotter for X Y Waveforms
-##################################################
-class channel_plotter(grid_plotter_base):
-
- def __init__(self, parent):
- """
- Create a new channel plotter.
- """
- #init
- grid_plotter_base.__init__(self, parent, MIN_PADDING)
- self.set_use_persistence(False)
- #setup legend cache
- self._legend_cache = self.new_gl_cache(self._draw_legend, 50)
- self.enable_legend(False)
- #setup waveform cache
- self._waveform_cache = self.new_gl_cache(self._draw_waveforms, 50)
- self._channels = dict()
- #init channel plotter
- self.register_init(self._init_channel_plotter)
- self.callback = None
-
- def _init_channel_plotter(self):
- """
- Run gl initialization tasks.
- """
- GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
-
- def enable_legend(self, enable=None):
- """
- Enable/disable the legend.
-
- Args:
- enable: true to enable
-
- Returns:
- the enable state when None
- """
- if enable is None: return self._enable_legend
- self.lock()
- self._enable_legend = enable
- self._legend_cache.changed(True)
- self.unlock()
-
- def _draw_waveforms(self):
- """
- Draw the waveforms for each channel.
- Scale the waveform data to the grid using gl matrix operations.
- """
- #use scissor to prevent drawing outside grid
- GL.glEnable(GL.GL_SCISSOR_TEST)
- GL.glScissor(
- self.padding_left+1,
- self.padding_bottom+1,
- self.width-self.padding_left-self.padding_right-1,
- self.height-self.padding_top-self.padding_bottom-1,
- )
- for channel in reversed(sorted(self._channels.keys())):
- samples = self._channels[channel][SAMPLES_KEY]
- num_samps = len(samples)
- if not num_samps: continue
- #use opengl to scale the waveform
- GL.glPushMatrix()
- GL.glTranslatef(self.padding_left, self.padding_top, 0)
- GL.glScalef(
- (self.width-self.padding_left-self.padding_right),
- (self.height-self.padding_top-self.padding_bottom),
- 1,
- )
- GL.glTranslatef(0, 1, 0)
- if isinstance(samples, tuple):
- x_scale, x_trans = 1.0/(self.x_max-self.x_min), -self.x_min
- points = zip(*samples)
- else:
- x_scale, x_trans = 1.0/(num_samps-1), -self._channels[channel][TRIG_OFF_KEY]
- points = zip(numpy.arange(0, num_samps), samples)
- GL.glScalef(x_scale, -1.0/(self.y_max-self.y_min), 1)
- GL.glTranslatef(x_trans, -self.y_min, 0)
- #draw the points/lines
- GL.glColor3f(*self._channels[channel][COLOR_SPEC_KEY])
- marker = self._channels[channel][MARKERY_KEY]
- if marker is None:
- GL.glVertexPointerf(points)
- GL.glDrawArrays(GL.GL_LINE_STRIP, 0, len(points))
- elif isinstance(marker, (int, float)) and marker > 0:
- GL.glPointSize(marker)
- GL.glVertexPointerf(points)
- GL.glDrawArrays(GL.GL_POINTS, 0, len(points))
- GL.glPopMatrix()
- GL.glDisable(GL.GL_SCISSOR_TEST)
-
- def _populate_point_label(self, x_val, y_val):
- """
- 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.
-
- 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'%(
- self.x_label, common.eng_format(x_val, self.x_units),
- self.y_label, common.eng_format(y_val, self.y_units),
- )
- for channel in sorted(self._channels.keys()):
- samples = self._channels[channel][SAMPLES_KEY]
- num_samps = len(samples)
- if not num_samps: continue
- if isinstance(samples, tuple): continue
- #linear interpolation
- x_index = (num_samps-1)*(x_val-self.x_min)/(self.x_max-self.x_min)
- x_index_low = int(math.floor(x_index))
- x_index_high = int(math.ceil(x_index))
- scale = x_index - x_index_low + self._channels[channel][TRIG_OFF_KEY]
- y_value = (samples[x_index_high] - samples[x_index_low])*scale + samples[x_index_low]
- if math.isnan(y_value): continue
- label_str += '\n%s: %s'%(channel, common.eng_format(y_value, self.y_units))
- return label_str
-
- def _call_callback (self, x_val, y_val):
- if self.callback != None:
- self.callback(x_val, y_val)
-
- def set_callback (self, callback):
- self.callback = callback
-
- def _draw_legend(self):
- """
- Draw the legend in the upper right corner.
- For each channel, draw a rectangle out of the channel color,
- and overlay the channel text on top of the rectangle.
- """
- if not self.enable_legend(): return
- x_off = self.width - self.padding_right - LEGEND_BOX_PADDING
- for i, channel in enumerate(reversed(sorted(self._channels.keys()))):
- samples = self._channels[channel][SAMPLES_KEY]
- if not len(samples): continue
- color_spec = self._channels[channel][COLOR_SPEC_KEY]
- txt = gltext.Text(channel, font_size=LEGEND_TEXT_FONT_SIZE)
- w, h = txt.get_size()
- #draw rect + text
- GL.glColor3f(*color_spec)
- self._draw_rect(
- x_off - w - LEGEND_BOX_PADDING,
- self.padding_top/2 - h/2 - LEGEND_BOX_PADDING,
- w+2*LEGEND_BOX_PADDING,
- h+2*LEGEND_BOX_PADDING,
- )
- txt.draw_text(wx.Point(x_off - w, self.padding_top/2 - h/2))
- x_off -= w + 4*LEGEND_BOX_PADDING
-
- def clear_waveform(self, channel):
- """
- Remove a waveform from the list of waveforms.
-
- Args:
- channel: the channel key
- """
- self.lock()
- if channel in self._channels.keys():
- self._channels.pop(channel)
- self._legend_cache.changed(True)
- self._waveform_cache.changed(True)
- self.unlock()
-
- def set_waveform(self, channel, samples=[], color_spec=(0, 0, 0), marker=None, trig_off=0):
- """
- Set the waveform for a given channel.
-
- 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)
- self._channels[channel] = {
- SAMPLES_KEY: samples,
- COLOR_SPEC_KEY: color_spec,
- MARKERY_KEY: marker,
- TRIG_OFF_KEY: trig_off,
- }
- self._waveform_cache.changed(True)
- self.unlock()
-
-if __name__ == '__main__':
- app = wx.PySimpleApp()
- frame = wx.Frame(None, -1, 'Demo', wx.DefaultPosition)
- vbox = wx.BoxSizer(wx.VERTICAL)
-
- plotter = channel_plotter(frame)
- plotter.set_x_grid(-1, 1, .2)
- plotter.set_y_grid(-1, 1, .4)
- vbox.Add(plotter, 1, wx.EXPAND)
-
- plotter = channel_plotter(frame)
- plotter.set_x_grid(-1, 1, .2)
- plotter.set_y_grid(-1, 1, .4)
- vbox.Add(plotter, 1, wx.EXPAND)
-
- frame.SetSizerAndFit(vbox)
- frame.SetSize(wx.Size(800, 600))
- frame.Show()
- app.MainLoop()
diff --git a/gr-wxgui/python/wxgui/plotter/common.py b/gr-wxgui/python/wxgui/plotter/common.py
deleted file mode 100644
index c296b1fa79..0000000000
--- a/gr-wxgui/python/wxgui/plotter/common.py
+++ /dev/null
@@ -1,149 +0,0 @@
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import threading
-import time
-import math
-import wx
-
-##################################################
-# Number formatting
-##################################################
-def get_exp(num):
- """
- Get the exponent of the number in base 10.
-
- 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))))
-
-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.
-
- Args:
- num: the floating point number
-
- Returns:
- the tuple coeff, exp, prefix
- """
- num = float(num)
- exp = get_exp(num)
- exp -= exp%3
- exp = min(max(exp, -24), 24) #bounds on SI table below
- prefix = {
- 24: 'Y', 21: 'Z',
- 18: 'E', 15: 'P',
- 12: 'T', 9: 'G',
- 6: 'M', 3: 'k',
- 0: '',
- -3: 'm', -6: 'u',
- -9: 'n', -12: 'p',
- -15: 'f', -18: 'a',
- -21: 'z', -24: 'y',
- }[exp]
- coeff = num/10**exp
- return coeff, exp, prefix
-
-def sci_format(num):
- """
- Format a floating point number into scientific notation.
-
- Args:
- num: the number to format
-
- Returns:
- a label string
- """
- coeff, exp, prefix = get_si_components(num)
- if -3 <= exp < 3: return '%g'%num
- return '%.3ge%d'%(coeff, exp)
-
-def eng_format(num, units=''):
- """
- Format a floating point number into engineering notation.
-
- 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
- return '%g%s%s%s'%(coeff, units and ' ' or '', prefix, units)
-
-##################################################
-# Interface with thread safe lock/unlock
-##################################################
-class mutex(object):
- _lock = threading.Lock()
- def lock(self): self._lock.acquire()
- def unlock(self): self._lock.release()
-
-##################################################
-# Periodic update thread for point label
-##################################################
-class point_label_thread(threading.Thread, mutex):
-
- def __init__(self, plotter):
- self._plotter = plotter
- self._coor_queue = list()
- #bind plotter mouse events
- self._plotter.Bind(wx.EVT_MOTION, lambda evt: self.enqueue(evt.GetPosition()))
- self._plotter.Bind(wx.EVT_LEAVE_WINDOW, lambda evt: self.enqueue(None))
- self._plotter.Bind(wx.EVT_RIGHT_DOWN, lambda evt: plotter.enable_point_label(not plotter.enable_point_label()))
- self._plotter.Bind(wx.EVT_LEFT_DOWN, lambda evt: plotter.call_freq_callback(evt.GetPosition()))
- #start the thread
- threading.Thread.__init__(self)
- self.start()
-
- def enqueue(self, coor):
- self.lock()
- self._coor_queue.append(coor)
- self.unlock()
-
- def run(self):
- last_ts = time.time()
- last_coor = coor = None
- try:
- while True:
- time.sleep(1.0/30.0)
- self.lock()
- #get most recent coor change
- if self._coor_queue:
- coor = self._coor_queue[-1]
- self._coor_queue = list()
- self.unlock()
- #update if coor change, or enough time expired
- if last_coor != coor or (time.time() - last_ts) > (1.0/2.0):
- self._plotter.set_point_label_coordinate(coor)
- last_coor = coor
- last_ts = time.time()
- except wx.PyDeadObjectError: pass
diff --git a/gr-wxgui/python/wxgui/plotter/gltext.py b/gr-wxgui/python/wxgui/plotter/gltext.py
deleted file mode 100644
index 55627bceb1..0000000000
--- a/gr-wxgui/python/wxgui/plotter/gltext.py
+++ /dev/null
@@ -1,507 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8
-#
-# Provides some text display functions for wx + ogl
-# Copyright (C) 2007 Christian Brugger, Stefan Hacker
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-import wx
-from OpenGL.GL import *
-
-"""
-Optimize with psyco if possible, this gains us about 50% speed when
-creating our textures in trade for about 4MBytes of additional memory usage for
-psyco. If you don't like loosing the memory you have to turn the lines following
-"enable psyco" into a comment while uncommenting the line after "Disable psyco".
-"""
-#Try to enable psyco
-try:
- import psyco
- psyco_optimized = False
-except ImportError:
- psyco = None
-
-#Disable psyco
-#psyco = None
-
-class TextElement(object):
- """
- A simple class for using system Fonts to display
- text in an OpenGL scene
- """
- def __init__(self,
- text = '',
- font = None,
- foreground = wx.BLACK,
- centered = False):
- """
- text (String) - Text
- font (wx.Font) - Font to draw with (None = System default)
- foreground (wx.Color) - Color of the text
- or (wx.Bitmap)- Bitmap to overlay the text with
- centered (bool) - Center the text
-
- Initializes the TextElement
- """
- # save given variables
- self._text = text
- self._lines = text.split('\n')
- self._font = font
- self._foreground = foreground
- self._centered = centered
-
- # init own variables
- self._owner_cnt = 0 #refcounter
- self._texture = None #OpenGL texture ID
- self._text_size = None #x/y size tuple of the text
- self._texture_size= None #x/y Texture size tuple
-
- # create Texture
- self.createTexture()
-
-
- #---Internal helpers
-
- def _getUpper2Base(self, value):
- """
- Returns the lowest value with the power of
- 2 greater than 'value' (2^n>value)
- """
- base2 = 1
- while base2 < value:
- base2 *= 2
- return base2
-
- #---Functions
-
- def draw_text(self, position = wx.Point(0,0), scale = 1.0, rotation = 0):
- """
- position (wx.Point) - x/y Position to draw in scene
- scale (float) - Scale
- rotation (int) - Rotation in degree
-
- Draws the text to the scene
- """
- #Enable necessary functions
- glColor(1,1,1,1)
- glEnable(GL_TEXTURE_2D)
- glEnable(GL_ALPHA_TEST) #Enable alpha test
- glAlphaFunc(GL_GREATER, 0)
- glEnable(GL_BLEND) #Enable blending
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
- #Bind texture
- glBindTexture(GL_TEXTURE_2D, self._texture)
-
- ow, oh = self._text_size
- w , h = self._texture_size
- #Perform transformations
- glPushMatrix()
- glTranslated(position.x, position.y, 0)
- glRotate(-rotation, 0, 0, 1)
- glScaled(scale, scale, scale)
- if self._centered:
- glTranslate(-w/2, -oh/2, 0)
- #Draw vertices
- glBegin(GL_QUADS)
- glTexCoord2f(0,0); glVertex2f(0,0)
- glTexCoord2f(0,1); glVertex2f(0,h)
- glTexCoord2f(1,1); glVertex2f(w,h)
- glTexCoord2f(1,0); glVertex2f(w,0)
- glEnd()
- glPopMatrix()
-
- #Disable features
- glDisable(GL_BLEND)
- glDisable(GL_ALPHA_TEST)
- glDisable(GL_TEXTURE_2D)
-
- def createTexture(self):
- """
- Creates a texture from the settings saved in TextElement, to be able to use normal
- system fonts conviently a wx.MemoryDC is used to draw on a wx.Bitmap. As wxwidgets
- device contexts don't support alpha at all it is necessary to apply a little hack
- to preserve antialiasing without sticking to a fixed background color:
-
- We draw the bmp in b/w mode so we can use its data as a alpha channel for a solid
- color bitmap which after GL_ALPHA_TEST and GL_BLEND will show a nicely antialiased
- text on any surface.
-
- To access the raw pixel data the bmp gets converted to a wx.Image. Now we just have
- to merge our foreground color with the alpha data we just created and push it all
- into a OpenGL texture and we are DONE *inhalesdelpy*
-
- DRAWBACK of the whole conversion thing is a really long time for creating the
- texture. If you see any optimizations that could save time PLEASE CREATE A PATCH!!!
- """
- # get a memory dc
- dc = wx.MemoryDC()
-
- # Select an empty bitmap into the MemoryDC - otherwise the call to
- # GetMultiLineTextExtent() may fail below
- dc.SelectObject(wx.EmptyBitmap(1,1))
-
- # set our font
- dc.SetFont(self._font)
-
- # Approximate extend to next power of 2 and create our bitmap
- # REMARK: You wouldn't believe how much fucking speed this little
- # sucker gains compared to sizes not of the power of 2. It's like
- # 500ms --> 0.5ms (on my ATI-GPU powered Notebook). On Sams nvidia
- # machine there don't seem to occur any losses...bad drivers?
- ow, oh = dc.GetMultiLineTextExtent(self._text)[:2]
- w, h = self._getUpper2Base(ow), self._getUpper2Base(oh)
-
- self._text_size = wx.Size(ow,oh)
- self._texture_size = wx.Size(w,h)
- bmp = wx.EmptyBitmap(w,h)
-
-
- #Draw in b/w mode to bmp so we can use it as alpha channel
- dc.SelectObject(bmp)
- dc.SetBackground(wx.BLACK_BRUSH)
- dc.Clear()
- dc.SetTextForeground(wx.WHITE)
- x,y = 0,0
- centered = self.centered
- for line in self._lines:
- if not line: line = ' '
- tw, th = dc.GetTextExtent(line)
- if centered:
- x = int(round((w-tw)/2))
- dc.DrawText(line, x, y)
- x = 0
- y += th
- #Release the dc
- dc.SelectObject(wx.NullBitmap)
- del dc
-
- #Generate a correct RGBA data string from our bmp
- """
- NOTE: You could also use wx.AlphaPixelData to access the pixel data
- in 'bmp' directly, but the iterator given by it is much slower than
- first converting to an image and using wx.Image.GetData().
- """
- img = wx.ImageFromBitmap(bmp)
- alpha = img.GetData()
-
- if isinstance(self._foreground, wx.Colour):
- """
- If we have a static color...
- """
- r,g,b = self._foreground.Get()
- color = "%c%c%c" % (chr(r), chr(g), chr(b))
-
- data = ''
- for i in xrange(0, len(alpha)-1, 3):
- data += color + alpha[i]
-
- elif isinstance(self._foreground, wx.Bitmap):
- """
- If we have a bitmap...
- """
- bg_img = wx.ImageFromBitmap(self._foreground)
- bg = bg_img.GetData()
- bg_width = self._foreground.GetWidth()
- bg_height = self._foreground.GetHeight()
-
- data = ''
-
- for y in xrange(0, h):
- for x in xrange(0, w):
- if (y > (bg_height-1)) or (x > (bg_width-1)):
- color = "%c%c%c" % (chr(0),chr(0),chr(0))
- else:
- pos = (x+y*bg_width) * 3
- color = bg[pos:pos+3]
- data += color + alpha[(x+y*w)*3]
-
-
- # now convert it to ogl texture
- self._texture = glGenTextures(1)
- glBindTexture(GL_TEXTURE_2D, self._texture)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
-
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0)
- glPixelStorei(GL_UNPACK_ALIGNMENT, 2)
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data)
-
- def deleteTexture(self):
- """
- Deletes the OpenGL texture object
- """
- if self._texture:
- if glIsTexture(self._texture):
- glDeleteTextures(self._texture)
- else:
- self._texture = None
-
- def bind(self):
- """
- Increase refcount
- """
- self._owner_cnt += 1
-
- def release(self):
- """
- Decrease refcount
- """
- self._owner_cnt -= 1
-
- def isBound(self):
- """
- Return refcount
- """
- return self._owner_cnt
-
- def __del__(self):
- """
- Destructor
- """
- self.deleteTexture()
-
- #---Getters/Setters
-
- def getText(self): return self._text
- def getFont(self): return self._font
- def getForeground(self): return self._foreground
- def getCentered(self): return self._centered
- def getTexture(self): return self._texture
- def getTexture_size(self): return self._texture_size
-
- def getOwner_cnt(self): return self._owner_cnt
- def setOwner_cnt(self, value):
- self._owner_cnt = value
-
- #---Properties
-
- text = property(getText, None, None, "Text of the object")
- font = property(getFont, None, None, "Font of the object")
- foreground = property(getForeground, None, None, "Color of the text")
- centered = property(getCentered, None, None, "Is text centered")
- owner_cnt = property(getOwner_cnt, setOwner_cnt, None, "Owner count")
- texture = property(getTexture, None, None, "Used texture")
- texture_size = property(getTexture_size, None, None, "Size of the used texture")
-
-
-class Text(object):
- """
- A simple class for using System Fonts to display text in
- an OpenGL scene. The Text adds a global Cache of already
- created text elements to TextElement's base functionality
- so you can save some memory and increase speed
- """
- _texts = [] #Global cache for TextElements
-
- def __init__(self,
- text = 'Text',
- font = None,
- font_size = 8,
- foreground = wx.BLACK,
- centered = False,
- bold = False):
- """
- text (string) - displayed text
- font (wx.Font) - if None, system default font will be used with font_size
- font_size (int) - font size in points
- foreground (wx.Color) - Color of the text
- or (wx.Bitmap) - Bitmap to overlay the text with
- centered (bool) - should the text drawn centered towards position?
-
- Initializes the text object
- """
- #Init/save variables
- self._aloc_text = None
- self._text = text
- self._font_size = font_size
- self._foreground= foreground
- self._centered = centered
-
- #Check if we are offered a font
- if not font:
- #if not use the system default
- self._font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
- else:
- #save it
- self._font = font
-
- if bold: self._font.SetWeight(wx.FONTWEIGHT_BOLD)
-
- #Bind us to our texture
- self._initText()
-
- #---Internal helpers
-
- def _initText(self):
- """
- Initializes/Reinitializes the Text object by binding it
- to a TextElement suitable for its current settings
- """
- #Check if we already bound to a texture
- if self._aloc_text:
- #if so release it
- self._aloc_text.release()
- if not self._aloc_text.isBound():
- self._texts.remove(self._aloc_text)
- self._aloc_text = None
-
- #Adjust our font
- self._font.SetPointSize(self._font_size)
-
- #Search for existing element in our global buffer
- for element in self._texts:
- if element.text == self._text and\
- element.font == self._font and\
- element.foreground == self._foreground and\
- element.centered == self._centered:
- # We already exist in global buffer ;-)
- element.bind()
- self._aloc_text = element
- break
-
- if not self._aloc_text:
- # We are not in the global buffer, let's create ourselves
- aloc_text = self._aloc_text = TextElement(self._text,
- self._font,
- self._foreground,
- self._centered)
- aloc_text.bind()
- self._texts.append(aloc_text)
-
- def __del__(self):
- """
- Destructor
- """
- aloc_text = self._aloc_text
- aloc_text.release()
- if not aloc_text.isBound():
- self._texts.remove(aloc_text)
-
- #---Functions
-
- def draw_text(self, position = wx.Point(0,0), scale = 1.0, rotation = 0):
- """
- position (wx.Point) - x/y Position to draw in scene
- scale (float) - Scale
- rotation (int) - Rotation in degree
-
- Draws the text to the scene
- """
-
- self._aloc_text.draw_text(position, scale, rotation)
-
- #---Setter/Getter
-
- def getText(self): return self._text
- def setText(self, value, reinit = True):
- """
- value (bool) - New Text
- reinit (bool) - Create a new texture
-
- Sets a new text
- """
- self._text = value
- if reinit:
- self._initText()
-
- def getFont(self): return self._font
- def setFont(self, value, reinit = True):
- """
- value (bool) - New Font
- reinit (bool) - Create a new texture
-
- Sets a new font
- """
- self._font = value
- if reinit:
- self._initText()
-
- def getFont_size(self): return self._font_size
- def setFont_size(self, value, reinit = True):
- """
- value (bool) - New font size
- reinit (bool) - Create a new texture
-
- Sets a new font size
- """
- self._font_size = value
- if reinit:
- self._initText()
-
- def getForeground(self): return self._foreground
- def setForeground(self, value, reinit = True):
- """
- value (bool) - New centered value
- reinit (bool) - Create a new texture
-
- Sets a new value for 'centered'
- """
- self._foreground = value
- if reinit:
- self._initText()
-
- def getCentered(self): return self._centered
- def setCentered(self, value, reinit = True):
- """
- value (bool) - New centered value
- reinit (bool) - Create a new texture
-
- Sets a new value for 'centered'
- """
- self._centered = value
- if reinit:
- self._initText()
-
- def get_size(self):
- """
- Returns a text size tuple
- """
- return self._aloc_text._text_size
-
- def getTexture_size(self):
- """
- Returns a texture size tuple
- """
- return self._aloc_text.texture_size
-
- def getTextElement(self):
- """
- Returns the text element bound to the Text class
- """
- return self._aloc_text
-
- def getTexture(self):
- """
- Returns the texture of the bound TextElement
- """
- return self._aloc_text.texture
-
-
- #---Properties
-
- text = property(getText, setText, None, "Text of the object")
- font = property(getFont, setFont, None, "Font of the object")
- font_size = property(getFont_size, setFont_size, None, "Font size")
- foreground = property(getForeground, setForeground, None, "Color/Overlay bitmap of the text")
- centered = property(getCentered, setCentered, None, "Display the text centered")
- texture_size = property(getTexture_size, None, None, "Size of the used texture")
- texture = property(getTexture, None, None, "Texture of bound TextElement")
- text_element = property(getTextElement,None , None, "TextElement bound to this class")
-
-#Optimize critical functions
-if psyco and not psyco_optimized:
- psyco.bind(TextElement.createTexture)
- psyco_optimized = True
diff --git a/gr-wxgui/python/wxgui/plotter/grid_plotter_base.py b/gr-wxgui/python/wxgui/plotter/grid_plotter_base.py
deleted file mode 100644
index bc48ad72f5..0000000000
--- a/gr-wxgui/python/wxgui/plotter/grid_plotter_base.py
+++ /dev/null
@@ -1,458 +0,0 @@
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import wx
-import wx.glcanvas
-from OpenGL import GL
-import common
-from plotter_base import plotter_base
-import gltext
-import math
-
-GRID_LINE_COLOR_SPEC = (.7, .7, .7) #gray
-GRID_BORDER_COLOR_SPEC = (0, 0, 0) #black
-TICK_TEXT_FONT_SIZE = 9
-TITLE_TEXT_FONT_SIZE = 13
-UNITS_TEXT_FONT_SIZE = 9
-AXIS_LABEL_PADDING = 5
-TICK_LABEL_PADDING = 5
-TITLE_LABEL_PADDING = 7
-POINT_LABEL_FONT_SIZE = 8
-POINT_LABEL_COLOR_SPEC = (1, 1, 0.5, 0.75)
-POINT_LABEL_PADDING = 3
-POINT_LABEL_OFFSET = 10
-GRID_LINE_DASH_LEN = 4
-
-##################################################
-# Grid Plotter Base Class
-##################################################
-class grid_plotter_base(plotter_base):
-
- def __init__(self, parent, min_padding=(0, 0, 0, 0)):
- plotter_base.__init__(self, parent)
- #setup grid cache
- self._grid_cache = self.new_gl_cache(self._draw_grid, 25)
- self.enable_grid_lines(True)
- #setup padding
- self.padding_top_min, self.padding_right_min, self.padding_bottom_min, self.padding_left_min = min_padding
- #store title and unit strings
- self.set_title('Title')
- self.set_x_label('X Label')
- self.set_y_label('Y Label')
- #init the grid to some value
- self.set_x_grid(-1, 1, 1)
- self.set_y_grid(-1, 1, 1)
- #setup point label cache
- self._point_label_cache = self.new_gl_cache(self._draw_point_label, 75)
- self.enable_point_label(False)
- self.enable_grid_aspect_ratio(False)
- self.set_point_label_coordinate(None)
- common.point_label_thread(self)
- #init grid plotter
- self.register_init(self._init_grid_plotter)
-
- def _init_grid_plotter(self):
- """
- Run gl initialization tasks.
- """
- GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
-
- def set_point_label_coordinate(self, coor):
- """
- Set the point label coordinate.
-
- Args:
- coor: the coordinate x, y tuple or None
- """
- self.lock()
- self._point_label_coordinate = coor
- self._point_label_cache.changed(True)
- self.update()
- self.unlock()
-
- def call_freq_callback(self, coor):
- try:
- x, y = self._point_label_coordinate
- except:
- return
- if x < self.padding_left or x > self.width-self.padding_right: return
- if y < self.padding_top or y > self.height-self.padding_bottom: return
- #scale to window bounds
- x_win_scalar = float(x - self.padding_left)/(self.width-self.padding_left-self.padding_right)
- y_win_scalar = float((self.height - y) - self.padding_bottom)/(self.height-self.padding_top-self.padding_bottom)
- #scale to grid bounds
- x_val = x_win_scalar*(self.x_max-self.x_min) + self.x_min
- y_val = y_win_scalar*(self.y_max-self.y_min) + self.y_min
- self._call_callback(x_val, y_val)
-
- def enable_grid_aspect_ratio(self, enable=None):
- """
- Enable/disable the grid aspect ratio.
- If enabled, enforce the aspect ratio on the padding:
- horizontal_padding:vertical_padding == width:height
-
- Args:
- enable: true to enable
-
- Returns:
- the enable state when None
- """
- if enable is None: return self._enable_grid_aspect_ratio
- self.lock()
- self._enable_grid_aspect_ratio = enable
- for cache in self._gl_caches: cache.changed(True)
- self.unlock()
-
- def enable_point_label(self, enable=None):
- """
- Enable/disable the point label.
-
- Args:
- enable: true to enable
-
- Returns:
- the enable state when None
- """
- if enable is None: return self._enable_point_label
- self.lock()
- self._enable_point_label = enable
- self._point_label_cache.changed(True)
- self.unlock()
-
- def set_title(self, title):
- """
- Set the title.
-
- Args:
- title the title string
- """
- self.lock()
- self.title = title
- self._grid_cache.changed(True)
- self.unlock()
-
- def set_x_label(self, x_label, x_units=''):
- """
- Set the x label and units.
-
- Args:
- x_label: the x label string
- x_units: the x units string
- """
- self.lock()
- self.x_label = x_label
- self.x_units = x_units
- self._grid_cache.changed(True)
- self.unlock()
-
- def set_y_label(self, y_label, y_units=''):
- """
- Set the y label and units.
-
- Args:
- y_label: the y label string
- y_units: the y units string
- """
- self.lock()
- self.y_label = y_label
- self.y_units = y_units
- self._grid_cache.changed(True)
- self.unlock()
-
- def set_x_grid(self, minimum, maximum, step, scale=False):
- """
- Set the x grid parameters.
-
- 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)
- self.x_max = float(maximum)
- self.x_step = float(step)
- if scale:
- coeff, exp, prefix = common.get_si_components(max(abs(self.x_min), abs(self.x_max)))
- self.x_scalar = 10**(-exp)
- self.x_prefix = prefix
- else:
- self.x_scalar = 1.0
- self.x_prefix = ''
- for cache in self._gl_caches: cache.changed(True)
- self.unlock()
-
- def set_y_grid(self, minimum, maximum, step, scale=False):
- """
- Set the y grid parameters.
-
- 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)
- self.y_max = float(maximum)
- self.y_step = float(step)
- if scale:
- coeff, exp, prefix = common.get_si_components(max(abs(self.y_min), abs(self.y_max)))
- self.y_scalar = 10**(-exp)
- self.y_prefix = prefix
- else:
- self.y_scalar = 1.0
- self.y_prefix = ''
- for cache in self._gl_caches: cache.changed(True)
- self.unlock()
-
- def _draw_grid(self):
- """
- Create the x, y, tick, and title labels.
- Resize the padding for the labels.
- Draw the border, grid, title, and labels.
- """
- ##################################################
- # Create GL text labels
- ##################################################
- #create x tick labels
- x_tick_labels = [(tick, self._get_tick_label(tick, self.x_units))
- for tick in self._get_ticks(self.x_min, self.x_max, self.x_step, self.x_scalar)]
- #create x tick labels
- y_tick_labels = [(tick, self._get_tick_label(tick, self.y_units))
- for tick in self._get_ticks(self.y_min, self.y_max, self.y_step, self.y_scalar)]
- #create x label
- x_label_str = self.x_units and "%s (%s%s)"%(self.x_label, self.x_prefix, self.x_units) or self.x_label
- x_label = gltext.Text(x_label_str, bold=True, font_size=UNITS_TEXT_FONT_SIZE, centered=True)
- #create y label
- y_label_str = self.y_units and "%s (%s%s)"%(self.y_label, self.y_prefix, self.y_units) or self.y_label
- y_label = gltext.Text(y_label_str, bold=True, font_size=UNITS_TEXT_FONT_SIZE, centered=True)
- #create title
- title_label = gltext.Text(self.title, bold=True, font_size=TITLE_TEXT_FONT_SIZE, centered=True)
- ##################################################
- # Resize the padding
- ##################################################
- self.padding_top = max(2*TITLE_LABEL_PADDING + title_label.get_size()[1], self.padding_top_min)
- self.padding_right = max(2*TICK_LABEL_PADDING, self.padding_right_min)
- self.padding_bottom = max(2*AXIS_LABEL_PADDING + TICK_LABEL_PADDING + x_label.get_size()[1] + max([label.get_size()[1] for tick, label in x_tick_labels]), self.padding_bottom_min)
- self.padding_left = max(2*AXIS_LABEL_PADDING + TICK_LABEL_PADDING + y_label.get_size()[1] + max([label.get_size()[0] for tick, label in y_tick_labels]), self.padding_left_min)
- #enforce padding aspect ratio if enabled
- if self.enable_grid_aspect_ratio():
- w_over_h_ratio = float(self.width)/float(self.height)
- horizontal_padding = float(self.padding_right + self.padding_left)
- veritical_padding = float(self.padding_top + self.padding_bottom)
- if w_over_h_ratio > horizontal_padding/veritical_padding:
- #increase the horizontal padding
- new_padding = veritical_padding*w_over_h_ratio - horizontal_padding
- #distribute the padding to left and right
- self.padding_left += int(round(new_padding/2))
- self.padding_right += int(round(new_padding/2))
- else:
- #increase the vertical padding
- new_padding = horizontal_padding/w_over_h_ratio - veritical_padding
- #distribute the padding to top and bottom
- self.padding_top += int(round(new_padding/2))
- self.padding_bottom += int(round(new_padding/2))
- ##################################################
- # Draw Grid X
- ##################################################
- for tick, label in x_tick_labels:
- scaled_tick = (self.width-self.padding_left-self.padding_right)*\
- (tick/self.x_scalar-self.x_min)/(self.x_max-self.x_min) + self.padding_left
- self._draw_grid_line(
- (scaled_tick, self.padding_top),
- (scaled_tick, self.height-self.padding_bottom),
- )
- w, h = label.get_size()
- label.draw_text(wx.Point(scaled_tick-w/2, self.height-self.padding_bottom+TICK_LABEL_PADDING))
- ##################################################
- # Draw Grid Y
- ##################################################
- for tick, label in y_tick_labels:
- scaled_tick = (self.height-self.padding_top-self.padding_bottom)*\
- (1 - (tick/self.y_scalar-self.y_min)/(self.y_max-self.y_min)) + self.padding_top
- self._draw_grid_line(
- (self.padding_left, scaled_tick),
- (self.width-self.padding_right, scaled_tick),
- )
- w, h = label.get_size()
- label.draw_text(wx.Point(self.padding_left-w-TICK_LABEL_PADDING, scaled_tick-h/2))
- ##################################################
- # Draw Border
- ##################################################
- GL.glColor3f(*GRID_BORDER_COLOR_SPEC)
- self._draw_rect(
- self.padding_left,
- self.padding_top,
- self.width - self.padding_right - self.padding_left,
- self.height - self.padding_top - self.padding_bottom,
- fill=False,
- )
- ##################################################
- # Draw Labels
- ##################################################
- #draw title label
- title_label.draw_text(wx.Point(self.width/2.0, TITLE_LABEL_PADDING + title_label.get_size()[1]/2))
- #draw x labels
- x_label.draw_text(wx.Point(
- (self.width-self.padding_left-self.padding_right)/2.0 + self.padding_left,
- self.height-(AXIS_LABEL_PADDING + x_label.get_size()[1]/2),
- )
- )
- #draw y labels
- y_label.draw_text(wx.Point(
- AXIS_LABEL_PADDING + y_label.get_size()[1]/2,
- (self.height-self.padding_top-self.padding_bottom)/2.0 + self.padding_top,
- ), rotation=90,
- )
-
- def _get_tick_label(self, tick, unit):
- """
- Format the tick value and create a gl 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)
- return gltext.Text(tick_str, font_size=TICK_TEXT_FONT_SIZE)
-
- def _get_ticks(self, min, max, step, scalar):
- """
- Determine the positions for the ticks.
-
- 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)
- max = float(max)
- step = float(step)
- #check for valid numbers
- try:
- assert step > 0
- assert max > min
- assert max - min > step
- except AssertionError: return [-1, 1]
- #determine the start and stop value
- start = int(math.ceil(min/step))
- stop = int(math.floor(max/step))
- return [i*step*scalar for i in range(start, stop+1)]
-
- def enable_grid_lines(self, enable=None):
- """
- Enable/disable the grid lines.
-
- Args:
- enable: true to enable
-
- Returns:
- the enable state when None
- """
- if enable is None: return self._enable_grid_lines
- self.lock()
- self._enable_grid_lines = enable
- self._grid_cache.changed(True)
- self.unlock()
-
- def _draw_grid_line(self, coor1, coor2):
- """
- Draw a dashed line from coor1 to coor2.
-
- 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)
- num_points = int(length/GRID_LINE_DASH_LEN)
- #calculate points array
- points = [(
- coor1[0] + i*(coor2[0]-coor1[0])/(num_points - 1),
- coor1[1] + i*(coor2[1]-coor1[1])/(num_points - 1)
- ) for i in range(num_points)]
- #set color and draw
- GL.glColor3f(*GRID_LINE_COLOR_SPEC)
- GL.glVertexPointerf(points)
- GL.glDrawArrays(GL.GL_LINES, 0, len(points))
-
- def _draw_rect(self, x, y, width, height, fill=True):
- """
- Draw a rectangle on the x, y plane.
- X and Y are the top-left corner.
-
- 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)
- GL.glVertex2f(x+width, y)
- GL.glVertex2f(x+width, y+height)
- GL.glVertex2f(x, y+height)
- GL.glEnd()
-
- def _draw_point_label(self):
- """
- Draw the point label for the last mouse motion coordinate.
- The mouse coordinate must be an X, Y tuple.
- The label will be drawn at the X, Y coordinate.
- The values of the X, Y coordinate will be scaled to the current X, Y bounds.
- """
- if not self.enable_point_label(): return
- if not self._point_label_coordinate: return
- x, y = self._point_label_coordinate
- if x < self.padding_left or x > self.width-self.padding_right: return
- if y < self.padding_top or y > self.height-self.padding_bottom: return
- #scale to window bounds
- x_win_scalar = float(x - self.padding_left)/(self.width-self.padding_left-self.padding_right)
- y_win_scalar = float((self.height - y) - self.padding_bottom)/(self.height-self.padding_top-self.padding_bottom)
- #scale to grid bounds
- x_val = x_win_scalar*(self.x_max-self.x_min) + self.x_min
- y_val = y_win_scalar*(self.y_max-self.y_min) + self.y_min
- #create text
- label_str = self._populate_point_label(x_val, y_val)
- if not label_str: return
- txt = gltext.Text(label_str, font_size=POINT_LABEL_FONT_SIZE)
- w, h = txt.get_size()
- #enable transparency
- GL.glEnable(GL.GL_BLEND)
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
- #draw rect + text
- GL.glColor4f(*POINT_LABEL_COLOR_SPEC)
- if x > self.width/2: x -= w+2*POINT_LABEL_PADDING + POINT_LABEL_OFFSET
- else: x += POINT_LABEL_OFFSET
- self._draw_rect(x, y-h-2*POINT_LABEL_PADDING, w+2*POINT_LABEL_PADDING, h+2*POINT_LABEL_PADDING)
- txt.draw_text(wx.Point(x+POINT_LABEL_PADDING, y-h-POINT_LABEL_PADDING))
diff --git a/gr-wxgui/python/wxgui/plotter/plotter_base.py b/gr-wxgui/python/wxgui/plotter/plotter_base.py
deleted file mode 100644
index ca904908ec..0000000000
--- a/gr-wxgui/python/wxgui/plotter/plotter_base.py
+++ /dev/null
@@ -1,220 +0,0 @@
-#
-# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import wx
-import wx.glcanvas
-from OpenGL import GL
-import common
-
-BACKGROUND_COLOR_SPEC = (1, 0.976, 1, 1) #creamy white
-
-##################################################
-# GL caching interface
-##################################################
-class gl_cache(object):
- """
- Cache a set of gl drawing routines in a compiled list.
- """
-
- def __init__(self, draw):
- """
- Create a new cache.
-
- Args:
- draw: a function to draw gl stuff
- """
- self.changed(True)
- self._draw = draw
-
- def init(self):
- """
- To be called when gl initializes.
- Create a new compiled list.
- """
- self._grid_compiled_list_id = GL.glGenLists(1)
-
- def draw(self):
- """
- Draw the gl stuff using a compiled list.
- If changed, reload the compiled list.
- """
- if self.changed():
- GL.glNewList(self._grid_compiled_list_id, GL.GL_COMPILE)
- self._draw()
- GL.glEndList()
- self.changed(False)
- #draw the grid
- GL.glCallList(self._grid_compiled_list_id)
-
- def changed(self, state=None):
- """
- Set the changed flag if state is not None.
- Otherwise return the changed flag.
- """
- if state is None: return self._changed
- self._changed = state
-
-##################################################
-# OpenGL WX Plotter Canvas
-##################################################
-class plotter_base(wx.glcanvas.GLCanvas, common.mutex):
- """
- Plotter base class for all plot types.
- """
-
- def __init__(self, parent):
- """
- Create a new plotter base.
- Initialize the GLCanvas with double buffering.
- Initialize various plotter flags.
- Bind the paint and size events.
-
- Args:
- parent: the parent widgit
- """
- attribList = (wx.glcanvas.WX_GL_DOUBLEBUFFER, wx.glcanvas.WX_GL_RGBA)
- wx.glcanvas.GLCanvas.__init__(self, parent, wx.ID_ANY, attribList=attribList); # Specifically use the CTOR which does NOT create an implicit GL context
- self._gl_ctx = wx.glcanvas.GLContext(self) # Create the explicit GL context
- self.use_persistence=False
- self.persist_alpha=2.0/15
- self.clear_accum=True
- self._gl_init_flag = False
- self._resized_flag = True
- self._init_fcns = list()
- self._draw_fcns = list()
- self._gl_caches = list()
- self.Bind(wx.EVT_PAINT, self._on_paint)
- self.Bind(wx.EVT_SIZE, self._on_size)
- self.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None)
-
- def set_use_persistence(self,enable):
- self.use_persistence=enable
- self.clear_accum=True
-
- def set_persist_alpha(self,analog_alpha):
- self.persist_alpha=analog_alpha
-
- def new_gl_cache(self, draw_fcn, draw_pri=50):
- """
- Create a new gl cache.
- Register its draw and init function.
-
- Returns:
- the new cache object
- """
- cache = gl_cache(draw_fcn)
- self.register_init(cache.init)
- self.register_draw(cache.draw, draw_pri)
- self._gl_caches.append(cache)
- return cache
-
- def register_init(self, init_fcn):
- self._init_fcns.append(init_fcn)
-
- def register_draw(self, draw_fcn, draw_pri=50):
- """
- Register a draw function with a layer priority.
- Large pri values are drawn last.
- Small pri values are drawn first.
- """
- for i in range(len(self._draw_fcns)):
- if draw_pri < self._draw_fcns[i][0]:
- self._draw_fcns.insert(i, (draw_pri, draw_fcn))
- return
- self._draw_fcns.append((draw_pri, draw_fcn))
-
- def _on_size(self, event):
- """
- Flag the resize event.
- The paint event will handle the actual resizing.
- """
- self.lock()
- self._resized_flag = True
- self.clear_accum=True
- self.unlock()
-
- def _on_paint(self, event):
- """
- Respond to paint events.
- Initialize GL if this is the first paint event.
- Resize the view port if the width or height changed.
- Redraw the screen, calling the draw functions.
- """
- if not self.IsShownOnScreen(): # Cannot realise a GL context on OS X if window is not yet shown
- return
- # create device context (needed on Windows, noop on X)
- dc = None
- if event.GetEventObject(): # Only create DC if paint triggered by WM message (for OS X)
- dc = wx.PaintDC(self)
- self.lock()
- self.SetCurrent(self._gl_ctx) # Real the explicit GL context
-
- # check if gl was initialized
- if not self._gl_init_flag:
- GL.glClearColor(*BACKGROUND_COLOR_SPEC)
- for fcn in self._init_fcns: fcn()
- self._gl_init_flag = True
-
- # check for a change in window size
- if self._resized_flag:
- self.width, self.height = self.GetSize()
- GL.glMatrixMode(GL.GL_PROJECTION)
- GL.glLoadIdentity()
- GL.glOrtho(0, self.width, self.height, 0, 1, 0)
- GL.glMatrixMode(GL.GL_MODELVIEW)
- GL.glLoadIdentity()
- GL.glViewport(0, 0, self.width, self.height)
- for cache in self._gl_caches: cache.changed(True)
- self._resized_flag = False
-
- # clear buffer if needed
- if self.clear_accum or not self.use_persistence:
- GL.glClear(GL.GL_COLOR_BUFFER_BIT)
- self.clear_accum=False
-
- # apply fading
- if self.use_persistence:
- GL.glEnable(GL.GL_BLEND)
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
-
- GL.glBegin(GL.GL_QUADS)
- GL.glColor4f(1,1,1,self.persist_alpha)
- GL.glVertex2f(0, self.height)
- GL.glVertex2f(self.width, self.height)
- GL.glVertex2f(self.width, 0)
- GL.glVertex2f(0, 0)
- GL.glEnd()
-
- GL.glDisable(GL.GL_BLEND)
-
- # draw functions
- for fcn in self._draw_fcns: fcn[1]()
-
- # show result
- self.SwapBuffers()
- self.unlock()
-
- def update(self):
- """
- Force a paint event.
- """
- if not self._gl_init_flag: return
- wx.PostEvent(self, wx.PaintEvent())
diff --git a/gr-wxgui/python/wxgui/plotter/waterfall_plotter.py b/gr-wxgui/python/wxgui/plotter/waterfall_plotter.py
deleted file mode 100644
index a5601e25bc..0000000000
--- a/gr-wxgui/python/wxgui/plotter/waterfall_plotter.py
+++ /dev/null
@@ -1,294 +0,0 @@
-#
-# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-import wx
-from grid_plotter_base import grid_plotter_base
-from OpenGL import GL
-import common
-import numpy
-import gltext
-import math
-import struct
-
-LEGEND_LEFT_PAD = 7
-LEGEND_NUM_BLOCKS = 256
-LEGEND_NUM_LABELS = 9
-LEGEND_WIDTH = 8
-LEGEND_FONT_SIZE = 8
-LEGEND_BORDER_COLOR_SPEC = (0, 0, 0) #black
-MIN_PADDING = 0, 60, 0, 0 #top, right, bottom, left
-
-ceil_log2 = lambda x: 2**int(math.ceil(math.log(x)/math.log(2)))
-
-pack_color = lambda x: struct.unpack('I', struct.pack('BBBB', *x))[0]
-unpack_color = lambda x: struct.unpack('BBBB', struct.pack('I', int(x)))
-
-def _get_rbga(red_pts, green_pts, blue_pts, alpha_pts=[(0, 0), (1, 0)]):
- """
- Get an array of 256 rgba values where each index maps to a color.
- The scaling for red, green, blue, alpha are specified in piece-wise functions.
- The piece-wise functions consist of a set of x, y coordinates.
- 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.
-
- 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:]):
- #linear interpolation
- if x <= x2: return float(y1 - y2)/(x1 - x2)*(x - x1) + y1
- raise Exception
- return numpy.array([pack_color(map(
- lambda pw: int(255*_fcn(i/255.0, pw)),
- (red_pts, green_pts, blue_pts, alpha_pts),
- )) for i in range(0, 256)], numpy.uint32)
-
-COLORS = {
- 'rgb1': _get_rbga( #http://www.ks.uiuc.edu/Research/vmd/vmd-1.7.1/ug/img47.gif
- red_pts = [(0, 0), (.5, 0), (1, 1)],
- green_pts = [(0, 0), (.5, 1), (1, 0)],
- blue_pts = [(0, 1), (.5, 0), (1, 0)],
- ),
- 'rgb2': _get_rbga( #http://xtide.ldeo.columbia.edu/~krahmann/coledit/screen.jpg
- red_pts = [(0, 0), (3.0/8, 0), (5.0/8, 1), (7.0/8, 1), (1, .5)],
- green_pts = [(0, 0), (1.0/8, 0), (3.0/8, 1), (5.0/8, 1), (7.0/8, 0), (1, 0)],
- blue_pts = [(0, .5), (1.0/8, 1), (3.0/8, 1), (5.0/8, 0), (1, 0)],
- ),
- 'rgb3': _get_rbga(
- red_pts = [(0, 0), (1.0/3.0, 0), (2.0/3.0, 0), (1, 1)],
- green_pts = [(0, 0), (1.0/3.0, 0), (2.0/3.0, 1), (1, 0)],
- blue_pts = [(0, 0), (1.0/3.0, 1), (2.0/3.0, 0), (1, 0)],
- ),
- 'gray': _get_rbga(
- red_pts = [(0, 0), (1, 1)],
- green_pts = [(0, 0), (1, 1)],
- blue_pts = [(0, 0), (1, 1)],
- ),
-}
-
-##################################################
-# Waterfall Plotter
-##################################################
-class waterfall_plotter(grid_plotter_base):
- def __init__(self, parent):
- """
- Create a new channel plotter.
- """
- #init
- grid_plotter_base.__init__(self, parent, MIN_PADDING)
- #setup legend cache
- self._legend_cache = self.new_gl_cache(self._draw_legend)
- #setup waterfall cache
- self._waterfall_cache = self.new_gl_cache(self._draw_waterfall, 50)
- #setup waterfall plotter
- self.register_init(self._init_waterfall)
- self._resize_texture(False)
- self._minimum = 0
- self._maximum = 0
- self._fft_size = 1
- self._buffer = list()
- self._pointer = 0
- self._counter = 0
- self.set_num_lines(0)
- self.set_color_mode(COLORS.keys()[0])
- self.callback = None
-
- def _init_waterfall(self):
- """
- Run gl initialization tasks.
- """
- self._waterfall_texture = GL.glGenTextures(1)
-
- def _draw_waterfall(self):
- """
- Draw the waterfall from the texture.
- The texture is circularly filled and will wrap around.
- Use matrix modeling to shift and scale the texture onto the coordinate plane.
- """
- #resize texture
- self._resize_texture()
- #setup texture
- GL.glBindTexture(GL.GL_TEXTURE_2D, self._waterfall_texture)
- GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR)
- GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR)
- GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT)
- GL.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE)
- #write the buffer to the texture
- while self._buffer:
- GL.glTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, self._pointer, self._fft_size, 1, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, self._buffer.pop(0))
- self._pointer = (self._pointer + 1)%self._num_lines
- #begin drawing
- GL.glEnable(GL.GL_TEXTURE_2D)
- GL.glPushMatrix()
- #matrix scaling
- GL.glTranslatef(self.padding_left, self.padding_top, 0)
- GL.glScalef(
- float(self.width-self.padding_left-self.padding_right),
- float(self.height-self.padding_top-self.padding_bottom),
- 1.0,
- )
- #draw texture with wrapping
- GL.glBegin(GL.GL_QUADS)
- prop_y = float(self._pointer)/(self._num_lines-1)
- prop_x = float(self._fft_size)/ceil_log2(self._fft_size)
- off = 1.0/(self._num_lines-1)
- GL.glTexCoord2f(0, prop_y+1-off)
- GL.glVertex2f(0, 1)
- GL.glTexCoord2f(prop_x, prop_y+1-off)
- GL.glVertex2f(1, 1)
- GL.glTexCoord2f(prop_x, prop_y)
- GL.glVertex2f(1, 0)
- GL.glTexCoord2f(0, prop_y)
- GL.glVertex2f(0, 0)
- GL.glEnd()
- GL.glPopMatrix()
- GL.glDisable(GL.GL_TEXTURE_2D)
-
- def _populate_point_label(self, x_val, y_val):
- """
- Get the text the will populate the point label.
- Give the X value for the current point.
-
- 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))
-
- def _call_callback(self, x_val, y_val):
- if self.callback != None:
- self.callback(x_val,y_val)
-
- def set_callback(self,callback):
- self.callback = callback
-
- def _draw_legend(self):
- """
- Draw the color scale legend.
- """
- if not self._color_mode: return
- legend_height = self.height-self.padding_top-self.padding_bottom
- #draw each legend block
- block_height = float(legend_height)/LEGEND_NUM_BLOCKS
- x = self.width - self.padding_right + LEGEND_LEFT_PAD
- for i in range(LEGEND_NUM_BLOCKS):
- color = unpack_color(COLORS[self._color_mode][int(255*i/float(LEGEND_NUM_BLOCKS-1))])
- GL.glColor4f(*numpy.array(color)/255.0)
- y = self.height - (i+1)*block_height - self.padding_bottom
- self._draw_rect(x, y, LEGEND_WIDTH, block_height)
- #draw rectangle around color scale border
- GL.glColor3f(*LEGEND_BORDER_COLOR_SPEC)
- self._draw_rect(x, self.padding_top, LEGEND_WIDTH, legend_height, fill=False)
- #draw each legend label
- label_spacing = float(legend_height)/(LEGEND_NUM_LABELS-1)
- x = self.width - (self.padding_right - LEGEND_LEFT_PAD - LEGEND_WIDTH)/2
- for i in range(LEGEND_NUM_LABELS):
- proportion = i/float(LEGEND_NUM_LABELS-1)
- dB = proportion*(self._maximum - self._minimum) + self._minimum
- y = self.height - i*label_spacing - self.padding_bottom
- txt = gltext.Text('%ddB'%int(dB), font_size=LEGEND_FONT_SIZE, centered=True)
- txt.draw_text(wx.Point(x, y))
-
- def _resize_texture(self, flag=None):
- """
- Create the texture to fit the fft_size X num_lines.
-
- Args:
- flag: the set/unset or update flag
- """
- if flag is not None:
- self._resize_texture_flag = flag
- return
- if not self._resize_texture_flag: return
- self._buffer = list()
- self._pointer = 0
- if self._num_lines and self._fft_size:
- GL.glBindTexture(GL.GL_TEXTURE_2D, self._waterfall_texture)
- data = numpy.zeros(self._num_lines*ceil_log2(self._fft_size)*4, numpy.uint8).tostring()
- GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, ceil_log2(self._fft_size), self._num_lines, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, data)
- self._resize_texture_flag = False
-
- def set_color_mode(self, color_mode):
- """
- Set the color mode.
- New samples will be converted to the new color mode.
- Old samples will not be recolorized.
-
- Args:
- color_mode: the new color mode string
- """
- self.lock()
- if color_mode in COLORS.keys():
- self._color_mode = color_mode
- self._legend_cache.changed(True)
- self.update()
- self.unlock()
-
- def set_num_lines(self, num_lines):
- """
- Set number of lines.
- Powers of two only.
-
- Args:
- num_lines: the new number of lines
- """
- self.lock()
- self._num_lines = num_lines
- self._resize_texture(True)
- self.update()
- self.unlock()
-
- def set_samples(self, samples, minimum, maximum):
- """
- Set the samples to the waterfall.
- Convert the samples to color data.
-
- 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
- if self._minimum != minimum or self._maximum != maximum:
- self._minimum = minimum
- self._maximum = maximum
- self._legend_cache.changed(True)
- if self._fft_size != len(samples):
- self._fft_size = len(samples)
- self._resize_texture(True)
- #normalize the samples to min/max
- samples = (samples - minimum)*float(255/(maximum-minimum))
- samples = numpy.clip(samples, 0, 255) #clip
- samples = numpy.array(samples, numpy.uint8)
- #convert the samples to RGBA data
- data = COLORS[self._color_mode][samples].tostring()
- self._buffer.append(data)
- self._waterfall_cache.changed(True)
- self.unlock()
diff --git a/gr-wxgui/python/wxgui/powermate.py b/gr-wxgui/python/wxgui/powermate.py
deleted file mode 100644
index 7c324c5d95..0000000000
--- a/gr-wxgui/python/wxgui/powermate.py
+++ /dev/null
@@ -1,448 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2005 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-"""
-Handler for Griffin PowerMate, Contour ShuttlePro & ShuttleXpress USB knobs
-
-This is Linux and wxPython specific.
-"""
-
-import os
-import sys
-import struct
-import exceptions
-import threading
-import wx
-from gnuradio import gru
-
-imported_ok = True
-
-try:
- import select
- import fcntl
-except ImportError:
- imported_ok = False
-
-
-# First a little bit of background:
-#
-# The Griffin PowerMate has
-# * a single knob which rotates
-# * a single button (pressing the knob)
-#
-# The Contour ShuttleXpress (aka SpaceShuttle) has
-# * "Jog Wheel" -- the knob (rotary encoder) on the inside
-# * "Shuttle Ring" -- the spring loaded rubber covered ring
-# * 5 buttons
-#
-# The Contour ShuttlePro has
-# * "Jog Wheel" -- the knob (rotary encoder) on the inside
-# * "Shuttle Ring" -- the spring loaded rubber covered ring
-# * 13 buttons
-#
-# The Contour ShuttlePro V2 has
-# *"Jog Wheel" -- the knob (rotary encoder) on the inside
-# * "Shuttle Ring" -- the spring loaded rubber covered ring
-# * 15 buttons
-
-# We remap all the buttons on the devices so that they start at zero.
-
-# For the ShuttleXpress the buttons are 0 to 4 (left to right)
-
-# For the ShuttlePro, we number the buttons immediately above
-# the ring 0 to 4 (left to right) so that they match our numbering
-# on the ShuttleXpress. The top row is 5, 6, 7, 8. The first row below
-# the ring is 9, 10, and the bottom row is 11, 12.
-
-# For the ShuttlePro V2, buttons 13 & 14 are to the
-# left and right of the wheel respectively.
-
-# We generate 3 kinds of events:
-#
-# button press/release (button_number, press/release)
-# knob rotation (relative_clicks) # typically -1, +1
-# shuttle position (absolute_position) # -7,-6,...,0,...,6,7
-
-# ----------------------------------------------------------------
-# Our ID's for the devices:
-# Not to be confused with anything related to magic hardware numbers.
-
-ID_POWERMATE = 'powermate'
-ID_SHUTTLE_XPRESS = 'shuttle xpress'
-ID_SHUTTLE_PRO = 'shuttle pro'
-ID_SHUTTLE_PRO_V2 = 'shuttle pro v2'
-
-# ------------------------------------------------------------------------
-# format of messages that we read from /dev/input/event*
-# See /usr/include/linux/input.h for more info
-#
-#struct input_event {
-# struct timeval time; = {long seconds, long microseconds}
-# unsigned short type;
-# unsigned short code;
-# unsigned int value;
-#};
-
-input_event_struct = "@llHHi"
-input_event_size = struct.calcsize(input_event_struct)
-
-# ------------------------------------------------------------------------
-# input_event types
-# ------------------------------------------------------------------------
-
-IET_SYN = 0x00 # aka RESET
-IET_KEY = 0x01 # key or button press/release
-IET_REL = 0x02 # relative movement (knob rotation)
-IET_ABS = 0x03 # absolute position (graphics pad, etc)
-IET_MSC = 0x04
-IET_LED = 0x11
-IET_SND = 0x12
-IET_REP = 0x14
-IET_FF = 0x15
-IET_PWR = 0x16
-IET_FF_STATUS = 0x17
-IET_MAX = 0x1f
-
-# ------------------------------------------------------------------------
-# input_event codes (there are a zillion of them, we only define a few)
-# ------------------------------------------------------------------------
-
-# these are valid for IET_KEY
-
-IEC_BTN_0 = 0x100
-IEC_BTN_1 = 0x101
-IEC_BTN_2 = 0x102
-IEC_BTN_3 = 0x103
-IEC_BTN_4 = 0x104
-IEC_BTN_5 = 0x105
-IEC_BTN_6 = 0x106
-IEC_BTN_7 = 0x107
-IEC_BTN_8 = 0x108
-IEC_BTN_9 = 0x109
-IEC_BTN_10 = 0x10a
-IEC_BTN_11 = 0x10b
-IEC_BTN_12 = 0x10c
-IEC_BTN_13 = 0x10d
-IEC_BTN_14 = 0x10e
-IEC_BTN_15 = 0x10f
-
-# these are valid for IET_REL (Relative axes)
-
-IEC_REL_X = 0x00
-IEC_REL_Y = 0x01
-IEC_REL_Z = 0x02
-IEC_REL_HWHEEL = 0x06
-IEC_REL_DIAL = 0x07 # rotating the knob
-IEC_REL_WHEEL = 0x08 # moving the shuttle ring
-IEC_REL_MISC = 0x09
-IEC_REL_MAX = 0x0f
-
-# ------------------------------------------------------------------------
-
-class powermate(threading.Thread):
- """
- Interface to Griffin PowerMate and Contour Shuttles
- """
- def __init__(self, event_receiver=None, filename=None, **kwargs):
- self.event_receiver = event_receiver
- self.handle = -1
- if not imported_ok:
- raise exceptions.RuntimeError, 'powermate not supported on this platform'
-
- if filename:
- if not self._open_device(filename):
- raise exceptions.RuntimeError, 'Unable to find powermate'
- else:
- ok = False
- for d in range(0, 16):
- if self._open_device("/dev/input/event%d" % d):
- ok = True
- break
- if not ok:
- raise exceptions.RuntimeError, 'Unable to find powermate'
-
- threading.Thread.__init__(self, **kwargs)
- self.setDaemon (1)
- self.keep_running = True
- self.start ()
-
- def __del__(self):
- self.keep_running = False
- if self.handle >= 0:
- os.close(self.handle)
- self.handle = -1
-
- def _open_device(self, filename):
- try:
- self.handle = os.open(filename, os.O_RDWR)
- if self.handle < 0:
- return False
-
- # read event device name
- name = fcntl.ioctl(self.handle, gru.hexint(0x80ff4506), chr(0) * 256)
- name = name.replace(chr(0), '')
-
- # do we see anything we recognize?
- if name == 'Griffin PowerMate' or name == 'Griffin SoundKnob':
- self.id = ID_POWERMATE
- self.mapper = _powermate_remapper()
- elif name == 'CAVS SpaceShuttle A/V' or name == 'Contour Design ShuttleXpress':
- self.id = ID_SHUTTLE_XPRESS
- self.mapper = _contour_remapper()
- elif name == 'Contour Design ShuttlePRO':
- self.id = ID_SHUTTLE_PRO
- self.mapper = _contour_remapper()
- elif name == 'Contour Design ShuttlePRO v2':
- self.id = ID_SHUTTLE_PRO_V2
- self.mapper = _contour_remapper()
- else:
- os.close(self.handle)
- self.handle = -1
- return False
-
- # get exclusive control of the device, using ioctl EVIOCGRAB
- # there may be an issue with this on non x86 platforms and if
- # the _IOW,_IOC,... macros in <asm/ioctl.h> are changed
- fcntl.ioctl(self.handle,gru.hexint(0x40044590), 1)
- return True
- except exceptions.OSError:
- return False
-
-
- def set_event_receiver(self, obj):
- self.event_receiver = obj
-
-
- def set_led_state(self, static_brightness, pulse_speed=0,
- pulse_table=0, pulse_on_sleep=0, pulse_on_wake=0):
- """
- What do these magic values mean...
- """
- if self.id != ID_POWERMATE:
- return False
-
- static_brightness &= 0xff;
- if pulse_speed < 0:
- pulse_speed = 0
- if pulse_speed > 510:
- pulse_speed = 510
- if pulse_table < 0:
- pulse_table = 0
- if pulse_table > 2:
- pulse_table = 2
- pulse_on_sleep = not not pulse_on_sleep # not not = convert to 0/1
- pulse_on_wake = not not pulse_on_wake
- magic = (static_brightness
- | (pulse_speed << 8)
- | (pulse_table << 17)
- | (pulse_on_sleep << 19)
- | (pulse_on_wake << 20))
- data = struct.pack(input_event_struct, 0, 0, 0x04, 0x01, magic)
- os.write(self.handle, data)
- return True
-
- def run (self):
- while (self.keep_running):
- s = os.read (self.handle, input_event_size)
- if not s:
- self.keep_running = False
- break
-
- raw_input_event = struct.unpack(input_event_struct,s)
- sec, usec, type, code, val = self.mapper(raw_input_event)
-
- if self.event_receiver is None:
- continue
-
- if type == IET_SYN: # ignore
- pass
- elif type == IET_MSC: # ignore (seems to be PowerMate reporting led brightness)
- pass
- elif type == IET_REL and code == IEC_REL_DIAL:
- #print "Dial: %d" % (val,)
- wx.PostEvent(self.event_receiver, PMRotateEvent(val))
- elif type == IET_REL and code == IEC_REL_WHEEL:
- #print "Shuttle: %d" % (val,)
- wx.PostEvent(self.event_receiver, PMShuttleEvent(val))
- elif type == IET_KEY:
- #print "Key: Btn%d %d" % (code - IEC_BTN_0, val)
- wx.PostEvent(self.event_receiver,
- PMButtonEvent(code - IEC_BTN_0, val))
- else:
- print "powermate: unrecognized event: type = 0x%x code = 0x%x val = %d" % (type, code, val)
-
-
-class _powermate_remapper(object):
- def __init__(self):
- pass
- def __call__(self, event):
- """
- Notice how nice and simple this is...
- """
- return event
-
-class _contour_remapper(object):
- def __init__(self):
- self.prev = None
- def __call__(self, event):
- """
- ...and how screwed up this is
- """
- sec, usec, type, code, val = event
- if type == IET_REL and code == IEC_REL_WHEEL:
- # === Shuttle ring ===
- # First off, this really ought to be IET_ABS, not IET_REL!
- # They never generate a zero value so you can't
- # tell when the shuttle ring is back in the center.
- # We kludge around this by calling both -1 and 1 zero.
- if val == -1 or val == 1:
- return (sec, usec, type, code, 0)
- return event
-
- if type == IET_REL and code == IEC_REL_DIAL:
- # === Jog knob (rotary encoder) ===
- # Dim wits got it wrong again! This one should return a
- # a relative value, e.g., -1, +1. Instead they return
- # a total that runs modulo 256 (almost!). For some
- # reason they count like this 253, 254, 255, 1, 2, 3
-
- if self.prev is None: # first time call
- self.prev = val
- return (sec, usec, IET_SYN, 0, 0) # will be ignored above
-
- diff = val - self.prev
- if diff == 0: # sometimes it just sends stuff...
- return (sec, usec, IET_SYN, 0, 0) # will be ignored above
-
- if abs(diff) > 100: # crossed into the twilight zone
- if self.prev > val: # we've wrapped going forward
- self.prev = val
- return (sec, usec, type, code, +1)
- else: # we've wrapped going backward
- self.prev = val
- return (sec, usec, type, code, -1)
-
- self.prev = val
- return (sec, usec, type, code, diff)
-
- if type == IET_KEY:
- # remap keys so that all 3 gadgets have buttons 0 to 4 in common
- return (sec, usec, type,
- (IEC_BTN_5, IEC_BTN_6, IEC_BTN_7, IEC_BTN_8,
- IEC_BTN_0, IEC_BTN_1, IEC_BTN_2, IEC_BTN_3, IEC_BTN_4,
- IEC_BTN_9, IEC_BTN_10,
- IEC_BTN_11, IEC_BTN_12,
- IEC_BTN_13, IEC_BTN_14)[code - IEC_BTN_0], val)
-
- return event
-
-# ------------------------------------------------------------------------
-# new wxPython event classes
-# ------------------------------------------------------------------------
-
-grEVT_POWERMATE_BUTTON = wx.NewEventType()
-grEVT_POWERMATE_ROTATE = wx.NewEventType()
-grEVT_POWERMATE_SHUTTLE = wx.NewEventType()
-
-EVT_POWERMATE_BUTTON = wx.PyEventBinder(grEVT_POWERMATE_BUTTON, 0)
-EVT_POWERMATE_ROTATE = wx.PyEventBinder(grEVT_POWERMATE_ROTATE, 0)
-EVT_POWERMATE_SHUTTLE = wx.PyEventBinder(grEVT_POWERMATE_SHUTTLE, 0)
-
-class PMButtonEvent(wx.PyEvent):
- def __init__(self, button, value):
- wx.PyEvent.__init__(self)
- self.SetEventType(grEVT_POWERMATE_BUTTON)
- self.button = button
- self.value = value
-
- def Clone (self):
- self.__class__(self.GetId())
-
-
-class PMRotateEvent(wx.PyEvent):
- def __init__(self, delta):
- wx.PyEvent.__init__(self)
- self.SetEventType (grEVT_POWERMATE_ROTATE)
- self.delta = delta
-
- def Clone (self):
- self.__class__(self.GetId())
-
-
-class PMShuttleEvent(wx.PyEvent):
- def __init__(self, position):
- wx.PyEvent.__init__(self)
- self.SetEventType (grEVT_POWERMATE_SHUTTLE)
- self.position = position
-
- def Clone (self):
- self.__class__(self.GetId())
-
-# ------------------------------------------------------------------------
-# Example usage
-# ------------------------------------------------------------------------
-
-if __name__ == '__main__':
- class Frame(wx.Frame):
- def __init__(self,parent=None,id=-1,title='Title',
- pos=wx.DefaultPosition, size=(400,200)):
- wx.Frame.__init__(self,parent,id,title,pos,size)
- EVT_POWERMATE_BUTTON(self, self.on_button)
- EVT_POWERMATE_ROTATE(self, self.on_rotate)
- EVT_POWERMATE_SHUTTLE(self, self.on_shuttle)
- self.brightness = 128
- self.pulse_speed = 0
-
- try:
- self.pm = powermate(self)
- except:
- sys.stderr.write("Unable to find PowerMate or Contour Shuttle\n")
- sys.exit(1)
-
- self.pm.set_led_state(self.brightness, self.pulse_speed)
-
-
- def on_button(self, evt):
- print "Button %d %s" % (evt.button,
- ("Released", "Pressed")[evt.value])
-
- def on_rotate(self, evt):
- print "Rotated %d" % (evt.delta,)
- if 0:
- new = max(0, min(255, self.brightness + evt.delta))
- if new != self.brightness:
- self.brightness = new
- self.pm.set_led_state(self.brightness, self.pulse_speed)
-
- def on_shuttle(self, evt):
- print "Shuttle %d" % (evt.position,)
-
- class App(wx.App):
- def OnInit(self):
- title='PowerMate Demo'
- self.frame = Frame(parent=None,id=-1,title=title)
- self.frame.Show()
- self.SetTopWindow(self.frame)
- return True
-
- app = App()
- app.MainLoop ()
diff --git a/gr-wxgui/python/wxgui/pubsub.py b/gr-wxgui/python/wxgui/pubsub.py
deleted file mode 100644
index e55d691978..0000000000
--- a/gr-wxgui/python/wxgui/pubsub.py
+++ /dev/null
@@ -1,153 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2008 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-"""
-Abstract GNU Radio publisher/subscriber interface
-
-This is a proof of concept implementation, will likely change significantly.
-"""
-
-class pubsub(dict):
- def __init__(self):
- self._publishers = { }
- self._subscribers = { }
- self._proxies = { }
-
- def __missing__(self, key, value=None):
- dict.__setitem__(self, key, value)
- self._publishers[key] = None
- self._subscribers[key] = []
- self._proxies[key] = None
-
- def __setitem__(self, key, val):
- if not self.has_key(key):
- self.__missing__(key, val)
- elif self._proxies[key] is not None:
- (p, pkey) = self._proxies[key]
- p[pkey] = val
- else:
- dict.__setitem__(self, key, val)
- for sub in self._subscribers[key]:
- # Note this means subscribers will get called in the thread
- # context of the 'set' caller.
- sub(val)
-
- def __getitem__(self, key):
- if not self.has_key(key): self.__missing__(key)
- if self._proxies[key] is not None:
- (p, pkey) = self._proxies[key]
- return p[pkey]
- elif self._publishers[key] is not None:
- return self._publishers[key]()
- else:
- return dict.__getitem__(self, key)
-
- def publish(self, key, publisher):
- if not self.has_key(key): self.__missing__(key)
- if self._proxies[key] is not None:
- (p, pkey) = self._proxies[key]
- p.publish(pkey, publisher)
- else:
- self._publishers[key] = publisher
-
- def subscribe(self, key, subscriber):
- if not self.has_key(key): self.__missing__(key)
- if self._proxies[key] is not None:
- (p, pkey) = self._proxies[key]
- p.subscribe(pkey, subscriber)
- else:
- self._subscribers[key].append(subscriber)
-
- def unpublish(self, key):
- if self._proxies[key] is not None:
- (p, pkey) = self._proxies[key]
- p.unpublish(pkey)
- else:
- self._publishers[key] = None
-
- def unsubscribe(self, key, subscriber):
- if self._proxies[key] is not None:
- (p, pkey) = self._proxies[key]
- p.unsubscribe(pkey, subscriber)
- else:
- self._subscribers[key].remove(subscriber)
-
- def proxy(self, key, p, pkey=None):
- if not self.has_key(key): self.__missing__(key)
- if pkey is None: pkey = key
- self._proxies[key] = (p, pkey)
-
- def unproxy(self, key):
- self._proxies[key] = None
-
-# Test code
-if __name__ == "__main__":
- import sys
- o = pubsub()
-
- # Non-existent key gets auto-created with None value
- print "Auto-created key 'foo' value:", o['foo']
-
- # Add some subscribers
- # First is a bare function
- def print_len(x):
- print "len=%i" % (len(x), )
- o.subscribe('foo', print_len)
-
- # The second is a class member function
- class subber(object):
- def __init__(self, param):
- self._param = param
- def printer(self, x):
- print self._param, `x`
- s = subber('param')
- o.subscribe('foo', s.printer)
-
- # The third is a lambda function
- o.subscribe('foo', lambda x: sys.stdout.write('val='+`x`+'\n'))
-
- # Update key 'foo', will notify subscribers
- print "Updating 'foo' with three subscribers:"
- o['foo'] = 'bar';
-
- # Remove first subscriber
- o.unsubscribe('foo', print_len)
-
- # Update now will only trigger second and third subscriber
- print "Updating 'foo' after removing a subscriber:"
- o['foo'] = 'bar2';
-
- # Publish a key as a function, in this case, a lambda function
- o.publish('baz', lambda : 42)
- print "Published value of 'baz':", o['baz']
-
- # Unpublish the key
- o.unpublish('baz')
-
- # This will return None, as there is no publisher
- print "Value of 'baz' with no publisher:", o['baz']
-
- # Set 'baz' key, it gets cached
- o['baz'] = 'bazzz'
-
- # Now will return cached value, since no provider
- print "Cached value of 'baz' after being set:", o['baz']
diff --git a/gr-wxgui/python/wxgui/scope_window.py b/gr-wxgui/python/wxgui/scope_window.py
deleted file mode 100644
index 71e2b8e285..0000000000
--- a/gr-wxgui/python/wxgui/scope_window.py
+++ /dev/null
@@ -1,691 +0,0 @@
-#
-# Copyright 2008,2010 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-import plotter
-import common
-import wx
-import numpy
-import time
-import pubsub
-from constants import *
-from gnuradio import gr #for gr.prefs, trigger modes
-from gnuradio import wxgui
-import forms
-
-##################################################
-# Constants
-##################################################
-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', wxgui.TRIG_MODE_AUTO)
-DEFAULT_WIN_SIZE = (600, 300)
-COUPLING_MODES = (
- ('DC', False),
- ('AC', True),
-)
-TRIGGER_MODES = (
- ('Freerun', wxgui.TRIG_MODE_FREE),
- ('Auto', wxgui.TRIG_MODE_AUTO),
- ('Normal', wxgui.TRIG_MODE_NORM),
- ('Stripchart', wxgui.TRIG_MODE_STRIPCHART),
-)
-TRIGGER_SLOPES = (
- ('Pos +', wxgui.TRIG_SLOPE_POS),
- ('Neg -', wxgui.TRIG_SLOPE_NEG),
-)
-CHANNEL_COLOR_SPECS = (
- (0.3, 0.3, 1.0),
- (0.0, 0.8, 0.0),
- (1.0, 0.0, 0.0),
- (0.8, 0.0, 0.8),
- (0.7, 0.7, 0.0),
- (0.15, 0.90, 0.98),
-
-)
-TRIGGER_COLOR_SPEC = (1.0, 0.4, 0.0)
-AUTORANGE_UPDATE_RATE = 0.5 #sec
-MARKER_TYPES = (
- ('Line Link', None),
- ('Dot Large', 3.0),
- ('Dot Med', 2.0),
- ('Dot Small', 1.0),
- ('None', 0.0),
-)
-DEFAULT_MARKER_TYPE = None
-
-##################################################
-# Scope window control panel
-##################################################
-class control_panel(wx.Panel):
- """
- A control panel with wx widgits to control the plotter and scope block.
- """
- def __init__(self, parent):
- """
- Create a new control panel.
-
- Args:
- parent: the wx parent window
- """
- WIDTH = 90
- self.parent = parent
- wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
- parent[SHOW_CONTROL_PANEL_KEY] = True
- parent.subscribe(SHOW_CONTROL_PANEL_KEY, self.Show)
- control_box = wx.BoxSizer(wx.VERTICAL)
-
- ##################################################
- # Persistence
- ##################################################
-
- forms.check_box(
- sizer=control_box, parent=self, label='Persistence',
- ps=parent, key=USE_PERSISTENCE_KEY,
- )
- #static text and slider for analog alpha
- persist_alpha_text = forms.static_text(
- sizer=control_box, parent=self, label='Analog Alpha',
- converter=forms.float_converter(lambda x: '%.4f'%x),
- ps=parent, key=PERSIST_ALPHA_KEY, width=50,
- )
- persist_alpha_slider = forms.log_slider(
- sizer=control_box, parent=self,
- min_exp=PERSIST_ALPHA_MIN_EXP,
- max_exp=PERSIST_ALPHA_MAX_EXP,
- num_steps=SLIDER_STEPS,
- ps=parent, key=PERSIST_ALPHA_KEY,
- )
- for widget in (persist_alpha_text, persist_alpha_slider):
- parent.subscribe(USE_PERSISTENCE_KEY, widget.Enable)
- widget.Enable(parent[USE_PERSISTENCE_KEY])
- parent.subscribe(USE_PERSISTENCE_KEY, widget.ShowItems)
- #allways show initially, so room is reserved for them
- widget.ShowItems(True) # (parent[USE_PERSISTENCE_KEY])
-
- parent.subscribe(USE_PERSISTENCE_KEY, self._update_layout)
-
- ##################################################
- # Axes Options
- ##################################################
- control_box.AddStretchSpacer()
- axes_options_box = forms.static_box_sizer(
- parent=self, sizer=control_box, label='Axes Options',
- bold=True, orient=wx.VERTICAL,
- )
- ##################################################
- # Scope Mode Box
- ##################################################
- scope_mode_box = wx.BoxSizer(wx.VERTICAL)
- axes_options_box.Add(scope_mode_box, 0, wx.EXPAND)
- #x axis divs
- forms.incr_decr_buttons(
- parent=self, sizer=scope_mode_box, label='Secs/Div',
- on_incr=self._on_incr_t_divs, on_decr=self._on_decr_t_divs,
- )
- #y axis divs
- y_buttons_scope = forms.incr_decr_buttons(
- parent=self, sizer=scope_mode_box, label='Counts/Div',
- on_incr=self._on_incr_y_divs, on_decr=self._on_decr_y_divs,
- )
- #y axis ref lvl
- y_off_buttons_scope = forms.incr_decr_buttons(
- parent=self, sizer=scope_mode_box, label='Y Offset',
- on_incr=self._on_incr_y_off, on_decr=self._on_decr_y_off,
- )
- #t axis ref lvl
- scope_mode_box.AddSpacer(5)
- forms.slider(
- parent=self, sizer=scope_mode_box,
- ps=parent, key=T_FRAC_OFF_KEY, label='T Offset',
- minimum=0, maximum=1, num_steps=1000,
- )
- scope_mode_box.AddSpacer(5)
- ##################################################
- # XY Mode Box
- ##################################################
- xy_mode_box = wx.BoxSizer(wx.VERTICAL)
- axes_options_box.Add(xy_mode_box, 0, wx.EXPAND)
- #x div controls
- x_buttons = forms.incr_decr_buttons(
- parent=self, sizer=xy_mode_box, label='X/Div',
- on_incr=self._on_incr_x_divs, on_decr=self._on_decr_x_divs,
- )
- #y div controls
- y_buttons = forms.incr_decr_buttons(
- parent=self, sizer=xy_mode_box, label='Y/Div',
- on_incr=self._on_incr_y_divs, on_decr=self._on_decr_y_divs,
- )
- #x offset controls
- x_off_buttons = forms.incr_decr_buttons(
- parent=self, sizer=xy_mode_box, label='X Off',
- on_incr=self._on_incr_x_off, on_decr=self._on_decr_x_off,
- )
- #y offset controls
- y_off_buttons = forms.incr_decr_buttons(
- parent=self, sizer=xy_mode_box, label='Y Off',
- on_incr=self._on_incr_y_off, on_decr=self._on_decr_y_off,
- )
- for widget in (y_buttons_scope, y_off_buttons_scope, x_buttons, y_buttons, x_off_buttons, y_off_buttons):
- parent.subscribe(AUTORANGE_KEY, widget.Disable)
- widget.Disable(parent[AUTORANGE_KEY])
- xy_mode_box.ShowItems(False)
- #autorange check box
- forms.check_box(
- parent=self, sizer=axes_options_box, label='Autorange',
- ps=parent, key=AUTORANGE_KEY,
- )
- ##################################################
- # Channel Options
- ##################################################
- TRIGGER_PAGE_INDEX = parent.num_inputs
- XY_PAGE_INDEX = parent.num_inputs+1
- control_box.AddStretchSpacer()
- chan_options_box = forms.static_box_sizer(
- parent=self, sizer=control_box, label='Channel Options',
- bold=True, orient=wx.VERTICAL,
- )
- options_notebook = wx.Notebook(self)
- options_notebook_args = list()
- CHANNELS = [('Ch %d'%(i+1), i) for i in range(parent.num_inputs)]
- ##################################################
- # Channel Menu Boxes
- ##################################################
- for i in range(parent.num_inputs):
- channel_menu_panel = wx.Panel(options_notebook)
- options_notebook_args.append((channel_menu_panel, i, 'Ch%d'%(i+1)))
- channel_menu_box = wx.BoxSizer(wx.VERTICAL)
- channel_menu_panel.SetSizer(channel_menu_box)
- #ac couple check box
- channel_menu_box.AddStretchSpacer()
- forms.drop_down(
- parent=channel_menu_panel, sizer=channel_menu_box,
- ps=parent, key=common.index_key(AC_COUPLE_KEY, i),
- choices=map(lambda x: x[1], COUPLING_MODES),
- labels=map(lambda x: x[0], COUPLING_MODES),
- label='Coupling', width=WIDTH,
- )
- #marker
- channel_menu_box.AddStretchSpacer()
- forms.drop_down(
- parent=channel_menu_panel, sizer=channel_menu_box,
- ps=parent, key=common.index_key(MARKER_KEY, i),
- choices=map(lambda x: x[1], MARKER_TYPES),
- labels=map(lambda x: x[0], MARKER_TYPES),
- label='Marker', width=WIDTH,
- )
- channel_menu_box.AddStretchSpacer()
- ##################################################
- # Trigger Menu Box
- ##################################################
- trigger_menu_panel = wx.Panel(options_notebook)
- options_notebook_args.append((trigger_menu_panel, TRIGGER_PAGE_INDEX, 'Trig'))
- trigger_menu_box = wx.BoxSizer(wx.VERTICAL)
- trigger_menu_panel.SetSizer(trigger_menu_box)
- #trigger mode
- forms.drop_down(
- parent=trigger_menu_panel, sizer=trigger_menu_box,
- ps=parent, key=TRIGGER_MODE_KEY,
- choices=map(lambda x: x[1], TRIGGER_MODES),
- labels=map(lambda x: x[0], TRIGGER_MODES),
- label='Mode', width=WIDTH,
- )
- #trigger slope
- trigger_slope_chooser = forms.drop_down(
- parent=trigger_menu_panel, sizer=trigger_menu_box,
- ps=parent, key=TRIGGER_SLOPE_KEY,
- choices=map(lambda x: x[1], TRIGGER_SLOPES),
- labels=map(lambda x: x[0], TRIGGER_SLOPES),
- label='Slope', width=WIDTH,
- )
- #trigger channel
- trigger_channel_chooser = forms.drop_down(
- parent=trigger_menu_panel, sizer=trigger_menu_box,
- ps=parent, key=TRIGGER_CHANNEL_KEY,
- choices=map(lambda x: x[1], CHANNELS),
- labels=map(lambda x: x[0], CHANNELS),
- label='Channel', width=WIDTH,
- )
- #trigger level
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- trigger_menu_box.Add(hbox, 0, wx.EXPAND)
- hbox.Add(wx.StaticText(trigger_menu_panel, label='Level:'), 1, wx.ALIGN_CENTER_VERTICAL)
- trigger_level_button = forms.single_button(
- parent=trigger_menu_panel, sizer=hbox, label='50%',
- callback=parent.set_auto_trigger_level, style=wx.BU_EXACTFIT,
- )
- hbox.AddSpacer(WIDTH-60)
- trigger_level_buttons = forms.incr_decr_buttons(
- parent=trigger_menu_panel, sizer=hbox,
- on_incr=self._on_incr_trigger_level, on_decr=self._on_decr_trigger_level,
- )
- def disable_all(trigger_mode):
- for widget in (trigger_slope_chooser, trigger_channel_chooser, trigger_level_buttons, trigger_level_button):
- widget.Disable(trigger_mode == wxgui.TRIG_MODE_FREE)
- parent.subscribe(TRIGGER_MODE_KEY, disable_all)
- disable_all(parent[TRIGGER_MODE_KEY])
- ##################################################
- # XY Menu Box
- ##################################################
- if parent.num_inputs > 1:
- xy_menu_panel = wx.Panel(options_notebook)
- options_notebook_args.append((xy_menu_panel, XY_PAGE_INDEX, 'XY'))
- xy_menu_box = wx.BoxSizer(wx.VERTICAL)
- xy_menu_panel.SetSizer(xy_menu_box)
- #x and y channel choosers
- xy_menu_box.AddStretchSpacer()
- forms.drop_down(
- parent=xy_menu_panel, sizer=xy_menu_box,
- ps=parent, key=X_CHANNEL_KEY,
- choices=map(lambda x: x[1], CHANNELS),
- labels=map(lambda x: x[0], CHANNELS),
- label='Channel X', width=WIDTH,
- )
- xy_menu_box.AddStretchSpacer()
- forms.drop_down(
- parent=xy_menu_panel, sizer=xy_menu_box,
- ps=parent, key=Y_CHANNEL_KEY,
- choices=map(lambda x: x[1], CHANNELS),
- labels=map(lambda x: x[0], CHANNELS),
- label='Channel Y', width=WIDTH,
- )
- #marker
- xy_menu_box.AddStretchSpacer()
- forms.drop_down(
- parent=xy_menu_panel, sizer=xy_menu_box,
- ps=parent, key=XY_MARKER_KEY,
- choices=map(lambda x: x[1], MARKER_TYPES),
- labels=map(lambda x: x[0], MARKER_TYPES),
- label='Marker', width=WIDTH,
- )
- xy_menu_box.AddStretchSpacer()
- ##################################################
- # Setup Options Notebook
- ##################################################
- forms.notebook(
- parent=self, sizer=chan_options_box,
- notebook=options_notebook,
- ps=parent, key=CHANNEL_OPTIONS_KEY,
- pages=map(lambda x: x[0], options_notebook_args),
- choices=map(lambda x: x[1], options_notebook_args),
- labels=map(lambda x: x[2], options_notebook_args),
- )
- #gui handling for channel options changing
- def options_notebook_changed(chan_opt):
- try:
- parent[TRIGGER_SHOW_KEY] = chan_opt == TRIGGER_PAGE_INDEX
- parent[XY_MODE_KEY] = chan_opt == XY_PAGE_INDEX
- except wx.PyDeadObjectError: pass
- parent.subscribe(CHANNEL_OPTIONS_KEY, options_notebook_changed)
- #gui handling for xy mode changing
- def xy_mode_changed(mode):
- #ensure xy tab is selected
- if mode and parent[CHANNEL_OPTIONS_KEY] != XY_PAGE_INDEX:
- parent[CHANNEL_OPTIONS_KEY] = XY_PAGE_INDEX
- #ensure xy tab is not selected
- elif not mode and parent[CHANNEL_OPTIONS_KEY] == XY_PAGE_INDEX:
- parent[CHANNEL_OPTIONS_KEY] = 0
- #show/hide control buttons
- scope_mode_box.ShowItems(not mode)
- xy_mode_box.ShowItems(mode)
- control_box.Layout()
- parent.subscribe(XY_MODE_KEY, xy_mode_changed)
- xy_mode_changed(parent[XY_MODE_KEY])
- ##################################################
- # Run/Stop Button
- ##################################################
- #run/stop
- control_box.AddStretchSpacer()
- forms.toggle_button(
- sizer=control_box, parent=self,
- true_label='Stop', false_label='Run',
- ps=parent, key=RUNNING_KEY,
- )
- #set sizer
- self.SetSizerAndFit(control_box)
- #mouse wheel event
- def on_mouse_wheel(event):
- if not parent[XY_MODE_KEY]:
- if event.GetWheelRotation() < 0: self._on_incr_t_divs(event)
- else: self._on_decr_t_divs(event)
- parent.plotter.Bind(wx.EVT_MOUSEWHEEL, on_mouse_wheel)
-
- ##################################################
- # Event handlers
- ##################################################
- #trigger level
- def _on_incr_trigger_level(self, event):
- self.parent[TRIGGER_LEVEL_KEY] += self.parent[Y_PER_DIV_KEY]/3.
- def _on_decr_trigger_level(self, event):
- self.parent[TRIGGER_LEVEL_KEY] -= self.parent[Y_PER_DIV_KEY]/3.
- #incr/decr divs
- def _on_incr_t_divs(self, event):
- self.parent[T_PER_DIV_KEY] = common.get_clean_incr(self.parent[T_PER_DIV_KEY])
- def _on_decr_t_divs(self, event):
- self.parent[T_PER_DIV_KEY] = common.get_clean_decr(self.parent[T_PER_DIV_KEY])
- def _on_incr_x_divs(self, event):
- self.parent[X_PER_DIV_KEY] = common.get_clean_incr(self.parent[X_PER_DIV_KEY])
- def _on_decr_x_divs(self, event):
- self.parent[X_PER_DIV_KEY] = common.get_clean_decr(self.parent[X_PER_DIV_KEY])
- def _on_incr_y_divs(self, event):
- self.parent[Y_PER_DIV_KEY] = common.get_clean_incr(self.parent[Y_PER_DIV_KEY])
- def _on_decr_y_divs(self, event):
- self.parent[Y_PER_DIV_KEY] = common.get_clean_decr(self.parent[Y_PER_DIV_KEY])
- #incr/decr offset
- def _on_incr_x_off(self, event):
- self.parent[X_OFF_KEY] = self.parent[X_OFF_KEY] + self.parent[X_PER_DIV_KEY]
- def _on_decr_x_off(self, event):
- self.parent[X_OFF_KEY] = self.parent[X_OFF_KEY] - self.parent[X_PER_DIV_KEY]
- def _on_incr_y_off(self, event):
- self.parent[Y_OFF_KEY] = self.parent[Y_OFF_KEY] + self.parent[Y_PER_DIV_KEY]
- def _on_decr_y_off(self, event):
- self.parent[Y_OFF_KEY] = self.parent[Y_OFF_KEY] - self.parent[Y_PER_DIV_KEY]
-
- ##################################################
- # subscriber handlers
- ##################################################
- def _update_layout(self,key):
- # Just ignore the key value we get
- # we only need to now that the visability or size of something has changed
- self.parent.Layout()
- #self.parent.Fit()
-
-##################################################
-# Scope window with plotter and control panel
-##################################################
-class scope_window(wx.Panel, pubsub.pubsub):
- def __init__(
- self,
- parent,
- controller,
- size,
- title,
- frame_rate,
- num_inputs,
- sample_rate_key,
- t_scale,
- v_scale,
- v_offset,
- xy_mode,
- ac_couple_key,
- trigger_level_key,
- trigger_mode_key,
- trigger_slope_key,
- trigger_channel_key,
- decimation_key,
- msg_key,
- use_persistence,
- persist_alpha,
- trig_mode,
- y_axis_label,
- ):
- pubsub.pubsub.__init__(self)
- #check num inputs
- assert num_inputs <= len(CHANNEL_COLOR_SPECS)
- #setup
- self.sampleses = None
- self.num_inputs = num_inputs
- autorange = not v_scale
- self.autorange_ts = 0
- v_scale = v_scale or 1
- self.frame_rate_ts = 0
- #proxy the keys
- self.proxy(MSG_KEY, controller, msg_key)
- self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
- self.proxy(TRIGGER_LEVEL_KEY, controller, trigger_level_key)
- self.proxy(TRIGGER_MODE_KEY, controller, trigger_mode_key)
- self.proxy(TRIGGER_SLOPE_KEY, controller, trigger_slope_key)
- self.proxy(TRIGGER_CHANNEL_KEY, controller, trigger_channel_key)
- self.proxy(DECIMATION_KEY, controller, decimation_key)
- #initialize values
- self[RUNNING_KEY] = True
- self[XY_MARKER_KEY] = 2.0
- self[CHANNEL_OPTIONS_KEY] = 0
- self[XY_MODE_KEY] = xy_mode
- self[X_CHANNEL_KEY] = 0
- self[Y_CHANNEL_KEY] = self.num_inputs-1
- self[AUTORANGE_KEY] = autorange
- self[T_PER_DIV_KEY] = t_scale
- self[X_PER_DIV_KEY] = v_scale
- self[Y_PER_DIV_KEY] = v_scale
- self[T_OFF_KEY] = 0
- self[X_OFF_KEY] = v_offset
- self[Y_OFF_KEY] = v_offset
- self[T_DIVS_KEY] = 8
- self[X_DIVS_KEY] = 8
- self[Y_DIVS_KEY] = 8
- self[Y_AXIS_LABEL] = y_axis_label
- self[FRAME_RATE_KEY] = frame_rate
- self[TRIGGER_LEVEL_KEY] = 0
- self[TRIGGER_CHANNEL_KEY] = 0
- self[TRIGGER_MODE_KEY] = trig_mode
-
- 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] == wxgui.TRIG_MODE_STRIPCHART:
- self[T_FRAC_OFF_KEY] = 0.0
-
- for i in range(num_inputs):
- self.proxy(common.index_key(AC_COUPLE_KEY, i), controller, common.index_key(ac_couple_key, i))
- #init panel and plot
- wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
- self.plotter = plotter.channel_plotter(self)
- self.plotter.SetSize(wx.Size(*size))
- self.plotter.SetSizeHints(*size)
- self.plotter.set_title(title)
- self.plotter.enable_legend(True)
- self.plotter.enable_point_label(True)
- self.plotter.enable_grid_lines(True)
- self.plotter.set_use_persistence(use_persistence)
- self.plotter.set_persist_alpha(persist_alpha)
- #setup the box with plot and controls
- self.control_panel = control_panel(self)
- main_box = wx.BoxSizer(wx.HORIZONTAL)
- main_box.Add(self.plotter, 1, wx.EXPAND)
- main_box.Add(self.control_panel, 0, wx.EXPAND)
- self.SetSizerAndFit(main_box)
- #register events for message
- self.subscribe(MSG_KEY, self.handle_msg)
- #register events for grid
- for key in [common.index_key(MARKER_KEY, i) for i in range(self.num_inputs)] + [
- TRIGGER_LEVEL_KEY, TRIGGER_MODE_KEY,
- T_PER_DIV_KEY, X_PER_DIV_KEY, Y_PER_DIV_KEY,
- T_OFF_KEY, X_OFF_KEY, Y_OFF_KEY,
- T_DIVS_KEY, X_DIVS_KEY, Y_DIVS_KEY,
- XY_MODE_KEY, AUTORANGE_KEY, T_FRAC_OFF_KEY,
- TRIGGER_SHOW_KEY, XY_MARKER_KEY, X_CHANNEL_KEY, Y_CHANNEL_KEY,
- ]: self.subscribe(key, self.update_grid)
- #register events for plotter settings
- self.subscribe(USE_PERSISTENCE_KEY, self.plotter.set_use_persistence)
- self.subscribe(PERSIST_ALPHA_KEY, self.plotter.set_persist_alpha)
- #initial update
- self.update_grid()
-
- def handle_msg(self, msg):
- """
- 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.
-
- Args:
- msg: the time domain data as a character array
- """
- if not self[RUNNING_KEY]: return
- #check time elapsed
- if time.time() - self.frame_rate_ts < 1.0/self[FRAME_RATE_KEY]: return
- #convert to floating point numbers
- samples = numpy.fromstring(msg, numpy.float32)
- #extract the trigger offset
- self.trigger_offset = samples[-1]
- samples = samples[:-1]
- samps_per_ch = len(samples)/self.num_inputs
- self.sampleses = [samples[samps_per_ch*i:samps_per_ch*(i+1)] for i in range(self.num_inputs)]
- #handle samples
- self.handle_samples()
- self.frame_rate_ts = time.time()
-
- def set_auto_trigger_level(self, *args):
- """
- Use the current trigger channel and samples to calculate the 50% level.
- """
- if not self.sampleses: return
- samples = self.sampleses[self[TRIGGER_CHANNEL_KEY]]
- self[TRIGGER_LEVEL_KEY] = (numpy.max(samples)+numpy.min(samples))/2
-
- def handle_samples(self):
- """
- Handle the cached samples from the scope input.
- Perform ac coupling, triggering, and auto ranging.
- """
- if not self.sampleses: return
- sampleses = self.sampleses
- if self[XY_MODE_KEY]:
- self[DECIMATION_KEY] = 1
- x_samples = sampleses[self[X_CHANNEL_KEY]]
- y_samples = sampleses[self[Y_CHANNEL_KEY]]
- #autorange
- if self[AUTORANGE_KEY] and time.time() - self.autorange_ts > AUTORANGE_UPDATE_RATE:
- x_min, x_max = common.get_min_max(x_samples)
- y_min, y_max = common.get_min_max(y_samples)
- #adjust the x per div
- x_per_div = common.get_clean_num((x_max-x_min)/self[X_DIVS_KEY])
- if x_per_div != self[X_PER_DIV_KEY]: self[X_PER_DIV_KEY] = x_per_div; return
- #adjust the x offset
- x_off = x_per_div*round((x_max+x_min)/2/x_per_div)
- if x_off != self[X_OFF_KEY]: self[X_OFF_KEY] = x_off; return
- #adjust the y per div
- y_per_div = common.get_clean_num((y_max-y_min)/self[Y_DIVS_KEY])
- if y_per_div != self[Y_PER_DIV_KEY]: self[Y_PER_DIV_KEY] = y_per_div; return
- #adjust the y offset
- y_off = y_per_div*round((y_max+y_min)/2/y_per_div)
- if y_off != self[Y_OFF_KEY]: self[Y_OFF_KEY] = y_off; return
- self.autorange_ts = time.time()
- #plot xy channel
- self.plotter.set_waveform(
- channel='XY',
- samples=(x_samples, y_samples),
- color_spec=CHANNEL_COLOR_SPECS[0],
- marker=self[XY_MARKER_KEY],
- )
- #turn off each waveform
- for i, samples in enumerate(sampleses):
- self.plotter.clear_waveform(channel='Ch%d'%(i+1))
- else:
- #autorange
- if self[AUTORANGE_KEY] and time.time() - self.autorange_ts > AUTORANGE_UPDATE_RATE:
- bounds = [common.get_min_max(samples) for samples in sampleses]
- y_min = numpy.min([bound[0] for bound in bounds])
- y_max = numpy.max([bound[1] for bound in bounds])
- #adjust the y per div
- y_per_div = common.get_clean_num((y_max-y_min)/self[Y_DIVS_KEY])
- if y_per_div != self[Y_PER_DIV_KEY]: self[Y_PER_DIV_KEY] = y_per_div; return
- #adjust the y offset
- y_off = y_per_div*round((y_max+y_min)/2/y_per_div)
- if y_off != self[Y_OFF_KEY]: self[Y_OFF_KEY] = y_off; return
- self.autorange_ts = time.time()
- #number of samples to scale to the screen
- actual_rate = self.get_actual_rate()
- time_span = self[T_PER_DIV_KEY]*self[T_DIVS_KEY]
- num_samps = int(round(time_span*actual_rate))
- #handle the time offset
- t_off = self[T_FRAC_OFF_KEY]*(len(sampleses[0])/actual_rate - time_span)
- if t_off != self[T_OFF_KEY]: self[T_OFF_KEY] = t_off; return
- samps_off = int(round(actual_rate*self[T_OFF_KEY]))
- #adjust the decim so that we use about half the samps
- self[DECIMATION_KEY] = int(round(
- time_span*self[SAMPLE_RATE_KEY]/(0.5*len(sampleses[0]))
- )
- )
- #num samps too small, auto increment the time
- if num_samps < 2: self[T_PER_DIV_KEY] = common.get_clean_incr(self[T_PER_DIV_KEY])
- #num samps in bounds, plot each waveform
- elif num_samps <= len(sampleses[0]):
- for i, samples in enumerate(sampleses):
- #plot samples
- self.plotter.set_waveform(
- channel='Ch%d'%(i+1),
- samples=samples[samps_off:num_samps+samps_off],
- color_spec=CHANNEL_COLOR_SPECS[i],
- marker=self[common.index_key(MARKER_KEY, i)],
- trig_off=self.trigger_offset,
- )
- #turn XY channel off
- self.plotter.clear_waveform(channel='XY')
- #keep trigger level within range
- if self[TRIGGER_LEVEL_KEY] > self.get_y_max():
- self[TRIGGER_LEVEL_KEY] = self.get_y_max(); return
- 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] == wxgui.TRIG_MODE_FREE:
- self.plotter.clear_waveform(channel='Trig')
- else: #show trigger channel
- trigger_level = self[TRIGGER_LEVEL_KEY]
- trigger_point = (len(self.sampleses[0])-1)/self.get_actual_rate()/2.0
- self.plotter.set_waveform(
- channel='Trig',
- samples=(
- [self.get_t_min(), trigger_point, trigger_point, trigger_point, trigger_point, self.get_t_max()],
- [trigger_level, trigger_level, self.get_y_max(), self.get_y_min(), trigger_level, trigger_level]
- ),
- color_spec=TRIGGER_COLOR_SPEC,
- )
- #update the plotter
- self.plotter.update()
-
- def get_actual_rate(self): return 1.0*self[SAMPLE_RATE_KEY]/self[DECIMATION_KEY]
- def get_t_min(self): return self[T_OFF_KEY]
- def get_t_max(self): return self[T_PER_DIV_KEY]*self[T_DIVS_KEY] + self[T_OFF_KEY]
- def get_x_min(self): return -1*self[X_PER_DIV_KEY]*self[X_DIVS_KEY]/2.0 + self[X_OFF_KEY]
- def get_x_max(self): return self[X_PER_DIV_KEY]*self[X_DIVS_KEY]/2.0 + self[X_OFF_KEY]
- def get_y_min(self): return -1*self[Y_PER_DIV_KEY]*self[Y_DIVS_KEY]/2.0 + self[Y_OFF_KEY]
- def get_y_max(self): return self[Y_PER_DIV_KEY]*self[Y_DIVS_KEY]/2.0 + self[Y_OFF_KEY]
-
- def update_grid(self, *args):
- """
- Update the grid to reflect the current settings:
- xy divisions, xy offset, xy mode setting
- """
- if self[T_FRAC_OFF_KEY] < 0: self[T_FRAC_OFF_KEY] = 0; return
- if self[T_FRAC_OFF_KEY] > 1: self[T_FRAC_OFF_KEY] = 1; return
- if self[XY_MODE_KEY]:
- #update the x axis
- self.plotter.set_x_label('Ch%d'%(self[X_CHANNEL_KEY]+1))
- self.plotter.set_x_grid(self.get_x_min(), self.get_x_max(), self[X_PER_DIV_KEY])
- #update the y axis
- self.plotter.set_y_label('Ch%d'%(self[Y_CHANNEL_KEY]+1))
- self.plotter.set_y_grid(self.get_y_min(), self.get_y_max(), self[Y_PER_DIV_KEY])
- else:
- #update the t axis
- self.plotter.set_x_label('Time', 's')
- self.plotter.set_x_grid(self.get_t_min(), self.get_t_max(), self[T_PER_DIV_KEY], True)
- #update the y axis
- self.plotter.set_y_label(self[Y_AXIS_LABEL])
- self.plotter.set_y_grid(self.get_y_min(), self.get_y_max(), self[Y_PER_DIV_KEY])
- #redraw current sample
- self.handle_samples()
-
diff --git a/gr-wxgui/python/wxgui/scopesink2.py b/gr-wxgui/python/wxgui/scopesink2.py
deleted file mode 100644
index 99e268895a..0000000000
--- a/gr-wxgui/python/wxgui/scopesink2.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright 2008,2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr
-
-p = gr.prefs()
-style = p.get_string('wxgui', 'style', 'auto')
-
-if style == 'auto' or style == 'gl':
- try:
- import wx.glcanvas
- from OpenGL.GL import *
- from scopesink_gl import scope_sink_f, scope_sink_c
- except ImportError:
- if style == 'gl':
- raise RuntimeError("Unable to import OpenGL. Are Python wrappers for OpenGL installed?")
- else:
- # Fall backto non-gl sinks
- from scopesink_nongl import scope_sink_f, scope_sink_c
-elif style == 'nongl':
- from scopesink_nongl import scope_sink_f, scope_sink_c
-else:
- raise RuntimeError("Unknown wxgui style")
diff --git a/gr-wxgui/python/wxgui/scopesink_gl.py b/gr-wxgui/python/wxgui/scopesink_gl.py
deleted file mode 100644
index b2d5670c77..0000000000
--- a/gr-wxgui/python/wxgui/scopesink_gl.py
+++ /dev/null
@@ -1,239 +0,0 @@
-#
-# Copyright 2008,2010,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-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
-
-class ac_couple_block(gr.hier_block2):
- """
- AC couple the incoming stream by subtracting out the low pass signal.
- Mute the low pass filter to disable ac coupling.
- """
-
- def __init__(self, controller, ac_couple_key, sample_rate_key):
- gr.hier_block2.__init__(
- self,
- "ac_couple",
- gr.io_signature(1, 1, gr.sizeof_float),
- gr.io_signature(1, 1, gr.sizeof_float),
- )
- #blocks
- 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))
- #subscribe
- controller.subscribe(ac_couple_key, lambda x: mute.set_mute(not x))
- controller.subscribe(sample_rate_key, lambda x: lpf.set_taps(0.05))
- #initialize
- controller[ac_couple_key] = controller[ac_couple_key]
- controller[sample_rate_key] = controller[sample_rate_key]
-
-##################################################
-# Scope sink block (wrapper for old wxgui)
-##################################################
-class _scope_sink_base(gr.hier_block2, common.wxgui_hb):
- """
- A scope block with a gui window.
- """
-
- def __init__(
- self,
- parent,
- title='',
- sample_rate=1,
- size=scope_window.DEFAULT_WIN_SIZE,
- v_scale=0,
- t_scale=0,
- v_offset=0,
- xy_mode=False,
- ac_couple=False,
- num_inputs=1,
- trig_mode=scope_window.DEFAULT_TRIG_MODE,
- y_axis_label='Counts',
- frame_rate=scope_window.DEFAULT_FRAME_RATE,
- use_persistence=False,
- persist_alpha=None,
- **kwargs #do not end with a comma
- ):
- #ensure analog alpha
- if persist_alpha is None:
- actual_frame_rate=float(frame_rate)
- analog_cutoff_freq=0.5 # Hertz
- #calculate alpha from wanted cutoff freq
- persist_alpha = 1.0 - math.exp(-2.0*math.pi*analog_cutoff_freq/actual_frame_rate)
-
- if not t_scale: t_scale = 10.0/sample_rate
- #init
- gr.hier_block2.__init__(
- self,
- "scope_sink",
- gr.io_signature(num_inputs, num_inputs, self._item_size),
- gr.io_signature(0, 0, 0),
- )
- #scope
- msgq = gr.msg_queue(2)
- scope = wxgui.oscope_sink_f(sample_rate, msgq)
- #controller
- self.controller = pubsub()
- self.controller.subscribe(SAMPLE_RATE_KEY, scope.set_sample_rate)
- self.controller.publish(SAMPLE_RATE_KEY, scope.sample_rate)
- self.controller.subscribe(DECIMATION_KEY, scope.set_decimation_count)
- self.controller.publish(DECIMATION_KEY, scope.get_decimation_count)
- self.controller.subscribe(TRIGGER_LEVEL_KEY, scope.set_trigger_level)
- self.controller.publish(TRIGGER_LEVEL_KEY, scope.get_trigger_level)
- self.controller.subscribe(TRIGGER_MODE_KEY, scope.set_trigger_mode)
- self.controller.publish(TRIGGER_MODE_KEY, scope.get_trigger_mode)
- self.controller.subscribe(TRIGGER_SLOPE_KEY, scope.set_trigger_slope)
- self.controller.publish(TRIGGER_SLOPE_KEY, scope.get_trigger_slope)
- self.controller.subscribe(TRIGGER_CHANNEL_KEY, scope.set_trigger_channel)
- self.controller.publish(TRIGGER_CHANNEL_KEY, scope.get_trigger_channel)
- actual_num_inputs = self._real and num_inputs or num_inputs*2
- #init ac couple
- for i in range(actual_num_inputs):
- self.controller[common.index_key(AC_COUPLE_KEY, i)] = ac_couple
- #start input watcher
- common.input_watcher(msgq, self.controller, MSG_KEY)
- #create window
- self.win = scope_window.scope_window(
- parent=parent,
- controller=self.controller,
- size=size,
- title=title,
- frame_rate=frame_rate,
- num_inputs=actual_num_inputs,
- sample_rate_key=SAMPLE_RATE_KEY,
- t_scale=t_scale,
- v_scale=v_scale,
- v_offset=v_offset,
- xy_mode=xy_mode,
- trig_mode=trig_mode,
- y_axis_label=y_axis_label,
- ac_couple_key=AC_COUPLE_KEY,
- trigger_level_key=TRIGGER_LEVEL_KEY,
- trigger_mode_key=TRIGGER_MODE_KEY,
- trigger_slope_key=TRIGGER_SLOPE_KEY,
- trigger_channel_key=TRIGGER_CHANNEL_KEY,
- decimation_key=DECIMATION_KEY,
- msg_key=MSG_KEY,
- use_persistence=use_persistence,
- persist_alpha=persist_alpha,
- )
- common.register_access_methods(self, self.win)
- #connect
- if self._real:
- for i in range(num_inputs):
- self.wxgui_connect(
- (self, i),
- ac_couple_block(self.controller, common.index_key(AC_COUPLE_KEY, i), SAMPLE_RATE_KEY),
- (scope, i),
- )
- else:
- for i in range(num_inputs):
- c2f = blocks.complex_to_float()
- self.wxgui_connect((self, i), c2f)
- for j in range(2):
- self.connect(
- (c2f, j),
- ac_couple_block(self.controller, common.index_key(AC_COUPLE_KEY, 2*i+j), SAMPLE_RATE_KEY),
- (scope, 2*i+j),
- )
-
-class scope_sink_f(_scope_sink_base):
- _item_size = gr.sizeof_float
- _real = True
-
-class scope_sink_c(_scope_sink_base):
- _item_size = gr.sizeof_gr_complex
- _real = False
-
-# ----------------------------------------------------------------
-# Stand-alone test application
-# ----------------------------------------------------------------
-
-import wx
-from gnuradio.wxgui import stdgui2
-
-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)
-
- default_input_rate = 1e6
- if len(argv) > 1:
- input_rate = int(argv[1])
- else:
- input_rate = default_input_rate
-
- if len(argv) > 2:
- v_scale = float(argv[2]) # start up at this v_scale value
- else:
- v_scale = None # start up in autorange mode, default
-
- if len(argv) > 3:
- t_scale = float(argv[3]) # start up at this t_scale value
- else:
- t_scale = .00003*default_input_rate/input_rate # old behavior
-
- print "input rate %s v_scale %s t_scale %s" % (input_rate,v_scale,t_scale)
-
-
- # Generate a complex sinusoid
- ampl=1.0e3
- 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.noise_source_c(analog.GR_GAUSSIAN, ampl/10)
- 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...
- 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)
-
- # Ultimately this will be
- # self.connect("src0 throttle scope")
- self.connect(self.src0,(self.combine,0))
- self.connect(self.noise,(self.combine,1))
- self.connect(self.combine, self.thr, scope)
-
-def main ():
- app = stdgui2.stdapp(test_top_block, "O'Scope Test App")
- app.MainLoop()
-
-if __name__ == '__main__':
- main()
diff --git a/gr-wxgui/python/wxgui/scopesink_nongl.py b/gr-wxgui/python/wxgui/scopesink_nongl.py
deleted file mode 100644
index 28a473860f..0000000000
--- a/gr-wxgui/python/wxgui/scopesink_nongl.py
+++ /dev/null
@@ -1,654 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2003,2004,2006,2007,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-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
-import numpy
-import struct
-
-default_scopesink_size = (640, 240)
-default_v_scale = 1000
-default_frame_decim = gr.prefs().get_long('wxgui', 'frame_decim', 1)
-
-class scope_sink_f(gr.hier_block2):
- def __init__(self, parent, title='', sample_rate=1,
- size=default_scopesink_size, frame_decim=default_frame_decim,
- v_scale=default_v_scale, t_scale=None, num_inputs=1, **kwargs):
-
- gr.hier_block2.__init__(self, "scope_sink_f",
- gr.io_signature(num_inputs, num_inputs, gr.sizeof_float),
- gr.io_signature(0,0,0))
-
- msgq = gr.msg_queue(2) # message queue that holds at most 2 messages
- self.guts = wxgui.oscope_sink_f(sample_rate, msgq)
- for i in range(num_inputs):
- self.connect((self, i), (self.guts, i))
-
- 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):
- self.guts.set_sample_rate(sample_rate)
- self.win.info.set_sample_rate(sample_rate)
-
-class scope_sink_c(gr.hier_block2):
- def __init__(self, parent, title='', sample_rate=1,
- size=default_scopesink_size, frame_decim=default_frame_decim,
- v_scale=default_v_scale, t_scale=None, num_inputs=1, xy_mode=False, **kwargs):
-
- gr.hier_block2.__init__(self, "scope_sink_c",
- gr.io_signature(num_inputs, num_inputs, gr.sizeof_gr_complex),
- gr.io_signature(0,0,0))
-
- msgq = gr.msg_queue(2) # message queue that holds at most 2 messages
- 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)
- 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)
- self.win.info.xy = xy_mode
-
- def set_sample_rate(self, sample_rate):
- self.guts.set_sample_rate(sample_rate)
- self.win.info.set_sample_rate(sample_rate)
-
-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)
- self.win.info.xy = True #constellation mode
-
-# ========================================================================
-
-
-time_base_list = [ # time / division
- 1.0e-7, # 100ns / div
- 2.5e-7,
- 5.0e-7,
- 1.0e-6, # 1us / div
- 2.5e-6,
- 5.0e-6,
- 1.0e-5, # 10us / div
- 2.5e-5,
- 5.0e-5,
- 1.0e-4, # 100us / div
- 2.5e-4,
- 5.0e-4,
- 1.0e-3, # 1ms / div
- 2.5e-3,
- 5.0e-3,
- 1.0e-2, # 10ms / div
- 2.5e-2,
- 5.0e-2
- ]
-
-v_scale_list = [ # counts / div, LARGER gains are SMALLER /div, appear EARLIER
- 2.0e-3, # 2m / div, don't call it V/div it's actually counts/div
- 5.0e-3,
- 1.0e-2,
- 2.0e-2,
- 5.0e-2,
- 1.0e-1,
- 2.0e-1,
- 5.0e-1,
- 1.0e+0,
- 2.0e+0,
- 5.0e+0,
- 1.0e+1,
- 2.0e+1,
- 5.0e+1,
- 1.0e+2,
- 2.0e+2,
- 5.0e+2,
- 1.0e+3,
- 2.0e+3,
- 5.0e+3,
- 1.0e+4 # 10000 /div, USRP full scale is -/+ 32767
- ]
-
-
-wxDATA_EVENT = wx.NewEventType()
-
-def EVT_DATA_EVENT(win, func):
- win.Connect(-1, -1, wxDATA_EVENT, func)
-
-class DataEvent(wx.PyEvent):
- def __init__(self, data):
- wx.PyEvent.__init__(self)
- self.SetEventType(wxDATA_EVENT)
- self.data = data
-
- def Clone(self):
- self.__class__(self.GetId())
-
-
-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):
- self.msgq = msgq
- self.sample_rate = sample_rate
- self.frame_decim = frame_decim
- self.scopesink = scopesink
- self.title = title;
-
- self.time_scale_cursor = gru.seq_with_cursor(time_base_list, initial_value = t_scale)
- self.v_scale_cursor = gru.seq_with_cursor(v_scale_list, initial_value = v_scale)
-
- self.marker = 'line'
- self.xy = xy
- self.autorange = not v_scale
- self.running = True
-
- 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 set_sample_rate(self, sample_rate):
- self.sample_rate = sample_rate
-
- def get_sample_rate(self):
- return self.sample_rate
-
- def get_decimation_rate(self):
- return 1.0
-
- def set_marker(self, s):
- self.marker = s
-
- def get_marker(self):
- return self.marker
-
-
-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
- gru.msgq_runner.__init__(self, msgq, self.handle_msg)
-
- def handle_msg(self, msg):
- if self.iscan == 0: # only display at frame_decim
- self.iscan = self.frame_decim
-
- nchan = int(msg.arg1()) # number of channels of data in msg
- nsamples = int(msg.arg2()) # number of samples in each channel
-
- s = msg.to_string() # get the body of the msg as a string
-
- bytes_per_chan = nsamples * gr.sizeof_float
-
- records = []
- 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)
-
- # print "nrecords = %d, reclen = %d" % (len (records),nsamples)
-
- de = DataEvent(records)
- wx.PostEvent(self.event_receiver, de)
- records = []
- del de
-
- self.iscan -= 1
-
-
-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)
- self.info = info
-
- vbox = wx.BoxSizer(wx.VERTICAL)
-
- 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)
-
- self.sizer = vbox
- 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)
-
- 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.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")
- 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)
-
- return ctrlbox
-
- 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_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()
-
- 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(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.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)
-
- 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)
-
- 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)
-
- 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 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 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 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 set_autorange(self, on):
- if on:
- self.v_scale_label.SetLabel(" (auto)")
- self.info.autorange = True
- self.autorange_checkbox.SetValue(True)
- self.inc_v_button.Enable(False)
- self.dec_v_button.Enable(False)
- else:
- if self.graph.y_range:
- (l,u) = self.graph.y_range # found by autorange
- self.info.v_scale_cursor.set_index_by_value((u-l)/8.0)
- self.update_v_scale_label()
- self.info.autorange = False
- self.autorange_checkbox.SetValue(False)
- self.inc_v_button.Enable(True)
- self.dec_v_button.Enable(True)
-
- def autorange_checkbox_event(self, evt):
- if evt.Checked():
- self.set_autorange(True)
- 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)
- assert i >= 0, "Hmmm, set_marker problem"
- self.marker_choice.SetSelection(i)
-
- def set_format_line(self):
- self.set_marker('line')
-
- def set_format_dot(self):
- self.set_marker('dot')
-
- def set_format_plus(self):
- self.set_marker('plus')
-
- 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_mode_choice_event(self, evt):
- sink = self.info.scopesink
- s = evt.GetString()
- if s == 'Norm':
- sink.set_trigger_mode(wxgui.TRIG_MODE_NORM)
- elif s == 'Auto':
- sink.set_trigger_mode(wxgui.TRIG_MODE_AUTO)
- elif s == 'Free':
- sink.set_trigger_mode(wxgui.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 run_stop(self, evt):
- self.info.running = not self.info.running
-
-
-class graph_window(plot.PlotCanvas):
-
- channel_colors = ['BLUE', 'RED',
- 'CYAN', 'MAGENTA', 'GREEN', 'YELLOW']
-
- 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)
-
- self.SetXUseScopeTicks(True)
- self.SetEnableGrid(True)
- self.SetEnableZoom(True)
- self.SetEnableLegend(True)
- # self.SetBackgroundColour('black')
-
- self.info = info;
- self.y_range = None
- self.x_range = None
- self.avg_y_min = None
- self.avg_y_max = None
- self.avg_x_min = None
- self.avg_x_max = None
-
- EVT_DATA_EVENT(self, self.format_data)
-
- self.input_watcher = input_watcher(info.msgq, self, info.frame_decim)
-
- def channel_color(self, ch):
- return self.channel_colors[ch % len(self.channel_colors)]
-
- def format_data(self, evt):
- if not self.info.running:
- return
-
- if self.info.xy:
- self.format_xy_data(evt)
- return
-
- info = self.info
- records = evt.data
- 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)
-
- # 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)
- n = n & ~0x1 # make even
- n = max(2, min(n, npoints))
-
- self.SetXUseScopeTicks(True) # use 10 divisions, no labels
-
- for ch in range(nchannels):
- r = records[ch]
-
- # plot middle n points of record
-
- 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[:,0] = x_vals[lb:ub]
- points[:,1] = r[lb:ub]
-
- m = info.get_marker()
- if m == 'line':
- 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,))))
-
- graphics = plot.PlotGraphics(objects,
- title=self.info.title,
- xLabel = '', yLabel = '')
-
- 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()
- 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
-
-
- def format_xy_data(self, evt):
- info = self.info
- records = evt.data
- 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[:,0] = records[0]
- points[:,1] = records[1]
-
- self.SetXUseScopeTicks(False)
-
- m = info.get_marker()
- if m == 'line':
- objects.append(plot.PolyLine(points,
- colour=self.channel_color(0)))
- else:
- objects.append(plot.PolyMarker(points,
- marker=m,
- colour=self.channel_color(0)))
-
- 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()
-
-
- def update_y_range(self):
- alpha = 1.0/25
- graphics = self.last_draw[0]
- 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)
- self.avg_y_max = p2[1] * alpha + self.avg_y_max * (1 - alpha)
- else: # initial guess
- 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)
- # 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):
- alpha = 1.0/25
- graphics = self.last_draw[0]
- 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)
- self.avg_x_max = p2[0] * alpha + self.avg_x_max * (1 - alpha)
- else:
- 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)
-
-
-# ----------------------------------------------------------------
-# Stand-alone test application
-# ----------------------------------------------------------------
-
-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)
-
- if len(argv) > 1:
- frame_decim = int(argv[1])
- else:
- frame_decim = 1
-
- if len(argv) > 2:
- v_scale = float(argv[2]) # start up at this v_scale value
- else:
- v_scale = None # start up in autorange mode, default
-
- if len(argv) > 3:
- t_scale = float(argv[3]) # start up at this t_scale value
- else:
- t_scale = None # old behavior
-
- print "frame decim %s v_scale %s t_scale %s" % (frame_decim,v_scale,t_scale)
-
- input_rate = 1e6
-
- # Generate a complex sinusoid
- 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 = 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)
-
- # 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()
-
-if __name__ == '__main__':
- main()
-
-# ----------------------------------------------------------------
diff --git a/gr-wxgui/python/wxgui/slider.py b/gr-wxgui/python/wxgui/slider.py
deleted file mode 100644
index 9a8bfff7e7..0000000000
--- a/gr-wxgui/python/wxgui/slider.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env python
-
-import wx
-
-def slider(parent, min, max, callback):
- """
- Return a wx.Slider object.
-
- 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()
- s = wx.Slider(parent, new_id, (max+min)/2, min, max, wx.DefaultPosition,
- wx.Size(250,-1), wx.SL_HORIZONTAL | wx.SL_LABELS)
- wx.EVT_COMMAND_SCROLL(parent, new_id,
- lambda evt : callback(evt.GetInt()))
- return s
-
-
-# ----------------------------------------------------------------
-# Demo app
-# ----------------------------------------------------------------
-if __name__ == '__main__':
-
- from gnuradio.wxgui import stdgui2
-
- class demo_graph(stdgui2.std_top_block):
-
- def __init__(self, frame, panel, vbox, argv):
- stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)
-
- vbox.Add(slider(panel, 23, 47, self.my_callback1), 1, wx.ALIGN_CENTER)
- vbox.Add(slider(panel, -100, 100, self.my_callback2), 1, wx.ALIGN_CENTER)
-
- def my_callback1(self, val):
- print "cb1 = ", val
-
- def my_callback2(self, val):
- print "cb2 = ", val
-
- def main ():
- app = stdgui2.stdapp (demo_graph, "Slider Demo")
- app.MainLoop ()
-
- main ()
diff --git a/gr-wxgui/python/wxgui/stdgui2.py b/gr-wxgui/python/wxgui/stdgui2.py
deleted file mode 100644
index dbd0307195..0000000000
--- a/gr-wxgui/python/wxgui/stdgui2.py
+++ /dev/null
@@ -1,107 +0,0 @@
-#
-# Copyright 2004 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-'''A simple wx gui for GNU Radio applications'''
-
-import ctypes
-import wx
-import sys
-from gnuradio import gr
-
-
-class stdapp (wx.App):
- def __init__ (self, top_block_maker, title="GNU Radio", nstatus=2,
- max_noutput_items=None):
- self.top_block_maker = top_block_maker
- self.title = title
- self._nstatus = nstatus
- self._max_noutput_items = max_noutput_items
- # If we're on Linux, also enable multi-threading Xlib access
- if sys.platform.startswith('linux'):
- try:
- x11 = ctypes.cdll.LoadLibrary('libX11.so')
- x11.XInitThreads()
- except:
- print "Warning: failed to XInitThreads()"
- # All our initialization must come before calling wx.App.__init__.
- # OnInit is called from somewhere in the guts of __init__.
- wx.App.__init__ (self, redirect=False)
-
- def OnInit (self):
- frame = stdframe (self.top_block_maker, self.title, self._nstatus)
- frame.Show (True)
- self.SetTopWindow (frame)
-
- if(self._max_noutput_items is not None):
- frame.top_block().start (self._max_noutput_items)
- else:
- frame.top_block().start ()
-
- return True
-
-
-class stdframe (wx.Frame):
- def __init__ (self, top_block_maker, title="GNU Radio", nstatus=2):
- # print "stdframe.__init__"
- wx.Frame.__init__(self, None, -1, title)
-
- self.CreateStatusBar (nstatus)
- mainmenu = wx.MenuBar ()
-
- menu = wx.Menu ()
- item = menu.Append (200, 'E&xit', 'Exit')
- self.Bind (wx.EVT_MENU, self.OnCloseWindow, item)
- mainmenu.Append (menu, "&File")
- self.SetMenuBar (mainmenu)
-
- self.Bind (wx.EVT_CLOSE, self.OnCloseWindow)
- self.panel = stdpanel (self, self, top_block_maker)
- vbox = wx.BoxSizer(wx.VERTICAL)
- vbox.Add(self.panel, 1, wx.EXPAND)
- self.SetSizer(vbox)
- self.SetAutoLayout(True)
- vbox.Fit(self)
-
- def OnCloseWindow (self, event):
- self.top_block().stop()
- self.top_block().wait()
- self.Destroy ()
-
- def top_block (self):
- return self.panel.top_block
-
-class stdpanel (wx.Panel):
- def __init__ (self, parent, frame, top_block_maker):
- # print "stdpanel.__init__"
- wx.Panel.__init__ (self, parent, -1)
- self.frame = frame
-
- vbox = wx.BoxSizer (wx.VERTICAL)
- self.top_block = top_block_maker (frame, self, vbox, sys.argv)
- self.SetSizer (vbox)
- self.SetAutoLayout (True)
- vbox.Fit (self)
-
-class std_top_block (gr.top_block):
- def __init__ (self, parent, panel, vbox, argv):
- # Call the hier_block2 constructor
- # Top blocks have no inputs and outputs
- gr.top_block.__init__(self, "std_top_block")
diff --git a/gr-wxgui/python/wxgui/termsink.py b/gr-wxgui/python/wxgui/termsink.py
deleted file mode 100644
index a0cfd575d6..0000000000
--- a/gr-wxgui/python/wxgui/termsink.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gru
-import wx
-
-DEFAULT_WIN_SIZE = (600, 300)
-APPEND_EVENT = wx.NewEventType()
-EVT_APPEND_EVENT = wx.PyEventBinder(APPEND_EVENT, 0)
-
-class AppendEvent(wx.PyEvent):
- def __init__(self, text):
- wx.PyEvent.__init__(self)
- self.SetEventType(APPEND_EVENT)
- self.text = text
-
- def Clone(self):
- self.__class__(self.GetId())
-
-class termsink(wx.Panel):
- def __init__(self,
- parent,
- msgq,
- size=DEFAULT_WIN_SIZE,
- ):
-
- wx.Panel.__init__(self,
- parent,
- size=size,
- style=wx.SIMPLE_BORDER,
- )
-
- self.text_ctrl = wx.TextCtrl(self,
- wx.ID_ANY,
- value="",
- size=size,
- style=wx.TE_MULTILINE|wx.TE_READONLY,
- )
-
- main_sizer = wx.BoxSizer(wx.VERTICAL)
- main_sizer.Add(self.text_ctrl, 1, wx.EXPAND)
- self.SetSizerAndFit(main_sizer)
-
- EVT_APPEND_EVENT(self, self.evt_append)
- self.runner = gru.msgq_runner(msgq, self.handle_msg)
-
- def handle_msg(self, msg):
- # This gets called in the queue runner thread context
- # For now, just add whatever the user sends to the text control
- text = msg.to_string()
-
- # Create a wxPython event and post it to the event queue
- evt = AppendEvent(text)
- wx.PostEvent(self, evt)
- del evt
-
- def evt_append(self, evt):
- # This gets called by the wxPython event queue runner
- self.text_ctrl.AppendText(evt.text)
diff --git a/gr-wxgui/python/wxgui/waterfall_window.py b/gr-wxgui/python/wxgui/waterfall_window.py
deleted file mode 100644
index 272af10ffc..0000000000
--- a/gr-wxgui/python/wxgui/waterfall_window.py
+++ /dev/null
@@ -1,328 +0,0 @@
-#
-# Copyright 2008 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1`301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-import plotter
-import common
-import wx
-import numpy
-import math
-import pubsub
-from constants import *
-from gnuradio import gr #for gr.prefs
-import forms
-
-##################################################
-# Constants
-##################################################
-SLIDER_STEPS = 100
-AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0
-DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'waterfall_rate', 30)
-DEFAULT_COLOR_MODE = gr.prefs().get_string('wxgui', 'waterfall_color', 'rgb1')
-DEFAULT_WIN_SIZE = (600, 300)
-DIV_LEVELS = (1, 2, 5, 10, 20)
-MIN_DYNAMIC_RANGE, MAX_DYNAMIC_RANGE = 10, 200
-DYNAMIC_RANGE_STEP = 10.
-COLOR_MODES = (
- ('RGB1', 'rgb1'),
- ('RGB2', 'rgb2'),
- ('RGB3', 'rgb3'),
- ('Gray', 'gray'),
-)
-
-##################################################
-# Waterfall window control panel
-##################################################
-class control_panel(wx.Panel):
- """
- A control panel with wx widgits to control the plotter and fft block chain.
- """
-
- def __init__(self, parent):
- """
- Create a new control panel.
-
- Args:
- parent: the wx parent window
- """
- self.parent = parent
- wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
- parent[SHOW_CONTROL_PANEL_KEY] = True
- parent.subscribe(SHOW_CONTROL_PANEL_KEY, self.Show)
- control_box = wx.BoxSizer(wx.VERTICAL)
- control_box.AddStretchSpacer()
- options_box = forms.static_box_sizer(
- parent=self, sizer=control_box, label='Options',
- bold=True, orient=wx.VERTICAL,
- )
- #average
- forms.check_box(
- sizer=options_box, parent=self, label='Average',
- ps=parent, key=AVERAGE_KEY,
- )
- avg_alpha_text = forms.static_text(
- sizer=options_box, parent=self, label='Avg Alpha',
- converter=forms.float_converter(lambda x: '%.4f'%x),
- ps=parent, key=AVG_ALPHA_KEY, width=50,
- )
- avg_alpha_slider = forms.log_slider(
- sizer=options_box, parent=self,
- min_exp=AVG_ALPHA_MIN_EXP,
- max_exp=AVG_ALPHA_MAX_EXP,
- num_steps=SLIDER_STEPS,
- ps=parent, key=AVG_ALPHA_KEY,
- )
- for widget in (avg_alpha_text, avg_alpha_slider):
- parent.subscribe(AVERAGE_KEY, widget.Enable)
- widget.Enable(parent[AVERAGE_KEY])
- #begin axes box
- control_box.AddStretchSpacer()
- axes_box = forms.static_box_sizer(
- parent=self, sizer=control_box, label='Axes Options',
- bold=True, orient=wx.VERTICAL,
- )
- #num lines buttons
- forms.incr_decr_buttons(
- parent=self, sizer=axes_box, label='Time Scale',
- on_incr=self._on_incr_time_scale, on_decr=self._on_decr_time_scale,
- )
- #dyanmic range buttons
- forms.incr_decr_buttons(
- parent=self, sizer=axes_box, label='Dyn Range',
- on_incr=self._on_incr_dynamic_range, on_decr=self._on_decr_dynamic_range,
- )
- #ref lvl buttons
- forms.incr_decr_buttons(
- parent=self, sizer=axes_box, label='Ref Level',
- on_incr=self._on_incr_ref_level, on_decr=self._on_decr_ref_level,
- )
- #color mode
- forms.drop_down(
- parent=self, sizer=axes_box, width=100,
- ps=parent, key=COLOR_MODE_KEY, label='Color',
- choices=map(lambda x: x[1], COLOR_MODES),
- labels=map(lambda x: x[0], COLOR_MODES),
- )
- #autoscale
- forms.single_button(
- parent=self, sizer=axes_box, label='Autoscale',
- callback=self.parent.autoscale,
- )
- #clear
- control_box.AddStretchSpacer()
- forms.single_button(
- parent=self, sizer=control_box, label='Clear',
- callback=self._on_clear_button,
- )
- #run/stop
- forms.toggle_button(
- sizer=control_box, parent=self,
- true_label='Stop', false_label='Run',
- ps=parent, key=RUNNING_KEY,
- )
- #set sizer
- self.SetSizerAndFit(control_box)
-
- ##################################################
- # Event handlers
- ##################################################
- def _on_clear_button(self, event):
- self.parent[NUM_LINES_KEY] = self.parent[NUM_LINES_KEY]
- def _on_incr_dynamic_range(self, event):
- self.parent[DYNAMIC_RANGE_KEY] = min(MAX_DYNAMIC_RANGE, common.get_clean_incr(self.parent[DYNAMIC_RANGE_KEY]))
- def _on_decr_dynamic_range(self, event):
- self.parent[DYNAMIC_RANGE_KEY] = max(MIN_DYNAMIC_RANGE, common.get_clean_decr(self.parent[DYNAMIC_RANGE_KEY]))
- def _on_incr_ref_level(self, event):
- self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] + self.parent[DYNAMIC_RANGE_KEY]/DYNAMIC_RANGE_STEP
- def _on_decr_ref_level(self, event):
- self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] - self.parent[DYNAMIC_RANGE_KEY]/DYNAMIC_RANGE_STEP
- def _on_incr_time_scale(self, event):
- old_rate = self.parent[FRAME_RATE_KEY]
- self.parent[FRAME_RATE_KEY] *= 0.75
- if self.parent[FRAME_RATE_KEY] < 1.0:
- self.parent[FRAME_RATE_KEY] = 1.0
-
- if self.parent[FRAME_RATE_KEY] == old_rate:
- self.parent[DECIMATION_KEY] += 1
- def _on_decr_time_scale(self, event):
- old_rate = self.parent[FRAME_RATE_KEY]
- self.parent[FRAME_RATE_KEY] *= 1.25
- if self.parent[FRAME_RATE_KEY] == old_rate:
- self.parent[DECIMATION_KEY] -= 1
-
-##################################################
-# Waterfall window with plotter and control panel
-##################################################
-class waterfall_window(wx.Panel, pubsub.pubsub):
- def __init__(
- self,
- parent,
- controller,
- size,
- title,
- real,
- fft_size,
- num_lines,
- decimation_key,
- baseband_freq,
- sample_rate_key,
- frame_rate_key,
- dynamic_range,
- ref_level,
- average_key,
- avg_alpha_key,
- msg_key,
- ):
- pubsub.pubsub.__init__(self)
- #setup
- self.samples = list()
- self.real = real
- self.fft_size = fft_size
- #proxy the keys
- self.proxy(MSG_KEY, controller, msg_key)
- self.proxy(DECIMATION_KEY, controller, decimation_key)
- self.proxy(FRAME_RATE_KEY, controller, frame_rate_key)
- self.proxy(AVERAGE_KEY, controller, average_key)
- self.proxy(AVG_ALPHA_KEY, controller, avg_alpha_key)
- self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
- #init panel and plot
- wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
- self.plotter = plotter.waterfall_plotter(self)
- self.plotter.SetSize(wx.Size(*size))
- self.plotter.SetSizeHints(*size)
- self.plotter.set_title(title)
- self.plotter.enable_point_label(True)
- self.plotter.enable_grid_lines(False)
- #plotter listeners
- self.subscribe(COLOR_MODE_KEY, self.plotter.set_color_mode)
- self.subscribe(NUM_LINES_KEY, self.plotter.set_num_lines)
- #initialize values
- self[DYNAMIC_RANGE_KEY] = dynamic_range
- self[NUM_LINES_KEY] = num_lines
- self[Y_DIVS_KEY] = 8
- self[X_DIVS_KEY] = 8 #approximate
- self[REF_LEVEL_KEY] = ref_level
- self[BASEBAND_FREQ_KEY] = baseband_freq
- self[COLOR_MODE_KEY] = COLOR_MODES[0][1]
- self[COLOR_MODE_KEY] = DEFAULT_COLOR_MODE
- self[RUNNING_KEY] = True
- #setup the box with plot and controls
- self.control_panel = control_panel(self)
- main_box = wx.BoxSizer(wx.HORIZONTAL)
- main_box.Add(self.plotter, 1, wx.EXPAND)
- main_box.Add(self.control_panel, 0, wx.EXPAND)
- self.SetSizerAndFit(main_box)
- #register events
- self.subscribe(MSG_KEY, self.handle_msg)
- for key in (
- DECIMATION_KEY, SAMPLE_RATE_KEY, FRAME_RATE_KEY,
- BASEBAND_FREQ_KEY, X_DIVS_KEY, Y_DIVS_KEY, NUM_LINES_KEY,
- ): self.subscribe(key, self.update_grid)
- #initial update
- self.update_grid()
-
- def set_callback(self,callb):
- self.plotter.set_callback(callb)
-
- def autoscale(self, *args):
- """
- Autoscale the waterfall plot to the last frame.
- Set the dynamic range and reference level.
- Does not affect the current data in the waterfall.
- """
- if not len(self.samples): return
- min_level, max_level = common.get_min_max_fft(self.samples)
- #set the range and level
- self[DYNAMIC_RANGE_KEY] = common.get_clean_num(max_level - min_level)
- self[REF_LEVEL_KEY] = DYNAMIC_RANGE_STEP*round(.5+max_level/DYNAMIC_RANGE_STEP)
-
- def handle_msg(self, msg):
- """
- Handle the message from the fft sink message queue.
- If complex, reorder the fft samples so the negative bins come first.
- If real, keep take only the positive bins.
- Send the data to the plotter.
-
- Args:
- msg: the fft array as a character array
- """
- if not self[RUNNING_KEY]: return
- #convert to floating point numbers
- self.samples = samples = numpy.fromstring(msg, numpy.float32)[:self.fft_size] #only take first frame
- num_samps = len(samples)
- #reorder fft
- if self.real: samples = samples[:(num_samps+1)/2]
- else: samples = numpy.concatenate((samples[num_samps/2+1:], samples[:(num_samps+1)/2]))
- #plot the fft
- self.plotter.set_samples(
- samples=samples,
- minimum=self[REF_LEVEL_KEY] - self[DYNAMIC_RANGE_KEY],
- maximum=self[REF_LEVEL_KEY],
- )
- #update the plotter
- self.plotter.update()
-
- def update_grid(self, *args):
- """
- Update the plotter grid.
- This update method is dependent on the variables below.
- Determine the x and y axis grid parameters.
- The x axis depends on sample rate, baseband freq, and x divs.
- The y axis depends on y per div, y divs, and ref level.
- """
- #grid parameters
- sample_rate = self[SAMPLE_RATE_KEY]
- frame_rate = self[FRAME_RATE_KEY]
- if frame_rate < 1.0 :
- frame_rate = 1.0
- baseband_freq = self[BASEBAND_FREQ_KEY]
- num_lines = self[NUM_LINES_KEY]
- y_divs = self[Y_DIVS_KEY]
- x_divs = self[X_DIVS_KEY]
- #determine best fitting x_per_div
- if self.real: x_width = sample_rate/2.0
- else: x_width = sample_rate/1.0
- x_per_div = common.get_clean_num(x_width/x_divs)
- #update the x grid
- if self.real:
- self.plotter.set_x_grid(
- baseband_freq,
- baseband_freq + sample_rate/2.0,
- x_per_div, True,
- )
- else:
- self.plotter.set_x_grid(
- baseband_freq - sample_rate/2.0,
- baseband_freq + sample_rate/2.0,
- x_per_div, True,
- )
- #update x units
- self.plotter.set_x_label('Frequency', 'Hz')
- #update y grid
- duration = float(num_lines)/frame_rate
- y_per_div = common.get_clean_num(duration/y_divs)
- self.plotter.set_y_grid(0, duration, y_per_div, True)
- #update y units
- self.plotter.set_y_label('Time', 's')
- #update plotter
- self.plotter.update()
diff --git a/gr-wxgui/python/wxgui/waterfallsink2.py b/gr-wxgui/python/wxgui/waterfallsink2.py
deleted file mode 100644
index 0b876fc3e2..0000000000
--- a/gr-wxgui/python/wxgui/waterfallsink2.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright 2008,2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr
-
-p = gr.prefs()
-style = p.get_string('wxgui', 'style', 'auto')
-
-if style == 'auto' or style == 'gl':
- try:
- import wx.glcanvas
- from OpenGL.GL import *
- from waterfallsink_gl import waterfall_sink_f, waterfall_sink_c
- except ImportError:
- if style == 'gl':
- raise RuntimeError("Unable to import OpenGL. Are Python wrappers for OpenGL installed?")
- else:
- # Fall backto non-gl sinks
- from waterfallsink_nongl import waterfall_sink_f, waterfall_sink_c
-elif style == 'nongl':
- from waterfallsink_nongl import waterfall_sink_f, waterfall_sink_c
-else:
- raise RuntimeError("Unknown wxgui style")
diff --git a/gr-wxgui/python/wxgui/waterfallsink_gl.py b/gr-wxgui/python/wxgui/waterfallsink_gl.py
deleted file mode 100644
index c763d591b2..0000000000
--- a/gr-wxgui/python/wxgui/waterfallsink_gl.py
+++ /dev/null
@@ -1,176 +0,0 @@
-#
-# Copyright 2008,2009,2012 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-##################################################
-# Imports
-##################################################
-import waterfall_window
-import common
-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 *
-
-##################################################
-# Waterfall sink block (wrapper for old wxgui)
-##################################################
-class _waterfall_sink_base(gr.hier_block2, common.wxgui_hb):
- """
- An fft block with real/complex inputs and a gui window.
- """
-
- def __init__(
- self,
- parent,
- baseband_freq=0,
- ref_level=50,
- sample_rate=1,
- fft_size=512,
- fft_rate=waterfall_window.DEFAULT_FRAME_RATE,
- average=False,
- avg_alpha=None,
- title='',
- size=waterfall_window.DEFAULT_WIN_SIZE,
- ref_scale=2.0,
- dynamic_range=80,
- num_lines=256,
- win=None,
- **kwargs #do not end with a comma
- ):
- #ensure avg alpha
- if avg_alpha is None: avg_alpha = 2.0/fft_rate
- #init
- gr.hier_block2.__init__(
- self,
- "waterfall_sink",
- gr.io_signature(1, 1, self._item_size),
- gr.io_signature(0, 0, 0),
- )
- #blocks
- fft = self._fft_chain(
- sample_rate=sample_rate,
- fft_size=fft_size,
- frame_rate=fft_rate,
- ref_scale=ref_scale,
- avg_alpha=avg_alpha,
- average=average,
- win=win,
- )
- msgq = gr.msg_queue(2)
- sink = blocks.message_sink(gr.sizeof_float*fft_size, msgq, True)
- #controller
- self.controller = pubsub()
- self.controller.subscribe(AVERAGE_KEY, fft.set_average)
- self.controller.publish(AVERAGE_KEY, fft.average)
- self.controller.subscribe(AVG_ALPHA_KEY, fft.set_avg_alpha)
- self.controller.publish(AVG_ALPHA_KEY, fft.avg_alpha)
- self.controller.subscribe(SAMPLE_RATE_KEY, fft.set_sample_rate)
- self.controller.publish(SAMPLE_RATE_KEY, fft.sample_rate)
- self.controller.subscribe(DECIMATION_KEY, fft.set_decimation)
- self.controller.publish(DECIMATION_KEY, fft.decimation)
- self.controller.subscribe(FRAME_RATE_KEY, fft.set_vec_rate)
- self.controller.publish(FRAME_RATE_KEY, fft.frame_rate)
- #start input watcher
- common.input_watcher(msgq, self.controller, MSG_KEY)
- #create window
- self.win = waterfall_window.waterfall_window(
- parent=parent,
- controller=self.controller,
- size=size,
- title=title,
- real=self._real,
- fft_size=fft_size,
- num_lines=num_lines,
- baseband_freq=baseband_freq,
- decimation_key=DECIMATION_KEY,
- sample_rate_key=SAMPLE_RATE_KEY,
- frame_rate_key=FRAME_RATE_KEY,
- dynamic_range=dynamic_range,
- ref_level=ref_level,
- average_key=AVERAGE_KEY,
- avg_alpha_key=AVG_ALPHA_KEY,
- msg_key=MSG_KEY,
- )
- common.register_access_methods(self, self.win)
- setattr(self.win, 'set_baseband_freq', getattr(self, 'set_baseband_freq')) #BACKWARDS
- #connect
- self.wxgui_connect(self, fft, sink)
-
- def set_callback(self,callb):
- self.win.set_callback(callb)
-
-class waterfall_sink_f(_waterfall_sink_base):
- _fft_chain = logpwrfft.logpwrfft_f
- _item_size = gr.sizeof_float
- _real = True
-
-class waterfall_sink_c(_waterfall_sink_base):
- _fft_chain = logpwrfft.logpwrfft_c
- _item_size = gr.sizeof_gr_complex
- _real = False
-
-# ----------------------------------------------------------------
-# Standalone test app
-# ----------------------------------------------------------------
-
-import wx
-from gnuradio.wxgui import stdgui2
-
-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)
-
- fft_size = 512
-
- # build our flow graph
- input_rate = 20.000e3
-
- # Generate a complex sinusoid
- 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 = 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)
- self.connect(self.src1, self.thr1, sink1)
- vbox.Add(sink1.win, 1, wx.EXPAND)
-
- # generate a real sinusoid
- 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)
-
-
-def main ():
- app = stdgui2.stdapp(test_top_block, "Waterfall Sink Test App")
- app.MainLoop()
-
-if __name__ == '__main__':
- main ()
-
diff --git a/gr-wxgui/python/wxgui/waterfallsink_nongl.py b/gr-wxgui/python/wxgui/waterfallsink_nongl.py
deleted file mode 100644
index 5cfcd24413..0000000000
--- a/gr-wxgui/python/wxgui/waterfallsink_nongl.py
+++ /dev/null
@@ -1,434 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2003-2005,2007,2008,2013 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-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
-import os
-import math
-
-default_fftsink_size = (640,240)
-default_fft_rate = gr.prefs().get_long('wxgui', 'fft_rate', 15)
-
-class waterfall_sink_base(object):
- def __init__(self, input_is_real=False, baseband_freq=0,
- sample_rate=1, fft_size=512,
- fft_rate=default_fft_rate,
- average=False, avg_alpha=None, title=''):
-
- # initialize common attributes
- self.baseband_freq = baseband_freq
- self.sample_rate = sample_rate
- self.fft_size = fft_size
- self.fft_rate = fft_rate
- self.average = average
- if avg_alpha is None:
- self.avg_alpha = 2.0 / fft_rate
- else:
- self.avg_alpha = avg_alpha
- self.title = title
- self.input_is_real = input_is_real
- self.msgq = gr.msg_queue(2) # queue up to 2 messages
-
- def set_average(self, average):
- self.average = average
- if average:
- self.avg.set_taps(self.avg_alpha)
- else:
- self.avg.set_taps(1.0)
-
- def set_avg_alpha(self, avg_alpha):
- self.avg_alpha = avg_alpha
-
- def set_baseband_freq(self, baseband_freq):
- self.baseband_freq = baseband_freq
-
- def set_sample_rate(self, sample_rate):
- self.sample_rate = sample_rate
- self._set_n()
-
- 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,
- fft_rate=default_fft_rate, average=False, avg_alpha=None,
- title='', size=default_fftsink_size, **kwargs):
-
- gr.hier_block2.__init__(self, "waterfall_sink_f",
- gr.io_signature(1, 1, gr.sizeof_float),
- gr.io_signature(0,0,0))
-
- waterfall_sink_base.__init__(self, input_is_real=True, baseband_freq=baseband_freq,
- sample_rate=sample_rate, fft_size=fft_size,
- fft_rate=fft_rate,
- average=average, avg_alpha=avg_alpha, title=title)
-
- 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 = 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)
- self.set_average(self.average)
-
-
-class waterfall_sink_c(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,
- fft_rate=default_fft_rate, average=False, avg_alpha=None,
- title='', size=default_fftsink_size, **kwargs):
-
- gr.hier_block2.__init__(self, "waterfall_sink_f",
- gr.io_signature(1, 1, gr.sizeof_gr_complex),
- gr.io_signature(0,0,0))
-
- waterfall_sink_base.__init__(self, input_is_real=False, baseband_freq=baseband_freq,
- sample_rate=sample_rate, fft_size=fft_size,
- fft_rate=fft_rate,
- average=average, avg_alpha=avg_alpha, title=title)
-
- 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 = 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)
- self.set_average(self.average)
-
-
-# ------------------------------------------------------------------------
-
-myDATA_EVENT = wx.NewEventType()
-EVT_DATA_EVENT = wx.PyEventBinder (myDATA_EVENT, 0)
-
-
-class DataEvent(wx.PyEvent):
- def __init__(self, data):
- wx.PyEvent.__init__(self)
- self.SetEventType (myDATA_EVENT)
- self.data = data
-
- def Clone (self):
- self.__class__ (self.GetId())
-
-class input_watcher (gru.msgq_runner):
- def __init__ (self, msgq, fft_size, event_receiver, **kwds):
- self.fft_size = fft_size
- self.event_receiver = event_receiver
- gru.msgq_runner.__init__(self, msgq, self.handle_msg)
-
- def handle_msg(self, msg):
- itemsize = int(msg.arg1())
- nitems = int(msg.arg2())
-
- s = msg.to_string() # get the body of the msg as a string
-
- # There may be more than one FFT frame in the message.
- # If so, we take only the last one
- if nitems > 1:
- start = itemsize * (nitems - 1)
- s = s[start:start+itemsize]
-
- complex_data = numpy.fromstring (s, numpy.float32)
- de = DataEvent (complex_data)
- wx.PostEvent (self.event_receiver, de)
- del de
-
-class waterfall_window (wx.Panel):
- def __init__ (self, fftsink, parent, id = -1,
- pos = wx.DefaultPosition, size = wx.DefaultSize,
- style = wx.DEFAULT_FRAME_STYLE, name = ""):
- wx.Panel.__init__(self, parent, id, pos, size, style, name)
- self.set_baseband_freq = fftsink.set_baseband_freq
- self.fftsink = fftsink
- self.bm = wx.EmptyBitmap(self.fftsink.fft_size, 300, -1)
-
- self.scale_factor = 5.0 # FIXME should autoscale, or set this
-
- dc1 = wx.MemoryDC()
- dc1.SelectObject(self.bm)
- dc1.Clear()
-
- self.pens = self.make_pens()
-
- wx.EVT_PAINT( self, self.OnPaint )
- wx.EVT_CLOSE (self, self.on_close_window)
- EVT_DATA_EVENT (self, self.set_data)
-
- self.build_popup_menu()
-
- wx.EVT_CLOSE (self, self.on_close_window)
- self.Bind(wx.EVT_RIGHT_UP, self.on_right_click)
-
- self.input_watcher = input_watcher(fftsink.msgq, fftsink.fft_size, self)
-
-
- def on_close_window (self, event):
- print "waterfall_window: on_close_window"
- self.keep_running = False
-
- def const_list(self,const,len):
- return [const] * len
-
- def make_colormap(self):
- r = []
- r.extend(self.const_list(0,96))
- r.extend(range(0,255,4))
- r.extend(self.const_list(255,64))
- r.extend(range(255,128,-4))
-
- g = []
- g.extend(self.const_list(0,32))
- g.extend(range(0,255,4))
- g.extend(self.const_list(255,64))
- g.extend(range(255,0,-4))
- g.extend(self.const_list(0,32))
-
- b = range(128,255,4)
- b.extend(self.const_list(255,64))
- b.extend(range(255,0,-4))
- b.extend(self.const_list(0,96))
- return (r,g,b)
-
- def make_pens(self):
- (r,g,b) = self.make_colormap()
- pens = []
- for i in range(0,256):
- colour = wx.Colour(r[i], g[i], b[i])
- pens.append( wx.Pen(colour, 2, wx.SOLID))
- return pens
-
- def OnPaint(self, event):
- dc = wx.PaintDC(self)
- self.DoDrawing(dc)
-
- def DoDrawing(self, dc=None):
- if dc is None:
- dc = wx.ClientDC(self)
- dc.DrawBitmap(self.bm, 0, 0, False )
-
-
- def const_list(self,const,len):
- a = [const]
- for i in range(1,len):
- a.append(const)
- return a
-
-
- def set_data (self, evt):
- dB = evt.data
- L = len (dB)
-
- dc1 = wx.MemoryDC()
- dc1.SelectObject(self.bm)
- dc1.Blit(0,1,self.fftsink.fft_size,300,dc1,0,0,wx.COPY,False,-1,-1)
-
- x = max(abs(self.fftsink.sample_rate), abs(self.fftsink.baseband_freq))
- if x >= 1e9:
- sf = 1e-9
- units = "GHz"
- elif x >= 1e6:
- sf = 1e-6
- units = "MHz"
- else:
- sf = 1e-3
- units = "kHz"
-
-
- if self.fftsink.input_is_real: # only plot 1/2 the points
- d_max = L/2
- p_width = 2
- else:
- d_max = L/2
- p_width = 1
-
- scale_factor = self.scale_factor
- if self.fftsink.input_is_real: # real fft
- for x_pos in range(0, d_max):
- value = int(dB[x_pos] * scale_factor)
- value = min(255, max(0, value))
- dc1.SetPen(self.pens[value])
- dc1.DrawRectangle(x_pos*p_width, 0, p_width, 2)
- else: # complex fft
- for x_pos in range(0, d_max): # positive freqs
- value = int(dB[x_pos] * scale_factor)
- value = min(255, max(0, value))
- dc1.SetPen(self.pens[value])
- dc1.DrawRectangle(x_pos*p_width + d_max, 0, p_width, 2)
- for x_pos in range(0 , d_max): # negative freqs
- value = int(dB[x_pos+d_max] * scale_factor)
- value = min(255, max(0, value))
- dc1.SetPen(self.pens[value])
- dc1.DrawRectangle(x_pos*p_width, 0, p_width, 2)
-
- del dc1
- self.DoDrawing (None)
-
- def on_average(self, evt):
- # print "on_average"
- self.fftsink.set_average(evt.IsChecked())
-
- def on_right_click(self, event):
- menu = self.popup_menu
- for id, pred in self.checkmarks.items():
- item = menu.FindItemById(id)
- item.Check(pred())
- self.PopupMenu(menu, event.GetPosition())
-
-
- def build_popup_menu(self):
- self.id_incr_ref_level = wx.NewId()
- self.id_decr_ref_level = wx.NewId()
- self.id_incr_y_per_div = wx.NewId()
- self.id_decr_y_per_div = wx.NewId()
- self.id_y_per_div_1 = wx.NewId()
- self.id_y_per_div_2 = wx.NewId()
- self.id_y_per_div_5 = wx.NewId()
- self.id_y_per_div_10 = wx.NewId()
- self.id_y_per_div_20 = wx.NewId()
- self.id_average = wx.NewId()
-
- self.Bind(wx.EVT_MENU, self.on_average, id=self.id_average)
- #self.Bind(wx.EVT_MENU, self.on_incr_ref_level, id=self.id_incr_ref_level)
- #self.Bind(wx.EVT_MENU, self.on_decr_ref_level, id=self.id_decr_ref_level)
- #self.Bind(wx.EVT_MENU, self.on_incr_y_per_div, id=self.id_incr_y_per_div)
- #self.Bind(wx.EVT_MENU, self.on_decr_y_per_div, id=self.id_decr_y_per_div)
- #self.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_1)
- #self.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_2)
- #self.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_5)
- #self.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_10)
- #self.Bind(wx.EVT_MENU, self.on_y_per_div, id=self.id_y_per_div_20)
-
-
- # make a menu
- menu = wx.Menu()
- self.popup_menu = menu
- menu.AppendCheckItem(self.id_average, "Average")
- # menu.Append(self.id_incr_ref_level, "Incr Ref Level")
- # menu.Append(self.id_decr_ref_level, "Decr Ref Level")
- # menu.Append(self.id_incr_y_per_div, "Incr dB/div")
- # menu.Append(self.id_decr_y_per_div, "Decr dB/div")
- # menu.AppendSeparator()
- # we'd use RadioItems for these, but they're not supported on Mac
- #menu.AppendCheckItem(self.id_y_per_div_1, "1 dB/div")
- #menu.AppendCheckItem(self.id_y_per_div_2, "2 dB/div")
- #menu.AppendCheckItem(self.id_y_per_div_5, "5 dB/div")
- #menu.AppendCheckItem(self.id_y_per_div_10, "10 dB/div")
- #menu.AppendCheckItem(self.id_y_per_div_20, "20 dB/div")
-
- self.checkmarks = {
- self.id_average : lambda : self.fftsink.average
- #self.id_y_per_div_1 : lambda : self.fftsink.y_per_div == 1,
- #self.id_y_per_div_2 : lambda : self.fftsink.y_per_div == 2,
- #self.id_y_per_div_5 : lambda : self.fftsink.y_per_div == 5,
- #self.id_y_per_div_10 : lambda : self.fftsink.y_per_div == 10,
- #self.id_y_per_div_20 : lambda : self.fftsink.y_per_div == 20,
- }
-
-
-def next_up(v, seq):
- """
- Return the first item in seq that is > v.
- """
- for s in seq:
- if s > v:
- return s
- return v
-
-def next_down(v, seq):
- """
- Return the last item in seq that is < v.
- """
- rseq = list(seq[:])
- rseq.reverse()
-
- for s in rseq:
- if s < v:
- return s
- return v
-
-
-# ----------------------------------------------------------------
-# Standalone test app
-# ----------------------------------------------------------------
-
-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)
-
- fft_size = 512
-
- # build our flow graph
- input_rate = 20.000e3
-
- # Generate a complex sinusoid
- 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 = 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)
- self.connect(self.src1, self.thr1, sink1)
- vbox.Add(sink1.win, 1, wx.EXPAND)
-
- # generate a real sinusoid
- 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)
-
-
-def main ():
- app = stdgui2.stdapp(test_top_block, "Waterfall Sink Test App")
- app.MainLoop()
-
-if __name__ == '__main__':
- main()
diff --git a/gr-wxgui/swig/CMakeLists.txt b/gr-wxgui/swig/CMakeLists.txt
deleted file mode 100644
index 4eb11633a7..0000000000
--- a/gr-wxgui/swig/CMakeLists.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright 2013 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-
-########################################################################
-# Setup swig generation
-########################################################################
-include(GrPython)
-include(GrSwig)
-
-set(GR_SWIG_INCLUDE_DIRS
- ${CMAKE_CURRENT_BINARY_DIR}/../include
- ${GR_WXGUI_INCLUDE_DIRS}
- ${GNURADIO_RUNTIME_SWIG_INCLUDE_DIRS}
- ${Boost_INCLUDE_DIRS}
-)
-
-if(ENABLE_GR_CTRLPORT)
- list(APPEND GR_SWIG_FLAGS "-DGR_CTRLPORT")
-endif(ENABLE_GR_CTRLPORT)
-
-set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/wxgui_swig_doc.i)
-set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include/gnuradio/wxgui)
-set(GR_SWIG_DOCS_TARGET_DEPS runtime_swig_swig_doc)
-set(GR_SWIG_TARGET_DEPS wxgui_generated_includes)
-set(GR_SWIG_LIBRARIES gnuradio-wxgui)
-
-GR_SWIG_MAKE(wxgui_swig wxgui_swig.i)
-
-GR_SWIG_INSTALL(
- TARGETS wxgui_swig
- DESTINATION ${GR_PYTHON_DIR}/gnuradio/wxgui
-)
-
-install(
- FILES
- wxgui_swig.i
- ${CMAKE_CURRENT_BINARY_DIR}/wxgui_swig_doc.i
- DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
-)
diff --git a/gr-wxgui/swig/wxgui_swig.i b/gr-wxgui/swig/wxgui_swig.i
deleted file mode 100644
index f370da407a..0000000000
--- a/gr-wxgui/swig/wxgui_swig.i
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#define WXGUI_API
-
-%include "gnuradio.i"
-
-//load generated python docstrings
-%include "wxgui_swig_doc.i"
-
-%include "gnuradio/wxgui/trigger_mode.h"
-
-%{
-#include "gnuradio/wxgui/oscope_sink_x.h"
-#include "gnuradio/wxgui/histo_sink_f.h"
-#include "gnuradio/wxgui/oscope_sink_f.h"
-%}
-
-%include "gnuradio/wxgui/oscope_sink_x.h"
-%include "gnuradio/wxgui/histo_sink_f.h"
-%include "gnuradio/wxgui/oscope_sink_f.h"
-
-GR_SWIG_BLOCK_MAGIC2(wxgui, histo_sink_f);
-GR_SWIG_BLOCK_MAGIC2(wxgui, oscope_sink_f);