GNU Radio Manual and C++ API Reference  3.8.2.0
The Free & Open Software Radio Ecosystem
eye_sink_c.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2020 Free Software Foundation, Inc.
4  *
5  * This is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3, or (at your option)
8  * any later version.
9  *
10  * This software is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this software; see the file COPYING. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef INCLUDED_QTGUI_EYE_SINK_C_H
22 #define INCLUDED_QTGUI_EYE_SINK_C_H
23 
24 #ifdef ENABLE_PYTHON
25 #include <Python.h>
26 #endif
27 
28 #include <gnuradio/qtgui/api.h>
30 #include <gnuradio/sync_block.h>
31 #include <qapplication.h>
32 
33 namespace gr {
34 namespace qtgui {
35 
36 /*!
37  * \brief A graphical sink to display signals eye patterns.
38  * \ingroup qtgui
39  *
40  * \details
41  * This is a QT-based graphical sink which takes a set of a complex
42  * streams and plots them as an eye pattern. For each signal, both
43  * the signal's I and Q eye patterns are plotted. Eye patterns are
44  * 2 symbol's time long. Symbol rate must be an integer multiple of
45  * the sample rate to obtain the eye pattern. The \a set_title and
46  * \a set_color functions can be used to change the label and color
47  * for a given input number.
48  *
49  * Trigger occurs at the beginning of each stream used to plot the
50  * eye pattern; whilst a real eye diagram would be triggered with
51  * a (recovered) symbol clock. For these reasons, triggering of
52  * noisy and/or unsynchronized signals may lead to incorrect eye
53  * pattern.
54  *
55  * The sink supports plotting streaming complex data or
56  * messages. The message port is named "in". The two modes cannot
57  * be used simultaneously, and \p nconnections should be set to 0
58  * when using the message mode. GRC handles this issue by
59  * providing the "Complex Message" type that removes the streaming
60  * port(s).
61  *
62  * This sink can plot messages that contain either uniform vectors
63  * of complex 32 values (pmt::is_c32vector) or PDUs where the data
64  * is a uniform vector of complex 32 values.
65  */
66 class QTGUI_API eye_sink_c : virtual public gr::sync_block
67 {
68 public:
69  // gr::qtgui::eye_sink_c::sptr
70  typedef boost::shared_ptr<eye_sink_c> sptr;
71 
72  /*!
73  * \brief Build complex eye sink
74  *
75  * \param size number of points to plot at once
76  * \param samp_rate sample rate (used to set x-axis labels)
77  * \param name title for the plot
78  * \param nconnections number of signals connected to sink
79  * \param parent a QWidget parent object, if any
80  */
81  static sptr make(int size,
82  double samp_rate,
83  const std::string& name,
84  unsigned int nconnections = 1,
85  QWidget* parent = NULL);
86 
87  virtual void exec_() = 0;
88  virtual QWidget* qwidget() = 0;
89 
90 #ifdef ENABLE_PYTHON
91  virtual PyObject* pyqwidget() = 0;
92 #else
93  virtual void* pyqwidget() = 0;
94 #endif
95 
96  virtual void set_y_axis(double min, double max) = 0;
97  virtual void set_y_label(const std::string& label, const std::string& unit = "") = 0;
98  virtual void set_update_time(double t) = 0;
99  virtual void set_samp_per_symbol(unsigned int sps) = 0;
100  virtual void set_title(const std::string& title) = 0;
101  virtual void set_line_label(unsigned int which, const std::string& label) = 0;
102  virtual void set_line_color(unsigned int which, const std::string& color) = 0;
103  virtual void set_line_width(unsigned int which, int width) = 0;
104  virtual void set_line_style(unsigned int which, int style) = 0;
105  virtual void set_line_marker(unsigned int which, int marker) = 0;
106  virtual void set_nsamps(const int newsize) = 0;
107  virtual void set_samp_rate(const double samp_rate) = 0;
108  virtual void set_line_alpha(unsigned int which, double alpha) = 0;
109 
110  /*!
111  * Set up a trigger for the sink to know when to start
112  * plotting. Useful to isolate events and avoid noise.
113  *
114  * The trigger modes are Free, Auto, Normal, and Tag (see
115  * gr::qtgui::trigger_mode). The first three are like a normal
116  * oscope trigger function. Free means free running with no
117  * trigger, auto will trigger if the trigger event is seen, but
118  * will still plot otherwise, and normal will hold until the
119  * trigger event is observed. The Tag trigger mode allows us to
120  * trigger off a specific stream tag. The tag trigger is based
121  * only on the name of the tag, so when a tag of the given name
122  * is seen, the trigger is activated.
123  *
124  * In auto and normal mode, we look for the slope of the of the
125  * signal. Given a gr::qtgui::trigger_slope as either Positive
126  * or Negative, if the value between two samples moves in the
127  * given direction (x[1] > x[0] for Positive or x[1] < x[0] for
128  * Negative), then the trigger is activated.
129  *
130  * With the complex eye sink, each input has two eye patterns
131  * drawn for the real and imaginary parts of the signal. When
132  * selecting the \p channel value, channel 0 is the real signal
133  * and channel 1 is the imaginary signal. For more than 1 input
134  * stream, channel 2i is the real part of the ith input and
135  * channel (2i+1) is the imaginary part of the ith input
136  * channel.
137  *
138  * The \p delay value is specified in time based off the sample
139  * rate. If the sample rate of the block is set to 1, the delay
140  * is then also the sample number offset. This is the offset
141  * from the left-hand y-axis of the plot. It delays the signal
142  * to show the trigger event at the given delay along with some
143  * portion of the signal before the event. The delay must be
144  * within 0 - t_max where t_max is the maximum amount of time
145  * displayed on the eye pattern equal to 2 symbol time.
146  *
147  * \param mode The trigger_mode: free, auto, normal, or tag.
148  * \param slope The trigger_slope: positive or negative. Only
149  * used for auto and normal modes.
150  * \param level The magnitude of the trigger even for auto or normal modes.
151  * \param delay The delay (in units of time) for where the trigger happens.
152  * \param channel Which input channel to use for the trigger events.
153  * \param tag_key The name (as a string) of the tag to trigger off
154  * of if using the tag mode.
155  */
158  float level,
159  float delay,
160  int channel,
161  const std::string& tag_key = "") = 0;
162 
163  virtual std::string title() = 0;
164  virtual std::string line_label(unsigned int which) = 0;
165  virtual std::string line_color(unsigned int which) = 0;
166  virtual int line_width(unsigned int which) = 0;
167  virtual int line_style(unsigned int which) = 0;
168  virtual int line_marker(unsigned int which) = 0;
169  virtual double line_alpha(unsigned int which) = 0;
170 
171  virtual void set_size(int width, int height) = 0;
172 
173  virtual void enable_menu(bool en = true) = 0;
174  virtual void enable_grid(bool en = true) = 0;
175  virtual void enable_autoscale(bool en = true) = 0;
176  virtual void enable_stem_plot(bool en = true) = 0; // Unused, but do not remove
177  virtual void enable_semilogx(bool en = true) = 0; // Unused, but do not remove
178  virtual void enable_semilogy(bool en = true) = 0; // Unused, but do not remove
179  virtual void enable_control_panel(bool en = true) = 0;
180  virtual void enable_tags(unsigned int which, bool en) = 0;
181  virtual void enable_tags(bool en) = 0;
182  virtual void enable_axis_labels(bool en = true) = 0;
183  virtual void disable_legend() = 0;
184 
185  virtual int nsamps() const = 0;
186  virtual void reset() = 0;
187 
188  QApplication* d_qApplication;
189 };
190 
191 } // namespace qtgui
192 } // namespace gr
193 
194 #endif /* INCLUDED_QTGUI_EYE_SINK_C_H */
gr::qtgui::eye_sink_c::set_update_time
virtual void set_update_time(double t)=0
gr::qtgui::eye_sink_c::disable_legend
virtual void disable_legend()=0
gr::qtgui::eye_sink_c::set_title
virtual void set_title(const std::string &title)=0
gr::qtgui::eye_sink_c::set_trigger_mode
virtual void set_trigger_mode(gr::qtgui::trigger_mode mode, gr::qtgui::trigger_slope slope, float level, float delay, int channel, const std::string &tag_key="")=0
gr::qtgui::eye_sink_c::enable_semilogy
virtual void enable_semilogy(bool en=true)=0
QTGUI_API
#define QTGUI_API
Definition: gr-qtgui/include/gnuradio/qtgui/api.h:30
gr::qtgui::eye_sink_c::qwidget
virtual QWidget * qwidget()=0
gr::qtgui::eye_sink_c::set_line_label
virtual void set_line_label(unsigned int which, const std::string &label)=0
gr::qtgui::eye_sink_c::make
static sptr make(int size, double samp_rate, const std::string &name, unsigned int nconnections=1, QWidget *parent=NULL)
Build complex eye sink.
gr::qtgui::eye_sink_c::enable_control_panel
virtual void enable_control_panel(bool en=true)=0
gr::trellis::min
float min(float a, float b)
gr::qtgui::eye_sink_c::title
virtual std::string title()=0
gr::qtgui::eye_sink_c::set_samp_per_symbol
virtual void set_samp_per_symbol(unsigned int sps)=0
gr::qtgui::eye_sink_c::line_style
virtual int line_style(unsigned int which)=0
gr::qtgui::eye_sink_c::set_nsamps
virtual void set_nsamps(const int newsize)=0
gr::qtgui::eye_sink_c::enable_menu
virtual void enable_menu(bool en=true)=0
gr::qtgui::eye_sink_c::reset
virtual void reset()=0
gr::qtgui::eye_sink_c::enable_autoscale
virtual void enable_autoscale(bool en=true)=0
gr::qtgui::eye_sink_c::set_line_width
virtual void set_line_width(unsigned int which, int width)=0
gr::qtgui::eye_sink_c::set_y_axis
virtual void set_y_axis(double min, double max)=0
api.h
gr::qtgui::eye_sink_c::enable_grid
virtual void enable_grid(bool en=true)=0
gr::sync_block
synchronous 1:1 input to output with history
Definition: sync_block.h:38
gr::qtgui::eye_sink_c::set_line_alpha
virtual void set_line_alpha(unsigned int which, double alpha)=0
gr::qtgui::eye_sink_c::enable_semilogx
virtual void enable_semilogx(bool en=true)=0
gr::qtgui::eye_sink_c::set_samp_rate
virtual void set_samp_rate(const double samp_rate)=0
gr::qtgui::eye_sink_c::enable_tags
virtual void enable_tags(bool en)=0
sync_block.h
gr::qtgui::eye_sink_c::set_y_label
virtual void set_y_label(const std::string &label, const std::string &unit="")=0
gr::qtgui::eye_sink_c::exec_
virtual void exec_()=0
trigger_mode.h
gr::qtgui::eye_sink_c::set_line_style
virtual void set_line_style(unsigned int which, int style)=0
gr::qtgui::eye_sink_c
A graphical sink to display signals eye patterns.
Definition: eye_sink_c.h:67
gr::qtgui::eye_sink_c::line_width
virtual int line_width(unsigned int which)=0
gr::qtgui::eye_sink_c::enable_axis_labels
virtual void enable_axis_labels(bool en=true)=0
gr::qtgui::eye_sink_c::line_marker
virtual int line_marker(unsigned int which)=0
gr::qtgui::eye_sink_c::pyqwidget
virtual void * pyqwidget()=0
gr::qtgui::eye_sink_c::nsamps
virtual int nsamps() const =0
gr::qtgui::eye_sink_c::set_size
virtual void set_size(int width, int height)=0
gr
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:43
gr::qtgui::eye_sink_c::set_line_color
virtual void set_line_color(unsigned int which, const std::string &color)=0
gr::qtgui::eye_sink_c::line_label
virtual std::string line_label(unsigned int which)=0
gr::qtgui::eye_sink_c::d_qApplication
QApplication * d_qApplication
Definition: eye_sink_c.h:188
gr::qtgui::eye_sink_c::enable_tags
virtual void enable_tags(unsigned int which, bool en)=0
gr::qtgui::eye_sink_c::line_color
virtual std::string line_color(unsigned int which)=0
gr::qtgui::eye_sink_c::enable_stem_plot
virtual void enable_stem_plot(bool en=true)=0
gr::qtgui::eye_sink_c::sptr
boost::shared_ptr< eye_sink_c > sptr
Definition: eye_sink_c.h:70
gr::qtgui::eye_sink_c::set_line_marker
virtual void set_line_marker(unsigned int which, int marker)=0
gr::qtgui::trigger_slope
trigger_slope
Definition: trigger_mode.h:36
gr::qtgui::trigger_mode
trigger_mode
Definition: trigger_mode.h:29
gr::qtgui::eye_sink_c::line_alpha
virtual double line_alpha(unsigned int which)=0