[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 09/50: controlport: cleanup and switching o
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 09/50: controlport: cleanup and switching over to new Python common interface. |
Date: |
Wed, 15 Apr 2015 21:07:52 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 490fe7fb527f629f6ba8fb804f33a51822e3b8ae
Author: Tom Rondeau <address@hidden>
Date: Sun Feb 22 11:57:01 2015 -0500
controlport: cleanup and switching over to new Python common interface.
---
gnuradio-runtime/lib/block.cc | 12 +-
.../lib/controlport/thrift/gnuradio.thrift | 4 +-
.../controlport/thrift/rpcpmtconverters_thrift.cc | 15 ++-
.../python/gnuradio/ctrlport/CMakeLists.txt | 26 ++--
.../gnuradio/ctrlport/GNURadioControlPortClient.py | 58 ++++++---
.../python/gnuradio/ctrlport/GrDataPlotter.py | 6 +-
.../python/gnuradio/ctrlport/gr-perf-monitorx | 132 ++++++++++-----------
7 files changed, 145 insertions(+), 108 deletions(-)
diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc
index f26d6bb..6edb739 100644
--- a/gnuradio-runtime/lib/block.cc
+++ b/gnuradio-runtime/lib/block.cc
@@ -842,42 +842,42 @@ namespace gr {
d_rpc_vars.push_back(
rpcbasic_sptr(new rpcbasic_register_get<block, std::vector<float> >(
alias(), "input \% full", &block::pc_input_buffers_full,
- pmt::make_c32vector(0,0), pmt::make_c32vector(0,1),
pmt::make_c32vector(0,0),
+ pmt::make_f32vector(0,0), pmt::make_f32vector(0,1),
pmt::make_f32vector(0,0),
"", "how full input buffers are", RPC_PRIVLVL_MIN,
DISPTIME | DISPOPTSTRIP)));
d_rpc_vars.push_back(
rpcbasic_sptr(new rpcbasic_register_get<block, std::vector<float> >(
alias(), "avg input \% full", &block::pc_input_buffers_full_avg,
- pmt::make_c32vector(0,0), pmt::make_c32vector(0,1),
pmt::make_c32vector(0,0),
+ pmt::make_f32vector(0,0), pmt::make_f32vector(0,1),
pmt::make_f32vector(0,0),
"", "Average of how full input buffers are", RPC_PRIVLVL_MIN,
DISPTIME | DISPOPTSTRIP)));
d_rpc_vars.push_back(
rpcbasic_sptr(new rpcbasic_register_get<block, std::vector<float> >(
alias(), "var input \% full", &block::pc_input_buffers_full_var,
- pmt::make_c32vector(0,0), pmt::make_c32vector(0,1),
pmt::make_c32vector(0,0),
+ pmt::make_f32vector(0,0), pmt::make_f32vector(0,1),
pmt::make_f32vector(0,0),
"", "Var. of how full input buffers are", RPC_PRIVLVL_MIN,
DISPTIME | DISPOPTSTRIP)));
d_rpc_vars.push_back(
rpcbasic_sptr(new rpcbasic_register_get<block, std::vector<float> >(
alias(), "output \% full", &block::pc_output_buffers_full,
- pmt::make_c32vector(0,0), pmt::make_c32vector(0,1),
pmt::make_c32vector(0,0),
+ pmt::make_f32vector(0,0), pmt::make_f32vector(0,1),
pmt::make_f32vector(0,0),
"", "how full output buffers are", RPC_PRIVLVL_MIN,
DISPTIME | DISPOPTSTRIP)));
d_rpc_vars.push_back(
rpcbasic_sptr(new rpcbasic_register_get<block, std::vector<float> >(
alias(), "avg output \% full", &block::pc_output_buffers_full_avg,
- pmt::make_c32vector(0,0), pmt::make_c32vector(0,1),
pmt::make_c32vector(0,0),
+ pmt::make_f32vector(0,0), pmt::make_f32vector(0,1),
pmt::make_f32vector(0,0),
"", "Average of how full output buffers are", RPC_PRIVLVL_MIN,
DISPTIME | DISPOPTSTRIP)));
d_rpc_vars.push_back(
rpcbasic_sptr(new rpcbasic_register_get<block, std::vector<float> >(
alias(), "var output \% full", &block::pc_output_buffers_full_var,
- pmt::make_c32vector(0,0), pmt::make_c32vector(0,1),
pmt::make_c32vector(0,0),
+ pmt::make_f32vector(0,0), pmt::make_f32vector(0,1),
pmt::make_f32vector(0,0),
"", "Var. of how full output buffers are", RPC_PRIVLVL_MIN,
DISPTIME | DISPOPTSTRIP)));
#endif /* defined(GR_CTRLPORT) && defined(GR_PERFORMANCE_COUNTERS) */
diff --git a/gnuradio-runtime/lib/controlport/thrift/gnuradio.thrift
b/gnuradio-runtime/lib/controlport/thrift/gnuradio.thrift
index 141dc3a..f261229 100644
--- a/gnuradio-runtime/lib/controlport/thrift/gnuradio.thrift
+++ b/gnuradio-runtime/lib/controlport/thrift/gnuradio.thrift
@@ -37,7 +37,9 @@ typedef list<double> VectorD
typedef list<string> VectorS
typedef list<complex> VectorZ
-enum BaseTypes { BOOL, BYTE, SHORT, INT, LONG, DOUBLE, STRING, COMPLEX }
+enum BaseTypes { BOOL, BYTE, SHORT, INT, LONG, DOUBLE, STRING, COMPLEX,
+ F32VECTOR, F64VECTOR, S64VECTOR, S32VECTOR, S16VECTOR,
+ S8VECTOR, C32VECTOR }
union KnobBase {
1: bool a_bool;
diff --git a/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc
b/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc
index 213dca0..9025784 100644
--- a/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc
+++ b/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc
@@ -28,7 +28,6 @@ GNURadio::Knob
rpcpmtconverter::from_pmt(const pmt::pmt_t& knob)
{
if(pmt::is_real(knob)) {
-
GNURadio::Knob result;
result.type = GNURadio::BaseTypes::DOUBLE;
result.value.__set_a_double(pmt::to_double(knob));
@@ -71,6 +70,7 @@ rpcpmtconverter::from_pmt(const pmt::pmt_t& knob)
}
else if(pmt::is_f32vector(knob)) {
GNURadio::Knob result;
+ result.type = GNURadio::BaseTypes::F32VECTOR;
size_t size(pmt::length(knob));
const float* start((const float*)pmt::f32vector_elements(knob,size));
result.value.__set_a_f32vector(std::vector<double>(start,start+size));
@@ -78,6 +78,7 @@ rpcpmtconverter::from_pmt(const pmt::pmt_t& knob)
}
else if(pmt::is_f64vector(knob)) {
GNURadio::Knob result;
+ result.type = GNURadio::BaseTypes::F64VECTOR;
size_t size(pmt::length(knob));
const double* start((const double*)pmt::f64vector_elements(knob,size));
result.value.__set_a_f64vector(std::vector<double>(start,start+size));
@@ -85,6 +86,7 @@ rpcpmtconverter::from_pmt(const pmt::pmt_t& knob)
}
else if(pmt::is_s64vector(knob)) {
GNURadio::Knob result;
+ result.type = GNURadio::BaseTypes::S64VECTOR;
size_t size(pmt::length(knob));
const int64_t* start((const int64_t*)pmt::s64vector_elements(knob,size));
result.value.__set_a_s64vector(std::vector<int64_t>(start,start+size));
@@ -92,6 +94,7 @@ rpcpmtconverter::from_pmt(const pmt::pmt_t& knob)
}
else if(pmt::is_s32vector(knob)) {
GNURadio::Knob result;
+ result.type = GNURadio::BaseTypes::S32VECTOR;
size_t size(pmt::length(knob));
const int32_t* start((const int32_t*)pmt::s32vector_elements(knob,size));
result.value.__set_a_s32vector(std::vector<int32_t>(start,start+size));
@@ -99,6 +102,7 @@ rpcpmtconverter::from_pmt(const pmt::pmt_t& knob)
}
else if(pmt::is_s16vector(knob)) {
GNURadio::Knob result;
+ result.type = GNURadio::BaseTypes::S16VECTOR;
size_t size(pmt::length(knob));
const int16_t* start((const int16_t*)pmt::s16vector_elements(knob,size));
result.value.__set_a_s16vector(std::vector<int16_t>(start,start+size));
@@ -106,6 +110,7 @@ rpcpmtconverter::from_pmt(const pmt::pmt_t& knob)
}
else if(pmt::is_s8vector(knob)) {
GNURadio::Knob result;
+ result.type = GNURadio::BaseTypes::S8VECTOR;
size_t size(pmt::length(knob));
const int8_t* start((const int8_t*)pmt::s8vector_elements(knob,size));
result.value.__set_a_s8vector(std::vector<int8_t>(start,start+size));
@@ -115,6 +120,7 @@ rpcpmtconverter::from_pmt(const pmt::pmt_t& knob)
std::vector< GNURadio::complex > z;
GNURadio::Knob result;
+ result.type = GNURadio::BaseTypes::C32VECTOR;
size_t size(pmt::length(knob));
const gr_complex* start((const
gr_complex*)pmt::c32vector_elements(knob,size));
for(size_t s = 0; s < size; s++) {
@@ -137,7 +143,6 @@ rpcpmtconverter::from_pmt(const pmt::pmt_t& knob)
pmt::pmt_t
rpcpmtconverter::to_pmt(const GNURadio::Knob& knob)
{
-
if(knob.type == GNURadio::BaseTypes::BYTE) {
return pmt::mp(knob.value.a_byte);
}
@@ -166,6 +171,12 @@ rpcpmtconverter::to_pmt(const GNURadio::Knob& knob)
gr_complexd cpx(knob.value.a_complex.re, knob.value.a_complex.im);
return pmt::from_complex(cpx);
}
+ else if(knob.type == GNURadio::BaseTypes::F32VECTOR) {
+ if (knob.value.a_bool)
+ return pmt::PMT_T;
+ else
+ return pmt::PMT_F;
+ }
else {
std::cerr << "Error: Don't know how to handle Knob Type: " << knob.type <<
std::endl; assert(0);
}
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt
b/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt
index 69a6107..225f3b0 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/CMakeLists.txt
@@ -20,16 +20,6 @@
########################################################################
include(GrPython)
-if(THRIFT_FOUND)
-
-EXECUTE_PROCESS(
- COMMAND ${THRIFT_BIN} --gen py -out ${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/controlport/thrift/gnuradio.thrift
- OUTPUT_VARIABLE THRIFT_PY_OUTPUT
- ERROR_VARIABLE THRIFT_PY_ERROR
- )
-
-endif(THRIFT_FOUND)
-
install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/icon.png
@@ -37,12 +27,13 @@ install(
COMPONENT "runtime_python"
)
+
GR_PYTHON_INSTALL(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/__init__.py
${CMAKE_CURRENT_SOURCE_DIR}/GrDataPlotter.py
${CMAKE_CURRENT_SOURCE_DIR}/monitor.py
- ${CMAKE_CURRENT_SOURCE_DIR}/ThriftRadioClient.py
+ ${CMAKE_CURRENT_SOURCE_DIR}/GNURadioControlPortClient.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/
COMPONENT "runtime_python"
)
@@ -50,14 +41,23 @@ GR_PYTHON_INSTALL(
GR_PYTHON_INSTALL(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/gr-perf-monitorx
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr-ctrlport-monitor
DESTINATION ${GR_RUNTIME_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
COMPONENT "runtime_python"
)
-# Install the files compiled from gnuradio.thrift
+if(THRIFT_FOUND)
+
+EXECUTE_PROCESS(
+ COMMAND ${THRIFT_BIN} --gen py -out ${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/controlport/thrift/gnuradio.thrift
+ OUTPUT_VARIABLE THRIFT_PY_OUTPUT
+ ERROR_VARIABLE THRIFT_PY_ERROR
+ )
+
GR_PYTHON_INSTALL(
FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/ThriftRadioClient.py
${CMAKE_CURRENT_BINARY_DIR}/GNURadio/__init__.py
${CMAKE_CURRENT_BINARY_DIR}/GNURadio/constants.py
${CMAKE_CURRENT_BINARY_DIR}/GNURadio/ControlPort.py
@@ -68,3 +68,5 @@ GR_PYTHON_INSTALL(
DESTINATION ${GR_PYTHON_DIR}/gnuradio/ctrlport/GNURadio
COMPONENT "runtime_python"
)
+
+endif(THRIFT_FOUND)
diff --git
a/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py
b/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py
index 3cf5186..b9d0e40 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py
@@ -128,6 +128,8 @@ Args:
host: hostname of the connection
"""
+from gnuradio.ctrlport.GNURadio.ttypes import BaseTypes
+
class RPCConnectionThrift(RPCConnection):
def __init__(self, host=None, port=None):
if port is None: port = 9090
@@ -148,29 +150,51 @@ class RPCConnectionThrift(RPCConnection):
result = {}
for key, knob in self.thriftclient.radio.getKnobs(*args).iteritems():
- if knob.type == 0: result[key] = Knob(key, knob.value.a_bool)
- elif knob.type == 1: result[key] = Knob(key, knob.value.a_byte)
- elif knob.type == 2: result[key] = Knob(key, knob.value.a_short)
- elif knob.type == 3: result[key] = Knob(key, knob.value.a_int)
- elif knob.type == 4: result[key] = Knob(key, knob.value.a_long)
- elif knob.type == 5: result[key] = Knob(key, knob.value.a_double)
- elif knob.type == 6: result[key] = Knob(key, knob.value.a_string)
- elif knob.type == 7: result[key] = Knob(key, knob.value.a_complex)
- elif knob.type == 8: result[key] = Knob(key,
knob.value.a_f32vector)
- elif knob.type == 9: result[key] = Knob(key,
knob.value.a_f64vector)
- elif knob.type == 10: result[key] = Knob(key,
knob.value.a_s64vector)
- elif knob.type == 11: result[key] = Knob(key,
knob.value.a_s32vector)
- elif knob.type == 12: result[key] = Knob(key,
knob.value.a_s16vector)
- elif knob.type == 13: result[key] = Knob(key,
knob.value.a_s8vector)
- elif knob.type == 14: result[key] = Knob(key,
knob.value.a_s32vector)
- elif knob.type == 15: result[key] = Knob(key, knob.value.byte)
+ if knob.type == BaseTypes.BOOL: result[key] = Knob(key,
knob.value.a_bool)
+ elif knob.type == BaseTypes.BYTE: result[key] = Knob(key,
knob.value.a_byte)
+ elif knob.type == BaseTypes.SHORT: result[key] = Knob(key,
knob.value.a_short)
+ elif knob.type == BaseTypes.INT: result[key] = Knob(key,
knob.value.a_int)
+ elif knob.type == BaseTypes.LONG: result[key] = Knob(key,
knob.value.a_long)
+ elif knob.type == BaseTypes.DOUBLE: result[key] = Knob(key,
knob.value.a_double)
+ elif knob.type == BaseTypes.STRING: result[key] = Knob(key,
knob.value.a_string)
+ elif knob.type == BaseTypes.COMPLEX: result[key] = Knob(key,
knob.value.a_complex)
+ elif knob.type == BaseTypes.F32VECTOR: result[key] = Knob(key,
knob.value.a_f32vector)
+ elif knob.type == BaseTypes.F64VECTOR: result[key] = Knob(key,
knob.value.a_f64vector)
+ elif knob.type == BaseTypes.S64VECTOR: result[key] = Knob(key,
knob.value.a_s64vector)
+ elif knob.type == BaseTypes.S32VECTOR: result[key] = Knob(key,
knob.value.a_s32vector)
+ elif knob.type == BaseTypes.S16VECTOR: result[key] = Knob(key,
knob.value.a_s16vector)
+ elif knob.type == BaseTypes.S8VECTOR: result[key] = Knob(key,
knob.value.a_s8vector)
+ elif knob.type == BaseTypes.C32VECTOR: result[key] = Knob(key,
knob.value.a_c32vector)
else:
raise exceptions.ValueError
return result
def getRe(self,*args):
- return self.thriftclient.radio.getRe(*args)
+ class Knob():
+ def __init__(self, key, value):
+ (self.key, self.value) = (key, value)
+
+ result = {}
+ for key, knob in self.thriftclient.radio.getRe(*args).iteritems():
+ if knob.type == BaseTypes.BOOL: result[key] = Knob(key,
knob.value.a_bool)
+ elif knob.type == BaseTypes.BYTE: result[key] = Knob(key,
knob.value.a_byte)
+ elif knob.type == BaseTypes.SHORT: result[key] = Knob(key,
knob.value.a_short)
+ elif knob.type == BaseTypes.INT: result[key] = Knob(key,
knob.value.a_int)
+ elif knob.type == BaseTypes.LONG: result[key] = Knob(key,
knob.value.a_long)
+ elif knob.type == BaseTypes.DOUBLE: result[key] = Knob(key,
knob.value.a_double)
+ elif knob.type == BaseTypes.STRING: result[key] = Knob(key,
knob.value.a_string)
+ elif knob.type == BaseTypes.COMPLEX: result[key] = Knob(key,
knob.value.a_complex)
+ elif knob.type == BaseTypes.F32VECTOR: result[key] = Knob(key,
knob.value.a_f32vector)
+ elif knob.type == BaseTypes.F64VECTOR: result[key] = Knob(key,
knob.value.a_f64vector)
+ elif knob.type == BaseTypes.S64VECTOR: result[key] = Knob(key,
knob.value.a_s64vector)
+ elif knob.type == BaseTypes.S32VECTOR: result[key] = Knob(key,
knob.value.a_s32vector)
+ elif knob.type == BaseTypes.S16VECTOR: result[key] = Knob(key,
knob.value.a_s16vector)
+ elif knob.type == BaseTypes.S8VECTOR: result[key] = Knob(key,
knob.value.a_s8vector)
+ elif knob.type == BaseTypes.C32VECTOR: result[key] = Knob(key,
knob.value.a_c32vector)
+ else:
+ raise exceptions.ValueError
+ return result
def setKnobs(self,*args):
self.thriftclient.radio.setKnobs(*args)
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
index 661705d..243cc82 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
@@ -442,7 +442,8 @@ class GrDataPlotterValueTable:
units = str(knobprops[itemKey].units)
descr = str(knobprops[itemKey].description)
- if(type(v) == GNURadio.complex):
+ # TODO: FIX COMPLEX
+ if False: #if(type(v) == GNURadio.complex):
v = v.re + v.im*1j
# If it's a byte stream, Python thinks it's a string.
# Unpack and convert to floats for plotting.
@@ -468,7 +469,8 @@ class GrDataPlotterValueTable:
for k in knobs.keys():
if k not in foundKeys:
v = knobs[k].value
- if(type(v) == GNURadio.complex):
+ # TODO: Fix Handle of Complex
+ if False: #if(type(v) == GNURadio.complex):
v = v.re + v.im*1j
# If it's a byte stream, Python thinks it's a string.
# Unpack and convert to floats for plotting.
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
old mode 100755
new mode 100644
index 038d24f..c39df03
--- a/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/gr-perf-monitorx
@@ -21,7 +21,7 @@
#
import random,math,operator
-import networkx as nx;
+import networkx as nx
import matplotlib
matplotlib.use("Qt4Agg");
import matplotlib.pyplot as plt
@@ -39,19 +39,19 @@ import itertools
from gnuradio.ctrlport.GrDataPlotter import *
#from gnuradio.ctrlport import GNURadio
-from gnuradio.ctrlport.ThriftRadioClient import ThriftRadioClient
+
class MAINWindow(QtGui.QMainWindow):
def minimumSizeHint(self):
return QtGui.QSize(800,600)
- def __init__(self, radio, port, interface):
+ def __init__(self, radioclient):
super(MAINWindow, self).__init__()
+ self.radioclient = radioclient
self.conns = []
self.plots = []
self.knobprops = []
- self.interface = interface
self.mdiArea = QtGui.QMdiArea()
self.mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
@@ -71,7 +71,8 @@ class MAINWindow(QtGui.QMainWindow):
self.setWindowTitle("GNU Radio Performance Monitor")
self.setUnifiedTitleAndToolBarOnMac(True)
- self.newCon(radio, port)
+ self.newCon(radioclient)
+
icon = QtGui.QIcon(ctrlport.__path__[0] + "/icon.png" )
self.setWindowIcon(icon)
@@ -83,16 +84,10 @@ class MAINWindow(QtGui.QMainWindow):
child.show();
self.mdiArea.currentSubWindow().showMaximized()
-
- def newCon(self, radio=None, port=None):
- child = MForm(radio, port, len(self.conns), self)
- if(child.radio is not None):
- child.setWindowTitle(str(child.radio))
-# horizbar = QtGui.QScrollArea()
-# horizbar.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
-# horizbar.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
-# horizbar.setWidget(child)
-# self.mdiArea.addSubWindow(horizbar)
+ def newCon(self, csomeBool):
+ child = MForm(self.radioclient, len(self.conns), self, prompt= not
csomeBool)
+ if(child.radioclient is not None):
+ child.setWindowTitle(str(child.radioclient))
self.mdiArea.addSubWindow(child)
self.mdiArea.currentSubWindow().showMaximized()
@@ -226,7 +221,7 @@ GNU Radio is free software; you can redistribute it and/or
modify it under the t
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)
+ QtGui.QMessageBox.about(None, "gr-perf-monitorx", about_info)
class ConInfoDialog(QtGui.QDialog):
@@ -263,7 +258,7 @@ class DataTable(QtGui.QWidget):
def update(self):
print "update"
- def __init__(self, radio, G):
+ def __init__(self, radioclient, G):
QtGui.QWidget.__init__( self)
self.layout = QtGui.QVBoxLayout(self);
@@ -271,7 +266,7 @@ class DataTable(QtGui.QWidget):
self.layout.addLayout(self.hlayout);
self.G = G;
- self.radio = radio;
+ self.radioclient = radioclient;
self._keymap = None
@@ -346,8 +341,8 @@ class DataTable(QtGui.QWidget):
self._sort = state > 0
class DataTableBuffers(DataTable):
- def __init__(self, radio, G):
- DataTable.__init__(self,radio,G)
+ def __init__(self, radioclient, G):
+ DataTable.__init__(self,radioclient,G)
self.perfTable.setHorizontalHeaderLabels( ["Block Name", "Percent
Buffer Full"] );
def update(self):
@@ -357,7 +352,7 @@ class DataTableBuffers(DataTable):
kl = map(lambda x: "%s::%soutput %% full" % \
(x, self._statistics_table[self._statistic]),
nodes);
- buf_knobs = self.radio.getKnobs(kl)
+ buf_knobs = self.radioclient.getKnobs(kl)
# strip values out of ctrlport response
buffer_fullness = dict(zip(
@@ -366,7 +361,7 @@ class DataTableBuffers(DataTable):
blockport_fullness = {}
for blk in buffer_fullness:
- bdata = buffer_fullness[blk].a_f32vector
+ bdata = buffer_fullness[blk]
for port in range(0,len(bdata)):
blockport_fullness["%s:%d"%(blk,port)] = bdata[port];
@@ -396,8 +391,8 @@ class DataTableBuffers(DataTable):
self.canvas.show();
class DataTableRuntimes(DataTable):
- def __init__(self, radio, G):
- DataTable.__init__(self,radio,G)
+ def __init__(self, radioclient, G):
+ DataTable.__init__(self,radioclient,G)
#self.perfTable.setRowCount(len( self.G.nodes() ))
def update(self):
@@ -407,15 +402,15 @@ class DataTableRuntimes(DataTable):
kl = map(lambda x: "%s::%swork time" % \
(x, self._statistics_table[self._statistic]),
nodes);
- wrk_knobs = self.radio.getKnobs(kl)
+ wrk_knobs = self.radioclient.getKnobs(kl)
# strip values out of ctrlport response
- total_work = sum(map(lambda x: x.value.a_double, wrk_knobs.values()))
+ total_work = sum(map(lambda x: x.value, wrk_knobs.values()))
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.a_double/total_work, wrk_knobs.values())))
+ map(lambda x: x.value/total_work, wrk_knobs.values())))
# update table view
self.table_update(work_times)
@@ -452,11 +447,11 @@ class MForm(QtGui.QWidget):
self.prevent_clock_change = True;
kl1 = None;
if(self.clockKey == None):
- kl1 = self.radio.getRe([".*perfcounter_clock"])
+ kl1 = self.radioclient.getRe([".*perfcounter_clock"])
else:
- kl1 = self.radio.getKnobs([self.clockKey])
+ kl1 = self.radioclient.getKnobs([self.clockKey])
self.clockKey = kl1.keys()[0]
- self.currClock = kl1[self.clockKey].value.a_long
+ self.currClock = kl1[self.clockKey].value
self.clockSelIdx = self.clocks.values().index(self.currClock)
self.clockSel.setCurrentIndex(self.clockSelIdx)
self.prevent_clock_change = False
@@ -472,29 +467,29 @@ class MForm(QtGui.QWidget):
nodes_stream);
st = time.time()
- buf_knobs = self.radio.getKnobs(kl)
+ buf_knobs = self.radioclient.getKnobs(kl)
td1 = time.time() - st;
# strip values out of ctrlport response
buf_vals = dict(zip(
map(lambda x: x.split("::")[0], buf_knobs.keys()),
- map(lambda x: x.value, buf_knobs.values())))
+ map(lambda x: x, buf_knobs.values())))
# get work time for all blocks
kl = map(lambda x: "%s::%swork time" % \
(x, self._statistics_table[self._statistic]),
nodes_stream);
st = time.time()
- wrk_knobs = self.radio.getKnobs(kl)
+ wrk_knobs = self.radioclient.getKnobs(kl)
td2 = time.time() - st;
# strip values out of ctrlport response
- total_work = sum(map(lambda x: x.value.a_double,
wrk_knobs.values()))
+ total_work = sum(map(lambda x: x.value, wrk_knobs.values()))
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.a_double/total_work,
wrk_knobs.values())))
+ map(lambda x: x.value/total_work, wrk_knobs.values())))
work_times_padded = dict(zip(
self.G.nodes(),
[0.1]*len(self.G.nodes())))
@@ -508,8 +503,7 @@ class MForm(QtGui.QWidget):
# get the right output buffer/port weight for each edge
sourceport = e[2]["sourceport"];
if(e[2]["type"] == "stream"):
- #newweight = buf_vals[n][sourceport]
- newweight = buf_vals[n].a_f32vector[0]
+ newweight = buf_vals[n].value[sourceport]
e[2]["weight"] = newweight;
for n in nodes_msg:
@@ -534,7 +528,7 @@ class MForm(QtGui.QWidget):
(latency*1000))
except Exception, e:
- sys.stderr.write("ctrlport-monitor: radio.getKnobs threw exception
({0}).\n".format(e))
+ sys.stderr.write("gr-perf-monitorx: radio.getKnobs threw exception
({0}).\n".format(e))
if(type(self.parent) is MAINWindow):
# Find window of connection
remove = []
@@ -553,10 +547,10 @@ class MForm(QtGui.QWidget):
return
def rtt(self):
- self.parent.newSubWindow( DataTableRuntimes(self.radio,
self.G_stream), "Runtime Table" );
+ self.parent.newSubWindow( DataTableRuntimes(self.radioclient,
self.G_stream), "Runtime Table" );
def bpt(self):
- self.parent.newSubWindow( DataTableBuffers(self.radio,
self.G_stream), "Buffers Table" );
+ self.parent.newSubWindow( DataTableBuffers(self.radioclient,
self.G_stream), "Buffers Table" );
def resetPCs(self):
knob = GNURadio.ttypes.KnobBase()
@@ -564,7 +558,7 @@ class MForm(QtGui.QWidget):
km = {}
for b in self.blocks_list:
km[b + "::reset_perf_counters"] = knob
- k = self.radio.setKnobs(km)
+ k = self.radioclient.setKnobs(km)
def toggleFlowgraph(self):
if self.pauseFGAct.isChecked():
@@ -578,14 +572,14 @@ class MForm(QtGui.QWidget):
km = {}
km[self.top_block + "::lock"] = knob
km[self.top_block + "::stop"] = knob
- k = self.radio.setKnobs(km)
+ k = self.radioclient.setKnobs(km)
def unpauseFlowgraph(self):
knob = GNURadio.ttypes.KnobBase()
knob.a_bool = False
km = {}
km[self.top_block + "::unlock"] = knob
- k = self.radio.setKnobs(km)
+ k = self.radioclient.setKnobs(km)
def stat_changed(self, index):
self._statistic = str(self.stattype.currentText())
@@ -596,27 +590,34 @@ class MForm(QtGui.QWidget):
idx = self.clockSel.currentIndex();
clk = self.clocks.values()[idx]
# print "UPDATE CLOCK!!! %d -> %d"%(idx,clk);
- k = self.radio.getKnobs([self.clockKey]);
+ k = self.radioclient.getKnobs([self.clockKey]);
k[self.clockKey].value = clk;
km = {};
km[self.clockKey] = k[self.clockKey];
- self.radio.setKnobs(km);
+ self.radioclient.setKnobs(km);
- def __init__(self, radio=None, port=None, uid=0, parent=None):
+ def __init__(self, radioclient, uid=0, parent=None, prompt = False):
super(MForm, self).__init__()
-
- if(radio == None or port == None):
+ self.radioclient = radioclient
+# print("before radioclient.getHost()", radioclient.getHost(),
radioclient.getPort(), "prompt", prompt)
+ if(prompt or radioclient.getHost() is None or radioclient.getPort() is
None):
+# print("before ConInfoDialog")
askinfo = ConInfoDialog(self);
if askinfo.exec_():
host = str(askinfo.host.text());
port = str(askinfo.port.text());
- radio = parent.interface.getRadio(host, port)
+# print("before radioclient.newConnection host: %s port:
%s"%(host,port))
+ newradio = self.radioclient.newConnection(host, port)
+ if newradio is None:
+ print("Error making a %s connection to %s:%s from %s" %
(radioclient.getName(), host, port, radioclient))
+ else:
+ self.radioclient = newradio
+
else:
- self.radio = None
+ self.radioclient = None
return
-
self.uid = uid
self.parent = parent
@@ -677,7 +678,7 @@ class MForm(QtGui.QWidget):
# self.setLayout(self.layout);
- self.radio = radio.radio
+ self.radio = radioclient
self.knobprops = self.radio.properties([])
self.parent.knobprops.append(self.knobprops)
@@ -720,8 +721,8 @@ class MForm(QtGui.QWidget):
sys.exit(1)
self.blocks_list = tmplist
- edges = edgelist.a_string.split("\n")[0:-1]
- msgedges = msgedgelist.a_string.split("\n")[0:-1]
+ edges = edgelist.split("\n")[0:-1]
+ msgedges = msgedgelist.split("\n")[0:-1]
edgepairs_stream = [];
edgepairs_msg = [];
@@ -819,7 +820,7 @@ class MForm(QtGui.QWidget):
index = self.table.treeWidget.selectedIndexes()
item = self.table.treeWidget.itemFromIndex(index[0])
itemname = str(item.text(0))
- self.parent.propertiesMenu(itemname, self.radio, self.uid)
+ self.parent.propertiesMenu(itemname, self.radioclient, self.uid)
def updateGraph(self):
@@ -844,18 +845,13 @@ class MForm(QtGui.QWidget):
self.canvas.draw();
self.canvas.show();
-#class MyClient(ThriftRadioClient):
-# def __init__(self):
-# ThriftRadioClient.__init__(self, MAINWindow)
-#
-#sys.exit(MyClient().main(sys.argv))
-app = QtGui.QApplication(sys.argv)
+class MyApp(object):
+ def __init__(self, args):
+ from gnuradio.ctrlport.GNURadioControlPortClient import
GNURadioControlPortClient
+ GNURadioControlPortClient(args, 'thrift', self.run,
QtGui.QApplication(sys.argv).exec_)
+
+ def run(self, client):
+ MAINWindow(client).show()
-host = "127.0.0.1"
-port = 9090
-iface = "lo"
-radio = ThriftRadioClient(host, port)
-mainwin = MAINWindow(radio, port, iface)
-mainwin.show()
-app.exec_()
+MyApp(sys.argv)
- [Commit-gnuradio] [gnuradio] 02/50: ctrlport: thrift: "py" instead of "python" -- guessing a version thing, (continued)
- [Commit-gnuradio] [gnuradio] 02/50: ctrlport: thrift: "py" instead of "python" -- guessing a version thing, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 04/50: controlport: restructuring to add subdirs for different cp backends., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 18/50: controlport: improving transport layer throughput., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 07/50: controlport: Addes a FindThrift cmake module to find the Thrift headers, libraries, and Python files., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 17/50: controlport: convert to To_PMT registration objects, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 20/50: runtime: more generic version of prefs class., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 22/50: cmake: force QA tests to turn ControlPort off by default., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 15/50: controlport: convert rpcpmtconverter::to_pmt() if statement to a function object map, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 01/50: Initial thrift definition for gnuradio, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 14/50: controlport: Thrift's binary type, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 09/50: controlport: cleanup and switching over to new Python common interface.,
git <=
- [Commit-gnuradio] [gnuradio] 23/50: controlport: cleaning up and using logger to display endpoint., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 34/50: controlport: replacement of nanosleep() with boost::sleep() in startup thread. Fix of merge error in booter_thrift., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 28/50: controlport: more cleaning up., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 31/50: controlport: moving the logger call that publishes Thrift's endpoint to i_impl()., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 24/50: controlport: adding performance and controlport monitor GRC blocks., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 29/50: controlport: changing the default port number on the Thrift interface to zero., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 21/50: controlport: Adds ability to configure Thrift through a config file, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 30/50: controlport: ephemeral / unused port number selection by OS working., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 13/50: controlport: using threaded server for multiple connections., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 39/50: controlport: documentation cleanup, git, 2015/04/16