2015-01-14 16:26:41 +00:00
|
|
|
/*!
|
|
|
|
* \file spir_file_signal_source.cc
|
|
|
|
* \brief Implementation of a class that reads signals samples from a SPIR file
|
|
|
|
* and adapts it to a SignalSourceInterface.
|
|
|
|
* \author Fran Fabra, 2014 fabra(at)ice.csic.es
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2015-01-14 16:26:41 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2021-02-12 18:46:19 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
2015-01-14 16:26:41 +00:00
|
|
|
*
|
2021-02-12 18:46:19 +00:00
|
|
|
* Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2015-01-14 16:26:41 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2015-01-14 16:26:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "spir_file_signal_source.h"
|
2021-02-16 13:27:46 +00:00
|
|
|
#include "gnss_sdr_string_literals.h"
|
2018-02-26 02:15:53 +00:00
|
|
|
#include <glog/logging.h>
|
2015-01-14 16:26:41 +00:00
|
|
|
|
|
|
|
|
2021-02-09 22:47:34 +00:00
|
|
|
using namespace std::string_literals;
|
|
|
|
|
2020-06-29 07:07:41 +00:00
|
|
|
SpirFileSignalSource::SpirFileSignalSource(const ConfigurationInterface* configuration,
|
2018-12-03 18:01:47 +00:00
|
|
|
const std::string& role, unsigned int in_streams, unsigned int out_streams,
|
2021-02-09 22:47:34 +00:00
|
|
|
Concurrent_Queue<pmt::pmt_t>* queue)
|
2021-02-15 22:34:48 +00:00
|
|
|
: FileSourceBase(configuration, role, "Spir_File_Signal_Source"s, queue, "int"s)
|
2015-01-14 16:26:41 +00:00
|
|
|
{
|
2021-02-12 18:46:19 +00:00
|
|
|
if (in_streams > 0)
|
2018-06-03 17:11:16 +00:00
|
|
|
{
|
|
|
|
LOG(ERROR) << "A signal source does not have an input stream";
|
|
|
|
}
|
2021-02-12 18:46:19 +00:00
|
|
|
if (out_streams > 1)
|
2018-06-03 17:11:16 +00:00
|
|
|
{
|
|
|
|
LOG(ERROR) << "This implementation only supports one output stream";
|
|
|
|
}
|
2015-01-14 16:26:41 +00:00
|
|
|
}
|
|
|
|
|
2021-02-13 01:23:10 +00:00
|
|
|
std::tuple<size_t, bool> SpirFileSignalSource::itemTypeToSize()
|
2015-01-14 16:26:41 +00:00
|
|
|
{
|
2021-02-12 18:46:19 +00:00
|
|
|
auto is_complex = false;
|
|
|
|
auto item_size = size_t(0);
|
|
|
|
|
|
|
|
if (item_type() == "int")
|
2015-01-14 16:26:41 +00:00
|
|
|
{
|
2021-02-12 18:46:19 +00:00
|
|
|
item_size = sizeof(int);
|
2015-01-14 16:26:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-12 18:46:19 +00:00
|
|
|
LOG(WARNING) << item_type() << " unsupported item type. Using int.";
|
|
|
|
item_size = sizeof(int);
|
2015-01-14 16:26:41 +00:00
|
|
|
}
|
2021-02-12 18:46:19 +00:00
|
|
|
|
|
|
|
return std::make_tuple(item_size, is_complex);
|
2015-01-14 16:26:41 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 18:46:19 +00:00
|
|
|
// This class feeds the file data through a decoder to produce samples; for all intents this is the "source"
|
|
|
|
gnss_shared_ptr<gr::block> SpirFileSignalSource::source() const { return unpack_intspir_; }
|
2015-01-14 16:26:41 +00:00
|
|
|
|
2021-02-12 18:46:19 +00:00
|
|
|
|
|
|
|
void SpirFileSignalSource::create_file_source_hook()
|
2015-01-14 16:26:41 +00:00
|
|
|
{
|
2021-02-12 18:46:19 +00:00
|
|
|
// connect the file to the decoder
|
|
|
|
unpack_intspir_ = make_unpack_intspir_1bit_samples();
|
|
|
|
DLOG(INFO) << "unpack_intspir_1bit_samples(" << unpack_intspir_->unique_id() << ")";
|
2015-01-14 16:26:41 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 18:46:19 +00:00
|
|
|
void SpirFileSignalSource::pre_connect_hook(gr::top_block_sptr top_block)
|
2015-01-14 16:26:41 +00:00
|
|
|
{
|
2021-02-12 18:46:19 +00:00
|
|
|
top_block->connect(file_source(), 0, unpack_intspir_, 0);
|
|
|
|
DLOG(INFO) << "connected file_source to unpacker";
|
2015-01-14 16:26:41 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 18:46:19 +00:00
|
|
|
void SpirFileSignalSource::post_disconnect_hook(gr::top_block_sptr top_block)
|
2015-01-14 16:26:41 +00:00
|
|
|
{
|
2021-02-12 18:46:19 +00:00
|
|
|
top_block->disconnect(file_source(), 0, unpack_intspir_, 0);
|
|
|
|
DLOG(INFO) << "disconnected file_source from unpacker";
|
2015-01-14 16:26:41 +00:00
|
|
|
}
|