GNU Radio 3.6.5 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 measurement_tools_blk
00039  *
00040  * \details
00041  *  This is a probe block (a sink) that can be used to monitor and
00042  *  retrieve estimations of the signal SNR. This probe is designed for
00043  *  use with M-PSK signals especially. The type of estimator is
00044  *  specified as the \p type parameter in the constructor. The
00045  *  estimators tend to trade off performance for accuracy, although
00046  *  experimentation should be done to figure out the right approach
00047  *  for a given implementation. Further, the current set of estimators
00048  *  are designed and proven theoretically under AWGN conditions; some
00049  *  amount of error should be assumed and/or estimated for real
00050  *  channel conditions.
00051  */
00052 class DIGITAL_API digital_probe_mpsk_snr_est_c : public gr_sync_block
00053 {
00054  private:
00055   snr_est_type_t d_type;
00056   int d_nsamples, d_count;
00057   double d_alpha;
00058   digital_impl_mpsk_snr_est *d_snr_est;
00059 
00060   //d_key is the message name, 'snr'
00061   pmt::pmt_t d_key;
00062 
00063   /*! Factory function returning shared pointer of this class
00064    *
00065    *  \param type: the type of estimator to use \ref ref_snr_est_types
00066    *  "snr_est_type_t" for details about the available types.
00067    *  \param msg_nsamples: [not implemented yet] after this many
00068    *  samples, a message containing the SNR (key='snr') will be sent
00069    *  \param alpha: the update rate of internal running average
00070    *  calculations.
00071    */
00072   friend DIGITAL_API digital_probe_mpsk_snr_est_c_sptr
00073     digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, 
00074                                       int msg_nsamples,
00075                                       double alpha);
00076   
00077   //! Private constructor
00078   digital_probe_mpsk_snr_est_c(snr_est_type_t type,
00079                                int msg_nsamples,
00080                                double alpha);
00081 
00082 public:
00083 
00084   ~digital_probe_mpsk_snr_est_c();
00085 
00086   int work (int noutput_items,
00087             gr_vector_const_void_star &input_items,
00088             gr_vector_void_star &output_items);
00089 
00090   //! Return the estimated signal-to-noise ratio in decibels
00091   double snr();
00092 
00093   //! Return the type of estimator in use
00094   snr_est_type_t type() const;
00095 
00096   //! Return how many samples between SNR messages
00097   int msg_nsample() const;
00098 
00099   //! Get the running-average coefficient
00100   double alpha() const;
00101 
00102   //! Set type of estimator to use
00103   void set_type(snr_est_type_t t);
00104 
00105   //! Set the number of samples between SNR messages
00106   void set_msg_nsample(int n);
00107 
00108   //! Set the running-average coefficient
00109   void set_alpha(double alpha);
00110 };
00111 
00112 #endif /* INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H */