2012-02-18 17:45:37 +00:00
|
|
|
/*!
|
|
|
|
* \file direct_resampler_conditioner.cc
|
|
|
|
* \brief Implementation of an adapter of a direct resampler conditioner block
|
|
|
|
* to a SignalConditionerInterface
|
|
|
|
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2015-01-08 18:49:59 +00:00
|
|
|
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
2012-02-18 17:45:37 +00:00
|
|
|
*
|
|
|
|
* 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
|
2015-01-08 18:49:59 +00:00
|
|
|
* (at your option) any later version.
|
2012-02-18 17:45:37 +00:00
|
|
|
*
|
|
|
|
* 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 "direct_resampler_conditioner.h"
|
2016-08-13 15:25:07 +00:00
|
|
|
#include <cmath>
|
|
|
|
#include <limits>
|
2014-01-14 23:22:54 +00:00
|
|
|
#include <glog/logging.h>
|
2013-07-04 13:47:40 +00:00
|
|
|
#include <gnuradio/blocks/file_sink.h>
|
2015-02-03 23:29:54 +00:00
|
|
|
#include <volk/volk.h>
|
2012-02-18 17:45:37 +00:00
|
|
|
#include "direct_resampler_conditioner_cc.h"
|
2015-02-04 01:12:37 +00:00
|
|
|
#include "direct_resampler_conditioner_cs.h"
|
|
|
|
#include "direct_resampler_conditioner_cb.h"
|
2012-02-18 17:45:37 +00:00
|
|
|
#include "configuration_interface.h"
|
2014-01-14 23:22:54 +00:00
|
|
|
|
2012-02-18 17:45:37 +00:00
|
|
|
using google::LogMessage;
|
|
|
|
|
|
|
|
DirectResamplerConditioner::DirectResamplerConditioner(
|
|
|
|
ConfigurationInterface* configuration, std::string role,
|
|
|
|
unsigned int in_stream, unsigned int out_stream) :
|
|
|
|
role_(role), in_stream_(in_stream), out_stream_(out_stream)
|
|
|
|
{
|
|
|
|
std::string default_item_type = "short";
|
|
|
|
std::string default_dump_file = "./data/signal_conditioner.dat";
|
2017-09-02 09:24:44 +00:00
|
|
|
double fs_in_deprecated, fs_in;
|
|
|
|
fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000.0);
|
|
|
|
fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated);
|
2017-08-18 10:45:47 +00:00
|
|
|
sample_freq_in_ = configuration->property(role_ + ".sample_freq_in", 4000000.0);
|
2016-08-13 15:25:07 +00:00
|
|
|
sample_freq_out_ = configuration->property(role_ + ".sample_freq_out", fs_in);
|
|
|
|
if(std::fabs(fs_in - sample_freq_out_) > std::numeric_limits<double>::epsilon())
|
|
|
|
{
|
2017-09-02 09:24:44 +00:00
|
|
|
std::string aux_warn = "CONFIGURATION WARNING: Parameters GNSS-SDR.internal_fs_sps and "
|
2016-08-13 15:25:07 +00:00
|
|
|
+ role_ + ".sample_freq_out are not set to the same value!" ;
|
|
|
|
LOG(WARNING) << aux_warn;
|
|
|
|
std::cout << aux_warn << std::endl;
|
|
|
|
}
|
2013-07-04 13:47:40 +00:00
|
|
|
item_type_ = configuration->property(role + ".item_type", default_item_type);
|
2012-02-18 17:45:37 +00:00
|
|
|
dump_ = configuration->property(role + ".dump", false);
|
2013-07-04 13:47:40 +00:00
|
|
|
DLOG(INFO) << "dump_ is " << dump_;
|
|
|
|
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
|
2012-02-18 17:45:37 +00:00
|
|
|
|
|
|
|
if (item_type_.compare("gr_complex") == 0)
|
|
|
|
{
|
|
|
|
item_size_ = sizeof(gr_complex);
|
2015-02-03 23:29:54 +00:00
|
|
|
resampler_ = direct_resampler_make_conditioner_cc(sample_freq_in_, sample_freq_out_);
|
2012-02-24 16:06:14 +00:00
|
|
|
DLOG(INFO) << "sample_freq_in " << sample_freq_in_;
|
|
|
|
DLOG(INFO) << "sample_freq_out" << sample_freq_out_;
|
|
|
|
DLOG(INFO) << "Item size " << item_size_;
|
|
|
|
DLOG(INFO) << "resampler(" << resampler_->unique_id() << ")";
|
2012-02-18 17:45:37 +00:00
|
|
|
}
|
2015-02-03 23:29:54 +00:00
|
|
|
else if (item_type_.compare("cshort") == 0)
|
2015-01-08 18:49:59 +00:00
|
|
|
{
|
2015-02-03 23:29:54 +00:00
|
|
|
item_size_ = sizeof(lv_16sc_t);
|
2015-02-04 01:12:37 +00:00
|
|
|
resampler_ = direct_resampler_make_conditioner_cs(sample_freq_in_, sample_freq_out_);
|
2015-02-03 23:29:54 +00:00
|
|
|
DLOG(INFO) << "sample_freq_in " << sample_freq_in_;
|
|
|
|
DLOG(INFO) << "sample_freq_out" << sample_freq_out_;
|
|
|
|
DLOG(INFO) << "Item size " << item_size_;
|
|
|
|
DLOG(INFO) << "resampler(" << resampler_->unique_id() << ")";
|
|
|
|
}
|
|
|
|
else if (item_type_.compare("cbyte") == 0)
|
|
|
|
{
|
|
|
|
item_size_ = sizeof(lv_8sc_t);
|
2015-02-04 01:12:37 +00:00
|
|
|
resampler_ = direct_resampler_make_conditioner_cb(sample_freq_in_, sample_freq_out_);
|
2015-02-03 23:29:54 +00:00
|
|
|
DLOG(INFO) << "sample_freq_in " << sample_freq_in_;
|
|
|
|
DLOG(INFO) << "sample_freq_out" << sample_freq_out_;
|
|
|
|
DLOG(INFO) << "Item size " << item_size_;
|
|
|
|
DLOG(INFO) << "resampler(" << resampler_->unique_id() << ")";
|
2015-01-08 18:49:59 +00:00
|
|
|
}
|
2012-02-18 17:45:37 +00:00
|
|
|
else
|
|
|
|
{
|
2014-03-16 19:58:29 +00:00
|
|
|
LOG(WARNING) << item_type_ << " unrecognized item type for resampler";
|
2012-02-18 17:45:37 +00:00
|
|
|
item_size_ = sizeof(short);
|
|
|
|
}
|
|
|
|
if (dump_)
|
|
|
|
{
|
|
|
|
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
2013-07-04 13:47:40 +00:00
|
|
|
file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str());
|
2012-02-18 17:45:37 +00:00
|
|
|
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
|
|
|
|
}
|
|
|
|
}
|
2012-10-28 10:56:04 +00:00
|
|
|
|
|
|
|
|
2012-02-18 17:45:37 +00:00
|
|
|
DirectResamplerConditioner::~DirectResamplerConditioner() {}
|
|
|
|
|
2012-10-28 10:56:04 +00:00
|
|
|
|
|
|
|
|
2013-07-04 13:47:40 +00:00
|
|
|
void DirectResamplerConditioner::connect(gr::top_block_sptr top_block)
|
2012-02-18 17:45:37 +00:00
|
|
|
{
|
|
|
|
if (dump_)
|
|
|
|
{
|
|
|
|
top_block->connect(resampler_, 0, file_sink_, 0);
|
|
|
|
DLOG(INFO) << "connected resampler to file sink";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DLOG(INFO) << "nothing to connect internally";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-28 10:56:04 +00:00
|
|
|
|
2013-07-04 13:47:40 +00:00
|
|
|
void DirectResamplerConditioner::disconnect(gr::top_block_sptr top_block)
|
2012-02-18 17:45:37 +00:00
|
|
|
{
|
|
|
|
if (dump_)
|
|
|
|
{
|
|
|
|
top_block->disconnect(resampler_, 0, file_sink_, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-28 10:56:04 +00:00
|
|
|
|
2013-07-04 13:47:40 +00:00
|
|
|
gr::basic_block_sptr DirectResamplerConditioner::get_left_block()
|
2012-02-18 17:45:37 +00:00
|
|
|
{
|
|
|
|
return resampler_;
|
|
|
|
}
|
|
|
|
|
2012-10-28 10:56:04 +00:00
|
|
|
|
2013-07-04 13:47:40 +00:00
|
|
|
gr::basic_block_sptr DirectResamplerConditioner::get_right_block()
|
2012-02-18 17:45:37 +00:00
|
|
|
{
|
|
|
|
return resampler_;
|
|
|
|
}
|