1 /* -*- c++ -*- */ 2 /* 3 * Copyright 2011-2013,2015 Free Software Foundation, Inc. 4 * 5 * This file is part of GNU Radio 6 * 7 * GNU Radio is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3, or (at your option) 10 * any later version. 11 * 12 * GNU Radio is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with GNU Radio; see the file COPYING. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #ifndef INCLUDED_QTGUI_TIME_SINK_C_IMPL_H 24 #define INCLUDED_QTGUI_TIME_SINK_C_IMPL_H 25 26 #include <gnuradio/qtgui/time_sink_c.h> 27 28 #include <gnuradio/high_res_timer.h> 29 #include <gnuradio/qtgui/timedisplayform.h> 30 31 namespace gr { 32 namespace qtgui { 33 34 class QTGUI_API time_sink_c_impl : public time_sink_c 35 { 36 private: 37 void initialize(); 38 39 int d_size, d_buffer_size; 40 double d_samp_rate; 41 std::string d_name; 42 unsigned int d_nconnections; 43 44 const pmt::pmt_t d_tag_key; 45 46 int d_index, d_start, d_end; 47 std::vector<gr_complex*> d_cbuffers; 48 std::vector<double*> d_buffers; 49 std::vector<std::vector<gr::tag_t>> d_tags; 50 51 int d_argc; 52 char* d_argv; 53 QWidget* d_parent; 54 TimeDisplayForm* d_main_gui; 55 56 gr::high_res_timer_type d_update_time; 57 gr::high_res_timer_type d_last_time; 58 59 // Members used for triggering scope 60 trigger_mode d_trigger_mode; 61 trigger_slope d_trigger_slope; 62 float d_trigger_level; 63 int d_trigger_channel; 64 int d_trigger_delay; 65 pmt::pmt_t d_trigger_tag_key; 66 bool d_triggered; 67 int d_trigger_count; 68 69 void _reset(); 70 void _npoints_resize(); 71 void _adjust_tags(int adj); 72 void _gui_update_trigger(); 73 void _test_trigger_tags(int nitems); 74 void _test_trigger_norm(int nitems, gr_vector_const_void_star inputs); 75 bool _test_trigger_slope(const gr_complex* in) const; 76 77 // Handles message input port for displaying PDU samples. 78 void handle_pdus(pmt::pmt_t msg); 79 80 public: 81 time_sink_c_impl(int size, 82 double samp_rate, 83 const std::string& name, 84 unsigned int nconnections, 85 QWidget* parent = NULL); 86 ~time_sink_c_impl(); 87 88 bool check_topology(int ninputs, int noutputs); 89 90 void exec_(); 91 QWidget* qwidget(); 92 93 #ifdef ENABLE_PYTHON 94 PyObject* pyqwidget(); 95 #else 96 void* pyqwidget(); 97 #endif 98 99 void set_y_axis(double min, double max); 100 void set_y_label(const std::string& label, const std::string& unit = ""); 101 void set_update_time(double t); 102 void set_title(const std::string& title); 103 void set_line_label(unsigned int which, const std::string& label); 104 void set_line_color(unsigned int which, const std::string& color); 105 void set_line_width(unsigned int which, int width); 106 void set_line_style(unsigned int which, int style); 107 void set_line_marker(unsigned int which, int marker); 108 void set_nsamps(const int size); 109 void set_samp_rate(const double samp_rate); 110 void set_line_alpha(unsigned int which, double alpha); 111 void set_trigger_mode(trigger_mode mode, 112 trigger_slope slope, 113 float level, 114 float delay, 115 int channel, 116 const std::string& tag_key = ""); 117 118 std::string title(); 119 std::string line_label(unsigned int which); 120 std::string line_color(unsigned int which); 121 int line_width(unsigned int which); 122 int line_style(unsigned int which); 123 int line_marker(unsigned int which); 124 double line_alpha(unsigned int which); 125 126 void set_size(int width, int height); 127 128 int nsamps() const; 129 130 void enable_menu(bool en); 131 void enable_grid(bool en); 132 void enable_autoscale(bool en); 133 void enable_stem_plot(bool en); 134 void enable_semilogx(bool en); 135 void enable_semilogy(bool en); 136 void enable_control_panel(bool en); 137 void enable_tags(unsigned int which, bool en); 138 void enable_tags(bool en); 139 void enable_axis_labels(bool en); 140 void disable_legend(); 141 142 void reset(); 143 144 int work(int noutput_items, 145 gr_vector_const_void_star& input_items, 146 gr_vector_void_star& output_items); 147 }; 148 149 } /* namespace qtgui */ 150 } /* namespace gr */ 151 152 #endif /* INCLUDED_QTGUI_TIME_SINK_C_IMPL_H */ 153