diff options
author | Tom Rondeau | 2011-12-29 11:27:00 -0500 |
---|---|---|
committer | Tom Rondeau | 2011-12-29 11:27:00 -0500 |
commit | 74c53aa4c5b9aeac590b803b12601bcc9c8b9b60 (patch) | |
tree | f56a0560b3246d8cbb9cf9690501424ec67248f6 /gr-digital/lib | |
parent | ceb18ce1c1342477d0704edfaa3e775830a999e4 (diff) | |
download | gnuradio-74c53aa4c5b9aeac590b803b12601bcc9c8b9b60.tar.gz gnuradio-74c53aa4c5b9aeac590b803b12601bcc9c8b9b60.tar.bz2 gnuradio-74c53aa4c5b9aeac590b803b12601bcc9c8b9b60.zip |
digital: added a probe (sink) for the new SNR estimators; also fixes up Makefiles and Swig files for SNR est blocks.
Diffstat (limited to 'gr-digital/lib')
-rw-r--r-- | gr-digital/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-digital/lib/Makefile.am | 2 | ||||
-rw-r--r-- | gr-digital/lib/digital_probe_mpsk_snr_est_c.cc | 123 |
3 files changed, 126 insertions, 0 deletions
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index 94ef2b64d..779972ff3 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -54,6 +54,7 @@ list(APPEND gr_digital_sources digital_ofdm_insert_preamble.cc digital_ofdm_mapper_bcv.cc digital_ofdm_sampler.cc + digital_probe_mpsk_snr_est_c.cc digital_gmskmod_bc.cc digital_cpmmod_bc.cc ) diff --git a/gr-digital/lib/Makefile.am b/gr-digital/lib/Makefile.am index b6fea599f..d5ad199e3 100644 --- a/gr-digital/lib/Makefile.am +++ b/gr-digital/lib/Makefile.am @@ -42,12 +42,14 @@ libgnuradio_digital_la_SOURCES = \ digital_lms_dd_equalizer_cc.cc \ digital_kurtotic_equalizer_cc.cc \ digital_mpsk_receiver_cc.cc \ + digital_mpsk_snr_est_cc.cc \ digital_ofdm_cyclic_prefixer.cc \ digital_ofdm_frame_acquisition.cc \ digital_ofdm_frame_sink.cc \ digital_ofdm_insert_preamble.cc \ digital_ofdm_mapper_bcv.cc \ digital_ofdm_sampler.cc \ + digital_probe_mpsk_snr_est_c.cc \ digital_gmskmod_bc.cc \ digital_cpmmod_bc.cc diff --git a/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc b/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc new file mode 100644 index 000000000..259074e13 --- /dev/null +++ b/gr-digital/lib/digital_probe_mpsk_snr_est_c.cc @@ -0,0 +1,123 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <digital_probe_mpsk_snr_est_c.h> +#include <gr_io_signature.h> +#include <cstdio> + +digital_probe_mpsk_snr_est_c_sptr +digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, + double alpha) +{ + return gnuradio::get_initial_sptr( + new digital_probe_mpsk_snr_est_c(type, alpha)); +} + +digital_probe_mpsk_snr_est_c::digital_probe_mpsk_snr_est_c( + snr_est_type_t type, double alpha) + : gr_sync_block ("probe_mpsk_snr_est_c", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(0, 0, 0)) +{ + d_snr_est = NULL; + + d_type = type; + set_alpha(alpha); + + set_type(type); + + // at least 1 estimator has to look back + set_history(2); +} + +digital_probe_mpsk_snr_est_c::~digital_probe_mpsk_snr_est_c() +{ + if(d_snr_est) + delete d_snr_est; +} + +int +digital_probe_mpsk_snr_est_c::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + return d_snr_est->update(noutput_items, input_items); +} + +double +digital_probe_mpsk_snr_est_c::snr() +{ + if(d_snr_est) + return d_snr_est->snr(); + else + throw std::runtime_error("digital_probe_mpsk_snr_est_c:: No SNR estimator defined.\n"); +} + +snr_est_type_t +digital_probe_mpsk_snr_est_c::type() const +{ + return d_type; +} + +double +digital_probe_mpsk_snr_est_c::alpha() const +{ + return d_alpha; +} + +void +digital_probe_mpsk_snr_est_c::set_type(snr_est_type_t t) +{ + d_type = t; + + if(d_snr_est) + delete d_snr_est; + + switch (d_type) { + case(SNR_EST_SIMPLE): + d_snr_est = new digital_impl_mpsk_snr_est_simple(d_alpha); + break; + case(SNR_EST_SKEW): + d_snr_est = new digital_impl_mpsk_snr_est_skew(d_alpha); + break; + case(SNR_EST_M2M4): + d_snr_est = new digital_impl_mpsk_snr_est_m2m4(d_alpha); + break; + case(SNR_EST_SVN): + d_snr_est = new digital_impl_mpsk_snr_est_svn(d_alpha); + break; + default: + throw std::invalid_argument("digital_probe_mpsk_snr_est_c: unknown type specified.\n"); + } +} + +void +digital_probe_mpsk_snr_est_c::set_alpha(double alpha) +{ + d_alpha = alpha; + if(d_snr_est) + d_snr_est->set_alpha(d_alpha); +} |