diff options
47 files changed, 3814 insertions, 234 deletions
diff --git a/config/gr_fortran.m4 b/config/gr_fortran.m4 index b5b0470f4..a558b2f7e 100644 --- a/config/gr_fortran.m4 +++ b/config/gr_fortran.m4 @@ -28,5 +28,6 @@ AC_DEFUN([GR_FORTRAN],[ then AC_PROG_F77 AC_F77_LIBRARY_LDFLAGS + AC_PROG_CC dnl bux fix to restore $ac_ext fi ]) diff --git a/configure.ac b/configure.ac index 1764b46ab..2bb37935e 100644 --- a/configure.ac +++ b/configure.ac @@ -286,9 +286,6 @@ dnl AX_BOOST_TEST_EXEC_MONITOR dnl AX_BOOST_UNIT_TEST_FRAMEWORK dnl AX_BOOST_WSERIALIZATION - -dnl If this is being done from a subversion tree, create variables -GR_SUBVERSION BUILD_DATE=`date -R -u` AC_SUBST(BUILD_DATE) diff --git a/gnuradio-core/src/lib/general/gr_constants.cc.in b/gnuradio-core/src/lib/general/gr_constants.cc.in index efb0f1c77..71a47eb51 100644 --- a/gnuradio-core/src/lib/general/gr_constants.cc.in +++ b/gnuradio-core/src/lib/general/gr_constants.cc.in @@ -51,18 +51,6 @@ gr_build_date() } const std::string -gr_svn_date() -{ - return "@SVNDATE@"; -} - -const std::string -gr_svn_version() -{ - return "@SVNVERSION@"; -} - -const std::string gr_version() { return "@VERSION@"; diff --git a/gnuradio-core/src/lib/general/gr_constants.h b/gnuradio-core/src/lib/general/gr_constants.h index e44890be0..449d41c17 100644 --- a/gnuradio-core/src/lib/general/gr_constants.h +++ b/gnuradio-core/src/lib/general/gr_constants.h @@ -45,16 +45,6 @@ const std::string gr_prefsdir(); const std::string gr_build_date(); /*! - * \brief return repository date as set when 'bootstrap' is run - */ -const std::string gr_svn_date(); - -/*! - * \brief return repository version as set when 'bootstrap' is run - */ -const std::string gr_svn_version(); - -/*! * \brief return version string defined in configure.ac */ const std::string gr_version(); diff --git a/gnuradio-core/src/lib/general/gr_constants.i b/gnuradio-core/src/lib/general/gr_constants.i index 156af4a36..a5aef1492 100644 --- a/gnuradio-core/src/lib/general/gr_constants.i +++ b/gnuradio-core/src/lib/general/gr_constants.i @@ -4,14 +4,10 @@ %rename(sysconfdir) gr_sysconfdir; %rename(prefsdir) gr_prefsdir; %rename(build_date) gr_build_date; -%rename(svn_date) gr_svn_date; -%rename(svn_version) gr_svn_version; %rename(version) gr_version; const std::string gr_prefix(); const std::string gr_sysconfdir(); const std::string gr_prefsdir(); const std::string gr_build_date(); -const std::string gr_svn_date(); -const std::string gr_svn_version(); const std::string gr_version(); diff --git a/gnuradio-core/src/lib/gnuradio-config-info.cc b/gnuradio-core/src/lib/gnuradio-config-info.cc index df78ea2dd..6fa53b877 100644 --- a/gnuradio-core/src/lib/gnuradio-config-info.cc +++ b/gnuradio-core/src/lib/gnuradio-config-info.cc @@ -43,8 +43,6 @@ main(int argc, char **argv) ("prefsdir", "print gnuradio preferences directory") ("builddate", "print gnuradio build date (RFC2822 format)") ("version,v", "print gnuradio version") - ("svnversion", "print SVN repository version (SVN format)") - ("svndate", "print SVN repository date") ; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -70,11 +68,5 @@ main(int argc, char **argv) if (vm.count("version")) std::cout << gr_version() << std::endl; - if (vm.count("svnversion")) - std::cout << gr_svn_version() << std::endl; - - if (vm.count("svndate")) - std::cout << gr_svn_date() << std::endl; - return 0; } diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py index cf8eb1be7..7ef40be40 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py @@ -55,9 +55,9 @@ class _logpwrfft_base(gr.hier_block2): c2mag = gr.complex_to_mag(fft_size) self._avg = gr.single_pole_iir_filter_ff(1.0, fft_size) self._log = gr.nlog10_ff(20, fft_size, - -10*math.log10(fft_size) # Adjust for number of bins + -20*math.log10(fft_size) # Adjust for number of bins -10*math.log10(window_power/fft_size) # Adjust for windowing loss - -20*math.log10(ref_scale/2)) # Adjust for reference scale + -20*math.log10(ref_scale/2)+3.0) # Adjust for reference scale self.connect(self, self._sd, fft, c2mag, self._avg, self._log, self) self._average = average diff --git a/gnuradio-core/src/python/gnuradio/optfir.py b/gnuradio-core/src/python/gnuradio/optfir.py index 06a0eea61..aee1d2a0c 100644 --- a/gnuradio-core/src/python/gnuradio/optfir.py +++ b/gnuradio-core/src/python/gnuradio/optfir.py @@ -27,7 +27,7 @@ For a great intro to how all this stuff works, see section 6.6 of and Barrie W. Jervis, Adison-Wesley, 1993. ISBN 0-201-54413-X. ''' -import math +import math, cmath from gnuradio import gr remez = gr.remez @@ -56,8 +56,10 @@ def low_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, ## Builds a band pass filter. # @param gain Filter gain in the passband (linear) # @param Fs Sampling rate (sps) -# @param freq1 End of stop band (in Hz) -# @param freq2 Start of pass band (in Hz) +# @param freq_sb1 End of stop band (in Hz) +# @param freq_pb1 Start of pass band (in Hz) +# @param freq_pb2 End of pass band (in Hz) +# @param freq_sb2 Start of stop band (in Hz) # @param passband_ripple_db Pass band ripple in dB (should be small, < 1) # @param stopband_atten_db Stop band attenuation in dB (should be large, >= 60) # @param nextra_taps Extra taps to use in the filter (default=2) @@ -75,6 +77,60 @@ def band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass") return taps + +## Builds a band pass filter with complex taps by making an LPF and +# spinning it up to the right center frequency +# @param gain Filter gain in the passband (linear) +# @param Fs Sampling rate (sps) +# @param freq_sb1 End of stop band (in Hz) +# @param freq_pb1 Start of pass band (in Hz) +# @param freq_pb2 End of pass band (in Hz) +# @param freq_sb2 Start of stop band (in Hz) +# @param passband_ripple_db Pass band ripple in dB (should be small, < 1) +# @param stopband_atten_db Stop band attenuation in dB (should be large, >= 60) +# @param nextra_taps Extra taps to use in the filter (default=2) +def complex_band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, + passband_ripple_db, stopband_atten_db, + nextra_taps=2): + center_freq = (freq_pb2 + freq_pb1) / 2.0 + lp_pb = (freq_pb2 - center_freq)/1.0 + lp_sb = freq_sb2 - center_freq + lptaps = low_pass(gain, Fs, lp_pb, lp_sb, passband_ripple_db, + stopband_atten_db, nextra_taps) + spinner = [cmath.exp(2j*cmath.pi*center_freq/Fs*i) for i in xrange(len(lptaps))] + taps = [s*t for s,t in zip(spinner, lptaps)] + return taps + + +## Builds a band reject filter +# spinning it up to the right center frequency +# @param gain Filter gain in the passband (linear) +# @param Fs Sampling rate (sps) +# @param freq_pb1 End of pass band (in Hz) +# @param freq_sb1 Start of stop band (in Hz) +# @param freq_sb2 End of stop band (in Hz) +# @param freq_pb2 Start of pass band (in Hz) +# @param passband_ripple_db Pass band ripple in dB (should be small, < 1) +# @param stopband_atten_db Stop band attenuation in dB (should be large, >= 60) +# @param nextra_taps Extra taps to use in the filter (default=2) +def band_reject (gain, Fs, freq_pb1, freq_sb1, freq_sb2, freq_pb2, + passband_ripple_db, stopband_atten_db, + nextra_taps=2): + passband_dev = passband_ripple_to_dev (passband_ripple_db) + stopband_dev = stopband_atten_to_dev (stopband_atten_db) + desired_ampls = (gain, 0, gain) + desired_freqs = [freq_pb1, freq_sb1, freq_sb2, freq_pb2] + desired_ripple = [passband_dev, stopband_dev, passband_dev] + (n, fo, ao, w) = remezord (desired_freqs, desired_ampls, + desired_ripple, Fs) + # Make sure we use an odd number of taps + if((n+nextra_taps)%2 == 1): + n += 1 + # The remezord typically under-estimates the filter order, so add 2 taps by default + taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass") + return taps + + ## Builds a high pass filter. # @param gain Filter gain in the passband (linear) # @param Fs Sampling rate (sps) diff --git a/gr-utils/src/python/Makefile.am b/gr-utils/src/python/Makefile.am index 65cbd536c..59ca215a7 100644 --- a/gr-utils/src/python/Makefile.am +++ b/gr-utils/src/python/Makefile.am @@ -23,12 +23,16 @@ include $(top_srcdir)/Makefile.common EXTRA_DIST = \ $(bin_SCRIPTS) \ - README.plot + README.plot \ + pyqt_plot.ui \ + pyqt_filter.ui ourpythondir = $(grpythondir) ourpython_PYTHON = \ - plot_data.py + plot_data.py \ + pyqt_plot.py \ + pyqt_filter.py bin_SCRIPTS = \ gr_plot_char.py \ @@ -43,6 +47,8 @@ bin_SCRIPTS = \ gr_plot_int.py \ gr_plot_iq.py \ gr_plot_short.py \ + gr_plot_qt.py \ + gr_filter_design.py \ lsusrp \ qr_fft.py \ usrp_fft.py \ @@ -57,3 +63,4 @@ bin_SCRIPTS = \ usrp2_rx_cfile.py \ usrp2_siggen.py \ usrp2_siggen_gui.py + diff --git a/gr-utils/src/python/gr_filter_design.py b/gr-utils/src/python/gr_filter_design.py new file mode 100755 index 000000000..bf83cf69f --- /dev/null +++ b/gr-utils/src/python/gr_filter_design.py @@ -0,0 +1,673 @@ +#!/usr/bin/env python + +import sys, os +from optparse import OptionParser +from gnuradio import gr, blks2, eng_notation + +try: + import scipy + from scipy import fftpack +except ImportError: + print "Please install SciPy to run this script (http://www.scipy.org/)" + raise SystemExit, 1 + +try: + from PyQt4 import Qt, QtCore, QtGui +except ImportError: + print "Please install PyQt4 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)" + raise SystemExit, 1 + +try: + import PyQt4.Qwt5 as Qwt +except ImportError: + print "Please install PyQwt5 to run this script (http://pyqwt.sourceforge.net/)" + raise SystemExit, 1 + +try: + from pyqt_filter import Ui_MainWindow +except ImportError: + print "Could not import from pyqt_filter. Please build with \"pyuic4 pyqt_filter.ui -o pyqt_filter.py\"" + raise SystemExit, 1 + + +class gr_plot_filter(QtGui.QMainWindow): + def __init__(self, qapp, options): + QtGui.QWidget.__init__(self, None) + self.gui = Ui_MainWindow() + self.gui.setupUi(self) + + self.connect(self.gui.filterTypeComboBox, + Qt.SIGNAL("currentIndexChanged(const QString&)"), + self.changed_filter_type) + self.connect(self.gui.filterDesignTypeComboBox, + Qt.SIGNAL("currentIndexChanged(const QString&)"), + self.changed_filter_design_type) + + self.connect(self.gui.designButton, + Qt.SIGNAL("released()"), + self.design) + + self.connect(self.gui.tabGroup, + Qt.SIGNAL("currentChanged(int)"), + self.tab_changed) + + self.connect(self.gui.nfftEdit, + Qt.SIGNAL("textEdited(QString)"), + self.nfft_edit_changed) + + self.gui.designButton.setShortcut(QtCore.Qt.Key_Return) + + self.taps = [] + self.fftdB = [] + self.fftDeg = [] + self.groupDelay = [] + self.nfftpts = int(10000) + self.gui.nfftEdit.setText(Qt.QString("%1").arg(self.nfftpts)) + + self.firFilters = ("Low Pass", "Band Pass", "Complex Band Pass", "Band Notch", + "High Pass", "Root Raised Cosine", "Gaussian") + self.optFilters = ("Low Pass", "Band Pass", "Complex Band Pass", + "Band Notch", "High Pass") + + self.set_windowed() + + # Initialize to LPF + self.gui.filterTypeWidget.setCurrentWidget(self.gui.firlpfPage) + + # Set Axis labels + self.gui.freqPlot.setAxisTitle(self.gui.freqPlot.xBottom, + "Frequency (Hz)") + self.gui.freqPlot.setAxisTitle(self.gui.freqPlot.yLeft, + "Magnitude (dB)") + self.gui.timePlot.setAxisTitle(self.gui.timePlot.xBottom, + "Tap number") + self.gui.timePlot.setAxisTitle(self.gui.timePlot.yLeft, + "Amplitude") + self.gui.phasePlot.setAxisTitle(self.gui.phasePlot.xBottom, + "Frequency (Hz)") + self.gui.phasePlot.setAxisTitle(self.gui.phasePlot.yLeft, + "Phase (Radians)") + self.gui.groupPlot.setAxisTitle(self.gui.groupPlot.xBottom, + "Frequency (Hz)") + self.gui.groupPlot.setAxisTitle(self.gui.groupPlot.yLeft, + "Delay (sec)") + + # Set up plot curves + self.rcurve = Qwt.QwtPlotCurve("Real") + self.rcurve.attach(self.gui.timePlot) + self.icurve = Qwt.QwtPlotCurve("Imag") + self.icurve.attach(self.gui.timePlot) + + self.freqcurve = Qwt.QwtPlotCurve("PSD") + self.freqcurve.attach(self.gui.freqPlot) + + self.phasecurve = Qwt.QwtPlotCurve("Phase") + self.phasecurve.attach(self.gui.phasePlot) + + self.groupcurve = Qwt.QwtPlotCurve("Group Delay") + self.groupcurve.attach(self.gui.groupPlot) + + # Create zoom functionality for the plots + self.timeZoomer = Qwt.QwtPlotZoomer(self.gui.timePlot.xBottom, + self.gui.timePlot.yLeft, + Qwt.QwtPicker.PointSelection, + Qwt.QwtPicker.AlwaysOn, + self.gui.timePlot.canvas()) + + self.freqZoomer = Qwt.QwtPlotZoomer(self.gui.freqPlot.xBottom, + self.gui.freqPlot.yLeft, + Qwt.QwtPicker.PointSelection, + Qwt.QwtPicker.AlwaysOn, + self.gui.freqPlot.canvas()) + + self.phaseZoomer = Qwt.QwtPlotZoomer(self.gui.phasePlot.xBottom, + self.gui.phasePlot.yLeft, + Qwt.QwtPicker.PointSelection, + Qwt.QwtPicker.AlwaysOn, + self.gui.phasePlot.canvas()) + + self.groupZoomer = Qwt.QwtPlotZoomer(self.gui.groupPlot.xBottom, + self.gui.groupPlot.yLeft, + Qwt.QwtPicker.PointSelection, + Qwt.QwtPicker.AlwaysOn, + self.gui.groupPlot.canvas()) + + # Set up pen for colors and line width + blue = QtGui.qRgb(0x00, 0x00, 0xFF) + blueBrush = Qt.QBrush(Qt.QColor(blue)) + red = QtGui.qRgb(0xFF, 0x00, 0x00) + redBrush = Qt.QBrush(Qt.QColor(red)) + self.freqcurve.setPen(Qt.QPen(blueBrush, 2)) + self.rcurve.setPen(Qt.QPen(blueBrush, 2)) + self.icurve.setPen(Qt.QPen(redBrush, 2)) + self.phasecurve.setPen(Qt.QPen(blueBrush, 2)) + self.groupcurve.setPen(Qt.QPen(blueBrush, 2)) + + # Set up validators for edit boxes + self.intVal = Qt.QIntValidator(None) + self.dblVal = Qt.QDoubleValidator(None) + self.gui.nfftEdit.setValidator(self.intVal) + self.gui.sampleRateEdit.setValidator(self.dblVal) + self.gui.filterGainEdit.setValidator(self.dblVal) + self.gui.endofLpfPassBandEdit.setValidator(self.dblVal) + self.gui.startofLpfStopBandEdit.setValidator(self.dblVal) + self.gui.lpfStopBandAttenEdit.setValidator(self.dblVal) + self.gui.lpfPassBandRippleEdit.setValidator(self.dblVal) + self.gui.startofBpfPassBandEdit.setValidator(self.dblVal) + self.gui.endofBpfPassBandEdit.setValidator(self.dblVal) + self.gui.bpfTransitionEdit.setValidator(self.dblVal) + self.gui.bpfStopBandAttenEdit.setValidator(self.dblVal) + self.gui.bpfPassBandRippleEdit.setValidator(self.dblVal) + self.gui.startofBnfStopBandEdit.setValidator(self.dblVal) + self.gui.endofBnfStopBandEdit.setValidator(self.dblVal) + self.gui.bnfTransitionEdit.setValidator(self.dblVal) + self.gui.bnfStopBandAttenEdit.setValidator(self.dblVal) + self.gui.bnfPassBandRippleEdit.setValidator(self.dblVal) + self.gui.endofHpfStopBandEdit.setValidator(self.dblVal) + self.gui.startofHpfPassBandEdit.setValidator(self.dblVal) + self.gui.hpfStopBandAttenEdit.setValidator(self.dblVal) + self.gui.hpfPassBandRippleEdit.setValidator(self.dblVal) + self.gui.rrcSymbolRateEdit.setValidator(self.dblVal) + self.gui.rrcAlphaEdit.setValidator(self.dblVal) + self.gui.rrcNumTapsEdit.setValidator(self.dblVal) + self.gui.gausSymbolRateEdit.setValidator(self.dblVal) + self.gui.gausBTEdit.setValidator(self.dblVal) + self.gui.gausNumTapsEdit.setValidator(self.dblVal) + + self.gui.nTapsEdit.setText("0") + + self.filterWindows = {"Hamming Window" : gr.firdes.WIN_HAMMING, + "Hann Window" : gr.firdes.WIN_HANN, + "Blackman Window" : gr.firdes.WIN_BLACKMAN, + "Rectangular Window" : gr.firdes.WIN_RECTANGULAR, + "Kaiser Window" : gr.firdes.WIN_KAISER, + "Blackman-harris Window" : gr.firdes.WIN_BLACKMAN_hARRIS} + + self.show() + + def changed_filter_type(self, ftype): + strftype = str(ftype.toAscii()) + if(ftype == "Low Pass"): + self.gui.filterTypeWidget.setCurrentWidget(self.gui.firlpfPage) + elif(ftype == "Band Pass"): + self.gui.filterTypeWidget.setCurrentWidget(self.gui.firbpfPage) + elif(ftype == "Complex Band Pass"): + self.gui.filterTypeWidget.setCurrentWidget(self.gui.firbpfPage) + elif(ftype == "Band Notch"): + self.gui.filterTypeWidget.setCurrentWidget(self.gui.firbnfPage) + elif(ftype == "High Pass"): + self.gui.filterTypeWidget.setCurrentWidget(self.gui.firhpfPage) + elif(ftype == "Root Raised Cosine"): + self.gui.filterTypeWidget.setCurrentWidget(self.gui.rrcPage) + elif(ftype == "Gaussian"): + self.gui.filterTypeWidget.setCurrentWidget(self.gui.gausPage) + + self.design() + + def changed_filter_design_type(self, design): + if(design == "Equiripple"): + self.set_equiripple() + else: + self.set_windowed() + + self.design() + + def set_equiripple(self): + # Stop sending the signal for this function + self.gui.filterTypeComboBox.blockSignals(True) + + self.equiripple = True + self.gui.lpfPassBandRippleLabel.setVisible(True) + self.gui.lpfPassBandRippleEdit.setVisible(True) + self.gui.bpfPassBandRippleLabel.setVisible(True) + self.gui.bpfPassBandRippleEdit.setVisible(True) + self.gui.bnfPassBandRippleLabel.setVisible(True) + self.gui.bnfPassBandRippleEdit.setVisible(True) + self.gui.hpfPassBandRippleLabel.setVisible(True) + self.gui.hpfPassBandRippleEdit.setVisible(True) + + # Save current type and repopulate the combo box for + # filters this window type can handle + currenttype = self.gui.filterTypeComboBox.currentText() + items = self.gui.filterTypeComboBox.count() + for i in xrange(items): + self.gui.filterTypeComboBox.removeItem(0) + self.gui.filterTypeComboBox.addItems(self.optFilters) + + # If the last filter type was valid for this window type, + # go back to it; otherwise, reset + try: + index = self.optFilters.index(currenttype) + self.gui.filterTypeComboBox.setCurrentIndex(index) + except ValueError: + pass + + # Tell gui its ok to start sending this signal again + self.gui.filterTypeComboBox.blockSignals(False) + + def set_windowed(self): + # Stop sending the signal for this function + self.gui.filterTypeComboBox.blockSignals(True) + + self.equiripple = False + self.gui.lpfPassBandRippleLabel.setVisible(False) + self.gui.lpfPassBandRippleEdit.setVisible(False) + self.gui.bpfPassBandRippleLabel.setVisible(False) + self.gui.bpfPassBandRippleEdit.setVisible(False) + self.gui.bnfPassBandRippleLabel.setVisible(False) + self.gui.bnfPassBandRippleEdit.setVisible(False) + self.gui.hpfPassBandRippleLabel.setVisible(False) + self.gui.hpfPassBandRippleEdit.setVisible(False) + + # Save current type and repopulate the combo box for + # filters this window type can handle + currenttype = self.gui.filterTypeComboBox.currentText() + items = self.gui.filterTypeComboBox.count() + for i in xrange(items): + self.gui.filterTypeComboBox.removeItem(0) + self.gui.filterTypeComboBox.addItems(self.firFilters) + + # If the last filter type was valid for this window type, + # go back to it; otherwise, reset + try: + index = self.optFilters.index(currenttype) + self.gui.filterTypeComboBox.setCurrentIndex(index) + except ValueError: + pass + + # Tell gui its ok to start sending this signal again + self.gui.filterTypeComboBox.blockSignals(False) + + def design(self): + ret = True + fs,r = self.gui.sampleRateEdit.text().toDouble() + ret = r and ret + gain,r = self.gui.filterGainEdit.text().toDouble() + ret = r and ret + + if(ret): + winstr = str(self.gui.filterDesignTypeComboBox.currentText().toAscii()) + ftype = str(self.gui.filterTypeComboBox.currentText().toAscii()) + + if(winstr == "Equiripple"): + designer = {"Low Pass" : self.design_opt_lpf, + "Band Pass" : self.design_opt_bpf, + "Complex Band Pass" : self.design_opt_cbpf, + "Band Notch" : self.design_opt_bnf, + "High Pass" : self.design_opt_hpf} + taps,r = designer[ftype](fs, gain) + + else: + designer = {"Low Pass" : self.design_win_lpf, + "Band Pass" : self.design_win_bpf, + "Complex Band Pass" : self.design_win_cbpf, + "Band Notch" : self.design_win_bnf, + "High Pass" : self.design_win_hpf, + "Root Raised Cosine" : self.design_win_rrc, + "Gaussian" : self.design_win_gaus} + wintype = self.filterWindows[winstr] + taps,r = designer[ftype](fs, gain, wintype) + + if(r): + self.taps = scipy.array(taps) + self.get_fft(fs, self.taps, self.nfftpts) + self.update_time_curves() + self.update_freq_curves() + self.update_phase_curves() + self.update_group_curves() + + self.gui.nTapsEdit.setText(Qt.QString("%1").arg(self.taps.size)) + + + # Filter design functions using a window + def design_win_lpf(self, fs, gain, wintype): + ret = True + pb,r = self.gui.endofLpfPassBandEdit.text().toDouble() + ret = r and ret + sb,r = self.gui.startofLpfStopBandEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.lpfStopBandAttenEdit.text().toDouble() + ret = r and ret + + if(ret): + tb = sb - pb + + taps = gr.firdes.low_pass_2(gain, fs, pb, tb, + atten, wintype) + return (taps, ret) + else: + return ([], ret) + + def design_win_bpf(self, fs, gain, wintype): + ret = True + pb1,r = self.gui.startofBpfPassBandEdit.text().toDouble() + ret = r and ret + pb2,r = self.gui.endofBpfPassBandEdit.text().toDouble() + ret = r and ret + tb,r = self.gui.bpfTransitionEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.bpfStopBandAttenEdit.text().toDouble() + ret = r and ret + + if(r): + taps = gr.firdes.band_pass_2(gain, fs, pb1, pb2, tb, + atten, wintype) + return (taps,r) + else: + return ([],r) + + def design_win_cbpf(self, fs, gain, wintype): + ret = True + pb1,r = self.gui.startofBpfPassBandEdit.text().toDouble() + ret = r and ret + pb2,r = self.gui.endofBpfPassBandEdit.text().toDouble() + ret = r and ret + tb,r = self.gui.bpfTransitionEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.bpfStopBandAttenEdit.text().toDouble() + ret = r and ret + + if(r): + taps = gr.firdes.complex_band_pass_2(gain, fs, pb1, pb2, tb, + atten, wintype) + return (taps,r) + else: + return ([],r) + + def design_win_bnf(self, fs, gain, wintype): + ret = True + pb1,r = self.gui.startofBnfStopBandEdit.text().toDouble() + ret = r and ret + pb2,r = self.gui.endofBnfStopBandEdit.text().toDouble() + ret = r and ret + tb,r = self.gui.bnfTransitionEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.bnfStopBandAttenEdit.text().toDouble() + ret = r and ret + + if(r): + taps = gr.firdes.band_reject_2(gain, fs, pb1, pb2, tb, + atten, wintype) + return (taps,r) + else: + return ([],r) + + def design_win_hpf(self, fs, gain, wintype): + ret = True + sb,r = self.gui.endofHpfStopBandEdit.text().toDouble() + ret = r and ret + pb,r = self.gui.startofHpfPassBandEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.hpfStopBandAttenEdit.text().toDouble() + ret = r and ret + + if(r): + tb = pb - sb + taps = gr.firdes.high_pass_2(gain, fs, pb, tb, + atten, wintype) + return (taps,r) + else: + return ([],r) + + def design_win_rrc(self, fs, gain, wintype): + ret = True + sr,r = self.gui.rrcSymbolRateEdit.text().toDouble() + ret = r and ret + alpha,r = self.gui.rrcAlphaEdit.text().toDouble() + ret = r and ret + ntaps,r = self.gui.rrcNumTapsEdit.text().toInt() + ret = r and ret + + if(r): + taps = gr.firdes.root_raised_cosine(gain, fs, sr, + alpha, ntaps) + return (taps,r) + else: + return ([],r) + + def design_win_gaus(self, fs, gain, wintype): + ret = True + sr,r = self.gui.gausSymbolRateEdit.text().toDouble() + ret = r and ret + bt,r = self.gui.gausBTEdit.text().toDouble() + ret = r and ret + ntaps,r = self.gui.gausNumTapsEdit.text().toInt() + ret = r and ret + + if(r): + spb = fs / sr + taps = gr.firdes.gaussian(gain, spb, bt, ntaps) + return (taps,r) + else: + return ([],r) + + # Design Functions for Equiripple Filters + def design_opt_lpf(self, fs, gain): + ret = True + pb,r = self.gui.endofLpfPassBandEdit.text().toDouble() + ret = r and ret + sb,r = self.gui.startofLpfStopBandEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.lpfStopBandAttenEdit.text().toDouble() + ret = r and ret + ripple,r = self.gui.lpfPassBandRippleEdit.text().toDouble() + ret = r and ret + + if(ret): + taps = blks2.optfir.low_pass(gain, fs, pb, sb, + ripple, atten) + return (taps, ret) + else: + return ([], ret) + + def design_opt_bpf(self, fs, gain): + ret = True + pb1,r = self.gui.startofBpfPassBandEdit.text().toDouble() + ret = r and ret + pb2,r = self.gui.endofBpfPassBandEdit.text().toDouble() + ret = r and ret + tb,r = self.gui.bpfTransitionEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.bpfStopBandAttenEdit.text().toDouble() + ret = r and ret + ripple,r = self.gui.bpfPassBandRippleEdit.text().toDouble() + ret = r and ret + + if(r): + sb1 = pb1 - tb + sb2 = pb2 + tb + taps = blks2.optfir.band_pass(gain, fs, sb1, pb1, pb2, sb2, + ripple, atten) + return (taps,r) + else: + return ([],r) + + def design_opt_cbpf(self, fs, gain): + ret = True + pb1,r = self.gui.startofBpfPassBandEdit.text().toDouble() + ret = r and ret + pb2,r = self.gui.endofBpfPassBandEdit.text().toDouble() + ret = r and ret + tb,r = self.gui.bpfTransitionEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.bpfStopBandAttenEdit.text().toDouble() + ret = r and ret + ripple,r = self.gui.bpfPassBandRippleEdit.text().toDouble() + ret = r and ret + + if(r): + sb1 = pb1 - tb + sb2 = pb2 + tb + taps = blks2.optfir.complex_band_pass(gain, fs, sb1, pb1, pb2, sb2, + ripple, atten) + return (taps,r) + else: + return ([],r) + + def design_opt_bnf(self, fs, gain): + ret = True + sb1,r = self.gui.startofBnfStopBandEdit.text().toDouble() + ret = r and ret + sb2,r = self.gui.endofBnfStopBandEdit.text().toDouble() + ret = r and ret + tb,r = self.gui.bnfTransitionEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.bnfStopBandAttenEdit.text().toDouble() + ret = r and ret + ripple,r = self.gui.bnfPassBandRippleEdit.text().toDouble() + ret = r and ret + + if(r): + pb1 = sb1 - tb + pb2 = sb2 + tb + taps = blks2.optfir.band_reject(gain, fs, pb1, sb1, sb2, pb2, + ripple, atten) + return (taps,r) + else: + return ([],r) + + def design_opt_hpf(self, fs, gain): + ret = True + sb,r = self.gui.endofHpfStopBandEdit.text().toDouble() + ret = r and ret + pb,r = self.gui.startofHpfPassBandEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.hpfStopBandAttenEdit.text().toDouble() + ret = r and ret + ripple,r = self.gui.hpfPassBandRippleEdit.text().toDouble() + ret = r and ret + + if(r): + taps = blks2.optfir.high_pass(gain, fs, sb, pb, + atten, ripple) + return (taps,r) + else: + return ([],r) + + def nfft_edit_changed(self, nfft): + infft,r = nfft.toInt() + if(r and (infft != self.nfftpts)): + self.nfftpts = infft + self.update_freq_curves() + + def tab_changed(self, tab): + if(tab == 0): + self.update_freq_curves() + if(tab == 1): + self.update_time_curves() + if(tab == 2): + self.update_phase_curves() + if(tab == 3): + self.update_group_curves() + + def get_fft(self, fs, taps, Npts): + Ts = 1.0/fs + fftpts = fftpack.fft(taps, Npts) + self.freq = scipy.arange(0, fs, 1.0/(Npts*Ts)) + self.fftdB = 20.0*scipy.log10(abs(fftpts)) + self.fftDeg = scipy.unwrap(scipy.angle(fftpts)) + self.groupDelay = -scipy.diff(self.fftDeg) + + def update_time_curves(self): + ntaps = len(self.taps) + if(ntaps > 0): + if(type(self.taps[0]) == scipy.complex128): + self.rcurve.setData(scipy.arange(ntaps), self.taps.real) + self.icurve.setData(scipy.arange(ntaps), self.taps.imag) + else: + self.rcurve.setData(scipy.arange(ntaps), self.taps) + + # Reset the x-axis to the new time scale + ymax = 1.5 * max(self.taps) + ymin = 1.5 * min(self.taps) + self.gui.timePlot.setAxisScale(self.gui.timePlot.xBottom, + 0, ntaps) + self.gui.timePlot.setAxisScale(self.gui.timePlot.yLeft, + ymin, ymax) + + # Set the zoomer base to unzoom to the new axis + self.timeZoomer.setZoomBase() + + self.gui.timePlot.replot() + + def update_freq_curves(self): + npts = len(self.fftdB) + if(npts > 0): + self.freqcurve.setData(self.freq, self.fftdB) + + # Reset the x-axis to the new time scale + ymax = 1.5 * max(self.fftdB[0:npts/2]) + ymin = 1.1 * min(self.fftdB[0:npts/2]) + xmax = self.freq[npts/2] + xmin = self.freq[0] + self.gui.freqPlot.setAxisScale(self.gui.freqPlot.xBottom, + xmin, xmax) + self.gui.freqPlot.setAxisScale(self.gui.freqPlot.yLeft, + ymin, ymax) + + # Set the zoomer base to unzoom to the new axis + self.freqZoomer.setZoomBase() + + self.gui.freqPlot.replot() + + + def update_phase_curves(self): + npts = len(self.fftDeg) + if(npts > 0): + self.phasecurve.setData(self.freq, self.fftDeg) + + # Reset the x-axis to the new time scale + ymax = 1.5 * max(self.fftDeg[0:npts/2]) + ymin = 1.1 * min(self.fftDeg[0:npts/2]) + xmax = self.freq[npts/2] + xmin = self.freq[0] + self.gui.phasePlot.setAxisScale(self.gui.phasePlot.xBottom, + xmin, xmax) + self.gui.phasePlot.setAxisScale(self.gui.phasePlot.yLeft, + ymin, ymax) + + # Set the zoomer base to unzoom to the new axis + self.phaseZoomer.setZoomBase() + + self.gui.phasePlot.replot() + + def update_group_curves(self): + npts = len(self.groupDelay) + if(npts > 0): + self.groupcurve.setData(self.freq, self.groupDelay) + + # Reset the x-axis to the new time scale + ymax = 1.5 * max(self.groupDelay[0:npts/2]) + ymin = 1.1 * min(self.groupDelay[0:npts/2]) + xmax = self.freq[npts/2] + xmin = self.freq[0] + self.gui.groupPlot.setAxisScale(self.gui.groupPlot.xBottom, + xmin, xmax) + self.gui.groupPlot.setAxisScale(self.gui.groupPlot.yLeft, + ymin, ymax) + + # Set the zoomer base to unzoom to the new axis + self.groupZoomer.setZoomBase() + + self.gui.groupPlot.replot() + + +def setup_options(): + usage="%prog: [options] (input_filename)" + description = "" + + parser = OptionParser(conflict_handler="resolve", + usage=usage, description=description) + return parser + +def main(args): + parser = setup_options() + (options, args) = parser.parse_args () + + app = Qt.QApplication(args) + gplt = gr_plot_filter(app, options) + app.exec_() + +if __name__ == '__main__': + main(sys.argv) + diff --git a/gr-utils/src/python/gr_plot_qt.py b/gr-utils/src/python/gr_plot_qt.py new file mode 100755 index 000000000..a5e3463c8 --- /dev/null +++ b/gr-utils/src/python/gr_plot_qt.py @@ -0,0 +1,643 @@ +#!/usr/bin/env python + +try: + import scipy + from scipy import fftpack +except ImportError: + print "Please install SciPy to run this script (http://www.scipy.org/)" + raise SystemExit, 1 + +import sys, os +from PyQt4 import Qt, QtCore, QtGui +import PyQt4.Qwt5 as Qwt +from matplotlib import mlab +from optparse import OptionParser +from gnuradio import eng_notation + +from pyqt_plot import Ui_MainWindow + +class SpectrogramData(Qwt.QwtRasterData): + + def __init__(self, f, t): + Qwt.QwtArrayData.__init__(self, Qt.QRectF(0, 0, 0, 0)) + self.sp = scipy.array([[0], [0]]) + + def set_data(self, xfreq, ytime, data): + self.sp = data + self.freq = xfreq + self.time = ytime + boundingBox = Qt.QRectF(self.freq.min(), self.time.min(), + self.freq.max() - self.freq.min(), + self.time.max() - self.time.min()) + self.setBoundingRect(boundingBox) + + def rasterHint(self, rect): + return Qt.QSize(self.sp.shape[0], self.sp.shape[1]) + + def copy(self): + return self + + def range(self): + + return Qwt.QwtDoubleInterval(self.sp.min(), self.sp.max()) + + def value(self, x, y): + f = int(self.freq.searchsorted(x)) + t = int(self.time.searchsorted(y)) + return self.sp[f][t-1] + + +class gr_plot_qt(QtGui.QMainWindow): + def __init__(self, qapp, filename, options, parent=None): + QtGui.QWidget.__init__(self, parent) + self.gui = Ui_MainWindow() + self.gui.setupUi(self) + + self.block_length = options.block_length + self.start = options.start + self.sample_rate = options.sample_rate + self.psdfftsize = options.psd_size + self.specfftsize = options.spec_size + self.winfunc = scipy.blackman + self.sizeof_data = 8 + self.datatype = scipy.complex64 + self.iq = list() + self.time = list() + + # Set up basic plot attributes + self.gui.timePlot.setAxisTitle(self.gui.timePlot.xBottom, "Time (sec)") + self.gui.timePlot.setAxisTitle(self.gui.timePlot.yLeft, "Amplitude (V)") + self.gui.freqPlot.setAxisTitle(self.gui.freqPlot.xBottom, "Frequency (Hz)") + self.gui.freqPlot.setAxisTitle(self.gui.freqPlot.yLeft, "Magnitude (dB)") + self.gui.specPlot.setAxisTitle(self.gui.specPlot.xBottom, "Frequency (Hz)") + self.gui.specPlot.setAxisTitle(self.gui.specPlot.yLeft, "Time (sec)") + + # Set up FFT size combo box + self.fftsizes = ["128", "256", "512", "1024", "2048", + "4096", "8192", "16384", "32768"] + self.gui.psdFFTComboBox.addItems(self.fftsizes) + self.gui.specFFTComboBox.addItems(self.fftsizes) + pos = self.gui.psdFFTComboBox.findText(Qt.QString("%1").arg(self.psdfftsize)) + self.gui.psdFFTComboBox.setCurrentIndex(pos) + pos = self.gui.specFFTComboBox.findText(Qt.QString("%1").arg(self.specfftsize)) + self.gui.specFFTComboBox.setCurrentIndex(pos) + + self.connect(self.gui.psdFFTComboBox, + Qt.SIGNAL("activated (const QString&)"), + self.psdFFTComboBoxEdit) + self.connect(self.gui.specFFTComboBox, + Qt.SIGNAL("activated (const QString&)"), + self.specFFTComboBoxEdit) + + # Set up color scheme box + self.color_modes = {"Black on White" : self.color_black_on_white, + "White on Black" : self.color_white_on_black, + "Blue on Black" : self.color_blue_on_black, + "Green on Black" : self.color_green_on_black} + self.gui.colorComboBox.addItems(self.color_modes.keys()) + pos = self.gui.colorComboBox.findText("Blue on Black") + self.gui.colorComboBox.setCurrentIndex(pos) + self.connect(self.gui.colorComboBox, + Qt.SIGNAL("activated (const QString&)"), + self.colorComboBoxEdit) + + + # Create zoom functionality for the plots + self.timeZoomer = Qwt.QwtPlotZoomer(self.gui.timePlot.xBottom, + self.gui.timePlot.yLeft, + Qwt.QwtPicker.PointSelection, + Qwt.QwtPicker.AlwaysOn, + self.gui.timePlot.canvas()) + + self.freqZoomer = Qwt.QwtPlotZoomer(self.gui.freqPlot.xBottom, + self.gui.freqPlot.yLeft, + Qwt.QwtPicker.PointSelection, + Qwt.QwtPicker.AlwaysOn, + self.gui.freqPlot.canvas()) + + self.specZoomer = Qwt.QwtPlotZoomer(self.gui.specPlot.xBottom, + self.gui.specPlot.yLeft, + Qwt.QwtPicker.PointSelection, + Qwt.QwtPicker.AlwaysOn, + self.gui.specPlot.canvas()) + + self.picker = Qwt.QwtPlotPicker(self.gui.timePlot.xBottom, + self.gui.timePlot.yLeft, + Qwt.QwtPicker.PointSelection, + Qwt.QwtPlotPicker.CrossRubberBand, + Qwt.QwtPicker.AlwaysOn, + self.gui.timePlot.canvas()) + self.picker.connect(self.picker, + Qt.SIGNAL('selected(const QwtDoublePoint&)'), + self.clickMe) + + # Set up action when tab is changed + self.connect(self.gui.tabGroup, + Qt.SIGNAL("currentChanged (int)"), + self.tabChanged) + + # Add a legend to the Time plot + legend_real = Qwt.QwtLegend() + self.gui.timePlot.insertLegend(legend_real) + + # Set up slider + self.gui.plotHBar.setSingleStep(1) + self.gui.plotHBar.setPageStep(self.block_length) + self.gui.plotHBar.setMinimum(0) + self.gui.plotHBar.setMaximum(self.block_length) + self.connect(self.gui.plotHBar, + Qt.SIGNAL("valueChanged(int)"), + self.sliderMoved) + + # Connect Open action to Open Dialog box + self.connect(self.gui.action_open, + Qt.SIGNAL("activated()"), + self.open_file) + + # Set up file position boxes to update current figure + self.connect(self.gui.filePosStartLineEdit, + Qt.SIGNAL("editingFinished()"), + self.file_position_changed) + self.connect(self.gui.filePosStopLineEdit, + Qt.SIGNAL("editingFinished()"), + self.file_position_changed) + self.connect(self.gui.filePosLengthLineEdit, + Qt.SIGNAL("editingFinished()"), + self.file_length_changed) + + self.connect(self.gui.fileTimeStartLineEdit, + Qt.SIGNAL("editingFinished()"), + self.file_time_changed) + self.connect(self.gui.fileTimeStopLineEdit, + Qt.SIGNAL("editingFinished()"), + self.file_time_changed) + self.connect(self.gui.fileTimeLengthLineEdit, + Qt.SIGNAL("editingFinished()"), + self.file_time_length_changed) + + self.rcurve = Qwt.QwtPlotCurve("Real") + self.icurve = Qwt.QwtPlotCurve("Imaginary") + + self.icurve.attach(self.gui.timePlot) + self.rcurve.attach(self.gui.timePlot) + + self.psdcurve = Qwt.QwtPlotCurve("PSD") + self.psdcurve.attach(self.gui.freqPlot) + + # Set up specTab plot as a spectrogram + self.specdata = SpectrogramData(range(0, 10), range(0, 10)) + + colorMap = Qwt.QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red) + colorMap.addColorStop(0.1, Qt.Qt.cyan) + colorMap.addColorStop(0.6, Qt.Qt.green) + colorMap.addColorStop(0.95, Qt.Qt.yellow) + + self.spec = Qwt.QwtPlotSpectrogram() + self.spec.setColorMap(colorMap) + self.spec.attach(self.gui.specPlot) + self.spec.setDisplayMode(Qwt.QwtPlotSpectrogram.ImageMode, True) + self.spec.setData(self.specdata) + + self.rightAxis = self.gui.specPlot.axisWidget(Qwt.QwtPlot.yRight) + self.rightAxis.setTitle("Magnitude (dBm)") + self.rightAxis.setColorBarEnabled(True) + self.rightAxis.setColorMap(self.spec.data().range(), + self.spec.colorMap()) + self.gui.specPlot.enableAxis(Qwt.QwtPlot.yRight) + + # Set up initial color scheme + self.color_modes["Blue on Black"]() + + # Connect a signal for when the sample rate changes + self.set_sample_rate(self.sample_rate) + self.connect(self.gui.sampleRateLineEdit, + Qt.SIGNAL("editingFinished()"), + self.sample_rate_changed) + + if(filename is not None): + self.initialize(filename) + + self.show() + + def open_file(self): + filename = Qt.QFileDialog.getOpenFileName(self, "Open", ".") + if(filename != ""): + print filename + self.initialize(filename) + + def initialize(self, filename): + self.hfile = open(filename, "r") + + self.setWindowTitle(("GNU Radio File Plot Utility: %s" % filename)) + + self.gui.filePosStartLineEdit.setText("0") + self.gui.filePosStopLineEdit.setText("0") + self.gui.fileTimeStartLineEdit.setText("0") + self.gui.fileTimeStopLineEdit.setText("0") + + self.cur_start = 0 + self.cur_stop = self.block_length + + self.init_data_input() + self.get_data(self.cur_start, self.cur_stop) + self.get_psd() + self.get_specgram() + self.gui.plotHBar.setSliderPosition(0) + self.gui.plotHBar.setMaximum(self.signal_size) + + + self.update_time_curves() + self.update_psd_curves() + self.update_specgram_curves() + + def init_data_input(self): + self.hfile.seek(0, os.SEEK_END) + self.signal_size = self.hfile.tell()/self.sizeof_data + print "Sizeof File: ", self.signal_size + self.hfile.seek(0, os.SEEK_SET) + + def get_data(self, start, end): + if(end > start): + self.hfile.seek(start*self.sizeof_data, os.SEEK_SET) + self.position = start + try: + iq = scipy.fromfile(self.hfile, dtype=self.datatype, + count=end-start) + + if(len(iq) < (end-start)): + end = len(iq) + self.gui.filePosLengthLineEdit.setText(Qt.QString("%1").arg(end)) + self.gui.plotHBar.setMaximum(end) + self.gui.plotHBar.setSingleStep(end) + self.file_length_changed() + + tstep = 1.0 / self.sample_rate + self.iq = iq + self.time = [tstep*(self.position + i) for i in xrange(len(self.iq))] + + self.set_file_pos_box(start, end) + except MemoryError: + pass + else: + # Do we want to do anything about this? + pass + + def get_psd(self): + winpoints = self.winfunc(self.psdfftsize) + iq_psd, freq = mlab.psd(self.iq, Fs=self.sample_rate, + NFFT=self.psdfftsize, + noverlap=self.psdfftsize/4.0, + window=winpoints, + scale_by_freq=False) + + self.iq_psd = 10.0*scipy.log10(abs(fftpack.fftshift(iq_psd))) + self.freq = freq - self.sample_rate/2.0 + + def get_specgram(self): + winpoints = self.winfunc(self.specfftsize) + iq_spec, f, t = mlab.specgram(self.iq, Fs=self.sample_rate, + NFFT=self.specfftsize, + noverlap=self.specfftsize/4.0, + window=winpoints, + scale_by_freq=False) + + self.iq_spec = 10.0*scipy.log10(abs(iq_spec)) + self.spec_f = f + self.spec_t = t + + def clickMe(self, qPoint): + print qPoint.x() + + def psdFFTComboBoxEdit(self, fftSize): + self.psdfftsize = fftSize.toInt()[0] + self.get_psd() + self.update_psd_curves() + + def specFFTComboBoxEdit(self, fftSize): + self.specfftsize = fftSize.toInt()[0] + self.get_specgram() + self.update_specgram_curves() + + def colorComboBoxEdit(self, colorSelection): + colorstr = str(colorSelection.toAscii()) + color_func = self.color_modes[colorstr] + color_func() + + def sliderMoved(self, value): + pos_start = value + pos_end = value + self.gui.plotHBar.pageStep() + + self.get_data(pos_start, pos_end) + self.get_psd() + self.get_specgram() + self.update_time_curves() + self.update_psd_curves() + self.update_specgram_curves() + + def set_sample_rate(self, sr): + self.sample_rate = sr + srstr = eng_notation.num_to_str(self.sample_rate) + self.gui.sampleRateLineEdit.setText(Qt.QString("%1").arg(srstr)) + + def sample_rate_changed(self): + srstr = self.gui.sampleRateLineEdit.text().toAscii() + self.sample_rate = eng_notation.str_to_num(srstr) + self.set_file_pos_box(self.cur_start, self.cur_stop) + self.get_data(self.cur_start, self.cur_stop) + self.get_psd() + self.get_specgram() + self.update_time_curves() + self.update_psd_curves() + self.update_specgram_curves() + + def set_file_pos_box(self, start, end): + tstart = start / self.sample_rate + tend = end / self.sample_rate + + self.gui.filePosStartLineEdit.setText(Qt.QString("%1").arg(start)) + self.gui.filePosStopLineEdit.setText(Qt.QString("%1").arg(end)) + self.gui.filePosLengthLineEdit.setText(Qt.QString("%1").arg(end-start)) + + self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart)) + self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend)) + self.gui.fileTimeLengthLineEdit.setText(Qt.QString("%1").arg(tend-tstart)) + + def file_position_changed(self): + start = self.gui.filePosStartLineEdit.text().toInt() + end = self.gui.filePosStopLineEdit.text().toInt() + if((start[1] == True) and (end[1] == True)): + self.cur_start = start[0] + self.cur_stop = end[0] + + tstart = self.cur_start / self.sample_rate + tend = self.cur_stop / self.sample_rate + self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart)) + self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend)) + + self.get_data(self.cur_start, self.cur_stop) + + self.update_time_curves() + self.update_psd_curves() + self.update_specgram_curves() + + # If there's a non-digit character, reset box + else: + self.set_file_pos_box(self.cur_start, self.cur_stop) + + def file_time_changed(self): + tstart = self.gui.fileTimeStartLineEdit.text().toDouble() + tstop = self.gui.fileTimeStopLineEdit.text().toDouble() + if((tstart[1] == True) and (tstop[1] == True)): + self.cur_start = int(tstart[0] * self.sample_rate) + self.cur_stop = int(tstop[0] * self.sample_rate) + self.get_data(self.cur_start, self.cur_stop) + + self.gui.filePosStartLineEdit.setText(Qt.QString("%1").arg(self.cur_start)) + self.gui.filePosStopLineEdit.setText(Qt.QString("%1").arg(self.cur_stop)) + + self.update_time_curves() + self.update_psd_curves() + self.update_specgram_curves() + # If there's a non-digit character, reset box + else: + self.set_file_pos_box(self.cur_start, self.cur_stop) + + def file_length_changed(self): + start = self.gui.filePosStartLineEdit.text().toInt() + length = self.gui.filePosLengthLineEdit.text().toInt() + + if((start[1] == True) and (length[1] == True)): + self.cur_start = start[0] + self.block_length = length[0] + self.cur_stop = self.cur_start + self.block_length + + tstart = self.cur_start / self.sample_rate + tend = self.cur_stop / self.sample_rate + tlen = self.block_length / self.sample_rate + self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart)) + self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend)) + self.gui.fileTimeLengthLineEdit.setText(Qt.QString("%1").arg(tlen)) + + self.gui.plotHBar.setPageStep(self.block_length) + + self.get_data(self.cur_start, self.cur_stop) + self.get_psd() + self.get_specgram() + + self.update_time_curves() + self.update_psd_curves() + self.update_specgram_curves() + # If there's a non-digit character, reset box + else: + self.set_file_pos_box(self.cur_start, self.cur_stop) + + def file_time_length_changed(self): + tstart = self.gui.fileTimeStartLineEdit.text().toDouble() + tlength = self.gui.fileTimeLengthLineEdit.text().toDouble() + if((tstart[1] == True) and (tlength[1] == True)): + self.cur_start = int(tstart[0] * self.sample_rate) + self.block_length = int(tlength[0] * self.sample_rate) + self.cur_stop = self.cur_start + self.block_length + + tstart = self.cur_start / self.sample_rate + tend = self.cur_stop / self.sample_rate + tlen = self.block_length / self.sample_rate + self.gui.fileTimeStartLineEdit.setText(Qt.QString("%1").arg(tstart)) + self.gui.fileTimeStopLineEdit.setText(Qt.QString("%1").arg(tend)) + self.gui.fileTimeLengthLineEdit.setText(Qt.QString("%1").arg(tlen)) + + self.get_data(self.cur_start, self.cur_stop) + self.get_psd() + self.get_specgram() + + self.update_time_curves() + self.update_psd_curves() + self.update_specgram_curves() + # If there's a non-digit character, reset box + else: + self.set_file_pos_box(self.cur_start, self.cur_stop) + + + def update_time_curves(self): + self.icurve.setData(self.time, self.iq.imag) + self.rcurve.setData(self.time, self.iq.real) + + # Reset the x-axis to the new time scale + iqmax = 1.5 * max(max(self.iq.real), max(self.iq.imag)) + iqmin = 1.5 * min(min(self.iq.real), min(self.iq.imag)) + self.gui.timePlot.setAxisScale(self.gui.timePlot.xBottom, + min(self.time), + max(self.time)) + self.gui.timePlot.setAxisScale(self.gui.timePlot.yLeft, + iqmin, + iqmax) + + # Set the zoomer base to unzoom to the new axis + self.timeZoomer.setZoomBase() + + self.gui.timePlot.replot() + + def update_psd_curves(self): + self.psdcurve.setData(self.freq, self.iq_psd) + + self.gui.freqPlot.setAxisScale(self.gui.freqPlot.xBottom, + min(self.freq), + max(self.freq)) + + # Set the zoomer base to unzoom to the new axis + self.freqZoomer.setZoomBase() + + self.gui.freqPlot.replot() + + def update_specgram_curves(self): + # We don't have to reset the data for the speccurve here + # since this is taken care of in the SpectrogramData class + self.specdata.set_data(self.spec_f, self.spec_t, self.iq_spec) + + # Set the color map based on the new data + self.rightAxis.setColorMap(self.spec.data().range(), + self.spec.colorMap()) + + # Set the new axis base; include right axis for the intenisty color bar + self.gui.specPlot.setAxisScale(self.gui.specPlot.xBottom, + min(self.spec_f), + max(self.spec_f)) + self.gui.specPlot.setAxisScale(self.gui.specPlot.yLeft, + min(self.spec_t), + max(self.spec_t)) + self.gui.specPlot.setAxisScale(self.gui.specPlot.yRight, + self.iq_spec.min(), + self.iq_spec.max()) + + # Set the zoomer base to unzoom to the new axis + self.specZoomer.setZoomBase() + + self.gui.specPlot.replot() + + def tabChanged(self, index): + self.gui.timePlot.replot() + self.gui.freqPlot.replot() + + def color_black_on_white(self): + blue = QtGui.qRgb(0x00, 0x00, 0xFF) + red = QtGui.qRgb(0xFF, 0x00, 0x00) + + blackBrush = Qt.QBrush(Qt.QColor("black")) + blueBrush = Qt.QBrush(Qt.QColor(blue)) + redBrush = Qt.QBrush(Qt.QColor(red)) + + self.gui.timePlot.setCanvasBackground(Qt.QColor("white")) + self.gui.freqPlot.setCanvasBackground(Qt.QColor("white")) + self.picker.setTrackerPen(Qt.QPen(blackBrush, 2)) + self.timeZoomer.setTrackerPen(Qt.QPen(blackBrush, 2)) + self.timeZoomer.setRubberBandPen(Qt.QPen(blackBrush, 2)) + self.freqZoomer.setTrackerPen(Qt.QPen(blackBrush, 2)) + self.freqZoomer.setRubberBandPen(Qt.QPen(blackBrush, 2)) + self.psdcurve.setPen(Qt.QPen(blueBrush, 1)) + self.rcurve.setPen(Qt.QPen(blueBrush, 2)) + self.icurve.setPen(Qt.QPen(redBrush, 2)) + + self.gui.timePlot.replot() + self.gui.freqPlot.replot() + + def color_white_on_black(self): + white = QtGui.qRgb(0xFF, 0xFF, 0xFF) + red = QtGui.qRgb(0xFF, 0x00, 0x00) + + whiteBrush = Qt.QBrush(Qt.QColor("white")) + whiteBrush = Qt.QBrush(Qt.QColor(white)) + redBrush = Qt.QBrush(Qt.QColor(red)) + + self.gui.timePlot.setCanvasBackground(QtGui.QColor("black")) + self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black")) + self.picker.setTrackerPen(Qt.QPen(whiteBrush, 2)) + self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, 2)) + self.timeZoomer.setRubberBandPen(Qt.QPen(whiteBrush, 2)) + self.freqZoomer.setTrackerPen(Qt.QPen(whiteBrush, 2)) + self.freqZoomer.setRubberBandPen(Qt.QPen(whiteBrush, 2)) + self.psdcurve.setPen(Qt.QPen(whiteBrush, 1)) + self.rcurve.setPen(Qt.QPen(whiteBrush, 2)) + self.icurve.setPen(Qt.QPen(redBrush, 2)) + + self.gui.timePlot.replot() + self.gui.freqPlot.replot() + + + def color_green_on_black(self): + green = QtGui.qRgb(0x00, 0xFF, 0x00) + red = QtGui.qRgb(0xFF, 0x00, 0x50) + + whiteBrush = Qt.QBrush(Qt.QColor("white")) + greenBrush = Qt.QBrush(Qt.QColor(green)) + redBrush = Qt.QBrush(Qt.QColor(red)) + + self.gui.timePlot.setCanvasBackground(QtGui.QColor("black")) + self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black")) + self.picker.setTrackerPen(Qt.QPen(whiteBrush, 2)) + self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, 2)) + self.timeZoomer.setRubberBandPen(Qt.QPen(whiteBrush, 2)) + self.freqZoomer.setTrackerPen(Qt.QPen(whiteBrush, 2)) + self.freqZoomer.setRubberBandPen(Qt.QPen(whiteBrush, 2)) + self.psdcurve.setPen(Qt.QPen(greenBrush, 1)) + self.rcurve.setPen(Qt.QPen(greenBrush, 2)) + self.icurve.setPen(Qt.QPen(redBrush, 2)) + + self.gui.timePlot.replot() + self.gui.freqPlot.replot() + + def color_blue_on_black(self): + blue = QtGui.qRgb(0x00, 0x00, 0xFF) + red = QtGui.qRgb(0xFF, 0x00, 0x00) + + whiteBrush = Qt.QBrush(Qt.QColor("white")) + blueBrush = Qt.QBrush(Qt.QColor(blue)) + redBrush = Qt.QBrush(Qt.QColor(red)) + + self.gui.timePlot.setCanvasBackground(QtGui.QColor("black")) + self.gui.freqPlot.setCanvasBackground(QtGui.QColor("black")) + self.picker.setTrackerPen(Qt.QPen(whiteBrush, 2)) + self.timeZoomer.setTrackerPen(Qt.QPen(whiteBrush, 2)) + self.timeZoomer.setRubberBandPen(Qt.QPen(whiteBrush, 2)) + self.freqZoomer.setTrackerPen(Qt.QPen(whiteBrush, 2)) + self.freqZoomer.setRubberBandPen(Qt.QPen(whiteBrush, 2)) + self.psdcurve.setPen(Qt.QPen(blueBrush, 1)) + self.rcurve.setPen(Qt.QPen(blueBrush, 2)) + self.icurve.setPen(Qt.QPen(redBrush, 2)) + + self.gui.timePlot.replot() + self.gui.freqPlot.replot() + +def setup_options(): + usage="%prog: [options] (input_filename)" + description = "" + + parser = OptionParser(conflict_handler="resolve", usage=usage, description=description) + parser.add_option("-B", "--block-length", type="int", default=8192, + help="Specify the block size [default=%default]") + parser.add_option("-s", "--start", type="int", default=0, + help="Specify where to start in the file [default=%default]") + parser.add_option("-R", "--sample-rate", type="float", default=1.0, + help="Set the sampler rate of the data [default=%default]") + parser.add_option("", "--psd-size", type="int", default=2048, + help="Set the size of the PSD FFT [default=%default]") + parser.add_option("", "--spec-size", type="int", default=2048, + help="Set the size of the spectrogram FFT [default=%default]") + + return parser + +def main(args): + parser = setup_options() + (options, args) = parser.parse_args () + + if(len(args) == 1): + filename = args[0] + else: + filename = None + + app = Qt.QApplication(args) + gplt = gr_plot_qt(app, filename, options) + app.exec_() + +if __name__ == '__main__': + main(sys.argv) + diff --git a/gr-utils/src/python/pyqt_filter.py b/gr-utils/src/python/pyqt_filter.py new file mode 100644 index 000000000..12ad183b0 --- /dev/null +++ b/gr-utils/src/python/pyqt_filter.py @@ -0,0 +1,426 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'pyqt_filter.ui' +# +# Created: Tue Aug 25 11:13:57 2009 +# by: PyQt4 UI code generator 4.4.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(1124, 696) + self.centralwidget = QtGui.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.gridLayout = QtGui.QGridLayout(self.centralwidget) + self.gridLayout.setObjectName("gridLayout") + self.filterFrame = QtGui.QFrame(self.centralwidget) + self.filterFrame.setMinimumSize(QtCore.QSize(300, 0)) + self.filterFrame.setMaximumSize(QtCore.QSize(300, 16777215)) + self.filterFrame.setFrameShape(QtGui.QFrame.StyledPanel) + self.filterFrame.setFrameShadow(QtGui.QFrame.Raised) + self.filterFrame.setObjectName("filterFrame") + self.verticalLayout = QtGui.QVBoxLayout(self.filterFrame) + self.verticalLayout.setObjectName("verticalLayout") + self.filterTypeComboBox = QtGui.QComboBox(self.filterFrame) + self.filterTypeComboBox.setObjectName("filterTypeComboBox") + self.filterTypeComboBox.addItem(QtCore.QString()) + self.filterTypeComboBox.addItem(QtCore.QString()) + self.filterTypeComboBox.addItem(QtCore.QString()) + self.filterTypeComboBox.addItem(QtCore.QString()) + self.filterTypeComboBox.addItem(QtCore.QString()) + self.filterTypeComboBox.addItem(QtCore.QString()) + self.filterTypeComboBox.addItem(QtCore.QString()) + self.verticalLayout.addWidget(self.filterTypeComboBox) + self.filterDesignTypeComboBox = QtGui.QComboBox(self.filterFrame) + self.filterDesignTypeComboBox.setObjectName("filterDesignTypeComboBox") + self.filterDesignTypeComboBox.addItem(QtCore.QString()) + self.filterDesignTypeComboBox.addItem(QtCore.QString()) + self.filterDesignTypeComboBox.addItem(QtCore.QString()) + self.filterDesignTypeComboBox.addItem(QtCore.QString()) + self.filterDesignTypeComboBox.addItem(QtCore.QString()) + self.filterDesignTypeComboBox.addItem(QtCore.QString()) + self.filterDesignTypeComboBox.addItem(QtCore.QString()) + self.verticalLayout.addWidget(self.filterDesignTypeComboBox) + self.globalParamsLayout = QtGui.QFormLayout() + self.globalParamsLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) + self.globalParamsLayout.setObjectName("globalParamsLayout") + self.sampleRateLabel = QtGui.QLabel(self.filterFrame) + self.sampleRateLabel.setMaximumSize(QtCore.QSize(16777215, 30)) + self.sampleRateLabel.setObjectName("sampleRateLabel") + self.globalParamsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.sampleRateLabel) + self.sampleRateEdit = QtGui.QLineEdit(self.filterFrame) + self.sampleRateEdit.setMaximumSize(QtCore.QSize(16777215, 30)) + self.sampleRateEdit.setObjectName("sampleRateEdit") + self.globalParamsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.sampleRateEdit) + self.filterGainLabel = QtGui.QLabel(self.filterFrame) + self.filterGainLabel.setObjectName("filterGainLabel") + self.globalParamsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.filterGainLabel) + self.filterGainEdit = QtGui.QLineEdit(self.filterFrame) + self.filterGainEdit.setObjectName("filterGainEdit") + self.globalParamsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.filterGainEdit) + self.verticalLayout.addLayout(self.globalParamsLayout) + self.filterTypeWidget = QtGui.QStackedWidget(self.filterFrame) + self.filterTypeWidget.setObjectName("filterTypeWidget") + self.firlpfPage = QtGui.QWidget() + self.firlpfPage.setObjectName("firlpfPage") + self.formLayout = QtGui.QFormLayout(self.firlpfPage) + self.formLayout.setObjectName("formLayout") + self.endofLpfPassBandLabel = QtGui.QLabel(self.firlpfPage) + self.endofLpfPassBandLabel.setObjectName("endofLpfPassBandLabel") + self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.endofLpfPassBandLabel) + self.endofLpfPassBandEdit = QtGui.QLineEdit(self.firlpfPage) + self.endofLpfPassBandEdit.setObjectName("endofLpfPassBandEdit") + self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.endofLpfPassBandEdit) + self.startofLpfStopBandLabel = QtGui.QLabel(self.firlpfPage) + self.startofLpfStopBandLabel.setObjectName("startofLpfStopBandLabel") + self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.startofLpfStopBandLabel) + self.startofLpfStopBandEdit = QtGui.QLineEdit(self.firlpfPage) + self.startofLpfStopBandEdit.setObjectName("startofLpfStopBandEdit") + self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.startofLpfStopBandEdit) + self.lpfStopBandAttenLabel = QtGui.QLabel(self.firlpfPage) + self.lpfStopBandAttenLabel.setObjectName("lpfStopBandAttenLabel") + self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.lpfStopBandAttenLabel) + self.lpfStopBandAttenEdit = QtGui.QLineEdit(self.firlpfPage) + self.lpfStopBandAttenEdit.setObjectName("lpfStopBandAttenEdit") + self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.lpfStopBandAttenEdit) + self.lpfPassBandRippleEdit = QtGui.QLineEdit(self.firlpfPage) + self.lpfPassBandRippleEdit.setObjectName("lpfPassBandRippleEdit") + self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.lpfPassBandRippleEdit) + self.lpfPassBandRippleLabel = QtGui.QLabel(self.firlpfPage) + self.lpfPassBandRippleLabel.setObjectName("lpfPassBandRippleLabel") + self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.lpfPassBandRippleLabel) + self.filterTypeWidget.addWidget(self.firlpfPage) + self.firbpfPage = QtGui.QWidget() + self.firbpfPage.setObjectName("firbpfPage") + self.formLayout_2 = QtGui.QFormLayout(self.firbpfPage) + self.formLayout_2.setObjectName("formLayout_2") + self.startofBpfPassBandLabel = QtGui.QLabel(self.firbpfPage) + self.startofBpfPassBandLabel.setObjectName("startofBpfPassBandLabel") + self.formLayout_2.setWidget(0, QtGui.QFormLayout.LabelRole, self.startofBpfPassBandLabel) + self.startofBpfPassBandEdit = QtGui.QLineEdit(self.firbpfPage) + self.startofBpfPassBandEdit.setObjectName("startofBpfPassBandEdit") + self.formLayout_2.setWidget(0, QtGui.QFormLayout.FieldRole, self.startofBpfPassBandEdit) + self.endofBpfPassBandLabel = QtGui.QLabel(self.firbpfPage) + self.endofBpfPassBandLabel.setObjectName("endofBpfPassBandLabel") + self.formLayout_2.setWidget(1, QtGui.QFormLayout.LabelRole, self.endofBpfPassBandLabel) + self.endofBpfPassBandEdit = QtGui.QLineEdit(self.firbpfPage) + self.endofBpfPassBandEdit.setObjectName("endofBpfPassBandEdit") + self.formLayout_2.setWidget(1, QtGui.QFormLayout.FieldRole, self.endofBpfPassBandEdit) + self.bpfStopBandAttenEdit = QtGui.QLineEdit(self.firbpfPage) + self.bpfStopBandAttenEdit.setObjectName("bpfStopBandAttenEdit") + self.formLayout_2.setWidget(3, QtGui.QFormLayout.FieldRole, self.bpfStopBandAttenEdit) + self.bpfStopBandAttenLabel = QtGui.QLabel(self.firbpfPage) + self.bpfStopBandAttenLabel.setObjectName("bpfStopBandAttenLabel") + self.formLayout_2.setWidget(3, QtGui.QFormLayout.LabelRole, self.bpfStopBandAttenLabel) + self.bpfTransitionLabel = QtGui.QLabel(self.firbpfPage) + self.bpfTransitionLabel.setObjectName("bpfTransitionLabel") + self.formLayout_2.setWidget(2, QtGui.QFormLayout.LabelRole, self.bpfTransitionLabel) + self.bpfTransitionEdit = QtGui.QLineEdit(self.firbpfPage) + self.bpfTransitionEdit.setObjectName("bpfTransitionEdit") + self.formLayout_2.setWidget(2, QtGui.QFormLayout.FieldRole, self.bpfTransitionEdit) + self.bpfPassBandRippleEdit = QtGui.QLineEdit(self.firbpfPage) + self.bpfPassBandRippleEdit.setObjectName("bpfPassBandRippleEdit") + self.formLayout_2.setWidget(4, QtGui.QFormLayout.FieldRole, self.bpfPassBandRippleEdit) + self.bpfPassBandRippleLabel = QtGui.QLabel(self.firbpfPage) + self.bpfPassBandRippleLabel.setObjectName("bpfPassBandRippleLabel") + self.formLayout_2.setWidget(4, QtGui.QFormLayout.LabelRole, self.bpfPassBandRippleLabel) + self.filterTypeWidget.addWidget(self.firbpfPage) + self.firbnfPage = QtGui.QWidget() + self.firbnfPage.setObjectName("firbnfPage") + self.formLayout_5 = QtGui.QFormLayout(self.firbnfPage) + self.formLayout_5.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_5.setObjectName("formLayout_5") + self.startofBnfStopBandLabel = QtGui.QLabel(self.firbnfPage) + self.startofBnfStopBandLabel.setObjectName("startofBnfStopBandLabel") + self.formLayout_5.setWidget(0, QtGui.QFormLayout.LabelRole, self.startofBnfStopBandLabel) + self.startofBnfStopBandEdit = QtGui.QLineEdit(self.firbnfPage) + self.startofBnfStopBandEdit.setObjectName("startofBnfStopBandEdit") + self.formLayout_5.setWidget(0, QtGui.QFormLayout.FieldRole, self.startofBnfStopBandEdit) + self.endofBnfStopBandLabel = QtGui.QLabel(self.firbnfPage) + self.endofBnfStopBandLabel.setObjectName("endofBnfStopBandLabel") + self.formLayout_5.setWidget(1, QtGui.QFormLayout.LabelRole, self.endofBnfStopBandLabel) + self.endofBnfStopBandEdit = QtGui.QLineEdit(self.firbnfPage) + self.endofBnfStopBandEdit.setObjectName("endofBnfStopBandEdit") + self.formLayout_5.setWidget(1, QtGui.QFormLayout.FieldRole, self.endofBnfStopBandEdit) + self.bnfTransitionLabel = QtGui.QLabel(self.firbnfPage) + self.bnfTransitionLabel.setObjectName("bnfTransitionLabel") + self.formLayout_5.setWidget(2, QtGui.QFormLayout.LabelRole, self.bnfTransitionLabel) + self.bnfTransitionEdit = QtGui.QLineEdit(self.firbnfPage) + self.bnfTransitionEdit.setObjectName("bnfTransitionEdit") + self.formLayout_5.setWidget(2, QtGui.QFormLayout.FieldRole, self.bnfTransitionEdit) + self.bnfStopBandAttenLabel = QtGui.QLabel(self.firbnfPage) + self.bnfStopBandAttenLabel.setObjectName("bnfStopBandAttenLabel") + self.formLayout_5.setWidget(3, QtGui.QFormLayout.LabelRole, self.bnfStopBandAttenLabel) + self.bnfStopBandAttenEdit = QtGui.QLineEdit(self.firbnfPage) + self.bnfStopBandAttenEdit.setObjectName("bnfStopBandAttenEdit") + self.formLayout_5.setWidget(3, QtGui.QFormLayout.FieldRole, self.bnfStopBandAttenEdit) + self.bnfPassBandRippleLabel = QtGui.QLabel(self.firbnfPage) + self.bnfPassBandRippleLabel.setObjectName("bnfPassBandRippleLabel") + self.formLayout_5.setWidget(4, QtGui.QFormLayout.LabelRole, self.bnfPassBandRippleLabel) + self.bnfPassBandRippleEdit = QtGui.QLineEdit(self.firbnfPage) + self.bnfPassBandRippleEdit.setObjectName("bnfPassBandRippleEdit") + self.formLayout_5.setWidget(4, QtGui.QFormLayout.FieldRole, self.bnfPassBandRippleEdit) + self.filterTypeWidget.addWidget(self.firbnfPage) + self.firhpfPage = QtGui.QWidget() + self.firhpfPage.setObjectName("firhpfPage") + self.formLayout_3 = QtGui.QFormLayout(self.firhpfPage) + self.formLayout_3.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_3.setObjectName("formLayout_3") + self.endofHpfStopBandLabel = QtGui.QLabel(self.firhpfPage) + self.endofHpfStopBandLabel.setObjectName("endofHpfStopBandLabel") + self.formLayout_3.setWidget(0, QtGui.QFormLayout.LabelRole, self.endofHpfStopBandLabel) + self.endofHpfStopBandEdit = QtGui.QLineEdit(self.firhpfPage) + self.endofHpfStopBandEdit.setObjectName("endofHpfStopBandEdit") + self.formLayout_3.setWidget(0, QtGui.QFormLayout.FieldRole, self.endofHpfStopBandEdit) + self.startofHpfPassBandLabel = QtGui.QLabel(self.firhpfPage) + self.startofHpfPassBandLabel.setObjectName("startofHpfPassBandLabel") + self.formLayout_3.setWidget(1, QtGui.QFormLayout.LabelRole, self.startofHpfPassBandLabel) + self.startofHpfPassBandEdit = QtGui.QLineEdit(self.firhpfPage) + self.startofHpfPassBandEdit.setObjectName("startofHpfPassBandEdit") + self.formLayout_3.setWidget(1, QtGui.QFormLayout.FieldRole, self.startofHpfPassBandEdit) + self.hpfStopBandAttenLabel = QtGui.QLabel(self.firhpfPage) + self.hpfStopBandAttenLabel.setObjectName("hpfStopBandAttenLabel") + self.formLayout_3.setWidget(2, QtGui.QFormLayout.LabelRole, self.hpfStopBandAttenLabel) + self.hpfStopBandAttenEdit = QtGui.QLineEdit(self.firhpfPage) + self.hpfStopBandAttenEdit.setObjectName("hpfStopBandAttenEdit") + self.formLayout_3.setWidget(2, QtGui.QFormLayout.FieldRole, self.hpfStopBandAttenEdit) + self.hpfPassBandRippleLabel = QtGui.QLabel(self.firhpfPage) + self.hpfPassBandRippleLabel.setObjectName("hpfPassBandRippleLabel") + self.formLayout_3.setWidget(3, QtGui.QFormLayout.LabelRole, self.hpfPassBandRippleLabel) + self.hpfPassBandRippleEdit = QtGui.QLineEdit(self.firhpfPage) + self.hpfPassBandRippleEdit.setObjectName("hpfPassBandRippleEdit") + self.formLayout_3.setWidget(3, QtGui.QFormLayout.FieldRole, self.hpfPassBandRippleEdit) + self.filterTypeWidget.addWidget(self.firhpfPage) + self.rrcPage = QtGui.QWidget() + self.rrcPage.setObjectName("rrcPage") + self.formLayout_6 = QtGui.QFormLayout(self.rrcPage) + self.formLayout_6.setObjectName("formLayout_6") + self.rrcSymbolRateLabel = QtGui.QLabel(self.rrcPage) + self.rrcSymbolRateLabel.setObjectName("rrcSymbolRateLabel") + self.formLayout_6.setWidget(0, QtGui.QFormLayout.LabelRole, self.rrcSymbolRateLabel) + self.rrcAlphaLabel = QtGui.QLabel(self.rrcPage) + self.rrcAlphaLabel.setObjectName("rrcAlphaLabel") + self.formLayout_6.setWidget(1, QtGui.QFormLayout.LabelRole, self.rrcAlphaLabel) + self.rrcNumTapsLabel = QtGui.QLabel(self.rrcPage) + self.rrcNumTapsLabel.setObjectName("rrcNumTapsLabel") + self.formLayout_6.setWidget(2, QtGui.QFormLayout.LabelRole, self.rrcNumTapsLabel) + self.rrcSymbolRateEdit = QtGui.QLineEdit(self.rrcPage) + self.rrcSymbolRateEdit.setObjectName("rrcSymbolRateEdit") + self.formLayout_6.setWidget(0, QtGui.QFormLayout.FieldRole, self.rrcSymbolRateEdit) + self.rrcAlphaEdit = QtGui.QLineEdit(self.rrcPage) + self.rrcAlphaEdit.setObjectName("rrcAlphaEdit") + self.formLayout_6.setWidget(1, QtGui.QFormLayout.FieldRole, self.rrcAlphaEdit) + self.rrcNumTapsEdit = QtGui.QLineEdit(self.rrcPage) + self.rrcNumTapsEdit.setObjectName("rrcNumTapsEdit") + self.formLayout_6.setWidget(2, QtGui.QFormLayout.FieldRole, self.rrcNumTapsEdit) + self.filterTypeWidget.addWidget(self.rrcPage) + self.gausPage = QtGui.QWidget() + self.gausPage.setObjectName("gausPage") + self.formLayout_7 = QtGui.QFormLayout(self.gausPage) + self.formLayout_7.setObjectName("formLayout_7") + self.gausSymbolRateLabel = QtGui.QLabel(self.gausPage) + self.gausSymbolRateLabel.setObjectName("gausSymbolRateLabel") + self.formLayout_7.setWidget(0, QtGui.QFormLayout.LabelRole, self.gausSymbolRateLabel) + self.gausSymbolRateEdit = QtGui.QLineEdit(self.gausPage) + self.gausSymbolRateEdit.setObjectName("gausSymbolRateEdit") + self.formLayout_7.setWidget(0, QtGui.QFormLayout.FieldRole, self.gausSymbolRateEdit) + self.gausBTLabel = QtGui.QLabel(self.gausPage) + self.gausBTLabel.setObjectName("gausBTLabel") + self.formLayout_7.setWidget(1, QtGui.QFormLayout.LabelRole, self.gausBTLabel) + self.gausBTEdit = QtGui.QLineEdit(self.gausPage) + self.gausBTEdit.setObjectName("gausBTEdit") + self.formLayout_7.setWidget(1, QtGui.QFormLayout.FieldRole, self.gausBTEdit) + self.gausNumTapsLabel = QtGui.QLabel(self.gausPage) + self.gausNumTapsLabel.setObjectName("gausNumTapsLabel") + self.formLayout_7.setWidget(2, QtGui.QFormLayout.LabelRole, self.gausNumTapsLabel) + self.gausNumTapsEdit = QtGui.QLineEdit(self.gausPage) + self.gausNumTapsEdit.setObjectName("gausNumTapsEdit") + self.formLayout_7.setWidget(2, QtGui.QFormLayout.FieldRole, self.gausNumTapsEdit) + self.filterTypeWidget.addWidget(self.gausPage) + self.verticalLayout.addWidget(self.filterTypeWidget) + self.filterPropsBox = QtGui.QGroupBox(self.filterFrame) + self.filterPropsBox.setObjectName("filterPropsBox") + self.formLayout_8 = QtGui.QFormLayout(self.filterPropsBox) + self.formLayout_8.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_8.setObjectName("formLayout_8") + self.nTapsLabel = QtGui.QLabel(self.filterPropsBox) + self.nTapsLabel.setMinimumSize(QtCore.QSize(150, 0)) + self.nTapsLabel.setObjectName("nTapsLabel") + self.formLayout_8.setWidget(1, QtGui.QFormLayout.LabelRole, self.nTapsLabel) + self.nTapsEdit = QtGui.QLabel(self.filterPropsBox) + self.nTapsEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.nTapsEdit.setFrameShape(QtGui.QFrame.Box) + self.nTapsEdit.setFrameShadow(QtGui.QFrame.Raised) + self.nTapsEdit.setObjectName("nTapsEdit") + self.formLayout_8.setWidget(1, QtGui.QFormLayout.FieldRole, self.nTapsEdit) + self.verticalLayout.addWidget(self.filterPropsBox) + self.sysParamsBox = QtGui.QGroupBox(self.filterFrame) + self.sysParamsBox.setObjectName("sysParamsBox") + self.formLayout_4 = QtGui.QFormLayout(self.sysParamsBox) + self.formLayout_4.setObjectName("formLayout_4") + self.nfftEdit = QtGui.QLineEdit(self.sysParamsBox) + self.nfftEdit.setObjectName("nfftEdit") + self.formLayout_4.setWidget(1, QtGui.QFormLayout.FieldRole, self.nfftEdit) + self.nfftLabel = QtGui.QLabel(self.sysParamsBox) + self.nfftLabel.setMinimumSize(QtCore.QSize(150, 0)) + self.nfftLabel.setObjectName("nfftLabel") + self.formLayout_4.setWidget(1, QtGui.QFormLayout.LabelRole, self.nfftLabel) + self.verticalLayout.addWidget(self.sysParamsBox) + self.designButton = QtGui.QPushButton(self.filterFrame) + self.designButton.setMinimumSize(QtCore.QSize(0, 0)) + self.designButton.setMaximumSize(QtCore.QSize(200, 16777215)) + self.designButton.setAutoDefault(True) + self.designButton.setDefault(True) + self.designButton.setObjectName("designButton") + self.verticalLayout.addWidget(self.designButton) + self.gridLayout.addWidget(self.filterFrame, 1, 0, 1, 1) + self.tabGroup = QtGui.QTabWidget(self.centralwidget) + self.tabGroup.setMinimumSize(QtCore.QSize(800, 0)) + self.tabGroup.setObjectName("tabGroup") + self.freqTab = QtGui.QWidget() + self.freqTab.setObjectName("freqTab") + self.horizontalLayout_2 = QtGui.QHBoxLayout(self.freqTab) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.freqPlot = Qwt5.QwtPlot(self.freqTab) + self.freqPlot.setObjectName("freqPlot") + self.horizontalLayout_2.addWidget(self.freqPlot) + self.tabGroup.addTab(self.freqTab, "") + self.timeTab = QtGui.QWidget() + self.timeTab.setObjectName("timeTab") + self.horizontalLayout = QtGui.QHBoxLayout(self.timeTab) + self.horizontalLayout.setObjectName("horizontalLayout") + self.timePlot = Qwt5.QwtPlot(self.timeTab) + self.timePlot.setObjectName("timePlot") + self.horizontalLayout.addWidget(self.timePlot) + self.tabGroup.addTab(self.timeTab, "") + self.phaseTab = QtGui.QWidget() + self.phaseTab.setObjectName("phaseTab") + self.horizontalLayout_3 = QtGui.QHBoxLayout(self.phaseTab) + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.phasePlot = Qwt5.QwtPlot(self.phaseTab) + self.phasePlot.setObjectName("phasePlot") + self.horizontalLayout_3.addWidget(self.phasePlot) + self.tabGroup.addTab(self.phaseTab, "") + self.groupTab = QtGui.QWidget() + self.groupTab.setObjectName("groupTab") + self.horizontalLayout_4 = QtGui.QHBoxLayout(self.groupTab) + self.horizontalLayout_4.setObjectName("horizontalLayout_4") + self.groupPlot = Qwt5.QwtPlot(self.groupTab) + self.groupPlot.setObjectName("groupPlot") + self.horizontalLayout_4.addWidget(self.groupPlot) + self.tabGroup.addTab(self.groupTab, "") + self.gridLayout.addWidget(self.tabGroup, 1, 1, 1, 1) + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtGui.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1124, 24)) + self.menubar.setObjectName("menubar") + self.menu_File = QtGui.QMenu(self.menubar) + self.menu_File.setObjectName("menu_File") + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + MainWindow.setStatusBar(self.statusbar) + self.action_open = QtGui.QAction(MainWindow) + self.action_open.setObjectName("action_open") + self.action_exit = QtGui.QAction(MainWindow) + self.action_exit.setObjectName("action_exit") + self.menu_File.addAction(self.action_exit) + self.menubar.addAction(self.menu_File.menuAction()) + + self.retranslateUi(MainWindow) + self.filterTypeWidget.setCurrentIndex(0) + self.tabGroup.setCurrentIndex(0) + QtCore.QObject.connect(self.action_exit, QtCore.SIGNAL("activated()"), MainWindow.close) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + MainWindow.setTabOrder(self.filterTypeComboBox, self.filterDesignTypeComboBox) + MainWindow.setTabOrder(self.filterDesignTypeComboBox, self.sampleRateEdit) + MainWindow.setTabOrder(self.sampleRateEdit, self.filterGainEdit) + MainWindow.setTabOrder(self.filterGainEdit, self.endofLpfPassBandEdit) + MainWindow.setTabOrder(self.endofLpfPassBandEdit, self.startofLpfStopBandEdit) + MainWindow.setTabOrder(self.startofLpfStopBandEdit, self.lpfStopBandAttenEdit) + MainWindow.setTabOrder(self.lpfStopBandAttenEdit, self.lpfPassBandRippleEdit) + MainWindow.setTabOrder(self.lpfPassBandRippleEdit, self.startofBpfPassBandEdit) + MainWindow.setTabOrder(self.startofBpfPassBandEdit, self.endofBpfPassBandEdit) + MainWindow.setTabOrder(self.endofBpfPassBandEdit, self.bpfTransitionEdit) + MainWindow.setTabOrder(self.bpfTransitionEdit, self.bpfStopBandAttenEdit) + MainWindow.setTabOrder(self.bpfStopBandAttenEdit, self.bpfPassBandRippleEdit) + MainWindow.setTabOrder(self.bpfPassBandRippleEdit, self.startofBnfStopBandEdit) + MainWindow.setTabOrder(self.startofBnfStopBandEdit, self.endofBnfStopBandEdit) + MainWindow.setTabOrder(self.endofBnfStopBandEdit, self.bnfTransitionEdit) + MainWindow.setTabOrder(self.bnfTransitionEdit, self.bnfStopBandAttenEdit) + MainWindow.setTabOrder(self.bnfStopBandAttenEdit, self.bnfPassBandRippleEdit) + MainWindow.setTabOrder(self.bnfPassBandRippleEdit, self.endofHpfStopBandEdit) + MainWindow.setTabOrder(self.endofHpfStopBandEdit, self.startofHpfPassBandEdit) + MainWindow.setTabOrder(self.startofHpfPassBandEdit, self.hpfStopBandAttenEdit) + MainWindow.setTabOrder(self.hpfStopBandAttenEdit, self.hpfPassBandRippleEdit) + MainWindow.setTabOrder(self.hpfPassBandRippleEdit, self.rrcSymbolRateEdit) + MainWindow.setTabOrder(self.rrcSymbolRateEdit, self.rrcAlphaEdit) + MainWindow.setTabOrder(self.rrcAlphaEdit, self.rrcNumTapsEdit) + MainWindow.setTabOrder(self.rrcNumTapsEdit, self.gausSymbolRateEdit) + MainWindow.setTabOrder(self.gausSymbolRateEdit, self.gausBTEdit) + MainWindow.setTabOrder(self.gausBTEdit, self.gausNumTapsEdit) + MainWindow.setTabOrder(self.gausNumTapsEdit, self.nfftEdit) + MainWindow.setTabOrder(self.nfftEdit, self.designButton) + MainWindow.setTabOrder(self.designButton, self.tabGroup) + + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "GNU Radio Filter Design Tool", None, QtGui.QApplication.UnicodeUTF8)) + self.filterTypeComboBox.setItemText(0, QtGui.QApplication.translate("MainWindow", "Low Pass", None, QtGui.QApplication.UnicodeUTF8)) + self.filterTypeComboBox.setItemText(1, QtGui.QApplication.translate("MainWindow", "Band Pass", None, QtGui.QApplication.UnicodeUTF8)) + self.filterTypeComboBox.setItemText(2, QtGui.QApplication.translate("MainWindow", "Complex Band Pass", None, QtGui.QApplication.UnicodeUTF8)) + self.filterTypeComboBox.setItemText(3, QtGui.QApplication.translate("MainWindow", "Band Notch", None, QtGui.QApplication.UnicodeUTF8)) + self.filterTypeComboBox.setItemText(4, QtGui.QApplication.translate("MainWindow", "High Pass", None, QtGui.QApplication.UnicodeUTF8)) + self.filterTypeComboBox.setItemText(5, QtGui.QApplication.translate("MainWindow", "Root Raised Cosine", None, QtGui.QApplication.UnicodeUTF8)) + self.filterTypeComboBox.setItemText(6, QtGui.QApplication.translate("MainWindow", "Gaussian", None, QtGui.QApplication.UnicodeUTF8)) + self.filterDesignTypeComboBox.setItemText(0, QtGui.QApplication.translate("MainWindow", "Hamming Window", None, QtGui.QApplication.UnicodeUTF8)) + self.filterDesignTypeComboBox.setItemText(1, QtGui.QApplication.translate("MainWindow", "Hann Window", None, QtGui.QApplication.UnicodeUTF8)) + self.filterDesignTypeComboBox.setItemText(2, QtGui.QApplication.translate("MainWindow", "Blackman Window", None, QtGui.QApplication.UnicodeUTF8)) + self.filterDesignTypeComboBox.setItemText(3, QtGui.QApplication.translate("MainWindow", "Rectangular Window", None, QtGui.QApplication.UnicodeUTF8)) + self.filterDesignTypeComboBox.setItemText(4, QtGui.QApplication.translate("MainWindow", "Kaiser Window", None, QtGui.QApplication.UnicodeUTF8)) + self.filterDesignTypeComboBox.setItemText(5, QtGui.QApplication.translate("MainWindow", "Blackman-harris Window", None, QtGui.QApplication.UnicodeUTF8)) + self.filterDesignTypeComboBox.setItemText(6, QtGui.QApplication.translate("MainWindow", "Equiripple", None, QtGui.QApplication.UnicodeUTF8)) + self.sampleRateLabel.setText(QtGui.QApplication.translate("MainWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) + self.filterGainLabel.setText(QtGui.QApplication.translate("MainWindow", "Filter Gain", None, QtGui.QApplication.UnicodeUTF8)) + self.endofLpfPassBandLabel.setText(QtGui.QApplication.translate("MainWindow", "End of Pass Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.startofLpfStopBandLabel.setText(QtGui.QApplication.translate("MainWindow", "Start of Stop Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.lpfStopBandAttenLabel.setText(QtGui.QApplication.translate("MainWindow", "Stop Band Attenuation (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.lpfPassBandRippleLabel.setText(QtGui.QApplication.translate("MainWindow", "Pass Band Ripple (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.startofBpfPassBandLabel.setText(QtGui.QApplication.translate("MainWindow", "Start of Pass Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.endofBpfPassBandLabel.setText(QtGui.QApplication.translate("MainWindow", "End of Pass Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.bpfStopBandAttenLabel.setText(QtGui.QApplication.translate("MainWindow", "Stop Band Attenuation (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.bpfTransitionLabel.setText(QtGui.QApplication.translate("MainWindow", "Transition Width (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.bpfPassBandRippleLabel.setText(QtGui.QApplication.translate("MainWindow", "Pass Band Ripple (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.startofBnfStopBandLabel.setText(QtGui.QApplication.translate("MainWindow", "Start of Stop Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.endofBnfStopBandLabel.setText(QtGui.QApplication.translate("MainWindow", "End of Stop Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.bnfTransitionLabel.setText(QtGui.QApplication.translate("MainWindow", "Transition Width (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.bnfStopBandAttenLabel.setText(QtGui.QApplication.translate("MainWindow", "Stop Band Attenuation (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.bnfPassBandRippleLabel.setText(QtGui.QApplication.translate("MainWindow", "Pass Band Ripple (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.endofHpfStopBandLabel.setText(QtGui.QApplication.translate("MainWindow", "End of Stop Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.startofHpfPassBandLabel.setText(QtGui.QApplication.translate("MainWindow", "Start of Pass Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) + self.hpfStopBandAttenLabel.setText(QtGui.QApplication.translate("MainWindow", "Stop Band Attenuation (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.hpfPassBandRippleLabel.setText(QtGui.QApplication.translate("MainWindow", "Pass Band Ripple (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.rrcSymbolRateLabel.setText(QtGui.QApplication.translate("MainWindow", "Symbol Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) + self.rrcAlphaLabel.setText(QtGui.QApplication.translate("MainWindow", "Roll-off Factor", None, QtGui.QApplication.UnicodeUTF8)) + self.rrcNumTapsLabel.setText(QtGui.QApplication.translate("MainWindow", "Number of Taps", None, QtGui.QApplication.UnicodeUTF8)) + self.gausSymbolRateLabel.setText(QtGui.QApplication.translate("MainWindow", "Symbol Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) + self.gausBTLabel.setText(QtGui.QApplication.translate("MainWindow", "Roll-off Factor", None, QtGui.QApplication.UnicodeUTF8)) + self.gausNumTapsLabel.setText(QtGui.QApplication.translate("MainWindow", "Number of Taps", None, QtGui.QApplication.UnicodeUTF8)) + self.filterPropsBox.setTitle(QtGui.QApplication.translate("MainWindow", "Filter Properties", None, QtGui.QApplication.UnicodeUTF8)) + self.nTapsLabel.setText(QtGui.QApplication.translate("MainWindow", "Number of Taps:", None, QtGui.QApplication.UnicodeUTF8)) + self.sysParamsBox.setTitle(QtGui.QApplication.translate("MainWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.nfftLabel.setText(QtGui.QApplication.translate("MainWindow", "Num FFT points", None, QtGui.QApplication.UnicodeUTF8)) + self.designButton.setText(QtGui.QApplication.translate("MainWindow", "Design", None, QtGui.QApplication.UnicodeUTF8)) + self.tabGroup.setTabText(self.tabGroup.indexOf(self.freqTab), QtGui.QApplication.translate("MainWindow", "Frequency Domain", None, QtGui.QApplication.UnicodeUTF8)) + self.tabGroup.setTabText(self.tabGroup.indexOf(self.timeTab), QtGui.QApplication.translate("MainWindow", "Time Domain", None, QtGui.QApplication.UnicodeUTF8)) + self.tabGroup.setTabText(self.tabGroup.indexOf(self.phaseTab), QtGui.QApplication.translate("MainWindow", "Phase", None, QtGui.QApplication.UnicodeUTF8)) + self.tabGroup.setTabText(self.tabGroup.indexOf(self.groupTab), QtGui.QApplication.translate("MainWindow", "Group Delay", None, QtGui.QApplication.UnicodeUTF8)) + self.menu_File.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) + self.action_open.setText(QtGui.QApplication.translate("MainWindow", "&Open", None, QtGui.QApplication.UnicodeUTF8)) + self.action_open.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+O", None, QtGui.QApplication.UnicodeUTF8)) + self.action_exit.setText(QtGui.QApplication.translate("MainWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) + +from PyQt4 import Qwt5 diff --git a/gr-utils/src/python/pyqt_filter.ui b/gr-utils/src/python/pyqt_filter.ui new file mode 100644 index 000000000..9b31112e8 --- /dev/null +++ b/gr-utils/src/python/pyqt_filter.ui @@ -0,0 +1,676 @@ +<ui version="4.0" > + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>1124</width> + <height>696</height> + </rect> + </property> + <property name="windowTitle" > + <string>GNU Radio Filter Design Tool</string> + </property> + <widget class="QWidget" name="centralwidget" > + <layout class="QGridLayout" name="gridLayout" > + <item row="1" column="0" > + <widget class="QFrame" name="filterFrame" > + <property name="minimumSize" > + <size> + <width>300</width> + <height>0</height> + </size> + </property> + <property name="maximumSize" > + <size> + <width>300</width> + <height>16777215</height> + </size> + </property> + <property name="frameShape" > + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout" > + <item> + <widget class="QComboBox" name="filterTypeComboBox" > + <item> + <property name="text" > + <string>Low Pass</string> + </property> + </item> + <item> + <property name="text" > + <string>Band Pass</string> + </property> + </item> + <item> + <property name="text" > + <string>Complex Band Pass</string> + </property> + </item> + <item> + <property name="text" > + <string>Band Notch</string> + </property> + </item> + <item> + <property name="text" > + <string>High Pass</string> + </property> + </item> + <item> + <property name="text" > + <string>Root Raised Cosine</string> + </property> + </item> + <item> + <property name="text" > + <string>Gaussian</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QComboBox" name="filterDesignTypeComboBox" > + <item> + <property name="text" > + <string>Hamming Window</string> + </property> + </item> + <item> + <property name="text" > + <string>Hann Window</string> + </property> + </item> + <item> + <property name="text" > + <string>Blackman Window</string> + </property> + </item> + <item> + <property name="text" > + <string>Rectangular Window</string> + </property> + </item> + <item> + <property name="text" > + <string>Kaiser Window</string> + </property> + </item> + <item> + <property name="text" > + <string>Blackman-harris Window</string> + </property> + </item> + <item> + <property name="text" > + <string>Equiripple</string> + </property> + </item> + </widget> + </item> + <item> + <layout class="QFormLayout" name="globalParamsLayout" > + <property name="fieldGrowthPolicy" > + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> + <item row="0" column="0" > + <widget class="QLabel" name="sampleRateLabel" > + <property name="maximumSize" > + <size> + <width>16777215</width> + <height>30</height> + </size> + </property> + <property name="text" > + <string>Sample Rate (sps)</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="sampleRateEdit" > + <property name="maximumSize" > + <size> + <width>16777215</width> + <height>30</height> + </size> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="filterGainLabel" > + <property name="text" > + <string>Filter Gain</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="filterGainEdit" /> + </item> + </layout> + </item> + <item> + <widget class="QStackedWidget" name="filterTypeWidget" > + <property name="currentIndex" > + <number>0</number> + </property> + <widget class="QWidget" name="firlpfPage" > + <layout class="QFormLayout" name="formLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="endofLpfPassBandLabel" > + <property name="text" > + <string>End of Pass Band (Hz)</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="endofLpfPassBandEdit" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="startofLpfStopBandLabel" > + <property name="text" > + <string>Start of Stop Band (Hz)</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="startofLpfStopBandEdit" /> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="lpfStopBandAttenLabel" > + <property name="text" > + <string>Stop Band Attenuation (dB)</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="lpfStopBandAttenEdit" /> + </item> + <item row="3" column="1" > + <widget class="QLineEdit" name="lpfPassBandRippleEdit" /> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="lpfPassBandRippleLabel" > + <property name="text" > + <string>Pass Band Ripple (dB)</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="firbpfPage" > + <layout class="QFormLayout" name="formLayout_2" > + <item row="0" column="0" > + <widget class="QLabel" name="startofBpfPassBandLabel" > + <property name="text" > + <string>Start of Pass Band (Hz)</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="startofBpfPassBandEdit" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="endofBpfPassBandLabel" > + <property name="text" > + <string>End of Pass Band (Hz)</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="endofBpfPassBandEdit" /> + </item> + <item row="3" column="1" > + <widget class="QLineEdit" name="bpfStopBandAttenEdit" /> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="bpfStopBandAttenLabel" > + <property name="text" > + <string>Stop Band Attenuation (dB)</string> + </property> + </widget> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="bpfTransitionLabel" > + <property name="text" > + <string>Transition Width (Hz)</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="bpfTransitionEdit" /> + </item> + <item row="4" column="1" > + <widget class="QLineEdit" name="bpfPassBandRippleEdit" /> + </item> + <item row="4" column="0" > + <widget class="QLabel" name="bpfPassBandRippleLabel" > + <property name="text" > + <string>Pass Band Ripple (dB)</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="firbnfPage" > + <layout class="QFormLayout" name="formLayout_5" > + <property name="fieldGrowthPolicy" > + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> + <item row="0" column="0" > + <widget class="QLabel" name="startofBnfStopBandLabel" > + <property name="text" > + <string>Start of Stop Band (Hz)</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="startofBnfStopBandEdit" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="endofBnfStopBandLabel" > + <property name="text" > + <string>End of Stop Band (Hz)</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="endofBnfStopBandEdit" /> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="bnfTransitionLabel" > + <property name="text" > + <string>Transition Width (Hz)</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="bnfTransitionEdit" /> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="bnfStopBandAttenLabel" > + <property name="text" > + <string>Stop Band Attenuation (dB)</string> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QLineEdit" name="bnfStopBandAttenEdit" /> + </item> + <item row="4" column="0" > + <widget class="QLabel" name="bnfPassBandRippleLabel" > + <property name="text" > + <string>Pass Band Ripple (dB)</string> + </property> + </widget> + </item> + <item row="4" column="1" > + <widget class="QLineEdit" name="bnfPassBandRippleEdit" /> + </item> + </layout> + </widget> + <widget class="QWidget" name="firhpfPage" > + <layout class="QFormLayout" name="formLayout_3" > + <property name="fieldGrowthPolicy" > + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> + <item row="0" column="0" > + <widget class="QLabel" name="endofHpfStopBandLabel" > + <property name="text" > + <string>End of Stop Band (Hz)</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="endofHpfStopBandEdit" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="startofHpfPassBandLabel" > + <property name="text" > + <string>Start of Pass Band (Hz)</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="startofHpfPassBandEdit" /> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="hpfStopBandAttenLabel" > + <property name="text" > + <string>Stop Band Attenuation (dB)</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="hpfStopBandAttenEdit" /> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="hpfPassBandRippleLabel" > + <property name="text" > + <string>Pass Band Ripple (dB)</string> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QLineEdit" name="hpfPassBandRippleEdit" /> + </item> + </layout> + </widget> + <widget class="QWidget" name="rrcPage" > + <layout class="QFormLayout" name="formLayout_6" > + <item row="0" column="0" > + <widget class="QLabel" name="rrcSymbolRateLabel" > + <property name="text" > + <string>Symbol Rate (sps)</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="rrcAlphaLabel" > + <property name="text" > + <string>Roll-off Factor</string> + </property> + </widget> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="rrcNumTapsLabel" > + <property name="text" > + <string>Number of Taps</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="rrcSymbolRateEdit" /> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="rrcAlphaEdit" /> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="rrcNumTapsEdit" /> + </item> + </layout> + </widget> + <widget class="QWidget" name="gausPage" > + <layout class="QFormLayout" name="formLayout_7" > + <item row="0" column="0" > + <widget class="QLabel" name="gausSymbolRateLabel" > + <property name="text" > + <string>Symbol Rate (sps)</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="gausSymbolRateEdit" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="gausBTLabel" > + <property name="text" > + <string>Roll-off Factor</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="gausBTEdit" /> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="gausNumTapsLabel" > + <property name="text" > + <string>Number of Taps</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="gausNumTapsEdit" /> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="QGroupBox" name="filterPropsBox" > + <property name="title" > + <string>Filter Properties</string> + </property> + <layout class="QFormLayout" name="formLayout_8" > + <property name="fieldGrowthPolicy" > + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> + <item row="1" column="0" > + <widget class="QLabel" name="nTapsLabel" > + <property name="minimumSize" > + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text" > + <string>Number of Taps:</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLabel" name="nTapsEdit" > + <property name="maximumSize" > + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + <property name="frameShape" > + <enum>QFrame::Box</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <property name="text" > + <string/> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="sysParamsBox" > + <property name="title" > + <string>System Parameters</string> + </property> + <layout class="QFormLayout" name="formLayout_4" > + <item row="1" column="1" > + <widget class="QLineEdit" name="nfftEdit" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="nfftLabel" > + <property name="minimumSize" > + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text" > + <string>Num FFT points</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QPushButton" name="designButton" > + <property name="minimumSize" > + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize" > + <size> + <width>200</width> + <height>16777215</height> + </size> + </property> + <property name="text" > + <string>Design</string> + </property> + <property name="autoDefault" > + <bool>true</bool> + </property> + <property name="default" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1" > + <widget class="QTabWidget" name="tabGroup" > + <property name="minimumSize" > + <size> + <width>800</width> + <height>0</height> + </size> + </property> + <property name="currentIndex" > + <number>0</number> + </property> + <widget class="QWidget" name="freqTab" > + <attribute name="title" > + <string>Frequency Domain</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_2" > + <item> + <widget class="QwtPlot" name="freqPlot" /> + </item> + </layout> + </widget> + <widget class="QWidget" name="timeTab" > + <attribute name="title" > + <string>Time Domain</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QwtPlot" name="timePlot" /> + </item> + </layout> + </widget> + <widget class="QWidget" name="phaseTab" > + <attribute name="title" > + <string>Phase</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_3" > + <item> + <widget class="QwtPlot" name="phasePlot" /> + </item> + </layout> + </widget> + <widget class="QWidget" name="groupTab" > + <attribute name="title" > + <string>Group Delay</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_4" > + <item> + <widget class="QwtPlot" name="groupPlot" /> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>1124</width> + <height>24</height> + </rect> + </property> + <widget class="QMenu" name="menu_File" > + <property name="title" > + <string>&File</string> + </property> + <addaction name="action_exit" /> + </widget> + <addaction name="menu_File" /> + </widget> + <widget class="QStatusBar" name="statusbar" /> + <action name="action_open" > + <property name="text" > + <string>&Open</string> + </property> + <property name="shortcut" > + <string>Ctrl+O</string> + </property> + </action> + <action name="action_exit" > + <property name="text" > + <string>E&xit</string> + </property> + </action> + </widget> + <customwidgets> + <customwidget> + <class>QwtPlot</class> + <extends>QFrame</extends> + <header>qwt_plot.h</header> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>filterTypeComboBox</tabstop> + <tabstop>filterDesignTypeComboBox</tabstop> + <tabstop>sampleRateEdit</tabstop> + <tabstop>filterGainEdit</tabstop> + <tabstop>endofLpfPassBandEdit</tabstop> + <tabstop>startofLpfStopBandEdit</tabstop> + <tabstop>lpfStopBandAttenEdit</tabstop> + <tabstop>lpfPassBandRippleEdit</tabstop> + <tabstop>startofBpfPassBandEdit</tabstop> + <tabstop>endofBpfPassBandEdit</tabstop> + <tabstop>bpfTransitionEdit</tabstop> + <tabstop>bpfStopBandAttenEdit</tabstop> + <tabstop>bpfPassBandRippleEdit</tabstop> + <tabstop>startofBnfStopBandEdit</tabstop> + <tabstop>endofBnfStopBandEdit</tabstop> + <tabstop>bnfTransitionEdit</tabstop> + <tabstop>bnfStopBandAttenEdit</tabstop> + <tabstop>bnfPassBandRippleEdit</tabstop> + <tabstop>endofHpfStopBandEdit</tabstop> + <tabstop>startofHpfPassBandEdit</tabstop> + <tabstop>hpfStopBandAttenEdit</tabstop> + <tabstop>hpfPassBandRippleEdit</tabstop> + <tabstop>rrcSymbolRateEdit</tabstop> + <tabstop>rrcAlphaEdit</tabstop> + <tabstop>rrcNumTapsEdit</tabstop> + <tabstop>gausSymbolRateEdit</tabstop> + <tabstop>gausBTEdit</tabstop> + <tabstop>gausNumTapsEdit</tabstop> + <tabstop>nfftEdit</tabstop> + <tabstop>designButton</tabstop> + <tabstop>tabGroup</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>action_exit</sender> + <signal>activated()</signal> + <receiver>MainWindow</receiver> + <slot>close()</slot> + <hints> + <hint type="sourcelabel" > + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel" > + <x>399</x> + <y>347</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/gr-utils/src/python/pyqt_plot.py b/gr-utils/src/python/pyqt_plot.py new file mode 100644 index 000000000..74c43c3eb --- /dev/null +++ b/gr-utils/src/python/pyqt_plot.py @@ -0,0 +1,206 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'pyqt_plot.ui' +# +# Created: Tue Aug 25 18:18:14 2009 +# by: PyQt4 UI code generator 4.4.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(927, 696) + self.centralwidget = QtGui.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.gridLayout = QtGui.QGridLayout(self.centralwidget) + self.gridLayout.setObjectName("gridLayout") + self.plotHBar = QtGui.QScrollBar(self.centralwidget) + self.plotHBar.setOrientation(QtCore.Qt.Horizontal) + self.plotHBar.setObjectName("plotHBar") + self.gridLayout.addWidget(self.plotHBar, 2, 0, 1, 2) + self.tabGroup = QtGui.QTabWidget(self.centralwidget) + self.tabGroup.setObjectName("tabGroup") + self.timeTab = QtGui.QWidget() + self.timeTab.setObjectName("timeTab") + self.horizontalLayout = QtGui.QHBoxLayout(self.timeTab) + self.horizontalLayout.setObjectName("horizontalLayout") + self.timePlot = Qwt5.QwtPlot(self.timeTab) + self.timePlot.setObjectName("timePlot") + self.horizontalLayout.addWidget(self.timePlot) + self.tabGroup.addTab(self.timeTab, "") + self.freqTab = QtGui.QWidget() + self.freqTab.setObjectName("freqTab") + self.horizontalLayout_2 = QtGui.QHBoxLayout(self.freqTab) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.fftPropBox = QtGui.QGroupBox(self.freqTab) + self.fftPropBox.setMinimumSize(QtCore.QSize(160, 0)) + self.fftPropBox.setObjectName("fftPropBox") + self.formLayout_4 = QtGui.QFormLayout(self.fftPropBox) + self.formLayout_4.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_4.setObjectName("formLayout_4") + self.psdFFTComboBox = QtGui.QComboBox(self.fftPropBox) + self.psdFFTComboBox.setMinimumSize(QtCore.QSize(96, 0)) + self.psdFFTComboBox.setMaximumSize(QtCore.QSize(96, 16777215)) + self.psdFFTComboBox.setObjectName("psdFFTComboBox") + self.formLayout_4.setWidget(0, QtGui.QFormLayout.FieldRole, self.psdFFTComboBox) + self.psdFFTSizeLabel = QtGui.QLabel(self.fftPropBox) + self.psdFFTSizeLabel.setObjectName("psdFFTSizeLabel") + self.formLayout_4.setWidget(0, QtGui.QFormLayout.LabelRole, self.psdFFTSizeLabel) + self.horizontalLayout_2.addWidget(self.fftPropBox) + self.freqPlot = Qwt5.QwtPlot(self.freqTab) + self.freqPlot.setObjectName("freqPlot") + self.horizontalLayout_2.addWidget(self.freqPlot) + self.tabGroup.addTab(self.freqTab, "") + self.specTab = QtGui.QWidget() + self.specTab.setObjectName("specTab") + self.horizontalLayout_3 = QtGui.QHBoxLayout(self.specTab) + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.groupBox = QtGui.QGroupBox(self.specTab) + self.groupBox.setObjectName("groupBox") + self.formLayout_3 = QtGui.QFormLayout(self.groupBox) + self.formLayout_3.setObjectName("formLayout_3") + self.specFFTLabel = QtGui.QLabel(self.groupBox) + self.specFFTLabel.setObjectName("specFFTLabel") + self.formLayout_3.setWidget(1, QtGui.QFormLayout.LabelRole, self.specFFTLabel) + self.specFFTComboBox = QtGui.QComboBox(self.groupBox) + self.specFFTComboBox.setMinimumSize(QtCore.QSize(96, 0)) + self.specFFTComboBox.setMaximumSize(QtCore.QSize(96, 16777215)) + self.specFFTComboBox.setObjectName("specFFTComboBox") + self.formLayout_3.setWidget(1, QtGui.QFormLayout.FieldRole, self.specFFTComboBox) + self.horizontalLayout_3.addWidget(self.groupBox) + self.specPlot = Qwt5.QwtPlot(self.specTab) + self.specPlot.setObjectName("specPlot") + self.horizontalLayout_3.addWidget(self.specPlot) + self.tabGroup.addTab(self.specTab, "") + self.gridLayout.addWidget(self.tabGroup, 1, 0, 1, 1) + self.filePosBox = QtGui.QGroupBox(self.centralwidget) + self.filePosBox.setMinimumSize(QtCore.QSize(0, 120)) + self.filePosBox.setObjectName("filePosBox") + self.formLayoutWidget_2 = QtGui.QWidget(self.filePosBox) + self.formLayoutWidget_2.setGeometry(QtCore.QRect(0, 20, 160, 92)) + self.formLayoutWidget_2.setObjectName("formLayoutWidget_2") + self.filePosLayout = QtGui.QFormLayout(self.formLayoutWidget_2) + self.filePosLayout.setObjectName("filePosLayout") + self.filePosStartLabel = QtGui.QLabel(self.formLayoutWidget_2) + self.filePosStartLabel.setObjectName("filePosStartLabel") + self.filePosLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.filePosStartLabel) + self.filePosStartLineEdit = QtGui.QLineEdit(self.formLayoutWidget_2) + self.filePosStartLineEdit.setObjectName("filePosStartLineEdit") + self.filePosLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.filePosStartLineEdit) + self.filePosStopLabel = QtGui.QLabel(self.formLayoutWidget_2) + self.filePosStopLabel.setObjectName("filePosStopLabel") + self.filePosLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.filePosStopLabel) + self.filePosStopLineEdit = QtGui.QLineEdit(self.formLayoutWidget_2) + self.filePosStopLineEdit.setObjectName("filePosStopLineEdit") + self.filePosLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.filePosStopLineEdit) + self.filePosLengthLabel = QtGui.QLabel(self.formLayoutWidget_2) + self.filePosLengthLabel.setObjectName("filePosLengthLabel") + self.filePosLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.filePosLengthLabel) + self.filePosLengthLineEdit = QtGui.QLineEdit(self.formLayoutWidget_2) + self.filePosLengthLineEdit.setObjectName("filePosLengthLineEdit") + self.filePosLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.filePosLengthLineEdit) + self.formLayoutWidget_4 = QtGui.QWidget(self.filePosBox) + self.formLayoutWidget_4.setGeometry(QtCore.QRect(180, 20, 231, 92)) + self.formLayoutWidget_4.setObjectName("formLayoutWidget_4") + self.fileTimeLayout = QtGui.QFormLayout(self.formLayoutWidget_4) + self.fileTimeLayout.setObjectName("fileTimeLayout") + self.fileTimeStartLabel = QtGui.QLabel(self.formLayoutWidget_4) + self.fileTimeStartLabel.setObjectName("fileTimeStartLabel") + self.fileTimeLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.fileTimeStartLabel) + self.fileTimeStartLineEdit = QtGui.QLineEdit(self.formLayoutWidget_4) + self.fileTimeStartLineEdit.setObjectName("fileTimeStartLineEdit") + self.fileTimeLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.fileTimeStartLineEdit) + self.fileTimeStopLabel = QtGui.QLabel(self.formLayoutWidget_4) + self.fileTimeStopLabel.setObjectName("fileTimeStopLabel") + self.fileTimeLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.fileTimeStopLabel) + self.fileTimeStopLineEdit = QtGui.QLineEdit(self.formLayoutWidget_4) + self.fileTimeStopLineEdit.setObjectName("fileTimeStopLineEdit") + self.fileTimeLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.fileTimeStopLineEdit) + self.fileTimeLengthLabel = QtGui.QLabel(self.formLayoutWidget_4) + self.fileTimeLengthLabel.setObjectName("fileTimeLengthLabel") + self.fileTimeLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.fileTimeLengthLabel) + self.fileTimeLengthLineEdit = QtGui.QLineEdit(self.formLayoutWidget_4) + self.fileTimeLengthLineEdit.setObjectName("fileTimeLengthLineEdit") + self.fileTimeLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.fileTimeLengthLineEdit) + self.sysGroupBox = QtGui.QGroupBox(self.filePosBox) + self.sysGroupBox.setGeometry(QtCore.QRect(530, 0, 200, 120)) + self.sysGroupBox.setMinimumSize(QtCore.QSize(200, 0)) + self.sysGroupBox.setObjectName("sysGroupBox") + self.formLayoutWidget_3 = QtGui.QWidget(self.sysGroupBox) + self.formLayoutWidget_3.setGeometry(QtCore.QRect(0, 20, 191, 91)) + self.formLayoutWidget_3.setObjectName("formLayoutWidget_3") + self.formLayout_2 = QtGui.QFormLayout(self.formLayoutWidget_3) + self.formLayout_2.setObjectName("formLayout_2") + self.sampleRateLabel = QtGui.QLabel(self.formLayoutWidget_3) + self.sampleRateLabel.setObjectName("sampleRateLabel") + self.formLayout_2.setWidget(0, QtGui.QFormLayout.LabelRole, self.sampleRateLabel) + self.sampleRateLineEdit = QtGui.QLineEdit(self.formLayoutWidget_3) + self.sampleRateLineEdit.setMinimumSize(QtCore.QSize(0, 0)) + self.sampleRateLineEdit.setObjectName("sampleRateLineEdit") + self.formLayout_2.setWidget(0, QtGui.QFormLayout.FieldRole, self.sampleRateLineEdit) + self.displayGroupBox = QtGui.QGroupBox(self.filePosBox) + self.displayGroupBox.setGeometry(QtCore.QRect(730, 0, 170, 120)) + self.displayGroupBox.setMinimumSize(QtCore.QSize(170, 0)) + self.displayGroupBox.setObjectName("displayGroupBox") + self.verticalLayoutWidget = QtGui.QWidget(self.displayGroupBox) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 20, 160, 91)) + self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") + self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout.setObjectName("verticalLayout") + self.colorComboBox = QtGui.QComboBox(self.verticalLayoutWidget) + self.colorComboBox.setObjectName("colorComboBox") + self.verticalLayout.addWidget(self.colorComboBox) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem) + self.gridLayout.addWidget(self.filePosBox, 3, 0, 1, 1) + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtGui.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 927, 24)) + self.menubar.setObjectName("menubar") + self.menu_File = QtGui.QMenu(self.menubar) + self.menu_File.setObjectName("menu_File") + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtGui.QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + MainWindow.setStatusBar(self.statusbar) + self.action_open = QtGui.QAction(MainWindow) + self.action_open.setObjectName("action_open") + self.action_exit = QtGui.QAction(MainWindow) + self.action_exit.setObjectName("action_exit") + self.menu_File.addAction(self.action_open) + self.menu_File.addAction(self.action_exit) + self.menubar.addAction(self.menu_File.menuAction()) + + self.retranslateUi(MainWindow) + self.tabGroup.setCurrentIndex(0) + QtCore.QObject.connect(self.action_exit, QtCore.SIGNAL("activated()"), MainWindow.close) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) + self.tabGroup.setTabText(self.tabGroup.indexOf(self.timeTab), QtGui.QApplication.translate("MainWindow", "Time Domain", None, QtGui.QApplication.UnicodeUTF8)) + self.fftPropBox.setTitle(QtGui.QApplication.translate("MainWindow", "FFT Properties", None, QtGui.QApplication.UnicodeUTF8)) + self.psdFFTSizeLabel.setText(QtGui.QApplication.translate("MainWindow", "FFT Size", None, QtGui.QApplication.UnicodeUTF8)) + self.tabGroup.setTabText(self.tabGroup.indexOf(self.freqTab), QtGui.QApplication.translate("MainWindow", "Frequency Domain", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Spectrogram Properties", None, QtGui.QApplication.UnicodeUTF8)) + self.specFFTLabel.setText(QtGui.QApplication.translate("MainWindow", "FFT Size", None, QtGui.QApplication.UnicodeUTF8)) + self.tabGroup.setTabText(self.tabGroup.indexOf(self.specTab), QtGui.QApplication.translate("MainWindow", "Spectrogram", None, QtGui.QApplication.UnicodeUTF8)) + self.filePosBox.setTitle(QtGui.QApplication.translate("MainWindow", "File Position", None, QtGui.QApplication.UnicodeUTF8)) + self.filePosStartLabel.setText(QtGui.QApplication.translate("MainWindow", "Start", None, QtGui.QApplication.UnicodeUTF8)) + self.filePosStopLabel.setText(QtGui.QApplication.translate("MainWindow", "Stop", None, QtGui.QApplication.UnicodeUTF8)) + self.filePosLengthLabel.setText(QtGui.QApplication.translate("MainWindow", "Length", None, QtGui.QApplication.UnicodeUTF8)) + self.fileTimeStartLabel.setText(QtGui.QApplication.translate("MainWindow", "time start (sec)", None, QtGui.QApplication.UnicodeUTF8)) + self.fileTimeStopLabel.setText(QtGui.QApplication.translate("MainWindow", "time stop (sec)", None, QtGui.QApplication.UnicodeUTF8)) + self.fileTimeLengthLabel.setText(QtGui.QApplication.translate("MainWindow", "time length (sec)", None, QtGui.QApplication.UnicodeUTF8)) + self.sysGroupBox.setTitle(QtGui.QApplication.translate("MainWindow", "System Properties", None, QtGui.QApplication.UnicodeUTF8)) + self.sampleRateLabel.setText(QtGui.QApplication.translate("MainWindow", "Sample Rate", None, QtGui.QApplication.UnicodeUTF8)) + self.displayGroupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Display Properties", None, QtGui.QApplication.UnicodeUTF8)) + self.menu_File.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) + self.action_open.setText(QtGui.QApplication.translate("MainWindow", "&Open", None, QtGui.QApplication.UnicodeUTF8)) + self.action_open.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+O", None, QtGui.QApplication.UnicodeUTF8)) + self.action_exit.setText(QtGui.QApplication.translate("MainWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) + +from PyQt4 import Qwt5 diff --git a/gr-utils/src/python/pyqt_plot.ui b/gr-utils/src/python/pyqt_plot.ui new file mode 100644 index 000000000..19a62adf5 --- /dev/null +++ b/gr-utils/src/python/pyqt_plot.ui @@ -0,0 +1,389 @@ +<ui version="4.0" > + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>927</width> + <height>696</height> + </rect> + </property> + <property name="windowTitle" > + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget" > + <layout class="QGridLayout" name="gridLayout" > + <item row="2" column="0" colspan="2" > + <widget class="QScrollBar" name="plotHBar" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QTabWidget" name="tabGroup" > + <property name="currentIndex" > + <number>0</number> + </property> + <widget class="QWidget" name="timeTab" > + <attribute name="title" > + <string>Time Domain</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QwtPlot" name="timePlot" /> + </item> + </layout> + </widget> + <widget class="QWidget" name="freqTab" > + <attribute name="title" > + <string>Frequency Domain</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_2" > + <item> + <widget class="QGroupBox" name="fftPropBox" > + <property name="minimumSize" > + <size> + <width>160</width> + <height>0</height> + </size> + </property> + <property name="title" > + <string>FFT Properties</string> + </property> + <layout class="QFormLayout" name="formLayout_4" > + <property name="fieldGrowthPolicy" > + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> + <item row="0" column="1" > + <widget class="QComboBox" name="psdFFTComboBox" > + <property name="minimumSize" > + <size> + <width>96</width> + <height>0</height> + </size> + </property> + <property name="maximumSize" > + <size> + <width>96</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="psdFFTSizeLabel" > + <property name="text" > + <string>FFT Size</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QwtPlot" name="freqPlot" /> + </item> + </layout> + </widget> + <widget class="QWidget" name="specTab" > + <attribute name="title" > + <string>Spectrogram</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_3" > + <item> + <widget class="QGroupBox" name="groupBox" > + <property name="title" > + <string>Spectrogram Properties</string> + </property> + <layout class="QFormLayout" name="formLayout_3" > + <item row="1" column="0" > + <widget class="QLabel" name="specFFTLabel" > + <property name="text" > + <string>FFT Size</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QComboBox" name="specFFTComboBox" > + <property name="minimumSize" > + <size> + <width>96</width> + <height>0</height> + </size> + </property> + <property name="maximumSize" > + <size> + <width>96</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QwtPlot" name="specPlot" /> + </item> + </layout> + <zorder>specPlot</zorder> + <zorder>groupBox</zorder> + </widget> + </widget> + </item> + <item row="3" column="0" > + <widget class="QGroupBox" name="filePosBox" > + <property name="minimumSize" > + <size> + <width>0</width> + <height>120</height> + </size> + </property> + <property name="title" > + <string>File Position</string> + </property> + <widget class="QWidget" name="formLayoutWidget_2" > + <property name="geometry" > + <rect> + <x>0</x> + <y>20</y> + <width>160</width> + <height>92</height> + </rect> + </property> + <layout class="QFormLayout" name="filePosLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="filePosStartLabel" > + <property name="text" > + <string>Start</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="filePosStartLineEdit" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="filePosStopLabel" > + <property name="text" > + <string>Stop</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="filePosStopLineEdit" /> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="filePosLengthLabel" > + <property name="text" > + <string>Length</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="filePosLengthLineEdit" /> + </item> + </layout> + </widget> + <widget class="QWidget" name="formLayoutWidget_4" > + <property name="geometry" > + <rect> + <x>180</x> + <y>20</y> + <width>231</width> + <height>92</height> + </rect> + </property> + <layout class="QFormLayout" name="fileTimeLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="fileTimeStartLabel" > + <property name="text" > + <string>time start (sec)</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="fileTimeStartLineEdit" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="fileTimeStopLabel" > + <property name="text" > + <string>time stop (sec)</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="fileTimeStopLineEdit" /> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="fileTimeLengthLabel" > + <property name="text" > + <string>time length (sec)</string> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QLineEdit" name="fileTimeLengthLineEdit" /> + </item> + </layout> + </widget> + <widget class="QGroupBox" name="sysGroupBox" > + <property name="geometry" > + <rect> + <x>530</x> + <y>0</y> + <width>200</width> + <height>120</height> + </rect> + </property> + <property name="minimumSize" > + <size> + <width>200</width> + <height>0</height> + </size> + </property> + <property name="title" > + <string>System Properties</string> + </property> + <widget class="QWidget" name="formLayoutWidget_3" > + <property name="geometry" > + <rect> + <x>0</x> + <y>20</y> + <width>191</width> + <height>91</height> + </rect> + </property> + <layout class="QFormLayout" name="formLayout_2" > + <item row="0" column="0" > + <widget class="QLabel" name="sampleRateLabel" > + <property name="text" > + <string>Sample Rate</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="sampleRateLineEdit" > + <property name="minimumSize" > + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + <widget class="QGroupBox" name="displayGroupBox" > + <property name="geometry" > + <rect> + <x>730</x> + <y>0</y> + <width>170</width> + <height>120</height> + </rect> + </property> + <property name="minimumSize" > + <size> + <width>170</width> + <height>0</height> + </size> + </property> + <property name="title" > + <string>Display Properties</string> + </property> + <widget class="QWidget" name="verticalLayoutWidget" > + <property name="geometry" > + <rect> + <x>0</x> + <y>20</y> + <width>160</width> + <height>91</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout" > + <item> + <widget class="QComboBox" name="colorComboBox" /> + </item> + <item> + <spacer name="verticalSpacer" > + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </widget> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>927</width> + <height>24</height> + </rect> + </property> + <widget class="QMenu" name="menu_File" > + <property name="title" > + <string>&File</string> + </property> + <addaction name="action_open" /> + <addaction name="action_exit" /> + </widget> + <addaction name="menu_File" /> + </widget> + <widget class="QStatusBar" name="statusbar" /> + <action name="action_open" > + <property name="text" > + <string>&Open</string> + </property> + <property name="shortcut" > + <string>Ctrl+O</string> + </property> + </action> + <action name="action_exit" > + <property name="text" > + <string>E&xit</string> + </property> + </action> + </widget> + <customwidgets> + <customwidget> + <class>QwtPlot</class> + <extends>QFrame</extends> + <header>qwt_plot.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections> + <connection> + <sender>action_exit</sender> + <signal>activated()</signal> + <receiver>MainWindow</receiver> + <slot>close()</slot> + <hints> + <hint type="sourcelabel" > + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel" > + <x>399</x> + <y>347</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/gr-vrt/src/vrt_quadradio_source_32fc.cc b/gr-vrt/src/vrt_quadradio_source_32fc.cc index 0321062aa..0aac86991 100644 --- a/gr-vrt/src/vrt_quadradio_source_32fc.cc +++ b/gr-vrt/src/vrt_quadradio_source_32fc.cc @@ -86,9 +86,15 @@ vrt_quadradio_source_32fc::set_center_freq(double target_freq) } bool -vrt_quadradio_source_32fc::set_band_select(const std::string &band) +vrt_quadradio_source_32fc::set_band_select(int band) { - return d_qr->set_band_select(band); + return d_qr->set_band_select(static_cast<vrt_band_sel_t>(band)); +} + +int +vrt_quadradio_source_32fc::get_band_select(void) +{ + return static_cast<int>(d_qr->get_band_select()); } //void @@ -210,3 +216,7 @@ vrt_quadradio_source_32fc::set_beamforming(std::vector<gr_complex> gains){ return d_qr->set_beamforming(gains_ints); } +bool +vrt_quadradio_source_32fc::set_cal_enb(bool enb){ + return d_qr->set_cal_enb(enb); +} diff --git a/gr-vrt/src/vrt_quadradio_source_32fc.h b/gr-vrt/src/vrt_quadradio_source_32fc.h index 6ad63f7be..6193efa10 100644 --- a/gr-vrt/src/vrt_quadradio_source_32fc.h +++ b/gr-vrt/src/vrt_quadradio_source_32fc.h @@ -68,9 +68,9 @@ public: /*! * \brief Set the band select dboard bits. - * \param band "A", "B", "C", "D" */ - bool set_band_select(const std::string &band); + bool set_band_select(int band); + int get_band_select(void); /*! * \brief Turn the 10 dB attenuation on/off. @@ -109,6 +109,7 @@ public: bool set_lo_freq(double freq); bool set_cal_freq(double freq); bool set_beamforming(std::vector<gr_complex> gains); + bool set_cal_enb(bool enb); }; diff --git a/gr-wxgui/src/python/common.py b/gr-wxgui/src/python/common.py index d555a1f05..9c97ce1ec 100644 --- a/gr-wxgui/src/python/common.py +++ b/gr-wxgui/src/python/common.py @@ -137,6 +137,25 @@ def get_min_max(samples): scale_factor = 3 mean = numpy.average(samples) rms = numpy.max([scale_factor*((numpy.sum((samples-mean)**2)/len(samples))**.5), .1]) - min = mean - rms - max = mean + rms - return min, max + min_val = mean - rms + max_val = mean + rms + return min_val, max_val + +def get_min_max_fft(fft_samps): + """ + Get the minimum and maximum bounds for an array of fft samples. + @param samples the array of real values + @return a tuple of min, max + """ + #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/src/python/constants.py b/gr-wxgui/src/python/constants.py index 5e1395701..8ff7fa8fe 100644 --- a/gr-wxgui/src/python/constants.py +++ b/gr-wxgui/src/python/constants.py @@ -41,6 +41,8 @@ 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' diff --git a/gr-wxgui/src/python/fft_window.py b/gr-wxgui/src/python/fft_window.py index ba5711d10..237c8940c 100644 --- a/gr-wxgui/src/python/fft_window.py +++ b/gr-wxgui/src/python/fft_window.py @@ -39,10 +39,15 @@ SLIDER_STEPS = 100 AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0 DEFAULT_WIN_SIZE = (600, 300) DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'fft_rate', 30) -DIV_LEVELS = (1, 2, 5, 10, 20) +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) -NO_PEAK_VALS = list() +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 @@ -63,7 +68,7 @@ class control_panel(wx.Panel): control_box.AddStretchSpacer() #checkboxes for average and peak hold options_box = forms.static_box_sizer( - parent=self, sizer=control_box, label='Options', + parent=self, sizer=control_box, label='Trace Options', bold=True, orient=wx.VERTICAL, ) forms.check_box( @@ -90,17 +95,32 @@ class control_panel(wx.Panel): for widget in (avg_alpha_text, avg_alpha_slider): parent.subscribe(AVERAGE_KEY, widget.Enable) widget.Enable(parent[AVERAGE_KEY]) + + #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.radio_buttons( - sizer=y_ctrl_box, parent=self, - ps=parent, key=Y_PER_DIV_KEY, - style=wx.RA_VERTICAL|wx.NO_BORDER, choices=DIV_LEVELS, - labels=map(lambda x: '%s dB/div'%x, DIV_LEVELS), + 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( @@ -135,6 +155,10 @@ class control_panel(wx.Panel): 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, self.parent[Y_PER_DIV_KEY]*2) + def _on_decr_db_div(self, event): + self.parent[Y_PER_DIV_KEY] = max(DB_DIV_MIN, self.parent[Y_PER_DIV_KEY]/2) ################################################## # FFT window with plotter and control panel @@ -159,13 +183,12 @@ class fft_window(wx.Panel, pubsub.pubsub): msg_key, ): pubsub.pubsub.__init__(self) - #ensure y_per_div - if y_per_div not in DIV_LEVELS: y_per_div = DIV_LEVELS[0] #setup - self.samples = list() + 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) @@ -179,6 +202,26 @@ class fft_window(wx.Panel, pubsub.pubsub): self[REF_LEVEL_KEY] = ref_level self[BASEBAND_FREQ_KEY] = baseband_freq self[RUNNING_KEY] = True + 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) @@ -194,7 +237,7 @@ class fft_window(wx.Panel, pubsub.pubsub): main_box.Add(self.control_panel, 0, wx.EXPAND) self.SetSizerAndFit(main_box) #register events - self.subscribe(AVERAGE_KEY, lambda x: self._reset_peak_vals()) + 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 ( @@ -211,19 +254,13 @@ class fft_window(wx.Panel, pubsub.pubsub): Set the dynamic range and reference level. """ if not len(self.samples): return - #get the peak level (max of the samples) - peak_level = numpy.max(self.samples) - #get the noise floor (averge the smallest samples) - noise_floor = numpy.average(numpy.sort(self.samples)[:len(self.samples)/4]) - #padding - noise_floor -= abs(noise_floor)*.5 - peak_level += abs(peak_level)*.1 - #set the reference level to a multiple of y divs - self[REF_LEVEL_KEY] = self[Y_DIVS_KEY]*math.ceil(peak_level/self[Y_DIVS_KEY]) + 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((peak_level - noise_floor)/self[Y_DIVS_KEY]) + 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): self.peak_vals = NO_PEAK_VALS + def _reset_peak_vals(self, *args): self.peak_vals = EMPTY_TRACE def handle_msg(self, msg): """ @@ -272,6 +309,15 @@ class fft_window(wx.Panel, pubsub.pubsub): 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] diff --git a/gr-wxgui/src/python/plotter/waterfall_plotter.py b/gr-wxgui/src/python/plotter/waterfall_plotter.py index 2e0669961..d32b0ca0a 100644 --- a/gr-wxgui/src/python/plotter/waterfall_plotter.py +++ b/gr-wxgui/src/python/plotter/waterfall_plotter.py @@ -209,7 +209,7 @@ class waterfall_plotter(grid_plotter_base): 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*self._fft_size*4, numpy.uint8).tostring() + 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 diff --git a/gr-wxgui/src/python/scopesink_gl.py b/gr-wxgui/src/python/scopesink_gl.py index b4ae0f339..a5e3ca3ce 100644 --- a/gr-wxgui/src/python/scopesink_gl.py +++ b/gr-wxgui/src/python/scopesink_gl.py @@ -50,7 +50,7 @@ class ac_couple_block(gr.hier_block2): 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(2.0/x)) + controller.subscribe(sample_rate_key, lambda x: lpf.set_taps(0.05)) #initialize controller[ac_couple_key] = ac_couple controller[sample_rate_key] = controller[sample_rate_key] diff --git a/gr-wxgui/src/python/waterfall_window.py b/gr-wxgui/src/python/waterfall_window.py index c00992e14..28e67a830 100644 --- a/gr-wxgui/src/python/waterfall_window.py +++ b/gr-wxgui/src/python/waterfall_window.py @@ -237,16 +237,10 @@ class waterfall_window(wx.Panel, pubsub.pubsub): Does not affect the current data in the waterfall. """ if not len(self.samples): return - #get the peak level (max of the samples) - peak_level = numpy.max(self.samples) - #get the noise floor (averge the smallest samples) - noise_floor = numpy.average(numpy.sort(self.samples)[:len(self.samples)/4]) - #padding - noise_floor -= abs(noise_floor)*.5 - peak_level += abs(peak_level)*.1 + min_level, max_level = common.get_min_max_fft(self.samples) #set the range and level - self[REF_LEVEL_KEY] = peak_level - self[DYNAMIC_RANGE_KEY] = peak_level - noise_floor + self[REF_LEVEL_KEY] = max_level + self[DYNAMIC_RANGE_KEY] = max_level - min_level def handle_msg(self, msg): """ diff --git a/grc/blocks/usrp2_sink_xxxx.xml b/grc/blocks/usrp2_sink_xxxx.xml index 639f96cf4..f2ee4d151 100644 --- a/grc/blocks/usrp2_sink_xxxx.xml +++ b/grc/blocks/usrp2_sink_xxxx.xml @@ -2,6 +2,7 @@ <!-- ################################################### ##USRP2 Sink +## Note: the center freq must be set after the lo offset ################################################### --> <block> @@ -16,14 +17,16 @@ usrp2.sink_$(type.fcn)($interface) usrp2.sink_$(type.fcn)($interface, $mac_addr) #end if self.$(id).set_interp($interpolation) -self.$(id).set_center_freq($frequency) -self.$(id).set_gain($gain) #if $lo_offset() != float('inf') self.$(id).set_lo_offset($lo_offset) -#end if</make> - <callback>set_lo_offset($lo_offset)</callback> +#end if +self.$(id).set_center_freq($frequency) +self.$(id).set_gain($gain)</make> <callback>set_interp($interpolation)</callback> - <callback>set_center_freq($frequency)</callback> + <callback>#if $lo_offset() != float('inf') +self.$(id).set_lo_offset($lo_offset) +#end if +self.$(id).set_center_freq($frequency)</callback> <callback>set_gain($gain)</callback> <param> <name>Output Type</name> diff --git a/grc/blocks/usrp2_source_xxxx.xml b/grc/blocks/usrp2_source_xxxx.xml index 6c776d0ad..02046e609 100644 --- a/grc/blocks/usrp2_source_xxxx.xml +++ b/grc/blocks/usrp2_source_xxxx.xml @@ -2,6 +2,7 @@ <!-- ################################################### ##USRP2 Source +## Note: the center freq must be set after the lo offset ################################################### --> <block> @@ -16,14 +17,16 @@ usrp2.source_$(type.fcn)($interface) usrp2.source_$(type.fcn)($interface, $mac_addr) #end if self.$(id).set_decim($decimation) -self.$(id).set_center_freq($frequency) -self.$(id).set_gain($gain) #if $lo_offset() != float('inf') self.$(id).set_lo_offset($lo_offset) -#end if</make> - <callback>set_lo_offset($lo_offset)</callback> +#end if +self.$(id).set_center_freq($frequency) +self.$(id).set_gain($gain)</make> <callback>set_decim($decimation)</callback> - <callback>set_center_freq($frequency)</callback> + <callback>#if $lo_offset() != float('inf') +self.$(id).set_lo_offset($lo_offset) +#end if +self.$(id).set_center_freq($frequency)</callback> <callback>set_gain($gain)</callback> <param> <name>Output Type</name> diff --git a/grc/blocks/usrp_dual_sink_x.xml b/grc/blocks/usrp_dual_sink_x.xml index 8f418becd..4539b62f9 100644 --- a/grc/blocks/usrp_dual_sink_x.xml +++ b/grc/blocks/usrp_dual_sink_x.xml @@ -10,16 +10,18 @@ <import>from grc_gnuradio import usrp as grc_usrp</import> <make>grc_usrp.dual_sink_$(type.fcn)(which=$which) self.$(id).set_interp_rate($interpolation) -self.$(id).set_frequency_a($frequency_a, verbose=True) -self.$(id).set_frequency_b($frequency_b, verbose=True) -self.$(id).set_gain_a($gain_a) -self.$(id).set_gain_b($gain_b) +self.$(id).set_frequency_a($frequency_a, verbose=True#slurp #if $lo_offset_a() != float('inf') -self.$(id).set_lo_offset_a($lo_offset_a) +, lo_offset=$lo_offset_a#slurp #end if +) +self.$(id).set_frequency_b($frequency_b, verbose=True#slurp #if $lo_offset_b() != float('inf') -self.$(id).set_lo_offset_b($lo_offset_b) +, lo_offset=$lo_offset_b#slurp #end if +) +self.$(id).set_gain_a($gain_a) +self.$(id).set_gain_b($gain_b) ################################################## ## Flex RF A ################################################## @@ -39,8 +41,16 @@ self.$(id).set_enable_b(True) self.$(id).set_auto_tr_b(True) #end if</make> <callback>set_interp_rate($interpolation)</callback> - <callback>set_frequency_a($frequency_a)</callback> - <callback>set_frequency_b($frequency_b)</callback> + <callback>set_frequency_a($frequency_a#slurp +#if $lo_offset_a() != float('inf') +, lo_offset=$lo_offset_a#slurp +#end if +)</callback> + <callback>set_frequency_b($frequency_b#slurp +#if $lo_offset_b() != float('inf') +, lo_offset=$lo_offset_b#slurp +#end if +)</callback> <callback>set_gain_a($gain_a)</callback> <callback>set_gain_b($gain_b)</callback> <param> diff --git a/grc/blocks/usrp_dual_source_x.xml b/grc/blocks/usrp_dual_source_x.xml index 740895d42..ad9a860ac 100644 --- a/grc/blocks/usrp_dual_source_x.xml +++ b/grc/blocks/usrp_dual_source_x.xml @@ -13,19 +13,29 @@ self.$(id).set_format(width=$format.width, shift=$format.shift) #end if self.$(id).set_decim_rate($decimation) -self.$(id).set_frequency_a($frequency_a, verbose=True) -self.$(id).set_frequency_b($frequency_b, verbose=True) -self.$(id).set_gain_a($gain_a) -self.$(id).set_gain_b($gain_b) +self.$(id).set_frequency_a($frequency_a, verbose=True#slurp #if $lo_offset_a() != float('inf') -self.$(id).set_lo_offset_a($lo_offset_a) +, lo_offset=$lo_offset_a#slurp #end if +) +self.$(id).set_frequency_b($frequency_b, verbose=True#slurp #if $lo_offset_b() != float('inf') -self.$(id).set_lo_offset_b($lo_offset_b) -#end if</make> +, lo_offset=$lo_offset_b#slurp +#end if +) +self.$(id).set_gain_a($gain_a) +self.$(id).set_gain_b($gain_b)</make> <callback>set_decim_rate($decimation)</callback> - <callback>set_frequency_a($frequency_a)</callback> - <callback>set_frequency_b($frequency_b)</callback> + <callback>set_frequency_a($frequency_a#slurp +#if $lo_offset_a() != float('inf') +, lo_offset=$lo_offset_a#slurp +#end if +)</callback> + <callback>set_frequency_b($frequency_b#slurp +#if $lo_offset_b() != float('inf') +, lo_offset=$lo_offset_b#slurp +#end if +)</callback> <callback>set_gain_a($gain_a)</callback> <callback>set_gain_b($gain_b)</callback> <param> diff --git a/grc/blocks/usrp_simple_sink_x.xml b/grc/blocks/usrp_simple_sink_x.xml index f3ccf1263..b52cd4880 100644 --- a/grc/blocks/usrp_simple_sink_x.xml +++ b/grc/blocks/usrp_simple_sink_x.xml @@ -10,20 +10,24 @@ <import>from grc_gnuradio import usrp as grc_usrp</import> <make>grc_usrp.simple_sink_$(type.fcn)(which=$which, side=$side) self.$(id).set_interp_rate($interpolation) -self.$(id).set_frequency($frequency, verbose=True) +self.$(id).set_frequency($frequency, verbose=True#slurp +#if $lo_offset() != float('inf') +, lo_offset=$lo_offset#slurp +#end if +) self.$(id).set_gain($gain) #if $transmit.tx_enb self.$(id).set_enable(True) #end if #if $transmit.auto_tr self.$(id).set_auto_tr(True) -#end if -#if $lo_offset() != float('inf') -self.$(id).set_lo_offset($lo_offset) #end if</make> - <callback>set_lo_offset($lo_offset)</callback> <callback>set_interp_rate($interpolation)</callback> - <callback>set_frequency($frequency)</callback> + <callback>set_frequency($frequency#slurp +#if $lo_offset() != float('inf') +, lo_offset=$lo_offset#slurp +#end if +)</callback> <callback>set_gain($gain)</callback> <param> <name>Input Type</name> diff --git a/grc/blocks/usrp_simple_source_x.xml b/grc/blocks/usrp_simple_source_x.xml index 1a777bd63..7fcc7a22c 100644 --- a/grc/blocks/usrp_simple_source_x.xml +++ b/grc/blocks/usrp_simple_source_x.xml @@ -13,14 +13,18 @@ self.$(id).set_format(width=$format.width, shift=$format.shift) #end if self.$(id).set_decim_rate($decimation) -self.$(id).set_frequency($frequency, verbose=True) -self.$(id).set_gain($gain) +self.$(id).set_frequency($frequency, verbose=True#slurp #if $lo_offset() != float('inf') -self.$(id).set_lo_offset($lo_offset) -#end if</make> - <callback>set_lo_offset($lo_offset)</callback> +, lo_offset=$lo_offset#slurp +#end if +) +self.$(id).set_gain($gain)</make> <callback>set_decim_rate($decimation)</callback> - <callback>set_frequency($frequency)</callback> + <callback>set_frequency($frequency#slurp +#if $lo_offset() != float('inf') +, lo_offset=$lo_offset#slurp +#end if +)</callback> <callback>set_gain($gain)</callback> <param> <name>Output Type</name> diff --git a/grc/grc_gnuradio/usrp/dual_usrp.py b/grc/grc_gnuradio/usrp/dual_usrp.py index 1ecf7c47f..3692e1760 100644 --- a/grc/grc_gnuradio/usrp/dual_usrp.py +++ b/grc/grc_gnuradio/usrp/dual_usrp.py @@ -53,22 +53,22 @@ class _dual_source(gr.hier_block2): for i in range(2): self.connect((deinter, i), (self, i)) def set_decim_rate(self, decim): self._get_u().set_decim_rate(int(decim)) - def set_frequency_a(self, frequency, verbose=False): + def set_frequency_a(self, frequency, verbose=False, lo_offset=None): + if lo_offset is not None: self._subdev_a.set_lo_offset(lo_offset) self._set_frequency( chan=0, #ddc0 subdev=self._subdev_a, frequency=frequency, verbose=verbose, ) - def set_frequency_b(self, frequency, verbose=False): + def set_frequency_b(self, frequency, verbose=False, lo_offset=None): + if lo_offset is not None: self._subdev_b.set_lo_offset(lo_offset) self._set_frequency( chan=1, #ddc1 subdev=self._subdev_b, frequency=frequency, verbose=verbose, ) - def set_lo_offset_a(self, lo_offset): self._subdev_a.set_lo_offset(lo_offset) - def set_lo_offset_b(self, lo_offset): self._subdev_b.set_lo_offset(lo_offset) def set_gain_a(self, gain): self._subdev_a.set_gain(gain) def set_gain_b(self, gain): self._subdev_b.set_gain(gain) @@ -105,22 +105,22 @@ class _dual_sink(gr.hier_block2): for i in range(2): self.connect((self, i), (inter, i)) def set_interp_rate(self, interp): self._get_u().set_interp_rate(int(interp)) - def set_frequency_a(self, frequency, verbose=False): + def set_frequency_a(self, frequency, verbose=False, lo_offset=None): + if lo_offset is not None: self._subdev_a.set_lo_offset(lo_offset) self._set_frequency( chan=self._subdev_a.which(), subdev=self._subdev_a, frequency=frequency, verbose=verbose, ) - def set_frequency_b(self, frequency, verbose=False): + def set_frequency_b(self, frequency, verbose=False, lo_offset=None): + if lo_offset is not None: self._subdev_b.set_lo_offset(lo_offset) self._set_frequency( chan=self._subdev_b.which(), subdev=self._subdev_b, frequency=frequency, verbose=verbose, ) - def set_lo_offset_a(self, lo_offset): self._subdev_a.set_lo_offset(lo_offset) - def set_lo_offset_b(self, lo_offset): self._subdev_b.set_lo_offset(lo_offset) def set_gain_a(self, gain): self._subdev_a.set_gain(gain) def set_gain_b(self, gain): self._subdev_b.set_gain(gain) def set_enable_a(self, enable): self._subdev_a.set_enable(enable) diff --git a/grc/grc_gnuradio/usrp/simple_usrp.py b/grc/grc_gnuradio/usrp/simple_usrp.py index 9065c7fe9..fc4c75bf0 100644 --- a/grc/grc_gnuradio/usrp/simple_usrp.py +++ b/grc/grc_gnuradio/usrp/simple_usrp.py @@ -56,8 +56,8 @@ class _simple_source(gr.hier_block2): self._get_u().set_decim_rate(int(decim)) if self._no_hb: #set the BW to half the sample rate self._subdev.set_bw(self._get_u().converter_rate()/decim/2) - def set_lo_offset(self, lo_offset): self._subdev.set_lo_offset(lo_offset) - def set_frequency(self, frequency, verbose=False): + def set_frequency(self, frequency, verbose=False, lo_offset=None): + if lo_offset is not None: self._subdev.set_lo_offset(lo_offset) self._set_frequency( chan=0, #ddc0 subdev=self._subdev, @@ -96,14 +96,14 @@ class _simple_sink(gr.hier_block2): self.connect(self, self._get_u()) def set_interp_rate(self, interp): self._get_u().set_interp_rate(int(interp)) - def set_frequency(self, frequency, verbose=False): + def set_frequency(self, frequency, verbose=False, lo_offset=None): + if lo_offset is not None: self._subdev.set_lo_offset(lo_offset) self._set_frequency( chan=self._subdev.which(), subdev=self._subdev, frequency=frequency, verbose=verbose, ) - def set_lo_offset(self, lo_offset): self._subdev.set_lo_offset(lo_offset) def set_gain(self, gain): self._subdev.set_gain(gain) def set_enable(self, enable): self._subdev.set_enable(enable) def set_auto_tr(self, auto_tr): self._subdev.set_auto_tr(auto_tr) diff --git a/gruel/src/include/gruel/Makefile.am b/gruel/src/include/gruel/Makefile.am index 9f50cb619..67dd12995 100644 --- a/gruel/src/include/gruel/Makefile.am +++ b/gruel/src/include/gruel/Makefile.am @@ -31,11 +31,12 @@ gruelinclude_HEADERS = \ msg_accepter.h \ msg_accepter_msgq.h \ msg_queue.h \ + msg_passing.h \ pmt.h \ pmt_pool.h \ pmt_serial_tags.h \ + pmt_sugar.h \ realtime.h \ - send.h \ sys_pri.h \ thread_body_wrapper.h \ thread_group.h \ diff --git a/gruel/src/include/gruel/msg_accepter.h b/gruel/src/include/gruel/msg_accepter.h index 3afd6dde0..70ac846f5 100644 --- a/gruel/src/include/gruel/msg_accepter.h +++ b/gruel/src/include/gruel/msg_accepter.h @@ -22,6 +22,7 @@ #define INCLUDED_GRUEL_MSG_ACCEPTER_H #include <gruel/pmt.h> +#include <boost/shared_ptr.hpp> namespace gruel { @@ -44,6 +45,8 @@ namespace gruel { virtual void post(pmt::pmt_t msg) = 0; }; + typedef boost::shared_ptr<msg_accepter> msg_accepter_sptr; + } /* namespace gruel */ #endif /* INCLUDED_GRUEL_MSG_ACCEPTER_H */ diff --git a/gruel/src/include/gruel/msg_passing.h b/gruel/src/include/gruel/msg_passing.h new file mode 100644 index 000000000..ebbeca815 --- /dev/null +++ b/gruel/src/include/gruel/msg_passing.h @@ -0,0 +1,111 @@ +/* -*- c++ -*- */ +/* + * 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_GRUEL_MSG_PASSING_H +#define INCLUDED_GRUEL_MSG_PASSING_H + +/*! + * \brief Include this header to use the message passing features + */ + +#include <gruel/pmt.h> +#include <gruel/msg_accepter.h> + + +namespace gruel { + + /*! + * \brief send message to msg_accepter + * + * \param accepter is the target of the send. + * \param msg is the message to send. It's usually a pmt tuple. + * + * Sending a message is an asynchronous operation. The \p send + * call will not wait for the message either to arrive at the + * destination or to be received. + * + * \returns msg + */ + static inline pmt::pmt_t + send(msg_accepter_sptr accepter, const pmt::pmt_t &msg) + { + accepter->post(msg); + return msg; + } + + /*! + * \brief send message to msg_accepter + * + * \param accepter is the target of the send. + * \param msg is the message to send. It's usually a pmt tuple. + * + * Sending a message is an asynchronous operation. The \p send + * call will not wait for the message either to arrive at the + * destination or to be received. + * + * \returns msg + */ + static inline pmt::pmt_t + send(msg_accepter *accepter, const pmt::pmt_t &msg) + { + accepter->post(msg); + return msg; + } + + /*! + * \brief send message to msg_accepter + * + * \param accepter is the target of the send. + * \param msg is the message to send. It's usually a pmt tuple. + * + * Sending a message is an asynchronous operation. The \p send + * call will not wait for the message either to arrive at the + * destination or to be received. + * + * \returns msg + */ + static inline pmt::pmt_t + send(msg_accepter &accepter, const pmt::pmt_t &msg) + { + accepter.post(msg); + return msg; + } + + /*! + * \brief send message to msg_accepter + * + * \param accepter is the target of the send. precond: pmt_is_msg_accepter(accepter) + * \param msg is the message to send. It's usually a pmt tuple. + * + * Sending a message is an asynchronous operation. The \p send + * call will not wait for the message either to arrive at the + * destination or to be received. + * + * \returns msg + */ + static inline pmt::pmt_t + send(pmt::pmt_t accepter, const pmt::pmt_t &msg) + { + return send(pmt_msg_accepter_ref(accepter), msg); + } + +} /* namespace gruel */ + +#endif /* INCLUDED_GRUEL_MSG_PASSING_H */ diff --git a/gruel/src/include/gruel/pmt.h b/gruel/src/include/gruel/pmt.h index 240359301..3188aad1d 100644 --- a/gruel/src/include/gruel/pmt.h +++ b/gruel/src/include/gruel/pmt.h @@ -24,6 +24,7 @@ #define INCLUDED_PMT_H #include <boost/intrusive_ptr.hpp> +#include <boost/shared_ptr.hpp> #include <boost/any.hpp> #include <complex> #include <string> @@ -31,6 +32,10 @@ #include <iosfwd> #include <stdexcept> +namespace gruel { + class msg_accepter; +}; + /*! * This file defines a polymorphic type and the operations on it. * @@ -299,6 +304,33 @@ void pmt_vector_set(pmt_t vector, size_t k, pmt_t obj); //! Store \p fill in every position of \p vector void pmt_vector_fill(pmt_t vector, pmt_t fill); +/* + * ------------------------------------------------------------------------ + * Binary Large Objects (BLOBs) + * + * Handy for passing around uninterpreted chunks of memory. + * ------------------------------------------------------------------------ + */ + +//! Return true if \p x is a blob, othewise false. +bool pmt_is_blob(pmt_t x); + +/*! + * \brief Make a blob given a pointer and length in bytes + * + * \param buf is the pointer to data to use to create blob + * \param len is the size of the data in bytes. + * + * The data is copied into the blob. + */ +pmt_t pmt_make_blob(const void *buf, size_t len); + +//! Return a pointer to the blob's data +const void *pmt_blob_data(pmt_t blob); + +//! Return the blob's length in bytes +size_t pmt_blob_length(pmt_t blob); + /*! * <pre> * ------------------------------------------------------------------------ @@ -484,6 +516,20 @@ void pmt_any_set(pmt_t obj, const boost::any &any); /* * ------------------------------------------------------------------------ + * msg_accepter -- pmt representation of gruel::msg_accepter + * ------------------------------------------------------------------------ + */ +//! Return true if \p obj is a msg_accepter +bool pmt_is_msg_accepter(const pmt_t &obj); + +//! make a msg_accepter +pmt_t pmt_make_msg_accepter(boost::shared_ptr<gruel::msg_accepter> ma); + +//! Return underlying msg_accepter +boost::shared_ptr<gruel::msg_accepter> pmt_msg_accepter_ref(const pmt_t &obj); + +/* + * ------------------------------------------------------------------------ * General functions * ------------------------------------------------------------------------ */ @@ -717,4 +763,7 @@ void pmt_dump_sizeof(); // debugging } /* namespace pmt */ + +#include <gruel/pmt_sugar.h> + #endif /* INCLUDED_PMT_H */ diff --git a/gruel/src/include/gruel/pmt_sugar.h b/gruel/src/include/gruel/pmt_sugar.h new file mode 100644 index 000000000..92bcb5fe5 --- /dev/null +++ b/gruel/src/include/gruel/pmt_sugar.h @@ -0,0 +1,165 @@ +/* -*- c++ -*- */ +/* + * 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_GRUEL_PMT_SUGAR_H +#define INCLUDED_GRUEL_PMT_SUGAR_H + +/*! + * This file is included by pmt.h and contains pseudo-constructor + * shorthand for making pmt objects + */ + +namespace pmt { + + //! Make pmt symbol + static inline pmt_t + mp(const std::string &s) + { + return pmt_string_to_symbol(s); + } + + //! Make pmt symbol + static inline pmt_t + mp(const char *s) + { + return pmt_string_to_symbol(s); + } + + //! Make pmt long + static inline pmt_t + mp(long x){ + return pmt_from_long(x); + } + + //! Make pmt long + static inline pmt_t + mp(int x){ + return pmt_from_long(x); + } + + //! Make pmt double + static inline pmt_t + mp(double x){ + return pmt_from_double(x); + } + + //! Make pmt complex + static inline pmt_t + mp(std::complex<double> z) + { + return pmt_make_rectangular(z.real(), z.imag()); + } + + //! Make pmt complex + static inline pmt_t + mp(std::complex<float> z) + { + return pmt_make_rectangular(z.real(), z.imag()); + } + + //! Make pmt msg_accepter + static inline pmt_t + mp(boost::shared_ptr<gruel::msg_accepter> ma) + { + return pmt_make_msg_accepter(ma); + } + + //! Make pmt Binary Large Object (BLOB) + static inline pmt_t + mp(const void *data, size_t len_in_bytes) + { + return pmt_make_blob(data, len_in_bytes); + } + + //! Make tuple + static inline pmt_t + mp(const pmt_t &e0) + { + return pmt_make_tuple(e0); + } + + //! Make tuple + static inline pmt_t + mp(const pmt_t &e0, const pmt_t &e1) + { + return pmt_make_tuple(e0, e1); + } + + //! Make tuple + static inline pmt_t + mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2) + { + return pmt_make_tuple(e0, e1, e2); + } + + //! Make tuple + static inline pmt_t + mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3) + { + return pmt_make_tuple(e0, e1, e2, e3); + } + + //! Make tuple + static inline pmt_t + mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4) + { + return pmt_make_tuple(e0, e1, e2, e3, e4); + } + + //! Make tuple + static inline pmt_t + mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5) + { + return pmt_make_tuple(e0, e1, e2, e3, e4, e5); + } + + //! Make tuple + static inline pmt_t + mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6) + { + return pmt_make_tuple(e0, e1, e2, e3, e4, e5, e6); + } + + //! Make tuple + static inline pmt_t + mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7) + { + return pmt_make_tuple(e0, e1, e2, e3, e4, e5, e6, e7); + } + + //! Make tuple + static inline pmt_t + mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8) + { + return pmt_make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8); + } + + //! Make tuple + static inline pmt_t + mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8, const pmt_t &e9) + { + return pmt_make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9); + } + + +} /* namespace pmt */ + + +#endif /* INCLUDED_GRUEL_PMT_SUGAR_H */ diff --git a/gruel/src/include/gruel/send.h b/gruel/src/include/gruel/send.h deleted file mode 100644 index 292017d45..000000000 --- a/gruel/src/include/gruel/send.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_GRUEL_SEND_H -#define INCLUDED_GRUEL_SEND_H - -#include <gruel/msg_accepter.h> - -namespace gruel { - - - /*! - * \brief send \p msg to \p msg_accepter - * - * Sending a message is an asynchronous operation. The \p send - * call will not wait for the message either to arrive at the - * destination or to be received. - * - * \returns msg - */ - static inline pmt::pmt_t - send(msg_accepter &acc, pmt::pmt_t msg) - { - return acc.post(msg); - } - - - -} /* namespace gruel */ - - -#endif /* INCLUDED_SEND_H */ diff --git a/gruel/src/lib/Makefile.am b/gruel/src/lib/Makefile.am index 6dfb6787c..9afa0d292 100644 --- a/gruel/src/lib/Makefile.am +++ b/gruel/src/lib/Makefile.am @@ -25,6 +25,12 @@ SUBDIRS = pmt msg AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) $(GRUEL_INCLUDES) $(WITH_INCLUDES) + +TESTS = test_gruel + +noinst_PROGRAMS = test_gruel + + lib_LTLIBRARIES = libgruel.la # magic flags @@ -47,3 +53,10 @@ libgruel_la_LIBADD = \ $(PMT_LIB) \ $(MSG_LIB) \ -lstdc++ + + +# ---------------------------------------------------------------- + +test_gruel_SOURCES = test_gruel.cc +test_gruel_LDADD = libgruel.la pmt/libpmt-qa.la + diff --git a/gruel/src/lib/pmt/Makefile.am b/gruel/src/lib/pmt/Makefile.am index 2b710a598..8750cbdf8 100644 --- a/gruel/src/lib/pmt/Makefile.am +++ b/gruel/src/lib/pmt/Makefile.am @@ -23,7 +23,6 @@ include $(top_srcdir)/Makefile.common AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) $(GRUEL_INCLUDES) $(WITH_INCLUDES) -TESTS = test_pmt noinst_LTLIBRARIES = libpmt.la @@ -90,14 +89,6 @@ libpmt_qa_la_LIBADD = \ $(CPPUNIT_LIBS) \ -lstdc++ -noinst_PROGRAMS = \ - test_pmt - - -LIBPMTQA = libpmt-qa.la - -test_pmt_SOURCES = test_pmt.cc -test_pmt_LDADD = $(LIBPMTQA) # Do creation and inclusion of other Makefiles last diff --git a/gruel/src/lib/pmt/pmt.cc b/gruel/src/lib/pmt/pmt.cc index f0e3c30a2..e50e21838 100644 --- a/gruel/src/lib/pmt/pmt.cc +++ b/gruel/src/lib/pmt/pmt.cc @@ -26,8 +26,9 @@ #include <vector> #include <gruel/pmt.h> #include "pmt_int.h" -#include <stdio.h> +#include <gruel/msg_accepter.h> #include <gruel/pmt_pool.h> +#include <stdio.h> #include <string.h> namespace pmt { @@ -882,6 +883,73 @@ pmt_any_set(pmt_t obj, const boost::any &any) } //////////////////////////////////////////////////////////////////////////// +// msg_accepter -- built from "any" +//////////////////////////////////////////////////////////////////////////// + +bool +pmt_is_msg_accepter(const pmt_t &obj) +{ + if (!pmt_is_any(obj)) + return false; + + boost::any r = pmt_any_ref(obj); + return boost::any_cast<gruel::msg_accepter_sptr>(&r) != 0; +} + +//! make a msg_accepter +pmt_t +pmt_make_msg_accepter(gruel::msg_accepter_sptr ma) +{ + return pmt_make_any(ma); +} + +//! Return underlying msg_accepter +gruel::msg_accepter_sptr +pmt_msg_accepter_ref(const pmt_t &obj) +{ + try { + return boost::any_cast<gruel::msg_accepter_sptr>(pmt_any_ref(obj)); + } + catch (boost::bad_any_cast &e){ + throw pmt_wrong_type("pmt_msg_accepter_ref", obj); + } +} + + +//////////////////////////////////////////////////////////////////////////// +// Binary Large Object -- currently a u8vector +//////////////////////////////////////////////////////////////////////////// + +bool +pmt_is_blob(pmt_t x) +{ + // return pmt_is_u8vector(x); + return pmt_is_uniform_vector(x); +} + +pmt_t +pmt_make_blob(const void *buf, size_t len_in_bytes) +{ + return pmt_init_u8vector(len_in_bytes, (const uint8_t *) buf); +} + +const void * +pmt_blob_data(pmt_t blob) +{ + size_t len; + return pmt_uniform_vector_elements(blob, len); +} + +size_t +pmt_blob_length(pmt_t blob) +{ + size_t len; + pmt_uniform_vector_elements(blob, len); + return len; +} + + +//////////////////////////////////////////////////////////////////////////// // General Functions //////////////////////////////////////////////////////////////////////////// diff --git a/gruel/src/lib/pmt/qa_pmt_prims.cc b/gruel/src/lib/pmt/qa_pmt_prims.cc index 899674bbb..59d9e14d3 100644 --- a/gruel/src/lib/pmt/qa_pmt_prims.cc +++ b/gruel/src/lib/pmt/qa_pmt_prims.cc @@ -22,8 +22,9 @@ #include <qa_pmt_prims.h> #include <cppunit/TestAssert.h> -#include <gruel/pmt.h> -#include <stdio.h> +#include <gruel/msg_passing.h> +#include <cstdio> +#include <cstring> #include <sstream> using namespace pmt; @@ -453,6 +454,41 @@ qa_pmt_prims::test_any() // ------------------------------------------------------------------------ +class qa_pmt_msg_accepter_nop : public gruel::msg_accepter { +public: + qa_pmt_msg_accepter_nop(){}; + ~qa_pmt_msg_accepter_nop(); + void post(pmt_t){}; +}; + +qa_pmt_msg_accepter_nop::~qa_pmt_msg_accepter_nop(){} + +void +qa_pmt_prims::test_msg_accepter() +{ + pmt_t sym = pmt_intern("my-symbol"); + + boost::any a0; + a0 = std::string("Hello!"); + pmt_t p0 = pmt_make_any(a0); + + gruel::msg_accepter_sptr ma0 = gruel::msg_accepter_sptr(new qa_pmt_msg_accepter_nop()); + pmt_t p1 = pmt_make_msg_accepter(ma0); + + CPPUNIT_ASSERT_EQUAL(ma0.get(), pmt_msg_accepter_ref(p1).get()); + + CPPUNIT_ASSERT_THROW(pmt_msg_accepter_ref(sym), pmt_wrong_type); + CPPUNIT_ASSERT_THROW(pmt_msg_accepter_ref(p0), pmt_wrong_type); + + // just confirm interfaces on send are OK + gruel::send(ma0.get(), sym); + gruel::send(ma0, sym); + gruel::send(p1, sym); + +} + +// ------------------------------------------------------------------------ + void qa_pmt_prims::test_serialize() { @@ -522,3 +558,19 @@ qa_pmt_prims::test_sets() CPPUNIT_ASSERT(!pmt_subsetp(l3,l2)); } +void +qa_pmt_prims::test_sugar() +{ + CPPUNIT_ASSERT(pmt_is_symbol(mp("my-symbol"))); + CPPUNIT_ASSERT_EQUAL((long) 10, pmt_to_long(mp(10))); + CPPUNIT_ASSERT_EQUAL((double) 1e6, pmt_to_double(mp(1e6))); + CPPUNIT_ASSERT_EQUAL(std::complex<double>(2, 3), + pmt_to_complex(mp(std::complex<double>(2, 3)))); + + int buf[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + pmt_t blob = mp(buf, sizeof(buf)); + const void *data = pmt_blob_data(blob); + size_t nbytes = pmt_blob_length(blob); + CPPUNIT_ASSERT_EQUAL(sizeof(buf), nbytes); + CPPUNIT_ASSERT(memcmp(buf, data, nbytes) == 0); +} diff --git a/gruel/src/lib/pmt/qa_pmt_prims.h b/gruel/src/lib/pmt/qa_pmt_prims.h index 2fe473c43..29ba02f11 100644 --- a/gruel/src/lib/pmt/qa_pmt_prims.h +++ b/gruel/src/lib/pmt/qa_pmt_prims.h @@ -40,10 +40,12 @@ class qa_pmt_prims : public CppUnit::TestCase { CPPUNIT_TEST(test_misc); CPPUNIT_TEST(test_dict); CPPUNIT_TEST(test_any); + CPPUNIT_TEST(test_msg_accepter); CPPUNIT_TEST(test_io); CPPUNIT_TEST(test_lists); CPPUNIT_TEST(test_serialize); CPPUNIT_TEST(test_sets); + CPPUNIT_TEST(test_sugar); CPPUNIT_TEST_SUITE_END(); private: @@ -59,10 +61,12 @@ class qa_pmt_prims : public CppUnit::TestCase { void test_misc(); void test_dict(); void test_any(); + void test_msg_accepter(); void test_io(); void test_lists(); void test_serialize(); void test_sets(); + void test_sugar(); }; #endif /* INCLUDED_QA_PMT_PRIMS_H */ diff --git a/gruel/src/lib/pmt/test_pmt.cc b/gruel/src/lib/test_gruel.cc index 034785f4e..669303447 100644 --- a/gruel/src/lib/pmt/test_pmt.cc +++ b/gruel/src/lib/test_gruel.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,7 +21,7 @@ */ #include <cppunit/TextTestRunner.h> -#include <qa_pmt.h> +#include "pmt/qa_pmt.h" int main(int argc, char **argv) diff --git a/usrp/host/lib/db_flexrf.cc b/usrp/host/lib/db_flexrf.cc index a8f4684b5..2d2bfabbb 100644 --- a/usrp/host/lib/db_flexrf.cc +++ b/usrp/host/lib/db_flexrf.cc @@ -668,7 +668,7 @@ _2400_common::freq_min() double _2400_common::freq_max() { - return 2700e6; + return 2900e6; } //---------------------------------------------------------------------- @@ -700,7 +700,7 @@ _1200_common::freq_min() double _1200_common::freq_max() { - return 1350e6; + return 1450e6; } //------------------------------------------------------------------------- @@ -726,13 +726,13 @@ _1800_common::_1800_common() double _1800_common::freq_min() { - return 1600e6; + return 1500e6; } double _1800_common::freq_max() { - return 2000e6; + return 2100e6; } //------------------------------------------------------------------------- @@ -758,13 +758,13 @@ _900_common::_900_common() double _900_common::freq_min() { - return 800e6; + return 750e6; } double _900_common::freq_max() { - return 1000e6; + return 1050e6; } //------------------------------------------------------------------------- diff --git a/usrp2/firmware/lib/db_rfx.c b/usrp2/firmware/lib/db_rfx.c index 2f950016f..ff12f9e32 100644 --- a/usrp2/firmware/lib/db_rfx.c +++ b/usrp2/firmware/lib/db_rfx.c @@ -200,8 +200,8 @@ struct db_rfx_900_rx db_rfx_900_rx = { .base.is_tx = false, .base.output_enables = 0x00E0, .base.used_pins = 0x00FF, - .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(800e6), - .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(1000e6), + .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(750e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(1050e6), .base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(0), .base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(70), .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(0.034), @@ -231,8 +231,8 @@ struct db_rfx_900_tx db_rfx_900_tx = { .base.is_tx = true, .base.output_enables = 0x00E0, .base.used_pins = 0x00FF, - .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(800e6), - .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(1000e6), + .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(750e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(1050e6), //.base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(xxx), //.base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(xxx), //.base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(xxx), @@ -262,7 +262,7 @@ struct db_rfx_1200_rx db_rfx_1200_rx = { .base.output_enables = 0x00E0, .base.used_pins = 0x00FF, .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(1150e6), - .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(1350e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(1450e6), .base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(0), .base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(70), .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(0.034), @@ -293,7 +293,7 @@ struct db_rfx_1200_tx db_rfx_1200_tx = { .base.output_enables = 0x00E0, .base.used_pins = 0x00FF, .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(1150e6), - .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(1350e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(1450e6), //.base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(xxx), //.base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(xxx), //.base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(xxx), @@ -322,8 +322,8 @@ struct db_rfx_1800_rx db_rfx_1800_rx = { .base.is_tx = false, .base.output_enables = 0x00E0, .base.used_pins = 0x00FF, - .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(1600e6), - .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2000e6), + .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(1500e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2100e6), .base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(0), .base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(70), .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(0.034), @@ -353,8 +353,8 @@ struct db_rfx_1800_tx db_rfx_1800_tx = { .base.is_tx = true, .base.output_enables = 0x00E0, .base.used_pins = 0x00FF, - .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(1600e6), - .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2000e6), + .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(1500e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2100e6), //.base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(xxx), //.base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(xxx), //.base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(xxx), @@ -385,7 +385,7 @@ struct db_rfx_2400_rx db_rfx_2400_rx = { .base.output_enables = 0x00E0, .base.used_pins = 0x00FF, .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(2300e6), - .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2700e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2900e6), .base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(0), .base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(70), .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(0.034), @@ -416,7 +416,7 @@ struct db_rfx_2400_tx db_rfx_2400_tx = { .base.output_enables = 0x00E0, .base.used_pins = 0x00FF, .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(2300e6), - .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2700e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2900e6), //.base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(xxx), //.base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(xxx), //.base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(xxx), diff --git a/vrt/include/vrt/quadradio.h b/vrt/include/vrt/quadradio.h index 747ca8ef4..83323f093 100644 --- a/vrt/include/vrt/quadradio.h +++ b/vrt/include/vrt/quadradio.h @@ -38,6 +38,14 @@ typedef enum{ } vrt_test_sig_t; +typedef enum{ + VRT_BAND_SEL_A='A', + VRT_BAND_SEL_B='B', + VRT_BAND_SEL_C='C', + VRT_BAND_SEL_D='D', + + } vrt_band_sel_t; + namespace vrt { /* @@ -53,7 +61,7 @@ namespace vrt { int d_data_port; // our data port number vrt::rx::sptr d_rx; // has-a rx - int d_band_select; // band select setting + vrt_band_sel_t d_band_select; // band select setting int d_rx_antenna; // antenna type rf/cal int d_attenuation0; // attenuation setting int d_attenuation1; // attenuation setting @@ -92,7 +100,8 @@ namespace vrt { /* convenience methods that ultimately write the dboard pins */ bool set_center_freq(double target_freq); - bool set_band_select(const std::string &band); + bool set_band_select(vrt_band_sel_t band); + vrt_band_sel_t get_band_select(void){return d_band_select;} //void set_10dB_atten(bool on); bool set_attenuation0(int attenuation); bool select_rx_antenna(const std::string &ant); @@ -110,6 +119,7 @@ namespace vrt { bool set_lo_freq(double freq); bool set_cal_freq(double freq); bool set_beamforming(int32_t gains[8]); + bool set_cal_enb(bool enb); /* * The first parameter for these is a bitmask which indicates which * daughterboard or daughterboards to apply the operation to. diff --git a/vrt/lib/quadradio.cc b/vrt/lib/quadradio.cc index ab5de89b8..8cf542e0f 100644 --- a/vrt/lib/quadradio.cc +++ b/vrt/lib/quadradio.cc @@ -51,7 +51,7 @@ send_and_check(int fd, void *buf, size_t len) vrt::quadradio::quadradio(const std::string &ip, size_t rx_bufsize) : d_ctrl_fd(0), d_data_fd(0), d_data_port(0), - d_band_select(0), d_rx_antenna(0), d_attenuation0(0), d_attenuation1(0)//d_10dB_atten(true) + d_band_select(VRT_BAND_SEL_A), d_rx_antenna(0), d_attenuation0(0), d_attenuation1(0)//d_10dB_atten(true) { if (!open(ip.c_str())) throw std::runtime_error("vrt::quadradio: failed to open " + ip + "\n"); @@ -89,20 +89,16 @@ vrt::quadradio::stop_streaming() bool vrt::quadradio::set_center_freq(double target_freq){ if (target_freq < 700e6) return false; - if (target_freq <= 1.0e9) return set_band_select("A"); - if (target_freq <= 1.5e9) return set_band_select("B"); - if (target_freq <= 2.2e9) return set_band_select("C"); - if (target_freq <= 3.0e9) return set_band_select("D"); + if (target_freq <= 1.0e9) return set_band_select(VRT_BAND_SEL_A); + if (target_freq <= 1.5e9) return set_band_select(VRT_BAND_SEL_B); + if (target_freq <= 2.2e9) return set_band_select(VRT_BAND_SEL_C); + if (target_freq <= 3.0e9) return set_band_select(VRT_BAND_SEL_D); return false; } bool -vrt::quadradio::set_band_select(const std::string &band){ - if (band == "A") d_band_select = 3; - else if (band == "B") d_band_select = 2; - else if (band == "C") d_band_select = 1; - else if (band == "D") d_band_select = 0; - else return false; +vrt::quadradio::set_band_select(vrt_band_sel_t band){ + d_band_select = band; update_dboard_pins(); return true; } @@ -149,11 +145,21 @@ static int reverse_bits(int input, int len){ void vrt::quadradio::update_dboard_pins(void){ + //convert the band ID to bits + int band_select; + switch (d_band_select){ + case VRT_BAND_SEL_A: band_select = 3; break; + case VRT_BAND_SEL_B: band_select = 2; break; + case VRT_BAND_SEL_C: band_select = 1; break; + case VRT_BAND_SEL_D: band_select = 0; break; + default: band_select = 0; + } + //calculate the control bits int db_ctrl = \ - ((reverse_bits(d_attenuation0, 5) & 0x1f) << 10) | \ + ((reverse_bits(d_attenuation0, 5) & 0x1f) << 10) | \ ((reverse_bits(~d_attenuation1, 5) & 0x1f) << 03) | \ - ((d_band_select & 0x03) << 01) | \ - ((d_rx_antenna & 0x01) << 00); + ((band_select & 0x03) << 01) | \ + ((d_rx_antenna & 0x01) << 00); set_dboard_pins(ALL_DBOARDS, db_ctrl); // FIXME sets them all } @@ -406,3 +412,13 @@ vrt::quadradio::set_beamforming(int32_t gains[8]){ return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); } +bool +vrt::quadradio::set_cal_enb(bool enb) +{ + uint32_t cmd[3]; + cmd[0] = htonl(0); // verb: set + cmd[1] = htonl(9); // id: cal enb + cmd[2] = htonl(enb); + + return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); +} |