mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 20:20:35 +00:00
Added experimental FileTimestampSignalSource to generate timestamp information using stream tags
This commit is contained in:
parent
933d3b3228
commit
42bece2dd4
@ -65,6 +65,7 @@ set(GNSS_SPLIBS_HEADERS
|
|||||||
pass_through.h
|
pass_through.h
|
||||||
short_x2_to_cshort.h
|
short_x2_to_cshort.h
|
||||||
gnss_sdr_string_literals.h
|
gnss_sdr_string_literals.h
|
||||||
|
gnss_time.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if(ENABLE_OPENCL)
|
if(ENABLE_OPENCL)
|
||||||
|
43
src/algorithms/libs/gnss_time.h
Normal file
43
src/algorithms/libs/gnss_time.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/* -------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 (see AUTHORS file for a list of contributors)
|
||||||
|
*
|
||||||
|
* GNSS-SDR-SIM is a software defined Global Navigation
|
||||||
|
* Satellite Systems Simulator
|
||||||
|
*
|
||||||
|
* This file is part of GNSS-SDR-SIM.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GNSS_SDR_SIM_GNSS_TIME_H
|
||||||
|
#define GNSS_SDR_SIM_GNSS_TIME_H
|
||||||
|
|
||||||
|
#include <boost/serialization/nvp.hpp>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
class GnssTime
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//time_t time; /* time (s) expressed by standard time_t */
|
||||||
|
int week; /*!< GPS week number (since January 1980) */
|
||||||
|
//double sec; /*!< second inside the GPS \a week */
|
||||||
|
int tow_ms; /* time of week [ms]*/
|
||||||
|
|
||||||
|
template <class Archive>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file.
|
||||||
|
*/
|
||||||
|
inline void serialize(Archive& archive, const uint32_t version)
|
||||||
|
{
|
||||||
|
using boost::serialization::make_nvp;
|
||||||
|
if (version)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
archive& make_nvp("week", week);
|
||||||
|
archive& make_nvp("tow_ms", tow_ms);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -112,6 +112,7 @@ set(SIGNAL_SOURCE_ADAPTER_SOURCES
|
|||||||
labsat_signal_source.cc
|
labsat_signal_source.cc
|
||||||
two_bit_cpx_file_signal_source.cc
|
two_bit_cpx_file_signal_source.cc
|
||||||
two_bit_packed_file_signal_source.cc
|
two_bit_packed_file_signal_source.cc
|
||||||
|
file_timestamp_signal_source.cc
|
||||||
${OPT_DRIVER_SOURCES}
|
${OPT_DRIVER_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -128,6 +129,7 @@ set(SIGNAL_SOURCE_ADAPTER_HEADERS
|
|||||||
labsat_signal_source.h
|
labsat_signal_source.h
|
||||||
two_bit_cpx_file_signal_source.h
|
two_bit_cpx_file_signal_source.h
|
||||||
two_bit_packed_file_signal_source.h
|
two_bit_packed_file_signal_source.h
|
||||||
|
file_timestamp_signal_source.h
|
||||||
${OPT_DRIVER_HEADERS}
|
${OPT_DRIVER_HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
/*!
|
||||||
|
* \file file_timestamp_signal_source.h
|
||||||
|
* \brief This class reads samples stored in a file and generate stream tags with its timestamp information stored in separated file
|
||||||
|
* \author Javier Arribas, jarribas(at)cttc.es
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "file_timestamp_signal_source.h"
|
||||||
|
#include "gnss_sdr_string_literals.h"
|
||||||
|
#include "gnss_sdr_timestamp.h"
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
using namespace std::string_literals;
|
||||||
|
|
||||||
|
FileTimestampSignalSource::FileTimestampSignalSource(const ConfigurationInterface* configuration,
|
||||||
|
const std::string& role, unsigned int in_streams, unsigned int out_streams,
|
||||||
|
Concurrent_Queue<pmt::pmt_t>* queue)
|
||||||
|
: FileSourceBase(configuration, role, "File_Timestamp_Signal_Source"s, queue, "byte"s), timestamp_file_(configuration->property(role + ".timestamp_filename"s, "../data/example_capture_timestamp.dat"s))
|
||||||
|
{
|
||||||
|
if (in_streams > 0)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "A signal source does not have an input stream";
|
||||||
|
}
|
||||||
|
if (out_streams > 1)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "This implementation only supports one output stream";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gnss_shared_ptr<gr::block> FileTimestampSignalSource::source() const { return timestamp_block_; }
|
||||||
|
|
||||||
|
|
||||||
|
void FileTimestampSignalSource::create_file_source_hook()
|
||||||
|
{
|
||||||
|
timestamp_block_ = gnss_sdr_make_Timestamp(
|
||||||
|
std::get<0>(itemTypeToSize()),
|
||||||
|
timestamp_file_);
|
||||||
|
DLOG(INFO) << "timestamp_block_(" << timestamp_block_->unique_id() << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileTimestampSignalSource::pre_connect_hook(gr::top_block_sptr top_block)
|
||||||
|
{
|
||||||
|
top_block->connect(file_source(), 0, timestamp_block_, 0);
|
||||||
|
DLOG(INFO) << "connected file_source to timestamp_block_";
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileTimestampSignalSource::pre_disconnect_hook(gr::top_block_sptr top_block)
|
||||||
|
{
|
||||||
|
top_block->disconnect(file_source(), 0, timestamp_block_, 0);
|
||||||
|
DLOG(INFO) << "disconnected file_source from timestamp_block_";
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*!
|
||||||
|
* \file file_timestamp_signal_source.h
|
||||||
|
* \brief This class reads samples stored in a file and generate stream tags with its timestamp information stored in separated file
|
||||||
|
* \author Javier Arribas, jarribas(at)cttc.es
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GNSS_SDR_FILE_TIMESTAMP_SIGNAL_SOURCE_H
|
||||||
|
#define GNSS_SDR_FILE_TIMESTAMP_SIGNAL_SOURCE_H
|
||||||
|
|
||||||
|
#include "configuration_interface.h"
|
||||||
|
#include "file_source_base.h"
|
||||||
|
#include "gnss_sdr_timestamp.h"
|
||||||
|
|
||||||
|
/** \addtogroup Signal_Source
|
||||||
|
* \{ */
|
||||||
|
/** \addtogroup Signal_Source_adapters
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Class that reads signals samples from a file
|
||||||
|
* and adapts it to a SignalSourceInterface
|
||||||
|
*/
|
||||||
|
class FileTimestampSignalSource : public FileSourceBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FileTimestampSignalSource(const ConfigurationInterface* configuration, const std::string& role,
|
||||||
|
unsigned int in_streams, unsigned int out_streams,
|
||||||
|
Concurrent_Queue<pmt::pmt_t>* queue);
|
||||||
|
|
||||||
|
~FileTimestampSignalSource() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//std::tuple<size_t, bool> itemTypeToSize() override;
|
||||||
|
//double packetsPerSample() const override;
|
||||||
|
gnss_shared_ptr<gr::block> source() const override;
|
||||||
|
void create_file_source_hook() override;
|
||||||
|
void pre_connect_hook(gr::top_block_sptr top_block) override;
|
||||||
|
void pre_disconnect_hook(gr::top_block_sptr top_block) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
gnss_shared_ptr<Gnss_Sdr_Timestamp> timestamp_block_;
|
||||||
|
std::string timestamp_file_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
/** \} */
|
||||||
|
#endif // GNSS_SDR_FILE_TIMESTAMP_SIGNAL_SOURCE_H
|
@ -25,6 +25,7 @@ set(SIGNAL_SOURCE_LIB_SOURCES
|
|||||||
rtl_tcp_commands.cc
|
rtl_tcp_commands.cc
|
||||||
rtl_tcp_dongle_info.cc
|
rtl_tcp_dongle_info.cc
|
||||||
gnss_sdr_valve.cc
|
gnss_sdr_valve.cc
|
||||||
|
gnss_sdr_timestamp.cc
|
||||||
${OPT_SIGNAL_SOURCE_LIB_SOURCES}
|
${OPT_SIGNAL_SOURCE_LIB_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ target_include_directories(signal_source_libs
|
|||||||
PUBLIC
|
PUBLIC
|
||||||
${CMAKE_SOURCE_DIR}/src/core/receiver
|
${CMAKE_SOURCE_DIR}/src/core/receiver
|
||||||
${CMAKE_SOURCE_DIR}/src/core/interfaces
|
${CMAKE_SOURCE_DIR}/src/core/interfaces
|
||||||
|
${CMAKE_SOURCE_DIR}/src/algorithms/libs
|
||||||
)
|
)
|
||||||
|
|
||||||
if(GNURADIO_USES_STD_POINTERS)
|
if(GNURADIO_USES_STD_POINTERS)
|
||||||
|
114
src/algorithms/signal_source/libs/gnss_sdr_timestamp.cc
Normal file
114
src/algorithms/signal_source/libs/gnss_sdr_timestamp.cc
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/*!
|
||||||
|
* \file gnss_sdr_timestamp.h
|
||||||
|
* \brief GNURadio block that adds to sample stream timestamp metadata information stored on a sepparated file
|
||||||
|
* \author Javier Arribas, 2021. jarribas(at)cttc.es
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "gnss_sdr_timestamp.h"
|
||||||
|
#include "command_event.h"
|
||||||
|
#include <glog/logging.h> // for LOG
|
||||||
|
#include <gnuradio/io_signature.h> // for io_signature
|
||||||
|
#include <pmt/pmt.h> // for make_any
|
||||||
|
#include <pmt/pmt_sugar.h> // for mp
|
||||||
|
#include <algorithm> // for min
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring> // for memcpy
|
||||||
|
|
||||||
|
Gnss_Sdr_Timestamp::Gnss_Sdr_Timestamp(size_t sizeof_stream_item,
|
||||||
|
std::string timestamp_file) : gr::sync_block("Timestamp",
|
||||||
|
gr::io_signature::make(1, 20, sizeof_stream_item),
|
||||||
|
gr::io_signature::make(1, 20, sizeof_stream_item)),
|
||||||
|
d_timefile(timestamp_file)
|
||||||
|
{
|
||||||
|
get_next_timetag = true;
|
||||||
|
next_timetag_samplecount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gnss_shared_ptr<Gnss_Sdr_Timestamp> gnss_sdr_make_Timestamp(size_t sizeof_stream_item, std::string timestamp_file)
|
||||||
|
{
|
||||||
|
gnss_shared_ptr<Gnss_Sdr_Timestamp> Timestamp_(new Gnss_Sdr_Timestamp(sizeof_stream_item, timestamp_file));
|
||||||
|
return Timestamp_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Gnss_Sdr_Timestamp::read_next_timetag()
|
||||||
|
{
|
||||||
|
d_timefilestream.read(reinterpret_cast<char*>(&next_timetag_samplecount), sizeof(uint64_t));
|
||||||
|
if (!d_timefilestream)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
d_timefilestream.read(reinterpret_cast<char*>(&next_timetag.week), sizeof(int32_t));
|
||||||
|
if (!d_timefilestream)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
d_timefilestream.read(reinterpret_cast<char*>(&next_timetag.tow_ms), sizeof(int32_t));
|
||||||
|
if (!d_timefilestream)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Gnss_Sdr_Timestamp::start()
|
||||||
|
{
|
||||||
|
d_timefilestream.open(d_timefile, std::ios::in | std::ios::binary);
|
||||||
|
|
||||||
|
if (d_timefilestream.is_open() == false)
|
||||||
|
{
|
||||||
|
std::cout << "ERROR: Could not open timestamp file: " << d_timefile << "\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t Gnss_Sdr_Timestamp::uint64diff(uint64_t first, uint64_t second)
|
||||||
|
{
|
||||||
|
uint64_t abs_diff = (first > second) ? (first - second) : (second - first);
|
||||||
|
assert(abs_diff <= INT64_MAX);
|
||||||
|
return (first > second) ? (int64_t)abs_diff : -(int64_t)abs_diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Gnss_Sdr_Timestamp::work(int noutput_items,
|
||||||
|
gr_vector_const_void_star& input_items,
|
||||||
|
gr_vector_void_star& output_items)
|
||||||
|
{
|
||||||
|
// multichannel support
|
||||||
|
if (get_next_timetag == true)
|
||||||
|
{
|
||||||
|
if (read_next_timetag() == false)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
get_next_timetag = false;
|
||||||
|
}
|
||||||
|
for (size_t ch = 0; ch < output_items.size(); ch++)
|
||||||
|
{
|
||||||
|
std::memcpy(output_items[ch], input_items[ch], noutput_items * input_signature()->sizeof_stream_item(ch));
|
||||||
|
int64_t diff_samplecount = uint64diff(nitems_read(ch), next_timetag_samplecount);
|
||||||
|
if (diff_samplecount > 0 and diff_samplecount < noutput_items)
|
||||||
|
{
|
||||||
|
add_item_tag(ch, this->nitems_written(0) + diff_samplecount, pmt::mp("timetag"), pmt::make_any(next_timetag));
|
||||||
|
get_next_timetag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return noutput_items;
|
||||||
|
}
|
72
src/algorithms/signal_source/libs/gnss_sdr_timestamp.h
Normal file
72
src/algorithms/signal_source/libs/gnss_sdr_timestamp.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*!
|
||||||
|
* \file gnss_sdr_timestamp.h
|
||||||
|
* \brief GNURadio block that adds to sample stream timestamp metadata information stored on a sepparated file
|
||||||
|
* \author Javier Arribas, 2021. jarribas(at)cttc.es
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GNSS_SDR_GNSS_SDR_TIMESTAMP_H
|
||||||
|
#define GNSS_SDR_GNSS_SDR_TIMESTAMP_H
|
||||||
|
|
||||||
|
#include "gnss_block_interface.h"
|
||||||
|
#include "gnss_time.h"
|
||||||
|
#include <gnuradio/sync_block.h> // for sync_block
|
||||||
|
#include <gnuradio/types.h> // for gr_vector_const_void_star
|
||||||
|
#include <pmt/pmt.h>
|
||||||
|
#include <cstddef> // for size_t
|
||||||
|
#include <cstdint>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
/** \addtogroup Signal_Source
|
||||||
|
* \{ */
|
||||||
|
/** \addtogroup Signal_Source_libs
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
|
||||||
|
class Gnss_Sdr_Timestamp;
|
||||||
|
|
||||||
|
gnss_shared_ptr<Gnss_Sdr_Timestamp> gnss_sdr_make_Timestamp(
|
||||||
|
size_t sizeof_stream_item,
|
||||||
|
std::string timestamp_file);
|
||||||
|
|
||||||
|
|
||||||
|
class Gnss_Sdr_Timestamp : public gr::sync_block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int work(int noutput_items,
|
||||||
|
gr_vector_const_void_star& input_items,
|
||||||
|
gr_vector_void_star& output_items);
|
||||||
|
bool start();
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend gnss_shared_ptr<Gnss_Sdr_Timestamp> gnss_sdr_make_Timestamp(
|
||||||
|
size_t sizeof_stream_item,
|
||||||
|
std::string timestamp_file);
|
||||||
|
|
||||||
|
Gnss_Sdr_Timestamp(size_t sizeof_stream_item,
|
||||||
|
std::string timestamp_file);
|
||||||
|
|
||||||
|
int64_t uint64diff(uint64_t first, uint64_t second);
|
||||||
|
bool read_next_timetag();
|
||||||
|
std::string d_timefile;
|
||||||
|
std::fstream d_timefilestream;
|
||||||
|
GnssTime next_timetag;
|
||||||
|
uint64_t next_timetag_samplecount;
|
||||||
|
bool get_next_timetag;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
/** \} */
|
||||||
|
#endif // GNSS_SDR_GNSS_SDR_TIMESTAMP_H
|
@ -38,6 +38,7 @@
|
|||||||
#include "configuration_interface.h"
|
#include "configuration_interface.h"
|
||||||
#include "direct_resampler_conditioner.h"
|
#include "direct_resampler_conditioner.h"
|
||||||
#include "file_signal_source.h"
|
#include "file_signal_source.h"
|
||||||
|
#include "file_timestamp_signal_source.h"
|
||||||
#include "fir_filter.h"
|
#include "fir_filter.h"
|
||||||
#include "freq_xlating_fir_filter.h"
|
#include "freq_xlating_fir_filter.h"
|
||||||
#include "galileo_e1_dll_pll_veml_tracking.h"
|
#include "galileo_e1_dll_pll_veml_tracking.h"
|
||||||
@ -654,6 +655,12 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock(
|
|||||||
out_streams, queue);
|
out_streams, queue);
|
||||||
block = std::move(block_);
|
block = std::move(block_);
|
||||||
}
|
}
|
||||||
|
else if (implementation == "File_Timestamp_Signal_Source")
|
||||||
|
{
|
||||||
|
std::unique_ptr<GNSSBlockInterface> block_ = std::make_unique<FileTimestampSignalSource>(configuration, role, in_streams,
|
||||||
|
out_streams, queue);
|
||||||
|
block = std::move(block_);
|
||||||
|
}
|
||||||
else if (implementation == "Multichannel_File_Signal_Source")
|
else if (implementation == "Multichannel_File_Signal_Source")
|
||||||
{
|
{
|
||||||
std::unique_ptr<GNSSBlockInterface> block_ = std::make_unique<MultichannelFileSignalSource>(configuration, role, in_streams,
|
std::unique_ptr<GNSSBlockInterface> block_ = std::make_unique<MultichannelFileSignalSource>(configuration, role, in_streams,
|
||||||
|
Loading…
Reference in New Issue
Block a user