commit-gnuradio
[Top][All Lists]
Advanced

[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,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]