mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 04:30:33 +00:00
Add RX time counter
This commit is contained in:
parent
5e2aa437ef
commit
1428630e79
@ -18,7 +18,31 @@
|
||||
|
||||
add_subdirectory(rtklib)
|
||||
|
||||
set(GNSS_SPLIBS_SOURCES
|
||||
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
|
||||
gps_l2c_signal.cc
|
||||
gps_l5_signal.cc
|
||||
galileo_e1_signal_processing.cc
|
||||
@ -38,7 +62,8 @@ set(GNSS_SPLIBS_SOURCES
|
||||
conjugate_cc.cc
|
||||
conjugate_sc.cc
|
||||
conjugate_ic.cc
|
||||
)
|
||||
)
|
||||
endif(ENABLE_FPGA)
|
||||
|
||||
if(OPENCL_FOUND)
|
||||
set(GNSS_SPLIBS_SOURCES ${GNSS_SPLIBS_SOURCES}
|
||||
|
126
src/algorithms/libs/gnss_sdr_time_counter.cc
Normal file
126
src/algorithms/libs/gnss_sdr_time_counter.cc
Normal 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;
|
||||
}
|
65
src/algorithms/libs/gnss_sdr_time_counter.h
Normal file
65
src/algorithms/libs/gnss_sdr_time_counter.h
Normal 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_*/
|
@ -62,8 +62,6 @@ GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configurati
|
||||
|
||||
|
||||
GNSSFlowgraph::~GNSSFlowgraph() {}
|
||||
|
||||
|
||||
void GNSSFlowgraph::start()
|
||||
{
|
||||
if (running_)
|
||||
@ -109,7 +107,7 @@ void GNSSFlowgraph::connect()
|
||||
|
||||
for (int i = 0; i < sources_count_; i++)
|
||||
{
|
||||
if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false)==false)
|
||||
if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -128,7 +126,7 @@ void GNSSFlowgraph::connect()
|
||||
// Signal Source > Signal conditioner >
|
||||
for (unsigned int i = 0; i < sig_conditioner_.size(); i++)
|
||||
{
|
||||
if (configuration_->property(sig_conditioner_.at(i)->role() + ".enable_FPGA", false)==false)
|
||||
if (configuration_->property(sig_conditioner_.at(i)->role() + ".enable_FPGA", false) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -193,7 +191,7 @@ void GNSSFlowgraph::connect()
|
||||
{
|
||||
//FPGA Accelerators do not need signal sources or conditioners
|
||||
//as the samples are feed directly to the FPGA fabric, so, if enabled, do not connect any source
|
||||
if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false)==false)
|
||||
if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -257,10 +255,11 @@ void GNSSFlowgraph::connect()
|
||||
}
|
||||
}
|
||||
DLOG(INFO) << "Signal source connected to signal conditioner";
|
||||
|
||||
bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false);
|
||||
|
||||
if (FPGA_enabled==false)
|
||||
#if ENABLE_FPGA
|
||||
|
||||
if (FPGA_enabled == false)
|
||||
{
|
||||
//connect the signal source to sample counter
|
||||
//connect the sample counter to Observables
|
||||
@ -284,17 +283,20 @@ void GNSSFlowgraph::connect()
|
||||
top_block_->disconnect_all();
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
//create a software-defined 1kHz gnss_synchro pulse for the observables block
|
||||
try
|
||||
{
|
||||
//null source
|
||||
null_source_= gr::blocks::null_source::make(sizeof(Gnss_Synchro));
|
||||
null_source_ = gr::blocks::null_source::make(sizeof(Gnss_Synchro));
|
||||
//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(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)
|
||||
{
|
||||
@ -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)
|
||||
int selected_signal_conditioner_ID;
|
||||
for (unsigned int i = 0; i < channels_count_; i++)
|
||||
{
|
||||
|
||||
|
||||
if (FPGA_enabled == false)
|
||||
{
|
||||
selected_signal_conditioner_ID = configuration_->property("Channel" + boost::lexical_cast<std::string>(i) + ".RF_channel_ID", 0);
|
||||
|
@ -49,6 +49,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if ENABLE_FPGA
|
||||
#include "gnss_sdr_time_counter.h"
|
||||
#endif
|
||||
|
||||
class GNSSBlockInterface;
|
||||
class ChannelInterface;
|
||||
@ -144,6 +147,9 @@ private:
|
||||
|
||||
std::vector<std::shared_ptr<ChannelInterface>> channels_;
|
||||
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::throttle::sptr throttle_;
|
||||
gr::top_block_sptr top_block_;
|
||||
|
Loading…
Reference in New Issue
Block a user