From 2d347740d075936daa3413380d244a5fa90bcc36 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 3 Apr 2018 23:21:44 +0200 Subject: [PATCH] Fix time reporting --- .../libs/gnss_sdr_sample_counter.cc | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/algorithms/libs/gnss_sdr_sample_counter.cc b/src/algorithms/libs/gnss_sdr_sample_counter.cc index 7c52d6496..ac4ac67cc 100644 --- a/src/algorithms/libs/gnss_sdr_sample_counter.cc +++ b/src/algorithms/libs/gnss_sdr_sample_counter.cc @@ -32,11 +32,14 @@ #include "gnss_sdr_sample_counter.h" #include "gnss_synchro.h" #include +#include +#include +#include gnss_sdr_sample_counter::gnss_sdr_sample_counter(double _fs) : gr::sync_decimator("sample_counter", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), - static_cast(floor(_fs * 0.001))) + static_cast(std::floor(_fs * 0.001))) { message_port_register_out(pmt::mp("sample_counter")); set_max_noutput_items(1); @@ -45,8 +48,8 @@ gnss_sdr_sample_counter::gnss_sdr_sample_counter(double _fs) : gr::sync_decimato current_m = 0; current_h = 0; current_days = 0; - report_interval_ms = 1000; //default reporting 1 second - flag_enable_send_msg = false; //enable it for reporting time with asynchronous message + report_interval_ms = 1000; // default reporting 1 second + flag_enable_send_msg = false; // enable it for reporting time with asynchronous message flag_m = false; flag_h = false; flag_days = false; @@ -90,21 +93,35 @@ int gnss_sdr_sample_counter::work(int noutput_items __attribute__((unused)), if (flag_days) { - std::cout << "Current receiver time: " << current_days << " [days] " << current_h << " [h] " << current_m << " [min] " << current_s << " [s]" << std::endl; - } - else if (flag_h) - { - std::cout << "Current receiver time: " << current_h << " [h] " << current_m << " [min] " << current_s << " [s]" << std::endl; - } - else if (flag_m) - { - std::cout << "Current receiver time: " << current_m << " [min] " << current_s << " [s]" << std::endl; + std::string day; + if (current_days == 1) + { + day = " day "; + } + else + { + day = " days "; + } + std::cout << "Current receiver time: " << current_days << day << current_h << " h " << current_m << " min " << current_s << " s" << std::endl; } else { - std::cout << "Current receiver time: " << current_s << " [s]" << std::endl; + if (flag_h) + { + std::cout << "Current receiver time: " << current_h << " h " << current_m << " min " << current_s << " s" << std::endl; + } + else + { + if (flag_m) + { + std::cout << "Current receiver time: " << current_m << " min " << current_s << " s" << std::endl; + } + else + { + std::cout << "Current receiver time: " << current_s << " s" << std::endl; + } + } } - if (flag_enable_send_msg) { message_port_pub(pmt::mp("receiver_time"), pmt::from_double(static_cast(current_T_rx_ms) / 1000.0));