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
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2017-02-02 19:05:15 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2017-02-02 19:05:15 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2017-02-02 19:05:15 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2017-02-02 19:05:15 +00:00
|
|
|
*/
|
2017-02-02 15:41:58 +00:00
|
|
|
|
|
|
|
#include "tracking_dump_reader.h"
|
2019-02-10 20:55:51 +00:00
|
|
|
#include <exception>
|
2018-02-25 21:49:06 +00:00
|
|
|
#include <iostream>
|
2018-12-03 18:01:47 +00:00
|
|
|
#include <utility>
|
2017-02-02 15:41:58 +00:00
|
|
|
|
2019-02-22 09:47:24 +00:00
|
|
|
bool Tracking_Dump_Reader::read_binary_obs()
|
2017-02-02 19:05:15 +00:00
|
|
|
{
|
2017-10-28 22:44:38 +00:00
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
2018-03-20 13:44:34 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&abs_VE), sizeof(float));
|
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));
|
2018-03-20 13:44:34 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&abs_VL), sizeof(float));
|
2017-08-19 10:45:19 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&prompt_I), sizeof(float));
|
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&prompt_Q), sizeof(float));
|
2018-08-10 19:16:10 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&PRN_start_sample_count), sizeof(uint64_t));
|
2018-03-20 13:44:34 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&acc_carrier_phase_rad), sizeof(float));
|
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&carrier_doppler_hz), sizeof(float));
|
2018-09-09 11:40:31 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&carrier_doppler_rate_hz_s), sizeof(float));
|
2018-03-20 13:44:34 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&code_freq_chips), sizeof(float));
|
2018-09-10 19:29:44 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&code_freq_rate_chips), sizeof(float));
|
2018-03-20 13:44:34 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&carr_error_hz), sizeof(float));
|
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&carr_error_filt_hz), sizeof(float));
|
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&code_error_chips), sizeof(float));
|
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&code_error_filt_chips), sizeof(float));
|
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&CN0_SNV_dB_Hz), sizeof(float));
|
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&carrier_lock_test), sizeof(float));
|
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&aux1), sizeof(float));
|
2017-08-19 10:45:19 +00:00
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&aux2), sizeof(double));
|
|
|
|
d_dump_file.read(reinterpret_cast<char *>(&PRN), sizeof(unsigned int));
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2017-10-24 09:38:37 +00:00
|
|
|
catch (const std::ifstream::failure &e)
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
2017-02-02 15:41:58 +00:00
|
|
|
return false;
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
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
|
|
|
|
2019-02-22 09:47:24 +00:00
|
|
|
bool Tracking_Dump_Reader::restart()
|
2017-02-02 19:05:15 +00:00
|
|
|
{
|
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;
|
|
|
|
}
|
2018-12-03 21:08:19 +00:00
|
|
|
return false;
|
2017-02-02 15:41:58 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 19:24:47 +00:00
|
|
|
|
2019-02-22 09:47:24 +00:00
|
|
|
int64_t Tracking_Dump_Reader::num_epochs()
|
2017-02-02 15:41:58 +00:00
|
|
|
{
|
|
|
|
std::ifstream::pos_type size;
|
2018-03-20 13:44:34 +00:00
|
|
|
int number_of_double_vars = 1;
|
2018-09-10 19:29:44 +00:00
|
|
|
int number_of_float_vars = 19;
|
2018-08-10 19:16:10 +00:00
|
|
|
int epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
|
2018-03-03 01:03:39 +00:00
|
|
|
sizeof(float) * number_of_float_vars + sizeof(unsigned int);
|
2017-07-12 19:24:47 +00:00
|
|
|
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();
|
2018-08-10 19:16:10 +00:00
|
|
|
int64_t nepoch = size / epoch_size_bytes;
|
2017-02-02 15:41:58 +00:00
|
|
|
return nepoch;
|
2017-02-02 19:05:15 +00:00
|
|
|
}
|
2018-12-03 21:08:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
2017-02-02 15:41:58 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 19:24:47 +00:00
|
|
|
|
2019-02-22 09:47:24 +00:00
|
|
|
bool Tracking_Dump_Reader::open_obs_file(std::string out_file)
|
2017-02-02 19:05:15 +00:00
|
|
|
{
|
2017-02-02 15:41:58 +00:00
|
|
|
if (d_dump_file.is_open() == false)
|
|
|
|
{
|
2017-02-02 19:05:15 +00:00
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
2018-12-03 18:01:47 +00:00
|
|
|
d_dump_filename = std::move(out_file);
|
2018-03-03 01:03:39 +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);
|
|
|
|
return true;
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
catch (const std::ifstream::failure &e)
|
|
|
|
{
|
2020-07-07 16:53:50 +00:00
|
|
|
std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename << '\n';
|
2017-02-02 19:05:15 +00:00
|
|
|
return false;
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
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
|
|
|
|
2019-02-22 09:47:24 +00:00
|
|
|
Tracking_Dump_Reader::~Tracking_Dump_Reader()
|
2017-02-02 19:05:15 +00:00
|
|
|
{
|
2019-02-10 20:55:51 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if (d_dump_file.is_open() == true)
|
|
|
|
{
|
|
|
|
d_dump_file.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const std::ifstream::failure &e)
|
|
|
|
{
|
|
|
|
std::cerr << "Problem closing Tracking dump Log file: " << d_dump_filename << '\n';
|
|
|
|
}
|
|
|
|
catch (const std::exception &e)
|
2017-02-02 19:05:15 +00:00
|
|
|
{
|
2019-02-10 20:55:51 +00:00
|
|
|
std::cerr << e.what() << '\n';
|
2017-02-02 19:05:15 +00:00
|
|
|
}
|
2017-02-02 15:41:58 +00:00
|
|
|
}
|