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