[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 09/21: qtgui: constellation plotter support
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 09/21: qtgui: constellation 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 38297b73f7d6f95ef994552452ed043d6cdb29ef
Author: Tom Rondeau <address@hidden>
Date: Mon Oct 26 13:01:06 2015 -0400
qtgui: constellation plotter supports PDU message plotting.
---
gr-qtgui/grc/qtgui_const_sink_x.xml | 8 ++++
gr-qtgui/lib/const_sink_c_impl.cc | 75 ++++++++++++++++++++++++++++++++++---
gr-qtgui/lib/const_sink_c_impl.h | 5 ++-
3 files changed, 82 insertions(+), 6 deletions(-)
diff --git a/gr-qtgui/grc/qtgui_const_sink_x.xml
b/gr-qtgui/grc/qtgui_const_sink_x.xml
index c17ceff..5a21337 100644
--- a/gr-qtgui/grc/qtgui_const_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_const_sink_x.xml
@@ -814,7 +814,15 @@ $(gui_hint()($win))</make>
<name>in</name>
<type>$type</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/lib/const_sink_c_impl.cc
b/gr-qtgui/lib/const_sink_c_impl.cc
index 0711315..d76e742 100644
--- a/gr-qtgui/lib/const_sink_c_impl.cc
+++ b/gr-qtgui/lib/const_sink_c_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012,2014 Free Software Foundation, Inc.
+ * Copyright 2012,2014-2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -49,7 +49,7 @@ namespace gr {
int nconnections,
QWidget *parent)
: sync_block("const_sink_c",
- io_signature::make(nconnections, nconnections,
sizeof(gr_complex)),
+ io_signature::make(0, nconnections, sizeof(gr_complex)),
io_signature::make(0, 0, 0)),
d_size(size), d_buffer_size(2*size), d_name(name),
d_nconnections(nconnections), d_parent(parent)
@@ -66,6 +66,11 @@ namespace gr {
d_index = 0;
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("pdus"));
+ set_msg_handler(pmt::mp("pdus"),
+ boost::bind(&const_sink_c_impl::handle_pdus, this, _1));
+
for(int i = 0; i < d_nconnections; i++) {
d_residbufs_real.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
volk_get_alignment()));
@@ -75,6 +80,14 @@ namespace gr {
memset(d_residbufs_imag[i], 0, d_buffer_size*sizeof(double));
}
+ // Used for PDU message input
+
d_residbufs_real.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
+ volk_get_alignment()));
+
d_residbufs_imag.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
+ volk_get_alignment()));
+ memset(d_residbufs_real[d_nconnections], 0,
d_buffer_size*sizeof(double));
+ memset(d_residbufs_imag[d_nconnections], 0,
d_buffer_size*sizeof(double));
+
// Set alignment properties for VOLK
const int alignment_multiple =
volk_get_alignment() / sizeof(gr_complex);
@@ -94,7 +107,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_real[i]);
volk_free(d_residbufs_imag[i]);
}
@@ -129,7 +142,8 @@ namespace gr {
d_qApplication->setStyleSheet(sstext);
}
- d_main_gui = new ConstellationDisplayForm(d_nconnections, d_parent);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new ConstellationDisplayForm(numplots, d_parent);
d_main_gui->setNPoints(d_size);
if(d_name.size() > 0)
@@ -318,7 +332,8 @@ namespace gr {
d_index = 0;
// Resize residbuf and replace data
- for(int i = 0; i < d_nconnections; i++) {
+ // +1 to handle PDU message input buffers
+ for(int i = 0; i < d_nconnections+1; i++) {
volk_free(d_residbufs_real[i]);
volk_free(d_residbufs_imag[i]);
d_residbufs_real[i] =
(double*)volk_malloc(d_buffer_size*sizeof(double),
@@ -533,5 +548,55 @@ namespace gr {
return nitems;
}
+ void
+ const_sink_c_impl::handle_pdus(pmt::pmt_t msg)
+ {
+ size_t len = 0;
+ 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("const_sink_c: message must be either "
+ "a PDU or a uniform vector of samples.");
+ }
+
+ len = pmt::length(samples);
+
+ const gr_complex *in;
+ if(pmt::is_c32vector(samples)) {
+ in = (const gr_complex*)pmt::c32vector_elements(samples, len);
+ }
+ else {
+ throw std::runtime_error("const_sink_c: unknown data type "
+ "of samples; must be complex.");
+ }
+
+ set_nsamps(len);
+
+ // 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();
+
+ // Copy data into the buffers.
+ volk_32fc_deinterleave_64f_x2(d_residbufs_real[d_nconnections],
+ d_residbufs_imag[d_nconnections],
+ in, len);
+
+ d_qApplication->postEvent(d_main_gui,
+ new ConstUpdateEvent(d_residbufs_real,
+ d_residbufs_imag,
+ len));
+ }
+ }
+
} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/const_sink_c_impl.h b/gr-qtgui/lib/const_sink_c_impl.h
index fc3706e..7d52c3a 100644
--- a/gr-qtgui/lib/const_sink_c_impl.h
+++ b/gr-qtgui/lib/const_sink_c_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012,2014 Free Software Foundation, Inc.
+ * Copyright 2012,2014-2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -67,6 +67,9 @@ namespace gr {
void _test_trigger_norm(int nitems, gr_vector_const_void_star inputs);
bool _test_trigger_slope(const gr_complex *in) const;
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
public:
const_sink_c_impl(int size,
const std::string &name,
- [Commit-gnuradio] [gnuradio] 02/21: grc: fix port placement for hidden ports, (continued)
- [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, 2015/10/30
- [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 <=
- [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
- [Commit-gnuradio] [gnuradio] 07/21: qtgui: freq plotters support PDU message plotting., git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 19/21: qtgui: cleaned non in-tree block from qtgui_message_inputs example., git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 10/21: qtgui: time plotters support PDU message plotting., git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 14/21: qtgui: moving to only allow either streaming or message modes., git, 2015/10/30
- [Commit-gnuradio] [gnuradio] 16/21: qtgui: adding example for using the message passing inputs to the QTGUI sinks., git, 2015/10/30