2011-10-01 18:45:20 +00:00
|
|
|
/*!
|
|
|
|
* \file pass_through.cc
|
2011-12-28 21:36:45 +00:00
|
|
|
* \brief Implementation of a block that just puts its input in its
|
|
|
|
* output.
|
2011-10-01 18:45:20 +00:00
|
|
|
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
|
|
|
|
*
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2011-10-01 18:45:20 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2011-10-01 18:45:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pass_through.h"
|
2018-02-26 02:15:53 +00:00
|
|
|
#include "configuration_interface.h"
|
2011-10-01 18:45:20 +00:00
|
|
|
#include <glog/logging.h>
|
2019-03-05 07:59:04 +00:00
|
|
|
#include <gnuradio/gr_complex.h>
|
|
|
|
#include <volk/volk_complex.h>
|
2019-03-05 11:33:54 +00:00
|
|
|
#include <cstdint> // for int8_t
|
2019-03-05 07:59:04 +00:00
|
|
|
#include <ostream> // for operator<<
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2019-03-05 11:33:54 +00:00
|
|
|
|
2020-06-29 07:07:41 +00:00
|
|
|
Pass_Through::Pass_Through(const ConfigurationInterface* configuration, const std::string& role,
|
2018-03-03 01:03:39 +00:00
|
|
|
unsigned int in_streams,
|
|
|
|
unsigned int out_streams) : role_(role),
|
|
|
|
in_streams_(in_streams),
|
|
|
|
out_streams_(out_streams)
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2020-07-09 22:37:55 +00:00
|
|
|
const std::string default_item_type("gr_complex");
|
2021-01-26 15:11:41 +00:00
|
|
|
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
2017-11-17 08:21:03 +00:00
|
|
|
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
|
2015-02-26 17:24:06 +00:00
|
|
|
|
2018-12-03 11:52:17 +00:00
|
|
|
if (item_type_ == "float")
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
|
|
|
item_size_ = sizeof(float);
|
|
|
|
}
|
2018-12-03 11:52:17 +00:00
|
|
|
else if (item_type_ == "gr_complex")
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
|
|
|
item_size_ = sizeof(gr_complex);
|
2018-03-03 01:03:39 +00:00
|
|
|
if (inverted_spectrum)
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
|
|
|
conjugate_cc_ = make_conjugate_cc();
|
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
2020-07-10 20:06:29 +00:00
|
|
|
else if ((item_type_ == "short") || (item_type_ == "ishort"))
|
2015-02-26 17:24:06 +00:00
|
|
|
{
|
|
|
|
item_size_ = sizeof(int16_t);
|
|
|
|
}
|
2018-12-03 11:52:17 +00:00
|
|
|
else if (item_type_ == "cshort")
|
2015-02-04 00:11:20 +00:00
|
|
|
{
|
|
|
|
item_size_ = sizeof(lv_16sc_t);
|
2018-03-03 01:03:39 +00:00
|
|
|
if (inverted_spectrum)
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
|
|
|
conjugate_sc_ = make_conjugate_sc();
|
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
2020-07-10 20:06:29 +00:00
|
|
|
else if ((item_type_ == "byte") || (item_type_ == "ibyte"))
|
2015-02-26 17:24:06 +00:00
|
|
|
{
|
|
|
|
item_size_ = sizeof(int8_t);
|
|
|
|
}
|
2018-12-03 11:52:17 +00:00
|
|
|
else if (item_type_ == "cbyte")
|
2015-01-08 18:49:59 +00:00
|
|
|
{
|
2015-02-04 00:11:20 +00:00
|
|
|
item_size_ = sizeof(lv_8sc_t);
|
2018-03-03 01:03:39 +00:00
|
|
|
if (inverted_spectrum)
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
|
|
|
conjugate_ic_ = make_conjugate_ic();
|
|
|
|
}
|
2015-01-08 18:49:59 +00:00
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
else
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << item_type_ << " unrecognized item type. Using float";
|
2011-10-01 18:45:20 +00:00
|
|
|
item_size_ = sizeof(float);
|
|
|
|
}
|
2017-11-17 08:21:03 +00:00
|
|
|
|
2013-07-04 13:47:40 +00:00
|
|
|
kludge_copy_ = gr::blocks::copy::make(item_size_);
|
2020-07-19 23:20:15 +00:00
|
|
|
const uint64_t max_source_buffer_samples = configuration->property("GNSS-SDR.max_source_buffer_samples", 0);
|
2019-07-16 15:41:12 +00:00
|
|
|
if (max_source_buffer_samples > 0)
|
|
|
|
{
|
|
|
|
kludge_copy_->set_max_output_buffer(max_source_buffer_samples);
|
|
|
|
LOG(INFO) << "Set signal conditioner max output buffer to " << max_source_buffer_samples;
|
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")";
|
2018-06-03 17:11:16 +00:00
|
|
|
if (in_streams_ > 1)
|
|
|
|
{
|
2021-01-26 15:11:41 +00:00
|
|
|
LOG(ERROR) << "This implementation only supports one input stream but it is set to " << in_streams_;
|
2018-06-03 17:11:16 +00:00
|
|
|
}
|
|
|
|
if (out_streams_ > 1)
|
|
|
|
{
|
2021-01-26 15:11:41 +00:00
|
|
|
LOG(ERROR) << "This implementation only supports one output stream but it is set to " << out_streams_;
|
2018-06-03 17:11:16 +00:00
|
|
|
}
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-10-28 12:38:11 +00:00
|
|
|
|
2013-07-04 13:47:40 +00:00
|
|
|
void Pass_Through::connect(gr::top_block_sptr top_block)
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
if (top_block)
|
|
|
|
{ /* top_block is not null */
|
|
|
|
};
|
2016-05-02 21:46:30 +00:00
|
|
|
DLOG(INFO) << "nothing to connect internally";
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-10-28 12:38:11 +00:00
|
|
|
|
2013-07-04 13:47:40 +00:00
|
|
|
void Pass_Through::disconnect(gr::top_block_sptr top_block)
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
if (top_block)
|
|
|
|
{ /* top_block is not null */
|
|
|
|
};
|
2016-05-02 21:46:30 +00:00
|
|
|
// Nothing to disconnect
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
|
|
|
|
2012-10-28 12:38:11 +00:00
|
|
|
|
2013-07-04 13:47:40 +00:00
|
|
|
gr::basic_block_sptr Pass_Through::get_left_block()
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
if (inverted_spectrum)
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
2018-12-03 11:52:17 +00:00
|
|
|
if (item_type_ == "gr_complex")
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
|
|
|
return conjugate_cc_;
|
|
|
|
}
|
2018-12-03 21:08:19 +00:00
|
|
|
if (item_type_ == "cshort")
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
|
|
|
return conjugate_sc_;
|
|
|
|
}
|
2018-12-04 12:20:49 +00:00
|
|
|
if (item_type_ == "cbyte")
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
|
|
|
return conjugate_ic_;
|
|
|
|
}
|
2018-12-08 17:49:31 +00:00
|
|
|
LOG(WARNING) << "Setting inverted_spectrum to true with item_type "
|
|
|
|
<< item_type_ << " is not defined and has no effect.";
|
2017-11-17 08:21:03 +00:00
|
|
|
}
|
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
return kludge_copy_;
|
|
|
|
}
|
|
|
|
|
2012-10-28 12:38:11 +00:00
|
|
|
|
2013-07-04 13:47:40 +00:00
|
|
|
gr::basic_block_sptr Pass_Through::get_right_block()
|
2011-10-01 18:45:20 +00:00
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
if (inverted_spectrum)
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
2018-12-03 11:52:17 +00:00
|
|
|
if (item_type_ == "gr_complex")
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
|
|
|
return conjugate_cc_;
|
|
|
|
}
|
2018-12-03 21:08:19 +00:00
|
|
|
if (item_type_ == "cshort")
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
|
|
|
return conjugate_sc_;
|
|
|
|
}
|
2018-12-04 12:20:49 +00:00
|
|
|
if (item_type_ == "cbyte")
|
2017-11-17 08:21:03 +00:00
|
|
|
{
|
|
|
|
return conjugate_ic_;
|
|
|
|
}
|
2018-12-08 17:49:31 +00:00
|
|
|
DLOG(WARNING) << "Setting inverted_spectrum to true with item_type "
|
|
|
|
<< item_type_ << " is not defined and has no effect.";
|
2017-11-17 08:21:03 +00:00
|
|
|
}
|
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
return kludge_copy_;
|
|
|
|
}
|