1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 20:20:35 +00:00

Add mechanisms for inverted spectrum

This commit is contained in:
Carles Fernandez 2017-11-17 09:21:03 +01:00
parent fe241c8b2d
commit d20902d688
21 changed files with 583 additions and 47 deletions

View File

@ -31,6 +31,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/core/system_parameters
${CMAKE_SOURCE_DIR}/src/core/interfaces
${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/gnuradio_blocks
${CMAKE_SOURCE_DIR}/src/algorithms/libs
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}

View File

@ -51,6 +51,7 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
size_t item_size = sizeof(lv_8sc_t);
@ -63,6 +64,10 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro
DLOG(INFO) << "Dumping output into file " << dump_filename_;
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
}
if(inverted_spectrum)
{
conjugate_ic_ = make_conjugate_ic();
}
}
@ -74,7 +79,26 @@ void IbyteToCbyte::connect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->connect(ibyte_to_cbyte_, 0, conjugate_ic_, 0);
top_block->connect(conjugate_ic_, 0, file_sink_, 0);
}
else
{
top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->connect(ibyte_to_cbyte_, 0, conjugate_ic_, 0);
}
else
{
DLOG(INFO) << "Nothing to connect internally";
}
}
}
@ -83,21 +107,40 @@ void IbyteToCbyte::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->disconnect(ibyte_to_cbyte_, 0, conjugate_ic_, 0);
top_block->disconnect(conjugate_ic_, 0, file_sink_, 0);
}
else
{
top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->disconnect(ibyte_to_cbyte_, 0, conjugate_ic_, 0);
}
}
}
gr::basic_block_sptr IbyteToCbyte::get_left_block()
{
return ibyte_to_cbyte_;
}
gr::basic_block_sptr IbyteToCbyte::get_right_block()
{
return ibyte_to_cbyte_;
if(inverted_spectrum)
{
return conjugate_ic_;
}
else
{
return ibyte_to_cbyte_;
}
}

View File

@ -34,6 +34,7 @@
#include <string>
#include <gnuradio/blocks/file_sink.h>
#include "conjugate_ic.h"
#include "gnss_block_interface.h"
#include "interleaved_byte_to_complex_byte.h"
@ -85,6 +86,8 @@ private:
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
conjugate_ic_sptr conjugate_ic_;
bool inverted_spectrum;
};
#endif

View File

@ -49,6 +49,7 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
size_t item_size = sizeof(gr_complex);
@ -56,6 +57,10 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin
DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_char_to_complex_->unique_id() << ")";
if (inverted_spectrum)
{
conjugate_cc_ = make_conjugate_cc();
}
if (dump_)
{
DLOG(INFO) << "Dumping output into file " << dump_filename_;
@ -72,7 +77,26 @@ void IbyteToComplex::connect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(gr_interleaved_char_to_complex_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->connect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0);
top_block->connect(conjugate_cc_, 0, file_sink_, 0);
}
else
{
top_block->connect(gr_interleaved_char_to_complex_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->connect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0);
}
else
{
DLOG(INFO) << "Nothing to connect internally";
}
}
}
@ -81,22 +105,40 @@ void IbyteToComplex::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(gr_interleaved_char_to_complex_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->disconnect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0);
top_block->disconnect(conjugate_cc_, 0, file_sink_, 0);
}
else
{
top_block->disconnect(gr_interleaved_char_to_complex_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->disconnect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0);
}
}
}
gr::basic_block_sptr IbyteToComplex::get_left_block()
{
return gr_interleaved_char_to_complex_;
}
gr::basic_block_sptr IbyteToComplex::get_right_block()
{
return gr_interleaved_char_to_complex_;
if(inverted_spectrum)
{
return conjugate_cc_;
}
else
{
return gr_interleaved_char_to_complex_;
}
}

View File

@ -34,8 +34,9 @@
#include <string>
#include <gnuradio/blocks/interleaved_char_to_complex.h>
#include <gnuradio/blocks/file_sink.h>
#include "gnss_synchro.h"
#include "conjugate_cc.h"
#include "gnss_block_interface.h"
#include "gnss_synchro.h"
class ConfigurationInterface;
@ -85,6 +86,8 @@ private:
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
conjugate_cc_sptr conjugate_cc_;
bool inverted_spectrum;
};
#endif

View File

@ -51,6 +51,7 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
size_t item_size = sizeof(lv_16sc_t);
@ -63,6 +64,10 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string
DLOG(INFO) << "Dumping output into file " << dump_filename_;
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
}
if(inverted_spectrum)
{
conjugate_sc_ = make_conjugate_sc();
}
}
@ -74,7 +79,22 @@ void IbyteToCshort::connect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(interleaved_byte_to_complex_short_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->connect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0);
top_block->connect(conjugate_sc_, 0, file_sink_, 0);
}
else
{
top_block->connect(interleaved_byte_to_complex_short_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->connect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0);
}
}
}
@ -83,22 +103,40 @@ void IbyteToCshort::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(interleaved_byte_to_complex_short_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->disconnect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0);
top_block->disconnect(conjugate_sc_, 0, file_sink_, 0);
}
else
{
top_block->disconnect(interleaved_byte_to_complex_short_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->disconnect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0);
}
}
}
gr::basic_block_sptr IbyteToCshort::get_left_block()
{
return interleaved_byte_to_complex_short_;
}
gr::basic_block_sptr IbyteToCshort::get_right_block()
{
return interleaved_byte_to_complex_short_;
if(inverted_spectrum)
{
return conjugate_sc_;
}
else
{
return interleaved_byte_to_complex_short_;
}
}

View File

@ -34,6 +34,7 @@
#include <string>
#include <gnuradio/blocks/file_sink.h>
#include "gnss_block_interface.h"
#include "conjugate_sc.h"
#include "interleaved_byte_to_complex_short.h"
@ -85,6 +86,8 @@ private:
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
conjugate_sc_sptr conjugate_sc_;
bool inverted_spectrum;
};
#endif

View File

@ -49,6 +49,7 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
size_t item_size = sizeof(gr_complex);
@ -56,6 +57,10 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str
DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_short_to_complex_->unique_id() << ")";
if (inverted_spectrum)
{
conjugate_cc_ = make_conjugate_cc();
}
if (dump_)
{
DLOG(INFO) << "Dumping output into file " << dump_filename_;
@ -72,11 +77,26 @@ void IshortToComplex::connect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(gr_interleaved_short_to_complex_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->connect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0);
top_block->connect(conjugate_cc_, 0, file_sink_, 0);
}
else
{
top_block->connect(gr_interleaved_short_to_complex_, 0, file_sink_, 0);
}
}
else
{
DLOG(INFO) << "Nothing to connect internally";
if(inverted_spectrum)
{
top_block->connect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0);
}
else
{
DLOG(INFO) << "Nothing to connect internally";
}
}
}
@ -85,22 +105,40 @@ void IshortToComplex::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(gr_interleaved_short_to_complex_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->disconnect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0);
top_block->disconnect(conjugate_cc_, 0, file_sink_, 0);
}
else
{
top_block->disconnect(gr_interleaved_short_to_complex_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->disconnect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0);
}
}
}
gr::basic_block_sptr IshortToComplex::get_left_block()
{
return gr_interleaved_short_to_complex_;
}
gr::basic_block_sptr IshortToComplex::get_right_block()
{
return gr_interleaved_short_to_complex_;
if(inverted_spectrum)
{
return conjugate_cc_;
}
else
{
return gr_interleaved_short_to_complex_;
}
}

View File

@ -34,6 +34,7 @@
#include <string>
#include <gnuradio/blocks/interleaved_short_to_complex.h>
#include <gnuradio/blocks/file_sink.h>
#include "conjugate_cc.h"
#include "gnss_block_interface.h"
@ -84,6 +85,8 @@ private:
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
conjugate_cc_sptr conjugate_cc_;
bool inverted_spectrum;
};
#endif

View File

@ -51,6 +51,7 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
size_t item_size = sizeof(lv_16sc_t);
@ -63,6 +64,10 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin
DLOG(INFO) << "Dumping output into file " << dump_filename_;
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
}
if(inverted_spectrum)
{
conjugate_sc_ = make_conjugate_sc();
}
}
@ -74,11 +79,26 @@ void IshortToCshort::connect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->connect(interleaved_short_to_complex_short_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->connect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0);
top_block->connect(conjugate_sc_, 0, file_sink_, 0);
}
else
{
top_block->connect(interleaved_short_to_complex_short_, 0, file_sink_, 0);
}
}
else
{
DLOG(INFO) << "Nothing to connect internally";
if(inverted_spectrum)
{
top_block->connect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0);
}
else
{
DLOG(INFO) << "Nothing to connect internally";
}
}
}
@ -87,22 +107,40 @@ void IshortToCshort::disconnect(gr::top_block_sptr top_block)
{
if (dump_)
{
top_block->disconnect(interleaved_short_to_complex_short_, 0, file_sink_, 0);
if(inverted_spectrum)
{
top_block->disconnect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0);
top_block->disconnect(conjugate_sc_, 0, file_sink_, 0);
}
else
{
top_block->disconnect(interleaved_short_to_complex_short_, 0, file_sink_, 0);
}
}
else
{
if(inverted_spectrum)
{
top_block->disconnect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0);
}
}
}
gr::basic_block_sptr IshortToCshort::get_left_block()
{
return interleaved_short_to_complex_short_;
}
gr::basic_block_sptr IshortToCshort::get_right_block()
{
return interleaved_short_to_complex_short_;
if(inverted_spectrum)
{
return conjugate_sc_;
}
else
{
return interleaved_short_to_complex_short_;
}
}

View File

@ -33,6 +33,7 @@
#include <string>
#include <gnuradio/blocks/file_sink.h>
#include "conjugate_sc.h"
#include "gnss_block_interface.h"
#include "interleaved_short_to_complex_short.h"
@ -85,6 +86,8 @@ private:
unsigned int in_streams_;
unsigned int out_streams_;
gr::blocks::file_sink::sptr file_sink_;
conjugate_sc_sptr conjugate_sc_;
bool inverted_spectrum;
};
#endif

View File

@ -32,6 +32,9 @@ set(GNSS_SPLIBS_SOURCES
cshort_to_float_x2.cc
short_x2_to_cshort.cc
complex_float_to_complex_byte.cc
conjugate_cc.cc
conjugate_sc.cc
conjugate_ic.cc
)

View File

@ -0,0 +1,29 @@
#include "conjugate_cc.h"
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
conjugate_cc_sptr make_conjugate_cc()
{
return conjugate_cc_sptr(new conjugate_cc());
}
conjugate_cc::conjugate_cc() : gr::sync_block("conjugate_cc",
gr::io_signature::make (1, 1, sizeof(gr_complex)),
gr::io_signature::make (1, 1, sizeof(gr_complex)))
{
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple));
}
int conjugate_cc::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = reinterpret_cast<const gr_complex *>(input_items[0]);
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
volk_32fc_conjugate_32fc(out, in, noutput_items);
return noutput_items;
}

View File

@ -0,0 +1,59 @@
/*!
* \file conjugate_cc.h
* \brief Conjugate
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (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_CONJUGATE_CC_H_
#define GNSS_SDR_CONJUGATE_CC_H_
#include <boost/shared_ptr.hpp>
#include <gnuradio/sync_block.h>
class conjugate_cc;
typedef boost::shared_ptr<conjugate_cc> conjugate_cc_sptr;
conjugate_cc_sptr make_conjugate_cc();
/*!
* \brief This class adapts a std::complex<short> stream
* into two 32-bits (float) streams
*/
class conjugate_cc : public gr::sync_block
{
private:
friend conjugate_cc_sptr make_conjugate_cc();
public:
conjugate_cc();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif

View File

@ -0,0 +1,29 @@
#include "conjugate_ic.h"
#include <gnuradio/io_signature.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
conjugate_ic_sptr make_conjugate_ic()
{
return conjugate_ic_sptr(new conjugate_ic());
}
conjugate_ic::conjugate_ic() : gr::sync_block("conjugate_ic",
gr::io_signature::make (1, 1, sizeof(lv_8sc_t)),
gr::io_signature::make (1, 1, sizeof(lv_8sc_t)))
{
const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_8sc_t);
set_alignment(std::max(1, alignment_multiple));
}
int conjugate_ic::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const lv_8sc_t *in = reinterpret_cast<const lv_8sc_t *>(input_items[0]);
lv_8sc_t *out = reinterpret_cast<lv_8sc_t *>(output_items[0]);
volk_gnsssdr_8ic_conjugate_8ic(out, in, noutput_items);
return noutput_items;
}

View File

@ -0,0 +1,59 @@
/*!
* \file conjugate_ic.h
* \brief Adapts a std::complex<short> stream into two float streams
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (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_CONJUGATE_IC_H_
#define GNSS_SDR_CONJUGATE_IC_H_
#include <boost/shared_ptr.hpp>
#include <gnuradio/sync_block.h>
class conjugate_ic;
typedef boost::shared_ptr<conjugate_ic> conjugate_ic_sptr;
conjugate_ic_sptr make_conjugate_ic();
/*!
* \brief This class adapts a std::complex<short> stream
* into two 32-bits (float) streams
*/
class conjugate_ic : public gr::sync_block
{
private:
friend conjugate_ic_sptr make_conjugate_ic();
public:
conjugate_ic();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif

View File

@ -0,0 +1,29 @@
#include "conjugate_sc.h"
#include <gnuradio/io_signature.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
conjugate_sc_sptr make_conjugate_sc()
{
return conjugate_sc_sptr(new conjugate_sc());
}
conjugate_sc::conjugate_sc() : gr::sync_block("conjugate_sc",
gr::io_signature::make (1, 1, sizeof(lv_16sc_t)),
gr::io_signature::make (1, 1, sizeof(lv_16sc_t)))
{
const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_16sc_t);
set_alignment(std::max(1, alignment_multiple));
}
int conjugate_sc::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const lv_16sc_t *in = reinterpret_cast<const lv_16sc_t *>(input_items[0]);
lv_16sc_t *out = reinterpret_cast<lv_16sc_t *>(output_items[0]);
volk_gnsssdr_16ic_conjugate_16ic(out, in, noutput_items);
return noutput_items;
}

View File

@ -0,0 +1,59 @@
/*!
* \file conjugate_sc.h
* \brief Adapts a std::complex<short> stream into two float streams
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2017 (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_CONJUGATE_SC_H_
#define GNSS_SDR_CONJUGATE_SC_H_
#include <boost/shared_ptr.hpp>
#include <gnuradio/sync_block.h>
class conjugate_sc;
typedef boost::shared_ptr<conjugate_sc> conjugate_sc_sptr;
conjugate_sc_sptr make_conjugate_sc();
/*!
* \brief This class adapts a std::complex<short> stream
* into two 32-bits (float) streams
*/
class conjugate_sc : public gr::sync_block
{
private:
friend conjugate_sc_sptr make_conjugate_sc();
public:
conjugate_sc();
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
#endif

View File

@ -57,7 +57,7 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
}
item_type_ = configuration->property(role + ".item_type", input_type);
vector_size_ = configuration->property(role + ".vector_size", 1);
inverted_spectrum = configuration->property(role + ".inverted_spectrum", false);
if(item_type_.compare("float") == 0)
{
@ -66,6 +66,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
else if(item_type_.compare("gr_complex") == 0)
{
item_size_ = sizeof(gr_complex);
if(inverted_spectrum)
{
conjugate_cc_ = make_conjugate_cc();
}
}
else if(item_type_.compare("short") == 0)
{
@ -78,6 +82,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
else if(item_type_.compare("cshort") == 0)
{
item_size_ = sizeof(lv_16sc_t);
if(inverted_spectrum)
{
conjugate_sc_ = make_conjugate_sc();
}
}
else if(item_type_.compare("byte") == 0)
{
@ -90,12 +98,17 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro
else if(item_type_.compare("cbyte") == 0)
{
item_size_ = sizeof(lv_8sc_t);
if(inverted_spectrum)
{
conjugate_ic_ = make_conjugate_ic();
}
}
else
{
LOG(WARNING) << item_type_ << " unrecognized item type. Using float";
item_size_ = sizeof(float);
}
kludge_copy_ = gr::blocks::copy::make(item_size_);
DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")";
}
@ -125,6 +138,27 @@ void Pass_Through::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr Pass_Through::get_left_block()
{
if(inverted_spectrum)
{
if(item_type_.compare("gr_complex") == 0)
{
return conjugate_cc_;
}
else if(item_type_.compare("cshort") == 0)
{
return conjugate_sc_;
}
else if(item_type_.compare("cbyte") == 0)
{
return conjugate_ic_;
}
else
{
LOG(WARNING) << "Setting inverted_spectrum to true with item_type "
<< item_type_ << " is not defined and has no effect.";
}
}
return kludge_copy_;
}
@ -132,5 +166,26 @@ gr::basic_block_sptr Pass_Through::get_left_block()
gr::basic_block_sptr Pass_Through::get_right_block()
{
if(inverted_spectrum)
{
if(item_type_.compare("gr_complex") == 0)
{
return conjugate_cc_;
}
else if(item_type_.compare("cshort") == 0)
{
return conjugate_sc_;
}
else if(item_type_.compare("cbyte") == 0)
{
return conjugate_ic_;
}
else
{
DLOG(WARNING) << "Setting inverted_spectrum to true with item_type "
<< item_type_ << " is not defined and has no effect.";
}
}
return kludge_copy_;
}

View File

@ -37,6 +37,10 @@
#include <gnuradio/hier_block2.h>
#include <gnuradio/blocks/copy.h>
#include "gnss_block_interface.h"
#include "conjugate_cc.h"
#include "conjugate_sc.h"
#include "conjugate_ic.h"
class ConfigurationInterface;
@ -69,11 +73,6 @@ public:
return item_type_;
}
inline size_t vector_size() const
{
return vector_size_;
}
inline size_t item_size() override
{
return item_size_;
@ -86,13 +85,16 @@ public:
private:
std::string item_type_;
size_t vector_size_;
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;
//gr_kludge_copy_sptr kludge_copy_;
gr::blocks::copy::sptr kludge_copy_;
size_t item_size_;
conjugate_cc_sptr conjugate_cc_;
conjugate_sc_sptr conjugate_sc_;
conjugate_ic_sptr conjugate_ic_;
bool inverted_spectrum;
};
#endif /*GNSS_SDR_PASS_THROUGH_H_*/

View File

@ -41,9 +41,6 @@ TEST(PassThroughTest, Instantiate)
{
std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();
config->set_property("Test.item_type", "gr_complex");
config->set_property("Test.vector_size", "2");
std::shared_ptr<Pass_Through> signal_conditioner = std::make_shared<Pass_Through>(config.get(), "Test", 1, 1);
EXPECT_STREQ("gr_complex", signal_conditioner->item_type().c_str());
unsigned int expected2 = 2;
EXPECT_EQ(expected2, signal_conditioner->vector_size());
}