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
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2015-01-08 18:49:59 +00:00
|
|
|
* Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
|
2011-10-01 18:45:20 +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
|
2014-11-24 21:50:33 +00:00
|
|
|
* (at your option) any later version.
|
2011-10-01 18:45:20 +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 "pass_through.h"
|
|
|
|
#include <iostream>
|
2015-01-08 18:49:59 +00:00
|
|
|
#include <complex>
|
2011-10-01 18:45:20 +00:00
|
|
|
#include <glog/logging.h>
|
2015-02-04 00:11:20 +00:00
|
|
|
#include <volk/volk.h>
|
2011-10-01 18:45:20 +00:00
|
|
|
#include "configuration_interface.h"
|
|
|
|
|
|
|
|
using google::LogMessage;
|
|
|
|
|
2012-10-28 12:38:11 +00:00
|
|
|
Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string role,
|
2011-10-01 18:45:20 +00:00
|
|
|
unsigned int in_streams,
|
|
|
|
unsigned int out_streams) :
|
|
|
|
role_(role),
|
|
|
|
in_streams_(in_streams),
|
|
|
|
out_streams_(out_streams)
|
|
|
|
{
|
2012-02-19 17:45:51 +00:00
|
|
|
std::string default_item_type = "gr_complex";
|
2015-02-26 17:24:06 +00:00
|
|
|
std::string input_type = configuration->property(role + ".input_item_type", default_item_type);
|
|
|
|
std::string output_type = configuration->property(role + ".output_item_type", default_item_type);
|
|
|
|
if(input_type.compare(output_type) != 0)
|
|
|
|
{
|
|
|
|
LOG(WARNING) << "input_item_type and output_item_type are different in a Pass_Through implementation! Taking "
|
|
|
|
<< input_type
|
|
|
|
<< ", but item_size will supersede it.";
|
|
|
|
}
|
|
|
|
|
|
|
|
item_type_ = configuration->property(role + ".item_type", input_type);
|
2011-10-01 18:45:20 +00:00
|
|
|
vector_size_ = configuration->property(role + ".vector_size", 1);
|
2015-02-26 17:24:06 +00:00
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
if(item_type_.compare("float") == 0)
|
|
|
|
{
|
|
|
|
item_size_ = sizeof(float);
|
|
|
|
}
|
|
|
|
else if(item_type_.compare("gr_complex") == 0)
|
|
|
|
{
|
|
|
|
item_size_ = sizeof(gr_complex);
|
|
|
|
}
|
|
|
|
else if(item_type_.compare("short") == 0)
|
|
|
|
{
|
2015-02-04 00:11:20 +00:00
|
|
|
item_size_ = sizeof(int16_t);
|
|
|
|
}
|
2015-02-26 17:24:06 +00:00
|
|
|
else if(item_type_.compare("ishort") == 0)
|
|
|
|
{
|
|
|
|
item_size_ = sizeof(int16_t);
|
|
|
|
}
|
2015-02-04 00:11:20 +00:00
|
|
|
else if(item_type_.compare("cshort") == 0)
|
|
|
|
{
|
|
|
|
item_size_ = sizeof(lv_16sc_t);
|
2011-10-01 18:45:20 +00:00
|
|
|
}
|
2014-11-24 21:50:33 +00:00
|
|
|
else if(item_type_.compare("byte") == 0)
|
|
|
|
{
|
2015-02-04 00:11:20 +00:00
|
|
|
item_size_ = sizeof(int8_t);
|
2014-11-24 21:50:33 +00:00
|
|
|
}
|
2015-02-26 17:24:06 +00:00
|
|
|
else if(item_type_.compare("ibyte") == 0)
|
|
|
|
{
|
|
|
|
item_size_ = sizeof(int8_t);
|
|
|
|
}
|
2015-01-08 18:49:59 +00:00
|
|
|
else if(item_type_.compare("cbyte") == 0)
|
|
|
|
{
|
2015-02-04 00:11:20 +00:00
|
|
|
item_size_ = sizeof(lv_8sc_t);
|
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);
|
|
|
|
}
|
2013-07-04 13:47:40 +00:00
|
|
|
kludge_copy_ = gr::blocks::copy::make(item_size_);
|
2011-10-01 18:45:20 +00:00
|
|
|
DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")";
|
|
|
|
}
|
|
|
|
|
2012-10-28 12:38:11 +00:00
|
|
|
|
|
|
|
|
2012-01-23 00:52:05 +00:00
|
|
|
Pass_Through::~Pass_Through()
|
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
|
|
|
{
|
2015-02-27 13:55:46 +00:00
|
|
|
if(top_block) { /* top_block is not null */};
|
|
|
|
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
|
|
|
{
|
2015-02-27 13:55:46 +00:00
|
|
|
if(top_block) { /* top_block is not null */};
|
|
|
|
// 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
|
|
|
{
|
|
|
|
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
|
|
|
{
|
|
|
|
return kludge_copy_;
|
|
|
|
}
|