[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10839 - gnuradio/branches/developers/trondeau/qtdevel
From: |
trondeau |
Subject: |
[Commit-gnuradio] r10839 - gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/python |
Date: |
Tue, 14 Apr 2009 17:23:09 -0600 (MDT) |
Author: trondeau
Date: 2009-04-14 17:23:08 -0600 (Tue, 14 Apr 2009)
New Revision: 10839
Modified:
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/python/usrp2_display.py
Log:
Fixed interface to QtGui for USRP2 display program
Modified:
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/python/usrp2_display.py
===================================================================
---
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/python/usrp2_display.py
2009-04-14 23:07:34 UTC (rev 10838)
+++
gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/python/usrp2_display.py
2009-04-14 23:23:08 UTC (rev 10839)
@@ -26,9 +26,101 @@
from gnuradio.eng_option import eng_option
from gnuradio.qtgui import qtgui
from optparse import OptionParser
-import sys
-import numpy
+from PyQt4 import QtGui, QtCore
+import sys, sip
+class dialog_box(QtGui.QWidget):
+ def __init__(self, display, control):
+ QtGui.QWidget.__init__(self, None)
+ self.setWindowTitle('USRP2 Display')
+
+ self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self)
+ self.boxlayout.addWidget(display, 1)
+ self.boxlayout.addWidget(control)
+
+ self.resize(800, 500)
+
+class control_panel(QtGui.QWidget):
+ def __init__(self, usrp, parent=None):
+ QtGui.QWidget.__init__(self, parent)
+ self.setWindowTitle('USRP2 Control Panel')
+
+ self.usrp = usrp
+ self.adc_rate = self.usrp.adc_rate()
+
+ self.setToolTip('Set the values of the USRP2')
+ QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
+
+ self.layout = QtGui.QFormLayout(self)
+
+ # Received frequency
+ self.freqEdit = QtGui.QLineEdit(self)
+ self.layout.addRow("Frequency:", self.freqEdit)
+ self.connect(self.freqEdit, QtCore.SIGNAL("editingFinished()"),
+ self.freqEditText)
+
+ # Receiver gain
+ self.gainEdit = QtGui.QLineEdit(self)
+ self.layout.addRow("Gain:", self.gainEdit)
+ self.connect(self.gainEdit, QtCore.SIGNAL("editingFinished()"),
+ self.gainEditText)
+
+
+ # Decim / Bandwidth
+ self.decimEdit = QtGui.QLineEdit(self)
+ self.layout.addRow("Decim Rate:", self.decimEdit)
+ self.connect(self.decimEdit, QtCore.SIGNAL("editingFinished()"),
+ self.decimEditText)
+
+ self.quit = QtGui.QPushButton('Close', self)
+ self.layout.addRow(self.quit)
+
+ self.connect(self.quit, QtCore.SIGNAL('clicked()'),
+ QtGui.qApp, QtCore.SLOT('quit()'))
+
+ def set_frequency(self, freq):
+ self.freq = freq
+ sfreq = eng_notation.num_to_str(self.freq)
+ self.freqEdit.setText(QtCore.QString("%1").arg(sfreq))
+
+ def set_gain(self, gain):
+ self.gain = gain
+ self.gainEdit.setText(QtCore.QString("%1").arg(self.gain))
+
+ def set_decim(self, decim):
+ self.decim = decim
+ self.bw = self.adc_rate / float(self.decim) / 1000.0
+ self.decimEdit.setText(QtCore.QString("%1").arg(self.decim))
+
+ def freqEditText(self):
+ try:
+ freq = eng_notation.str_to_num(self.freqEdit.text().toAscii())
+ r = self.usrp.set_center_freq(freq)
+ self.freq = freq
+ except RuntimeError:
+ pass
+
+ #self.set_frequency(self.freq)
+
+ def gainEditText(self):
+ try:
+ gain = float(self.gainEdit.text())
+ self.usrp.set_gain(gain)
+ self.gain = gain
+ except ValueError:
+ pass
+
+ #self.set_gain(gain)
+
+ def decimEditText(self):
+ try:
+ decim = int(self.decimEdit.text())
+ self.usrp.set_decim(decim)
+ except ValueError:
+ pass
+
+ #self.set_decim(decim)
+
class app_top_block(gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
@@ -54,18 +146,20 @@
self.options = options
self.show_debug_info = True
+ self.qapp = QtGui.QApplication(sys.argv)
+
self.u = usrp2.source_32fc(options.interface, options.mac_addr)
self.u.set_decim(options.decim)
input_rate = self.u.adc_rate() / self.u.decim()
self.snk = qtgui.sink_c(options.fft_size,
gr.firdes.WIN_BLACKMAN_hARRIS,
- -input_rate/2.0, input_rate/2.0)
+ -input_rate/2, input_rate/2,
+ "USRP2 Display",
+ True, True, False, True, False)
self.connect(self.u, self.snk)
- self.snk.initialize()
-
if options.gain is None:
# if no gain was specified, use the mid-point in dB
g = self.u.gain_range()
@@ -77,34 +171,31 @@
options.freq = float(r[0]+r[1])/2
self.set_gain(options.gain)
+ r = self.u.set_center_freq(options.freq)
if self.show_debug_info:
print "Decimation rate: ", self.u.decim()
print "Bandwidth: ", input_rate
print "D'board: ", self.u.daughterboard_id()
- self.set_freq(options.freq)
-
-
- def set_freq(self, target_freq):
- """
- Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
- @rypte: bool
+ self.ctrl_win = control_panel(self.u)
- Tuning is a two step process. First we ask the front-end to
- tune as close to the desired frequency as it can. Then we use
- the result of that operation and our target_frequency to
- determine the value for the digital down converter.
- """
- r = self.u.set_center_freq(target_freq)
+ self.ctrl_win.set_frequency(options.freq)
+ self.ctrl_win.set_gain(options.gain)
+ self.ctrl_win.set_decim(options.decim)
- if r:
- return True
+ # Get the reference pointer to the SpectrumDisplayForm QWidget
+ pyQt = self.snk.pyqwidget()
- return False
+ # Wrap the pointer as a PyQt SIP object
+ # This can now be manipulated as a PyQt4.QtGui.QWidget
+ pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
+ self.main_box = dialog_box(pyWin, self.ctrl_win)
+
+ self.main_box.show()
+
def set_gain(self, gain):
self.u.set_gain(gain)
@@ -118,7 +209,7 @@
def main ():
tb = app_top_block()
tb.start()
- tb.snk.start_app();
+ tb.snk.exec_();
if __name__ == '__main__':
try:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10839 - gnuradio/branches/developers/trondeau/qtdevel2/gr-qtgui/src/python,
trondeau <=