2017-02-02 19:05:15 +00:00
|
|
|
/*!
|
|
|
|
* \file tracking_dump_reader.cc
|
|
|
|
* \brief Helper file for unit testing
|
|
|
|
* \author Javier Arribas, 2017. jarribas(at)cttc.es
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
2017-02-02 15:41:58 +00:00
|
|
|
|
|
|
|
#include "tracking_dump_reader.h"
|
|
|
|
|
|
|
|
bool tracking_dump_reader::read_binary_obs()
|
2017-02-02 19:05:15 +00:00
|
|
|
{
|
|
|
|
try {
|
2017-08-19 10:45:19 +00:00
|
|
|
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));
|
2017-02-02 15:41:58 +00:00
|
|
|
|
2017-08-19 10:45:19 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&PRN_start_sample_count), sizeof(unsigned long int));
|
2017-02-02 15:41:58 +00:00
|
|
|
|
2017-08-19 10:45:19 +00:00
|
|
|
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));
|
2017-02-02 19:05:15 +00:00
|
|
|
}
|
2017-10-24 09:38:37 +00:00
|
|
|
catch (const std::ifstream::failure &e)
|
2017-02-02 19:05:15 +00:00
|
|
|
{
|
2017-02-02 15:41:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-02-02 19:05:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2017-02-02 15:41:58 +00:00
|
|
|
|
2017-07-12 18:02:34 +00:00
|
|
|
|
2017-02-02 19:05:15 +00:00
|
|
|
bool tracking_dump_reader::restart()
|
|
|
|
{
|
2017-02-02 15:41:58 +00:00
|
|
|
if (d_dump_file.is_open())
|
2017-02-02 19:05:15 +00:00
|
|
|
{
|
|
|
|
d_dump_file.clear();
|
|
|
|
d_dump_file.seekg(0, std::ios::beg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-02-02 15:41:58 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 19:24:47 +00:00
|
|
|
|
2017-02-02 15:41:58 +00:00
|
|
|
long int tracking_dump_reader::num_epochs()
|
|
|
|
{
|
|
|
|
std::ifstream::pos_type size;
|
2017-02-05 19:07:34 +00:00
|
|
|
int number_of_double_vars = 11;
|
|
|
|
int number_of_float_vars = 5;
|
2017-07-12 19:24:47 +00:00
|
|
|
int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars +
|
|
|
|
sizeof(float) * number_of_float_vars + sizeof(unsigned int);
|
|
|
|
std::ifstream tmpfile(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
|
2017-02-02 15:41:58 +00:00
|
|
|
if (tmpfile.is_open())
|
|
|
|
{
|
|
|
|
size = tmpfile.tellg();
|
2017-02-02 19:05:15 +00:00
|
|
|
long int nepoch = size / epoch_size_bytes;
|
2017-02-02 15:41:58 +00:00
|
|
|
return nepoch;
|
2017-02-02 19:05:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-02 15:41:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-12 19:24:47 +00:00
|
|
|
|
2017-02-02 19:05:15 +00:00
|
|
|
bool tracking_dump_reader::open_obs_file(std::string out_file)
|
|
|
|
{
|
2017-02-02 15:41:58 +00:00
|
|
|
if (d_dump_file.is_open() == false)
|
|
|
|
{
|
2017-02-02 19:05:15 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
d_dump_filename = out_file;
|
2017-08-19 10:45:19 +00:00
|
|
|
d_dump_file.exceptions( std::ifstream::failbit | std::ifstream::badbit );
|
2017-02-02 19:05:15 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
catch (const std::ifstream::failure & e)
|
|
|
|
{
|
|
|
|
std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename.c_str() << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
2017-02-05 19:07:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
2017-02-02 15:41:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-19 10:45:19 +00:00
|
|
|
|
2017-02-02 19:05:15 +00:00
|
|
|
tracking_dump_reader::~tracking_dump_reader()
|
|
|
|
{
|
2017-02-02 15:41:58 +00:00
|
|
|
if (d_dump_file.is_open() == true)
|
2017-02-02 19:05:15 +00:00
|
|
|
{
|
|
|
|
d_dump_file.close();
|
|
|
|
}
|
2017-02-02 15:41:58 +00:00
|
|
|
}
|