1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-13 19:50:34 +00:00

Improve constructors: prefer member initializers to member initializations in the constructor body

This commit is contained in:
Carles Fernandez 2021-10-11 15:02:43 +02:00
parent a9a55d7156
commit 3d6cfdbcbe
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
7 changed files with 122 additions and 157 deletions

View File

@ -47,20 +47,41 @@ pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_)
}
pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acquisition",
gr::io_signature::make(1, 1, conf_.it_size),
gr::io_signature::make(0, 1, sizeof(Gnss_Synchro)))
pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_)
: gr::block("pcps_acquisition",
gr::io_signature::make(1, 1, conf_.it_size),
gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))),
d_acq_parameters(conf_),
d_gnss_synchro(nullptr),
d_dump_filename(conf_.dump_filename),
d_dump_number(0LL),
d_sample_counter(0ULL),
d_threshold(0.0),
d_mag(0),
d_input_power(0.0),
d_test_statistics(0.0),
d_doppler_center_step_two(0.0),
d_state(0),
d_positive_acq(0),
d_doppler_center(0U),
d_doppler_bias(0),
d_channel(0U),
d_samplesPerChip(conf_.samples_per_chip),
d_doppler_step(conf_.doppler_step),
d_num_noncoherent_integrations_counter(0U),
d_consumed_samples(conf_.sampled_ms * conf_.samples_per_ms * (conf_.bit_transition_flag ? 2.0 : 1.0)),
d_num_doppler_bins(0U),
d_num_doppler_bins_step2(conf_.num_doppler_bins_step2),
d_dump_channel(conf_.dump_channel),
d_buffer_count(0U),
d_active(false),
d_worker_active(false),
d_step_two(false),
d_use_CFAR_algorithm_flag(conf_.use_CFAR_algorithm_flag),
d_dump(conf_.dump)
{
this->message_port_register_out(pmt::mp("events"));
d_acq_parameters = conf_;
d_sample_counter = 0ULL; // SAMPLE COUNTER
d_active = false;
d_positive_acq = 0;
d_state = 0;
d_doppler_bias = 0;
d_num_noncoherent_integrations_counter = 0U;
d_consumed_samples = d_acq_parameters.sampled_ms * d_acq_parameters.samples_per_ms * (d_acq_parameters.bit_transition_flag ? 2.0 : 1.0);
if (d_acq_parameters.sampled_ms == d_acq_parameters.ms_per_code)
{
d_fft_size = d_consumed_samples;
@ -70,23 +91,6 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu
d_fft_size = d_consumed_samples * 2;
}
// d_fft_size = next power of two? ////
d_mag = 0;
d_input_power = 0.0;
d_num_doppler_bins = 0U;
d_threshold = 0.0;
d_doppler_step = d_acq_parameters.doppler_step;
d_doppler_center = 0U;
d_doppler_center_step_two = 0.0;
d_test_statistics = 0.0;
d_channel = 0U;
if (conf_.it_size == sizeof(gr_complex))
{
d_cshort = false;
}
else
{
d_cshort = true;
}
// COD:
// Experimenting with the overlap/save technique for handling bit trannsitions
@ -110,25 +114,24 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu
d_fft_if = gnss_fft_fwd_make_unique(d_fft_size);
d_ifft = gnss_fft_rev_make_unique(d_fft_size);
d_gnss_synchro = nullptr;
d_worker_active = false;
d_grid = arma::fmat();
d_narrow_grid = arma::fmat();
if (conf_.it_size == sizeof(gr_complex))
{
d_cshort = false;
}
else
{
d_cshort = true;
}
d_data_buffer = volk_gnsssdr::vector<std::complex<float>>(d_consumed_samples);
if (d_cshort)
{
d_data_buffer_sc = volk_gnsssdr::vector<lv_16sc_t>(d_consumed_samples);
}
d_grid = arma::fmat();
d_narrow_grid = arma::fmat();
d_step_two = false;
d_num_doppler_bins_step2 = d_acq_parameters.num_doppler_bins_step2;
d_samplesPerChip = d_acq_parameters.samples_per_chip;
d_buffer_count = 0U;
d_use_CFAR_algorithm_flag = d_acq_parameters.use_CFAR_algorithm_flag;
d_dump_number = 0LL;
d_dump_channel = d_acq_parameters.dump_channel;
d_dump = d_acq_parameters.dump;
d_dump_filename = d_acq_parameters.dump_filename;
if (d_dump)
{
std::string dump_path;

View File

@ -92,7 +92,7 @@ pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_);
class pcps_acquisition : public gr::block
{
public:
~pcps_acquisition() = default;
~pcps_acquisition() override = default;
/*!
* \brief Initializes acquisition algorithm and reserves memory.
@ -212,7 +212,7 @@ public:
*/
int general_work(int noutput_items, gr_vector_int& ninput_items,
gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items);
gr_vector_void_star& output_items) override;
private:
friend pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_);
@ -226,7 +226,7 @@ private:
void send_positive_acquisition();
void dump_results(int32_t effective_fft_size);
bool is_fdma();
bool start();
bool start() override;
void calculate_threshold(void);
float first_vs_second_peak_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step);
float max_to_input_power_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step);

View File

@ -19,7 +19,7 @@
#include "pcps_acquisition_fpga.h"
#include "gnss_sdr_make_unique.h"
#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11
#include "gnss_synchro.h"
#include <glog/logging.h>
#include <cmath> // for ceil
@ -34,37 +34,31 @@ pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_)
pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_)
: d_acq_parameters(std::move(conf_)),
d_gnss_synchro(nullptr),
d_sample_counter(0ULL),
d_threshold(0.0),
d_mag(0),
d_input_power(0.0),
d_test_statistics(0.0),
d_doppler_step2(d_acq_parameters.doppler_step2),
d_doppler_center_step_two(0.0),
d_doppler_center(0U),
d_state(0),
d_doppler_index(0U),
d_channel(0U),
d_doppler_step(0U),
d_doppler_max(d_acq_parameters.doppler_max),
d_fft_size(d_acq_parameters.samples_per_code),
d_num_doppler_bins(0U),
d_downsampling_factor(d_acq_parameters.downsampling_factor),
d_select_queue_Fpga(d_acq_parameters.select_queue_Fpga),
d_total_block_exp(d_acq_parameters.total_block_exp),
d_num_doppler_bins_step2(d_acq_parameters.num_doppler_bins_step2),
d_max_num_acqs(d_acq_parameters.max_num_acqs),
d_active(false),
d_make_2_steps(d_acq_parameters.make_2_steps)
{
d_acq_parameters = std::move(conf_);
d_sample_counter = 0ULL; // Sample Counter
d_active = false;
d_state = 0;
d_fft_size = d_acq_parameters.samples_per_code;
d_mag = 0;
d_input_power = 0.0;
d_num_doppler_bins = 0U;
d_threshold = 0.0;
d_doppler_step = 0U;
d_doppler_center = 0U;
d_doppler_index = 0U;
d_test_statistics = 0.0;
d_channel = 0U;
d_gnss_synchro = nullptr;
d_downsampling_factor = d_acq_parameters.downsampling_factor;
d_select_queue_Fpga = d_acq_parameters.select_queue_Fpga;
d_total_block_exp = d_acq_parameters.total_block_exp;
d_make_2_steps = d_acq_parameters.make_2_steps;
d_num_doppler_bins_step2 = d_acq_parameters.num_doppler_bins_step2;
d_doppler_step2 = d_acq_parameters.doppler_step2;
d_doppler_center_step_two = 0.0;
d_doppler_max = d_acq_parameters.doppler_max;
d_max_num_acqs = d_acq_parameters.max_num_acqs;
d_acquisition_fpga = std::make_unique<Fpga_Acquisition>(d_acq_parameters.device_name, d_acq_parameters.code_length, d_acq_parameters.doppler_max, d_fft_size,
d_acq_parameters.fs_in, d_acq_parameters.select_queue_Fpga, d_acq_parameters.all_fft_codes, d_acq_parameters.excludelimit);
}
@ -302,6 +296,7 @@ void pcps_acquisition_fpga::reset_acquisition()
d_acquisition_fpga->close_device();
}
void pcps_acquisition_fpga::stop_acquisition()
{
// this function stops the acquisition and the other FPGA Modules.

View File

@ -33,6 +33,8 @@ else()
endif()
target_link_libraries(acquisition_libs
PUBLIC
Gnuradio::runtime
PRIVATE
Gflags::gflags
Glog::glog

View File

@ -18,43 +18,8 @@
#include "acq_conf.h"
#include "item_type_helpers.h"
#include <glog/logging.h>
#include <gnuradio/gr_complex.h>
#include <cmath>
Acq_Conf::Acq_Conf()
{
/* PCPS acquisition configuration */
sampled_ms = 1U;
ms_per_code = 1U;
max_dwells = 1U;
samples_per_chip = 2U;
chips_per_second = 1023000;
doppler_max = 5000;
doppler_min = -5000;
doppler_step = 250.0;
num_doppler_bins_step2 = 4U;
doppler_step2 = 125.0;
pfa = 0.0;
pfa2 = 0.0;
fs_in = 4000000;
samples_per_ms = 0.0;
samples_per_code = 0.0;
bit_transition_flag = false;
use_CFAR_algorithm_flag = true;
dump = false;
blocking = true;
make_2_steps = false;
dump_channel = 0U;
it_size = sizeof(gr_complex);
item_type = std::string("gr_complex");
blocking_on_standby = false;
use_automatic_resampler = false;
resampler_ratio = 1.0;
resampled_fs = 0LL;
resampler_latency_samples = 0U;
enable_monitor_output = false;
}
void Acq_Conf::SetFromConfiguration(const ConfigurationInterface *configuration,
const std::string &role, double chip_rate, double opt_freq)

View File

@ -19,6 +19,7 @@
#define GNSS_SDR_ACQ_CONF_H
#include "configuration_interface.h"
#include <gnuradio/gr_complex.h>
#include <cstdint>
#include <string>
@ -32,46 +33,46 @@
class Acq_Conf
{
public:
Acq_Conf();
Acq_Conf() = default;
void SetFromConfiguration(const ConfigurationInterface *configuration, const std::string &role, double chip_rate, double opt_freq);
/* PCPS Acquisition configuration */
std::string item_type;
std::string item_type{"gr_complex"};
std::string dump_filename;
int64_t fs_in;
int64_t resampled_fs;
int64_t fs_in{4000000LL};
int64_t resampled_fs{0LL};
size_t it_size;
size_t it_size{sizeof(gr_complex)};
float doppler_step;
float samples_per_ms;
float doppler_step2;
float pfa;
float pfa2;
float samples_per_code;
float resampler_ratio;
float doppler_step{250.0};
float samples_per_ms{0.0};
float doppler_step2{125.0};
float pfa{0.0};
float pfa2{0.0};
float samples_per_code{0.0};
float resampler_ratio{1.0};
uint32_t sampled_ms;
uint32_t ms_per_code;
uint32_t samples_per_chip;
uint32_t chips_per_second;
uint32_t max_dwells;
uint32_t num_doppler_bins_step2;
uint32_t resampler_latency_samples;
uint32_t dump_channel;
int32_t doppler_max;
int32_t doppler_min;
uint32_t sampled_ms{1U};
uint32_t ms_per_code{1U};
uint32_t samples_per_chip{2U};
uint32_t chips_per_second{1023000U};
uint32_t max_dwells{1U};
uint32_t num_doppler_bins_step2{4U};
uint32_t resampler_latency_samples{0U};
uint32_t dump_channel{0U};
int32_t doppler_max{5000};
int32_t doppler_min{-5000};
bool bit_transition_flag;
bool use_CFAR_algorithm_flag;
bool dump;
bool blocking;
bool blocking_on_standby; // enable it only for unit testing to avoid sample consume on idle status
bool make_2_steps;
bool use_automatic_resampler;
bool enable_monitor_output;
bool bit_transition_flag{false};
bool use_CFAR_algorithm_flag{true};
bool dump{false};
bool blocking{true};
bool blocking_on_standby{false}; // enable it only for unit testing to avoid sample consume on idle status
bool make_2_steps{false};
bool use_automatic_resampler{false};
bool enable_monitor_output{false};
private:
void SetDerivedParams();

View File

@ -51,28 +51,25 @@ Fpga_Acquisition::Fpga_Acquisition(std::string device_name,
int64_t fs_in,
uint32_t select_queue,
uint32_t *all_fft_codes,
uint32_t excludelimit)
uint32_t excludelimit) : d_device_name(std::move(device_name)),
d_fs_in(fs_in),
d_fd(0), // driver descriptor
d_map_base(nullptr), // driver memory map
d_all_fft_codes(all_fft_codes),
d_vector_length(nsamples_total),
d_excludelimit(excludelimit),
d_nsamples_total(nsamples_total),
d_nsamples(nsamples), // number of samples not including padding
d_select_queue(select_queue),
d_doppler_max(doppler_max),
d_doppler_step(0),
d_PRN(0)
{
const uint32_t vector_length = nsamples_total;
// initial values
d_device_name = std::move(device_name);
d_fs_in = fs_in;
d_vector_length = vector_length;
d_excludelimit = excludelimit;
d_nsamples = nsamples; // number of samples not including padding
d_select_queue = select_queue;
d_nsamples_total = nsamples_total;
d_doppler_max = doppler_max;
d_doppler_step = 0;
d_fd = 0; // driver descriptor
d_map_base = nullptr; // driver memory map
d_all_fft_codes = all_fft_codes;
Fpga_Acquisition::open_device();
Fpga_Acquisition::reset_acquisition();
Fpga_Acquisition::fpga_acquisition_test_register();
Fpga_Acquisition::close_device();
d_PRN = 0;
DLOG(INFO) << "Acquisition FPGA class created";
}
@ -244,12 +241,14 @@ void Fpga_Acquisition::reset_acquisition()
// the FPGA HW modules including the multicorrelators
}
void Fpga_Acquisition::stop_acquisition()
{
d_map_base[8] = STOP_ACQUISITION; // setting bit 3 of d_map_base[8] stops the acquisition module. This stops all
// the FPGA HW modules including the multicorrelators
}
// this function is only used for the unit tests
void Fpga_Acquisition::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor)
{