Deleting old direct_resampler

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@167 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Luis Esteve 2012-02-18 16:52:15 +00:00
parent 08f1444df4
commit c5d142a258
9 changed files with 6 additions and 677 deletions

View File

@ -1,129 +0,0 @@
/*!
* \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
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
*
* 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
* at your option) any later version.
*
* 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"
// #include <gnuradio/usrp_source_c.h>
#include <gnuradio/gr_file_sink.h>
#include "direct_resampler_conditioner_cc.h"
//#include "direct_resampler_conditioner_ss.h"
#include "configuration_interface.h"
#include <glog/log_severity.h>
#include <glog/logging.h>
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";
sample_freq_in_ = configuration->property(role_ + ".sample_freq_in",
(double)4000000.0);
sample_freq_out_ = configuration->property(role_ + ".sample_freq_out",
(double)2048000.0);
item_type_ = configuration->property(role + ".item_type",
default_item_type);
dump_ = configuration->property(role + ".dump", false);
dump_filename_ = configuration->property(role + ".dump_filename",
default_dump_file);
if (item_type_.compare("gr_complex") == 0)
{
item_size_ = sizeof(gr_complex);
resampler_ = direct_resampler_make_conditioner_cc(sample_freq_in_,
sample_freq_out_);
}
// else if (item_type_.compare("short") == 0)
// {
// item_size_ = sizeof(short);
// resampler_ = direct_resampler_make_conditioner_ss(sample_freq_in_,
// sample_freq_out_);
// }
else
{
LOG_AT_LEVEL(WARNING) << item_type_
<< " unrecognized item type. Using short";
item_size_ = sizeof(short);
}
if (dump_)
{
DLOG(INFO) << "Dumping output into file " << dump_filename_;
file_sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str());
}
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() << ")";
if (dump_)
{
DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
}
}
DirectResamplerConditioner::~DirectResamplerConditioner() {}
void DirectResamplerConditioner::connect(gr_top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(resampler_, 0, file_sink_, 0);
DLOG(INFO) << "connected resampler to file sink";
}
else
{
DLOG(INFO) << "nothing to connect internally";
}
}
void DirectResamplerConditioner::disconnect(gr_top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(resampler_, 0, file_sink_, 0);
}
}
gr_basic_block_sptr DirectResamplerConditioner::get_left_block()
{
return resampler_;
}
gr_basic_block_sptr DirectResamplerConditioner::get_right_block()
{
return resampler_;
}

View File

@ -1,84 +0,0 @@
/*!
* \file direct_resampler_conditioner.h
* \brief Interface of an adapter of a direct resampler conditioner block
* to a SignalConditionerInterface
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
*
* 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
* at your option) any later version.
*
* 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/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_DIRECT_RESAMPLER_CONDITIONER_H_
#define GNSS_SDR_DIRECT_RESAMPLER_CONDITIONER_H_
#include <gnuradio/gr_hier_block2.h>
#include "gnss_block_interface.h"
class ConfigurationInterface;
class DirectResamplerConditioner: public GNSSBlockInterface
{
public:
DirectResamplerConditioner(ConfigurationInterface* configuration,
std::string role, unsigned int in_stream,
unsigned int out_stream);
virtual ~DirectResamplerConditioner();
std::string role()
{
return role_;
}
std::string implementation()
{
return "DirectResamplerConditioner";
}
size_t item_size()
{
return item_size_;
}
void connect(gr_top_block_sptr top_block);
void disconnect(gr_top_block_sptr top_block);
gr_basic_block_sptr get_left_block();
gr_basic_block_sptr get_right_block();
private:
std::string role_;
unsigned int in_stream_;
unsigned int out_stream_;
std::string item_type_;
size_t item_size_;
long samples_;
bool dump_;
std::string dump_filename_;
double sample_freq_in_;
double sample_freq_out_;
gr_block_sptr resampler_;
gr_block_sptr file_sink_;
};
#endif /*GNSS_SDR_DIRECT_RESAMPLER_CONDITIONER_H_*/

View File

@ -1,140 +0,0 @@
/*!
* \file direct_resampler_conditioner_cc.cc
* \brief Brief description of the file here
* \author Luis Esteve, 2011. luis(at)epsilon-formacion.com
*
* Detailed description of the file here if needed.
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
*
* 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
* at your option) any later version.
*
* 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_cc.h"
#include <iostream>
#include <gnuradio/gr_io_signature.h>
#include <glog/log_severity.h>
#include <glog/logging.h>
using google::LogMessage;
direct_resampler_conditioner_cc_sptr direct_resampler_make_conditioner_cc(
double sample_freq_in, double sample_freq_out)
{
return direct_resampler_conditioner_cc_sptr(
new direct_resampler_conditioner_cc(sample_freq_in,
sample_freq_out));
}
direct_resampler_conditioner_cc::direct_resampler_conditioner_cc(
double sample_freq_in, double sample_freq_out) :
gr_block("direct_resampler_conditioner_cc", gr_make_io_signature(1, 1,
sizeof(gr_complex)), gr_make_io_signature(1, 1,
sizeof(gr_complex))), d_sample_freq_in(sample_freq_in),
d_sample_freq_out(sample_freq_out), d_phase(0), d_lphase(0),
d_history(1)
{
// Computes the phase step multiplying the resampling ratio by 2^32 = 4294967296
if (d_sample_freq_in >= d_sample_freq_out)
{
d_phase_step = (unsigned int)floor((double)4294967296.0
* sample_freq_out / sample_freq_in);
}
else
{
d_phase_step = (unsigned int)floor((double)4294967296.0
* sample_freq_in / sample_freq_out);
}
set_relative_rate(1.0 * sample_freq_out / sample_freq_in);
set_output_multiple(1);
}
direct_resampler_conditioner_cc::~direct_resampler_conditioner_cc()
{
}
void direct_resampler_conditioner_cc::forecast(int noutput_items,
gr_vector_int &ninput_items_required)
{
int nreqd = std::max((unsigned)1, (int)((double)(noutput_items + 1)
* sample_freq_in() / sample_freq_out()) + history() - 1);
unsigned ninputs = ninput_items_required.size();
for (unsigned i = 0; i < ninputs; i++)
{
ninput_items_required[i] = nreqd;
}
}
int direct_resampler_conditioner_cc::general_work(int noutput_items,
gr_vector_int &ninput_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex *)input_items[0];
gr_complex *out = (gr_complex *)output_items[0];
int lcv = 0;
int count = 0;
if (d_sample_freq_in >= d_sample_freq_out)
{
while ((lcv < noutput_items))
{
if (d_phase <= d_lphase)
{
out[lcv] = *in;
lcv++;
}
d_lphase = d_phase;
d_phase += d_phase_step;
in++;
count++;
}
}
else
{
while ((lcv < noutput_items))
{
d_lphase = d_phase;
d_phase += d_phase_step;
if (d_phase <= d_lphase)
{
in++;
count++;
}
out[lcv] = *in;
lcv++;
}
}
consume_each(std::min(count, ninput_items[0]));
return lcv;
}

View File

@ -1,93 +0,0 @@
/*!
* \file direct_resampler_conditioner_cc.h
*
* \brief Direct resampler with
* gr_complex input and gr_complex output
* \author Luis Esteve, 2011. luis(at)epsilon-formacion.com
*
* This block takes in a signal stream and performs direct
* resampling.
* The theory behind this block can be found in Chapter 7.5 of
* the following book.
*
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
*
* 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
* at your option) any later version.
*
* 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/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_DIRECT_RESAMPLER_CONDITIONER_CC_H
#define GNSS_SDR_DIRECT_RESAMPLER_CONDITIONER_CC_H
#include <gnuradio/gr_block.h>
class direct_resampler_conditioner_cc;
typedef boost::shared_ptr<direct_resampler_conditioner_cc>
direct_resampler_conditioner_cc_sptr;
direct_resampler_conditioner_cc_sptr
direct_resampler_make_conditioner_cc(double sample_freq_in,
double sample_freq_out);
/*!
* \brief This class implements a direct resampler conditioner for complex data
*
* Direct resampling without interpolation
*/
class direct_resampler_conditioner_cc: public gr_block
{
private:
friend direct_resampler_conditioner_cc_sptr
direct_resampler_make_conditioner_cc(double sample_freq_in,
double sample_freq_out);
double d_sample_freq_in; //! Specifies the sampling frequency of the input signal
double d_sample_freq_out; //! Specifies the sampling frequency of the output signal
unsigned int d_phase;
unsigned int d_lphase;
unsigned int d_phase_step;
unsigned int d_history;
direct_resampler_conditioner_cc(double sample_freq_in,
double sample_freq_out);
public:
~direct_resampler_conditioner_cc();
unsigned int sample_freq_in() const
{
return d_sample_freq_in;
}
unsigned int sample_freq_out() const
{
return d_sample_freq_out;
}
void forecast(int noutput_items, gr_vector_int &ninput_items_required);
int general_work(int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif /* GNSS_SDR_DIRECT_RESAMPLER_CONDITIONER_CC_H */

View File

@ -1,140 +0,0 @@
/*!
* \file direct_resampler_conditioner_ss.cc
* \brief Brief description of the file here
* \author Luis Esteve, 2011. luis(at)epsilon-formacion.com
*
* Detailed description of the file here if needed.
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
*
* 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
* at your option) any later version.
*
* 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_ss.h"
#include "gps_sdr_signal_processing.h"
#include <iostream>
#include <gnuradio/gr_io_signature.h>
#include <glog/log_severity.h>
#include <glog/logging.h>
using google::LogMessage;
direct_resampler_conditioner_ss_sptr direct_resampler_make_conditioner_ss(
double sample_freq_in, double sample_freq_out)
{
return direct_resampler_conditioner_ss_sptr(
new direct_resampler_conditioner_ss(sample_freq_in,
sample_freq_out));
}
direct_resampler_conditioner_ss::direct_resampler_conditioner_ss(
double sample_freq_in, double sample_freq_out) :
gr_block("direct_resampler_make_conditioner_ss", gr_make_io_signature(1,
1, sizeof(short)), gr_make_io_signature(1, 1, sizeof(short))),
d_sample_freq_in(sample_freq_in), d_sample_freq_out(
sample_freq_out), d_phase(0), d_lphase(0), d_history(1)
{
// Computes the phase step multiplying the resampling ratio by 2^32 = 4294967296
if (d_sample_freq_in >= d_sample_freq_out)
{
d_phase_step = (unsigned int)floor((double)4294967296.0
* sample_freq_out / sample_freq_in);
}
else
{
d_phase_step = (unsigned int)floor((double)4294967296.0
* sample_freq_in / sample_freq_out);
}
set_relative_rate(1.0 * sample_freq_out / sample_freq_in);
set_output_multiple(1);
}
direct_resampler_conditioner_ss::~direct_resampler_conditioner_ss()
{
}
void direct_resampler_conditioner_ss::forecast(int noutput_items,
gr_vector_int &ninput_items_required)
{
int nreqd = std::max((unsigned)1, (int)((double)(noutput_items + 1)
* sample_freq_in() / sample_freq_out()) + history() - 1);
unsigned ninputs = ninput_items_required.size();
for (unsigned i = 0; i < ninputs; i++)
{
ninput_items_required[i] = nreqd;
}
}
int direct_resampler_conditioner_ss::general_work(int noutput_items,
gr_vector_int &ninput_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const CPX *in = (const CPX *)input_items[0];
CPX *out = (CPX *)output_items[0];
int lcv = 0;
int count = 0;
if (d_sample_freq_in >= d_sample_freq_out)
{
while ((lcv < noutput_items))
{
if (d_phase <= d_lphase)
{
out[lcv] = *in;
lcv++;
}
d_lphase = d_phase;
d_phase += d_phase_step;
in++;
count++;
}
}
else
{
while ((lcv < noutput_items))
{
d_lphase = d_phase;
d_phase += d_phase_step;
if (d_phase <= d_lphase)
{
in++;
count++;
}
out[lcv] = *in;
lcv++;
}
}
consume_each(std::min(count, ninput_items[0]));
return lcv;
}

View File

@ -1,85 +0,0 @@
/*!
* \file direct_resampler_conditioner_ss.h
* \brief Direct resampler with
* short input and short output
* \author Luis Esteve, 2011. luis(at)epsilon-formacion.com
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
*
* 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
* at your option) any later version.
*
* 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/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_DIRECT_RESAMPLER_CONDITIONER_SS_H
#define GNSS_SDR_DIRECT_RESAMPLER_CONDITIONER_SS_H
#include <gnuradio/gr_block.h>
class direct_resampler_conditioner_ss;
typedef boost::shared_ptr<direct_resampler_conditioner_ss>
direct_resampler_conditioner_ss_sptr;
direct_resampler_conditioner_ss_sptr
direct_resampler_make_conditioner_ss(double sample_freq_in,
double sample_freq_out);
/*!
* \brief This class implements a direct resampler conditioner for shorts
*
* Direct resampling without interpolation
*/
class direct_resampler_conditioner_ss: public gr_block
{
private:
friend direct_resampler_conditioner_ss_sptr
direct_resampler_make_conditioner_ss(double sample_freq_in,
double sample_freq_out);
double d_sample_freq_in;
double d_sample_freq_out;
unsigned int d_phase;
unsigned int d_lphase;
unsigned int d_phase_step;
unsigned int d_history;
direct_resampler_conditioner_ss(double sample_freq_in,
double sample_freq_out);
public:
~direct_resampler_conditioner_ss();
unsigned int sample_freq_in() const
{
return d_sample_freq_in;
}
unsigned int sample_freq_out() const
{
return d_sample_freq_out;
}
void forecast(int noutput_items, gr_vector_int &ninput_items_required);
int general_work(int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif /* GNSS_SDR_DIRECT_RESAMPLER_CONDITIONER_SS_H */

View File

@ -1,2 +1,2 @@
build-project adapters ;
build-project gnuradio_blocks ;
#build-project adapters ;
#build-project gnuradio_blocks ;

View File

@ -9,8 +9,8 @@ exe gnss-sdr : main.cc
#../algorithms/acquisition/gnuradio_blocks//gps_l1_ca_tong_pcps_acquisition_cc
../algorithms/channel/adapters//channel
../algorithms/channel/libs//gps_l1_ca_channel_fsm
../algorithms/conditioner/adapters//direct_resampler_conditioner
../algorithms/conditioner/gnuradio_blocks//direct_resampler_conditioner_cc
#../algorithms/conditioner/adapters//direct_resampler_conditioner
#../algorithms/conditioner/gnuradio_blocks//direct_resampler_conditioner_cc
#../algorithms/conditioner/gnuradio_blocks//direct_resampler_conditioner_ss
../algorithms/libs//gps_sdr_signal_processing
../algorithms/libs//gnss_sdr_valve

View File

@ -10,8 +10,8 @@ exe run_tests : test_main.cc
#../algorithms/acquisition/gnuradio_blocks//gps_l1_ca_tong_pcps_acquisition_cc
../algorithms/channel/adapters//channel
../algorithms/channel/libs//gps_l1_ca_channel_fsm
../algorithms/conditioner/adapters//direct_resampler_conditioner
../algorithms/conditioner/gnuradio_blocks//direct_resampler_conditioner_cc
#../algorithms/conditioner/adapters//direct_resampler_conditioner
#../algorithms/conditioner/gnuradio_blocks//direct_resampler_conditioner_cc
#../algorithms/conditioner/gnuradio_blocks//direct_resampler_conditioner_ss
../algorithms/libs//gps_sdr_signal_processing
../algorithms/libs//gnss_sdr_valve