From 63b7c00b168e1b7b02406f0b9d720cb908d1c5c1 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 25 Jun 2020 11:58:01 +0200 Subject: [PATCH] Sort private members in headers --- .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 1 + .../adapters/byte_to_short.h | 4 +- .../adapters/ibyte_to_cbyte.h | 6 +- .../adapters/ibyte_to_complex.h | 6 +- .../adapters/ibyte_to_cshort.h | 6 +- .../adapters/ishort_to_complex.h | 6 +- .../adapters/ishort_to_cshort.h | 6 +- .../input_filter/adapters/beamformer_filter.h | 22 +-- .../input_filter/adapters/fir_filter.cc | 136 +++++++++--------- .../input_filter/adapters/fir_filter.h | 31 ++-- .../adapters/freq_xlating_fir_filter.h | 30 ++-- .../input_filter/adapters/notch_filter.h | 9 +- .../input_filter/adapters/notch_filter_lite.h | 9 +- .../adapters/pulse_blanking_filter.h | 22 +-- .../gnuradio_blocks/CMakeLists.txt | 2 + .../input_filter/gnuradio_blocks/notch_cc.cc | 27 ++-- .../input_filter/gnuradio_blocks/notch_cc.h | 17 +-- .../gnuradio_blocks/notch_lite_cc.cc | 15 +- .../gnuradio_blocks/notch_lite_cc.h | 27 ++-- .../gnuradio_blocks/pulse_blanking_cc.cc | 21 +-- .../gnuradio_blocks/pulse_blanking_cc.h | 11 +- src/algorithms/libs/pass_through.h | 3 - .../adapters/direct_resampler_conditioner.h | 12 +- .../adapters/mmse_resampler_conditioner.h | 18 +-- .../adapters/signal_generator.h | 14 +- .../gnuradio_blocks/signal_generator_c.cc | 8 +- .../gnuradio_blocks/signal_generator_c.h | 30 ++-- 27 files changed, 243 insertions(+), 256 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 7f1229c51..9a673b790 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -501,6 +501,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, rtklib_pvt_gs::~rtklib_pvt_gs() { + DLOG(INFO) << "PVT block destructor called."; if (d_sysv_msqid != -1) { msgctl(d_sysv_msqid, IPC_RMID, nullptr); diff --git a/src/algorithms/data_type_adapter/adapters/byte_to_short.h b/src/algorithms/data_type_adapter/adapters/byte_to_short.h index ff6a5e707..b59af1438 100644 --- a/src/algorithms/data_type_adapter/adapters/byte_to_short.h +++ b/src/algorithms/data_type_adapter/adapters/byte_to_short.h @@ -63,15 +63,15 @@ public: private: gr::blocks::char_to_short::sptr gr_char_to_short_; + gr::blocks::file_sink::sptr file_sink_; ConfigurationInterface* config_; - bool dump_; std::string dump_filename_; std::string input_item_type_; std::string output_item_type_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; + bool dump_; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h index a18435535..694b32036 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h @@ -65,17 +65,17 @@ public: private: interleaved_byte_to_complex_byte_sptr ibyte_to_cbyte_; + conjugate_ic_sptr conjugate_ic_; + gr::blocks::file_sink::sptr file_sink_; ConfigurationInterface* config_; - bool dump_; std::string dump_filename_; std::string input_item_type_; std::string output_item_type_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; - conjugate_ic_sptr conjugate_ic_; bool inverted_spectrum; + bool dump_; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h index 2c596b065..584fec4ff 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h @@ -64,17 +64,17 @@ public: private: gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex_; + conjugate_cc_sptr conjugate_cc_; + gr::blocks::file_sink::sptr file_sink_; ConfigurationInterface* config_; - bool dump_; std::string dump_filename_; std::string input_item_type_; std::string output_item_type_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; - conjugate_cc_sptr conjugate_cc_; bool inverted_spectrum; + bool dump_; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h index b5b06d5b0..d6891d82c 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h @@ -65,17 +65,17 @@ public: private: interleaved_byte_to_complex_short_sptr interleaved_byte_to_complex_short_; + conjugate_sc_sptr conjugate_sc_; + gr::blocks::file_sink::sptr file_sink_; ConfigurationInterface* config_; - bool dump_; std::string dump_filename_; std::string input_item_type_; std::string output_item_type_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; - conjugate_sc_sptr conjugate_sc_; bool inverted_spectrum; + bool dump_; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h index 1d506ea2f..39b4317ad 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h @@ -64,17 +64,17 @@ public: private: gr::blocks::interleaved_short_to_complex::sptr gr_interleaved_short_to_complex_; + conjugate_cc_sptr conjugate_cc_; + gr::blocks::file_sink::sptr file_sink_; ConfigurationInterface* config_; - bool dump_; std::string dump_filename_; std::string input_item_type_; std::string output_item_type_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; - conjugate_cc_sptr conjugate_cc_; bool inverted_spectrum; + bool dump_; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h index f99960c54..a9e096b1e 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h @@ -65,17 +65,17 @@ public: private: interleaved_short_to_complex_short_sptr interleaved_short_to_complex_short_; + conjugate_sc_sptr conjugate_sc_; + gr::blocks::file_sink::sptr file_sink_; ConfigurationInterface* config_; - bool dump_; std::string dump_filename_; std::string input_item_type_; std::string output_item_type_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; - conjugate_sc_sptr conjugate_sc_; bool inverted_spectrum; + bool dump_; }; #endif diff --git a/src/algorithms/input_filter/adapters/beamformer_filter.h b/src/algorithms/input_filter/adapters/beamformer_filter.h index d56cc24bc..a29cd09bb 100644 --- a/src/algorithms/input_filter/adapters/beamformer_filter.h +++ b/src/algorithms/input_filter/adapters/beamformer_filter.h @@ -29,8 +29,8 @@ class ConfigurationInterface; /*! - * \brief Interface of an adapter of a direct resampler conditioner block - * to a SignalConditionerInterface + * \brief Interface of an adapter of a digital beamformer block + * to a GNSSBlockInterface */ class BeamformerFilter : public GNSSBlockInterface { @@ -46,7 +46,7 @@ public: return role_; } - //! returns "Direct_Resampler" + //! returns "Beamformer_Filte" inline std::string implementation() override { return "Beamformer_Filter"; @@ -63,16 +63,16 @@ public: gr::basic_block_sptr get_right_block() override; private: - std::string role_; - unsigned int in_stream_; - unsigned int out_stream_; - std::string item_type_; - size_t item_size_; - uint64_t samples_; - bool dump_; - std::string dump_filename_; gr::block_sptr beamformer_; gr::block_sptr file_sink_; + std::string role_; + std::string item_type_; + std::string dump_filename_; + size_t item_size_; + uint64_t samples_; + unsigned int in_stream_; + unsigned int out_stream_; + bool dump_; }; #endif // GNSS_SDR_BEAMFORMER_FILTER_H diff --git a/src/algorithms/input_filter/adapters/fir_filter.cc b/src/algorithms/input_filter/adapters/fir_filter.cc index 9950f6fad..d47196fce 100644 --- a/src/algorithms/input_filter/adapters/fir_filter.cc +++ b/src/algorithms/input_filter/adapters/fir_filter.cc @@ -129,6 +129,74 @@ FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role, } +void FirFilter::init() +{ + std::string default_input_item_type = "gr_complex"; + std::string default_output_item_type = "gr_complex"; + std::string default_taps_item_type = "float"; + std::string default_dump_filename = "../data/input_filter.dat"; + int default_number_of_taps = 6; + unsigned int default_number_of_bands = 2; + std::vector default_bands = {0.0, 0.4, 0.6, 1.0}; + std::vector default_ampl = {1.0, 1.0, 0.0, 0.0}; + std::vector default_error_w = {1.0, 1.0}; + std::string default_filter_type = "bandpass"; + int default_grid_density = 16; + + DLOG(INFO) << "role " << role_; + + input_item_type_ = config_->property(role_ + ".input_item_type", default_input_item_type); + output_item_type_ = config_->property(role_ + ".output_item_type", default_output_item_type); + taps_item_type_ = config_->property(role_ + ".taps_item_type", default_taps_item_type); + dump_ = config_->property(role_ + ".dump", false); + dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + int number_of_taps = config_->property(role_ + ".number_of_taps", default_number_of_taps); + unsigned int number_of_bands = config_->property(role_ + ".number_of_bands", default_number_of_bands); + + std::vector bands; + std::vector ampl; + std::vector error_w; + std::string option; + double option_value; + for (unsigned int i = 0; i < number_of_bands; i++) + { + option = ".band" + std::to_string(i + 1) + "_begin"; + option_value = config_->property(role_ + option, default_bands[i]); + bands.push_back(option_value); + + option = ".band" + std::to_string(i + 1) + "_end"; + option_value = config_->property(role_ + option, default_bands[i]); + bands.push_back(option_value); + + option = ".ampl" + std::to_string(i + 1) + "_begin"; + option_value = config_->property(role_ + option, default_bands[i]); + ampl.push_back(option_value); + + option = ".ampl" + std::to_string(i + 1) + "_end"; + option_value = config_->property(role_ + option, default_bands[i]); + ampl.push_back(option_value); + + option = ".band" + std::to_string(i + 1) + "_error"; + option_value = config_->property(role_ + option, default_bands[i]); + error_w.push_back(option_value); + } + + std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type); + int grid_density = config_->property(role_ + ".grid_density", default_grid_density); + + // pm_remez implements the Parks-McClellan FIR filter design. + // It calculates the optimal (in the Chebyshev/minimax sense) FIR filter + // impulse response given a set of band edges, the desired response on + // those bands, and the weight given to the error in those bands. + std::vector taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density); + taps_.reserve(taps_d.size()); + for (double& it : taps_d) + { + taps_.push_back(static_cast(it)); + } +} + + void FirFilter::connect(gr::top_block_sptr top_block) { if ((taps_item_type_ == "float") && (input_item_type_ == "gr_complex") && (output_item_type_ == "gr_complex")) @@ -313,71 +381,3 @@ gr::basic_block_sptr FirFilter::get_right_block() LOG(WARNING) << "Unknown input filter taps item type"; return nullptr; } - - -void FirFilter::init() -{ - std::string default_input_item_type = "gr_complex"; - std::string default_output_item_type = "gr_complex"; - std::string default_taps_item_type = "float"; - std::string default_dump_filename = "../data/input_filter.dat"; - int default_number_of_taps = 6; - unsigned int default_number_of_bands = 2; - std::vector default_bands = {0.0, 0.4, 0.6, 1.0}; - std::vector default_ampl = {1.0, 1.0, 0.0, 0.0}; - std::vector default_error_w = {1.0, 1.0}; - std::string default_filter_type = "bandpass"; - int default_grid_density = 16; - - DLOG(INFO) << "role " << role_; - - input_item_type_ = config_->property(role_ + ".input_item_type", default_input_item_type); - output_item_type_ = config_->property(role_ + ".output_item_type", default_output_item_type); - taps_item_type_ = config_->property(role_ + ".taps_item_type", default_taps_item_type); - dump_ = config_->property(role_ + ".dump", false); - dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); - int number_of_taps = config_->property(role_ + ".number_of_taps", default_number_of_taps); - unsigned int number_of_bands = config_->property(role_ + ".number_of_bands", default_number_of_bands); - - std::vector bands; - std::vector ampl; - std::vector error_w; - std::string option; - double option_value; - for (unsigned int i = 0; i < number_of_bands; i++) - { - option = ".band" + std::to_string(i + 1) + "_begin"; - option_value = config_->property(role_ + option, default_bands[i]); - bands.push_back(option_value); - - option = ".band" + std::to_string(i + 1) + "_end"; - option_value = config_->property(role_ + option, default_bands[i]); - bands.push_back(option_value); - - option = ".ampl" + std::to_string(i + 1) + "_begin"; - option_value = config_->property(role_ + option, default_bands[i]); - ampl.push_back(option_value); - - option = ".ampl" + std::to_string(i + 1) + "_end"; - option_value = config_->property(role_ + option, default_bands[i]); - ampl.push_back(option_value); - - option = ".band" + std::to_string(i + 1) + "_error"; - option_value = config_->property(role_ + option, default_bands[i]); - error_w.push_back(option_value); - } - - std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type); - int grid_density = config_->property(role_ + ".grid_density", default_grid_density); - - // pm_remez implements the Parks-McClellan FIR filter design. - // It calculates the optimal (in the Chebyshev/minimax sense) FIR filter - // impulse response given a set of band edges, the desired response on - // those bands, and the weight given to the error in those bands. - std::vector taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density); - taps_.reserve(taps_d.size()); - for (double& it : taps_d) - { - taps_.push_back(static_cast(it)); - } -} diff --git a/src/algorithms/input_filter/adapters/fir_filter.h b/src/algorithms/input_filter/adapters/fir_filter.h index 1b67578fe..4cbbe2c35 100644 --- a/src/algorithms/input_filter/adapters/fir_filter.h +++ b/src/algorithms/input_filter/adapters/fir_filter.h @@ -86,30 +86,31 @@ public: gr::basic_block_sptr get_right_block() override; private: + void init(); + gr::filter::fir_filter_ccf::sptr fir_filter_ccf_; + gr::filter::fir_filter_fff::sptr fir_filter_fff_1_; + gr::filter::fir_filter_fff::sptr fir_filter_fff_2_; + gr::blocks::float_to_complex::sptr float_to_complex_; + gr::blocks::float_to_short::sptr float_to_short_1_; + gr::blocks::float_to_short::sptr float_to_short_2_; + short_x2_to_cshort_sptr short_x2_to_cshort_; + complex_byte_to_float_x2_sptr cbyte_to_float_x2_; + byte_x2_to_complex_byte_sptr char_x2_cbyte_; + cshort_to_float_x2_sptr cshort_to_float_x2_; + gr::blocks::float_to_char::sptr float_to_char_1_; + gr::blocks::float_to_char::sptr float_to_char_2_; + gr::blocks::file_sink::sptr file_sink_; ConfigurationInterface* config_; - bool dump_; + std::vector taps_; std::string dump_filename_; std::string input_item_type_; std::string output_item_type_; std::string taps_item_type_; - std::vector taps_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; - void init(); - complex_byte_to_float_x2_sptr cbyte_to_float_x2_; - gr::filter::fir_filter_fff::sptr fir_filter_fff_1_; - gr::filter::fir_filter_fff::sptr fir_filter_fff_2_; - gr::blocks::float_to_char::sptr float_to_char_1_; - gr::blocks::float_to_char::sptr float_to_char_2_; - byte_x2_to_complex_byte_sptr char_x2_cbyte_; - gr::blocks::float_to_complex::sptr float_to_complex_; - cshort_to_float_x2_sptr cshort_to_float_x2_; - gr::blocks::float_to_short::sptr float_to_short_1_; - gr::blocks::float_to_short::sptr float_to_short_2_; - short_x2_to_cshort_sptr short_x2_to_cshort_; + bool dump_; }; #endif diff --git a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h index 1ed543e27..c2b41933d 100644 --- a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h +++ b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h @@ -87,27 +87,27 @@ private: gr::filter::freq_xlating_fir_filter_ccf::sptr freq_xlating_fir_filter_ccf_; gr::filter::freq_xlating_fir_filter_fcf::sptr freq_xlating_fir_filter_fcf_; gr::filter::freq_xlating_fir_filter_scf::sptr freq_xlating_fir_filter_scf_; - ConfigurationInterface* config_; - int decimation_factor_; - bool dump_; - std::string dump_filename_; - std::string input_item_type_; - size_t input_size_; - std::string output_item_type_; - std::string taps_item_type_; - std::vector taps_; - double intermediate_freq_; - double sampling_freq_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; gr::blocks::complex_to_float::sptr complex_to_float_; gr::blocks::char_to_short::sptr gr_char_to_short_; gr::blocks::float_to_short::sptr float_to_short_1_; gr::blocks::float_to_short::sptr float_to_short_2_; short_x2_to_cshort_sptr short_x2_to_cshort_; complex_float_to_complex_byte_sptr complex_to_complex_byte_; + gr::blocks::file_sink::sptr file_sink_; + ConfigurationInterface* config_; + std::vector taps_; + std::string dump_filename_; + std::string input_item_type_; + std::string output_item_type_; + std::string taps_item_type_; + std::string role_; + size_t input_size_; + double intermediate_freq_; + double sampling_freq_; + int decimation_factor_; + unsigned int in_streams_; + unsigned int out_streams_; + bool dump_; }; #endif // GNSS_SDR_FREQ_XLATING_FIR_FILTER_H diff --git a/src/algorithms/input_filter/adapters/notch_filter.h b/src/algorithms/input_filter/adapters/notch_filter.h index 5f64cec68..5d817fc9c 100644 --- a/src/algorithms/input_filter/adapters/notch_filter.h +++ b/src/algorithms/input_filter/adapters/notch_filter.h @@ -38,6 +38,7 @@ public: unsigned int out_streams); ~NotchFilter() = default; + std::string role() { return role_; @@ -48,24 +49,26 @@ public: { return "Notch_Filter"; } + size_t item_size() { return 0; } + void connect(gr::top_block_sptr top_block); void disconnect(gr::top_block_sptr top_block); gr::basic_block_sptr get_left_block(); gr::basic_block_sptr get_right_block(); private: - bool dump_; + notch_sptr notch_filter_; + gr::blocks::file_sink::sptr file_sink_; std::string dump_filename_; std::string role_; std::string item_type_; unsigned int in_streams_; unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; - notch_sptr notch_filter_; + bool dump_; }; #endif // GNSS_SDR_NOTCH_FILTER_H diff --git a/src/algorithms/input_filter/adapters/notch_filter_lite.h b/src/algorithms/input_filter/adapters/notch_filter_lite.h index 9dd6aa543..f66b6c1e6 100644 --- a/src/algorithms/input_filter/adapters/notch_filter_lite.h +++ b/src/algorithms/input_filter/adapters/notch_filter_lite.h @@ -38,6 +38,7 @@ public: unsigned int out_streams); ~NotchFilterLite() = default; + std::string role() { return role_; @@ -48,24 +49,26 @@ public: { return "Notch_Filter_Lite"; } + size_t item_size() { return 0; } + void connect(gr::top_block_sptr top_block); void disconnect(gr::top_block_sptr top_block); gr::basic_block_sptr get_left_block(); gr::basic_block_sptr get_right_block(); private: - bool dump_; + notch_lite_sptr notch_filter_lite_; + gr::blocks::file_sink::sptr file_sink_; std::string dump_filename_; std::string role_; std::string item_type_; unsigned int in_streams_; unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; - notch_lite_sptr notch_filter_lite_; + bool dump_; }; #endif // GNSS_SDR_NOTCH_FILTER_LITE_H diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h index ae3b0c9c8..5b181c35a 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h @@ -64,19 +64,19 @@ public: gr::basic_block_sptr get_right_block() override; private: - ConfigurationInterface* config_; - bool dump_; - bool xlat_; - std::string dump_filename_; - std::string input_item_type_; - size_t input_size_; - std::string output_item_type_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; - gr::blocks::file_sink::sptr file_sink_; pulse_blanking_cc_sptr pulse_blanking_cc_; gr::filter::freq_xlating_fir_filter_ccf::sptr freq_xlating_; + gr::blocks::file_sink::sptr file_sink_; + ConfigurationInterface* config_; + std::string dump_filename_; + std::string input_item_type_; + std::string output_item_type_; + std::string role_; + size_t input_size_; + unsigned int in_streams_; + unsigned int out_streams_; + bool dump_; + bool xlat_; }; #endif // GNSS_SDR_PULSE_BLANKING_FILTER_H diff --git a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt index 46ed867d2..ba87e0dea 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt @@ -45,7 +45,9 @@ target_link_libraries(input_filter_gr_blocks PUBLIC Gnuradio::blocks Gnuradio::filter + Volkgnsssdr::volkgnsssdr PRIVATE + algorithms_libs Volk::volk Log4cpp::log4cpp ) diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc index ed84b97aa..0e14da02d 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc @@ -18,6 +18,7 @@ */ #include "notch_cc.h" +#include "gnss_sdr_make_unique.h" #include #include #include @@ -55,19 +56,11 @@ Notch::Notch(float pfa, z_0 = gr_complex(0.0, 0.0); boost::math::chi_squared_distribution my_dist_(n_deg_fred); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); - c_samples = static_cast(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment())); - angle_ = static_cast(volk_malloc(length_ * sizeof(float), volk_get_alignment())); - power_spect = static_cast(volk_malloc(length_ * sizeof(float), volk_get_alignment())); + c_samples = volk_gnsssdr::vector(length_); + angle_ = volk_gnsssdr::vector(length_); + power_spect = volk_gnsssdr::vector(length_); last_out = gr_complex(0.0, 0.0); - d_fft = std::unique_ptr(new gr::fft::fft_complex(length_, true)); -} - - -Notch::~Notch() -{ - volk_free(c_samples); - volk_free(angle_); - volk_free(power_spect); + d_fft = std::make_unique(length_, true); } @@ -96,8 +89,8 @@ int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribu { memcpy(d_fft->get_inbuf(), in, sizeof(gr_complex) * length_); d_fft->execute(); - volk_32fc_s32f_power_spectrum_32f(power_spect, d_fft->get_outbuf(), 1.0, length_); - volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect, 15.0, length_); + volk_32fc_s32f_power_spectrum_32f(power_spect.data(), d_fft->get_outbuf(), 1.0, length_); + volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect.data(), 15.0, length_); sig2lin = std::pow(10.0, (sig2dB / 10.0)) / (static_cast(n_deg_fred)); noise_pow_est = (static_cast(n_segments) * noise_pow_est + sig2lin) / (static_cast(n_segments + 1)); memcpy(out, in, sizeof(gr_complex) * length_); @@ -112,11 +105,11 @@ int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribu filter_state_ = true; last_out = gr_complex(0, 0); } - volk_32fc_x2_multiply_conjugate_32fc(c_samples, in, (in - 1), length_); - volk_32fc_s32f_atan2_32f(angle_, c_samples, static_cast(1.0), length_); + volk_32fc_x2_multiply_conjugate_32fc(c_samples.data(), in, (in - 1), length_); + volk_32fc_s32f_atan2_32f(angle_.data(), c_samples.data(), static_cast(1.0), length_); for (int32_t aux = 0; aux < length_; aux++) { - z_0 = std::exp(gr_complex(0, 1) * (*(angle_ + aux))); + z_0 = std::exp(gr_complex(0, 1) * (*(angle_.data() + aux))); *(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out; last_out = *(out + aux); } diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h index 488f00108..452856092 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h @@ -27,6 +27,7 @@ #endif #include #include +#include // for volk_gnsssdr::vector #include class Notch; @@ -50,7 +51,7 @@ notch_sptr make_notch_filter( class Notch : public gr::block { public: - ~Notch(); + ~Notch() = default; void forecast(int noutput_items, gr_vector_int &ninput_items_required); @@ -61,6 +62,13 @@ public: private: friend notch_sptr make_notch_filter(float pfa, float p_c_factor, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); Notch(float pfa, float p_c_factor, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); + std::unique_ptr d_fft; + volk_gnsssdr::vector c_samples; + volk_gnsssdr::vector angle_; + volk_gnsssdr::vector power_spect; + gr_complex last_out; + gr_complex z_0; + gr_complex p_c_factor; float pfa; float noise_pow_est; float thres_; @@ -70,13 +78,6 @@ private: uint32_t n_segments_est; uint32_t n_segments_reset; bool filter_state_; - gr_complex last_out; - gr_complex z_0; - gr_complex p_c_factor; - gr_complex *c_samples; - float *angle_; - float *power_spect; - std::unique_ptr d_fft; }; #endif // GNSS_SDR_NOTCH_H diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc index a11fb35e6..3f2ee6ee6 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc @@ -18,6 +18,7 @@ */ #include "notch_lite_cc.h" +#include "gnss_sdr_make_unique.h" #include #include #include @@ -63,14 +64,8 @@ NotchLite::NotchLite(float p_c_factor, c_samples2 = gr_complex(0.0, 0.0); angle1 = 0.0; angle2 = 0.0; - power_spect = static_cast(volk_malloc(length_ * sizeof(float), volk_get_alignment())); - d_fft = std::unique_ptr(new gr::fft::fft_complex(length_, true)); -} - - -NotchLite::~NotchLite() -{ - volk_free(power_spect); + power_spect = volk_gnsssdr::vector(length_); + d_fft = std::make_unique(length_, true); } @@ -99,8 +94,8 @@ int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __att { memcpy(d_fft->get_inbuf(), in, sizeof(gr_complex) * length_); d_fft->execute(); - volk_32fc_s32f_power_spectrum_32f(power_spect, d_fft->get_outbuf(), 1.0, length_); - volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect, 15.0, length_); + volk_32fc_s32f_power_spectrum_32f(power_spect.data(), d_fft->get_outbuf(), 1.0, length_); + volk_32f_s32f_calc_spectral_noise_floor_32f(&sig2dB, power_spect.data(), 15.0, length_); sig2lin = std::pow(10.0, (sig2dB / 10.0)) / static_cast(n_deg_fred); noise_pow_est = (static_cast(n_segments) * noise_pow_est + sig2lin) / static_cast(n_segments + 1); memcpy(out, in, sizeof(gr_complex) * length_); diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h index 85ffddb2f..857bbc423 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h @@ -27,6 +27,7 @@ #endif #include #include +#include // for volk_gnsssdr::vector #include class NotchLite; @@ -51,7 +52,7 @@ notch_lite_sptr make_notch_filter_lite( class NotchLite : public gr::block { public: - ~NotchLite(); + ~NotchLite() = default; void forecast(int noutput_items, gr_vector_int &ninput_items_required); @@ -62,6 +63,18 @@ public: private: friend notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff); NotchLite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff); + std::unique_ptr d_fft; + volk_gnsssdr::vector power_spect; + gr_complex last_out; + gr_complex z_0; + gr_complex p_c_factor; + gr_complex c_samples1; + gr_complex c_samples2; + float pfa; + float thres_; + float noise_pow_est; + float angle1; + float angle2; int32_t length_; int32_t n_segments; int32_t n_segments_est; @@ -69,19 +82,7 @@ private: int32_t n_segments_coeff_reset; int32_t n_segments_coeff; int32_t n_deg_fred; - float pfa; - float thres_; - float noise_pow_est; bool filter_state_; - gr_complex last_out; - gr_complex z_0; - gr_complex p_c_factor; - gr_complex c_samples1; - gr_complex c_samples2; - float angle1; - float angle2; - float *power_spect; - std::unique_ptr d_fft; }; #endif // GNSS_SDR_NOTCH_LITE_H diff --git a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc index 60912f4b6..efe123a32 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.cc @@ -50,17 +50,7 @@ pulse_blanking_cc::pulse_blanking_cc(float pfa, n_deg_fred = 2 * length_; boost::math::chi_squared_distribution my_dist_(n_deg_fred); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); - zeros_ = static_cast(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment())); - for (int32_t aux = 0; aux < length_; aux++) - { - zeros_[aux] = gr_complex(0.0, 0.0); - } -} - - -pulse_blanking_cc::~pulse_blanking_cc() -{ - volk_free(zeros_); + zeros_ = volk_gnsssdr::vector(length_); } @@ -78,13 +68,13 @@ int pulse_blanking_cc::general_work(int noutput_items, gr_vector_int &ninput_ite { const auto *in = reinterpret_cast(input_items[0]); auto *out = reinterpret_cast(output_items[0]); - auto *magnitude = static_cast(volk_malloc(noutput_items * sizeof(float), volk_get_alignment())); - volk_32fc_magnitude_squared_32f(magnitude, in, noutput_items); + auto magnitude = volk_gnsssdr::vector(noutput_items); + volk_32fc_magnitude_squared_32f(magnitude.data(), in, noutput_items); int32_t sample_index = 0; float segment_energy; while ((sample_index + length_) < noutput_items) { - volk_32f_accumulator_s32f(&segment_energy, (magnitude + sample_index), length_); + volk_32f_accumulator_s32f(&segment_energy, (magnitude.data() + sample_index), length_); if ((n_segments < n_segments_est) && (last_filtered == false)) { noise_power_estimation = (static_cast(n_segments) * noise_power_estimation + segment_energy / static_cast(n_deg_fred)) / static_cast(n_segments + 1); @@ -94,7 +84,7 @@ int pulse_blanking_cc::general_work(int noutput_items, gr_vector_int &ninput_ite { if ((segment_energy / noise_power_estimation) > thres_) { - memcpy(out, zeros_, sizeof(gr_complex) * length_); + memcpy(out, zeros_.data(), sizeof(gr_complex) * length_); last_filtered = true; } else @@ -112,7 +102,6 @@ int pulse_blanking_cc::general_work(int noutput_items, gr_vector_int &ninput_ite sample_index += length_; n_segments++; } - volk_free(magnitude); consume_each(sample_index); return sample_index; } diff --git a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h index 20f2c70c2..ee98a3b76 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/pulse_blanking_cc.h @@ -26,6 +26,7 @@ #include #endif #include +#include // for volk_gnsssdr::vector #include class pulse_blanking_cc; @@ -45,7 +46,7 @@ pulse_blanking_cc_sptr make_pulse_blanking_cc( class pulse_blanking_cc : public gr::block { public: - ~pulse_blanking_cc(); + ~pulse_blanking_cc() = default; void forecast(int noutput_items, gr_vector_int &ninput_items_required); @@ -55,16 +56,16 @@ public: private: friend pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset); + volk_gnsssdr::vector zeros_; + float noise_power_estimation; + float thres_; + float pfa; int32_t length_; int32_t n_segments; int32_t n_segments_est; int32_t n_segments_reset; int32_t n_deg_fred; bool last_filtered; - float noise_power_estimation; - float thres_; - float pfa; - gr_complex *zeros_; }; #endif // GNSS_SDR_PULSE_BLANKING_H diff --git a/src/algorithms/libs/pass_through.h b/src/algorithms/libs/pass_through.h index ef0f80b12..51bed37f4 100644 --- a/src/algorithms/libs/pass_through.h +++ b/src/algorithms/libs/pass_through.h @@ -78,14 +78,11 @@ private: conjugate_cc_sptr conjugate_cc_; conjugate_sc_sptr conjugate_sc_; conjugate_ic_sptr conjugate_ic_; - std::string item_type_; std::string role_; size_t item_size_; - unsigned int in_streams_; unsigned int out_streams_; - bool inverted_spectrum; }; diff --git a/src/algorithms/resampler/adapters/direct_resampler_conditioner.h b/src/algorithms/resampler/adapters/direct_resampler_conditioner.h index 5a36f6b84..bf13074f1 100644 --- a/src/algorithms/resampler/adapters/direct_resampler_conditioner.h +++ b/src/algorithms/resampler/adapters/direct_resampler_conditioner.h @@ -63,17 +63,17 @@ public: gr::basic_block_sptr get_right_block() override; private: + gr::block_sptr resampler_; + gr::block_sptr file_sink_; std::string role_; - unsigned int in_stream_; - unsigned int out_stream_; std::string item_type_; - size_t item_size_; - bool dump_; std::string dump_filename_; double sample_freq_in_; double sample_freq_out_; - gr::block_sptr resampler_; - gr::block_sptr file_sink_; + size_t item_size_; + unsigned int in_stream_; + unsigned int out_stream_; + bool dump_; }; #endif // GNSS_SDR_DIRECT_RESAMPLER_CONDITIONER_H diff --git a/src/algorithms/resampler/adapters/mmse_resampler_conditioner.h b/src/algorithms/resampler/adapters/mmse_resampler_conditioner.h index aac630a8a..1ef983090 100644 --- a/src/algorithms/resampler/adapters/mmse_resampler_conditioner.h +++ b/src/algorithms/resampler/adapters/mmse_resampler_conditioner.h @@ -70,15 +70,6 @@ public: gr::basic_block_sptr get_right_block() override; private: - std::string role_; - unsigned int in_stream_; - unsigned int out_stream_; - std::string item_type_; - size_t item_size_; - bool dump_; - std::string dump_filename_; - double sample_freq_in_; - double sample_freq_out_; #ifdef GR_GREATER_38 gr::filter::mmse_resampler_cc::sptr resampler_; #else @@ -86,6 +77,15 @@ private: #endif gr::filter::fir_filter_ccf::sptr fir_filter_ccf_; gr::block_sptr file_sink_; + std::string role_; + std::string item_type_; + std::string dump_filename_; + size_t item_size_; + double sample_freq_in_; + double sample_freq_out_; + unsigned int in_stream_; + unsigned int out_stream_; + bool dump_; }; #endif // GNSS_SDR_FRACTIONAL_RESAMPLER_CONDITIONER_H diff --git a/src/algorithms/signal_generator/adapters/signal_generator.h b/src/algorithms/signal_generator/adapters/signal_generator.h index 9bb607f1d..4e97b07d1 100644 --- a/src/algorithms/signal_generator/adapters/signal_generator.h +++ b/src/algorithms/signal_generator/adapters/signal_generator.h @@ -72,13 +72,6 @@ public: gr::basic_block_sptr get_right_block() override; private: - std::string role_; - unsigned int in_stream_; - unsigned int out_stream_; - std::string item_type_; - size_t item_size_; - bool dump_; - std::string dump_filename_; #if GNURADIO_USES_STD_POINTERS std::shared_ptr gen_source_; #else @@ -86,6 +79,13 @@ private: #endif gr::blocks::vector_to_stream::sptr vector_to_stream_; gr::blocks::file_sink::sptr file_sink_; + std::string role_; + std::string item_type_; + std::string dump_filename_; + size_t item_size_; + unsigned int in_stream_; + unsigned int out_stream_; + bool dump_; }; #endif // GNSS_SDR_SIGNAL_GENERATOR_H diff --git a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc index c6bb5ff6a..ba6c79c44 100644 --- a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc +++ b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc @@ -65,17 +65,17 @@ signal_generator_c::signal_generator_c(std::vector signal1, float BW_BB) : gr::block("signal_gen_cc", gr::io_signature::make(0, 0, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(gr_complex) * vector_length)), signal_(std::move(signal1)), system_(std::move(system)), - PRN_(PRN), CN0_dB_(std::move(CN0_dB)), doppler_Hz_(std::move(doppler_Hz)), + PRN_(PRN), delay_chips_(std::move(delay_chips)), delay_sec_(std::move(delay_sec)), - data_flag_(data_flag), - noise_flag_(noise_flag), + BW_BB_(BW_BB * static_cast(fs_in) / 2.0), fs_in_(fs_in), num_sats_(PRN.size()), vector_length_(vector_length), - BW_BB_(BW_BB * static_cast(fs_in) / 2.0) + data_flag_(data_flag), + noise_flag_(noise_flag) { init(); generate_codes(); diff --git a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h index ca2307640..ae5cbea6d 100644 --- a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h +++ b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.h @@ -121,35 +121,35 @@ private: void generate_codes(); + std::random_device r; + std::uniform_int_distribution uniform_dist; + std::normal_distribution normal_dist; std::vector signal_; std::vector system_; - std::vector PRN_; + std::vector> sampled_code_data_; + std::vector> sampled_code_pilot_; + std::vector current_data_bits_; + std::vector complex_phase_; std::vector CN0_dB_; std::vector doppler_Hz_; + std::vector start_phase_rad_; + std::vector PRN_; std::vector delay_chips_; std::vector delay_sec_; - bool data_flag_; - bool noise_flag_; - unsigned int fs_in_; - unsigned int num_sats_; - unsigned int vector_length_; - float BW_BB_; std::vector samples_per_code_; std::vector num_of_codes_per_vector_; std::vector data_bit_duration_ms_; std::vector ms_counter_; - std::vector start_phase_rad_; - std::vector current_data_bits_; std::vector current_data_bit_int_; std::vector data_modulation_; std::vector pilot_modulation_; - std::vector> sampled_code_data_; - std::vector> sampled_code_pilot_; - std::vector complex_phase_; + float BW_BB_; unsigned int work_counter_{}; - std::random_device r; - std::uniform_int_distribution uniform_dist; - std::normal_distribution normal_dist; + unsigned int fs_in_; + unsigned int num_sats_; + unsigned int vector_length_; + bool data_flag_; + bool noise_flag_; }; #endif // GNSS_SDR_SIGNAL_GENERATOR_C_H