[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 12/21: qtgui: histogram plotter supports PD
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 12/21: qtgui: histogram plotter supports PDU message plotting. |
Date: |
Fri, 30 Oct 2015 21:11:27 +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 eadb401e3d630f7b0e2e103f2323b4cce6d2f8fb
Author: Tom Rondeau <address@hidden>
Date: Tue Oct 27 14:53:04 2015 -0400
qtgui: histogram plotter supports PDU message plotting.
---
gr-qtgui/grc/qtgui_histogram_sink_x.xml | 10 ++-
.../include/gnuradio/qtgui/HistogramDisplayPlot.h | 2 +
.../include/gnuradio/qtgui/spectrumUpdateEvents.h | 29 ++++++++
gr-qtgui/lib/HistogramDisplayPlot.cc | 20 ++++-
gr-qtgui/lib/histogram_sink_f_impl.cc | 85 ++++++++++++++++++++--
gr-qtgui/lib/histogram_sink_f_impl.h | 5 +-
gr-qtgui/lib/histogramdisplayform.cc | 7 ++
gr-qtgui/lib/spectrumUpdateEvents.cc | 17 +++++
8 files changed, 160 insertions(+), 15 deletions(-)
diff --git a/gr-qtgui/grc/qtgui_histogram_sink_x.xml
b/gr-qtgui/grc/qtgui_histogram_sink_x.xml
index ba04da1..1d28fdd 100644
--- a/gr-qtgui/grc/qtgui_histogram_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_histogram_sink_x.xml
@@ -741,13 +741,19 @@ $(gui_hint()($win))
</param>
-
-
<sink>
<name>in</name>
<type>float</type>
<nports>$nconnections</nports>
+ <optional>1</optional>
+ </sink>
+
+ <sink>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
</sink>
+
<doc>
The GUI hint can be used to position the widget within the application. \
The hint is of the form address@hidden: [row, col, row_span, col_span]. \
diff --git a/gr-qtgui/include/gnuradio/qtgui/HistogramDisplayPlot.h
b/gr-qtgui/include/gnuradio/qtgui/HistogramDisplayPlot.h
index 27002bd..d91f30d 100644
--- a/gr-qtgui/include/gnuradio/qtgui/HistogramDisplayPlot.h
+++ b/gr-qtgui/include/gnuradio/qtgui/HistogramDisplayPlot.h
@@ -59,6 +59,8 @@ public slots:
void setNumBins(int bins);
void setXaxis(double min, double max);
+ void clear();
+
private:
void _resetXAxisPoints(double left, double right);
void _autoScaleY(double bottom, double top);
diff --git a/gr-qtgui/include/gnuradio/qtgui/spectrumUpdateEvents.h
b/gr-qtgui/include/gnuradio/qtgui/spectrumUpdateEvents.h
index 3ea3085..e33eda9 100644
--- a/gr-qtgui/include/gnuradio/qtgui/spectrumUpdateEvents.h
+++ b/gr-qtgui/include/gnuradio/qtgui/spectrumUpdateEvents.h
@@ -328,6 +328,35 @@ private:
};
+class HistogramSetAccumulator: public QEvent
+{
+public:
+ HistogramSetAccumulator(const bool en);
+ ~HistogramSetAccumulator();
+
+ bool getAccumulator() const;
+
+ static QEvent::Type Type()
+ { return QEvent::Type(SpectrumUpdateEventType+1); }
+
+private:
+ bool _en;
+};
+
+class HistogramClearEvent: public QEvent
+{
+public:
+ HistogramClearEvent()
+ : QEvent(QEvent::Type(SpectrumUpdateEventType+2))
+ {}
+
+ ~HistogramClearEvent() {}
+
+ static QEvent::Type Type()
+ { return QEvent::Type(SpectrumUpdateEventType+2); }
+};
+
+
/********************************************************************/
diff --git a/gr-qtgui/lib/HistogramDisplayPlot.cc
b/gr-qtgui/lib/HistogramDisplayPlot.cc
index 0124cc7..9b24295 100644
--- a/gr-qtgui/lib/HistogramDisplayPlot.cc
+++ b/gr-qtgui/lib/HistogramDisplayPlot.cc
@@ -228,16 +228,17 @@ HistogramDisplayPlot::plotNewData(const
std::vector<double*> dataPoints,
// If autoscalex has been clicked, clear the data for the new
// bin widths and reset the x-axis.
if(d_autoscalex_state) {
- for(int n = 0; n < d_nplots; n++)
- memset(d_ydata[n], 0, d_bins*sizeof(double));
+ clear();
_resetXAxisPoints(d_xmin, d_xmax);
d_autoscalex_state = false;
}
+ if(!d_accum) {
+ clear();
+ }
+
int index;
for(int n = 0; n < d_nplots; n++) {
- if(!d_accum)
- memset(d_ydata[n], 0, d_bins*sizeof(double));
for(int64_t point = 0; point < numDataPoints; point++) {
index = boost::math::iround(1e-20 + (dataPoints[n][point] -
d_left)/d_width);
if((index >= 0) && (index < d_bins))
@@ -481,4 +482,15 @@ HistogramDisplayPlot::setNumBins(int bins)
}
}
+
+void
+HistogramDisplayPlot::clear()
+{
+ if(!d_stop) {
+ for(int n = 0; n < d_nplots; n++) {
+ memset(d_ydata[n], 0, d_bins*sizeof(double));
+ }
+ }
+}
+
#endif /* HISTOGRAM_DISPLAY_PLOT_C */
diff --git a/gr-qtgui/lib/histogram_sink_f_impl.cc
b/gr-qtgui/lib/histogram_sink_f_impl.cc
index cdaf5cf..7569c6a 100644
--- a/gr-qtgui/lib/histogram_sink_f_impl.cc
+++ b/gr-qtgui/lib/histogram_sink_f_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Free Software Foundation, Inc.
+ * Copyright 2013,2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -52,7 +52,7 @@ namespace gr {
int nconnections,
QWidget *parent)
: sync_block("histogram_sink_f",
- io_signature::make(nconnections, nconnections,
sizeof(float)),
+ io_signature::make(0, nconnections, sizeof(float)),
io_signature::make(0, 0, 0)),
d_size(size), d_bins(bins), d_xmin(xmin), d_xmax(xmax), d_name(name),
d_nconnections(nconnections), d_parent(parent)
@@ -69,7 +69,13 @@ namespace gr {
d_index = 0;
- for(int i = 0; i < d_nconnections; i++) {
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("pdus"));
+ set_msg_handler(pmt::mp("pdus"),
+ boost::bind(&histogram_sink_f_impl::handle_pdus, this,
_1));
+
+ // +1 for the PDU buffer
+ for(int i = 0; i < d_nconnections+1; i++) {
d_residbufs.push_back((double*)volk_malloc(d_size*sizeof(double),
volk_get_alignment()));
memset(d_residbufs[i], 0, d_size*sizeof(double));
@@ -89,7 +95,7 @@ namespace gr {
d_main_gui->close();
// d_main_gui is a qwidget destroyed with its parent
- for(int i = 0; i < d_nconnections; i++) {
+ for(int i = 0; i < d_nconnections+1; i++) {
volk_free(d_residbufs[i]);
}
@@ -123,7 +129,8 @@ namespace gr {
d_qApplication->setStyleSheet(sstext);
}
- d_main_gui = new HistogramDisplayForm(d_nconnections, d_parent);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new HistogramDisplayForm(numplots, d_parent);
d_main_gui->setNumBins(d_bins);
d_main_gui->setNPoints(d_size);
d_main_gui->setXaxis(d_xmin, d_xmax);
@@ -282,7 +289,7 @@ namespace gr {
if(newsize != d_size) {
// Resize residbuf and replace data
- for(int i = 0; i < d_nconnections; i++) {
+ for(int i = 0; i < d_nconnections+1; i++) {
volk_free(d_residbufs[i]);
d_residbufs[i] = (double*)volk_malloc(newsize*sizeof(double),
volk_get_alignment());
@@ -382,8 +389,8 @@ namespace gr {
int
histogram_sink_f_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
int n=0, j=0, idx=0;
const float *in = (const float*)input_items[idx];
@@ -431,5 +438,67 @@ namespace gr {
return j;
}
+ void
+ histogram_sink_f_impl::handle_pdus(pmt::pmt_t msg)
+ {
+ size_t len;
+ pmt::pmt_t dict, samples;
+
+ // Test to make sure this is either a PDU or a uniform vector of
+ // samples. Get the samples PMT and the dictionary if it's a PDU.
+ // If not, we throw an error and exit.
+ if(pmt::is_pair(msg)) {
+ dict = pmt::car(msg);
+ samples = pmt::cdr(msg);
+ }
+ else if(pmt::is_uniform_vector(msg)) {
+ samples = msg;
+ }
+ else {
+ throw std::runtime_error("time_sink_c: message must be either "
+ "a PDU or a uniform vector of samples.");
+ }
+
+ len = pmt::length(samples);
+
+ const float *in;
+ if(pmt::is_f32vector(samples)) {
+ in = (const float*)pmt::f32vector_elements(samples, len);
+ }
+ else {
+ throw std::runtime_error("histogram_sink_f: unknown data type "
+ "of samples; must be float.");
+ }
+
+ // Plot if we're past the last update time
+ if(gr::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gr::high_res_timer_now();
+
+ npoints_resize();
+
+ // Clear the histogram
+ d_qApplication->postEvent(d_main_gui, new HistogramClearEvent());
+
+ // Set to accumulate over length of the current PDU
+ d_qApplication->postEvent(d_main_gui, new
HistogramSetAccumulator(true));
+
+ float nplots_f = static_cast<float>(len) / static_cast<float>(d_size);
+ int nplots = static_cast<int>(ceilf(nplots_f));
+ int idx = 0;
+ for(int n = 0; n < nplots; n++) {
+ int size = std::min(d_size, (int)(len - idx));
+ volk_32f_convert_64f_u(d_residbufs[d_nconnections], &in[idx], size);
+
+ d_qApplication->postEvent(d_main_gui,
+ new HistogramUpdateEvent(d_residbufs,
size));
+
+ idx += size;
+ }
+
+ // Turn accumulation off
+ d_qApplication->postEvent(d_main_gui, new
HistogramSetAccumulator(false));
+ }
+ }
+
} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/histogram_sink_f_impl.h
b/gr-qtgui/lib/histogram_sink_f_impl.h
index e8ae1ac..acacf1a 100644
--- a/gr-qtgui/lib/histogram_sink_f_impl.h
+++ b/gr-qtgui/lib/histogram_sink_f_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2013 Free Software Foundation, Inc.
+ * Copyright 2013,2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -54,6 +54,9 @@ namespace gr {
void npoints_resize();
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
public:
histogram_sink_f_impl(int size, int bins,
double xmin, double xmax,
diff --git a/gr-qtgui/lib/histogramdisplayform.cc
b/gr-qtgui/lib/histogramdisplayform.cc
index c4e9b51..7d64760 100644
--- a/gr-qtgui/lib/histogramdisplayform.cc
+++ b/gr-qtgui/lib/histogramdisplayform.cc
@@ -123,6 +123,13 @@ HistogramDisplayForm::customEvent(QEvent * e)
if(e->type() == HistogramUpdateEvent::Type()) {
newData(e);
}
+ else if(e->type() == HistogramSetAccumulator::Type()) {
+ bool en = ((HistogramSetAccumulator*)e)->getAccumulator();
+ setAccumulate(en);
+ }
+ else if(e->type() == HistogramClearEvent::Type()) {
+ getPlot()->clear();
+ }
}
void
diff --git a/gr-qtgui/lib/spectrumUpdateEvents.cc
b/gr-qtgui/lib/spectrumUpdateEvents.cc
index 60e07fc..383332c 100644
--- a/gr-qtgui/lib/spectrumUpdateEvents.cc
+++ b/gr-qtgui/lib/spectrumUpdateEvents.cc
@@ -542,6 +542,23 @@ HistogramUpdateEvent::getNumDataPoints() const
}
+HistogramSetAccumulator::HistogramSetAccumulator(const bool en)
+ : QEvent(QEvent::Type(SpectrumUpdateEventType+1)),
+ _en(en)
+{
+}
+
+HistogramSetAccumulator::~HistogramSetAccumulator()
+{
+}
+
+bool
+HistogramSetAccumulator::getAccumulator() const
+{
+ return _en;
+}
+
+
/***************************************************************************/
- [Commit-gnuradio] [gnuradio] branch master updated (1aface8 -> f8a84eb), git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 03/21: grc: disconnect hidden blocks, git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 01/21: blocks: Add Complex to IChar block, git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 13/21: qtgui: time display: fixes a threading issue., git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 02/21: grc: fix port placement for hidden ports, git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 06/21: qtgui: whitespace and line formatting, git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 12/21: qtgui: histogram plotter supports PDU message plotting.,
git <=
- [Commit-gnuradio] [gnuradio] 08/21: qtgui: Better support for waterfall PDU message port., git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 05/21: qtgui: added documentation describing pdus message input port., git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 04/21: qtgui: Throw an error if the PDU is not a multiple of the fft size., git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 17/21: Merge branch 'maint', git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 18/21: Merge remote-tracking branch 'miek/complex-to-ichar', git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 20/21: Merge branch 'maint', git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 11/21: qtgui: time raster plotters support PDU message plotting., git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 09/21: qtgui: constellation plotter supports PDU message plotting., git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 21/21: Merge remote-tracking branch 'tom/qtgui/pdu_handling', git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 15/21: qtgui: documenting message input support., git, 2015/10/30