diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc index a349ef753..df4caef92 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc @@ -326,8 +326,7 @@ rtklib_pvt_cc::rtklib_pvt_cc(unsigned int nchannels, bool dump, std::string dump std::cout << "GNSS-SDR can not create message queues!" << std::endl; throw new std::exception(); } - gettimeofday(&tv, NULL); - begin = tv.tv_sec * 1000000 + tv.tv_usec; + start = std::chrono::system_clock::now(); } @@ -568,9 +567,9 @@ int rtklib_pvt_cc::work (int noutput_items, gr_vector_const_void_star &input_ite << " [deg], Height= " << d_ls_pvt->d_height_m << " [m]" << std::endl; ttff_msgbuf ttff; ttff.mtype = 1; - gettimeofday(&tv, NULL); - long long int end = tv.tv_sec * 1000000 + tv.tv_usec; - ttff.ttff = static_cast(end - begin) / 1000000.0; + end = std::chrono::system_clock::now(); + std::chrono::duration elapsed_seconds = end - start; + ttff.ttff = elapsed_seconds.count(); send_sys_v_ttff_msg(ttff); first_fix = false; } diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h index a23cb4b38..a188c5809 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.h @@ -31,7 +31,7 @@ #ifndef GNSS_SDR_RTKLIB_PVT_CC_H #define GNSS_SDR_RTKLIB_PVT_CC_H -#include +#include #include #include #include @@ -143,8 +143,7 @@ private: double ttff; } ttff_msgbuf; bool send_sys_v_ttff_msg(ttff_msgbuf ttff); - struct timeval tv; - long long int begin; + std::chrono::time_point start, end; public: rtklib_pvt_cc(unsigned int nchannels, diff --git a/src/algorithms/PVT/libs/geojson_printer.cc b/src/algorithms/PVT/libs/geojson_printer.cc index 997992934..b86d01a8e 100644 --- a/src/algorithms/PVT/libs/geojson_printer.cc +++ b/src/algorithms/PVT/libs/geojson_printer.cc @@ -31,9 +31,9 @@ #include "geojson_printer.h" -#include #include #include +#include #include GeoJSON_Printer::GeoJSON_Printer() @@ -51,41 +51,39 @@ GeoJSON_Printer::~GeoJSON_Printer () bool GeoJSON_Printer::set_headers(std::string filename, bool time_tag_name) { - time_t rawtime; - struct tm * timeinfo; - time ( &rawtime ); - timeinfo = localtime ( &rawtime ); + boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); //::local_sec_clock::local_time(zone); + tm timeinfo = boost::posix_time::to_tm(pt); if (time_tag_name) { std::stringstream strm0; - const int year = timeinfo->tm_year - 100; + const int year = timeinfo.tm_year - 100; strm0 << year; - const int month = timeinfo->tm_mon + 1; + const int month = timeinfo.tm_mon + 1; if(month < 10) { strm0 << "0"; } strm0 << month; - const int day = timeinfo->tm_mday; + const int day = timeinfo.tm_mday; if(day < 10) { strm0 << "0"; } strm0 << day << "_"; - const int hour = timeinfo->tm_hour; + const int hour = timeinfo.tm_hour; if(hour < 10) { strm0 << "0"; } strm0 << hour; - const int min = timeinfo->tm_min; + const int min = timeinfo.tm_min; if(min < 10) { strm0 << "0"; } strm0 << min; - const int sec = timeinfo->tm_sec; + const int sec = timeinfo.tm_sec; if(sec < 10) { strm0 << "0"; diff --git a/src/algorithms/PVT/libs/kml_printer.cc b/src/algorithms/PVT/libs/kml_printer.cc index dd457db45..8e008d2c0 100644 --- a/src/algorithms/PVT/libs/kml_printer.cc +++ b/src/algorithms/PVT/libs/kml_printer.cc @@ -30,51 +30,47 @@ */ #include "kml_printer.h" -#include #include +#include #include using google::LogMessage; bool Kml_Printer::set_headers(std::string filename, bool time_tag_name) { + boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); + tm timeinfo = boost::posix_time::to_tm(pt); - time_t rawtime; - struct tm * timeinfo; - time ( &rawtime ); - timeinfo = localtime ( &rawtime ); if (time_tag_name) { - - std::stringstream strm0; - const int year = timeinfo->tm_year - 100; + const int year = timeinfo.tm_year - 100; strm0 << year; - const int month = timeinfo->tm_mon + 1; + const int month = timeinfo.tm_mon + 1; if(month < 10) { strm0 << "0"; } strm0 << month; - const int day = timeinfo->tm_mday; + const int day = timeinfo.tm_mday; if(day < 10) { strm0 << "0"; } strm0 << day << "_"; - const int hour = timeinfo->tm_hour; + const int hour = timeinfo.tm_hour; if(hour < 10) { strm0 << "0"; } strm0 << hour; - const int min = timeinfo->tm_min; + const int min = timeinfo.tm_min; if(min < 10) { strm0 << "0"; } strm0 << min; - const int sec = timeinfo->tm_sec; + const int sec = timeinfo.tm_sec; if(sec < 10) { strm0 << "0"; @@ -88,6 +84,7 @@ bool Kml_Printer::set_headers(std::string filename, bool time_tag_name) kml_filename = filename + ".kml"; } kml_file.open(kml_filename.c_str()); + if (kml_file.is_open()) { DLOG(INFO) << "KML printer writing on " << filename.c_str(); @@ -98,7 +95,7 @@ bool Kml_Printer::set_headers(std::string filename, bool time_tag_name) << "" << std::endl << " " << std::endl << " GNSS Track" << std::endl - << " GNSS-SDR Receiver position log file created at " << asctime (timeinfo) + << " GNSS-SDR Receiver position log file created at " << pt << " " << std::endl << "