diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-02-14 14:30:11 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-02-14 14:30:49 -0500 |
commit | 8313e9c53562c27cb29290281af73ed9815f314e (patch) | |
tree | f9044090daefba6e4390a3f163cbf7c379611669 /gnuradio-core/src/python | |
parent | 54008ea650fa5e69e905495fe79d57d34268b426 (diff) |
ctrlport: added time raster plot option to gr-ctrlport-monitor.
Diffstat (limited to 'gnuradio-core/src/python')
-rw-r--r-- | gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py | 135 | ||||
-rwxr-xr-x | gnuradio-core/src/python/gnuradio/ctrlport/gr-ctrlport-monitor | 24 |
2 files changed, 154 insertions, 5 deletions
diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py b/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py index f93944c397..e2844b8bad 100644 --- a/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py +++ b/gnuradio-core/src/python/gnuradio/ctrlport/GrDataPlotter.py @@ -390,6 +390,141 @@ class GrDataPlotterPsdF(gr.top_block): self.src.set_data(self._last_data) +class GrTimeRasterF(gr.top_block): + def __init__(self, name, rate, pmin=None, pmax=None): + gr.top_block.__init__(self) + + self._name = name + self._npts = 100 + self._rows = 100 + samp_rate = 1.0 + + self._last_data = self._npts*[0,] + self._data_len = 0 + + self.src = gr.vector_source_f([]) + self.thr = gr.throttle(gr.sizeof_float, rate) + self.snk = qtgui.time_raster_sink_f(samp_rate, self._npts, self._rows, + [], [], self._name, 1) + + self.connect(self.src, self.thr, (self.snk, 0)) + + self.py_window = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + + def __del__(self): + pass + + def qwidget(self): + return self.py_window + + def name(self): + return self._name + + def update(self, data): + # Ask GUI if there has been a change in nsamps + npts = int(self.snk.num_cols()) + if(self._npts != npts): + + # Adjust buffers to accomodate new settings + if(npts < self._npts): + if(self._data_len < npts): + self._last_data = self._last_data[0:npts] + else: + self._last_data = self._last_data[self._data_len-npts:self._data_len] + self._data_len = npts + else: + self._last_data += (npts - self._npts)*[0,] + self._npts = npts + self.snk.reset() + + # Update the plot data depending on type + if(type(data) == list): + if(len(data) > self._npts): + self.src.set_data(data) + self._last_data = data[-self._npts:] + else: + newdata = self._last_data[-(self._npts-len(data)):] + newdata += data + self.src.set_data(newdata) + self._last_data = newdata + + else: # single value update + if(self._data_len < self._npts): + self._last_data[self._data_len] = data + self._data_len += 1 + else: + self._last_data = self._last_data[1:] + self._last_data.append(data) + self.src.set_data(self._last_data) + +class GrTimeRasterB(gr.top_block): + def __init__(self, name, rate, pmin=None, pmax=None): + gr.top_block.__init__(self) + + self._name = name + self._npts = 100 + self._rows = 100 + samp_rate = 1.0 + + self._last_data = self._npts*[0,] + self._data_len = 0 + + self.src = gr.vector_source_b([]) + self.thr = gr.throttle(gr.sizeof_char, rate) + self.snk = qtgui.time_raster_sink_b(samp_rate, self._npts, self._rows, + [], [], self._name, 1) + + self.connect(self.src, self.thr, (self.snk, 0)) + + self.py_window = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + + def __del__(self): + pass + + def qwidget(self): + return self.py_window + + def name(self): + return self._name + + def update(self, data): + # Ask GUI if there has been a change in nsamps + npts = self.snk.num_cols() + if(self._npts != npts): + + # Adjust buffers to accomodate new settings + if(npts < self._npts): + if(self._data_len < npts): + self._last_data = self._last_data[0:npts] + else: + self._last_data = self._last_data[self._data_len-npts:self._data_len] + self._data_len = npts + else: + self._last_data += (npts - self._npts)*[0,] + self._npts = npts + self.snk.reset() + + # Update the plot data depending on type + if(type(data) == list): + if(len(data) > self._npts): + self.src.set_data(data) + self._last_data = data[-self._npts:] + else: + newdata = self._last_data[-(self._npts-len(data)):] + newdata += data + self.src.set_data(newdata) + self._last_data = newdata + + else: # single value update + if(self._data_len < self._npts): + self._last_data[self._data_len] = data + self._data_len += 1 + else: + self._last_data = self._last_data[1:] + self._last_data.append(data) + self.src.set_data(self._last_data) + + class GrDataPlotterValueTable: def __init__(self, uid, parent, x, y, xsize, ysize, headers=['Statistic Key ( Source Block :: Stat Name ) ', diff --git a/gnuradio-core/src/python/gnuradio/ctrlport/gr-ctrlport-monitor b/gnuradio-core/src/python/gnuradio/ctrlport/gr-ctrlport-monitor index b51888527b..ec31be209f 100755 --- a/gnuradio-core/src/python/gnuradio/ctrlport/gr-ctrlport-monitor +++ b/gnuradio-core/src/python/gnuradio/ctrlport/gr-ctrlport-monitor @@ -133,6 +133,12 @@ class MAINWindow(QtGui.QMainWindow): def newPlotterPsdCProxy(): self.newPlotPsdC(key, uid, title) + def newPlotterRasterFProxy(): + self.newPlotRasterF(key, uid, title, pmin, pmax) + + def newPlotterRasterBProxy(): + self.newPlotRasterB(key, uid, title, pmin, pmax) + menu = QtGui.QMenu(self) menu.setTitle("Item Actions") menu.setTearOffEnabled(False) @@ -140,14 +146,14 @@ class MAINWindow(QtGui.QMainWindow): # object properties menu.addAction("Properties", newUpdaterProxy) - # displays available if not complex + # displays available menu.addAction("Plot Time", newPlotterFProxy) - menu.addAction("Plot PSD", newPlotterPsdFProxy) - - # displays available if complex menu.addAction("Plot Time (cpx)", newPlotterCProxy) - menu.addAction("Plot Constellation", newPlotterConstProxy) + menu.addAction("Plot PSD", newPlotterPsdFProxy) menu.addAction("Plot PSD cpx", newPlotterPsdCProxy) + menu.addAction("Plot Constellation", newPlotterConstProxy) + menu.addAction("Plot Raster (real)", newPlotterRasterFProxy) + #menu.addAction("Plot Raster (bits)", newPlotterRasterBProxy) menu.popup(QtGui.QCursor.pos()) @@ -222,6 +228,14 @@ class MAINWindow(QtGui.QMainWindow): plot = GrDataPlotterPsdC(tag, 32e6, pmin, pmax) self.createPlot(plot, uid, title) + def newPlotRasterF(self, tag, uid, title="", pmin=None, pmax=None): + plot = GrTimeRasterF(tag, 32e6, pmin, pmax) + self.createPlot(plot, uid, title) + + def newPlotRasterB(self, tag, uid, title="", pmin=None, pmax=None): + plot = GrTimeRasterB(tag, 32e6, pmin, pmax) + self.createPlot(plot, uid, title) + def update(self, knobs, uid): #sys.stderr.write("KNOB KEYS: {0}\n".format(knobs.keys())) for plot in self.plots[uid]: |