diff options
-rw-r--r-- | gr-digital/lib/chunks_to_symbols_impl.h | 2 | ||||
-rw-r--r-- | gr-digital/lib/constellation_receiver_cb_impl.cc | 2 | ||||
-rw-r--r-- | gr-digital/lib/costas_loop_cc_impl.cc | 64 | ||||
-rw-r--r-- | gr-digital/lib/costas_loop_cc_impl.h | 7 | ||||
-rw-r--r-- | gr-digital/lib/diff_encoder_bb_impl.cc | 3 | ||||
-rw-r--r-- | gr-digital/lib/diff_encoder_bb_impl.h | 2 | ||||
-rw-r--r-- | gr-digital/lib/fll_band_edge_cc_impl.cc | 2 | ||||
-rw-r--r-- | gr-digital/lib/pfb_clock_sync_ccf_impl.cc | 5 | ||||
-rw-r--r-- | gr-digital/lib/pfb_clock_sync_ccf_impl.h | 2 | ||||
-rw-r--r-- | gr-digital/lib/pfb_clock_sync_fff_impl.cc | 5 | ||||
-rw-r--r-- | gr-digital/lib/pfb_clock_sync_fff_impl.h | 2 |
11 files changed, 45 insertions, 51 deletions
diff --git a/gr-digital/lib/chunks_to_symbols_impl.h b/gr-digital/lib/chunks_to_symbols_impl.h index 8cbcdb350e..e6bb7811e3 100644 --- a/gr-digital/lib/chunks_to_symbols_impl.h +++ b/gr-digital/lib/chunks_to_symbols_impl.h @@ -32,7 +32,7 @@ template <class IN_T, class OUT_T> class chunks_to_symbols_impl : public chunks_to_symbols<IN_T, OUT_T> { private: - int d_D; + const int d_D; std::vector<OUT_T> d_symbol_table; public: diff --git a/gr-digital/lib/constellation_receiver_cb_impl.cc b/gr-digital/lib/constellation_receiver_cb_impl.cc index f7f4c2fc8f..0dff574e44 100644 --- a/gr-digital/lib/constellation_receiver_cb_impl.cc +++ b/gr-digital/lib/constellation_receiver_cb_impl.cc @@ -112,7 +112,7 @@ void constellation_receiver_cb_impl::handle_set_constellation( void constellation_receiver_cb_impl::handle_rotate_phase(pmt::pmt_t rotation) { if (pmt::is_real(rotation)) { - double phase = pmt::to_double(rotation); + const double phase = pmt::to_double(rotation); d_phase += phase; } } diff --git a/gr-digital/lib/costas_loop_cc_impl.cc b/gr-digital/lib/costas_loop_cc_impl.cc index c3b30834eb..4129dd05fa 100644 --- a/gr-digital/lib/costas_loop_cc_impl.cc +++ b/gr-digital/lib/costas_loop_cc_impl.cc @@ -50,36 +50,8 @@ costas_loop_cc_impl::costas_loop_cc_impl(float loop_bw, int order, bool use_snr) d_order(order), d_error(0), d_noise(1.0), - d_phase_detector(NULL) + d_phase_detector(choose_phase_detector(order, use_snr)) { - // Set up the phase detector to use based on the constellation order - switch (d_order) { - case 2: - if (use_snr) - d_phase_detector = &costas_loop_cc_impl::phase_detector_snr_2; - else - d_phase_detector = &costas_loop_cc_impl::phase_detector_2; - break; - - case 4: - if (use_snr) - d_phase_detector = &costas_loop_cc_impl::phase_detector_snr_4; - else - d_phase_detector = &costas_loop_cc_impl::phase_detector_4; - break; - - case 8: - if (use_snr) - d_phase_detector = &costas_loop_cc_impl::phase_detector_snr_8; - else - d_phase_detector = &costas_loop_cc_impl::phase_detector_8; - break; - - default: - throw std::invalid_argument("order must be 2, 4, or 8"); - break; - } - message_port_register_in(pmt::mp("noise")); set_msg_handler(pmt::mp("noise"), boost::bind(&costas_loop_cc_impl::handle_set_noise, this, _1)); @@ -87,6 +59,30 @@ costas_loop_cc_impl::costas_loop_cc_impl(float loop_bw, int order, bool use_snr) costas_loop_cc_impl::~costas_loop_cc_impl() {} +costas_loop_cc_impl::d_phase_detector_t costas_loop_cc_impl::choose_phase_detector(int order, bool use_snr) +{ + switch (order) { + case 2: + if (use_snr) { + return &costas_loop_cc_impl::phase_detector_snr_2; + } + return &costas_loop_cc_impl::phase_detector_2; + + case 4: + if (use_snr) { + return &costas_loop_cc_impl::phase_detector_snr_4; + } + return &costas_loop_cc_impl::phase_detector_4; + + case 8: + if (use_snr) { + return &costas_loop_cc_impl::phase_detector_snr_8; + } + return &costas_loop_cc_impl::phase_detector_8; + } + throw std::invalid_argument("order must be 2, 4, or 8"); +} + float costas_loop_cc_impl::phase_detector_8(gr_complex sample) const { /* This technique splits the 8PSK constellation into 2 squashed @@ -103,7 +99,7 @@ float costas_loop_cc_impl::phase_detector_8(gr_complex sample) const Circuits and Systems, Vol. 2, pp. 1447 - 1450, 2004. */ - float K = (sqrt(2.0) - 1); + const float K = (sqrt(2.0) - 1); if (fabsf(sample.real()) >= fabsf(sample.imag())) { return ((sample.real() > 0 ? 1.0 : -1.0) * sample.imag() - (sample.imag() > 0 ? 1.0 : -1.0) * sample.real() * K); @@ -126,8 +122,8 @@ float costas_loop_cc_impl::phase_detector_2(gr_complex sample) const float costas_loop_cc_impl::phase_detector_snr_8(gr_complex sample) const { - float K = (sqrt(2.0) - 1); - float snr = abs(sample) * abs(sample) / d_noise; + const float K = (sqrt(2.0) - 1); + const float snr = abs(sample) * abs(sample) / d_noise; if (fabsf(sample.real()) >= fabsf(sample.imag())) { return ((blocks::tanhf_lut(snr * sample.real()) * sample.imag()) - (blocks::tanhf_lut(snr * sample.imag()) * sample.real() * K)); @@ -139,14 +135,14 @@ float costas_loop_cc_impl::phase_detector_snr_8(gr_complex sample) const float costas_loop_cc_impl::phase_detector_snr_4(gr_complex sample) const { - float snr = abs(sample) * abs(sample) / d_noise; + const float snr = abs(sample) * abs(sample) / d_noise; return ((blocks::tanhf_lut(snr * sample.real()) * sample.imag()) - (blocks::tanhf_lut(snr * sample.imag()) * sample.real())); } float costas_loop_cc_impl::phase_detector_snr_2(gr_complex sample) const { - float snr = abs(sample) * abs(sample) / d_noise; + const float snr = abs(sample) * abs(sample) / d_noise; return blocks::tanhf_lut(snr * sample.real()) * sample.imag(); } diff --git a/gr-digital/lib/costas_loop_cc_impl.h b/gr-digital/lib/costas_loop_cc_impl.h index d970a97c30..87655a44cf 100644 --- a/gr-digital/lib/costas_loop_cc_impl.h +++ b/gr-digital/lib/costas_loop_cc_impl.h @@ -32,7 +32,7 @@ namespace digital { class costas_loop_cc_impl : public costas_loop_cc { private: - int d_order; + const int d_order; float d_error; float d_noise; @@ -85,8 +85,9 @@ private: */ float phase_detector_snr_2(gr_complex sample) const; // for BPSK - - float (costas_loop_cc_impl::*d_phase_detector)(gr_complex sample) const; + typedef float (costas_loop_cc_impl::*d_phase_detector_t)(gr_complex sample) const; + static d_phase_detector_t choose_phase_detector(int order, bool use_snr); + const d_phase_detector_t d_phase_detector; public: costas_loop_cc_impl(float loop_bw, int order, bool use_snr = false); diff --git a/gr-digital/lib/diff_encoder_bb_impl.cc b/gr-digital/lib/diff_encoder_bb_impl.cc index 26e37c3eb6..447a8da6c5 100644 --- a/gr-digital/lib/diff_encoder_bb_impl.cc +++ b/gr-digital/lib/diff_encoder_bb_impl.cc @@ -54,10 +54,9 @@ int diff_encoder_bb_impl::work(int noutput_items, unsigned char* out = (unsigned char*)output_items[0]; unsigned last_out = d_last_out; - unsigned modulus = d_modulus; for (int i = 0; i < noutput_items; i++) { - out[i] = (in[i] + last_out) % modulus; + out[i] = (in[i] + last_out) % d_modulus; last_out = out[i]; } diff --git a/gr-digital/lib/diff_encoder_bb_impl.h b/gr-digital/lib/diff_encoder_bb_impl.h index eeb70a68d8..6188135809 100644 --- a/gr-digital/lib/diff_encoder_bb_impl.h +++ b/gr-digital/lib/diff_encoder_bb_impl.h @@ -40,7 +40,7 @@ public: private: unsigned int d_last_out; - unsigned int d_modulus; + const unsigned int d_modulus; }; } /* namespace digital */ diff --git a/gr-digital/lib/fll_band_edge_cc_impl.cc b/gr-digital/lib/fll_band_edge_cc_impl.cc index ef05e59b08..e61dad3645 100644 --- a/gr-digital/lib/fll_band_edge_cc_impl.cc +++ b/gr-digital/lib/fll_band_edge_cc_impl.cc @@ -138,7 +138,7 @@ void fll_band_edge_cc_impl::design_filter(float samps_per_sym, float rolloff, int filter_size) { - int M = rint(filter_size / samps_per_sym); + const int M = rint(filter_size / samps_per_sym); float power = 0; // Create the baseband filter by adding two sincs together diff --git a/gr-digital/lib/pfb_clock_sync_ccf_impl.cc b/gr-digital/lib/pfb_clock_sync_ccf_impl.cc index 3ad559ee84..5354130b25 100644 --- a/gr-digital/lib/pfb_clock_sync_ccf_impl.cc +++ b/gr-digital/lib/pfb_clock_sync_ccf_impl.cc @@ -75,7 +75,6 @@ pfb_clock_sync_ccf_impl::pfb_clock_sync_ccf_impl(double sps, // enable_update_rate(true); set_tag_propagation_policy(TPP_DONT); - d_nfilters = filter_size; d_sps = floor(sps); // Set the damping factor for a critically damped system @@ -202,7 +201,7 @@ float pfb_clock_sync_ccf_impl::phase() const { return d_k; } void pfb_clock_sync_ccf_impl::update_gains() { - float denom = (1.0 + 2.0 * d_damping * d_loop_bw + d_loop_bw * d_loop_bw); + const float denom = (1.0 + 2.0 * d_damping * d_loop_bw + d_loop_bw * d_loop_bw); d_alpha = (4 * d_damping * d_loop_bw) / denom; d_beta = (4 * d_loop_bw * d_loop_bw) / denom; } @@ -213,7 +212,7 @@ void pfb_clock_sync_ccf_impl::set_taps(const std::vector<float>& newtaps, { int i, j; - unsigned int ntaps = newtaps.size(); + const unsigned int ntaps = newtaps.size(); d_taps_per_filter = (unsigned int)ceil((double)ntaps / (double)d_nfilters); // Create d_numchan vectors to store each channel's taps diff --git a/gr-digital/lib/pfb_clock_sync_ccf_impl.h b/gr-digital/lib/pfb_clock_sync_ccf_impl.h index eecd65c587..396d3d846a 100644 --- a/gr-digital/lib/pfb_clock_sync_ccf_impl.h +++ b/gr-digital/lib/pfb_clock_sync_ccf_impl.h @@ -40,7 +40,7 @@ private: float d_alpha; float d_beta; - int d_nfilters; + const int d_nfilters; int d_taps_per_filter; std::vector<std::unique_ptr<kernel::fir_filter_ccf>> d_filters; std::vector<std::unique_ptr<kernel::fir_filter_ccf>> d_diff_filters; diff --git a/gr-digital/lib/pfb_clock_sync_fff_impl.cc b/gr-digital/lib/pfb_clock_sync_fff_impl.cc index aaec9aa56b..9947474857 100644 --- a/gr-digital/lib/pfb_clock_sync_fff_impl.cc +++ b/gr-digital/lib/pfb_clock_sync_fff_impl.cc @@ -71,7 +71,6 @@ pfb_clock_sync_fff_impl::pfb_clock_sync_fff_impl(double sps, // Let scheduler adjust our relative_rate. enable_update_rate(true); - d_nfilters = filter_size; d_sps = floor(sps); // Set the damping factor for a critically damped system @@ -195,7 +194,7 @@ float pfb_clock_sync_fff_impl::clock_rate() const { return d_rate_f; } void pfb_clock_sync_fff_impl::update_gains() { - float denom = (1.0 + 2.0 * d_damping * d_loop_bw + d_loop_bw * d_loop_bw); + const float denom = (1.0 + 2.0 * d_damping * d_loop_bw + d_loop_bw * d_loop_bw); d_alpha = (4 * d_damping * d_loop_bw) / denom; d_beta = (4 * d_loop_bw * d_loop_bw) / denom; } @@ -206,7 +205,7 @@ void pfb_clock_sync_fff_impl::set_taps(const std::vector<float>& newtaps, { int i, j; - unsigned int ntaps = newtaps.size(); + const unsigned int ntaps = newtaps.size(); d_taps_per_filter = (unsigned int)ceil((double)ntaps / (double)d_nfilters); // Create d_numchan vectors to store each channel's taps diff --git a/gr-digital/lib/pfb_clock_sync_fff_impl.h b/gr-digital/lib/pfb_clock_sync_fff_impl.h index f9acb778cd..33a4406cda 100644 --- a/gr-digital/lib/pfb_clock_sync_fff_impl.h +++ b/gr-digital/lib/pfb_clock_sync_fff_impl.h @@ -40,7 +40,7 @@ private: float d_alpha; float d_beta; - int d_nfilters; + const int d_nfilters; int d_taps_per_filter; std::vector<kernel::fir_filter_fff*> d_filters; std::vector<kernel::fir_filter_fff*> d_diff_filters; |