1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-01 15:53:03 +00:00

Remove build and data folders, move tests and utils to the base of the source tree

This commit is contained in:
Carles Fernandez
2024-10-04 11:55:09 +02:00
parent 5be2971c9b
commit 825037592a
251 changed files with 154 additions and 179 deletions

View File

@@ -0,0 +1,108 @@
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
# This file is part of GNSS-SDR.
#
# SPDX-FileCopyrightText: 2010-2020 C. Fernandez-Prades cfernandez(at)cttc.es
# SPDX-License-Identifier: BSD-3-Clause
set(SIGNAL_PROCESSING_TESTING_LIB_SOURCES
acquisition_dump_reader.cc
acquisition_msg_rx.cc
tracking_dump_reader.cc
tlm_dump_reader.cc
observables_dump_reader.cc
tracking_true_obs_reader.cc
true_observables_reader.cc
)
file(GLOB SIGNAL_PROCESSING_TESTING_LIB_HEADERS "*.h")
list(SORT SIGNAL_PROCESSING_TESTING_LIB_HEADERS)
if(USE_CMAKE_TARGET_SOURCES)
add_library(signal_processing_testing_lib STATIC)
target_sources(signal_processing_testing_lib
PRIVATE
${SIGNAL_PROCESSING_TESTING_LIB_SOURCES}
PUBLIC
${SIGNAL_PROCESSING_TESTING_LIB_HEADERS}
)
else()
source_group(Headers FILES ${SIGNAL_PROCESSING_TESTING_LIB_HEADERS})
add_library(signal_processing_testing_lib
${SIGNAL_PROCESSING_TESTING_LIB_SOURCES}
${SIGNAL_PROCESSING_TESTING_LIB_HEADERS}
)
endif()
target_link_libraries(signal_processing_testing_lib
PUBLIC
Armadillo::armadillo
Gnuradio::runtime
Gnuradio::pmt
PRIVATE
Boost::headers
Matio::matio
)
if(ENABLE_GLOG_AND_GFLAGS)
target_link_libraries(signal_processing_testing_lib PRIVATE Gflags::gflags Glog::glog)
target_compile_definitions(signal_processing_testing_lib PRIVATE -DUSE_GLOG_AND_GFLAGS=1)
else()
target_link_libraries(signal_processing_testing_lib PRIVATE absl::flags absl::log)
endif()
target_include_directories(signal_processing_testing_lib
PUBLIC
${GNSSSDR_SOURCE_DIR}/src/core/interfaces
INTERFACE
${GNSSSDR_SOURCE_DIR}/tests/common-files
)
if(USE_GENERIC_LAMBDAS)
set(has_generic_lambdas HAS_GENERIC_LAMBDA=1)
set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0)
target_compile_definitions(signal_processing_testing_lib
PRIVATE
"$<$<COMPILE_FEATURES:cxx_generic_lambdas>:${has_generic_lambdas}>"
"$<$<NOT:$<COMPILE_FEATURES:cxx_generic_lambdas>>:${no_has_generic_lambdas}>"
)
else()
target_compile_definitions(signal_processing_testing_lib
PRIVATE
-DHAS_GENERIC_LAMBDA=0
)
endif()
if(USE_BOOST_BIND_PLACEHOLDERS)
target_compile_definitions(signal_processing_testing_lib
PRIVATE
-DUSE_BOOST_BIND_PLACEHOLDERS=1
)
endif()
if(GNURADIO_USES_STD_POINTERS)
target_compile_definitions(signal_processing_testing_lib
PUBLIC -DGNURADIO_USES_STD_POINTERS=1
)
endif()
if(PMT_USES_BOOST_ANY)
target_compile_definitions(signal_processing_testing_lib
PRIVATE
-DPMT_USES_BOOST_ANY=1
)
endif()
if(ENABLE_CLANG_TIDY)
if(CLANG_TIDY_EXE)
set_target_properties(signal_processing_testing_lib
PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
endif()
endif()
set_property(TARGET signal_processing_testing_lib
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)

View File

@@ -0,0 +1,306 @@
/*!
* \file acquisition_dump_reader.cc
* \brief Helper file for unit testing
* \authors Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
* Antonio Ramos, 2018. antonio.ramos(at)cttc.es
*
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "acquisition_dump_reader.h"
#include <matio.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>
bool Acquisition_Dump_Reader::read_binary_acq()
{
mat_t* matfile = Mat_Open(d_dump_filename.c_str(), MAT_ACC_RDONLY);
if (matfile == nullptr)
{
std::cout << "Unreachable Acquisition dump file " << d_dump_filename << '\n';
return false;
}
matvar_t* var_ = Mat_VarRead(matfile, "acq_grid");
if (var_ == nullptr)
{
std::cout << "Unreachable grid variable in Acquisition dump file.\n";
Mat_Close(matfile);
return false;
}
if (var_->rank != 2)
{
std::cout << "Invalid Acquisition dump file: rank error\n";
Mat_VarFree(var_);
Mat_Close(matfile);
return false;
}
if ((var_->dims[0] != d_samples_per_code) or (var_->dims[1] != d_num_doppler_bins))
{
std::cout << "Invalid Acquisition dump file: dimension matrix error\n";
if (var_->dims[0] != d_samples_per_code)
{
std::cout << "Expected " << d_samples_per_code << " samples per code. Obtained " << var_->dims[0] << '\n';
}
if (var_->dims[1] != d_num_doppler_bins)
{
std::cout << "Expected " << d_num_doppler_bins << " Doppler bins. Obtained " << var_->dims[1] << '\n';
}
Mat_VarFree(var_);
Mat_Close(matfile);
return false;
}
if (var_->data_type != MAT_T_SINGLE)
{
std::cout << "Invalid Acquisition dump file: data type error\n";
Mat_VarFree(var_);
Mat_Close(matfile);
return false;
}
matvar_t* var2_ = Mat_VarRead(matfile, "doppler_max");
d_doppler_max = *static_cast<unsigned int*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "doppler_step");
d_doppler_step = *static_cast<unsigned int*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "input_power");
input_power = *static_cast<float*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "acq_doppler_hz");
acq_doppler_hz = *static_cast<float*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "acq_delay_samples");
acq_delay_samples = *static_cast<float*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "test_statistic");
test_statistic = *static_cast<float*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "threshold");
threshold = *static_cast<float*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "sample_counter");
sample_counter = *static_cast<uint64_t*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "d_positive_acq");
positive_acq = *static_cast<int*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "num_dwells");
num_dwells = *static_cast<int*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "PRN");
PRN = *static_cast<int*>(var2_->data);
Mat_VarFree(var2_);
std::vector<std::vector<float> >::iterator it1;
std::vector<float>::iterator it2;
auto* aux = static_cast<float*>(var_->data);
int k = 0;
float normalization_factor = std::pow(d_samples_per_code, 4) * input_power;
for (it1 = mag.begin(); it1 != mag.end(); it1++)
{
for (it2 = it1->begin(); it2 != it1->end(); it2++)
{
*it2 = static_cast<float>(aux[k]) / normalization_factor;
k++;
}
}
Mat_VarFree(var_);
Mat_Close(matfile);
return true;
}
Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename,
int channel,
int execution)
{
unsigned int sat_ = 0;
unsigned int doppler_max_ = 0;
unsigned int doppler_step_ = 0;
unsigned int samples_per_code_ = 0;
mat_t* matfile = Mat_Open(d_dump_filename.c_str(), MAT_ACC_RDONLY);
if (matfile != nullptr)
{
matvar_t* var_ = Mat_VarRead(matfile, "doppler_max");
doppler_max_ = *static_cast<unsigned int*>(var_->data);
Mat_VarFree(var_);
var_ = Mat_VarRead(matfile, "doppler_step");
doppler_step_ = *static_cast<unsigned int*>(var_->data);
Mat_VarFree(var_);
var_ = Mat_VarRead(matfile, "PRN");
sat_ = *static_cast<int*>(var_->data);
Mat_VarFree(var_);
var_ = Mat_VarRead(matfile, "grid");
samples_per_code_ = var_->dims[0];
Mat_VarFree(var_);
Mat_Close(matfile);
}
else
{
std::cout << "Unreachable Acquisition dump file " << d_dump_filename << '\n';
}
acq_doppler_hz = 0.0;
acq_delay_samples = 0.0;
test_statistic = 0.0;
input_power = 0.0;
threshold = 0.0;
positive_acq = 0;
sample_counter = 0;
PRN = 0;
d_sat = 0;
d_doppler_max = doppler_max_;
d_doppler_step = doppler_step_;
d_samples_per_code = samples_per_code_;
d_num_doppler_bins = 0;
num_dwells = 0;
*this = Acquisition_Dump_Reader(basename,
sat_,
doppler_max_,
doppler_step_,
samples_per_code_,
channel,
execution);
}
Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename,
unsigned int sat,
unsigned int doppler_max,
unsigned int doppler_step,
unsigned int samples_per_code,
int channel,
int execution)
: d_basename(basename),
d_sat(sat),
d_doppler_max(doppler_max),
d_doppler_step(doppler_step),
d_samples_per_code(samples_per_code)
{
if (d_doppler_step == 0)
{
d_doppler_step = 1;
}
d_num_doppler_bins = static_cast<unsigned int>(ceil(static_cast<double>(static_cast<int>(d_doppler_max) - static_cast<int>(-d_doppler_max)) / static_cast<double>(d_doppler_step)));
std::vector<std::vector<float> > mag_aux(d_num_doppler_bins, std::vector<float>(d_samples_per_code));
mag = std::move(mag_aux);
d_dump_filename = d_basename + "_ch_" + std::to_string(channel) + "_" + std::to_string(execution) + "_sat_" + std::to_string(d_sat) + ".mat";
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
doppler.push_back(-static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index);
}
for (unsigned int k = 0; k < d_samples_per_code; k++)
{
samples.push_back(k);
}
}
// Copy assignment operator
Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(const Acquisition_Dump_Reader& other)
{
if (this != &other)
{
doppler = other.doppler;
samples = other.samples;
mag = other.mag;
acq_doppler_hz = other.acq_doppler_hz;
acq_delay_samples = other.acq_delay_samples;
test_statistic = other.test_statistic;
input_power = other.input_power;
threshold = other.threshold;
positive_acq = other.positive_acq;
PRN = other.PRN;
num_dwells = other.num_dwells;
sample_counter = other.sample_counter;
d_basename = other.d_basename;
d_dump_filename = other.d_dump_filename;
d_sat = other.d_sat;
d_doppler_max = other.d_doppler_max;
d_doppler_step = other.d_doppler_step;
d_samples_per_code = other.d_samples_per_code;
d_num_doppler_bins = other.d_num_doppler_bins;
}
return *this;
}
// Move constructor
Acquisition_Dump_Reader::Acquisition_Dump_Reader(Acquisition_Dump_Reader&& other) noexcept
: doppler(std::move(other.doppler)),
samples(std::move(other.samples)),
mag(std::move(other.mag)),
acq_doppler_hz(other.acq_doppler_hz),
acq_delay_samples(other.acq_delay_samples),
test_statistic(other.test_statistic),
input_power(other.input_power),
threshold(other.threshold),
positive_acq(other.positive_acq),
PRN(other.PRN),
num_dwells(other.num_dwells),
sample_counter(other.sample_counter),
d_basename(std::move(other.d_basename)),
d_dump_filename(std::move(other.d_dump_filename)),
d_sat(other.d_sat),
d_doppler_max(other.d_doppler_max),
d_doppler_step(other.d_doppler_step),
d_samples_per_code(other.d_samples_per_code),
d_num_doppler_bins(other.d_num_doppler_bins)
{
}
// Move assignment operator
Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(Acquisition_Dump_Reader&& other) noexcept
{
if (this != &other) // Check for self-assignment
{
// Move member variables from the other object to this object
d_basename = std::move(other.d_basename);
d_dump_filename = std::move(other.d_dump_filename);
d_sat = other.d_sat;
d_doppler_max = other.d_doppler_max;
d_doppler_step = other.d_doppler_step;
d_samples_per_code = other.d_samples_per_code;
d_num_doppler_bins = other.d_num_doppler_bins;
doppler = std::move(other.doppler);
samples = std::move(other.samples);
mag = std::move(other.mag);
acq_doppler_hz = other.acq_doppler_hz;
acq_delay_samples = other.acq_delay_samples;
test_statistic = other.test_statistic;
input_power = other.input_power;
threshold = other.threshold;
positive_acq = other.positive_acq;
PRN = other.PRN;
num_dwells = other.num_dwells;
sample_counter = other.sample_counter;
}
return *this;
}

View File

@@ -0,0 +1,70 @@
/*!
* \file acquisition_dump_reader.h
* \brief Helper file for unit testing
* \authors Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
* Antonio Ramos, 2018. antonio.ramos(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_ACQUISITION_DUMP_READER_H
#define GNSS_SDR_ACQUISITION_DUMP_READER_H
#include <cstdint>
#include <string>
#include <vector>
class Acquisition_Dump_Reader
{
public:
Acquisition_Dump_Reader(const std::string& basename,
unsigned int sat,
unsigned int doppler_max,
unsigned int doppler_step,
unsigned int samples_per_code,
int channel = 0,
int execution = 1);
Acquisition_Dump_Reader(const std::string& basename,
int channel = 0,
int execution = 1);
Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) = default; //!< Copy constructor
Acquisition_Dump_Reader& operator=(const Acquisition_Dump_Reader& other); //!< Copy assignment operator
Acquisition_Dump_Reader(Acquisition_Dump_Reader&& other) noexcept; //!< Move constructor
Acquisition_Dump_Reader& operator=(Acquisition_Dump_Reader&& other) noexcept; //!< Move assignment operator
bool read_binary_acq();
std::vector<int> doppler;
std::vector<unsigned int> samples;
std::vector<std::vector<float> > mag;
float acq_doppler_hz{};
float acq_delay_samples{};
float test_statistic{};
float input_power{};
float threshold{};
int positive_acq{};
unsigned int PRN{};
unsigned int num_dwells{};
uint64_t sample_counter{};
private:
std::string d_basename;
std::string d_dump_filename;
unsigned int d_sat{};
unsigned int d_doppler_max{};
unsigned int d_doppler_step{};
unsigned int d_samples_per_code{};
unsigned int d_num_doppler_bins{};
};
#endif // GNSS_SDR_ACQUISITION_DUMP_READER_H

View File

@@ -0,0 +1,84 @@
/*!
* \file acquisition_msg_rx.cc
* \brief This is a helper class to catch the asynchronous messages
* emitted by an acquisition block.
* \author Carles Fernandez-Prades, 2018. cfernandez(at)cttc.cat
*
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2012-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "acquisition_msg_rx.h"
#include <cstdint>
#include <utility>
#if USE_GLOG_AND_GFLAGS
#include <gflags/gflags.h>
#include <glog/logging.h>
#else
#include <absl/flags/flag.h>
#include <absl/log/log.h>
#endif
#if HAS_GENERIC_LAMBDA
#else
#include <boost/bind/bind.hpp>
#endif
#if PMT_USES_BOOST_ANY
#include <boost/any.hpp>
namespace wht = boost;
#else
#include <any>
namespace wht = std;
#endif
Acquisition_msg_rx_sptr Acquisition_msg_rx_make()
{
return Acquisition_msg_rx_sptr(new Acquisition_msg_rx());
}
void Acquisition_msg_rx::msg_handler_channel_events(const pmt::pmt_t& msg)
{
try
{
int64_t message = pmt::to_long(msg);
rx_message = message;
top_block->stop(); // stop the flowgraph
}
catch (const wht::bad_any_cast& e)
{
LOG(WARNING) << "msg_handler_acquisition Bad cast!\n";
rx_message = 0;
}
}
Acquisition_msg_rx::Acquisition_msg_rx()
: gr::block("Acquisition_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)),
rx_message(0)
{
this->message_port_register_in(pmt::mp("events"));
this->set_msg_handler(pmt::mp("events"),
#if HAS_GENERIC_LAMBDA
[this](auto&& PH1) { msg_handler_channel_events(PH1); });
#else
#if USE_BOOST_BIND_PLACEHOLDERS
boost::bind(&Acquisition_msg_rx::msg_handler_channel_events, this, boost::placeholders::_1));
#else
boost::bind(&Acquisition_msg_rx::msg_handler_channel_events, this, _1));
#endif
#endif
}
Acquisition_msg_rx::~Acquisition_msg_rx() = default;

View File

@@ -0,0 +1,50 @@
/*!
* \file acquisition_msg_rx.h
* \brief This is a helper class to catch the asynchronous messages
* emitted by an acquisition block.
* \author Carles Fernandez-Prades, 2018. cfernandez(at)cttc.cat
*
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2012-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_ACQUISITION_MSG_RX_H
#define GNSS_SDR_ACQUISITION_MSG_RX_H
#include "gnss_block_interface.h"
#include <gnuradio/block.h>
#include <gnuradio/top_block.h>
#include <pmt/pmt.h>
// ######## GNURADIO ACQUISITION BLOCK MESSAGE RECEVER #########
class Acquisition_msg_rx;
using Acquisition_msg_rx_sptr = gnss_shared_ptr<Acquisition_msg_rx>;
Acquisition_msg_rx_sptr Acquisition_msg_rx_make();
class Acquisition_msg_rx : public gr::block
{
private:
friend Acquisition_msg_rx_sptr Acquisition_msg_rx_make();
void msg_handler_channel_events(const pmt::pmt_t& msg);
Acquisition_msg_rx();
public:
int rx_message;
gr::top_block_sptr top_block;
~Acquisition_msg_rx(); //!< Default destructor
};
#endif // GNSS_SDR_ACQUISITION_MSG_RX_H

View File

@@ -0,0 +1,250 @@
/*!
* \file item_type_helpers_test.cc
* \brief This file implements unit tests for the item_type_helpers
* custom block
* \author Cillian O'Driscoll, 2019. cillian.odriscoll (at) gmail.com
*
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "item_type_helpers.h"
#include <gtest/gtest.h>
#include <algorithm>
#include <random>
class ItemTypeHelpersTest : public ::testing::Test
{
protected:
static constexpr size_t N = 1000;
public:
ItemTypeHelpersTest()
{
std::random_device r;
std::default_random_engine e(r());
std::uniform_int_distribution<int8_t> udist_int8(-100, 100);
std::uniform_int_distribution<int16_t> udist_int16(-100, 100);
std::uniform_real_distribution<float> udist_float(-100, 100);
std::generate(byte_array_in.begin(), byte_array_in.end(), [&udist_int8, &e]() { return udist_int8(e); });
std::generate(short_array_in.begin(), short_array_in.end(), [&udist_int16, &e]() { return udist_int16(e); });
std::generate(float_array_in.begin(), float_array_in.end(), [&udist_float, &e]() { return udist_float(e); });
}
std::vector<std::string> valid_item_types = {"byte", "ibyte", "cbyte",
"short", "ishort", "cshort", "float", "gr_complex"};
std::vector<std::string> invalid_item_types = {"i8", "tfgs", "cbite",
"shirt", "qshort", "csort", "flat", "igr_complex"};
std::array<int8_t, 2 * N> byte_array_in;
std::array<int8_t, 2 * N> byte_array_out;
std::array<int16_t, 2 * N> short_array_in;
std::array<int16_t, 2 * N> short_array_out;
std::array<float, 2 * N> float_array_in;
std::array<float, 2 * N> float_array_out;
};
TEST_F(ItemTypeHelpersTest, CheckValidTypes)
{
for (auto &valid_type : valid_item_types)
{
EXPECT_TRUE(item_type_valid(valid_type));
}
for (auto &invalid_type : invalid_item_types)
{
EXPECT_FALSE(item_type_valid(invalid_type));
}
}
TEST_F(ItemTypeHelpersTest, CheckSizes)
{
EXPECT_EQ(item_type_size("byte"), 1);
EXPECT_EQ(item_type_size("ibyte"), 1);
EXPECT_EQ(item_type_size("cbyte"), 2);
EXPECT_EQ(item_type_size("short"), 2);
EXPECT_EQ(item_type_size("ishort"), 2);
EXPECT_EQ(item_type_size("cshort"), 4);
EXPECT_EQ(item_type_size("float"), 4);
EXPECT_EQ(item_type_size("gr_complex"), 8);
for (auto &invalid_type : invalid_item_types)
{
EXPECT_EQ(item_type_size(invalid_type), 0);
}
}
TEST_F(ItemTypeHelpersTest, CheckMakeConverters)
{
for (auto &input_type : valid_item_types)
{
for (auto &output_type : valid_item_types)
{
item_type_converter_t converter = nullptr;
if (item_type_is_complex(input_type) == item_type_is_complex(output_type))
{
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
}
else
{
EXPECT_THROW(converter = make_vector_converter(input_type, output_type), std::runtime_error);
}
}
}
}
TEST_F(ItemTypeHelpersTest, CheckConversionsReal)
{
std::string input_type = "byte";
std::string output_type = "byte";
item_type_converter_t converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(byte_array_out.data(), byte_array_in.data(), N);
EXPECT_TRUE(std::equal(byte_array_in.begin(), byte_array_in.begin() + N, byte_array_out.begin()));
input_type = "byte";
output_type = "short";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(short_array_out.data(), byte_array_in.data(), N);
converter = make_vector_converter(output_type, input_type);
EXPECT_NE(converter, nullptr);
converter(byte_array_out.data(), short_array_out.data(), N);
EXPECT_TRUE(std::equal(byte_array_out.begin(), byte_array_out.begin() + N, byte_array_in.begin()));
input_type = "byte";
output_type = "float";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(float_array_out.data(), byte_array_in.data(), N);
converter = make_vector_converter(output_type, input_type);
EXPECT_NE(converter, nullptr);
converter(byte_array_out.data(), float_array_out.data(), N);
EXPECT_TRUE(std::equal(byte_array_out.begin(), byte_array_out.begin() + N, byte_array_in.begin()));
input_type = "short";
output_type = "short";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(short_array_out.data(), short_array_in.data(), N);
EXPECT_TRUE(std::equal(short_array_in.begin(), short_array_in.begin() + N, short_array_out.begin()));
input_type = "short";
output_type = "float";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(float_array_out.data(), short_array_in.data(), N);
converter = make_vector_converter(output_type, input_type);
EXPECT_NE(converter, nullptr);
converter(short_array_out.data(), float_array_out.data(), N);
EXPECT_TRUE(std::equal(short_array_out.begin(), short_array_out.begin() + N, short_array_in.begin()));
input_type = "float";
output_type = "float";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(float_array_out.data(), float_array_in.data(), N);
EXPECT_TRUE(std::equal(float_array_in.begin(), float_array_in.begin() + N, float_array_out.begin()));
}
TEST_F(ItemTypeHelpersTest, CheckConversionsComplex)
{
std::string input_type = "cbyte";
std::string output_type = "cbyte";
item_type_converter_t converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(byte_array_out.data(), byte_array_in.data(), N);
EXPECT_TRUE(std::equal(byte_array_in.begin(), byte_array_in.begin() + N, byte_array_out.begin()));
input_type = "cbyte";
output_type = "ibyte";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(byte_array_out.data(), byte_array_in.data(), N);
EXPECT_TRUE(std::equal(byte_array_in.begin(), byte_array_in.begin() + N, byte_array_out.begin()));
input_type = "cbyte";
output_type = "cshort";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(short_array_out.data(), byte_array_in.data(), N);
converter = make_vector_converter(output_type, input_type);
EXPECT_NE(converter, nullptr);
converter(byte_array_out.data(), short_array_out.data(), N);
EXPECT_TRUE(std::equal(byte_array_out.begin(), byte_array_out.begin() + N, byte_array_in.begin()));
input_type = "cbyte";
output_type = "ishort";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(short_array_out.data(), byte_array_in.data(), N);
converter = make_vector_converter(output_type, input_type);
EXPECT_NE(converter, nullptr);
converter(byte_array_out.data(), short_array_out.data(), N);
EXPECT_TRUE(std::equal(byte_array_out.begin(), byte_array_out.begin() + N, byte_array_in.begin()));
input_type = "cbyte";
output_type = "gr_complex";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(float_array_out.data(), byte_array_in.data(), N);
converter = make_vector_converter(output_type, input_type);
EXPECT_NE(converter, nullptr);
converter(byte_array_out.data(), float_array_out.data(), N);
EXPECT_TRUE(std::equal(byte_array_out.begin(), byte_array_out.begin() + N, byte_array_in.begin()));
input_type = "cshort";
output_type = "cshort";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(short_array_out.data(), short_array_in.data(), N);
EXPECT_TRUE(std::equal(short_array_in.begin(), short_array_in.begin() + N, short_array_out.begin()));
input_type = "cshort";
output_type = "ishort";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(short_array_out.data(), short_array_in.data(), N);
EXPECT_TRUE(std::equal(short_array_in.begin(), short_array_in.begin() + N, short_array_out.begin()));
input_type = "cshort";
output_type = "gr_complex";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(float_array_out.data(), short_array_in.data(), N);
converter = make_vector_converter(output_type, input_type);
EXPECT_NE(converter, nullptr);
converter(short_array_out.data(), float_array_out.data(), N);
EXPECT_TRUE(std::equal(short_array_out.begin(), short_array_out.begin() + N, short_array_in.begin()));
input_type = "gr_complex";
output_type = "gr_complex";
converter = make_vector_converter(input_type, output_type);
EXPECT_NE(converter, nullptr);
converter(float_array_out.data(), float_array_in.data(), N);
EXPECT_TRUE(std::equal(float_array_in.begin(), float_array_in.begin() + N, float_array_out.begin()));
}

View File

@@ -0,0 +1,136 @@
/*!
* \file observables_dump_reader.cc
* \brief Helper file for unit testing
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "observables_dump_reader.h"
#include <exception>
#include <iostream>
#include <utility>
bool Observables_Dump_Reader::read_binary_obs()
{
try
{
for (int i = 0; i < n_channels; i++)
{
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)
{
return false;
}
return true;
}
bool Observables_Dump_Reader::restart()
{
if (d_dump_file.is_open())
{
d_dump_file.clear();
d_dump_file.seekg(0, std::ios::beg);
return true;
}
return false;
}
int64_t Observables_Dump_Reader::num_epochs()
{
std::ifstream::pos_type size;
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())
{
size = tmpfile.tellg();
int64_t nepoch = size / epoch_size_bytes;
return nepoch;
}
return 0;
}
bool Observables_Dump_Reader::open_obs_file(std::string out_file)
{
if (d_dump_file.is_open() == false)
{
try
{
d_dump_filename = std::move(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);
return true;
}
catch (const std::ifstream::failure &e)
{
std::cout << "Problem opening Observables dump Log file: " << d_dump_filename << '\n';
return false;
}
}
else
{
return false;
}
}
void Observables_Dump_Reader::close_obs_file()
{
if (d_dump_file.is_open() == false)
{
d_dump_file.close();
}
}
Observables_Dump_Reader::Observables_Dump_Reader(int n_channels_)
: n_channels(n_channels_)
{
RX_time = std::vector<double>(n_channels);
TOW_at_current_symbol_s = std::vector<double>(n_channels);
Carrier_Doppler_hz = std::vector<double>(n_channels);
Acc_carrier_phase_hz = std::vector<double>(n_channels);
Pseudorange_m = std::vector<double>(n_channels);
PRN = std::vector<double>(n_channels);
valid = std::vector<double>(n_channels);
}
Observables_Dump_Reader::~Observables_Dump_Reader()
{
try
{
if (d_dump_file.is_open() == true)
{
d_dump_file.close();
}
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem closing Observables dump Log file: " << d_dump_filename << '\n';
}
catch (const std::exception &e)
{
std::cerr << e.what() << '\n';
}
}

View File

@@ -0,0 +1,51 @@
/*!
* \file observables_dump_reader.h
* \brief Helper file for unit testing
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_OBSERVABLES_DUMP_READER_H
#define GNSS_SDR_OBSERVABLES_DUMP_READER_H
#include <cstdint>
#include <fstream>
#include <string>
#include <vector>
class Observables_Dump_Reader
{
public:
explicit Observables_Dump_Reader(int n_channels);
~Observables_Dump_Reader();
bool read_binary_obs();
bool restart();
int64_t num_epochs();
bool open_obs_file(std::string out_file);
void close_obs_file();
// dump variables
std::vector<double> RX_time;
std::vector<double> TOW_at_current_symbol_s;
std::vector<double> Carrier_Doppler_hz;
std::vector<double> Acc_carrier_phase_hz;
std::vector<double> Pseudorange_m;
std::vector<double> PRN;
std::vector<double> valid;
private:
int n_channels;
std::string d_dump_filename;
std::ifstream d_dump_file;
};
#endif // GNSS_SDR_OBSERVABLES_DUMP_READER_H

View File

@@ -0,0 +1,111 @@
/*!
* \file tlm_dump_reader.cc
* \brief Helper file for unit testing
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "tlm_dump_reader.h"
#include <exception>
#include <iostream>
#include <utility>
bool Tlm_Dump_Reader::read_binary_obs()
{
try
{
d_dump_file.read(reinterpret_cast<char *>(&TOW_at_current_symbol), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&Tracking_sample_counter), sizeof(uint64_t));
d_dump_file.read(reinterpret_cast<char *>(&d_TOW_at_Preamble), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&nav_symbol), sizeof(int32_t));
d_dump_file.read(reinterpret_cast<char *>(&prn), sizeof(int32_t));
}
catch (const std::ifstream::failure &e)
{
return false;
}
return true;
}
bool Tlm_Dump_Reader::restart()
{
if (d_dump_file.is_open())
{
d_dump_file.clear();
d_dump_file.seekg(0, std::ios::beg);
return true;
}
return false;
}
int64_t Tlm_Dump_Reader::num_epochs()
{
std::ifstream::pos_type size;
int number_of_double_vars_in_epoch = 2;
int number_of_int_vars_in_epoch = 2;
int epoch_size_bytes = sizeof(double) * number_of_double_vars_in_epoch + sizeof(uint64_t) + sizeof(int32_t) * number_of_int_vars_in_epoch;
std::ifstream tmpfile(d_dump_filename.c_str(), std::ios::binary | std::ios::ate);
if (tmpfile.is_open())
{
size = tmpfile.tellg();
int64_t nepoch = size / epoch_size_bytes;
return nepoch;
}
return 0;
}
bool Tlm_Dump_Reader::open_obs_file(std::string out_file)
{
if (d_dump_file.is_open() == false)
{
try
{
d_dump_filename = std::move(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() << '\n';
return true;
}
catch (const std::ifstream::failure &e)
{
std::cout << "Problem opening TLM dump Log file: " << d_dump_filename << '\n';
return false;
}
}
else
{
return false;
}
}
Tlm_Dump_Reader::~Tlm_Dump_Reader()
{
try
{
if (d_dump_file.is_open() == true)
{
d_dump_file.close();
}
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem closing TLM dump Log file: " << d_dump_filename << '\n';
}
catch (const std::exception &e)
{
std::cerr << e.what() << '\n';
}
}

View File

@@ -0,0 +1,46 @@
/*!
* \file tlm_dump_reader.h
* \brief Helper file for unit testing
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_TLM_DUMP_READER_H
#define GNSS_SDR_TLM_DUMP_READER_H
#include <cstdint>
#include <fstream>
#include <string>
#include <vector>
class Tlm_Dump_Reader
{
public:
~Tlm_Dump_Reader();
bool read_binary_obs();
bool restart();
int64_t num_epochs();
bool open_obs_file(std::string out_file);
// telemetry decoder dump variables
double TOW_at_current_symbol;
uint64_t Tracking_sample_counter;
double d_TOW_at_Preamble;
int32_t nav_symbol;
int32_t prn;
private:
std::string d_dump_filename;
std::ifstream d_dump_file;
};
#endif // GNSS_SDR_TLM_DUMP_READER_H

View File

@@ -0,0 +1,130 @@
/*!
* \file tracking_dump_reader.cc
* \brief Helper file for unit testing
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "tracking_dump_reader.h"
#include <exception>
#include <iostream>
#include <utility>
bool Tracking_Dump_Reader::read_binary_obs()
{
try
{
d_dump_file.read(reinterpret_cast<char *>(&abs_VE), 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 *>(&abs_VL), 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(reinterpret_cast<char *>(&PRN_start_sample_count), sizeof(uint64_t));
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));
d_dump_file.read(reinterpret_cast<char *>(&carrier_doppler_rate_hz_s), sizeof(float));
d_dump_file.read(reinterpret_cast<char *>(&code_freq_chips), sizeof(float));
d_dump_file.read(reinterpret_cast<char *>(&code_freq_rate_chips), sizeof(float));
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));
d_dump_file.read(reinterpret_cast<char *>(&aux2), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&PRN), sizeof(unsigned int));
}
catch (const std::ifstream::failure &e)
{
return false;
}
return true;
}
bool Tracking_Dump_Reader::restart()
{
if (d_dump_file.is_open())
{
d_dump_file.clear();
d_dump_file.seekg(0, std::ios::beg);
return true;
}
return false;
}
int64_t Tracking_Dump_Reader::num_epochs()
{
std::ifstream::pos_type size;
int number_of_double_vars = 1;
int number_of_float_vars = 19;
int epoch_size_bytes = sizeof(uint64_t) + 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);
if (tmpfile.is_open())
{
size = tmpfile.tellg();
int64_t nepoch = size / epoch_size_bytes;
return nepoch;
}
return 0;
}
bool Tracking_Dump_Reader::open_obs_file(std::string out_file)
{
if (d_dump_file.is_open() == false)
{
try
{
d_dump_filename = std::move(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);
return true;
}
catch (const std::ifstream::failure &e)
{
std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename << '\n';
return false;
}
}
else
{
return false;
}
}
Tracking_Dump_Reader::~Tracking_Dump_Reader()
{
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)
{
std::cerr << e.what() << '\n';
}
}

View File

@@ -0,0 +1,79 @@
/*!
* \file tracking_dump_reader.h
* \brief Helper file for unit testing
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_TRACKING_DUMP_READER_H
#define GNSS_SDR_TRACKING_DUMP_READER_H
#include <cstdint>
#include <fstream>
#include <string>
#include <vector>
class Tracking_Dump_Reader
{
public:
~Tracking_Dump_Reader();
bool read_binary_obs();
bool restart();
int64_t num_epochs();
bool open_obs_file(std::string out_file);
// tracking dump variables
// VEPLVL
float abs_VE;
float abs_E;
float abs_P;
float abs_L;
float abs_VL;
// PROMPT I and Q (to analyze navigation symbols)
float prompt_I;
float prompt_Q;
// PRN start sample stamp
uint64_t PRN_start_sample_count;
// accumulated carrier phase
float acc_carrier_phase_rad;
// carrier and code frequency
float carrier_doppler_hz;
float carrier_doppler_rate_hz_s;
float code_freq_chips;
float code_freq_rate_chips;
// PLL commands
float carr_error_hz;
float carr_error_filt_hz;
// DLL commands
float code_error_chips;
float code_error_filt_chips;
// CN0 and carrier lock test
float CN0_SNV_dB_Hz;
float carrier_lock_test;
// AUX vars (for debug purposes)
float aux1;
double aux2;
unsigned int PRN;
private:
std::string d_dump_filename;
std::ifstream d_dump_file;
};
#endif // GNSS_SDR_TRACKING_DUMP_READER_H

View File

@@ -0,0 +1,117 @@
/*!
* \file tracking_true_obs_reader.cc
* \brief Helper file for unit testing
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "tracking_true_obs_reader.h"
#include <exception>
#include <iostream>
#include <utility>
bool Tracking_True_Obs_Reader::read_binary_obs()
{
try
{
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::ifstream::failure &e)
{
return false;
}
return true;
}
bool Tracking_True_Obs_Reader::restart()
{
if (d_dump_file.is_open())
{
d_dump_file.clear();
d_dump_file.seekg(0, std::ios::beg);
return true;
}
return false;
}
int64_t Tracking_True_Obs_Reader::num_epochs()
{
std::ifstream::pos_type size;
int number_of_vars_in_epoch = 5;
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())
{
size = tmpfile.tellg();
int64_t nepoch = size / epoch_size_bytes;
return nepoch;
}
return 0;
}
bool Tracking_True_Obs_Reader::open_obs_file(std::string out_file)
{
if (d_dump_file.is_open() == false)
{
try
{
d_dump_file.clear();
d_dump_filename = std::move(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);
return true;
}
catch (const std::ifstream::failure &e)
{
std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename << '\n';
return false;
}
}
else
{
return false;
}
}
void Tracking_True_Obs_Reader::close_obs_file()
{
if (d_dump_file.is_open() == true)
{
d_dump_file.close();
}
}
Tracking_True_Obs_Reader::~Tracking_True_Obs_Reader()
{
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)
{
std::cerr << e.what() << '\n';
}
}

View File

@@ -0,0 +1,47 @@
/*!
* \file tracking_true_obs_reader.h
* \brief Helper file for unit testing
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_TRACKING_TRUE_OBS_READER_H
#define GNSS_SDR_TRACKING_TRUE_OBS_READER_H
#include <cstdint>
#include <fstream>
#include <string>
#include <vector>
class Tracking_True_Obs_Reader
{
public:
~Tracking_True_Obs_Reader();
bool read_binary_obs();
bool restart();
int64_t num_epochs();
bool open_obs_file(std::string out_file);
void close_obs_file();
bool d_dump;
double signal_timestamp_s;
double acc_carrier_phase_cycles;
double doppler_l1_hz;
double prn_delay_chips;
double tow;
private:
std::string d_dump_filename;
std::ifstream d_dump_file;
};
#endif // GNSS_SDR_RACKING_TRUE_OBS_READER_H

View File

@@ -0,0 +1,115 @@
/*!
* \file true_observables_reader.cc
* \brief Helper file for unit testing
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "true_observables_reader.h"
#include <exception>
#include <iostream>
#include <utility>
bool True_Observables_Reader::read_binary_obs()
{
try
{
for (int i = 0; i < 12; i++)
{
d_dump_file.read(reinterpret_cast<char *>(&gps_time_sec[i]), sizeof(double));
d_dump_file.read(reinterpret_cast<char *>(&doppler_l1_hz[i]), 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)
{
return false;
}
return true;
}
bool True_Observables_Reader::restart()
{
if (d_dump_file.is_open())
{
d_dump_file.clear();
d_dump_file.seekg(0, std::ios::beg);
return true;
}
return false;
}
int64_t True_Observables_Reader::num_epochs()
{
std::ifstream::pos_type size;
int number_of_vars_in_epoch = 6 * 12;
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())
{
size = tmpfile.tellg();
int64_t nepoch = size / epoch_size_bytes;
return nepoch;
}
return 0;
}
bool True_Observables_Reader::open_obs_file(std::string out_file)
{
if (d_dump_file.is_open() == false)
{
try
{
d_dump_filename = std::move(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() << '\n';
return true;
}
catch (const std::ifstream::failure &e)
{
std::cout << "Problem opening true Observables Log file: " << d_dump_filename << '\n';
return false;
}
}
else
{
return false;
}
}
True_Observables_Reader::~True_Observables_Reader()
{
try
{
if (d_dump_file.is_open() == true)
{
d_dump_file.close();
}
}
catch (const std::ifstream::failure &e)
{
std::cerr << "Problem closing true Observables dump Log file: " << d_dump_filename << '\n';
}
catch (const std::exception &e)
{
std::cerr << e.what() << '\n';
}
}

View File

@@ -0,0 +1,47 @@
/*!
* \file true_observables_reader.h
* \brief Helper file for unit testing
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_TRUE_OBSERVABLES_READER_H
#define GNSS_SDR_TRUE_OBSERVABLES_READER_H
#include <cstdint>
#include <fstream>
#include <string>
#include <vector>
class True_Observables_Reader
{
public:
~True_Observables_Reader();
bool read_binary_obs();
bool restart();
int64_t num_epochs();
bool open_obs_file(std::string out_file);
double gps_time_sec[12];
double doppler_l1_hz[12];
double acc_carrier_phase_l1_cycles[12];
double dist_m[12];
double true_dist_m[12];
double carrier_phase_l1_cycles[12];
double prn[12];
private:
std::string d_dump_filename;
std::ifstream d_dump_file;
};
#endif // GNSS_SDR_TRUE_OBSERVABLES_READER_H