GNU Radio 3.5.1 C++ API
digital_probe_mpsk_snr_est_c.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2011 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 #ifndef INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H
00023 #define INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H
00024 
00025 #include <digital_api.h>
00026 #include <gr_sync_block.h>
00027 #include <digital_impl_mpsk_snr_est.h>
00028 
00029 class digital_probe_mpsk_snr_est_c;
00030 typedef boost::shared_ptr<digital_probe_mpsk_snr_est_c> digital_probe_mpsk_snr_est_c_sptr;
00031 
00032 DIGITAL_API digital_probe_mpsk_snr_est_c_sptr
00033 digital_make_probe_mpsk_snr_est_c(snr_est_type_t type,
00034                                   int msg_nsamples=10000,
00035                                   double alpha=0.001);
00036 
00037 //! \brief A probe for computing SNR of a signal.
00038 /*! \ingroup snr_blk
00039  *
00040  *  This is a probe block (a sink) that can be used to monitor and
00041  *  retrieve estimations of the signal SNR. This probe is designed for
00042  *  use with M-PSK signals especially. The type of estimator is
00043  *  specified as the \p type parameter in the constructor. The
00044  *  estimators tend to trade off performance for accuracy, although
00045  *  experimentation should be done to figure out the right approach
00046  *  for a given implementation. Further, the current set of estimators
00047  *  are designed and proven theoretically under AWGN conditions; some
00048  *  amount of error should be assumed and/or estimated for real
00049  *  channel conditions.
00050  */
00051 class DIGITAL_API digital_probe_mpsk_snr_est_c : public gr_sync_block
00052 {
00053  private:
00054   snr_est_type_t d_type;
00055   int d_nsamples, d_count;
00056   double d_alpha;
00057   digital_impl_mpsk_snr_est *d_snr_est;
00058 
00059   //d_key is the message name, 'snr'
00060   pmt::pmt_t d_key;
00061 
00062   /*! Factory function returning shared pointer of this class
00063    *
00064    *  Parameters:
00065    *
00066    *  \param type: the type of estimator to use \ref ref_snr_est_types
00067    *  "snr_est_type_t" for details about the available types.
00068    *  \param msg_nsamples: [not implemented yet] after this many
00069    *  samples, a message containing the SNR (key='snr') will be sent
00070    *  \param alpha: the update rate of internal running average
00071    *  calculations.
00072    */
00073   friend DIGITAL_API digital_probe_mpsk_snr_est_c_sptr
00074     digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, 
00075                                       int msg_nsamples,
00076                                       double alpha);
00077   
00078   //! Private constructor
00079   digital_probe_mpsk_snr_est_c(snr_est_type_t type,
00080                                int msg_nsamples,
00081                                double alpha);
00082 
00083 public:
00084 
00085   ~digital_probe_mpsk_snr_est_c();
00086 
00087   int work (int noutput_items,
00088             gr_vector_const_void_star &input_items,
00089             gr_vector_void_star &output_items);
00090 
00091   //! Return the estimated signal-to-noise ratio in decibels
00092   double snr();
00093 
00094   //! Return the type of estimator in use
00095   snr_est_type_t type() const;
00096 
00097   //! Return how many samples between SNR messages
00098   int msg_nsample() const;
00099 
00100   //! Get the running-average coefficient
00101   double alpha() const;
00102 
00103   //! Set type of estimator to use
00104   void set_type(snr_est_type_t t);
00105 
00106   //! Set the number of samples between SNR messages
00107   void set_msg_nsample(int n);
00108 
00109   //! Set the running-average coefficient
00110   void set_alpha(double alpha);
00111 };
00112 
00113 #endif /* INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H */