summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx')
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx293
1 files changed, 160 insertions, 133 deletions
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
index 3c807755db..cd704888bb 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
@@ -10,8 +10,13 @@
from argparse import ArgumentParser
-import sys, time, re, signal
-import random,math,operator
+import sys
+import time
+import re
+import signal
+import random
+import math
+import operator
from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient
@@ -29,11 +34,10 @@ try:
print(sys.argv[0], "could not load QTAgg backend.")
sys.exit(1)
-
from matplotlib.figure import Figure
except ImportError:
print(sys.argv[0], "requires networkx and matplotlib.",
- "Please check that they are installed and try again.")
+ "Please check that they are installed and try again.")
sys.exit(1)
from PyQt5 import QtCore, Qt
@@ -44,9 +48,10 @@ from gnuradio.ctrlport.GrDataPlotter import *
from networkx.drawing.nx_agraph import graphviz_layout
+
class MAINWindow(Qt.QMainWindow):
def minimumSizeHint(self):
- return Qt.QSize(800,600)
+ return Qt.QSize(800, 600)
def __init__(self, radioclient):
@@ -74,7 +79,7 @@ class MAINWindow(Qt.QMainWindow):
self.newCon(radioclient)
- icon = Qt.QIcon(ctrlport.__path__[0] + "/icon.png" )
+ icon = Qt.QIcon(ctrlport.__path__[0] + "/icon.png")
self.setWindowIcon(icon)
def newSubWindow(self, window, title):
@@ -96,55 +101,54 @@ class MAINWindow(Qt.QMainWindow):
if window:
self.mdiArea.setActiveSubWindow(window)
-
def createActions(self):
self.newConAct = Qt.QAction("&New Connection",
- self, shortcut=Qt.QKeySequence.New,
- statusTip="Create a new file", triggered=lambda x: self.newCon(None))
+ self, shortcut=Qt.QKeySequence.New,
+ statusTip="Create a new file", triggered=lambda x: self.newCon(None))
self.exitAct = Qt.QAction("E&xit", self, shortcut="Ctrl+Q",
- statusTip="Exit the application",
- triggered=Qt.qApp.closeAllWindows)
+ statusTip="Exit the application",
+ triggered=Qt.qApp.closeAllWindows)
self.closeAct = Qt.QAction("Cl&ose", self, shortcut="Ctrl+F4",
- statusTip="Close the active window",
- triggered=self.mdiArea.closeActiveSubWindow)
+ statusTip="Close the active window",
+ triggered=self.mdiArea.closeActiveSubWindow)
self.closeAllAct = Qt.QAction("Close &All", self,
- statusTip="Close all the windows",
- triggered=self.mdiArea.closeAllSubWindows)
+ statusTip="Close all the windows",
+ triggered=self.mdiArea.closeAllSubWindows)
qks = Qt.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_T)
self.tileAct = Qt.QAction("&Tile", self,
- statusTip="Tile the windows",
- triggered=self.mdiArea.tileSubWindows,
- shortcut=qks)
+ statusTip="Tile the windows",
+ triggered=self.mdiArea.tileSubWindows,
+ shortcut=qks)
qks = Qt.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_C)
self.cascadeAct = Qt.QAction("&Cascade", self,
- statusTip="Cascade the windows", shortcut=qks,
- triggered=self.mdiArea.cascadeSubWindows)
+ statusTip="Cascade the windows", shortcut=qks,
+ triggered=self.mdiArea.cascadeSubWindows)
self.nextAct = Qt.QAction("Ne&xt", self,
- shortcut=Qt.QKeySequence.NextChild,
- statusTip="Move the focus to the next window",
- triggered=self.mdiArea.activateNextSubWindow)
+ shortcut=Qt.QKeySequence.NextChild,
+ statusTip="Move the focus to the next window",
+ triggered=self.mdiArea.activateNextSubWindow)
self.previousAct = Qt.QAction("Pre&vious", self,
- shortcut=Qt.QKeySequence.PreviousChild,
- statusTip="Move the focus to the previous window",
- triggered=self.mdiArea.activatePreviousSubWindow)
+ shortcut=Qt.QKeySequence.PreviousChild,
+ statusTip="Move the focus to the previous window",
+ triggered=self.mdiArea.activatePreviousSubWindow)
self.separatorAct = Qt.QAction(self)
self.separatorAct.setSeparator(True)
self.aboutAct = Qt.QAction("&About", self,
- statusTip="Show the application's About box",
- triggered=self.about)
+ statusTip="Show the application's About box",
+ triggered=self.about)
self.aboutQtAct = Qt.QAction("About &Qt", self,
- statusTip="Show the Qt library's About box",
- triggered=Qt.qApp.aboutQt)
+ statusTip="Show the Qt library's About box",
+ triggered=Qt.qApp.aboutQt)
def createMenus(self):
self.fileMenu = self.menuBar().addMenu("&File")
@@ -173,7 +177,6 @@ class MAINWindow(Qt.QMainWindow):
def createStatusBar(self):
self.statusBar().showMessage("Ready")
-
def activeMdiChild(self):
activeSubWindow = self.mdiArea.activeSubWindow()
if activeSubWindow:
@@ -204,7 +207,7 @@ class MAINWindow(Qt.QMainWindow):
def about(self):
about_info = \
-'''Copyright 2012 Free Software Foundation, Inc.\n
+ '''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
@@ -219,14 +222,13 @@ class ConInfoDialog(Qt.QDialog):
self.gridLayout = Qt.QGridLayout(self)
-
self.host = Qt.QLineEdit(self)
self.port = Qt.QLineEdit(self)
self.host.setText("localhost")
self.port.setText("43243")
self.buttonBox = Qt.QDialogButtonBox(Qt.QDialogButtonBox.Ok |
- Qt.QDialogButtonBox.Cancel)
+ Qt.QDialogButtonBox.Cancel)
self.gridLayout.addWidget(self.host)
self.gridLayout.addWidget(self.port)
@@ -235,7 +237,6 @@ class ConInfoDialog(Qt.QDialog):
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
-
def accept(self):
self.done(1)
@@ -288,21 +289,22 @@ class DataTable(Qt.QWidget):
self.perfTable = Qt.QTableWidget()
self.perfTable.setColumnCount(2)
self.perfTable.verticalHeader().hide()
- self.perfTable.setHorizontalHeaderLabels( ["Block Name", "Percent Runtime"] )
+ self.perfTable.setHorizontalHeaderLabels(
+ ["Block Name", "Percent Runtime"])
self.perfTable.horizontalHeader().setStretchLastSection(True)
self.perfTable.setSortingEnabled(True)
nodes = self.G.nodes(data=True)
# set up plot
- self.f = plt.figure(figsize=(10,8), dpi=90)
+ self.f = plt.figure(figsize=(10, 8), dpi=90)
self.sp = self.f.add_subplot(111)
- self.sp.autoscale_view(True,True,True)
+ self.sp.autoscale_view(True, True, True)
self.sp.set_autoscale_on(True)
# set up tabs
self.tabber = Qt.QTabWidget()
self.layout.addWidget(self.tabber)
- self.tabber.addTab(self.perfTable,"Table View")
+ self.tabber.addTab(self.perfTable, "Table View")
self.tabber.addTab(self.f.canvas, "Graph View")
# set up timer
@@ -312,19 +314,21 @@ class DataTable(Qt.QWidget):
for i, node in enumerate(nodes):
self.perfTable.setItem(i, 0,
- Qt.QTableWidgetItem(node[0]))
+ Qt.QTableWidgetItem(node[0]))
- def table_update(self,data):
+ def table_update(self, data):
for k in data.keys():
weight = data[k]
- existing = self.perfTable.findItems(str(k),QtCore.Qt.MatchFixedString)
+ existing = self.perfTable.findItems(
+ str(k), QtCore.Qt.MatchFixedString)
if(len(existing) == 0):
i = self.perfTable.rowCount()
- self.perfTable.setRowCount( i+1)
- self.perfTable.setItem( i,0, Qt.QTableWidgetItem(str(k)))
- self.perfTable.setItem( i,1, Qt.QTableWidgetItem(str(weight)))
+ self.perfTable.setRowCount(i + 1)
+ self.perfTable.setItem(i, 0, Qt.QTableWidgetItem(str(k)))
+ self.perfTable.setItem(i, 1, Qt.QTableWidgetItem(str(weight)))
else:
- self.perfTable.setItem( self.perfTable.row(existing[0]),1, Qt.QTableWidgetItem(str(weight)))
+ self.perfTable.setItem(self.perfTable.row(
+ existing[0]), 1, Qt.QTableWidgetItem(str(weight)))
def stat_changed(self, index):
self._statistic = str(self.stattype.currentText())
@@ -332,22 +336,25 @@ class DataTable(Qt.QWidget):
def checksort_changed(self, state):
self._sort = state > 0
+
class DataTableBuffers(DataTable):
def __init__(self, radioclient, G):
super(DataTableBuffers, self).__init__(radioclient, G)
- self.perfTable.setHorizontalHeaderLabels( ["Block Name", "Percent Buffer Full"] )
+ self.perfTable.setHorizontalHeaderLabels(
+ ["Block Name", "Percent Buffer Full"])
def update(self):
nodes = self.G.nodes()
# get buffer fullness for all blocks
- kl = list(map(lambda x: "%s::%soutput %% full" % \
- (x, self._statistics_table[self._statistic]),
- nodes))
+ kl = list(map(lambda x: "%s::%soutput %% full" %
+ (x, self._statistics_table[self._statistic]),
+ nodes))
try:
buf_knobs = self.radioclient.getKnobs(kl)
except Exception as e:
- sys.stderr.write("gr-perf-monitorx: lost connection ({0}).\n".format(e))
+ sys.stderr.write(
+ "gr-perf-monitorx: lost connection ({0}).\n".format(e))
self.parentWidget().mdiArea().removeSubWindow(self.parentWidget())
self.close()
return
@@ -361,8 +368,8 @@ class DataTableBuffers(DataTable):
for blk in buffer_fullness:
bdata = buffer_fullness[blk]
if bdata:
- for port in range(0,len(bdata)):
- blockport_fullness["%s:%d"%(blk,port)] = bdata[port]
+ for port in range(0, len(bdata)):
+ blockport_fullness["%s:%d" % (blk, port)] = bdata[port]
if(self.perfTable.isVisible()):
self.table_update(blockport_fullness)
@@ -371,48 +378,54 @@ class DataTableBuffers(DataTable):
if(self._sort):
sorted_fullness = sorted(blockport_fullness.items(),
key=operator.itemgetter(1))
- self._keymap = list(map(operator.itemgetter(0), sorted_fullness))
+ self._keymap = list(
+ map(operator.itemgetter(0), sorted_fullness))
else:
if self._keymap:
- sorted_fullness = len(self._keymap)*['',]
+ sorted_fullness = len(self._keymap) * ['', ]
for b in blockport_fullness:
- sorted_fullness[self._keymap.index(b)] = (b, blockport_fullness[b])
+ sorted_fullness[self._keymap.index(b)] = (
+ b, blockport_fullness[b])
else:
sorted_fullness = blockport_fullness.items()
if(not self.disp):
- self.disp = self.sp.bar(range(0,len(sorted_fullness)),
- list(map(lambda x: x[1], sorted_fullness)),
+ self.disp = self.sp.bar(range(0, len(sorted_fullness)),
+ list(
+ map(lambda x: x[1], sorted_fullness)),
alpha=0.5, align='edge')
self.sp.set_ylabel("% Buffers Full")
- self.sp.set_xticks(list(map(lambda x: x+0.5, range(0,len(sorted_fullness)))))
+ self.sp.set_xticks(
+ list(map(lambda x: x + 0.5, range(0, len(sorted_fullness)))))
self.sp.set_xticklabels(list(map(lambda x: " " + x, map(lambda x: x[0], sorted_fullness))),
rotation="vertical", verticalalignment="bottom")
else:
self.sp.set_xticklabels(list(map(lambda x: " " + x, map(lambda x: x[0], sorted_fullness))),
rotation="vertical", verticalalignment="bottom")
- for r,w in zip(self.disp, sorted_fullness):
+ for r, w in zip(self.disp, sorted_fullness):
r.set_height(w[1])
self.f.canvas.draw()
+
class DataTableRuntimes(DataTable):
def __init__(self, radioclient, G):
- super(DataTableRuntimes, self).__init__( radioclient, G)
+ super(DataTableRuntimes, self).__init__(radioclient, G)
def update(self):
nodes = self.G.nodes()
# get work time for all blocks
- kl = list(map(lambda x: "%s::%swork time" % \
- (x, self._statistics_table[self._statistic]),
- nodes))
+ kl = list(map(lambda x: "%s::%swork time" %
+ (x, self._statistics_table[self._statistic]),
+ nodes))
try:
wrk_knobs = self.radioclient.getKnobs(kl)
except Exception as e:
- sys.stderr.write("gr-perf-monitorx: lost connection ({0}).\n".format(e))
+ sys.stderr.write(
+ "gr-perf-monitorx: lost connection ({0}).\n".format(e))
self.parentWidget().mdiArea().removeSubWindow(self.parentWidget())
self.close()
return
@@ -423,7 +436,7 @@ class DataTableRuntimes(DataTable):
total_work = 1
work_times = dict(zip(
map(lambda x: x.split("::")[0], wrk_knobs.keys()),
- map(lambda x: 1e-10 + x.value/total_work, wrk_knobs.values())))
+ map(lambda x: 1e-10 + x.value / total_work, wrk_knobs.values())))
# update table view
if(self.perfTable.isVisible()):
@@ -431,32 +444,35 @@ class DataTableRuntimes(DataTable):
else:
if(self._sort):
- sorted_work = sorted(work_times.items(), key=operator.itemgetter(1))
+ sorted_work = sorted(work_times.items(),
+ key=operator.itemgetter(1))
self._keymap = list(map(operator.itemgetter(0), sorted_work))
else:
if self._keymap:
- sorted_work = len(list(self._keymap))*['',]
+ sorted_work = len(list(self._keymap)) * ['', ]
for b in work_times:
sorted_work[self._keymap.index(b)] = (b, work_times[b])
else:
sorted_work = work_times.items()
if(not self.disp):
- self.disp = self.sp.bar(range(0,len(sorted_work)),
+ self.disp = self.sp.bar(range(0, len(sorted_work)),
list(map(lambda x: x[1], sorted_work)),
alpha=0.5, align='edge')
self.sp.set_ylabel("% Runtime")
- self.sp.set_xticks(list(map(lambda x: x+0.5, range(0,len(sorted_work)))))
+ self.sp.set_xticks(
+ list(map(lambda x: x + 0.5, range(0, len(sorted_work)))))
self.sp.set_xticklabels(list(map(lambda x: " " + x[0], sorted_work)),
- rotation="vertical", verticalalignment="bottom" )
+ rotation="vertical", verticalalignment="bottom")
else:
self.sp.set_xticklabels(list(map(lambda x: " " + x[0], sorted_work)),
- rotation="vertical", verticalalignment="bottom" )
- for r,w in zip(self.disp, sorted_work):
+ rotation="vertical", verticalalignment="bottom")
+ for r, w in zip(self.disp, sorted_work):
r.set_height(w[1])
self.f.canvas.draw()
+
class MForm(Qt.QWidget):
def update(self):
try:
@@ -470,7 +486,8 @@ class MForm(Qt.QWidget):
kl1 = self.radioclient.getKnobs([self.clockKey])
self.clockKey = list(kl1.keys())[0]
self.currClock = kl1[self.clockKey].value
- self.clockSelIdx = list(self.clocks.values()).index(self.currClock)
+ self.clockSelIdx = list(
+ self.clocks.values()).index(self.currClock)
self.clockSel.setCurrentIndex(self.clockSelIdx)
self.prevent_clock_change = False
except Exception as e:
@@ -481,9 +498,9 @@ class MForm(Qt.QWidget):
nodes_msg = self.G_msg.nodes()
# get current buffer depths of all output buffers
- kl = list(map(lambda x: "%s::%soutput %% full" % \
- (x, self._statistics_table[self._statistic]),
- nodes_stream))
+ kl = list(map(lambda x: "%s::%soutput %% full" %
+ (x, self._statistics_table[self._statistic]),
+ nodes_stream))
st = time.time()
buf_knobs = self.radioclient.getKnobs(kl)
@@ -495,9 +512,9 @@ class MForm(Qt.QWidget):
map(lambda x: x.value, buf_knobs.values())))
# get work time for all blocks
- kl = list(map(lambda x: "%s::%swork time" % \
- (x, self._statistics_table[self._statistic]),
- nodes_stream))
+ kl = list(map(lambda x: "%s::%swork time" %
+ (x, self._statistics_table[self._statistic]),
+ nodes_stream))
st = time.time()
wrk_knobs = self.radioclient.getKnobs(kl)
td2 = time.time() - st
@@ -507,18 +524,18 @@ class MForm(Qt.QWidget):
if(total_work == 0):
total_work = 1
work_times = dict(zip(
- map(lambda x: x.split("::")[0], wrk_knobs.keys()),
- map(lambda x: x.value/total_work, wrk_knobs.values())))
+ map(lambda x: x.split("::")[0], wrk_knobs.keys()),
+ map(lambda x: x.value / total_work, wrk_knobs.values())))
work_times_padded = dict(zip(
- self.G.nodes(),
- [0.1]*len(self.G.nodes())))
+ self.G.nodes(),
+ [0.1] * len(self.G.nodes())))
work_times_padded.update(work_times)
for n in nodes_stream:
# ne is the list of edges away from this node!
- ne = self.G.edges([n],True)
- #for e in ne: # iterate over edges from this block
- for e in ne: # iterate over edges from this block
+ ne = self.G.edges([n], True)
+ # for e in ne: # iterate over edges from this block
+ for e in ne: # iterate over edges from this block
# get the right output buffer/port weight for each edge
sourceport = e[2]["sourceport"]
if(e[2]["type"] == "stream"):
@@ -526,8 +543,8 @@ class MForm(Qt.QWidget):
e[2]["weight"] = newweight
for n in nodes_msg:
- ne = self.G.edges([n],True)
- for e in ne: # iterate over edges from this block
+ ne = self.G.edges([n], True)
+ for e in ne: # iterate over edges from this block
sourceport = e[2]["sourceport"]
if(e[2]["type"] == "msg"):
newweight = 0.01
@@ -535,8 +552,10 @@ class MForm(Qt.QWidget):
# set updated weights
#self.node_weights = map(lambda x: 20+2000*work_times[x], nodes_stream)
- self.node_weights = list(map(lambda x: 20+2000*work_times_padded[x], self.G.nodes()))
- self.edge_weights = list(map(lambda x: 100.0*x[2]["weight"], self.G.edges(data=True)))
+ self.node_weights = list(
+ map(lambda x: 20 + 2000 * work_times_padded[x], self.G.nodes()))
+ self.edge_weights = list(
+ map(lambda x: 100.0 * x[2]["weight"], self.G.edges(data=True)))
# draw graph updates
if(self.do_update):
@@ -545,11 +564,12 @@ class MForm(Qt.QWidget):
self.updateGraph()
latency = td1 + td2
- self.parent.statusBar().showMessage("Current GNU Radio Control Port Query Latency: %f ms"%\
- (latency*1000))
+ self.parent.statusBar().showMessage("Current GNU Radio Control Port Query Latency: %f ms" %
+ (latency * 1000))
except Exception as e:
- sys.stderr.write("gr-perf-monitorx: lost connection ({0}).\n".format(e))
+ sys.stderr.write(
+ "gr-perf-monitorx: lost connection ({0}).\n".format(e))
if(type(self.parent) is MAINWindow):
# Find window of connection
for p in self.parent.mdiArea.subWindowList():
@@ -562,15 +582,17 @@ class MForm(Qt.QWidget):
return
def rtt(self):
- self.parent.newSubWindow(DataTableRuntimes(self.radioclient, self.G_stream), "Runtime Table")
+ self.parent.newSubWindow(DataTableRuntimes(
+ self.radioclient, self.G_stream), "Runtime Table")
def bpt(self):
- self.parent.newSubWindow(DataTableBuffers(self.radioclient, self.G_stream), "Buffers Table")
+ self.parent.newSubWindow(DataTableBuffers(
+ self.radioclient, self.G_stream), "Buffers Table")
def resetPCs(self):
knobs = []
for b in self.blocks_list:
- knobs += [self.radioclient.Knob(b + "::reset_perf_counters"),]
+ knobs += [self.radioclient.Knob(b + "::reset_perf_counters"), ]
k = self.radioclient.setKnobs(knobs)
def toggleFlowgraph(self):
@@ -614,13 +636,13 @@ class MForm(Qt.QWidget):
host = str(askinfo.host.text())
port = str(askinfo.port.text())
try:
- self.radioclient = GNURadioControlPortClient(host, port, 'thrift').client
+ self.radioclient = GNURadioControlPortClient(
+ host, port, 'thrift').client
print("Connected to %s:%s" % (host, port))
except:
print("Error connecting to %s:%s" % (host, port))
else:
self.radioclient = radioclient
-
if self.radioclient is None:
return
@@ -635,27 +657,27 @@ class MForm(Qt.QWidget):
self.layoutTop.addLayout(self.layout)
self.rttAct = Qt.QAction("Runtime Table",
- self, statusTip="Runtime Table", triggered=self.rtt)
+ self, statusTip="Runtime Table", triggered=self.rtt)
self.rttBut = Qt.QToolButton()
self.rttBut.setDefaultAction(self.rttAct)
self.ctlBox.addWidget(self.rttBut)
self.bptAct = Qt.QAction("Buffer Table",
- self, statusTip="Buffer Table", triggered=self.bpt)
+ self, statusTip="Buffer Table", triggered=self.bpt)
self.bptBut = Qt.QToolButton()
self.bptBut.setDefaultAction(self.bptAct)
self.ctlBox.addWidget(self.bptBut)
self.resetPCsAct = Qt.QAction("Reset", self,
- statusTip="Reset all Performance Counters",
- triggered=self.resetPCs)
+ statusTip="Reset all Performance Counters",
+ triggered=self.resetPCs)
self.resetPCsBut = Qt.QToolButton()
self.resetPCsBut.setDefaultAction(self.resetPCsAct)
self.ctlBox.addWidget(self.resetPCsBut)
self.pauseFGAct = Qt.QAction("Pause", self,
- statusTip="Pause the Flowgraph",
- triggered=self.toggleFlowgraph)
+ statusTip="Pause the Flowgraph",
+ triggered=self.toggleFlowgraph)
self.pauseFGAct.setCheckable(True)
self.pauseFGBut = Qt.QToolButton()
self.pauseFGBut.setDefaultAction(self.pauseFGAct)
@@ -663,7 +685,7 @@ class MForm(Qt.QWidget):
self.prevent_clock_change = True
self.clockKey = None
- self.clocks = {"MONOTONIC":1, "THREAD":3}
+ self.clocks = {"MONOTONIC": 1, "THREAD": 3}
self.clockSel = Qt.QComboBox(self)
list(map(lambda x: self.clockSel.addItem(x), self.clocks.keys()))
self.ctlBox.addWidget(self.clockSel)
@@ -691,15 +713,14 @@ class MForm(Qt.QWidget):
self.timer = QtCore.QTimer()
self.constupdatediv = 0
self.tableupdatediv = 0
- plotsize=250
-
+ plotsize = 250
# Set up the graph of blocks
- input_name = lambda x: x+"::avg input % full"
- output_name = lambda x: x+"::avg output % full"
- wtime_name = lambda x: x+"::avg work time"
- nout_name = lambda x: x+"::avg noutput_items"
- nprod_name = lambda x: x+"::avg nproduced"
+ def input_name(x): return x + "::avg input % full"
+ def output_name(x): return x + "::avg output % full"
+ def wtime_name(x): return x + "::avg work time"
+ def nout_name(x): return x + "::avg noutput_items"
+ def nprod_name(x): return x + "::avg nproduced"
tmplist = []
knobs = self.radio.getKnobs([])
@@ -719,11 +740,10 @@ class MForm(Qt.QWidget):
if(input_name(blockname) in knobs):
tmplist.append(blockname)
-
if not edgelist:
- sys.stderr.write("Could not find list of edges from flowgraph. " + \
- "Make sure the option 'edges_list' is enabled " + \
- "in the ControlPort configuration.\n\n")
+ sys.stderr.write("Could not find list of edges from flowgraph. " +
+ "Make sure the option 'edges_list' is enabled " +
+ "in the ControlPort configuration.\n\n")
sys.exit(1)
self.blocks_list = tmplist
@@ -736,12 +756,14 @@ class MForm(Qt.QWidget):
# add stream connections
for e in edges:
_e = e.split("->")
- edgepairs_stream.append( (_e[0].split(":")[0], _e[1].split(":")[0], {"type":"stream", "sourceport":int(_e[0].split(":")[1])}) )
+ edgepairs_stream.append((_e[0].split(":")[0], _e[1].split(
+ ":")[0], {"type": "stream", "sourceport": int(_e[0].split(":")[1])}))
# add msg connections
for e in msgedges:
_e = e.split("->")
- edgepairs_msg.append( (_e[0].split(":")[0], _e[1].split(":")[0], {"type":"msg", "sourceport":_e[0].split(":")[1]}) )
+ edgepairs_msg.append((_e[0].split(":")[0], _e[1].split(":")[0], {
+ "type": "msg", "sourceport": _e[0].split(":")[1]}))
self.G = nx.MultiDiGraph()
self.G_stream = nx.MultiDiGraph()
@@ -755,14 +777,14 @@ class MForm(Qt.QWidget):
n_edges = self.G.edges(data=True)
for e in n_edges:
- e[2]["weight"] = 5+random.random()*10
+ e[2]["weight"] = 5 + random.random() * 10
self.G = nx.MultiDiGraph()
self.G.add_edges_from(n_edges)
- self.f = plt.figure(figsize=(10,8), dpi=90)
+ self.f = plt.figure(figsize=(10, 8), dpi=90)
self.sp = self.f.add_subplot(111)
- self.sp.autoscale_view(True,True,True)
+ self.sp.autoscale_view(True, True, True)
self.sp.set_autoscale_on(True)
self.layout.addWidget(self.f.canvas)
@@ -799,26 +821,26 @@ class MForm(Qt.QWidget):
thrsh = 100
if(x is not None and y is not None):
- nearby = list(map(lambda z: math.sqrt( math.pow(x-z[0],2) + math.pow(y-z[1],2)), self.pos.values()))
+ nearby = list(map(lambda z: math.sqrt(
+ math.pow(x - z[0], 2) + math.pow(y - z[1], 2)), self.pos.values()))
i = nearby.index(min(nearby))
if(abs(list(self.pos.values())[i][0] - x) < thrsh and
- abs(list(self.pos.values())[i][1]-y) < thrsh):
+ abs(list(self.pos.values())[i][1] - y) < thrsh):
self._current_block = list(self.pos.keys())[i]
- #print "MOVING BLOCK: ", self._current_block
- #print "CUR POS: ", self.pos.values()[i]
+ # print "MOVING BLOCK: ", self._current_block
+ # print "CUR POS: ", self.pos.values()[i]
self._grabbed = True
def mouse_move(self, event):
if self._grabbed:
x, y = event.xdata, event.ydata
if(x is not None and y is not None):
- self.pos[self._current_block] = (x,y)
+ self.pos[self._current_block] = (x, y)
self.updateGraph()
def button_release(self, event):
self._grabbed = False
-
def openMenu(self, pos):
index = self.table.treeWidget.selectedIndexes()
item = self.table.treeWidget.itemFromIndex(index[0])
@@ -835,13 +857,14 @@ class MForm(Qt.QWidget):
nx.draw(self.G, self.pos,
edge_color=self.edge_weights,
node_color='#A0CBE2',
- width=list(map(lambda x: 3+math.log(x+1e-20), self.edge_weights)),
+ width=list(
+ map(lambda x: 3 + math.log(x + 1e-20), self.edge_weights)),
node_shape="s",
node_size=self.node_weights,
edge_cmap=plt.cm.Reds,
ax=self.sp,
arrows=False
- )
+ )
nx.draw_networkx_labels(self.G, self.pos,
font_size=12)
@@ -859,7 +882,8 @@ class MForm(Qt.QWidget):
nx.draw_networkx_edges(self.G, self.pos,
edge_color=self.edge_weights,
- width=list(map(lambda x: 3+math.log(x+1e-20), self.edge_weights)),
+ width=list(
+ map(lambda x: 3 + math.log(x + 1e-20), self.edge_weights)),
edge_cmap=plt.cm.Reds,
ax=self.sp,
arrows=False)
@@ -874,7 +898,8 @@ class MyApp(object):
def __init__(self, args):
parser = ArgumentParser(description="GNU Radio Performance Monitor")
- parser.add_argument("host", nargs="?", default="localhost", help="host name or IP")
+ parser.add_argument("host", nargs="?",
+ default="localhost", help="host name or IP")
parser.add_argument("port", help="port")
args = parser.parse_args()
@@ -882,7 +907,8 @@ class MyApp(object):
signal.signal(signal.SIGTERM, signal.SIG_DFL)
try:
- GNURadioControlPortClient(args.host, args.port, 'thrift', self.run, Qt.QApplication(sys.argv).exec_)
+ GNURadioControlPortClient(
+ args.host, args.port, 'thrift', self.run, Qt.QApplication(sys.argv).exec_)
except:
print("ControlPort failed to connect. Check the config of your endpoint.")
print("\t[ControlPort] on = True")
@@ -894,4 +920,5 @@ class MyApp(object):
def run(self, client):
MAINWindow(client).show()
+
MyApp(sys.argv)