summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2015-10-26 14:17:23 -0400
committerTom Rondeau <tom@trondeau.com>2015-10-29 16:21:03 -0400
commit253e6c3d8ab51eb8d660a0d8f881498c33b2bb1b (patch)
treeb0acac26472dfe589f2eb0b421d7d0f151db2ad5
parent38297b73f7d6f95ef994552452ed043d6cdb29ef (diff)
qtgui: time plotters support PDU message plotting.
-rw-r--r--gr-qtgui/grc/qtgui_time_sink_x.xml11
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.cc68
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.h5
-rw-r--r--gr-qtgui/lib/time_sink_f_impl.cc65
-rw-r--r--gr-qtgui/lib/time_sink_f_impl.h5
5 files changed, 137 insertions, 17 deletions
diff --git a/gr-qtgui/grc/qtgui_time_sink_x.xml b/gr-qtgui/grc/qtgui_time_sink_x.xml
index 0d77c4f7e9..913ef8870e 100644
--- a/gr-qtgui/grc/qtgui_time_sink_x.xml
+++ b/gr-qtgui/grc/qtgui_time_sink_x.xml
@@ -889,14 +889,19 @@ $(gui_hint()($win))</make>
<hide>#if (int($nconnections()) >= 10 or ($type() == "complex" and int($nconnections()) >= 5)) then 'part' else 'all'#</hide>
</param>
-
- <check>$tr_chan &lt; 2*$nconnections</check>
-
<sink>
<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 [tab_id@tab_index]: [row, col, row_span, col_span]. \
diff --git a/gr-qtgui/lib/time_sink_c_impl.cc b/gr-qtgui/lib/time_sink_c_impl.cc
index fe33a0997e..45aef41827 100644
--- a/gr-qtgui/lib/time_sink_c_impl.cc
+++ b/gr-qtgui/lib/time_sink_c_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011-2013 Free Software Foundation, Inc.
+ * Copyright 2011-2013,2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -50,7 +50,7 @@ namespace gr {
int nconnections,
QWidget *parent)
: sync_block("time_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_samp_rate(samp_rate), d_name(name),
d_nconnections(2*nconnections), d_parent(parent)
@@ -65,12 +65,19 @@ namespace gr {
d_main_gui = NULL;
- for(int n = 0; n < d_nconnections; n++) {
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("pdus"));
+ set_msg_handler(pmt::mp("pdus"),
+ boost::bind(&time_sink_c_impl::handle_pdus, this, _1));
+
+ // +2 for the PDU message buffers
+ for(int n = 0; n < d_nconnections+2; n++) {
d_buffers.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
volk_get_alignment()));
memset(d_buffers[n], 0, d_buffer_size*sizeof(double));
}
+ // We don't use cbuffers with the PDU message handling capabilities.
for(int n = 0; n < d_nconnections/2; n++) {
d_cbuffers.push_back((gr_complex*)volk_malloc(d_buffer_size*sizeof(gr_complex),
volk_get_alignment()));
@@ -99,7 +106,7 @@ namespace gr {
d_main_gui->close();
// d_main_gui is a qwidget destroyed with its parent
- for(int n = 0; n < d_nconnections; n++) {
+ for(int n = 0; n < d_nconnections+2; n++) {
volk_free(d_buffers[n]);
}
for(int n = 0; n < d_nconnections/2; n++) {
@@ -136,7 +143,8 @@ namespace gr {
d_qApplication->setStyleSheet(sstext);
}
- d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new TimeDisplayForm(numplots, d_parent);
d_main_gui->setNPoints(d_size);
d_main_gui->setSampleRate(d_samp_rate);
@@ -335,7 +343,7 @@ namespace gr {
d_buffer_size = 2*d_size;
// Resize buffers and replace data
- for(int n = 0; n < d_nconnections; n++) {
+ for(int n = 0; n < d_nconnections+2; n++) {
volk_free(d_buffers[n]);
d_buffers[n] = (double*)volk_malloc(d_buffer_size*sizeof(double),
volk_get_alignment());
@@ -679,5 +687,53 @@ namespace gr {
return nitems;
}
+ void
+ time_sink_c_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 gr_complex *in;
+ if(pmt::is_c32vector(samples)) {
+ in = (const gr_complex*)pmt::c32vector_elements(samples, len);
+ }
+ else {
+ throw std::runtime_error("time_sink_c: unknown data type "
+ "of samples; must be complex.");
+ }
+
+ // 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();
+
+ set_nsamps(len);
+
+ volk_32fc_deinterleave_64f_x2(d_buffers[2*d_nconnections+0],
+ d_buffers[2*d_nconnections+1],
+ in, len);
+
+ std::vector< std::vector<gr::tag_t> > t;
+ d_qApplication->postEvent(d_main_gui,
+ new TimeUpdateEvent(d_buffers, len, t));
+ }
+ }
+
} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/time_sink_c_impl.h b/gr-qtgui/lib/time_sink_c_impl.h
index f29d84768d..ce6bd94d51 100644
--- a/gr-qtgui/lib/time_sink_c_impl.h
+++ b/gr-qtgui/lib/time_sink_c_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011-2013 Free Software Foundation, Inc.
+ * Copyright 2011-2013,2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -72,6 +72,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:
time_sink_c_impl(int size, double samp_rate,
const std::string &name,
diff --git a/gr-qtgui/lib/time_sink_f_impl.cc b/gr-qtgui/lib/time_sink_f_impl.cc
index d0cafd42a9..10d39addd6 100644
--- a/gr-qtgui/lib/time_sink_f_impl.cc
+++ b/gr-qtgui/lib/time_sink_f_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011-2013 Free Software Foundation, Inc.
+ * Copyright 2011-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("time_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_buffer_size(2*size), d_samp_rate(samp_rate), d_name(name),
d_nconnections(nconnections), d_parent(parent)
@@ -67,7 +67,13 @@ namespace gr {
d_main_gui = NULL;
- for(int n = 0; n < d_nconnections; n++) {
+ // setup PDU handling input port
+ message_port_register_in(pmt::mp("pdus"));
+ set_msg_handler(pmt::mp("pdus"),
+ boost::bind(&time_sink_f_impl::handle_pdus, this, _1));
+
+ // +1 for the PDU buffer
+ for(int n = 0; n < d_nconnections+1; n++) {
d_buffers.push_back((double*)volk_malloc(d_buffer_size*sizeof(double),
volk_get_alignment()));
memset(d_buffers[n], 0, d_buffer_size*sizeof(double));
@@ -99,7 +105,7 @@ namespace gr {
d_main_gui->close();
// d_main_gui is a qwidget destroyed with its parent
- for(int n = 0; n < d_nconnections; n++) {
+ for(int n = 0; n < d_nconnections+1; n++) {
volk_free(d_buffers[n]);
volk_free(d_fbuffers[n]);
}
@@ -134,7 +140,8 @@ namespace gr {
d_qApplication->setStyleSheet(sstext);
}
- d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
+ int numplots = (d_nconnections > 0) ? d_nconnections : 1;
+ d_main_gui = new TimeDisplayForm(numplots, d_parent);
d_main_gui->setNPoints(d_size);
d_main_gui->setSampleRate(d_samp_rate);
@@ -333,7 +340,7 @@ namespace gr {
d_buffer_size = 2*d_size;
// Resize buffers and replace data
- for(int n = 0; n < d_nconnections; n++) {
+ for(int n = 0; n < d_nconnections+1; n++) {
volk_free(d_buffers[n]);
d_buffers[n] = (double*)volk_malloc(d_buffer_size*sizeof(double),
volk_get_alignment());
@@ -672,5 +679,51 @@ namespace gr {
return nitems;
}
+ void
+ time_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("time_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();
+
+ set_nsamps(len);
+
+ volk_32f_convert_64f(d_buffers[d_nconnections], in, len);
+
+ std::vector< std::vector<gr::tag_t> > t;
+ d_qApplication->postEvent(d_main_gui,
+ new TimeUpdateEvent(d_buffers, len, t));
+ }
+ }
+
} /* namespace qtgui */
} /* namespace gr */
diff --git a/gr-qtgui/lib/time_sink_f_impl.h b/gr-qtgui/lib/time_sink_f_impl.h
index 1d42f36994..25d920c0da 100644
--- a/gr-qtgui/lib/time_sink_f_impl.h
+++ b/gr-qtgui/lib/time_sink_f_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011-2013 Free Software Foundation, Inc.
+ * Copyright 2011-2013,2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -72,6 +72,9 @@ namespace gr {
void _test_trigger_norm(int nitems, gr_vector_const_void_star inputs);
bool _test_trigger_slope(const float *in) const;
+ // Handles message input port for displaying PDU samples.
+ void handle_pdus(pmt::pmt_t msg);
+
public:
time_sink_f_impl(int size, double samp_rate,
const std::string &name,