diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-02-04 22:32:12 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-02-04 22:32:12 -0500 |
commit | 9521183111be31f5aa4409d10d0476c75b3f8a20 (patch) | |
tree | 1c2c2c4725e00b737074d1a23041507155b61e27 /gnuradio-core/src/python | |
parent | 1162a912c71aeac4e3cce458c2806c402fac0ae8 (diff) |
ctrlport: removed obsolete files.
Diffstat (limited to 'gnuradio-core/src/python')
3 files changed, 0 insertions, 861 deletions
diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/CMakeLists.txt b/gnuradio-core/src/python/gnuradio/ctrlport/CMakeLists.txt index a096a526c8..994e3a48cf 100644 --- a/gnuradio-core/src/python/gnuradio/ctrlport/CMakeLists.txt +++ b/gnuradio-core/src/python/gnuradio/ctrlport/CMakeLists.txt @@ -81,7 +81,6 @@ install( GR_PYTHON_INSTALL( FILES - ${CMAKE_CURRENT_SOURCE_DIR}/DataPlotter.py ${CMAKE_CURRENT_SOURCE_DIR}/GrDataPlotter.py ${CMAKE_CURRENT_SOURCE_DIR}/monitor.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/ @@ -90,7 +89,6 @@ GR_PYTHON_INSTALL( GR_PYTHON_INSTALL( FILES - ${CMAKE_CURRENT_SOURCE_DIR}/ctrlport-monitor ${CMAKE_CURRENT_SOURCE_DIR}/gr-ctrlport-monitor ${CMAKE_CURRENT_SOURCE_DIR}/gr-ctrlport-curses DESTINATION ${GR_RUNTIME_DIR} diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/DataPlotter.py b/gnuradio-core/src/python/gnuradio/ctrlport/DataPlotter.py deleted file mode 100644 index c689bfa055..0000000000 --- a/gnuradio-core/src/python/gnuradio/ctrlport/DataPlotter.py +++ /dev/null @@ -1,382 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2012 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import sys - -try: - from PyQt4.QtCore import Qt; - from PyQt4 import QtGui, QtCore -except ImportError: - print "Error: Program requires PyQt4." - sys.exit(1) - -try: - import PyQt4.Qwt5 as Qwt - from PyQt4.Qwt5.anynumpy import * -except ImportError: - print "Error: Program requires PyQwt5." - sys.exit(1) - - -class Zoomer(Qwt.QwtPlotZoomer): - def __init__(self, a,b,c,d,e): - Qwt.QwtPlotZoomer.__init__(self,a,b,c,d,e); - self.zoomers = []; - - def zoom(self, r): - Qwt.QwtPlotZoomer.zoom(self,r); - if(r == 0): - #self.plot().setAxisAutoScale(True); - self.plot().setAxisAutoScale(Qwt.QwtPlot.xBottom) - self.plot().setAxisAutoScale(Qwt.QwtPlot.yLeft) - self.plot().replot(); - - -class DataPlotterBase(Qwt.QwtPlot): - DefaultColors = ( Qt.green, Qt.red, Qt.blue, - Qt.cyan, Qt.magenta, Qt.black, Qt.darkRed, - Qt.darkGray, Qt.darkGreen, Qt.darkBlue, Qt.yellow) - - dropSignal = QtCore.pyqtSignal(QtCore.QEvent) - - def contextMenuEvent(self,e): - menu = QtGui.QMenu(self); - menu.addAction(self.gridAct); - menu.addAction(self.axesAct); - menu.addAction(self.curvAct); - menu.exec_(e.globalPos()); - - def dragEnterEvent(self,e): - e.accept(); - - def dropEvent(self, e): - Qwt.QwtPlot.dropEvent(self,e) - self.dropSignal.emit( e ); - - - - def __init__(self, parent, title, xlabel, ylabel, size, x, y): - Qwt.QwtPlot.__init__(self, parent) - self.callback = None; - - self.gridAct = QtGui.QAction("Toggle &Grid", self, triggered=self.toggleGrid); - self.axesAct = QtGui.QAction("Toggle &Axes", self, triggered=self.toggleAxes); - self.curvAct = QtGui.QAction("Toggle &Lines", self, triggered=self.toggleCurve); - - # Set up the zoomer - self.zoomer = Zoomer(Qwt.QwtPlot.xBottom, - Qwt.QwtPlot.yLeft, - Qwt.QwtPicker.DragSelection, - Qwt.QwtPicker.AlwaysOff, - self.canvas()) - - # Crosshairs + Data labels - self.picker = Qwt.QwtPlotPicker( - Qwt.QwtPlot.xBottom, - Qwt.QwtPlot.yLeft, - Qwt.QwtPicker.PointSelection | Qwt.QwtPicker.DragSelection, - Qwt.QwtPlotPicker.CrossRubberBand, - Qwt.QwtPicker.AlwaysOn, - self.canvas()) - self.picker.setRubberBandPen(QtGui.QPen(QtCore.Qt.white, 1, QtCore.Qt.DashLine)) - self.picker.setTrackerPen(QtGui.QPen(QtCore.Qt.white)) - - self.axisEnable = False; - # Turn off bloated data labels - self.enableAxis(Qwt.QwtPlot.yLeft, False); - self.enableAxis(Qwt.QwtPlot.xBottom, False); - - # Allow panning with middle mouse - panner = Qwt.QwtPlotPanner(self.canvas()) - panner.setAxisEnabled(Qwt.QwtPlot.yRight, False) - panner.setMouseButton(Qt.MidButton) - - # Accept dropping of stats - self.setAcceptDrops(True); - self.grid = None - self.curve_en = False - self.setCanvasBackground(Qt.black) - - self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.TopLegend); - - self.axisEnabled(True); - - self.resize(size, size) - self.setAutoReplot(False) - self.show() - self.updateTimerInt = 500 - self.startTimer(self.updateTimerInt) - - # Set Axis on and Grid off by default - #self.toggleGrid(); - self.toggleAxes(); - - - def toggleAxes(self): - self.axisEnable = not self.axisEnable; - self.enableAxis(Qwt.QwtPlot.yLeft, self.axisEnable); - self.enableAxis(Qwt.QwtPlot.xBottom, self.axisEnable); - - - def toggleGrid(self): - # grid - if self.grid == None: - self.grid = Qwt.QwtPlotGrid() - self.grid.enableXMin(True) - self.grid.setMajPen(QtGui.QPen(Qt.gray, 0, Qt.DotLine)) - self.grid.setMinPen(QtGui.QPen(Qt.gray, 0 , Qt.DotLine)) - self.grid.attach(self) - else: - self.grid.detach() - self.grid = None - - return self - - def toggleCurve(self): - self.curve_en = not self.curve_en; - - -class DataPlotterVector(DataPlotterBase): - def __init__(self, parent, legend, title, xlabel, ylabel, size, x, y): - DataPlotterBase.__init__(self, parent, title, xlabel, ylabel, size, x, y) - self.curve = Qwt.QwtPlotCurve(legend) - self.curve.attach(self) - self.tag = None; - self.x = self.y = [0.0]; - - def offerData(self, data, tag): - if(tag == self.tag): - self.x = data[::2]; self.y = data[1::2] - - def timerEvent(self, e): - if(self.curve_en): - self.curve.setStyle(Qwt.QwtPlotCurve.Lines) - self.curve.setPen(QtGui.QPen(Qt.green)) - else: - self.curve.setStyle(Qwt.QwtPlotCurve.NoCurve) - - self.curve.setData(self.x, self.y) - self.replot() - - def enableLegend(self): - self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend); - return self - - def setSeries(self,tag,name): - self.tag = tag; - self.curve.setTitle(name) - - -class DataPlotterVectorOne(DataPlotterVector): - def __init__(self, parent, legend, title, xlabel, ylabel, size, x, y): - DataPlotterVector.__init__(self, parent, legend, title, xlabel, ylabel, size, x, y) - self.curve.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.XCross, - QtGui.QBrush(), QtGui.QPen(Qt.green), QtCore.QSize(2, 2))) - self.setAxisAutoScale(True) - self.axisSet = False; - - # Lines on by default - self.toggleCurve(); - - def offerData(self, data, tag): - if(tag == self.tag): - if not self.axisSet: - self.setAxisScale(1, 0, len(data)); - self.axisSet = True; - self.x = range(0,len(data)); - self.y = data; - - -class DataPlotterConst(DataPlotterVector): - def __init__(self, parent, legend, title, xlabel, ylabel, size, x, y): - DataPlotterVector.__init__(self, parent, legend, title, xlabel, ylabel, size, x, y) - self.x = arange(-2, 100.1, 2) - self.y = zeros(len(self.x), Float) - self.curve.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.XCross, - QtGui.QBrush(), QtGui.QPen(Qt.green), QtCore.QSize(2, 2))) - self.curve.setStyle(Qwt.QwtPlotCurve.NoCurve) - self.setAxisAutoScale(False) - -class DataPlotterEqTaps(DataPlotterVector): - def __init__(self, parent, legend, title, xlabel, ylabel, size, x, y, qtcolor): - DataPlotterVector.__init__(self, parent, legend, title, xlabel, ylabel, size, x, y) - self.x = arange(-.5, .5, 1) - self.y = zeros(len(self.x), Float) - self.curve.setPen(QtGui.QPen(qtcolor)) - -class DataPlotterTicker(DataPlotterBase): - def __init__(self, parent, title, xlabel, ylabel, size, x, y, seconds = 60): - DataPlotterBase.__init__(self, parent, title, xlabel, ylabel, size, x, y) - self.series = {} - self.setTimeScale(seconds) - -# AAAAAAAAAA - enable for legend at bottom -# self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend); - self.skipEvents=1 - - def setTimeScale(self, seconds): - intv = float(self.updateTimerInt) / 1000 - self.x = arange(0, seconds, intv) - #self.x = arange(0, seconds, 1) - return self - - def addSeries(self, tag, label, qtcolor = None, alpha = 1): - class Series: - def __init__(self, tag, label, qtcolor, x, plot): - self.vec = zeros(len(x), Float) - self.value = None - self.alpha = alpha - self.curve = Qwt.QwtPlotCurve(label) - self.curve.setPen(QtGui.QPen(qtcolor)) - self.plot = plot - - if qtcolor == None: qtcolor = self.DefaultColors[len(self.series)] - self.series[tag] = s = Series(tag, label, qtcolor, self.x, self) - self.enableSeries(tag) - return self - - def enableSeries(self, tag): - if self.hasSeries(tag): - s = self.series[tag] - s.enabled = True - s.curve.attach(s.plot) - return self - - def disableSeries(self, tag): - if self.hasSeries(tag): - s = self.series[tag] - s.enabled = False - s.curve.detach() - return self - - def toggleSeries(self,tag): - if self.seriesIsEnabled(tag): - self.disableSeries(tag) - else: - self.enableSeries(tag) - return self - - def timerEvent(self, e): - for k, v in self.series.iteritems(): - if v.value == None: continue - elif v.vec[0] == 0: v.vec = ones(len(v.vec), Float)*v.value - - prev = v.vec[0] - v.vec = concatenate((v.vec[:1], v.vec[:-1]), 1) - v.vec[0] = v.value*v.alpha + prev*(1-v.alpha) - self.series[k] = v - v.curve.setData(self.x, v.vec) - self.replot() - - def offerData(self, value, tag): - if(self.series.has_key(tag)): - if not value == NaN: - self.series[tag].value = value - #print "Data Offer %s items:"%(tag) - return self - - def hasSeries(self, tag): - return self.series.has_key(tag); - - def seriesIsEnabled(self, tag): - if self.hasSeries(tag): return self.series[tag].enabled - else: return False - -class DataPlotterTickerWithSeriesButtons(DataPlotterTicker): - def __init__(self, parent, title, xlabel, ylabel, size, x, y, seconds = 60): - DataPlotterTicker.__init__(self, parent, title, xlabel, ylabel, size, x, y, seconds) - DataPlotterTicker.setAcceptDrops(self,True); - self.buttonx = 50; self.buttony = 20; self.buttonSize = 16 - self.btns = [] - - - - - def addSeriesWithButton(self, tag, legend, qtcolor=None, alpha = 1): - self.addSeries(tag, legend, qtcolor, alpha) - lenbtns = len(self.btns) - - btn = QtGui.QToolButton(self) - btn.rank = lenbtns - btn.setText(str(btn.rank)) - btn.tag = tag - #btn.setIcon(Qt.QIcon(Qt.QPixmap(print_xpm))) - #btn.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) - #btn.setForegroundColor(Qt.red) - self.btns.append(btn) - btn.setGeometry(self.buttonx, self.buttony, self.buttonSize, self.buttonSize) - self.buttonx += self.buttonSize - - if lenbtns == 0: callback = self.print_0 - if lenbtns == 1: callback = self.print_1 - if lenbtns == 2: callback = self.print_2 - if lenbtns == 3: callback = self.print_3 - if lenbtns == 4: callback = self.print_4 - if lenbtns == 5: callback = self.print_5 - if lenbtns == 6: callback = self.print_6 - if lenbtns == 7: callback = self.print_7 - self.connect(btn, QtCore.SIGNAL('clicked()'), callback) - return self - - def toggleSeriesWithButton(self,btn): - DataPlotterTicker.toggleSeries(self, btn.tag) - - if self.seriesIsEnabled(btn.tag): - # btn.setForegroundRole(Qt.QPalette.NoRole) - btn.setText(str(btn.rank)) - else: - btn.setText('x') - # btn.setForegroundRole(Qt.QPalette.Light) - - def print_0(self): self.toggleSeriesWithButton(self.btns[0]) - def print_1(self): self.toggleSeriesWithButton(self.btns[1]) - def print_2(self): self.toggleSeriesWithButton(self.btns[2]) - def print_3(self): self.toggleSeriesWithButton(self.btns[3]) - def print_4(self): self.toggleSeriesWithButton(self.btns[4]) - def print_5(self): self.toggleSeriesWithButton(self.btns[5]) - def print_6(self): self.toggleSeriesWithButton(self.btns[6]) - def print_7(self): self.toggleSeriesWithButton(self.btns[7]) - -class DataPlotterValueTable: - def __init__(self, parent, x, y, xsize, ysize, headers=['Statistic Key ( Source Block :: Stat Name ) ', 'Curent Value', 'Units', 'Description']): - # must encapsulate, cuz Qt's bases are not classes - self.treeWidget = QtGui.QTreeWidget(parent) - self.treeWidget.setColumnCount(len(headers)) - self.treeWidget.setGeometry(x,y,xsize,ysize) - self.treeWidget.setHeaderLabels(headers) - self.treeWidget.resizeColumnToContents(0) - - def updateItems(self, knobs, knobprops): - # save previous selection if exists - sel = self.treeWidget.currentItem(); - row = self.treeWidget.indexOfTopLevelItem(sel); - items = []; - self.treeWidget.clear() - for k, v in knobs.iteritems(): - items.append(QtGui.QTreeWidgetItem([str(k), str(v.value), knobprops[k].units, knobprops[k].description])) - self.treeWidget.insertTopLevelItems(0, items) - # re-set previous selection if exists - if(row != -1): - try: - self.treeWidget.setCurrentItem(self.treeWidget.topLevelItem(row)); - except: - pass diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/ctrlport-monitor b/gnuradio-core/src/python/gnuradio/ctrlport/ctrlport-monitor deleted file mode 100755 index 0230c4cf7a..0000000000 --- a/gnuradio-core/src/python/gnuradio/ctrlport/ctrlport-monitor +++ /dev/null @@ -1,477 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import ctrlport - -from PyQt4.QtCore import Qt; -from PyQt4 import QtCore -import PyQt4.QtGui as QtGui -import sys, time, Ice, subprocess; -from gnuradio.ctrlport.IceRadioClient import *; -from gnuradio.ctrlport.DataPlotter import *; - -_gr_prefs = gr.prefs() -ice_directory = _gr_prefs.get_string('ctrlport', 'ice_directory', '') -print ice_directory -Ice.loadSlice(ice_directory + '/gnuradio.ice') - -import GNURadio - -class MAINWindow(QtGui.QMainWindow): - def minimumSizeHint(self): - return Qtgui.QSize(800,600); - def __init__(self, radio, port): - - super(MAINWindow, self).__init__() - self.plots = []; - - self.mdiArea = QtGui.QMdiArea() - self.mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - self.mdiArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - self.setCentralWidget(self.mdiArea) - - self.mdiArea.subWindowActivated.connect(self.updateMenus) - self.windowMapper = QtCore.QSignalMapper(self) - self.windowMapper.mapped[QtGui.QWidget].connect(self.setActiveSubWindow) - - self.createActions() - self.createMenus() - self.createToolBars() - self.createStatusBar() - self.updateMenus() - -# self.readSettings() - - self.setWindowTitle("GNU Radio Control Port Monitor") - self.setUnifiedTitleAndToolBarOnMac(True) - -# self.resize(QtCore.QSize(1024,768)); - - self.newCon(radio,port); -# self.mdiArea.addSubWindow(child); -# child.resize(QtCore.QSize(800,600)); - icon = QtGui.QIcon( ctrlport.__path__[0] + "/icon.png" ); - self.setWindowIcon(icon); - -# add empty plots ? -# self.plots = []; -# for i in range(3): -# self.newPlot(); - - def newCon(self,host=None,port=None): - child = MForm(host,port,self); - #child.setWindowTitle("Modem Connected :: %s:%s"%(host,port)); - child.setWindowTitle(str(host)); - self.mdiArea.addSubWindow(child); - child.resize(QtCore.QSize(800,600)); - child.showMaximized(); - return child; - - - def newUpd(self,k,r): - updater = UpdaterWindow(k,r,None); - updater.setWindowTitle("Updater: " + k); - self.mdiArea.addSubWindow(updater); - updater.show(); - - - def newSub(self,e): - tag = str(e.text(0)); - knobprop = self.knobprops[tag] - - if(type(knobprop.min) in [GNURadio.KnobVecB, GNURadio.KnobVecC, - GNURadio.KnobVecI,GNURadio.KnobVecF, - GNURadio.KnobVecD,GNURadio.KnobVecL]): - if(knobprop.display == ctrlport.DISPTIMESERIES): - #plot = self.newConstPlot(); - plot = self.newVecSeriesPlot(); - plot.setSeries(tag,tag); - plot.setWindowTitle(str(tag)); - else: # Plot others as XY for now - plot = self.newConstPlot(); - plot.setSeries(tag,tag); - plot.setWindowTitle(str(tag)); - elif(type(knobprop.min) in [GNURadio.KnobB,GNURadio.KnobC,GNURadio.KnobI, - GNURadio.KnobF,GNURadio.KnobD,GNURadio.KnobL]): - plot = self.newPlot(); - plot.addSeriesWithButton(tag, knobprop.description + ' (' + knobprop.units + ')', None, 1.0); - plot.setWindowTitle(str(tag)); - else: - print "WARNING: plotting of this knob-type not yet supported, ignoring attempt..." - - - def newVecSeriesPlot(self): - #plot = DataPlotterEqTaps(None, 'legend', 'title', 'xlabel', 'ylabel', 250, 0, 0, Qt.green) - plot = DataPlotterVectorOne(None, 'legend', 'title', 'xlabel', 'ylabel', 250, 0, 0); - self.mdiArea.addSubWindow(plot); - plot.dropSignal.connect(self.plotDropEvent ); - plot.show(); - self.plots.append(plot); - return plot; - - def newConstPlot(self): - plot = DataPlotterConst(None, 'legend', 'title', 'xlabel', 'ylabel', 250, 0, 0) - self.mdiArea.addSubWindow(plot); - plot.dropSignal.connect(self.plotDropEvent ); - plot.show(); - self.plots.append(plot); - return plot; - - def newPlot(self): - plot = DataPlotterTickerWithSeriesButtons(None,"",'units', '', 250,0,0,120); - self.mdiArea.addSubWindow(plot); - plot.dropSignal.connect(self.plotDropEvent ); - plot.show(); - self.plots.append(plot); - return plot; - - - def update(self, knobs): - for item in knobs.keys(): - for plot in self.plots: - plot.offerData( knobs[item].value, item ); - - def plotDropEvent(self, e): - model = QtGui.QStandardItemModel() - model.dropMimeData(e.mimeData(), QtCore.Qt.CopyAction,0,0,QtCore.QModelIndex()) - tag = str(QtGui.QTreeWidgetItem([model.item(0,0).text()]).text(0)); - knobprop = self.knobprops[tag] - try: - self.sender().addSeriesWithButton(tag, knobprop.description + ' (' + knobprop.units + ')', None, 1.0); - except: - print "This plot does not accept additional data items! ignoring..." - - - def setActiveSubWindow(self, window): - if window: - self.mdiArea.setActiveSubWindow(window) - - - def createActions(self): - self.newConAct = QtGui.QAction("&New Connection", - self, shortcut=QtGui.QKeySequence.New, - statusTip="Create a new file", triggered=self.newCon) - #self.newAct = QtGui.QAction(QtGui.QIcon(':/images/new.png'), "&New Plot", - self.newPlotAct = QtGui.QAction("&New Plot", - self, shortcut=QtGui.QKeySequence.New, - statusTip="Create a new file", triggered=self.newPlot) - - self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", - statusTip="Exit the application", - triggered=QtGui.qApp.closeAllWindows) - - self.closeAct = QtGui.QAction("Cl&ose", self, shortcut="Ctrl+F4", - statusTip="Close the active window", - triggered=self.mdiArea.closeActiveSubWindow) - - self.closeAllAct = QtGui.QAction("Close &All", self, - statusTip="Close all the windows", - triggered=self.mdiArea.closeAllSubWindows) - - - qks = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_T); - self.tileAct = QtGui.QAction("&Tile", self, - statusTip="Tile the windows", - triggered=self.mdiArea.tileSubWindows, - shortcut=qks) - - qks = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_C); - self.cascadeAct = QtGui.QAction("&Cascade", self, - statusTip="Cascade the windows", shortcut=qks, - triggered=self.mdiArea.cascadeSubWindows) - - self.nextAct = QtGui.QAction("Ne&xt", self, - shortcut=QtGui.QKeySequence.NextChild, - statusTip="Move the focus to the next window", - triggered=self.mdiArea.activateNextSubWindow) - - self.previousAct = QtGui.QAction("Pre&vious", self, - shortcut=QtGui.QKeySequence.PreviousChild, - statusTip="Move the focus to the previous window", - triggered=self.mdiArea.activatePreviousSubWindow) - - self.separatorAct = QtGui.QAction(self) - self.separatorAct.setSeparator(True) - - self.aboutAct = QtGui.QAction("&About", self, - statusTip="Show the application's About box", - triggered=self.about) - - self.aboutQtAct = QtGui.QAction("About &Qt", self, - statusTip="Show the Qt library's About box", - triggered=QtGui.qApp.aboutQt) - - def createMenus(self): - self.fileMenu = self.menuBar().addMenu("&File") - self.fileMenu.addAction(self.newConAct) - self.fileMenu.addAction(self.newPlotAct) - self.fileMenu.addSeparator() - self.fileMenu.addAction(self.exitAct) - - self.windowMenu = self.menuBar().addMenu("&Window") - self.updateWindowMenu() - self.windowMenu.aboutToShow.connect(self.updateWindowMenu) - - self.menuBar().addSeparator() - - self.helpMenu = self.menuBar().addMenu("&Help") - self.helpMenu.addAction(self.aboutAct) - self.helpMenu.addAction(self.aboutQtAct) - - - def createToolBars(self): - self.fileToolBar = self.addToolBar("File") - self.fileToolBar.addAction(self.newConAct) - self.fileToolBar.addAction(self.newPlotAct) - - self.fileToolBar = self.addToolBar("Window") - self.fileToolBar.addAction(self.tileAct) - self.fileToolBar.addAction(self.cascadeAct) - - def createStatusBar(self): - self.statusBar().showMessage("Ready") - - - def activeMdiChild(self): - activeSubWindow = self.mdiArea.activeSubWindow() - if activeSubWindow: - return activeSubWindow.widget() - return None - - def updateMenus(self): - hasMdiChild = (self.activeMdiChild() is not None) - self.closeAct.setEnabled(hasMdiChild) - self.closeAllAct.setEnabled(hasMdiChild) - self.tileAct.setEnabled(hasMdiChild) - self.cascadeAct.setEnabled(hasMdiChild) - self.nextAct.setEnabled(hasMdiChild) - self.previousAct.setEnabled(hasMdiChild) - self.separatorAct.setVisible(hasMdiChild) - - - def updateWindowMenu(self): - self.windowMenu.clear() - self.windowMenu.addAction(self.closeAct) - self.windowMenu.addAction(self.closeAllAct) - self.windowMenu.addSeparator() - self.windowMenu.addAction(self.tileAct) - self.windowMenu.addAction(self.cascadeAct) - self.windowMenu.addSeparator() - self.windowMenu.addAction(self.nextAct) - self.windowMenu.addAction(self.previousAct) - self.windowMenu.addAction(self.separatorAct) - - def about(self): - about_info = \ -'''Copyright 2012 Free Software Foundation, Inc.\n -This program is part of GNU Radio.\n -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.\n -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.\n -You should have received a copy of the GNU General Public License along with GNU Radio; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301, USA.''' - - QtGui.QMessageBox.about(None, "gr-ctrlport-monitor", about_info) - -class ConInfoDialog(QtGui.QDialog): - def __init__(self, parent=None): - super(ConInfoDialog, self).__init__(parent) - - self.gridLayout = QtGui.QGridLayout(self) - - - self.host = QtGui.QLineEdit(self); - self.port = QtGui.QLineEdit(self); - self.host.setText("localhost"); - self.port.setText("43243"); - - self.buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) - - self.gridLayout.addWidget(self.host); - self.gridLayout.addWidget(self.port); - self.gridLayout.addWidget(self.buttonBox); - - self.buttonBox.accepted.connect(self.accept) - self.buttonBox.rejected.connect(self.reject) - - - def accept(self): - self.done(1); - - def reject(self): - self.done(0); - -class UpdaterWindow(QtGui.QWidget): - def __init__(self, key, radio, parent): - QtGui.QWidget.__init__(self,parent) - - self.key = key; - self.radio = radio; - - self.resize(300,200) - self.layout = QtGui.QVBoxLayout(); - - self.textInput = QtGui.QLineEdit(); - self.setButton = QtGui.QPushButton("Set Value") - - rv = radio.get([key]); - self.textInput.setText(str(rv[key].value)); - self.sv = rv[key]; - - - self.props = radio.properties([key])[key]; - info = str(self.props); - - self.infoLabel = QtGui.QLabel(info); - self.layout.addWidget(self.infoLabel); - - self.layout.addWidget(self.textInput); - - self.setButton.connect(self.setButton, QtCore.SIGNAL('clicked()'), self._set) - - self.is_num = ((type(self.sv.value)==float) or (type(self.sv.value)==int)); - if(self.is_num): - self.sliderlayout = QtGui.QHBoxLayout(); - - self.slider = QtGui.QSlider(Qt.Horizontal); - - self.sliderlayout.addWidget(QtGui.QLabel(str(self.props.min.value))); - self.sliderlayout.addWidget(self.slider); - self.sliderlayout.addWidget(QtGui.QLabel(str(self.props.max.value))); - - - self.steps = 10000; - self.valspan = self.props.max.value - self.props.min.value; - - #self.slider.setRange( self.props.min.value, self.props.max.value ); - self.slider.setRange( 0,10000 ); - - self.slider.setValue( self.sv.value ); - self.slider.setValue( self.steps*(self.sv.value-self.props.min.value)/self.valspan); - - self.connect(self.slider, QtCore.SIGNAL("sliderReleased()"), self._slide); - - self.layout.addLayout(self.sliderlayout); - - self.layout.addWidget(self.setButton); - - # set layout and go... - self.setLayout(self.layout); - - def _slide(self): - val = (self.slider.value()*self.valspan + self.props.min.value)/float(self.steps); - self.textInput.setText(str(val)); - - def _set(self): - if(type(self.sv.value) == str): - val = str(self.textInput.text()); - elif(type(self.sv.value) == int): - val = int(round(float(self.textInput.text()))); - elif(type(self.sv.value) == float): - val = float(self.textInput.text()); - else: - print "set type not supported! (%s)"%(type(self.sv.value)); - sys.exit(-1); - #self.sv.value = int(val); - self.sv.value = val; - km = {}; - km[self.key] = self.sv; - self.radio.set(km); - -class MForm(QtGui.QWidget): - def update(self): - try: - st = time.time(); - knobs = self.radio.get([]); - ft = time.time(); - latency = ft-st; - self.parent.statusBar().showMessage("Current GNU Radio Control Port Query Latency: %f ms"%(latency*1000)) - - except Exception, e: - sys.stderr.write("ctrlport-monitor: radio.get threw exception ({0}).\n".format(e)) - if(type(self.parent) is MAINWindow): - # closing all of these seems to help control shutdown order. - self.parent.closeAct.trigger() - else: - sys.exit(1) - return - - tableitems = knobs.keys(); - - #UPDATE TABLE: - self.table.updateItems(knobs, self.knobprops) - - #UPDATE PLOTS - self.parent.update( knobs ); - - - def __init__(self, radio=None, port=None, parent=None): - - super(MForm, self).__init__() - - if(radio == None or port == None): - askinfo = ConInfoDialog(self); - if askinfo.exec_(): - print "connecting..." - radio = str(askinfo.host.text()); - port = str(askinfo.port.text()); - print "this is broken" - return; - else: - return; - - self.parent = parent; - self.horizontalLayout = QtGui.QVBoxLayout(self); - self.gridLayout = QtGui.QGridLayout() - - - self.radio = radio - self.knobprops = self.radio.properties([]) - self.parent.knobprops = self.knobprops; - self.resize(775,500) - self.timer = QtCore.QTimer() - self.constupdatediv = 0 - self.tableupdatediv = 0 - plotsize=250; - - - # make table - self.table = DataPlotterValueTable(self, 0, 0, 400, 200); - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) - self.table.treeWidget.setSizePolicy(sizePolicy); - self.table.treeWidget.setEditTriggers(QtGui.QAbstractItemView.EditKeyPressed); - self.table.treeWidget.setSortingEnabled(True); - self.table.treeWidget.setDragEnabled(True) - - # add things to layouts - self.horizontalLayout.addWidget(self.table.treeWidget); - - # set up timer - self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.update); - self.connect(self.table.treeWidget, QtCore.SIGNAL('itemDoubleClicked(QTreeWidgetItem*, int)'), self.parent.newSub); - - # set up context menu .. - self.table.treeWidget.setContextMenuPolicy(Qt.CustomContextMenu); - self.table.treeWidget.customContextMenuRequested.connect(self.openMenu); - - self.timer.start(2000) - - def plotDropEvent(self, e): - model = QtGui.QStandardItemModel() - model.dropMimeData(e.mimeData(), QtCore.Qt.CopyAction,0,0,QtCore.QModelIndex()) - tag = str(QtGui.QTreeWidgetItem([model.item(0,0).text()]).text(0)); - knobprop = self.knobprops[tag] - self.sender().addSeriesWithButton(tag, knobprop.description + ' (' + knobprop.units + ')', None, 1.0); - - def openMenu(self, pos): - index = self.table.treeWidget.selectedIndexes(); - item = self.table.treeWidget.itemFromIndex(index[0]); - itemname = str(item.text(0)); - self.parent.newUpd(itemname, self.radio); -# updater = UpdaterWindow(itemname, self.radio, self.parent); -# updater.setWindowTitle("Updater: " + itemname); -# self.parent.mdiArea.addSubWindow(updater); -# print "done" - - -class MyClient(IceRadioClient): - def __init__(self): IceRadioClient.__init__(self, MAINWindow) - -sys.exit(MyClient().main(sys.argv)) |