1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-25 11:34:53 +00:00

Improve tracking dump saving

Dump files can now be saved anywhere, including absolute paths. If directories do not exist, they will be created.

Added new dump_mat to deactivate generation of .mat files
This commit is contained in:
Carles Fernandez
2018-10-30 00:47:12 +01:00
parent 5b3eb12998
commit 715f32f0ee
21 changed files with 308 additions and 120 deletions

View File

@@ -49,6 +49,7 @@
#include "gps_l2c_signal.h"
#include "GPS_L5.h"
#include "gps_l5_signal.h"
#include "gnss_sdr_create_directory.h"
#include <boost/lexical_cast.hpp>
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
@@ -415,6 +416,42 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl
d_carr_ph_history.resize(1);
d_code_ph_history.resize(1);
}
d_dump = trk_parameters.dump;
d_dump_mat = trk_parameters.dump_mat and d_dump;
if (d_dump)
{
d_dump_filename = trk_parameters.dump_filename;
std::string dump_path;
// Get path
if (d_dump_filename.find_last_of("/") != std::string::npos)
{
std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of("/") + 1);
dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of("/"));
d_dump_filename = dump_filename_;
}
else
{
dump_path = std::string(".");
}
if (d_dump_filename.empty())
{
d_dump_filename = "trk_channel_";
}
// remove extension if any
if (d_dump_filename.substr(1).find_last_of(".") != std::string::npos)
{
d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of("."));
}
d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename;
// create directory
if (!gnss_sdr_create_directory(dump_path))
{
std::cerr << "GNSS-SDR cannot create dump files for the tracking block. Wrong permissions?" << std::endl;
d_dump = false;
}
}
}
@@ -592,17 +629,9 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking()
LOG(WARNING) << "Exception in destructor " << ex.what();
}
}
if (trk_parameters.dump)
if (d_dump_mat)
{
if (d_channel == 0)
{
std::cout << "Writing .mat files ...";
}
save_matfile();
if (d_channel == 0)
{
std::cout << " done." << std::endl;
}
}
try
{
@@ -928,7 +957,7 @@ void dll_pll_veml_tracking::save_correlation_results()
void dll_pll_veml_tracking::log_data(bool integrating)
{
if (trk_parameters.dump)
if (d_dump)
{
// Dump results to file
float prompt_I;
@@ -1060,10 +1089,16 @@ int32_t dll_pll_veml_tracking::save_matfile()
int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
sizeof(float) * number_of_float_vars + sizeof(uint32_t);
std::ifstream dump_file;
std::string dump_filename_ = d_dump_filename;
// add channel number to the filename
dump_filename_.append(boost::lexical_cast<std::string>(d_channel));
// add extension
dump_filename_.append(".dat");
std::cout << "Generating .mat file for " << dump_filename_ << std::endl;
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
dump_file.open(trk_parameters.dump_filename.c_str(), std::ios::binary | std::ios::ate);
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
}
catch (const std::ifstream::failure &e)
{
@@ -1168,7 +1203,7 @@ int32_t dll_pll_veml_tracking::save_matfile()
// WRITE MAT FILE
mat_t *matfp;
matvar_t *matvar;
std::string filename = trk_parameters.dump_filename;
std::string filename = dump_filename_;
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
@@ -1296,17 +1331,23 @@ void dll_pll_veml_tracking::set_channel(uint32_t channel)
d_channel = channel;
LOG(INFO) << "Tracking Channel set to " << d_channel;
// ############# ENABLE DATA FILE LOG #################
if (trk_parameters.dump)
if (d_dump)
{
std::string dump_filename_ = d_dump_filename;
// add channel number to the filename
dump_filename_.append(boost::lexical_cast<std::string>(d_channel));
// add extension
dump_filename_.append(".dat");
if (!d_dump_file.is_open())
{
try
{
trk_parameters.dump_filename.append(boost::lexical_cast<std::string>(d_channel));
trk_parameters.dump_filename.append(".dat");
//trk_parameters.dump_filename.append(boost::lexical_cast<std::string>(d_channel));
//trk_parameters.dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
d_dump_file.open(trk_parameters.dump_filename.c_str(), std::ios::out | std::ios::binary);
LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << trk_parameters.dump_filename.c_str();
d_dump_file.open(dump_filename_.c_str(), std::ios::out | std::ios::binary);
LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << dump_filename_.c_str();
}
catch (const std::ifstream::failure &e)
{

View File

@@ -196,6 +196,9 @@ private:
// file dump
std::ofstream d_dump_file;
std::string d_dump_filename;
bool d_dump;
bool d_dump_mat;
};
#endif // GNSS_SDR_DLL_PLL_VEML_TRACKING_H

View File

@@ -47,6 +47,7 @@
#include "gps_l2c_signal.h"
#include "GPS_L5.h"
#include "gps_l5_signal.h"
#include "gnss_sdr_create_directory.h"
#include <boost/lexical_cast.hpp>
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
@@ -420,6 +421,42 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &
multicorrelator_fpga->set_output_vectors(d_correlator_outs, d_Prompt_Data);
d_pull_in = 0;
d_dump = trk_parameters.dump;
d_dump_mat = trk_parameters.dump_mat and d_dump;
if (d_dump)
{
d_dump_filename = trk_parameters.dump_filename;
std::string dump_path;
if (d_dump_filename.find_last_of("/") != std::string::npos)
{
std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of("/") + 1);
dump_path = d_dump_filename.substr(0, d_dump_filename.find_last_of("/"));
d_dump_filename = dump_filename_;
}
else
{
dump_path = std::string(".");
}
if (d_dump_filename.empty())
{
d_dump_filename = "trk_channel_";
}
// remove extension if any
if (d_dump_filename.substr(1).find_last_of(".") != std::string::npos)
{
d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of("."));
}
d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename;
// create directory
if (!gnss_sdr_create_directory(dump_path))
{
std::cerr << "GNSS-SDR cannot create dump files for the tracking block. Wrong permissions?" << std::endl;
d_dump = false;
};
}
}
@@ -583,17 +620,9 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga()
LOG(WARNING) << "Exception in destructor " << ex.what();
}
}
if (trk_parameters.dump)
if (d_dump_mat)
{
if (d_channel == 0)
{
std::cout << "Writing .mat files ...";
}
save_matfile();
if (d_channel == 0)
{
std::cout << " done." << std::endl;
}
}
try
{
@@ -842,7 +871,7 @@ void dll_pll_veml_tracking_fpga::save_correlation_results()
void dll_pll_veml_tracking_fpga::log_data(bool integrating)
{
if (trk_parameters.dump)
if (d_dump)
{
// Dump results to file
float prompt_I;
@@ -968,10 +997,16 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile()
int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars +
sizeof(float) * number_of_float_vars + sizeof(uint32_t);
std::ifstream dump_file;
std::string dump_filename_ = d_dump_filename;
// add channel number to the filename
dump_filename_.append(boost::lexical_cast<std::string>(d_channel));
// add extension
dump_filename_.append(".dat");
std::cout << "Generating .mat file for " << dump_filename_ << std::endl;
dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
dump_file.open(trk_parameters.dump_filename.c_str(), std::ios::binary | std::ios::ate);
dump_file.open(dump_filename_.c_str(), std::ios::binary | std::ios::ate);
}
catch (const std::ifstream::failure &e)
{
@@ -1070,7 +1105,7 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile()
// WRITE MAT FILE
mat_t *matfp;
matvar_t *matvar;
std::string filename = trk_parameters.dump_filename;
std::string filename = dump_filename_;
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
@@ -1188,17 +1223,21 @@ void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel)
multicorrelator_fpga->set_channel(d_channel);
LOG(INFO) << "Tracking Channel set to " << d_channel;
// ############# ENABLE DATA FILE LOG #################
if (trk_parameters.dump)
if (d_dump)
{
std::string dump_filename_ = d_dump_filename;
// add channel number to the filename
dump_filename_.append(boost::lexical_cast<std::string>(d_channel));
// add extension
dump_filename_.append(".dat");
if (!d_dump_file.is_open())
{
try
{
trk_parameters.dump_filename.append(boost::lexical_cast<std::string>(d_channel));
trk_parameters.dump_filename.append(".dat");
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
d_dump_file.open(trk_parameters.dump_filename.c_str(), std::ios::out | std::ios::binary);
LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << trk_parameters.dump_filename.c_str();
d_dump_file.open(dump_filename_.c_str(), std::ios::out | std::ios::binary);
LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << dump_filename_.c_str();
}
catch (const std::ifstream::failure &e)
{

View File

@@ -195,6 +195,9 @@ private:
// file dump
std::ofstream d_dump_file;
std::string d_dump_filename;
bool d_dump;
bool d_dump_mat;
// extra
int32_t d_correlation_length_samples;