[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/16: updates to waterfall for suchsamples
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/16: updates to waterfall for suchsamples |
Date: |
Tue, 21 Jul 2015 19:27:51 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 6b605cbe63070b1fd751c09c337dc18a1369eab0
Author: Nicholas McCarthy <address@hidden>
Date: Sun Jun 28 11:23:56 2015 -0400
updates to waterfall for suchsamples
bit of cleanup to suchsamples commit
bugfixes
---
gr-qtgui/grc/qtgui_waterfall_sink_x.xml | 8 +
.../include/gnuradio/qtgui/waterfalldisplayform.h | 2 +-
gr-qtgui/lib/WaterfallDisplayPlot.cc | 105 +++++++-----
gr-qtgui/lib/waterfall_sink_c_impl.cc | 185 +++++++++++++++------
gr-qtgui/lib/waterfall_sink_c_impl.h | 5 +
gr-qtgui/lib/waterfalldisplayform.cc | 5 +
6 files changed, 216 insertions(+), 94 deletions(-)
diff --git a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml
b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml
index 3857cb5..f0d0c60 100644
--- a/gr-qtgui/grc/qtgui_waterfall_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_waterfall_sink_x.xml
@@ -490,6 +490,7 @@ $(gui_hint()($win))</make>
<name>in</name>
<type>$type</type>
<nports>$nconnections</nports>
+ <optional>1</optional>
</sink>
<sink>
@@ -499,6 +500,13 @@ $(gui_hint()($win))</make>
<hide>$showports</hide>
</sink>
+ <sink>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ <hide>$showports</hide>
+ </sink>
+
<source>
<name>freq</name>
<type>message</type>
diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
b/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
index 10378d4..6d1e4be 100644
--- a/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
+++ b/gr-qtgui/include/gnuradio/qtgui/waterfalldisplayform.h
@@ -65,7 +65,7 @@ class WaterfallDisplayForm : public DisplayForm
public slots:
void customEvent(QEvent *e);
-
+ void setTimeTitle(const std::string);
void setSampleRate(const QString &samprate);
void setFFTSize(const int);
void setFFTAverage(const float);
diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.cc
b/gr-qtgui/lib/WaterfallDisplayPlot.cc
index 2f7e967..111374c 100644
--- a/gr-qtgui/lib/WaterfallDisplayPlot.cc
+++ b/gr-qtgui/lib/WaterfallDisplayPlot.cc
@@ -276,49 +276,72 @@ WaterfallDisplayPlot::getStopFrequency() const
void
WaterfallDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
- const int64_t numDataPoints,
- const double timePerFFT,
- const gr::high_res_timer_type timestamp,
- const int droppedFrames)
+ const int64_t numDataPoints,
+ const double timePerFFT,
+ const gr::high_res_timer_type timestamp,
+ const int droppedFrames)
{
- int64_t _npoints_in = d_half_freq ? numDataPoints/2 : numDataPoints;
- int64_t _in_index = d_half_freq ? _npoints_in : 0;
-
- if(!d_stop) {
- if(numDataPoints > 0){
- if(_npoints_in != d_numPoints) {
- d_numPoints = _npoints_in;
-
- resetAxis();
-
- for(int i = 0; i < d_nplots; i++) {
- d_spectrogram[i]->invalidateCache();
- d_spectrogram[i]->itemChanged();
- }
-
- if(isVisible()) {
- replot();
- }
- }
-
- QwtTimeScaleDraw* timeScale =
(QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
- timeScale->setSecondsPerLine(timePerFFT);
- timeScale->setZeroTime(timestamp);
-
- ((WaterfallZoomer*)d_zoomer)->setSecondsPerLine(timePerFFT);
- ((WaterfallZoomer*)d_zoomer)->setZeroTime(timestamp);
-
- for(int i = 0; i < d_nplots; i++) {
- d_data[i]->addFFTData(&(dataPoints[i][_in_index]),
- _npoints_in, droppedFrames);
- d_data[i]->incrementNumLinesToUpdate();
- d_spectrogram[i]->invalidateCache();
- d_spectrogram[i]->itemChanged();
- }
-
- replot();
+ int64_t _npoints_in = d_half_freq ? numDataPoints/2 : numDataPoints;
+ int64_t _in_index = d_half_freq ? _npoints_in : 0;
+
+ if(!d_stop) {
+ if(numDataPoints > 0 && timestamp == 0){
+ d_numPoints = numDataPoints/200;
+ resetAxis();
+
+ //you got an entire waterfall plot, just plot it
+ for(int i = 0; i < d_nplots; i++) {
+ d_data[i]->setSpectrumDataBuffer(dataPoints[i]);
+ d_data[i]->setNumLinesToUpdate(0);
+ d_spectrogram[i]->invalidateCache();
+ d_spectrogram[i]->itemChanged();
+ }
+
+ QwtTimeScaleDraw* timeScale =
(QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
+ timeScale->setSecondsPerLine(timePerFFT);
+ timeScale->setZeroTime(timestamp);
+ timeScale->initiateUpdate();
+
+ ((WaterfallZoomer*)d_zoomer)->setSecondsPerLine(timePerFFT);
+ ((WaterfallZoomer*)d_zoomer)->setZeroTime(timestamp);
+ replot();
+ }
+
+
+
+ else if(numDataPoints > 0) {
+ if(_npoints_in != d_numPoints) {
+ d_numPoints = _npoints_in;
+ resetAxis();
+
+ for(int i = 0; i < d_nplots; i++) {
+ d_spectrogram[i]->invalidateCache();
+ d_spectrogram[i]->itemChanged();
+ }
+
+ if(isVisible()) {
+ replot();
+ }
+ }
+
+ QwtTimeScaleDraw* timeScale =
(QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft);
+ timeScale->setSecondsPerLine(timePerFFT);
+ timeScale->setZeroTime(timestamp);
+
+ ((WaterfallZoomer*)d_zoomer)->setSecondsPerLine(timePerFFT);
+ ((WaterfallZoomer*)d_zoomer)->setZeroTime(timestamp);
+
+ for(int i = 0; i < d_nplots; i++) {
+ d_data[i]->addFFTData(&(dataPoints[i][_in_index]),
+ _npoints_in, droppedFrames);
+ d_data[i]->incrementNumLinesToUpdate();
+ d_spectrogram[i]->invalidateCache();
+ d_spectrogram[i]->itemChanged();
+ }
+
+ replot();
+ }
}
- }
}
void
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc
b/gr-qtgui/lib/waterfall_sink_c_impl.cc
index 1675b80..49f07c3 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -30,6 +30,7 @@
#include <string.h>
#include <volk/volk.h>
#include <qwt_symbol.h>
+#include <iostream>
namespace gr {
namespace qtgui {
@@ -54,7 +55,7 @@ namespace gr {
int nconnections,
QWidget *parent)
: sync_block("waterfall_sink_c",
- io_signature::make(1, nconnections, sizeof(gr_complex)),
+ io_signature::make(0, nconnections, sizeof(gr_complex)),
io_signature::make(0, 0, 0)),
d_fftsize(fftsize), d_fftavg(1.0),
d_wintype((filter::firdes::win_type)(wintype)),
@@ -76,6 +77,12 @@ namespace gr {
set_msg_handler(pmt::mp("freq"),
boost::bind(&waterfall_sink_c_impl::handle_set_freq,
this, _1));
+
+ // setup such samples pdu port
+ message_port_register_in(pmt::mp("pdus"));
+ set_msg_handler(pmt::mp("pdus"),
+ boost::bind(&waterfall_sink_c_impl::handle_such_samples,
this, _1));
+
d_main_gui = NULL;
// Perform fftshift operation;
@@ -88,15 +95,21 @@ namespace gr {
memset(d_fbuf, 0, d_fftsize*sizeof(float));
d_index = 0;
+ // save the last "connection" for such samples
for(int i = 0; i < d_nconnections; i++) {
-
d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
- volk_get_alignment()));
- d_magbufs.push_back((double*)volk_malloc(d_fftsize*sizeof(double),
- volk_get_alignment()));
- memset(d_residbufs[i], 0, d_fftsize*sizeof(float));
- memset(d_magbufs[i], 0, d_fftsize*sizeof(double));
+
d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
+
volk_get_alignment()));
+ d_magbufs.push_back((double*)volk_malloc(d_fftsize*sizeof(double),
+ volk_get_alignment()));
+ memset(d_residbufs[i], 0, d_fftsize*sizeof(float));
+ memset(d_magbufs[i], 0, d_fftsize*sizeof(double));
}
-
+
d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
+ volk_get_alignment()));
+ pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*200,
volk_get_alignment());
+ d_magbufs.push_back(pdu_magbuf);
+ memset(pdu_magbuf, 0, d_fftsize*sizeof(double)*200);
+ memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(gr_complex));
buildwindow();
initialize();
@@ -107,13 +120,13 @@ namespace gr {
if(!d_main_gui->isClosed())
d_main_gui->close();
- for(int i = 0; i < d_nconnections; i++) {
- volk_free(d_residbufs[i]);
- volk_free(d_magbufs[i]);
+ for(int i = 0; i < (int)d_residbufs.size(); i++) {
+ volk_free(d_residbufs[i]);
+ volk_free(d_magbufs[i]);
}
delete d_fft;
volk_free(d_fbuf);
-
+
delete d_argv;
}
@@ -152,8 +165,8 @@ namespace gr {
QString sstext = get_qt_style_sheet(QString(qssfile.c_str()));
d_qApplication->setStyleSheet(sstext);
}
-
- d_main_gui = new WaterfallDisplayForm(d_nconnections, d_parent);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new WaterfallDisplayForm(numplots, d_parent);
set_fft_window(d_wintype);
set_fft_size(d_fftsize);
set_frequency_range(d_center_freq, d_bandwidth);
@@ -268,6 +281,12 @@ namespace gr {
}
void
+ waterfall_sink_c_impl::set_time_title(const std::string &title)
+ {
+ d_main_gui->setTimeTitle(title);
+ }
+
+ void
waterfall_sink_c_impl::set_line_label(int which, const std::string &label)
{
d_main_gui->setLineLabel(which, label.c_str());
@@ -400,46 +419,51 @@ namespace gr {
void
waterfall_sink_c_impl::fftresize()
{
- gr::thread::scoped_lock lock(d_setlock);
-
- int newfftsize = d_main_gui->getFFTSize();
- d_fftavg = d_main_gui->getFFTAverage();
-
- if(newfftsize != d_fftsize) {
-
- // Resize residbuf and replace data
- for(int i = 0; i < d_nconnections; i++) {
- volk_free(d_residbufs[i]);
- volk_free(d_magbufs[i]);
-
- d_residbufs[i] =
(gr_complex*)volk_malloc(newfftsize*sizeof(gr_complex),
+ gr::thread::scoped_lock lock(d_setlock);
+
+ int newfftsize = d_main_gui->getFFTSize();
+ d_fftavg = d_main_gui->getFFTAverage();
+
+ if(newfftsize != d_fftsize) {
+
+ // Resize residbuf and replace data
+ for(int i = 0; i < d_nconnections; i++) {
+ volk_free(d_residbufs[i]);
+ volk_free(d_magbufs[i]);
+
+ d_residbufs[i] =
(gr_complex*)volk_malloc(newfftsize*sizeof(gr_complex),
+
volk_get_alignment());
+ d_magbufs[i] = (double*)volk_malloc(newfftsize*sizeof(double),
volk_get_alignment());
- d_magbufs[i] = (double*)volk_malloc(newfftsize*sizeof(double),
- volk_get_alignment());
-
- memset(d_residbufs[i], 0, newfftsize*sizeof(gr_complex));
- memset(d_magbufs[i], 0, newfftsize*sizeof(double));
- }
-
- // Set new fft size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_fftsize = newfftsize;
- d_index = 0;
-
- // Reset window to reflect new size
- buildwindow();
-
- // Reset FFTW plan for new size
- delete d_fft;
- d_fft = new fft::fft_complex(d_fftsize, true);
-
- volk_free(d_fbuf);
- d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
- memset(d_fbuf, 0, d_fftsize*sizeof(float));
- }
+
+ memset(d_residbufs[i], 0, newfftsize*sizeof(gr_complex));
+ memset(d_magbufs[i], 0, newfftsize*sizeof(double));
+ }
+
d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
+
volk_get_alignment()));
+ pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*200,
volk_get_alignment());
+ d_magbufs.push_back(pdu_magbuf);
+ memset(pdu_magbuf, 0, d_fftsize*sizeof(double)*200);
+ memset(d_residbufs[d_nconnections], 0,
d_fftsize*sizeof(gr_complex));
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
+
+ // Reset window to reflect new size
+ buildwindow();
+
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new fft::fft_complex(d_fftsize, true);
+
+ volk_free(d_fbuf);
+ d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
+ volk_get_alignment());
+ memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ }
}
-
+
void
waterfall_sink_c_impl::check_clicked()
{
@@ -527,5 +551,62 @@ namespace gr {
return j;
}
+ void
+ waterfall_sink_c_impl::handle_such_samples(pmt::pmt_t msg)
+ {
+ int j = 0;
+ size_t len = 0;
+ size_t start = 0;
+ if(pmt::is_pair(msg)) {
+ pmt::pmt_t dict = pmt::car(msg);
+ pmt::pmt_t samples = pmt::cdr(msg);
+
+ pmt::pmt_t len_key = pmt::string_to_symbol("len");
+ if(pmt::dict_has_key(dict, len_key)) {
+ len = pmt::to_uint64(pmt::dict_ref(dict, len_key,
pmt::PMT_NIL));
+ }
+
+ pmt::pmt_t start_key = pmt::string_to_symbol("start");
+ if(pmt::dict_has_key(dict, start_key)) {
+ start = pmt::to_uint64(pmt::dict_ref(dict, start_key,
pmt::PMT_NIL));
+ }
+
+
+ gr::high_res_timer_type ref_start = (uint64_t)start *
(double)(1.0/d_bandwidth) * 1000000;
+
+
+ const gr_complex *in = (const gr_complex*)
pmt::c32vector_elements(samples, len);
+ int stride = (len - d_fftsize)/199;
+
+ set_time_per_fft(1.0/d_bandwidth * stride);
+ std::ostringstream title("");
+ title << "Time (+" << (uint64_t)ref_start << "us)";
+ set_time_title(title.str());
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+ check_clicked();
+
+ for(size_t i=0; j < 200; i+=stride) {
+
+ memcpy(d_residbufs[d_nconnections], &in[j * stride],
sizeof(gr_complex)*d_fftsize);
+
+ fft(d_fbuf, d_residbufs[d_nconnections], d_fftsize);
+ for(int x = 0; x < d_fftsize; x++) {
+ pdu_magbuf[j * d_fftsize + x] = (double)d_fbuf[x];
+ }
+ j++;
+
+ }
+
+ //update gui per-pdu
+ d_qApplication->postEvent(d_main_gui,
+ new WaterfallUpdateEvent(d_magbufs,
+ d_fftsize*200,
+ 0));
+
+ }
+ }
+
} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.h
b/gr-qtgui/lib/waterfall_sink_c_impl.h
index e21de88..c243799 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.h
@@ -54,6 +54,7 @@ namespace gr {
int d_index;
std::vector<gr_complex*> d_residbufs;
std::vector<double*> d_magbufs;
+ double* pdu_magbuf;
float *d_fbuf;
int d_argc;
@@ -74,6 +75,9 @@ namespace gr {
// The message is a PMT pair (intern('freq'), double(frequency)).
void handle_set_freq(pmt::pmt_t msg);
+ // Handles message input port for displaying such samples pdus.
+ void handle_such_samples(pmt::pmt_t msg);
+
public:
waterfall_sink_c_impl(int size, int wintype,
double fc, double bw,
@@ -108,6 +112,7 @@ namespace gr {
void set_update_time(double t);
void set_time_per_fft(double t);
void set_title(const std::string &title);
+ void set_time_title(const std::string &title);
void set_line_label(int which, const std::string &label);
void set_line_alpha(int which, double alpha);
void set_color_map(int which, const int color);
diff --git a/gr-qtgui/lib/waterfalldisplayform.cc
b/gr-qtgui/lib/waterfalldisplayform.cc
index 9f87504..b6eb345 100644
--- a/gr-qtgui/lib/waterfalldisplayform.cc
+++ b/gr-qtgui/lib/waterfalldisplayform.cc
@@ -325,6 +325,11 @@ WaterfallDisplayForm::checkClicked()
}
}
+void
+WaterfallDisplayForm::setTimeTitle(const std::string title) {
+ getPlot()->setAxisTitle(QwtPlot::yLeft, title.c_str());
+}
+
float
WaterfallDisplayForm::getClickedFreq() const
{
- [Commit-gnuradio] [gnuradio] branch master updated (55d8f48 -> cc973de), git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 05/16: fec: extended encoder now appends unpack_k_bits(8) block after encoder to satisfy get_output_conversion() = unpack behaviour, git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 02/16: fec: some initial refactoring for ber_bf, git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 03/16: fec: fixed QA for ber_bf., git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 04/16: fec: code clean-up for block 'ber_bf'., git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 08/16: fec: added tests for extended_encoder input/output conversion., git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 15/16: Merge remote-tracking branch 'fewu/crc32_unpack', git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 01/16: updates to waterfall for suchsamples,
git <=
- [Commit-gnuradio] [gnuradio] 10/16: Merge remote-tracking branch 'namccart/master' into master_waterfall_pdu, git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 07/16: digital: added an option to the crc32_bb block that adds the unpacked CRC to the bit stream, git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 12/16: qtgui: protect PDU handling waterfall port for wrong data type., git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 09/16: Merge remote-tracking branch 'jdemel/fec/fix-extended_encoder', git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 16/16: Merge branch 'maint', git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 11/16: qtgui: waterfall PDU handling, git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 13/16: qtgui: pdu handler for float waterfall plot., git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 14/16: qtgui: waterfall plots, git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 06/16: digital: whitespace fixes, git, 2015/07/21