GNU Radio 3.5.1 C++ API
digital_mpsk_snr_est_cc.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_MPSK_SNR_EST_CC_H
00023 #define INCLUDED_DIGITAL_MPSK_SNR_EST_CC_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_mpsk_snr_est_cc;
00030 typedef boost::shared_ptr<digital_mpsk_snr_est_cc> digital_mpsk_snr_est_cc_sptr;
00031 
00032 DIGITAL_API digital_mpsk_snr_est_cc_sptr
00033 digital_make_mpsk_snr_est_cc(snr_est_type_t type,
00034                              int tag_nsamples=10000,
00035                              double alpha=0.001);
00036 
00037 //! \brief A block for computing SNR of a signal.
00038 /*! \ingroup snr_blk
00039  *
00040  *  This block can be used to monitor and retrieve estimations of the
00041  *  signal SNR. It is designed to work in a flowgraph and passes all
00042  *  incoming data along to its output.
00043  *
00044  *  The block is designed for use with M-PSK signals especially. The
00045  *  type of estimator is specified as the \p type parameter in the
00046  *  constructor. The estimators tend to trade off performance for
00047  *  accuracy, although experimentation should be done to figure out
00048  *  the right approach for a given implementation. Further, the
00049  *  current set of estimators are designed and proven theoretically
00050  *  under AWGN conditions; some amount of error should be assumed
00051  *  and/or estimated for real channel conditions.
00052  */
00053 class DIGITAL_API digital_mpsk_snr_est_cc : public gr_sync_block
00054 {
00055  private:
00056   snr_est_type_t d_type;
00057   int d_nsamples, d_count;
00058   double d_alpha;
00059   digital_impl_mpsk_snr_est *d_snr_est;
00060 
00061   //d_key is the tag name, 'snr', d_me is the block name + unique ID
00062   pmt::pmt_t d_key, d_me; 
00063 
00064   /*! Factory function returning shared pointer of this class
00065    *
00066    *  Parameters:
00067    *
00068    *  \param type: the type of estimator to use \ref ref_snr_est_types
00069    *  "snr_est_type_t" for details about the available types.
00070    *  \param tag_nsamples: after this many samples, a tag containing
00071    *  the SNR (key='snr') will be sent
00072    *  \param alpha: the update rate of internal running average
00073    *  calculations.
00074    */
00075   friend DIGITAL_API digital_mpsk_snr_est_cc_sptr
00076     digital_make_mpsk_snr_est_cc(snr_est_type_t type,
00077                                  int tag_nsamples,
00078                                  double alpha);
00079   
00080   // Private constructor
00081   digital_mpsk_snr_est_cc(snr_est_type_t type,
00082                           int tag_nsamples,
00083                           double alpha);
00084 
00085 public:
00086 
00087   ~digital_mpsk_snr_est_cc();
00088 
00089   int work (int noutput_items,
00090             gr_vector_const_void_star &input_items,
00091             gr_vector_void_star &output_items);
00092 
00093   //! Return the estimated signal-to-noise ratio in decibels
00094   double snr();
00095 
00096   //! Return the type of estimator in use
00097   snr_est_type_t type() const;
00098 
00099   //! Return how many samples between SNR tags
00100   int tag_nsample() const;
00101 
00102   //! Get the running-average coefficient
00103   double alpha() const;
00104 
00105   //! Set type of estimator to use
00106   void set_type(snr_est_type_t t);
00107 
00108   //! Set the number of samples between SNR tags
00109   void set_tag_nsample(int n);
00110 
00111   //! Set the running-average coefficient
00112   void set_alpha(double alpha);
00113 };
00114 
00115 #endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H */