GNU Radio 3.6.5.1 C++ API
digital_probe_mpsk_snr_est_c.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2011 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 #ifndef INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H
23 #define INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H
24 
25 #include <digital_api.h>
26 #include <gr_sync_block.h>
28 
31 
34  int msg_nsamples=10000,
35  double alpha=0.001);
36 
37 /*! \brief A probe for computing SNR of a signal.
38  * \ingroup measurement_tools_blk
39  *
40  * \details
41  * This is a probe block (a sink) that can be used to monitor and
42  * retrieve estimations of the signal SNR. This probe is designed for
43  * use with M-PSK signals especially. The type of estimator is
44  * specified as the \p type parameter in the constructor. The
45  * estimators tend to trade off performance for accuracy, although
46  * experimentation should be done to figure out the right approach
47  * for a given implementation. Further, the current set of estimators
48  * are designed and proven theoretically under AWGN conditions; some
49  * amount of error should be assumed and/or estimated for real
50  * channel conditions.
51  */
53 {
54  private:
55  snr_est_type_t d_type;
56  int d_nsamples, d_count;
57  double d_alpha;
58  digital_impl_mpsk_snr_est *d_snr_est;
59 
60  //d_key is the message name, 'snr'
61  pmt::pmt_t d_key;
62 
63  /*! Factory function returning shared pointer of this class
64  *
65  * \param type: the type of estimator to use \ref ref_snr_est_types
66  * "snr_est_type_t" for details about the available types.
67  * \param msg_nsamples: [not implemented yet] after this many
68  * samples, a message containing the SNR (key='snr') will be sent
69  * \param alpha: the update rate of internal running average
70  * calculations.
71  */
74  int msg_nsamples,
75  double alpha);
76 
77  //! Private constructor
79  int msg_nsamples,
80  double alpha);
81 
82 public:
83 
85 
86  int work (int noutput_items,
87  gr_vector_const_void_star &input_items,
88  gr_vector_void_star &output_items);
89 
90  //! Return the estimated signal-to-noise ratio in decibels
91  double snr();
92 
93  //! Return the type of estimator in use
94  snr_est_type_t type() const;
95 
96  //! Return how many samples between SNR messages
97  int msg_nsample() const;
98 
99  //! Get the running-average coefficient
100  double alpha() const;
101 
102  //! Set type of estimator to use
103  void set_type(snr_est_type_t t);
104 
105  //! Set the number of samples between SNR messages
106  void set_msg_nsample(int n);
107 
108  //! Set the running-average coefficient
109  void set_alpha(double alpha);
110 };
111 
112 #endif /* INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H */