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