mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 04:00:34 +00:00
Do not produce empty files
This commit is contained in:
parent
90a539ed26
commit
fa549b09a2
@ -67,6 +67,25 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for create_directories, exists
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
|
||||
|
||||
Rtklib_Solver::Rtklib_Solver(int nchannels, std::string dump_filename, bool flag_dump_to_file, bool flag_dump_to_mat, const rtk_t &rtk)
|
||||
{
|
||||
@ -341,6 +360,7 @@ Rtklib_Solver::~Rtklib_Solver()
|
||||
{
|
||||
if (d_dump_file.is_open() == true)
|
||||
{
|
||||
auto pos = d_dump_file.tellp();
|
||||
try
|
||||
{
|
||||
d_dump_file.close();
|
||||
@ -349,6 +369,15 @@ Rtklib_Solver::~Rtklib_Solver()
|
||||
{
|
||||
LOG(WARNING) << "Exception in destructor closing the RTKLIB dump file " << ex.what();
|
||||
}
|
||||
if (pos == 0)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
if (!fs::remove(fs::path(d_dump_filename), ec))
|
||||
{
|
||||
std::cerr << "Problem removing temporary file " << d_dump_filename << '\n';
|
||||
}
|
||||
d_flag_dump_mat_enabled = false;
|
||||
}
|
||||
}
|
||||
if (d_flag_dump_mat_enabled)
|
||||
{
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include <utility> // for move
|
||||
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
@ -54,8 +56,12 @@ namespace fs = std::experimental::filesystem;
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/operations.hpp> // for create_directories, exists
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
|
||||
|
||||
@ -64,33 +70,6 @@ hybrid_observables_gs_sptr hybrid_observables_gs_make(unsigned int nchannels_in,
|
||||
return hybrid_observables_gs_sptr(new hybrid_observables_gs(nchannels_in, nchannels_out, dump, dump_mat, std::move(dump_filename)));
|
||||
}
|
||||
|
||||
void hybrid_observables_gs::msg_handler_pvt_to_observables(const pmt::pmt_t &msg)
|
||||
{
|
||||
gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler
|
||||
try
|
||||
{
|
||||
if (pmt::any_ref(msg).type() == typeid(double))
|
||||
{
|
||||
double new_rx_clock_offset_s;
|
||||
new_rx_clock_offset_s = boost::any_cast<double>(pmt::any_ref(msg));
|
||||
T_rx_offset_ms = new_rx_clock_offset_s * 1000.0;
|
||||
T_rx_TOW_ms = T_rx_TOW_ms - static_cast<int>(round(T_rx_offset_ms));
|
||||
T_rx_remnant_to_20ms = (T_rx_TOW_ms % 20);
|
||||
//d_Rx_clock_buffer.clear(); // Clear all the elements in the buffer
|
||||
for (uint32_t n = 0; n < d_nchannels_out; n++)
|
||||
{
|
||||
d_gnss_synchro_history->clear(n);
|
||||
}
|
||||
|
||||
LOG(INFO) << "Corrected new RX Time offset: " << T_rx_offset_ms << "[ms]";
|
||||
}
|
||||
}
|
||||
catch (boost::bad_any_cast &e)
|
||||
{
|
||||
LOG(WARNING) << "msg_handler_pvt_to_observables Bad any cast!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hybrid_observables_gs::hybrid_observables_gs(uint32_t nchannels_in,
|
||||
uint32_t nchannels_out,
|
||||
@ -110,7 +89,7 @@ hybrid_observables_gs::hybrid_observables_gs(uint32_t nchannels_in,
|
||||
d_nchannels_out = nchannels_out;
|
||||
d_nchannels_in = nchannels_in;
|
||||
T_rx_offset_ms = 0;
|
||||
d_gnss_synchro_history = new Gnss_circular_deque<Gnss_Synchro>(500, d_nchannels_out);
|
||||
d_gnss_synchro_history = std::make_shared<Gnss_circular_deque<Gnss_Synchro>>(500, d_nchannels_out);
|
||||
|
||||
// ############# ENABLE DATA FILE LOG #################
|
||||
if (d_dump)
|
||||
@ -169,9 +148,9 @@ hybrid_observables_gs::hybrid_observables_gs(uint32_t nchannels_in,
|
||||
|
||||
hybrid_observables_gs::~hybrid_observables_gs()
|
||||
{
|
||||
delete d_gnss_synchro_history;
|
||||
if (d_dump_file.is_open())
|
||||
{
|
||||
auto pos = d_dump_file.tellp();
|
||||
try
|
||||
{
|
||||
d_dump_file.close();
|
||||
@ -180,6 +159,15 @@ hybrid_observables_gs::~hybrid_observables_gs()
|
||||
{
|
||||
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
|
||||
}
|
||||
if (pos == 0)
|
||||
{
|
||||
errorlib::error_code ec;
|
||||
if (!fs::remove(fs::path(d_dump_filename), ec))
|
||||
{
|
||||
std::cerr << "Problem removing temporary file " << d_dump_filename << '\n';
|
||||
}
|
||||
d_dump_mat = false;
|
||||
}
|
||||
}
|
||||
if (d_dump_mat)
|
||||
{
|
||||
@ -195,6 +183,34 @@ hybrid_observables_gs::~hybrid_observables_gs()
|
||||
}
|
||||
|
||||
|
||||
void hybrid_observables_gs::msg_handler_pvt_to_observables(const pmt::pmt_t &msg)
|
||||
{
|
||||
gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler
|
||||
try
|
||||
{
|
||||
if (pmt::any_ref(msg).type() == typeid(double))
|
||||
{
|
||||
double new_rx_clock_offset_s;
|
||||
new_rx_clock_offset_s = boost::any_cast<double>(pmt::any_ref(msg));
|
||||
T_rx_offset_ms = new_rx_clock_offset_s * 1000.0;
|
||||
T_rx_TOW_ms = T_rx_TOW_ms - static_cast<int>(round(T_rx_offset_ms));
|
||||
T_rx_remnant_to_20ms = (T_rx_TOW_ms % 20);
|
||||
//d_Rx_clock_buffer.clear(); // Clear all the elements in the buffer
|
||||
for (uint32_t n = 0; n < d_nchannels_out; n++)
|
||||
{
|
||||
d_gnss_synchro_history->clear(n);
|
||||
}
|
||||
|
||||
LOG(INFO) << "Corrected new RX Time offset: " << T_rx_offset_ms << "[ms]";
|
||||
}
|
||||
}
|
||||
catch (boost::bad_any_cast &e)
|
||||
{
|
||||
LOG(WARNING) << "msg_handler_pvt_to_observables Bad any cast!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t hybrid_observables_gs::save_matfile()
|
||||
{
|
||||
// READ DUMP FILE
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <gnuradio/types.h> // for gr_vector_int
|
||||
#include <cstdint> // for int32_t
|
||||
#include <fstream> // for string, ofstream
|
||||
#include <memory> // for shared_ptr
|
||||
#include <vector> // for vector
|
||||
|
||||
class Gnss_Synchro;
|
||||
@ -95,7 +96,7 @@ private:
|
||||
std::string d_dump_filename;
|
||||
std::ofstream d_dump_file;
|
||||
boost::circular_buffer<uint64_t> d_Rx_clock_buffer; // time history
|
||||
Gnss_circular_deque<Gnss_Synchro>* d_gnss_synchro_history; // Tracking observable history
|
||||
std::shared_ptr<Gnss_circular_deque<Gnss_Synchro>> d_gnss_synchro_history; // Tracking observable history
|
||||
void msg_handler_pvt_to_observables(const pmt::pmt_t& msg);
|
||||
double compute_T_rx_s(const Gnss_Synchro& a);
|
||||
bool interp_trk_obs(Gnss_Synchro& interpolated_obs, const uint32_t& ch, const uint64_t& rx_clock);
|
||||
|
Loading…
Reference in New Issue
Block a user