From fa19b2e6a48edfb0d600bff0e9f48e46dc45c56c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 28 Jan 2019 01:08:57 +0100 Subject: [PATCH] Fix compilation in Mac OS and crosscompilation. Formatting rules applied --- .../adapters/beidou_b1i_pcps_acquisition.cc | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc index b355794ff..d2c8a99e2 100644 --- a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc @@ -32,27 +32,26 @@ */ #include "beidou_b1i_pcps_acquisition.h" +#include "Beidou_B1I.h" +#include "acq_conf.h" +#include "beidou_b1i_signal_processing.h" #include "configuration_interface.h" #include "gnss_sdr_flags.h" -#include "acq_conf.h" #include #include -#include "beidou_b1i_signal_processing.h" -#include "Beidou_B1I.h" - using google::LogMessage; BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( ConfigurationInterface* configuration, - std::string role, - unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) { - Acq_Conf acq_parameters = Acq_Conf(); + Acq_Conf acq_parameters = Acq_Conf(); configuration_ = configuration; std::string default_item_type = "gr_complex"; std::string default_dump_filename = "./data/acquisition.dat"; @@ -61,7 +60,7 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); acq_parameters.fs_in = fs_in_; dump_ = configuration_->property(role + ".dump", false); @@ -82,7 +81,7 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); acq_parameters.dump_filename = dump_filename_; //--- Find number of samples per spreading code ------------------------- - code_length_ = static_cast(std::round(static_cast(fs_in_) / ( BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS))); + code_length_ = static_cast(std::round(static_cast(fs_in_) / (BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS))); vector_length_ = code_length_ * sampled_ms_; @@ -93,7 +92,7 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( code_ = new gr_complex[vector_length_]; - if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); } @@ -114,7 +113,7 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; - if (item_type_.compare("cbyte") == 0) + if (item_type_ == "cbyte") { cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); float_to_complex_ = gr::blocks::float_to_complex::make(); @@ -123,7 +122,7 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( channel_ = 0; threshold_ = 0.0; doppler_step_ = 0; - gnss_synchro_ = 0; + gnss_synchro_ = nullptr; if (in_streams_ > 1) { LOG(ERROR) << "This implementation only supports one input stream"; @@ -210,7 +209,7 @@ void BeidouB1iPcpsAcquisition::init() void BeidouB1iPcpsAcquisition::set_local_code() { - std::complex* code = new std::complex[code_length_]; + auto* code = new std::complex[code_length_]; beidou_b1i_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); @@ -254,9 +253,9 @@ float BeidouB1iPcpsAcquisition::calculate_threshold(float pfa) unsigned int ncells = vector_length_ * frequency_bins; double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa, exponent); - double lambda = static_cast(vector_length_); + auto lambda = static_cast(vector_length_); boost::math::exponential_distribution mydist(lambda); - float threshold = static_cast(quantile(mydist, val)); + auto threshold = static_cast(quantile(mydist, val)); return threshold; } @@ -264,15 +263,15 @@ float BeidouB1iPcpsAcquisition::calculate_threshold(float pfa) void BeidouB1iPcpsAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - // nothing to connect + // nothing to connect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - // nothing to connect + // nothing to connect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); @@ -287,15 +286,15 @@ void BeidouB1iPcpsAcquisition::connect(gr::top_block_sptr top_block) void BeidouB1iPcpsAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { - // nothing to disconnect + // nothing to disconnect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { - // nothing to disconnect + // nothing to disconnect } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { // Since a byte-based acq implementation is not available, // we just convert cshorts to gr_complex @@ -312,15 +311,15 @@ void BeidouB1iPcpsAcquisition::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr BeidouB1iPcpsAcquisition::get_left_block() { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { return acquisition_; } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { return acquisition_; } - else if (item_type_.compare("cbyte") == 0) + else if (item_type_ == "cbyte") { return cbyte_to_float_x2_; }