From 9c7795dd9ad225478bc7423ac8fae348245c21b0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 12 Sep 2014 20:23:39 +0200 Subject: [PATCH] Changing C-styled cast by C++ style --- src/algorithms/PVT/libs/galileo_e1_ls_pvt.cc | 64 +++++++++--------- src/algorithms/PVT/libs/gps_l1_ca_ls_pvt.cc | 8 +-- src/algorithms/PVT/libs/hybrid_ls_pvt.cc | 8 +-- src/algorithms/PVT/libs/nmea_printer.cc | 8 +-- ...lileo_e1_pcps_8ms_ambiguous_acquisition.cc | 2 +- .../galileo_e1_pcps_ambiguous_acquisition.cc | 6 +- ...eo_e1_pcps_cccwsr_ambiguous_acquisition.cc | 4 +- ...e1_pcps_quicksync_ambiguous_acquisition.cc | 2 +- ...ileo_e1_pcps_tong_ambiguous_acquisition.cc | 6 +- ...ileo_e5a_noncoherent_iq_acquisition_caf.cc | 6 +- .../adapters/gps_l1_ca_pcps_acquisition.cc | 4 +- .../gps_l1_ca_pcps_multithread_acquisition.cc | 8 +-- .../gps_l1_ca_pcps_opencl_acquisition.cc | 8 +-- .../gps_l1_ca_pcps_quicksync_acquisition.cc | 6 +- .../gps_l1_ca_pcps_tong_acquisition.cc | 10 +-- ...o_e5a_noncoherent_iq_acquisition_caf_cc.cc | 66 +++++++++---------- .../galileo_pcps_8ms_acquisition_cc.cc | 19 +++--- .../gnuradio_blocks/pcps_acquisition_cc.cc | 16 ++--- .../pcps_acquisition_fine_doppler_cc.cc | 24 ++++--- .../pcps_assisted_acquisition_cc.cc | 12 ++-- .../pcps_cccwsr_acquisition_cc.cc | 22 +++---- .../pcps_opencl_acquisition_cc.cc | 32 ++++----- .../pcps_quicksync_acquisition_cc.cc | 37 +++++------ .../pcps_tong_acquisition_cc.cc | 16 ++--- .../galileo_e5a_telemetry_decoder_cc.cc | 10 +-- .../system_parameters/galileo_utc_model.cc | 6 +- src/core/system_parameters/gps_utc_model.cc | 6 +- src/main/main.cc | 2 +- 28 files changed, 207 insertions(+), 211 deletions(-) diff --git a/src/algorithms/PVT/libs/galileo_e1_ls_pvt.cc b/src/algorithms/PVT/libs/galileo_e1_ls_pvt.cc index b73bc6314..6ed0f6920 100644 --- a/src/algorithms/PVT/libs/galileo_e1_ls_pvt.cc +++ b/src/algorithms/PVT/libs/galileo_e1_ls_pvt.cc @@ -347,7 +347,7 @@ bool galileo_e1_ls_pvt::get_PVT(std::map gnss_pseudoranges_map d_position_UTC_time = p_time; LOG(INFO) << "Galileo Position at TOW=" << galileo_current_time << " in ECEF (X,Y,Z) = " << mypos; - cart2geo((double)mypos(0), (double)mypos(1), (double)mypos(2), 4); + cart2geo(static_cast(mypos(0)), static_cast(mypos(1)), static_cast(mypos(2)), 4); //ToDo: Find an Observables/PVT random bug with some satellite configurations that gives an erratic PVT solution (i.e. height>50 km) if (d_height_m > 50000) { @@ -366,17 +366,17 @@ bool galileo_e1_ls_pvt::get_PVT(std::map gnss_pseudoranges_map // 1- Rotation matrix from ECEF coordinates to ENU coordinates // ref: http://www.navipedia.net/index.php/Transformations_between_ECEF_and_ENU_coordinates arma::mat F = arma::zeros(3,3); - F(0,0) = -sin(GPS_TWO_PI*(d_longitude_d/360.0)); - F(0,1) = -sin(GPS_TWO_PI*(d_latitude_d/360.0))*cos(GPS_TWO_PI*(d_longitude_d/360.0)); - F(0,2) = cos(GPS_TWO_PI*(d_latitude_d/360.0))*cos(GPS_TWO_PI*(d_longitude_d/360.0)); + F(0,0) = -sin(GPS_TWO_PI * (d_longitude_d/360.0)); + F(0,1) = -sin(GPS_TWO_PI * (d_latitude_d/360.0)) * cos(GPS_TWO_PI * (d_longitude_d/360.0)); + F(0,2) = cos(GPS_TWO_PI * (d_latitude_d/360.0)) * cos(GPS_TWO_PI * (d_longitude_d/360.0)); - F(1,0) = cos((GPS_TWO_PI*d_longitude_d)/360.0); - F(1,1) = -sin((GPS_TWO_PI*d_latitude_d)/360.0)*sin((GPS_TWO_PI*d_longitude_d)/360.0); - F(1,2) = cos((GPS_TWO_PI*d_latitude_d/360.0))*sin((GPS_TWO_PI*d_longitude_d)/360.0); + F(1,0) = cos((GPS_TWO_PI * d_longitude_d)/360.0); + F(1,1) = -sin((GPS_TWO_PI * d_latitude_d)/360.0) * sin((GPS_TWO_PI * d_longitude_d)/360.0); + F(1,2) = cos((GPS_TWO_PI * d_latitude_d/360.0)) * sin((GPS_TWO_PI * d_longitude_d)/360.0); F(2,0) = 0; - F(2,1) = cos((GPS_TWO_PI*d_latitude_d)/360.0); - F(2,2) = sin((GPS_TWO_PI*d_latitude_d/360.0)); + F(2,1) = cos((GPS_TWO_PI * d_latitude_d)/360.0); + F(2,2) = sin((GPS_TWO_PI * d_latitude_d/360.0)); // 2- Apply the rotation to the latest covariance matrix (available in ECEF from LS) arma::mat Q_ECEF = d_Q.submat(0, 0, 2, 2); @@ -384,7 +384,7 @@ bool galileo_e1_ls_pvt::get_PVT(std::map gnss_pseudoranges_map try { - DOP_ENU = arma::htrans(F)*Q_ECEF*F; + DOP_ENU = arma::htrans(F) * Q_ECEF * F; d_GDOP = sqrt(arma::trace(DOP_ENU)); // Geometric DOP d_PDOP = sqrt(DOP_ENU(0,0) + DOP_ENU(1,1) + DOP_ENU(2,2)); // PDOP d_HDOP = sqrt(DOP_ENU(0,0) + DOP_ENU(1,1)); // HDOP @@ -461,9 +461,9 @@ bool galileo_e1_ls_pvt::get_PVT(std::map gnss_pseudoranges_map d_avg_longitude_d = d_avg_longitude_d + d_hist_longitude_d.at(i); d_avg_height_m = d_avg_height_m + d_hist_height_m.at(i); } - d_avg_latitude_d = d_avg_latitude_d / (double)d_averaging_depth; - d_avg_longitude_d = d_avg_longitude_d / (double)d_averaging_depth; - d_avg_height_m = d_avg_height_m / (double)d_averaging_depth; + d_avg_latitude_d = d_avg_latitude_d / static_cast(d_averaging_depth); + d_avg_longitude_d = d_avg_longitude_d / static_cast(d_averaging_depth); + d_avg_height_m = d_avg_height_m / static_cast(d_averaging_depth); b_valid_position = true; return true; //indicates that the returned position is valid } @@ -514,9 +514,9 @@ void galileo_e1_ls_pvt::cart2geo(double X, double Y, double Z, int elipsoid_sele const double f[5] = {1/297, 1/298.247, 1/298.26, 1/298.257222101, 1/298.257223563}; double lambda = atan2(Y, X); - double ex2 = (2 - f[elipsoid_selection]) * f[elipsoid_selection] / ((1 - f[elipsoid_selection])*(1 - f[elipsoid_selection])); + double ex2 = (2 - f[elipsoid_selection]) * f[elipsoid_selection] / ((1 - f[elipsoid_selection]) * (1 - f[elipsoid_selection])); double c = a[elipsoid_selection] * sqrt(1+ex2); - double phi = atan(Z / ((sqrt(X*X + Y*Y)*(1 - (2 - f[elipsoid_selection])) * f[elipsoid_selection]))); + double phi = atan(Z / ((sqrt(X * X + Y * Y) * (1 - (2 - f[elipsoid_selection])) * f[elipsoid_selection]))); double h = 0.1; double oldh = 0; @@ -526,8 +526,8 @@ void galileo_e1_ls_pvt::cart2geo(double X, double Y, double Z, int elipsoid_sele { oldh = h; N = c / sqrt(1 + ex2 * (cos(phi) * cos(phi))); - phi = atan(Z / ((sqrt(X*X + Y*Y) * (1 - (2 - f[elipsoid_selection]) * f[elipsoid_selection] *N / (N + h) )))); - h = sqrt(X*X + Y*Y) / cos(phi) - N; + phi = atan(Z / ((sqrt(X * X + Y * Y) * (1 - (2 - f[elipsoid_selection]) * f[elipsoid_selection] * N / (N + h) )))); + h = sqrt(X * X + Y * Y) / cos(phi) - N; iterations = iterations + 1; if (iterations > 100) { @@ -582,7 +582,7 @@ void galileo_e1_ls_pvt::togeod(double *dphi, double *dlambda, double *h, double } // first guess - double P = sqrt(X*X + Y*Y); // P is distance from spin axis + double P = sqrt(X * X + Y * Y); // P is distance from spin axis //direct calculation of longitude if (P > 1.0E-20) @@ -600,7 +600,7 @@ void galileo_e1_ls_pvt::togeod(double *dphi, double *dlambda, double *h, double *dlambda = *dlambda + 360.0; } - double r = sqrt(P*P + Z*Z); // r is distance from origin (0,0,0) + double r = sqrt(P * P + Z * Z); // r is distance from origin (0,0,0) double sinphi; if (r > 1.0E-20) @@ -621,7 +621,7 @@ void galileo_e1_ls_pvt::togeod(double *dphi, double *dlambda, double *h, double return; } - *h = r - a*(1 - sinphi*sinphi/finv); + *h = r - a * (1 - sinphi * sinphi/finv); // iterate double cosphi; @@ -636,18 +636,18 @@ void galileo_e1_ls_pvt::togeod(double *dphi, double *dlambda, double *h, double cosphi = cos(*dphi); // compute radius of curvature in prime vertical direction - N_phi = a / sqrt(1 - esq*sinphi*sinphi); + N_phi = a / sqrt(1 - esq * sinphi * sinphi); // compute residuals in P and Z dP = P - (N_phi + (*h)) * cosphi; - dZ = Z - (N_phi*oneesq + (*h)) * sinphi; + dZ = Z - (N_phi * oneesq + (*h)) * sinphi; // update height and latitude - *h = *h + (sinphi*dZ + cosphi*dP); - *dphi = *dphi + (cosphi*dZ - sinphi*dP)/(N_phi + (*h)); + *h = *h + (sinphi * dZ + cosphi * dP); + *dphi = *dphi + (cosphi * dZ - sinphi * dP)/(N_phi + (*h)); // test for convergence - if ((dP*dP + dZ*dZ) < tolsq) + if ((dP * dP + dZ * dZ) < tolsq) { break; } @@ -693,12 +693,12 @@ void galileo_e1_ls_pvt::topocent(double *Az, double *El, double *D, arma::vec x, arma::mat F = arma::zeros(3,3); F(0,0) = -sl; - F(0,1) = -sb*cl; - F(0,2) = cb*cl; + F(0,1) = -sb * cl; + F(0,2) = cb * cl; F(1,0) = cl; - F(1,1) = -sb*sl; - F(1,2) = cb*sl; + F(1,1) = -sb * sl; + F(1,2) = cb * sl; F(2,0) = 0; F(2,1) = cb; @@ -713,7 +713,7 @@ void galileo_e1_ls_pvt::topocent(double *Az, double *El, double *D, arma::vec x, double U = local_vector(2); double hor_dis; - hor_dis = sqrt(E*E + N*N); + hor_dis = sqrt(E * E + N * N); if (hor_dis < 1.0E-20) { @@ -731,7 +731,7 @@ void galileo_e1_ls_pvt::topocent(double *Az, double *El, double *D, arma::vec x, *Az = *Az + 360.0; } - *D = sqrt(dx(0)*dx(0) + dx(1)*dx(1) + dx(2)*dx(2)); + *D = sqrt(dx(0) * dx(0) + dx(1) * dx(1) + dx(2) * dx(2)); } void galileo_e1_ls_pvt::tropo(double *ddr_m, double sinel, double hsta_km, double p_mb, double t_kel, double hum, double hp_km, double htkel_km, double hhum_km) @@ -764,7 +764,7 @@ void galileo_e1_ls_pvt::tropo(double *ddr_m, double sinel, double hsta_km, doubl const double em = -978.77 / (2.8704e6 * tlapse * 1.0e-5); double tkhum = t_kel + tlapse * (hhum_km - htkel_km); - double atkel = 7.5*(tkhum - 273.15) / (237.3 + tkhum - 273.15); + double atkel = 7.5 * (tkhum - 273.15) / (237.3 + tkhum - 273.15); double e0 = 0.0611 * hum * pow(10, atkel); double tksea = t_kel - tlapse * htkel_km; double tkelh = tksea + tlapse * hhum_km; diff --git a/src/algorithms/PVT/libs/gps_l1_ca_ls_pvt.cc b/src/algorithms/PVT/libs/gps_l1_ca_ls_pvt.cc index 748039516..1568a7938 100644 --- a/src/algorithms/PVT/libs/gps_l1_ca_ls_pvt.cc +++ b/src/algorithms/PVT/libs/gps_l1_ca_ls_pvt.cc @@ -332,7 +332,7 @@ bool gps_l1_ca_ls_pvt::get_PVT(std::map gnss_pseudoranges_map, } // Compute UTC time and print PVT solution double secondsperweek = 604800.0; // number of seconds in one week (7*24*60*60) - boost::posix_time::time_duration t = boost::posix_time::seconds(utc + secondsperweek*(double)GPS_week); + boost::posix_time::time_duration t = boost::posix_time::seconds(utc + secondsperweek * static_cast(GPS_week)); // 22 August 1999 last GPS time roll over boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); d_position_UTC_time = p_time; @@ -441,9 +441,9 @@ bool gps_l1_ca_ls_pvt::get_PVT(std::map gnss_pseudoranges_map, d_avg_longitude_d = d_avg_longitude_d + d_hist_longitude_d.at(i); d_avg_height_m = d_avg_height_m + d_hist_height_m.at(i); } - d_avg_latitude_d = d_avg_latitude_d / (double)d_averaging_depth; - d_avg_longitude_d = d_avg_longitude_d / (double)d_averaging_depth; - d_avg_height_m = d_avg_height_m / (double)d_averaging_depth; + d_avg_latitude_d = d_avg_latitude_d / static_cast(d_averaging_depth); + d_avg_longitude_d = d_avg_longitude_d / static_cast(d_averaging_depth); + d_avg_height_m = d_avg_height_m / static_cast(d_averaging_depth); b_valid_position = true; return true; //indicates that the returned position is valid } diff --git a/src/algorithms/PVT/libs/hybrid_ls_pvt.cc b/src/algorithms/PVT/libs/hybrid_ls_pvt.cc index 1be7c15ea..7c0981600 100644 --- a/src/algorithms/PVT/libs/hybrid_ls_pvt.cc +++ b/src/algorithms/PVT/libs/hybrid_ls_pvt.cc @@ -416,7 +416,7 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_pseudoranges_map, do d_position_UTC_time = p_time; LOG(INFO) << "HYBRID Position at TOW=" << hybrid_current_time << " in ECEF (X,Y,Z) = " << mypos; - cart2geo((double)mypos(0), (double)mypos(1), (double)mypos(2), 4); + cart2geo(static_cast(mypos(0)), static_cast(mypos(1)), static_cast(mypos(2)), 4); //ToDo: Find an Observables/PVT random bug with some satellite configurations that gives an erratic PVT solution (i.e. height>50 km) if (d_height_m > 50000) { @@ -535,9 +535,9 @@ bool hybrid_ls_pvt::get_PVT(std::map gnss_pseudoranges_map, do d_avg_longitude_d = d_avg_longitude_d + d_hist_longitude_d.at(i); d_avg_height_m = d_avg_height_m + d_hist_height_m.at(i); } - d_avg_latitude_d = d_avg_latitude_d / (double)d_averaging_depth; - d_avg_longitude_d = d_avg_longitude_d / (double)d_averaging_depth; - d_avg_height_m = d_avg_height_m / (double)d_averaging_depth; + d_avg_latitude_d = d_avg_latitude_d / static_cast(d_averaging_depth); + d_avg_longitude_d = d_avg_longitude_d / static_cast(d_averaging_depth); + d_avg_height_m = d_avg_height_m / static_cast(d_averaging_depth); b_valid_position = true; return true; //indicates that the returned position is valid } diff --git a/src/algorithms/PVT/libs/nmea_printer.cc b/src/algorithms/PVT/libs/nmea_printer.cc index 2cbc9d15c..2d96ab54c 100644 --- a/src/algorithms/PVT/libs/nmea_printer.cc +++ b/src/algorithms/PVT/libs/nmea_printer.cc @@ -222,8 +222,8 @@ std::string Nmea_Printer::latitude_to_hm(double lat) north = true; } - int deg = (int)lat; - double mins = lat - (double)deg; + int deg = static_cast(lat); + double mins = lat - static_cast(deg); mins *= 60.0 ; std::ostringstream out_string; out_string.setf(std::ios::fixed, std::ios::floatfield); @@ -271,7 +271,7 @@ std::string Nmea_Printer::longitude_to_hm(double longitude) out_string.precision(4); out_string << mins; - if (east==true) + if (east == true) { out_string << ",E"; } @@ -361,7 +361,7 @@ std::string Nmea_Printer::get_GPRMC() sentence_str << ",V"; }; - if (d_PVT_data->d_flag_averaging==true) + if (d_PVT_data->d_flag_averaging == true) { // Latitude ddmm.mmmm,(N or S) sentence_str << "," << latitude_to_hm(d_PVT_data->d_avg_latitude_d); diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc index 42529eb6d..61a210034 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc @@ -268,7 +268,7 @@ float GalileoE1Pcps8msAmbiguousAcquisition::calculate_threshold(float pfa) DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; unsigned int ncells = vector_length_*frequency_bins; - double exponent = 1/(double)ncells; + double exponent = 1 / static_cast(ncells); double val = pow(1.0 - pfa,exponent); double lambda = double(vector_length_); boost::math::exponential_distribution mydist (lambda); diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc index 3bc22a8de..7ec3bb266 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc @@ -277,9 +277,9 @@ float GalileoE1PcpsAmbiguousAcquisition::calculate_threshold(float pfa) DLOG(INFO) <<"Channel "<(sampled_ms_ / 4); int samples_per_ms = code_length_ / 4; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc index 9e2e384e8..b5645c2a6 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc @@ -305,7 +305,7 @@ float GalileoE1PcpsQuickSyncAmbiguousAcquisition::calculate_threshold(float pfa) DLOG(INFO) <<"Channel "<(abs(doppler_index - i))); } // d_CAF_vector[doppler_index] /= CAF_bins_half+doppler_index+1; - d_CAF_vector[doppler_index] /= 1+CAF_bins_half+doppler_index - weighting_factor*CAF_bins_half*(CAF_bins_half+1)/2 - weighting_factor*doppler_index*(doppler_index+1)/2; // triangles = [n*(n+1)/2] + d_CAF_vector[doppler_index] /= 1 + CAF_bins_half+doppler_index - weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2 - weighting_factor*doppler_index*(doppler_index+1)/2; // triangles = [n*(n+1)/2] if (d_both_signal_components) { accum[0] = 0; // volk_32f_accumulator_s32f_a(&accum[0], d_CAF_vector_Q, CAF_bins_half+doppler_index+1); for (int i = 0; i < CAF_bins_half+doppler_index+1; i++) { - accum[0] += d_CAF_vector_Q[i] * (1-weighting_factor*(unsigned int)(abs(doppler_index - i))); + accum[0] += d_CAF_vector_Q[i] * (1 - weighting_factor * static_cast(abs(doppler_index - i))); } // accum[0] /= CAF_bins_half+doppler_index+1; - accum[0] /= 1+CAF_bins_half+doppler_index - weighting_factor*CAF_bins_half*(CAF_bins_half+1)/2 - weighting_factor*doppler_index*(doppler_index+1)/2; // triangles = [n*(n+1)/2] + accum[0] /= 1+CAF_bins_half+doppler_index - weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2 - weighting_factor * doppler_index * (doppler_index + 1) / 2; // triangles = [n*(n+1)/2] d_CAF_vector[doppler_index] += accum[0]; } } // Body loop - for (unsigned int doppler_index=CAF_bins_half;doppler_index(abs(doppler_index - i))); } // d_CAF_vector[doppler_index] /= 2*CAF_bins_half+1; - d_CAF_vector[doppler_index] /= 1+2*CAF_bins_half - 2*weighting_factor*CAF_bins_half*(CAF_bins_half+1)/2; + d_CAF_vector[doppler_index] /= 1 + 2 * CAF_bins_half - 2 *weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2; if (d_both_signal_components) { accum[0] = 0; // volk_32f_accumulator_s32f_a(&accum[0], &d_CAF_vector_Q[doppler_index-CAF_bins_half], 2*CAF_bins_half); for (int i = doppler_index-CAF_bins_half; i < doppler_index+CAF_bins_half+1; i++) { - accum[0] += d_CAF_vector_Q[i] * (1-weighting_factor*(unsigned int)(abs(doppler_index - i))); + accum[0] += d_CAF_vector_Q[i] * (1 -weighting_factor * static_cast(abs(doppler_index - i))); } // accum[0] /= 2*CAF_bins_half+1; - accum[0] /= 1+2*CAF_bins_half - 2*weighting_factor*CAF_bins_half*(CAF_bins_half+1)/2; + accum[0] /= 1+2*CAF_bins_half - 2*weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2; d_CAF_vector[doppler_index] += accum[0]; } } // Final iterations - for (unsigned int doppler_index=d_num_doppler_bins-CAF_bins_half;doppler_indexAcq_doppler_hz = (double)doppler; + doppler = -static_cast(d_doppler_max) + d_doppler_step * indext; + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); // Dump if required, appended at the end of the file if (d_dump) { diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc index a5ae138da..84db27e13 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc @@ -149,8 +149,8 @@ void galileo_pcps_8ms_acquisition_cc::init() // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = (int)(-d_doppler_max); - doppler <= (int)d_doppler_max; + for (int doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -161,9 +161,8 @@ void galileo_pcps_8ms_acquisition_cc::init() for (unsigned int doppler_index=0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); - int doppler = -(int)d_doppler_max + d_doppler_step*doppler_index; - complex_exp_gen_conj(d_grid_doppler_wipeoffs[doppler_index], - d_freq + doppler, d_fs_in, d_fft_size); + int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + complex_exp_gen_conj(d_grid_doppler_wipeoffs[doppler_index], d_freq + doppler, d_fs_in, d_fft_size); } } @@ -209,7 +208,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, float magt_A = 0.0; float magt_B = 0.0; const gr_complex *in = (const gr_complex *)input_items[0]; //Get the input samples pointer - float fft_normalization_factor = (float)d_fft_size * (float)d_fft_size; + float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); d_input_power = 0.0; d_mag = 0.0; @@ -226,14 +225,14 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size); volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size); - d_input_power /= (float)d_fft_size; + d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -(int)d_doppler_max + d_doppler_step*doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); @@ -290,8 +289,8 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, if (d_mag < magt) { d_mag = magt; - d_gnss_synchro->Acq_delay_samples = (double)(indext % d_samples_per_code); - d_gnss_synchro->Acq_doppler_hz = (double)doppler; + d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc index 4e542f8fa..85a32af4e 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc @@ -140,8 +140,8 @@ void pcps_acquisition_cc::init() // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = (int)(-d_doppler_max); - doppler <= (int)d_doppler_max; + for (int doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -153,7 +153,7 @@ void pcps_acquisition_cc::init() for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); - int doppler = -(int)d_doppler_max + d_doppler_step * doppler_index; + int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; complex_exp_gen_conj(d_grid_doppler_wipeoffs[doppler_index], d_freq + doppler, d_fs_in, d_fft_size); } } @@ -206,7 +206,7 @@ int pcps_acquisition_cc::general_work(int noutput_items, unsigned int indext = 0; float magt = 0.0; const gr_complex *in = (const gr_complex *)input_items[0]; //Get the input samples pointer - float fft_normalization_factor = (float)d_fft_size * (float)d_fft_size; + float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); d_input_power = 0.0; d_mag = 0.0; @@ -223,14 +223,14 @@ int pcps_acquisition_cc::general_work(int noutput_items, // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size); volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size); - d_input_power /= (float)d_fft_size; + d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop for (unsigned int doppler_index=0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -(int)d_doppler_max + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); @@ -268,8 +268,8 @@ int pcps_acquisition_cc::general_work(int noutput_items, // restarted between consecutive dwells in multidwell operation. if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag) { - d_gnss_synchro->Acq_delay_samples = (double)(indext % d_samples_per_code); - d_gnss_synchro->Acq_doppler_hz = (double)doppler; + d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // 5- Compute the test statistics and compare to the threshold diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index 912ca1b00..d6fe92227 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -187,7 +187,7 @@ void pcps_acquisition_fine_doppler_cc::update_carrier_wipeoff() doppler_hz = d_config_doppler_min + d_doppler_step*doppler_index; // doppler search steps // compute the carrier doppler wipe-off signal and store it - phase_step_rad = (float)GPS_TWO_PI*doppler_hz / (float)d_fs_in; + phase_step_rad = static_cast(GPS_TWO_PI) * doppler_hz / static_cast(d_fs_in); d_grid_doppler_wipeoffs[doppler_index] = new gr_complex[d_fft_size]; fxp_nco(d_grid_doppler_wipeoffs[doppler_index], d_fft_size,0, phase_step_rad); } @@ -214,15 +214,15 @@ double pcps_acquisition_fine_doppler_cc::search_maximum() } // Normalize the maximum value to correct the scale factor introduced by FFTW - fft_normalization_factor = (float)d_fft_size * (float)d_fft_size;; + fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); magt = magt / (fft_normalization_factor * fft_normalization_factor); // 5- Compute the test statistics and compare to the threshold d_test_statistics = magt/(d_input_power*std::sqrt(d_well_count)); // 4- record the maximum peak and the associated synchronization parameters - d_gnss_synchro->Acq_delay_samples = (double)index_time; - d_gnss_synchro->Acq_doppler_hz = (double)(index_doppler * d_doppler_step + d_config_doppler_min); + d_gnss_synchro->Acq_delay_samples = static_cast(index_time); + d_gnss_synchro->Acq_doppler_hz = static_cast(index_doppler * d_doppler_step + d_config_doppler_min); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // Record results to file if required @@ -250,7 +250,7 @@ float pcps_acquisition_fine_doppler_cc::estimate_input_power(gr_vector_const_voi float power = 0; volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size); volk_32f_accumulator_s32f(&power, d_magnitude, d_fft_size); - power /= (float)d_fft_size; + power /= static_cast(d_fft_size); return power; } @@ -305,6 +305,7 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star int zero_padding_factor = 16; int fft_size_extended = d_fft_size * zero_padding_factor; gr::fft::fft_complex *fft_operator = new gr::fft::fft_complex(fft_size_extended, true); + //zero padding the entire vector memset(fft_operator->get_inbuf(), 0, fft_size_extended * sizeof(gr_complex)); @@ -313,9 +314,8 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star gps_l1_ca_code_gen_complex_sampled(code_replica, d_gnss_synchro->PRN, d_fs_in, 0); - int shift_index = (int)d_gnss_synchro->Acq_delay_samples; + int shift_index = static_cast(d_gnss_synchro->Acq_delay_samples); - //std::cout<<"shift_index="<get_outbuf(), fft_size_extended); unsigned int tmp_index_freq = 0; - volk_32f_index_max_16u(&tmp_index_freq,p_tmp_vector,fft_size_extended); - - //std::cout<<"FFT maximum index present at "<(d_fs_in) / 2.0) * static_cast(k)) / (static_cast(fft_size_extended) / 2.0); counter++; } for (int k = fft_size_extended / 2; k > 0; k--) { - fftFreqBins[counter] = ((-(float)d_fs_in / 2) * (float)k) / ((float)fft_size_extended / 2.0); + fftFreqBins[counter] = ((-static_cast(d_fs_in) / 2) * static_cast(k)) / (static_cast(fft_size_extended) / 2.0); counter++; } // 5. Update the Doppler estimation in Hz if (abs(fftFreqBins[tmp_index_freq] - d_gnss_synchro->Acq_doppler_hz) < 1000) { - d_gnss_synchro->Acq_doppler_hz = (double)fftFreqBins[tmp_index_freq]; + d_gnss_synchro->Acq_doppler_hz = static_cast(fftFreqBins[tmp_index_freq]); //std::cout<<"FFT maximum present at "<(GPS_TWO_PI) * doppler_hz / static_cast(d_fs_in); d_grid_doppler_wipeoffs[doppler_index] = new gr_complex[d_fft_size]; fxp_nco(d_grid_doppler_wipeoffs[doppler_index], d_fft_size, 0, phase_step_rad); } @@ -258,15 +258,15 @@ double pcps_assisted_acquisition_cc::search_maximum() } // Normalize the maximum value to correct the scale factor introduced by FFTW - fft_normalization_factor = (float)d_fft_size * (float)d_fft_size; + fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); magt = magt / (fft_normalization_factor * fft_normalization_factor); // 5- Compute the test statistics and compare to the threshold - d_test_statistics = 2 * d_fft_size * magt /(d_input_power*d_well_count); + d_test_statistics = 2 * d_fft_size * magt / (d_input_power * d_well_count); // 4- record the maximum peak and the associated synchronization parameters - d_gnss_synchro->Acq_delay_samples = (double)index_time; - d_gnss_synchro->Acq_doppler_hz = (double)(index_doppler*d_doppler_step + d_doppler_min); + d_gnss_synchro->Acq_delay_samples = static_cast(index_time); + d_gnss_synchro->Acq_doppler_hz = static_cast(index_doppler * d_doppler_step + d_doppler_min); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // Record results to file if required @@ -300,7 +300,7 @@ float pcps_assisted_acquisition_cc::estimate_input_power(gr_vector_const_void_st float power; volk_32f_accumulator_s32f(&power, p_const_tmp_vector, d_fft_size); volk_free(p_tmp_vector); - return ( power / (float)d_fft_size); + return ( power / static_cast(d_fft_size)); } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc index 0c5f69a7a..21cd1b75d 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc @@ -137,7 +137,7 @@ void pcps_cccwsr_acquisition_cc::set_local_code(std::complex* code_data, std::complex* code_pilot) { // Data code (E1B) - memcpy(d_fft_if->get_inbuf(), code_data, sizeof(gr_complex)*d_fft_size); + memcpy(d_fft_if->get_inbuf(), code_data, sizeof(gr_complex) * d_fft_size); d_fft_if->execute(); // We need the FFT of local code @@ -145,12 +145,12 @@ void pcps_cccwsr_acquisition_cc::set_local_code(std::complex* code_data, volk_32fc_conjugate_32fc(d_fft_code_data,d_fft_if->get_outbuf(),d_fft_size); // Pilot code (E1C) - memcpy(d_fft_if->get_inbuf(), code_pilot, sizeof(gr_complex)*d_fft_size); + memcpy(d_fft_if->get_inbuf(), code_pilot, sizeof(gr_complex) * d_fft_size); d_fft_if->execute(); // We need the FFT of local code //Conjugate the local code, - volk_32fc_conjugate_32fc(d_fft_code_pilot,d_fft_if->get_outbuf(),d_fft_size); + volk_32fc_conjugate_32fc(d_fft_code_pilot, d_fft_if->get_outbuf(), d_fft_size); } void pcps_cccwsr_acquisition_cc::init() @@ -163,8 +163,8 @@ void pcps_cccwsr_acquisition_cc::init() // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = (int)(-d_doppler_max); - doppler <= (int)d_doppler_max; + for (int doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -176,7 +176,7 @@ void pcps_cccwsr_acquisition_cc::init() { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); - int doppler = -(int)d_doppler_max + d_doppler_step * doppler_index; + int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; complex_exp_gen_conj(d_grid_doppler_wipeoffs[doppler_index], d_freq + doppler, d_fs_in, d_fft_size); } @@ -223,7 +223,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, float magt_plus = 0.0; float magt_minus = 0.0; const gr_complex *in = (const gr_complex *)input_items[0]; //Get the input samples pointer - float fft_normalization_factor = (float)d_fft_size * (float)d_fft_size; + float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); d_sample_counter += d_fft_size; // sample counter @@ -238,14 +238,14 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size); volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size); - d_input_power /= (float)d_fft_size; + d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -(int)d_doppler_max + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); @@ -314,8 +314,8 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, if (d_mag < magt) { d_mag = magt; - d_gnss_synchro->Acq_delay_samples = (double)(indext % d_samples_per_code); - d_gnss_synchro->Acq_doppler_hz = (double)doppler; + d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc index 0f0e72a3b..b39c2abe3 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc @@ -105,7 +105,7 @@ pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc( d_well_count = 0; d_doppler_max = doppler_max; d_fft_size = d_sampled_ms * d_samples_per_ms; - d_fft_size_pow2 = pow(2, ceil(log2(2*d_fft_size))); + d_fft_size_pow2 = pow(2, ceil(log2(2 * d_fft_size))); d_mag = 0; d_input_power = 0.0; d_num_doppler_bins = 0; @@ -298,8 +298,8 @@ void pcps_opencl_acquisition_cc::init() // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = (int)(-d_doppler_max); - doppler <= (int)d_doppler_max; + for (int doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -316,7 +316,7 @@ void pcps_opencl_acquisition_cc::init() { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); - int doppler= -(int)d_doppler_max + d_doppler_step * doppler_index; + int doppler= -static_cast(d_doppler_max) + d_doppler_step * doppler_index; complex_exp_gen_conj(d_grid_doppler_wipeoffs[doppler_index], d_freq + doppler, d_fs_in, d_fft_size); @@ -381,7 +381,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() int doppler; unsigned int indext = 0; float magt = 0.0; - float fft_normalization_factor = (float)d_fft_size * (float)d_fft_size; + float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); gr_complex* in = d_in_buffer[d_well_count]; unsigned long int samplestamp = d_sample_counter_buffer[d_well_count]; @@ -399,13 +399,13 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size); volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size); - d_input_power /= (float)d_fft_size; + d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -(int)d_doppler_max + d_doppler_step*doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); @@ -443,8 +443,8 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() // restarted between consecutive dwells in multidwell operation. if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag) { - d_gnss_synchro->Acq_delay_samples = (double)(indext % d_samples_per_code); - d_gnss_synchro->Acq_doppler_hz = (double)doppler; + d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = samplestamp; // 5- Compute the test statistics and compare to the threshold @@ -503,7 +503,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() int doppler; unsigned int indext = 0; float magt = 0.0; - float fft_normalization_factor = ((float)d_fft_size_pow2 * (float)d_fft_size); //This works, but I am not sure why. + float fft_normalization_factor = (static_cast(d_fft_size_pow2) * static_cast(d_fft_size)); //This works, but I am not sure why. gr_complex* in = d_in_buffer[d_well_count]; unsigned long int samplestamp = d_sample_counter_buffer[d_well_count]; @@ -531,7 +531,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size); volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size); - d_input_power /= (float)d_fft_size; + d_input_power /= static_cast(d_fft_size); cl::Kernel kernel; @@ -540,7 +540,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() { // doppler search steps - doppler = -(int)d_doppler_max + d_doppler_step*doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step*doppler_index; //Multiply input signal with doppler wipe-off kernel = cl::Kernel(d_cl_program, "mult_vectors"); @@ -605,8 +605,8 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() // restarted between consecutive dwells in multidwell operation. if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag) { - d_gnss_synchro->Acq_delay_samples = (double)(indext % d_samples_per_code); - d_gnss_synchro->Acq_doppler_hz = (double)doppler; + d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = samplestamp; // 5- Compute the test statistics and compare to the threshold @@ -702,7 +702,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items, // Fill internal buffer with d_max_dwells signal blocks. This step ensures that // consecutive signal blocks will be processed in multi-dwell operation. This is // essential when d_bit_transition_flag = true. - unsigned int num_dwells = std::min((int)(d_max_dwells-d_in_dwell_count), ninput_items[0]); + unsigned int num_dwells = std::min(static_cast(d_max_dwells-d_in_dwell_count), ninput_items[0]); for (unsigned int i = 0; i < num_dwells; i++) { memcpy(d_in_buffer[d_in_dwell_count++], (gr_complex*)input_items[i], @@ -711,7 +711,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items, d_sample_counter_buffer.push_back(d_sample_counter); } - if (ninput_items[0] > (int)num_dwells) + if (ninput_items[0] > static_cast(num_dwells)) { d_sample_counter += d_fft_size * (ninput_items[0] - num_dwells); } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc index 0c2626f7a..a2738cfd2 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc @@ -187,8 +187,8 @@ void pcps_quicksync_acquisition_cc::init() // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = (int)(-d_doppler_max); - doppler <= (int)(d_doppler_max); + for (int doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -199,7 +199,7 @@ void pcps_quicksync_acquisition_cc::init() for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_malloc(d_samples_per_code * d_folding_factor * sizeof(gr_complex), volk_get_alignment())); - int doppler = -(int)d_doppler_max + d_doppler_step * doppler_index; + int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; complex_exp_gen_conj(d_grid_doppler_wipeoffs[doppler_index], d_freq + doppler, d_fs_in, d_samples_per_code * d_folding_factor); @@ -273,7 +273,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, /*Stores a copy of the folded version of the signal.This is used for the FFT operations in future steps of excecution*/ // gr_complex in_folded[d_fft_size]; - float fft_normalization_factor = (float)d_fft_size * (float)d_fft_size; + float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); d_input_power = 0.0; d_mag = 0.0; @@ -299,7 +299,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, being performed in a signal of size nxp */ volk_32fc_magnitude_squared_32f(d_magnitude, in, d_samples_per_code * d_folding_factor); volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_samples_per_code * d_folding_factor); - d_input_power /= (float)(d_samples_per_code * d_folding_factor); + d_input_power /= static_cast(d_samples_per_code * d_folding_factor); for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { @@ -312,7 +312,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, /*Doppler search steps and then multiplication of the incoming signal with the doppler wipeoffs to eliminate frequency offset */ - doppler = -(int)d_doppler_max + d_doppler_step*doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; /*Perform multiplication of the incoming signal with the complex exponential vector. This removes the frequency doppler @@ -324,7 +324,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, /*Perform folding of the carrier wiped-off incoming signal. Since superlinear method is being used the folding factor in the incoming raw data signal is of d_folding_factor^2*/ - for ( int i = 0; i < (int)(d_folding_factor*d_folding_factor); i++) + for ( int i = 0; i < static_cast(d_folding_factor * d_folding_factor); i++) { std::transform ((in_temp + i * d_fft_size), (in_temp + ((i + 1) * d_fft_size)) , @@ -357,7 +357,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, // (1 / (fft_normalization_factor * fft_normalization_factor)), d_fft_size); volk_32f_index_max_16u(&indext, d_magnitude_folded, d_fft_size); - magt = d_magnitude_folded[indext]/ (fft_normalization_factor * fft_normalization_factor); + magt = d_magnitude_folded[indext] / (fft_normalization_factor * fft_normalization_factor); delete d_signal_folded; @@ -380,26 +380,25 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, gr_complex complex_acumulator[100]; //gr_complex complex_acumulator[d_folding_factor]; - for (int i = 0; i < (int)d_folding_factor; i++) + for (int i = 0; i < static_cast(d_folding_factor); i++) { - d_possible_delay[i] = detected_delay_samples_folded + (i)*d_fft_size; + d_possible_delay[i] = detected_delay_samples_folded + (i) * d_fft_size; } - for ( int i = 0; i < (int)d_folding_factor; i++) + for ( int i = 0; i < static_cast(d_folding_factor); i++) { /*Copy a signal of 1 code length into suggested buffer. The copied signal must have doppler effect corrected*/ memcpy(in_1code,&in_temp[d_possible_delay[i]], - sizeof(gr_complex)*(d_samples_per_code)); + sizeof(gr_complex) * (d_samples_per_code)); /*Perform multiplication of the unmodified local generated code with the incoming signal with doppler effect corrected and accumulates its value. This is indeed correlation in time for an specific value of a shift*/ - volk_32fc_x2_multiply_32fc(corr_output, in_1code, - d_code, d_samples_per_code); + volk_32fc_x2_multiply_32fc(corr_output, in_1code, d_code, d_samples_per_code); for(int j = 0; j < d_samples_per_code; j++) { @@ -412,8 +411,8 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, volk_32f_index_max_16u(&indext, d_corr_output_f, d_folding_factor); /*Now save the real code phase in the gnss_syncro block for use in other stages*/ - d_gnss_synchro->Acq_delay_samples = (double)(d_possible_delay[indext]); - d_gnss_synchro->Acq_doppler_hz = (double)doppler; + d_gnss_synchro->Acq_delay_samples = static_cast(d_possible_delay[indext]); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; /* 5- Compute the test statistics and compare to the threshold d_test_statistics = 2 * d_fft_size * d_mag / d_input_power;*/ @@ -487,8 +486,8 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "test statistics value " << d_test_statistics; DLOG(INFO) << "test statistics threshold " << d_threshold; DLOG(INFO) << "folding factor " << d_folding_factor; - DLOG(INFO) << "possible delay correlation output"; - for (int i = 0; i < (int)d_folding_factor; i++) DLOG(INFO) << d_possible_delay[i] <<"\t\t\t"<(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; DLOG(INFO) << "magnitude folded " << d_mag; @@ -517,7 +516,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "test statistics threshold " << d_threshold; DLOG(INFO) << "folding factor "<(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; DLOG(INFO) << "magnitude folded " << d_mag; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc index 99e9b44e2..3fe7da27d 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc @@ -158,8 +158,8 @@ void pcps_tong_acquisition_cc::init() // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = (int)(-d_doppler_max); - doppler <= (int)d_doppler_max; + for (int doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -172,7 +172,7 @@ void pcps_tong_acquisition_cc::init() { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); - int doppler = -(int)d_doppler_max + d_doppler_step * doppler_index; + int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; complex_exp_gen_conj(d_grid_doppler_wipeoffs[doppler_index], d_freq + doppler, d_fs_in, d_fft_size); @@ -232,7 +232,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, unsigned int indext = 0; float magt = 0.0; const gr_complex *in = (const gr_complex *)input_items[0]; //Get the input samples pointer - float fft_normalization_factor = (float)d_fft_size * (float)d_fft_size; + float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); d_input_power = 0.0; d_mag = 0.0; @@ -249,14 +249,14 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size); volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size); - d_input_power /= (float)d_fft_size; + d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -(int)d_doppler_max + d_doppler_step*doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); @@ -293,8 +293,8 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, if (d_mag < magt) { d_mag = magt; - d_gnss_synchro->Acq_delay_samples = (double)(indext % d_samples_per_code); - d_gnss_synchro->Acq_doppler_hz = (double)doppler; + d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc index a0881602b..5628c9dcc 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc @@ -456,7 +456,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items, gr_vector { d_CRC_error_counter = 0; d_flag_preamble = true; //valid preamble indicator (initialized to false every work()) - d_preamble_time_seconds = in[0][0].Tracking_timestamp_secs - ((double)(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); //record the PRN start sample index associated to the preamble start. + d_preamble_time_seconds = in[0][0].Tracking_timestamp_secs - (static_cast(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); //record the PRN start sample index associated to the preamble start. if (!d_flag_frame_sync) { d_flag_frame_sync = true; @@ -505,25 +505,25 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items, gr_vector if (d_nav.flag_TOW_1 == true) { d_TOW_at_Preamble = d_nav.FNAV_TOW_1; - d_TOW_at_current_symbol = d_TOW_at_Preamble + ((double)(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); + d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); d_nav.flag_TOW_1 = false; } if (d_nav.flag_TOW_2 == true) { d_TOW_at_Preamble = d_nav.FNAV_TOW_2; - d_TOW_at_current_symbol = d_TOW_at_Preamble + ((double)(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); + d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); d_nav.flag_TOW_2 = false; } if (d_nav.flag_TOW_3 == true) { d_TOW_at_Preamble = d_nav.FNAV_TOW_3; - d_TOW_at_current_symbol = d_TOW_at_Preamble + ((double)(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); + d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); d_nav.flag_TOW_3 = false; } if (d_nav.flag_TOW_4 == true) { d_TOW_at_Preamble = d_nav.FNAV_TOW_4; - d_TOW_at_current_symbol = d_TOW_at_Preamble + ((double)(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); + d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); d_nav.flag_TOW_4 = false; } else diff --git a/src/core/system_parameters/galileo_utc_model.cc b/src/core/system_parameters/galileo_utc_model.cc index 807d96e89..06d97d789 100644 --- a/src/core/system_parameters/galileo_utc_model.cc +++ b/src/core/system_parameters/galileo_utc_model.cc @@ -67,7 +67,7 @@ double Galileo_Utc_Model::GST_to_UTC_time(double t_e, int WN) * the GST/Utc relationship is given by */ //std::cout<<"GST->UTC case a"<((WN % 256) - WNot_6)); t_Utc_daytime = fmod(t_e - Delta_t_Utc, 86400); } else @@ -78,7 +78,7 @@ double Galileo_Utc_Model::GST_to_UTC_time(double t_e, int WN) * the effective time is computed according to the following equations: */ //std::cout<<"GST->UTC case b"<((WN % 256) - WNot_6)); double W = fmod(t_e - Delta_t_Utc - 43200, 86400) + 43200; t_Utc_daytime = fmod(W, 86400 + Delta_tLSF_6 - Delta_tLS_6); //implement something to handle a leap second event! @@ -94,7 +94,7 @@ double Galileo_Utc_Model::GST_to_UTC_time(double t_e, int WN) * the following equation: */ //std::cout<<"GST->UTC case c"<((WN % 256) - WNot_6)); t_Utc_daytime = fmod(t_e - Delta_t_Utc, 86400); } diff --git a/src/core/system_parameters/gps_utc_model.cc b/src/core/system_parameters/gps_utc_model.cc index 3c82a1f87..5624f939e 100644 --- a/src/core/system_parameters/gps_utc_model.cc +++ b/src/core/system_parameters/gps_utc_model.cc @@ -47,7 +47,7 @@ double Gps_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) { double t_utc; double t_utc_daytime; - double Delta_t_UTC = d_DeltaT_LS + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * (double)(i_GPS_week - i_WN_T)); + double Delta_t_UTC = d_DeltaT_LS + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); // Determine if the effectivity time of the leap second event is in the past int weeksToLeapSecondEvent = i_WN_LSF - i_GPS_week; @@ -87,7 +87,7 @@ double Gps_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) } if ( (gpstime_corrected - secondOfLeapSecondEvent) > 21600) { - Delta_t_UTC = d_DeltaT_LSF + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800*(double)(i_GPS_week - i_WN_T)); + Delta_t_UTC = d_DeltaT_LSF + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); } } @@ -99,7 +99,7 @@ double Gps_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) * WNLSF and DN values, is in the "past" (relative to the user's current time), * and the user�s current time does not fall in the time span as given above * in 20.3.3.5.2.4b,*/ - Delta_t_UTC = d_DeltaT_LSF + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * (double)(i_GPS_week - i_WN_T)); + Delta_t_UTC = d_DeltaT_LSF + d_A0 + d_A1 * (gpstime_corrected - d_t_OT + 604800 * static_cast(i_GPS_week - i_WN_T)); t_utc_daytime = fmod(gpstime_corrected - Delta_t_UTC, 86400); } diff --git a/src/main/main.cc b/src/main/main.cc index d3a89024f..4aff582a8 100644 --- a/src/main/main.cc +++ b/src/main/main.cc @@ -178,7 +178,7 @@ int main(int argc, char** argv) gettimeofday(&tv, NULL); long long int end = tv.tv_sec * 1000000 + tv.tv_usec; std::cout << "Total GNSS-SDR run time " - << ((double)(end - begin))/1000000.0 + << (static_cast(end - begin)) / 1000000.0 << " [seconds]" << std::endl; google::ShutDownCommandLineFlags();