1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 12:40:35 +00:00

Add RX time counter

This commit is contained in:
Antonio Ramos 2018-04-13 15:27:14 +02:00
parent 5e2aa437ef
commit 1428630e79
5 changed files with 412 additions and 163 deletions

View File

@ -18,6 +18,30 @@
add_subdirectory(rtklib) add_subdirectory(rtklib)
if(ENABLE_FPGA)
set(GNSS_SPLIBS_SOURCES
gps_l2c_signal.cc
gps_l5_signal.cc
galileo_e1_signal_processing.cc
gnss_sdr_valve.cc
gnss_sdr_sample_counter.cc
gnss_sdr_time_counter.cc
gnss_signal_processing.cc
gps_sdr_signal_processing.cc
glonass_l1_signal_processing.cc
glonass_l2_signal_processing.cc
pass_through.cc
galileo_e5_signal_processing.cc
complex_byte_to_float_x2.cc
byte_x2_to_complex_byte.cc
cshort_to_float_x2.cc
short_x2_to_cshort.cc
complex_float_to_complex_byte.cc
conjugate_cc.cc
conjugate_sc.cc
conjugate_ic.cc
)
else(ENABLE_FPGA)
set(GNSS_SPLIBS_SOURCES set(GNSS_SPLIBS_SOURCES
gps_l2c_signal.cc gps_l2c_signal.cc
gps_l5_signal.cc gps_l5_signal.cc
@ -39,6 +63,7 @@ set(GNSS_SPLIBS_SOURCES
conjugate_sc.cc conjugate_sc.cc
conjugate_ic.cc conjugate_ic.cc
) )
endif(ENABLE_FPGA)
if(OPENCL_FOUND) if(OPENCL_FOUND)
set(GNSS_SPLIBS_SOURCES ${GNSS_SPLIBS_SOURCES} set(GNSS_SPLIBS_SOURCES ${GNSS_SPLIBS_SOURCES}

View File

@ -0,0 +1,126 @@
/*!
* \file gnss_sdr_time_counter.cc
* \brief Simple block to report the current receiver time based on the output of the tracking or telemetry blocks
* \author Antonio Ramos 2018. antonio.ramos(at)gmail.com
*
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#include "gnss_sdr_time_counter.h"
#include "gnss_synchro.h"
#include <gnuradio/io_signature.h>
#include <cmath>
#include <iostream>
#include <string>
gnss_sdr_time_counter::gnss_sdr_time_counter() : gr::block("time_counter",
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{
set_max_noutput_items(1);
current_T_rx_ms = 0;
current_s = 0;
current_m = 0;
current_h = 0;
current_days = 0;
report_interval_ms = 1000; // default reporting 1 second
flag_m = false;
flag_h = false;
flag_days = false;
}
gnss_sdr_time_counter_sptr gnss_sdr_make_time_counter()
{
gnss_sdr_time_counter_sptr counter_(new gnss_sdr_time_counter());
return counter_;
}
int gnss_sdr_time_counter::general_work(int noutput_items __attribute__((unused)),
gr_vector_const_void_star &input_items __attribute__((unused)),
gr_vector_void_star &output_items)
{
Gnss_Synchro *out = reinterpret_cast<Gnss_Synchro *>(output_items[0]);
const Gnss_Synchro *in = reinterpret_cast<const Gnss_Synchro *>(input_items[0]);
out[0] = in[0];
if ((current_T_rx_ms % report_interval_ms) == 0)
{
current_s++;
if ((current_s % 60) == 0)
{
current_s = 0;
current_m++;
flag_m = true;
if ((current_m % 60) == 0)
{
current_m = 0;
current_h++;
flag_h = true;
if ((current_h % 24) == 0)
{
current_h = 0;
current_days++;
flag_days = true;
}
}
}
if (flag_days)
{
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
{
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;
}
}
}
}
current_T_rx_ms++;
return 1;
}

View File

@ -0,0 +1,65 @@
/*!
* \file gnss_sdr_time_counter.h
* \brief Simple block to report the current receiver time based on the output of the tracking or telemetry blocks
* \author Antonio Ramos 2018. antonio.ramosdet(at)gmail.com
*
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
*
* GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_TIME_COUNTER_H_
#define GNSS_SDR_TIME_COUNTER_H_
#include <gnuradio/block.h>
#include <boost/shared_ptr.hpp>
class gnss_sdr_time_counter;
typedef boost::shared_ptr<gnss_sdr_time_counter> gnss_sdr_time_counter_sptr;
gnss_sdr_time_counter_sptr gnss_sdr_make_time_counter();
class gnss_sdr_time_counter : public gr::block
{
private:
gnss_sdr_time_counter();
long long int current_T_rx_ms; // Receiver time in ms since the beginning of the run
unsigned int current_s; // Receiver time in seconds, modulo 60
bool flag_m; // True if the receiver has been running for at least 1 minute
unsigned int current_m; // Receiver time in minutes, modulo 60
bool flag_h; // True if the receiver has been running for at least 1 hour
unsigned int current_h; // Receiver time in hours, modulo 24
bool flag_days; // True if the receiver has been running for at least 1 day
unsigned int current_days; // Receiver time in days since the beginning of the run
int report_interval_ms;
public:
friend gnss_sdr_time_counter_sptr gnss_sdr_make_time_counter();
int general_work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif /*GNSS_SDR_SAMPLE_COUNTER_H_*/

View File

@ -62,8 +62,6 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configurati
GNSSFlowgraph::~GNSSFlowgraph() {} GNSSFlowgraph::~GNSSFlowgraph() {}
void GNSSFlowgraph::start() void GNSSFlowgraph::start()
{ {
if (running_) if (running_)
@ -257,9 +255,10 @@ void GNSSFlowgraph::connect()
} }
} }
DLOG(INFO) << "Signal source connected to signal conditioner"; DLOG(INFO) << "Signal source connected to signal conditioner";
bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false);
#if ENABLE_FPGA
if (FPGA_enabled == false) if (FPGA_enabled == false)
{ {
//connect the signal source to sample counter //connect the signal source to sample counter
@ -284,7 +283,9 @@ void GNSSFlowgraph::connect()
top_block_->disconnect_all(); top_block_->disconnect_all();
return; return;
} }
}else{ }
else
{
//create a software-defined 1kHz gnss_synchro pulse for the observables block //create a software-defined 1kHz gnss_synchro pulse for the observables block
try try
{ {
@ -292,9 +293,10 @@ void GNSSFlowgraph::connect()
null_source_ = gr::blocks::null_source::make(sizeof(Gnss_Synchro)); null_source_ = gr::blocks::null_source::make(sizeof(Gnss_Synchro));
//throttle 1kHz //throttle 1kHz
throttle_ = gr::blocks::throttle::make(sizeof(Gnss_Synchro), 1000); // 1000 samples per second (1kHz) throttle_ = gr::blocks::throttle::make(sizeof(Gnss_Synchro), 1000); // 1000 samples per second (1kHz)
time_counter_ = gnss_sdr_make_time_counter();
top_block_->connect(null_source_, 0, throttle_, 0); top_block_->connect(null_source_, 0, throttle_, 0);
top_block_->connect(throttle_, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse top_block_->connect(throttle_, 0, time_counter_, 0);
top_block_->connect(time_counter_, 0, observables_->get_left_block(), channels_count_);
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
@ -305,12 +307,37 @@ void GNSSFlowgraph::connect()
} }
} }
#else
//connect the signal source to sample counter
//connect the sample counter to Observables
try
{
double fs = static_cast<double>(configuration_->property("GNSS-SDR.internal_fs_sps", 0));
if (fs == 0.0)
{
LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file";
std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl;
throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration"));
}
ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0));
top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0);
top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse
}
catch (const std::exception& e)
{
LOG(WARNING) << "Can't connect sample counter";
LOG(ERROR) << e.what();
top_block_->disconnect_all();
return;
}
#endif
// Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID) // Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID)
int selected_signal_conditioner_ID; int selected_signal_conditioner_ID;
for (unsigned int i = 0; i < channels_count_; i++) for (unsigned int i = 0; i < channels_count_; i++)
{ {
if (FPGA_enabled == false) if (FPGA_enabled == false)
{ {
selected_signal_conditioner_ID = configuration_->property("Channel" + boost::lexical_cast<std::string>(i) + ".RF_channel_ID", 0); selected_signal_conditioner_ID = configuration_->property("Channel" + boost::lexical_cast<std::string>(i) + ".RF_channel_ID", 0);

View File

@ -49,6 +49,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
#if ENABLE_FPGA
#include "gnss_sdr_time_counter.h"
#endif
class GNSSBlockInterface; class GNSSBlockInterface;
class ChannelInterface; class ChannelInterface;
@ -144,6 +147,9 @@ private:
std::vector<std::shared_ptr<ChannelInterface>> channels_; std::vector<std::shared_ptr<ChannelInterface>> channels_;
gnss_sdr_sample_counter_sptr ch_out_sample_counter; gnss_sdr_sample_counter_sptr ch_out_sample_counter;
#if ENABLE_FPGA
gnss_sdr_time_counter_sptr time_counter_;
#endif
gr::blocks::null_source::sptr null_source_; gr::blocks::null_source::sptr null_source_;
gr::blocks::throttle::sptr throttle_; gr::blocks::throttle::sptr throttle_;
gr::top_block_sptr top_block_; gr::top_block_sptr top_block_;