1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 20:20:35 +00:00

Replace C-style casts by C++ casts

This commit is contained in:
Carles Fernandez 2017-08-19 12:45:19 +02:00
parent 64ab909a0d
commit d12858e579
5 changed files with 77 additions and 59 deletions

View File

@ -34,16 +34,15 @@ bool observables_dump_reader::read_binary_obs()
{
try
{
for(int i=0;i<n_channels;i++)
for(int i = 0; i < n_channels; i++)
{
d_dump_file.read((char *) &RX_time[i], sizeof(double));
d_dump_file.read((char *) &TOW_at_current_symbol_s[i], sizeof(double));
d_dump_file.read((char *) &Carrier_Doppler_hz[i], sizeof(double));
d_dump_file.read((char *) &Acc_carrier_phase_hz[i], sizeof(double));
d_dump_file.read((char *) &Pseudorange_m[i], sizeof(double));
d_dump_file.read((char *) &PRN[i], sizeof(double));
d_dump_file.read((char *) &valid[i], sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&RX_time[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol_s[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&Carrier_Doppler_hz[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&Acc_carrier_phase_hz[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&Pseudorange_m[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&PRN[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&valid[i]), sizeof(double));
}
}
catch (const std::ifstream::failure &e)
@ -53,6 +52,7 @@ bool observables_dump_reader::read_binary_obs()
return true;
}
bool observables_dump_reader::restart()
{
if (d_dump_file.is_open())
@ -67,10 +67,11 @@ bool observables_dump_reader::restart()
}
}
long int observables_dump_reader::num_epochs()
{
std::ifstream::pos_type size;
int number_of_vars_in_epoch = n_channels*7;
int number_of_vars_in_epoch = n_channels * 7;
int epoch_size_bytes = sizeof(double) * number_of_vars_in_epoch;
std::ifstream tmpfile( d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
if (tmpfile.is_open())
@ -85,14 +86,15 @@ long int observables_dump_reader::num_epochs()
}
}
bool observables_dump_reader::open_obs_file(std::string out_file)
{
if (d_dump_file.is_open() == false)
{
try
{
d_dump_filename=out_file;
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
d_dump_filename = out_file;
d_dump_file.exceptions( std::ifstream::failbit | std::ifstream::badbit );
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "Observables sum file opened, Log file: " << d_dump_filename.c_str() << std::endl;
return true;
@ -109,17 +111,20 @@ bool observables_dump_reader::open_obs_file(std::string out_file)
}
}
observables_dump_reader::observables_dump_reader(int n_channels_)
{
n_channels=n_channels_;
RX_time=new double[n_channels];
TOW_at_current_symbol_s=new double[n_channels];
Carrier_Doppler_hz=new double[n_channels];
Acc_carrier_phase_hz=new double[n_channels];
Pseudorange_m=new double[n_channels];
PRN=new double[n_channels];
valid=new double[n_channels];
n_channels = n_channels_;
RX_time = new double[n_channels];
TOW_at_current_symbol_s = new double[n_channels];
Carrier_Doppler_hz = new double[n_channels];
Acc_carrier_phase_hz = new double[n_channels];
Pseudorange_m = new double[n_channels];
PRN = new double[n_channels];
valid = new double[n_channels];
}
observables_dump_reader::~observables_dump_reader()
{
if (d_dump_file.is_open() == true)

View File

@ -34,9 +34,9 @@ bool tlm_dump_reader::read_binary_obs()
{
try
{
d_dump_file.read((char *) &TOW_at_current_symbol, sizeof(double));
d_dump_file.read((char *) &Tracking_sample_counter, sizeof(unsigned long int));
d_dump_file.read((char *) &d_TOW_at_Preamble, sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&Tracking_sample_counter), sizeof(unsigned long int));
d_dump_file.read(reinterpret_cast<char *>(&d_TOW_at_Preamble), sizeof(double));
}
catch (const std::ifstream::failure &e)
{
@ -45,6 +45,7 @@ bool tlm_dump_reader::read_binary_obs()
return true;
}
bool tlm_dump_reader::restart()
{
if (d_dump_file.is_open())
@ -59,6 +60,7 @@ bool tlm_dump_reader::restart()
}
}
long int tlm_dump_reader::num_epochs()
{
std::ifstream::pos_type size;
@ -77,14 +79,15 @@ long int tlm_dump_reader::num_epochs()
}
}
bool tlm_dump_reader::open_obs_file(std::string out_file)
{
if (d_dump_file.is_open() == false)
{
try
{
d_dump_filename=out_file;
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
d_dump_filename = out_file;
d_dump_file.exceptions( std::ifstream::failbit | std::ifstream::badbit );
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "TLM dump enabled, Log file: " << d_dump_filename.c_str() << std::endl;
return true;
@ -101,6 +104,7 @@ bool tlm_dump_reader::open_obs_file(std::string out_file)
}
}
tlm_dump_reader::~tlm_dump_reader()
{
if (d_dump_file.is_open() == true)

View File

@ -33,26 +33,26 @@
bool tracking_dump_reader::read_binary_obs()
{
try {
d_dump_file.read((char *) &abs_E, sizeof(float));
d_dump_file.read((char *) &abs_P, sizeof(float));
d_dump_file.read((char *) &abs_L, sizeof(float));
d_dump_file.read((char *) &prompt_I, sizeof(float));
d_dump_file.read((char *) &prompt_Q, sizeof(float));
d_dump_file.read(reinterpret_cast<char *>(&abs_E), sizeof(float));
d_dump_file.read(reinterpret_cast<char *>(&abs_P), sizeof(float));
d_dump_file.read(reinterpret_cast<char *>(&abs_L), sizeof(float));
d_dump_file.read(reinterpret_cast<char *>(&prompt_I), sizeof(float));
d_dump_file.read(reinterpret_cast<char *>(&prompt_Q), sizeof(float));
d_dump_file.read((char *) &PRN_start_sample_count, sizeof(unsigned long int));
d_dump_file.read(reinterpret_cast<char *>(&PRN_start_sample_count), sizeof(unsigned long int));
d_dump_file.read((char *) &acc_carrier_phase_rad, sizeof(double));
d_dump_file.read((char *) &carrier_doppler_hz, sizeof(double));
d_dump_file.read((char *) &code_freq_chips, sizeof(double));
d_dump_file.read((char *) &carr_error_hz, sizeof(double));
d_dump_file.read((char *) &carr_error_filt_hz, sizeof(double));
d_dump_file.read((char *) &code_error_chips, sizeof(double));
d_dump_file.read((char *) &code_error_filt_chips, sizeof(double));
d_dump_file.read((char *) &CN0_SNV_dB_Hz, sizeof(double));
d_dump_file.read((char *) &carrier_lock_test, sizeof(double));
d_dump_file.read((char *) &aux1, sizeof(double));
d_dump_file.read((char *) &aux2, sizeof(double));
d_dump_file.read((char *) &PRN, sizeof(unsigned int));
d_dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_rad), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&carrier_doppler_hz), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&code_freq_chips), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&carr_error_hz), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&carr_error_filt_hz), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&code_error_chips), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&code_error_filt_chips), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&CN0_SNV_dB_Hz), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&carrier_lock_test), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&aux1), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&aux2), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&PRN), sizeof(unsigned int));
}
catch (const std::exception &e)
{
@ -105,7 +105,7 @@ bool tracking_dump_reader::open_obs_file(std::string out_file)
try
{
d_dump_filename = out_file;
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
d_dump_file.exceptions( std::ifstream::failbit | std::ifstream::badbit );
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "Tracking dump enabled, Log file: " << d_dump_filename.c_str() << std::endl;
return true;
@ -122,6 +122,7 @@ bool tracking_dump_reader::open_obs_file(std::string out_file)
}
}
tracking_dump_reader::~tracking_dump_reader()
{
if (d_dump_file.is_open() == true)

View File

@ -34,11 +34,11 @@ bool tracking_true_obs_reader::read_binary_obs()
{
try
{
d_dump_file.read((char *) &signal_timestamp_s, sizeof(double));
d_dump_file.read((char *) &acc_carrier_phase_cycles, sizeof(double));
d_dump_file.read((char *) &doppler_l1_hz, sizeof(double));
d_dump_file.read((char *) &prn_delay_chips, sizeof(double));
d_dump_file.read((char *) &tow, sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&signal_timestamp_s), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_cycles), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&doppler_l1_hz), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&prn_delay_chips), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&tow), sizeof(double));
}
catch (const std::exception &e)
{
@ -47,6 +47,7 @@ bool tracking_true_obs_reader::read_binary_obs()
return true;
}
bool tracking_true_obs_reader::restart()
{
if (d_dump_file.is_open())
@ -61,6 +62,7 @@ bool tracking_true_obs_reader::restart()
}
}
long int tracking_true_obs_reader::num_epochs()
{
std::ifstream::pos_type size;
@ -79,6 +81,7 @@ long int tracking_true_obs_reader::num_epochs()
}
}
bool tracking_true_obs_reader::open_obs_file(std::string out_file)
{
if (d_dump_file.is_open() == false)
@ -86,7 +89,7 @@ bool tracking_true_obs_reader::open_obs_file(std::string out_file)
try
{
d_dump_filename = out_file;
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
d_dump_file.exceptions( std::ifstream::failbit | std::ifstream::badbit );
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "Observables dump enabled, Log file: " << d_dump_filename.c_str() << std::endl;
return true;
@ -103,6 +106,7 @@ bool tracking_true_obs_reader::open_obs_file(std::string out_file)
}
}
tracking_true_obs_reader::~tracking_true_obs_reader()
{
if (d_dump_file.is_open() == true)

View File

@ -36,13 +36,13 @@ bool true_observables_reader::read_binary_obs()
{
for(int i=0;i<12;i++)
{
d_dump_file.read((char *) &gps_time_sec[i], sizeof(double));
d_dump_file.read((char *) &doppler_l1_hz, sizeof(double));
d_dump_file.read((char *) &acc_carrier_phase_l1_cycles[i], sizeof(double));
d_dump_file.read((char *) &dist_m[i], sizeof(double));
d_dump_file.read((char *) &true_dist_m[i], sizeof(double));
d_dump_file.read((char *) &carrier_phase_l1_cycles[i], sizeof(double));
d_dump_file.read((char *) &prn[i], sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&gps_time_sec[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&doppler_l1_hz), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_l1_cycles[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&dist_m[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&true_dist_m[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&carrier_phase_l1_cycles[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&prn[i]), sizeof(double));
}
}
catch (const std::ifstream::failure &e)
@ -52,6 +52,7 @@ bool true_observables_reader::read_binary_obs()
return true;
}
bool true_observables_reader::restart()
{
if (d_dump_file.is_open())
@ -66,6 +67,7 @@ bool true_observables_reader::restart()
}
}
long int true_observables_reader::num_epochs()
{
std::ifstream::pos_type size;
@ -84,14 +86,15 @@ long int true_observables_reader::num_epochs()
}
}
bool true_observables_reader::open_obs_file(std::string out_file)
{
if (d_dump_file.is_open() == false)
{
try
{
d_dump_filename=out_file;
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
d_dump_filename = out_file;
d_dump_file.exceptions( std::ifstream::failbit | std::ifstream::badbit );
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "True observables Log file opened: " << d_dump_filename.c_str() << std::endl;
return true;
@ -108,6 +111,7 @@ bool true_observables_reader::open_obs_file(std::string out_file)
}
}
true_observables_reader::~true_observables_reader()
{
if (d_dump_file.is_open() == true)