[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 13/16: qtgui: pdu handler for float waterfa
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 13/16: qtgui: pdu handler for float waterfall plot. |
Date: |
Tue, 21 Jul 2015 19:27:52 +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 ac589f17bd80b267f745b09e9f960b1971bf5add
Author: Tom Rondeau <address@hidden>
Date: Mon Jul 20 18:04:11 2015 -0400
qtgui: pdu handler for float waterfall plot.
Small updates to complex version; mostly formatting.
---
gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h | 1 +
gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h | 1 +
gr-qtgui/lib/waterfall_sink_c_impl.cc | 37 +++++----
gr-qtgui/lib/waterfall_sink_c_impl.h | 2 +-
gr-qtgui/lib/waterfall_sink_f_impl.cc | 94 +++++++++++++++++++++-
gr-qtgui/lib/waterfall_sink_f_impl.h | 5 ++
6 files changed, 120 insertions(+), 20 deletions(-)
diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
index aca4509..2e09e71 100644
--- a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
+++ b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_c.h
@@ -122,6 +122,7 @@ namespace gr {
virtual void set_update_time(double t) = 0;
virtual void set_title(const std::string &title) = 0;
+ virtual void set_time_title(const std::string &title) = 0;
virtual void set_line_label(int which, const std::string &line) = 0;
virtual void set_line_alpha(int which, double alpha) = 0;
virtual void set_color_map(int which, const int color) = 0;
diff --git a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
index 13c7b98..62c0086 100644
--- a/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
+++ b/gr-qtgui/include/gnuradio/qtgui/waterfall_sink_f.h
@@ -121,6 +121,7 @@ namespace gr {
virtual void set_update_time(double t) = 0;
virtual void set_title(const std::string &title) = 0;
+ virtual void set_time_title(const std::string &title) = 0;
virtual void set_line_label(int which, const std::string &line) = 0;
virtual void set_line_alpha(int which, double alpha) = 0;
virtual void set_color_map(int which, const int color) = 0;
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc
b/gr-qtgui/lib/waterfall_sink_c_impl.cc
index 870b291..6b0f2de 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -77,7 +77,6 @@ namespace gr {
set_msg_handler(pmt::mp("freq"),
boost::bind(&waterfall_sink_c_impl::handle_set_freq,
this, _1));
-
// setup PDU handling input port
message_port_register_in(pmt::mp("pdus"));
set_msg_handler(pmt::mp("pdus"),
@@ -95,21 +94,24 @@ namespace gr {
memset(d_fbuf, 0, d_fftsize*sizeof(float));
d_index = 0;
- // save the last "connection" for such samples
+ // save the last "connection" for the PDU memory
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);
+ d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*200,
+ volk_get_alignment());
+ d_magbufs.push_back(d_pdu_magbuf);
+ memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*200);
memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(gr_complex));
+
buildwindow();
initialize();
@@ -386,6 +388,7 @@ namespace gr {
volk_32fc_s32f_x2_power_spectral_density_32f(data_out,
d_fft->get_outbuf(),
size, 1.0, size);
+
// Perform shift operation
unsigned int len = (unsigned int)(floor(size/2.0));
float *tmp = (float*)malloc(sizeof(float)*len);
@@ -440,12 +443,14 @@ namespace gr {
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);
+ d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*200,
volk_get_alignment());
+ d_magbufs.push_back(d_pdu_magbuf);
+ memset(d_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;
@@ -460,7 +465,7 @@ namespace gr {
volk_free(d_fbuf);
d_fbuf = (float*)volk_malloc(d_fftsize*sizeof(float),
- volk_get_alignment());
+ volk_get_alignment());
memset(d_fbuf, 0, d_fftsize*sizeof(float));
}
}
@@ -596,7 +601,7 @@ namespace gr {
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];
+ d_pdu_magbuf[j * d_fftsize + x] = (double)d_fbuf[x];
}
j++;
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.h
b/gr-qtgui/lib/waterfall_sink_c_impl.h
index 5251dfc..2c5e72c 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.h
@@ -54,7 +54,7 @@ namespace gr {
int d_index;
std::vector<gr_complex*> d_residbufs;
std::vector<double*> d_magbufs;
- double* pdu_magbuf;
+ double* d_pdu_magbuf;
float *d_fbuf;
int d_argc;
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.cc
b/gr-qtgui/lib/waterfall_sink_f_impl.cc
index 7bb2a09..3f893b8 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.cc
@@ -29,6 +29,7 @@
#include <gnuradio/prefs.h>
#include <string.h>
#include <volk/volk.h>
+#include <iostream>
namespace gr {
namespace qtgui {
@@ -53,7 +54,7 @@ namespace gr {
int nconnections,
QWidget *parent)
: sync_block("waterfall_sink_f",
- io_signature::make(1, -1, sizeof(float)),
+ io_signature::make(0, nconnections, sizeof(float)),
io_signature::make(0, 0, 0)),
d_fftsize(fftsize), d_fftavg(1.0),
d_wintype((filter::firdes::win_type)(wintype)),
@@ -75,6 +76,11 @@ namespace gr {
set_msg_handler(pmt::mp("freq"),
boost::bind(&waterfall_sink_f_impl::handle_set_freq,
this, _1));
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("pdus"));
+ set_msg_handler(pmt::mp("pdus"),
+ boost::bind(&waterfall_sink_f_impl::handle_pdus, this,
_1));
+
d_main_gui = NULL;
// Perform fftshift operation;
@@ -87,6 +93,7 @@ namespace gr {
memset(d_fbuf, 0, d_fftsize*sizeof(float));
d_index = 0;
+ // save the last "connection" for the PDU memory
for(int i = 0; i < d_nconnections; i++) {
d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
volk_get_alignment()));
@@ -96,6 +103,14 @@ namespace gr {
memset(d_magbufs[i], 0, d_fftsize*sizeof(double));
}
+ d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
+ volk_get_alignment()));
+ d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*200,
+ volk_get_alignment());
+ d_magbufs.push_back(d_pdu_magbuf);
+ memset(d_pdu_magbuf, 0, d_fftsize*sizeof(double)*200);
+ memset(d_residbufs[d_nconnections], 0, d_fftsize*sizeof(float));
+
buildwindow();
initialize();
@@ -106,7 +121,7 @@ namespace gr {
if(!d_main_gui->isClosed())
d_main_gui->close();
- for(int i = 0; i < d_nconnections; i++) {
+ for(int i = 0; i < (int)d_residbufs.size(); i++) {
volk_free(d_residbufs[i]);
volk_free(d_magbufs[i]);
}
@@ -152,7 +167,8 @@ namespace gr {
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);
@@ -267,6 +283,12 @@ namespace gr {
}
void
+ waterfall_sink_f_impl::set_time_title(const std::string &title)
+ {
+ d_main_gui->setTimeTitle(title);
+ }
+
+ void
waterfall_sink_f_impl::set_line_label(int which, const std::string &label)
{
d_main_gui->setLineLabel(which, label.c_str());
@@ -429,6 +451,13 @@ namespace gr {
memset(d_magbufs[i], 0, newfftsize*sizeof(double));
}
+ d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
+ volk_get_alignment()));
+ d_pdu_magbuf = (double*)volk_malloc(d_fftsize*sizeof(double)*200,
volk_get_alignment());
+ d_magbufs.push_back(d_pdu_magbuf);
+ memset(d_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;
@@ -535,5 +564,64 @@ namespace gr {
return j;
}
+ void
+ waterfall_sink_f_impl::handle_pdus(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);
+
+ len = pmt::length(samples);
+
+ 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 float *in;
+ if(pmt::is_f32vector(samples)) {
+ in = (const float*)pmt::f32vector_elements(samples, len);
+ }
+ else {
+ throw std::runtime_error("waterfall sink: unknown data type of
samples; must be float.");
+ }
+
+ 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++) {
+ d_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_f_impl.h
b/gr-qtgui/lib/waterfall_sink_f_impl.h
index 8be0003..b7223b7 100644
--- a/gr-qtgui/lib/waterfall_sink_f_impl.h
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.h
@@ -54,6 +54,7 @@ namespace gr {
int d_index;
std::vector<float*> d_residbufs;
std::vector<double*> d_magbufs;
+ double *d_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 PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
public:
waterfall_sink_f_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);
- [Commit-gnuradio] [gnuradio] 04/16: fec: code clean-up for block 'ber_bf'., (continued)
- [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, 2015/07/21
- [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 <=
- [Commit-gnuradio] [gnuradio] 14/16: qtgui: waterfall plots, git, 2015/07/21
- [Commit-gnuradio] [gnuradio] 06/16: digital: whitespace fixes, git, 2015/07/21