From 18cd7daa09bd1f09e91b739d613b37c50da3b710 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 11 Aug 2017 05:18:38 +0200 Subject: [PATCH] Eliminate ctime library. Replaced by chrono or boost::date_time --- .../PVT/gnuradio_blocks/rtklib_pvt_cc.cc | 9 +- .../PVT/gnuradio_blocks/rtklib_pvt_cc.h | 5 +- src/algorithms/PVT/libs/geojson_printer.cc | 20 ++- src/algorithms/PVT/libs/kml_printer.cc | 25 ++- src/algorithms/PVT/libs/rtcm_printer.cc | 20 ++- src/algorithms/libs/gnss_sdr_valve.cc | 5 + src/algorithms/libs/gnss_sdr_valve.h | 5 +- src/algorithms/libs/rtklib/rtklib.h | 11 +- .../volk_gnsssdr/lib/qa_utils.cc | 11 +- src/main/main.cc | 21 ++- src/tests/system-tests/ttff_gps_l1.cc | 28 ++-- .../arithmetic/code_generation_test.cc | 50 +++--- .../arithmetic/complex_carrier_test.cc | 43 +++-- .../unit-tests/arithmetic/conjugate_test.cc | 54 +++---- .../unit-tests/arithmetic/fft_length_test.cc | 13 +- .../arithmetic/magnitude_squared_test.cc | 56 +++---- .../unit-tests/arithmetic/multiply_test.cc | 80 +++++---- ...8ms_ambiguous_acquisition_gsoc2013_test.cc | 32 ++-- ...cps_ambiguous_acquisition_gsoc2013_test.cc | 31 ++-- ...e1_pcps_ambiguous_acquisition_gsoc_test.cc | 31 ++-- ...ileo_e1_pcps_ambiguous_acquisition_test.cc | 31 ++-- ...wsr_ambiguous_acquisition_gsoc2013_test.cc | 30 ++-- ...ync_ambiguous_acquisition_gsoc2014_test.cc | 37 ++--- ...ong_ambiguous_acquisition_gsoc2013_test.cc | 44 ++--- ...cps_acquisition_gsoc2014_gensource_test.cc | 41 ++--- ...ps_l1_ca_pcps_acquisition_gsoc2013_test.cc | 32 ++-- .../gps_l1_ca_pcps_acquisition_test.cc | 31 ++-- .../gps_l1_ca_pcps_acquisition_test_fpga.cc | 42 ++--- ...s_multithread_acquisition_gsoc2013_test.cc | 30 ++-- ...a_pcps_opencl_acquisition_gsoc2013_test.cc | 30 ++-- ...cps_quicksync_acquisition_gsoc2014_test.cc | 35 ++-- ..._ca_pcps_tong_acquisition_gsoc2013_test.cc | 31 ++-- .../gps_l2_m_pcps_acquisition_test.cc | 31 ++-- .../filter/fir_filter_test.cc | 80 +++++---- .../observables/hybrid_observables_test.cc | 45 +++--- .../direct_resampler_conditioner_cc_test.cc | 16 +- .../gps_l1_ca_telemetry_decoder_test.cc | 24 ++- .../tracking/cpu_multicorrelator_test.cc | 116 ++++++------- .../galileo_e1_dll_pll_veml_tracking_test.cc | 30 ++-- .../tracking/galileo_e5a_tracking_test.cc | 16 +- .../gps_l1_ca_dll_pll_tracking_test.cc | 2 +- .../gps_l1_ca_dll_pll_tracking_test_fpga.cc | 152 ++++++++---------- .../gps_l2_m_dll_pll_tracking_test.cc | 17 +- .../tracking/gpu_multicorrelator_test.cc | 130 ++++++++------- src/utils/front-end-cal/front_end_cal.cc | 1 - src/utils/front-end-cal/main.cc | 15 +- 46 files changed, 759 insertions(+), 880 deletions(-) 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 << "