1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-04-04 09:47:02 +00:00

adding more data types to the freq_xlating_fir_filter

This commit is contained in:
Carles Fernandez 2015-02-04 21:45:16 +01:00
parent f54ef85300
commit 792c8c1c33
5 changed files with 330 additions and 42 deletions

View File

@ -74,22 +74,41 @@ FreqXlatingFirFilter::FreqXlatingFirFilter(ConfigurationInterface* configuration
freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_);
DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_scf_->unique_id() << ")";
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0)
&& (output_item_type_.compare("cshort") == 0))
{
item_size = sizeof(lv_16sc_t);
input_size_ = sizeof(int16_t); //input
freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_);
DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_scf_->unique_id() << ")";
complex_to_float_ = gr::blocks::complex_to_float::make();
float_to_short_1_ = gr::blocks::float_to_short::make();
float_to_short_2_ = gr::blocks::float_to_short::make();
short_x2_to_cshort_ = make_short_x2_to_cshort();
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
item_size = sizeof(gr_complex);
input_size_ = sizeof(int8_t); //input
// gr_char_to_short_ = gr::blocks::char_to_short::make();
gr_char_to_short_ = gr::blocks::char_to_short::make();
freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_);
// short_x2_complex_byte
DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_scf_->unique_id() << ")";
}
// gr_short_to_float _ = gr::blocks::short_to_float::make();
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0)
&& (output_item_type_.compare("cbyte") == 0))
{
item_size = sizeof(lv_8sc_t);
input_size_ = sizeof(int8_t); //input
gr_char_to_short_ = gr::blocks::char_to_short::make();
freq_xlating_fir_filter_scf_ = gr::filter::freq_xlating_fir_filter_scf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_);
DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_scf_->unique_id() << ")";
complex_to_complex_byte_ = make_complex_float_to_complex_byte();
}
else
{
LOG(ERROR) << taps_item_type_ << " unknown input filter item type";
item_size = sizeof(gr_complex); //avoids unitialization
item_size = sizeof(gr_complex); //avoids uninitialization
}
if (dump_)
@ -109,24 +128,65 @@ FreqXlatingFirFilter::~FreqXlatingFirFilter()
void FreqXlatingFirFilter::connect(gr::top_block_sptr top_block)
{
if (dump_)
if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
if (input_size_ == sizeof(float))
{
top_block->connect(freq_xlating_fir_filter_fcf_, 0, file_sink_, 0);
}
else if (input_size_ == sizeof(short))
{
top_block->connect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0);
}
else
if (dump_)
{
top_block->connect(freq_xlating_fir_filter_ccf_, 0, file_sink_, 0);
}
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("float") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
if (dump_)
{
top_block->connect(freq_xlating_fir_filter_fcf_, 0, file_sink_, 0);
}
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
if (dump_)
{
top_block->connect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0);
}
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0)
&& (output_item_type_.compare("cshort") == 0))
{
top_block->connect(freq_xlating_fir_filter_scf_, 0, complex_to_float_, 0);
top_block->connect(complex_to_float_, 0, float_to_short_1_, 0);
top_block->connect(complex_to_float_, 1, float_to_short_2_, 0);
top_block->connect(float_to_short_1_, 0, short_x2_to_cshort_, 0);
top_block->connect(float_to_short_2_, 0, short_x2_to_cshort_, 0);
if (dump_)
{
top_block->connect(short_x2_to_cshort_, 0, file_sink_, 0);
}
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
top_block->connect(gr_char_to_short_, 0, freq_xlating_fir_filter_scf_, 0);
if (dump_)
{
top_block->connect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0);
}
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0)
&& (output_item_type_.compare("cbyte") == 0))
{
top_block->connect(gr_char_to_short_, 0, freq_xlating_fir_filter_scf_, 0);
top_block->connect(freq_xlating_fir_filter_scf_, 0, complex_to_complex_byte_, 0);
if (dump_)
{
top_block->connect(complex_to_complex_byte_, 0, file_sink_, 0);
}
}
else
{
DLOG(INFO) << "Nothing to connect internally";
LOG(ERROR) << " unknown input filter item type";
}
}
@ -134,56 +194,145 @@ void FreqXlatingFirFilter::connect(gr::top_block_sptr top_block)
void FreqXlatingFirFilter::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
if (input_size_ == sizeof(float))
{
top_block->disconnect(freq_xlating_fir_filter_fcf_, 0, file_sink_, 0);
}
else if (input_size_ == sizeof(short))
{
top_block->disconnect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0);
}
else
if (dump_)
{
top_block->disconnect(freq_xlating_fir_filter_ccf_, 0, file_sink_, 0);
}
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("float") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
if (dump_)
{
top_block->disconnect(freq_xlating_fir_filter_fcf_, 0, file_sink_, 0);
}
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
if (dump_)
{
top_block->disconnect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0);
}
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0)
&& (output_item_type_.compare("cshort") == 0))
{
top_block->disconnect(freq_xlating_fir_filter_scf_, 0, complex_to_float_, 0);
top_block->disconnect(complex_to_float_, 0, float_to_short_1_, 0);
top_block->disconnect(complex_to_float_, 1, float_to_short_2_, 0);
top_block->disconnect(float_to_short_1_, 0, short_x2_to_cshort_, 0);
top_block->disconnect(float_to_short_2_, 0, short_x2_to_cshort_, 0);
if (dump_)
{
top_block->disconnect(short_x2_to_cshort_, 0, file_sink_, 0);
}
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
top_block->disconnect(gr_char_to_short_, 0, freq_xlating_fir_filter_scf_, 0);
if (dump_)
{
top_block->disconnect(freq_xlating_fir_filter_scf_, 0, file_sink_, 0);
}
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0)
&& (output_item_type_.compare("cbyte") == 0))
{
top_block->disconnect(gr_char_to_short_, 0, freq_xlating_fir_filter_scf_, 0);
top_block->disconnect(freq_xlating_fir_filter_scf_, 0, complex_to_complex_byte_, 0);
if (dump_)
{
top_block->disconnect(complex_to_complex_byte_, 0, file_sink_, 0);
}
}
else
{
LOG(ERROR) << " unknown input filter item type";
}
}
gr::basic_block_sptr FreqXlatingFirFilter::get_left_block()
{
if (input_size_ == sizeof(float))
{
return freq_xlating_fir_filter_fcf_;
}
else if (input_size_ == sizeof(short))
{
return freq_xlating_fir_filter_scf_;
}
else
if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
return freq_xlating_fir_filter_ccf_;
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("float") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
return freq_xlating_fir_filter_fcf_;
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
return freq_xlating_fir_filter_scf_;
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0)
&& (output_item_type_.compare("cshort") == 0))
{
return freq_xlating_fir_filter_scf_;
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
return gr_char_to_short_;
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0)
&& (output_item_type_.compare("cbyte") == 0))
{
return gr_char_to_short_;
}
else
{
return nullptr;
LOG(ERROR) << " unknown input filter item type";
}
}
gr::basic_block_sptr FreqXlatingFirFilter::get_right_block()
{
if (input_size_ == sizeof(float))
if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
return freq_xlating_fir_filter_ccf_;
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("float") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
return freq_xlating_fir_filter_fcf_;
}
else if (input_size_ == sizeof(short))
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
return freq_xlating_fir_filter_scf_;
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("short") == 0)
&& (output_item_type_.compare("cshort") == 0))
{
return short_x2_to_cshort_;
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0)
&& (output_item_type_.compare("gr_complex") == 0))
{
return freq_xlating_fir_filter_scf_;
}
else if((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("byte") == 0)
&& (output_item_type_.compare("cbyte") == 0))
{
return complex_to_complex_byte_;
}
else
{
return freq_xlating_fir_filter_ccf_;
return nullptr;
LOG(ERROR) << " unknown input filter item type";
}
}

View File

@ -39,10 +39,14 @@
#include <gnuradio/filter/freq_xlating_fir_filter_fcf.h>
#include <gnuradio/filter/freq_xlating_fir_filter_scf.h>
#include <gnuradio/blocks/file_sink.h>
#include <gnuradio/blocks/complex_to_float.h>
#include <gnuradio/blocks/char_to_short.h>
#include <gnuradio/blocks/float_to_short.h>
#include <gnuradio/msg_queue.h>
#include "gnss_synchro.h"
#include "gnss_block_interface.h"
#include "short_x2_to_cshort.h"
#include "complex_float_to_complex_byte.h"
class ConfigurationInterface;
@ -104,6 +108,12 @@ private:
unsigned int out_streams_;
boost::shared_ptr<gr::msg_queue> queue_;
gr::blocks::file_sink::sptr file_sink_;
gr::blocks::complex_to_float::sptr complex_to_float_;
gr::blocks::char_to_short::sptr gr_char_to_short_;
gr::blocks::float_to_short::sptr float_to_short_1_;
gr::blocks::float_to_short::sptr float_to_short_2_;
short_x2_to_cshort_sptr short_x2_to_cshort_;
complex_float_to_complex_byte_sptr complex_to_complex_byte_;
void init();
};

View File

@ -23,6 +23,7 @@ set(INPUT_FILTER_GR_BLOCKS_SOURCES
byte_x2_to_complex_byte.cc
cshort_to_float_x2.cc
short_x2_to_cshort.cc
complex_float_to_complex_byte.cc
)
include_directories(
@ -30,10 +31,15 @@ include_directories(
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
${GNURADIO_BLOCKS_INCLUDE_DIRS}
${VOLK_INCLUDE_DIRS}
${VOLK_GNSSSDR_INCLUDE_DIRS}
)
file(GLOB INPUT_FILTER_GR_BLOCKS_HEADERS "*.h")
add_library(input_filter_gr_blocks ${INPUT_FILTER_GR_BLOCKS_SOURCES} ${INPUT_FILTER_GR_BLOCKS_HEADERS})
source_group(Headers FILES ${INPUT_FILTER_GR_BLOCKS_HEADERS})
target_link_libraries(input_filter_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_LIBRARIES})
target_link_libraries(input_filter_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${GNURADIO_BLOCKS_LIBRARIES})
if(NOT VOLK_GNSSSDR_FOUND)
add_dependencies(input_filter_gr_blocks volk_gnsssdr_module)
endif(NOT VOLK_GNSSSDR_FOUND)

View File

@ -0,0 +1,63 @@
/*!
* \file complex_float_to_complex_byte.cc
* \brief Adapts a gr_complex stream into a std::complex<signed char> stream
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2015 (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 "complex_float_to_complex_byte.h"
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
#include "volk_gnsssdr/volk_gnsssdr.h"
complex_float_to_complex_byte_sptr make_complex_float_to_complex_byte()
{
return complex_float_to_complex_byte_sptr(new complex_float_to_complex_byte());
}
complex_float_to_complex_byte::complex_float_to_complex_byte() : sync_block("complex_float_to_complex_byte",
gr::io_signature::make (1, 1, sizeof(gr_complex)),
gr::io_signature::make (1, 1, sizeof(lv_8sc_t))) // lv_8sc_t is a Volk's typedef for std::complex<signed char>
{
const int alignment_multiple = volk_get_alignment() / sizeof(lv_8sc_t);
set_alignment(std::max(1, alignment_multiple));
}
int complex_float_to_complex_byte::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex *) input_items[0];
lv_8sc_t *out = (lv_8sc_t*) output_items[0];
volk_gnsssdr_32fc_convert_8ic(out, in, noutput_items);
return noutput_items;
}

View File

@ -0,0 +1,60 @@
/*!
* \file complex_float_to_complex_byte.h
* \brief Adapts a gr_complex stream into a std::complex<signed char> stream
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2015 (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_COMPLEX_FLOAT_TO_COMPLEX_BYTE_H_
#define GNSS_SDR_COMPLEX_FLOAT_TO_COMPLEX_BYTE_H_
#include <string>
#include <boost/shared_ptr.hpp>
#include <gnuradio/sync_block.h>
class complex_float_to_complex_byte;
typedef boost::shared_ptr<complex_float_to_complex_byte> complex_float_to_complex_byte_sptr;
complex_float_to_complex_byte_sptr make_complex_float_to_complex_byte();
/*!
* \brief This class adapts a gr_complex stream into a std::complex<signed char> stream
*/
class complex_float_to_complex_byte : public gr::sync_block
{
private:
friend complex_float_to_complex_byte_sptr make_complex_float_to_complex_byte();
public:
complex_float_to_complex_byte();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif