From 52c69073ac9f46bdff2b42d2704fc2d54eb21458 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 18 Mar 2019 09:10:00 +0100 Subject: [PATCH] Apply clang-tidy fixes --- .../adapters/beidou_b3i_pcps_acquisition.cc | 32 ++++++------- .../adapters/beidou_b3i_pcps_acquisition.h | 2 +- .../libs/beidou_b3i_signal_processing.cc | 45 ++++++++++--------- .../adapters/beidou_b3i_telemetry_decoder.cc | 2 +- .../adapters/beidou_b3i_telemetry_decoder.h | 2 +- .../adapters/beidou_b3i_dll_pll_tracking.cc | 7 ++- .../adapters/beidou_b3i_dll_pll_tracking.h | 2 +- src/core/system_parameters/Beidou_DNAV.h | 4 +- 8 files changed, 50 insertions(+), 46 deletions(-) diff --git a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc index d8eec0412..cb42488af 100644 --- a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc @@ -43,7 +43,7 @@ using google::LogMessage; BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), @@ -90,7 +90,7 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( code_ = new gr_complex[vector_length_]; - if (item_type_.compare("cshort") == 0) + if (item_type_ == "cshort") { item_size_ = sizeof(lv_16sc_t); } @@ -111,7 +111,7 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( 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(); @@ -120,7 +120,7 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( 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"; @@ -207,7 +207,7 @@ void BeidouB3iPcpsAcquisition::init() void BeidouB3iPcpsAcquisition::set_local_code() { - std::complex* code = new std::complex[code_length_]; + auto* code = new std::complex[code_length_]; beidou_b3i_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); @@ -251,9 +251,9 @@ float BeidouB3iPcpsAcquisition::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; } @@ -261,15 +261,15 @@ float BeidouB3iPcpsAcquisition::calculate_threshold(float pfa) void BeidouB3iPcpsAcquisition::connect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { // nothing to connect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { // 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); @@ -284,15 +284,15 @@ void BeidouB3iPcpsAcquisition::connect(gr::top_block_sptr top_block) void BeidouB3iPcpsAcquisition::disconnect(gr::top_block_sptr top_block) { - if (item_type_.compare("gr_complex") == 0) + if (item_type_ == "gr_complex") { // nothing to disconnect } - else if (item_type_.compare("cshort") == 0) + else if (item_type_ == "cshort") { // 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 @@ -309,15 +309,15 @@ void BeidouB3iPcpsAcquisition::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr BeidouB3iPcpsAcquisition::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_; } diff --git a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h index cc76c671d..79059b7c8 100644 --- a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h @@ -54,7 +54,7 @@ class BeidouB3iPcpsAcquisition : public AcquisitionInterface { public: BeidouB3iPcpsAcquisition(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, + const std::string& role, unsigned int in_streams, unsigned int out_streams); virtual ~BeidouB3iPcpsAcquisition(); diff --git a/src/algorithms/libs/beidou_b3i_signal_processing.cc b/src/algorithms/libs/beidou_b3i_signal_processing.cc index d0e6de608..1b1268760 100644 --- a/src/algorithms/libs/beidou_b3i_signal_processing.cc +++ b/src/algorithms/libs/beidou_b3i_signal_processing.cc @@ -39,30 +39,35 @@ void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shi const unsigned int _code_length = 10230; bool G1[_code_length]; bool G2[_code_length]; - std::array G1_register = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; - std::array G2_register = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; - std::array G1_register_reset = {{0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; + std::array G1_register = {{true, true, true, true, true, true, true, true, true, true, true, true, true}}; + std::array G2_register = {{true, true, true, true, true, true, true, true, true, true, true, true, true}}; + std::array G1_register_reset = {{false, false, true, true, true, true, true, true, true, true, true, true, true}}; bool feedback1, feedback2, aux; uint32_t lcv, lcv2, delay; int32_t prn_idx = _prn - 1; // clang-format off std::array, 63> G2_register_shifted = {{ - {{1,0,1,0,1,1,1,1,1,1,1,1,1,}}, {{1,1,1,1,0,0,0,1,0,1,0,1,1,}}, {{1,0,1,1,1,1,0,0,0,1,0,1,0,}}, {{1,1,1,1,1,1,1,1,1,1,0,1,1,}}, - {{1,1,0,0,1,0,0,0,1,1,1,1,1,}}, {{1,0,0,1,0,0,1,1,0,0,1,0,0,}}, {{1,1,1,1,1,1,1,0,1,0,0,1,0,}}, {{1,1,1,0,1,1,1,1,1,1,1,0,1,}}, - {{1,0,1,0,0,0,0,0,0,0,0,1,0,}}, {{0,0,1,0,0,0,0,0,1,1,0,1,1,}}, {{1,1,1,0,1,0,1,1,1,0,0,0,0,}}, {{0,0,1,0,1,1,0,0,1,1,1,1,0,}}, - {{0,1,1,0,0,1,0,0,1,0,1,0,1,}}, {{0,1,1,1,0,0,0,1,0,0,1,1,0,}}, {{1,0,0,0,1,1,0,0,0,1,0,0,1,}}, {{1,1,1,0,0,0,1,1,1,1,1,0,0,}}, - {{0,0,1,0,0,1,1,0,0,0,1,0,1,}}, {{0,0,0,0,0,1,1,1,0,1,1,0,0,}}, {{1,0,0,0,1,0,1,0,1,0,1,1,1,}}, {{0,0,0,1,0,1,1,0,1,1,1,1,0,}}, - {{0,0,1,0,0,0,0,1,0,1,1,0,1,}}, {{0,0,1,0,1,1,0,0,0,1,0,1,0,}}, {{0,0,0,1,0,1,1,0,0,1,1,1,1,}}, {{0,0,1,1,0,0,1,1,0,0,0,1,0,}}, - {{0,0,1,1,1,0,1,0,0,1,0,0,0,}}, {{0,1,0,0,1,0,0,1,0,1,0,0,1,}}, {{1,0,1,1,0,1,1,0,1,0,0,1,1,}}, {{1,0,1,0,1,1,1,1,0,0,0,1,0,}}, - {{0,0,0,1,0,1,1,1,1,0,1,0,1,}},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1,0,}}, {{0,0,1,0,0,0,1,0,0,1,1,1,0,}}}}; + {{true,false,true,false,true,true,true,true,true,true,true,true,true,}}, + {{true,true,true,true,false,false,false,true,false,true,false,true,true,}}, + {{true,false,true,true,true,true,false,false,false,true,false,true,false,}}, + {{true,true,true,true,true,true,true,true,true,true,false,true,true,}}, + {{true,true,false,false,true,false,false,false,true,true,true,true,true,}}, + {{true,false,false,true,false,false,true,true,false,false,true,false,false,}}, + {{true,true,true,true,true,true,true,false,true,false,false,true,false,}}, {{true,true,true,false,true,true,true,true,true,true,true,false,true,}}, + {{true,false,true,false,false,false,false,false,false,false,false,true,false,}}, {{false,false,true,false,false,false,false,false,true,true,false,true,true,}}, {{true,true,true,false,true,false,true,true,true,false,false,false,false,}}, {{false,false,true,false,true,true,false,false,true,true,true,true,false,}}, + {{false,true,true,false,false,true,false,false,true,false,true,false,true,}}, {{false,true,true,true,false,false,false,true,false,false,true,true,false,}}, {{true,false,false,false,true,true,false,false,false,true,false,false,true,}}, {{true,true,true,false,false,false,true,true,true,true,true,false,false,}}, + {{false,false,true,false,false,true,true,false,false,false,true,false,true,}}, {{false,false,false,false,false,true,true,true,false,true,true,false,false,}}, {{true,false,false,false,true,false,true,false,true,false,true,true,true,}}, {{false,false,false,true,false,true,true,false,true,true,true,true,false,}}, + {{false,false,true,false,false,false,false,true,false,true,true,false,true,}}, {{false,false,true,false,true,true,false,false,false,true,false,true,false,}}, {{false,false,false,true,false,true,true,false,false,true,true,true,true,}}, {{false,false,true,true,false,false,true,true,false,false,false,true,false,}}, + {{false,false,true,true,true,false,true,false,false,true,false,false,false,}}, {{false,true,false,false,true,false,false,true,false,true,false,false,true,}}, {{true,false,true,true,false,true,true,false,true,false,false,true,true,}}, {{true,false,true,false,true,true,true,true,false,false,false,true,false,}}, + {{false,false,false,true,false,true,true,true,true,false,true,false,true,}}, {{false,true,true,true,true,true,true,true,true,true,true,true,true,}}, {{false,true,true,false,true,true,false,false,false,true,true,true,true,}}, {{true,false,true,false,true,true,false,false,false,true,false,false,true,}}, + {{true,false,false,true,false,true,false,true,false,true,false,true,true,}}, {{true,true,false,false,true,true,false,true,false,false,true,false,true,}}, {{true,true,false,true,false,false,true,false,true,true,true,false,true,}}, {{true,true,true,true,true,false,true,true,true,false,true,false,false,}}, + {{false,false,true,false,true,false,true,true,false,false,true,true,true,}}, {{true,true,true,false,true,false,false,false,true,false,false,false,false,}}, {{true,true,false,true,true,true,false,false,true,false,false,false,false,}}, {{true,true,false,true,false,true,true,false,false,true,true,true,false,}}, + {{true,false,false,false,false,false,false,true,true,false,true,false,false,}}, {{false,true,false,true,true,true,true,false,true,true,false,false,true,}}, {{false,true,true,false,true,true,false,true,true,true,true,false,false,}}, {{true,true,false,true,false,false,true,true,true,false,false,false,true,}}, + {{false,false,true,true,true,false,false,true,false,false,false,true,false,}}, {{false,true,false,true,false,true,true,false,false,false,true,false,true,}}, {{true,false,false,true,true,true,true,true,false,false,true,true,false,}}, {{true,true,true,true,true,false,true,false,false,true,false,false,false,}}, + {{false,false,false,false,true,false,true,false,false,true,false,false,true,}}, {{true,false,false,false,false,true,false,true,false,true,true,false,false,}}, {{true,true,true,true,false,false,true,false,false,true,true,false,false,}}, {{false,true,false,false,true,true,false,false,false,true,true,true,true,}}, + {{false,false,false,false,false,false,false,false,true,true,false,false,false,}}, {{true,false,false,false,false,false,false,false,false,false,true,false,false,}}, {{false,false,true,true,false,true,false,true,false,false,true,true,false,}}, {{true,false,true,true,false,false,true,false,false,false,true,true,false,}}, + {{false,true,true,true,false,false,true,true,true,true,false,false,false,}}, {{false,false,true,false,true,true,true,false,false,true,false,true,false,}}, {{true,true,false,false,true,true,true,true,true,false,true,true,false,}}, {{true,false,false,true,false,false,true,false,false,false,true,false,true,}}, + {{false,true,true,true,false,false,false,true,false,false,false,false,false,}}, {{false,false,true,true,false,false,true,false,false,false,false,true,false,}}, {{false,false,true,false,false,false,true,false,false,true,true,true,false,}}}}; // clang-format on // A simple error check if ((prn_idx < 0) || (prn_idx > 63)) @@ -96,7 +101,7 @@ void beidou_b3i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shi // Reset G1 register if sequence found if (G1_register == G1_register_reset) { - G1_register = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; + G1_register = {{true, true, true, true, true, true, true, true, true, true, true, true, true}}; } } diff --git a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc index d334bb72a..702041239 100644 --- a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc @@ -34,7 +34,7 @@ #include BeidouB3iTelemetryDecoder::BeidouB3iTelemetryDecoder( - ConfigurationInterface *configuration, std::string role, + ConfigurationInterface *configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { diff --git a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h index a0b4996f9..6df5a9994 100644 --- a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h @@ -48,7 +48,7 @@ class BeidouB3iTelemetryDecoder : public TelemetryDecoderInterface { public: BeidouB3iTelemetryDecoder(ConfigurationInterface *configuration, - std::string role, unsigned int in_streams, + const std::string& role, unsigned int in_streams, unsigned int out_streams); virtual ~BeidouB3iTelemetryDecoder(); diff --git a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc index 2deaefce1..6253788e8 100644 --- a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc @@ -45,7 +45,7 @@ using google::LogMessage; BeidouB3iDllPllTracking::BeidouB3iDllPllTracking( - ConfigurationInterface* configuration, std::string role, + ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { Dll_Pll_Conf trk_param = Dll_Pll_Conf(); @@ -118,7 +118,7 @@ BeidouB3iDllPllTracking::BeidouB3iDllPllTracking( trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### - if (item_type.compare("gr_complex") == 0) + if (item_type == "gr_complex") { item_size_ = sizeof(gr_complex); tracking_ = dll_pll_veml_make_tracking(trk_param); @@ -142,8 +142,7 @@ BeidouB3iDllPllTracking::BeidouB3iDllPllTracking( BeidouB3iDllPllTracking::~BeidouB3iDllPllTracking() -{ -} += default; void BeidouB3iDllPllTracking::start_tracking() diff --git a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h index c3dda0777..d56d10069 100644 --- a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h @@ -50,7 +50,7 @@ class BeidouB3iDllPllTracking : public TrackingInterface { public: BeidouB3iDllPllTracking(ConfigurationInterface* configuration, - std::string role, + const std::string& role, unsigned int in_streams, unsigned int out_streams); diff --git a/src/core/system_parameters/Beidou_DNAV.h b/src/core/system_parameters/Beidou_DNAV.h index fdb496709..fd2792493 100644 --- a/src/core/system_parameters/Beidou_DNAV.h +++ b/src/core/system_parameters/Beidou_DNAV.h @@ -36,8 +36,8 @@ #include #include -const double BEIDOU_DNAV_C_m_s = 299792458.0; //!< The speed of light, [m/s] -const double BEIDOU_DNAV_C_m_ms = 299792.4580; //!< The speed of light, [m/ms] +const double BEIDOU_DNAV_C_M_S = 299792458.0; //!< The speed of light, [m/s] +const double BEIDOU_DNAV_C_M_MS = 299792.4580; //!< The speed of light, [m/ms] const double BEIDOU_DNAV_PI = 3.1415926535898; //!< Pi const double BEIDOU_DNAV_TWO_PI = 6.283185307179586; //!< 2Pi const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_BITS = 11;