1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-18 11:09:56 +00:00

Reverted to gnss-sdr style naming for item_types

i8->byte
ic8->cbyte
...
fc32->gr_complex
This commit is contained in:
Cillian O'Driscoll 2019-11-15 11:39:05 +00:00
parent 3d27940b0a
commit feab31ae6b
12 changed files with 166 additions and 258 deletions

View File

@ -200,15 +200,15 @@ float BeidouB1iPcpsAcquisition::calculate_threshold(float pfa)
void BeidouB1iPcpsAcquisition::connect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to connect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to connect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
// Since a byte-based acq implementation is not available,
// we just convert cshorts to gr_complex
@ -225,15 +225,15 @@ void BeidouB1iPcpsAcquisition::connect(gr::top_block_sptr top_block)
void BeidouB1iPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to disconnect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to disconnect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0);
top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1);
@ -248,15 +248,15 @@ void BeidouB1iPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr BeidouB1iPcpsAcquisition::get_left_block()
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
return acquisition_;
}
if (item_type_ == "ic16")
if (item_type_ == "cshort")
{
return acquisition_;
}
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
return cbyte_to_float_x2_;
}

View File

@ -201,15 +201,15 @@ float BeidouB3iPcpsAcquisition::calculate_threshold(float pfa)
void BeidouB3iPcpsAcquisition::connect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to connect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to connect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
// Since a byte-based acq implementation is not available,
// we just convert cshorts to gr_complex
@ -226,15 +226,15 @@ void BeidouB3iPcpsAcquisition::connect(gr::top_block_sptr top_block)
void BeidouB3iPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to disconnect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to disconnect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0);
top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1);
@ -249,15 +249,15 @@ void BeidouB3iPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr BeidouB3iPcpsAcquisition::get_left_block()
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
return acquisition_;
}
if (item_type_ == "ic16")
if (item_type_ == "cshort")
{
return acquisition_;
}
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
return cbyte_to_float_x2_;
}

View File

@ -69,7 +69,7 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition(
acquisition_ = pcps_make_acquisition(acq_parameters_);
DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")";
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
cbyte_to_float_x2_ = make_complex_byte_to_float_x2();
float_to_complex_ = gr::blocks::float_to_complex::make();
@ -249,15 +249,15 @@ float GalileoE1PcpsAmbiguousAcquisition::calculate_threshold(float pfa)
void GalileoE1PcpsAmbiguousAcquisition::connect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to connect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to connect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
// Since a byte-based acq implementation is not available,
// we just convert cshorts to gr_complex
@ -274,15 +274,15 @@ void GalileoE1PcpsAmbiguousAcquisition::connect(gr::top_block_sptr top_block)
void GalileoE1PcpsAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to disconnect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to disconnect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0);
top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1);
@ -297,15 +297,15 @@ void GalileoE1PcpsAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisition::get_left_block()
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
return acquisition_;
}
if (item_type_ == "ic16")
if (item_type_ == "cshort")
{
return acquisition_;
}
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
return cbyte_to_float_x2_;
}

View File

@ -234,11 +234,11 @@ void GalileoE5aPcpsAcquisition::set_state(int state)
void GalileoE5aPcpsAcquisition::connect(gr::top_block_sptr top_block __attribute__((unused)))
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to connect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to connect
}
@ -251,11 +251,11 @@ void GalileoE5aPcpsAcquisition::connect(gr::top_block_sptr top_block __attribute
void GalileoE5aPcpsAcquisition::disconnect(gr::top_block_sptr top_block __attribute__((unused)))
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to disconnect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to disconnect
}

View File

@ -71,7 +71,7 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition(
acquisition_ = pcps_make_acquisition(acq_parameters_);
DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")";
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
cbyte_to_float_x2_ = make_complex_byte_to_float_x2();
float_to_complex_ = gr::blocks::float_to_complex::make();
@ -210,15 +210,15 @@ float GlonassL1CaPcpsAcquisition::calculate_threshold(float pfa)
void GlonassL1CaPcpsAcquisition::connect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to connect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to connect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0);
top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1);
@ -233,15 +233,15 @@ void GlonassL1CaPcpsAcquisition::connect(gr::top_block_sptr top_block)
void GlonassL1CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to disconnect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to disconnect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
// Since a byte-based acq implementation is not available,
// we just convert cshorts to gr_complex
@ -258,15 +258,15 @@ void GlonassL1CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr GlonassL1CaPcpsAcquisition::get_left_block()
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
return acquisition_;
}
if (item_type_ == "ic16")
if (item_type_ == "cshort")
{
return acquisition_;
}
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
return cbyte_to_float_x2_;
}

View File

@ -70,7 +70,7 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition(
acquisition_ = pcps_make_acquisition(acq_parameters_);
DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")";
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
cbyte_to_float_x2_ = make_complex_byte_to_float_x2();
float_to_complex_ = gr::blocks::float_to_complex::make();
@ -209,15 +209,15 @@ float GlonassL2CaPcpsAcquisition::calculate_threshold(float pfa)
void GlonassL2CaPcpsAcquisition::connect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to connect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to connect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
// Since a byte-based acq implementation is not available,
// we just convert cshorts to gr_complex
@ -234,15 +234,15 @@ void GlonassL2CaPcpsAcquisition::connect(gr::top_block_sptr top_block)
void GlonassL2CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to disconnect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to disconnect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0);
top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1);
@ -257,15 +257,15 @@ void GlonassL2CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr GlonassL2CaPcpsAcquisition::get_left_block()
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
return acquisition_;
}
if (item_type_ == "ic16")
if (item_type_ == "cshort")
{
return acquisition_;
}
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
return cbyte_to_float_x2_;
}

View File

@ -74,7 +74,7 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition(
acquisition_ = pcps_make_acquisition(acq_parameters_);
DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")";
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
cbyte_to_float_x2_ = make_complex_byte_to_float_x2();
float_to_complex_ = gr::blocks::float_to_complex::make();
@ -220,15 +220,15 @@ float GpsL1CaPcpsAcquisition::calculate_threshold(float pfa)
void GpsL1CaPcpsAcquisition::connect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to connect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to connect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
// Since a byte-based acq implementation is not available,
// we just convert cshorts to gr_complex
@ -245,15 +245,15 @@ void GpsL1CaPcpsAcquisition::connect(gr::top_block_sptr top_block)
void GpsL1CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to disconnect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to disconnect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0);
top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1);
@ -268,15 +268,15 @@ void GpsL1CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr GpsL1CaPcpsAcquisition::get_left_block()
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
return acquisition_;
}
if (item_type_ == "ic16")
if (item_type_ == "cshort")
{
return acquisition_;
}
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
return cbyte_to_float_x2_;
}

View File

@ -69,7 +69,7 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition(
acquisition_ = pcps_make_acquisition(acq_parameters_);
DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")";
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
cbyte_to_float_x2_ = make_complex_byte_to_float_x2();
float_to_complex_ = gr::blocks::float_to_complex::make();
@ -223,15 +223,15 @@ float GpsL2MPcpsAcquisition::calculate_threshold(float pfa)
void GpsL2MPcpsAcquisition::connect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to connect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to connect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
// Since a byte-based acq implementation is not available,
// we just convert cshorts to gr_complex
@ -248,15 +248,15 @@ void GpsL2MPcpsAcquisition::connect(gr::top_block_sptr top_block)
void GpsL2MPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to disconnect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to disconnect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0);
top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1);
@ -271,15 +271,15 @@ void GpsL2MPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr GpsL2MPcpsAcquisition::get_left_block()
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
return acquisition_;
}
if (item_type_ == "ic16")
if (item_type_ == "cshort")
{
return acquisition_;
}
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
return cbyte_to_float_x2_;
}

View File

@ -71,7 +71,7 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition(
acquisition_ = pcps_make_acquisition(acq_parameters_);
DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")";
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
cbyte_to_float_x2_ = make_complex_byte_to_float_x2();
float_to_complex_ = gr::blocks::float_to_complex::make();
@ -224,15 +224,15 @@ float GpsL5iPcpsAcquisition::calculate_threshold(float pfa)
void GpsL5iPcpsAcquisition::connect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to connect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to connect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
// Since a byte-based acq implementation is not available,
// we just convert cshorts to gr_complex
@ -249,15 +249,15 @@ void GpsL5iPcpsAcquisition::connect(gr::top_block_sptr top_block)
void GpsL5iPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
// nothing to disconnect
}
else if (item_type_ == "ic16")
else if (item_type_ == "cshort")
{
// nothing to disconnect
}
else if (item_type_ == "ic8")
else if (item_type_ == "cbyte")
{
top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0);
top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1);
@ -272,15 +272,15 @@ void GpsL5iPcpsAcquisition::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr GpsL5iPcpsAcquisition::get_left_block()
{
if (item_type_ == "fc32")
if (item_type_ == "gr_complex")
{
return acquisition_;
}
if (item_type_ == "ic16")
if (item_type_ == "cshort")
{
return acquisition_;
}
if (item_type_ == "ic8")
if (item_type_ == "cbyte")
{
return cbyte_to_float_x2_;
}

View File

@ -71,7 +71,6 @@ void Acq_Conf::SetFromConfiguration(ConfigurationInterface *configuration,
const std::string &role, double chip_rate, double opt_freq)
{
item_type = configuration->property(role + ".item_type", item_type);
item_type = external_item_type_to_internal(item_type);
if (!item_type_valid(item_type))
{
throw std::invalid_argument("Unknown item type: " + item_type);

View File

@ -35,45 +35,11 @@
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cstring> // memcpy
std::string external_item_type_to_internal(const std::string &external_item_type)
{
std::string internal_item_type("");
if (external_item_type == "byte")
{
internal_item_type = "i8";
}
else if (external_item_type == "ibyte" || external_item_type == "cbyte")
{
internal_item_type = "ic8";
}
else if (external_item_type == "short")
{
internal_item_type = "i16";
}
else if (external_item_type == "ishort" || external_item_type == "cshort")
{
internal_item_type = "ic16";
}
else if (external_item_type == "float")
{
internal_item_type = "f32";
}
else if (external_item_type == "gr_complex")
{
internal_item_type = "fc32";
}
return internal_item_type;
}
bool item_type_valid(const std::string &item_type)
{
if (item_type != "i8" and item_type != "ic8" and
item_type != "i16" and item_type != "ic16" and
item_type != "i32" and item_type != "ic32" and
item_type != "f32" and item_type != "fc32")
if (item_type != "byte" and item_type != "cbyte" and item_type != "ibyte" and
item_type != "short" and item_type != "cshort" and item_type != "ishort" and
item_type != "float" and item_type != "gr_complex")
{
return false;
}
@ -83,35 +49,27 @@ bool item_type_valid(const std::string &item_type)
size_t item_type_size(const std::string &item_type)
{
if (item_type == "i8")
if (item_type == "byte" or item_type == "ibyte")
{
return sizeof(int8_t);
}
else if (item_type == "ic8")
else if (item_type == "cbyte")
{
return 2 * sizeof(int8_t);
}
else if (item_type == "i16")
else if (item_type == "short" or item_type == "ishort" )
{
return sizeof(int16_t);
}
else if (item_type == "ic16")
else if (item_type == "cshort")
{
return 2 * sizeof(int16_t);
}
else if (item_type == "i32")
{
return sizeof(int32_t);
}
else if (item_type == "ic32")
{
return 2 * sizeof(int32_t);
}
else if (item_type == "f32")
else if (item_type == "float")
{
return sizeof(float);
}
else if (item_type == "fc32")
else if (item_type == "gr_complex")
{
return 2 * sizeof(float);
}
@ -121,14 +79,9 @@ size_t item_type_size(const std::string &item_type)
}
}
// VOLK doesnt do 32 bit integer converters
template <typename OT>
void convert_32i_generic(OT *dest, const int32_t *src, unsigned int num_items)
bool item_type_is_complex(const std::string &item_type)
{
for (unsigned int i = 0; i < num_items; ++i)
{
dest[i] = static_cast<OT>(src[i]);
}
return (item_type == "ibyte") or (item_type == "cbyte") or (item_type == "ishort") or (item_type == "cshort") or (item_type == "gr_complex");
}
void copy_converter(void *dest, const void *src, unsigned int num_items, size_t item_size)
@ -184,42 +137,6 @@ void convert_16ic_32fc(void *dest, const void *src, unsigned int num_items)
reinterpret_cast<const int16_t *>(src), 1.0f, 2 * num_items);
}
void convert_32i_8i(void *dest, const void *src, unsigned int num_items)
{
convert_32i_generic<int8_t>(reinterpret_cast<int8_t *>(dest),
reinterpret_cast<const int32_t *>(src), num_items);
}
void convert_32i_16i(void *dest, const void *src, unsigned int num_items)
{
convert_32i_generic<int16_t>(reinterpret_cast<int16_t *>(dest),
reinterpret_cast<const int32_t *>(src), num_items);
}
void convert_32i_32f(void *dest, const void *src, unsigned int num_items)
{
convert_32i_generic<float>(reinterpret_cast<float *>(dest),
reinterpret_cast<const int32_t *>(src), num_items);
}
void convert_32ic_8ic(void *dest, const void *src, unsigned int num_items)
{
convert_32i_generic<int8_t>(reinterpret_cast<int8_t *>(dest),
reinterpret_cast<const int32_t *>(src), 2 * num_items);
}
void convert_32ic_16ic(void *dest, const void *src, unsigned int num_items)
{
convert_32i_generic<int16_t>(reinterpret_cast<int16_t *>(dest),
reinterpret_cast<const int32_t *>(src), 2 * num_items);
}
void convert_32ic_32fc(void *dest, const void *src, unsigned int num_items)
{
convert_32i_generic<float>(reinterpret_cast<float *>(dest),
reinterpret_cast<const int32_t *>(src), 2 * num_items);
}
void convert_32f_8i(void *dest, const void *src, unsigned int num_items)
{
volk_32f_s32f_convert_8i(reinterpret_cast<int8_t *>(dest),
@ -244,29 +161,6 @@ void convert_32fc_16ic(void *dest, const void *src, unsigned int num_items)
reinterpret_cast<const float *>(src), 1.0f, 2 * num_items);
}
/*!
* \brief Create a function to convert an array of input_type to an array of output_type
*
* \description Provides a generic interface to generate conversion functions for mapping
* arrays of items.
*
* \param input_type - String representation of the input item type
* \param output_type - String representation of the output item type
*
* The item types accepted are:
*
* 1. "i8" for 8 bit integers
* 2. "ic8" for complex (interleaved) 8 bit integers
* 3. "i16" for 16 bit integers
* 4. "ic16" for complex (interleaved) 16 bit integers
* 5. "f32" for 32 bit floating point values
* 6. "fc32" for complex (interleaved) 32 bit floating point values
*
* \returns A function object with the following prototype:
* void convert_fun( void *dest, void *src, int num_items );
*
*
*/
item_type_converter_t make_vector_converter(std::string input_type,
std::string output_type)
{
@ -282,115 +176,129 @@ item_type_converter_t make_vector_converter(std::string input_type,
std::placeholders::_3, input_size);
}
if (input_type == "i8")
if (input_type == "byte")
{
if (output_type == "i16")
if (output_type == "short")
{
return std::bind(convert_8i_16i, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
else if (output_type == "f32")
else if (output_type == "float")
{
return std::bind(convert_8i_32f, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
}
else if (input_type == "ic8")
else if (input_type == "cbyte")
{
if (output_type == "ic16")
if (output_type == "ibyte" )
{
size_t input_size = item_type_size(input_type);
return std::bind(copy_converter, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, input_size);
}
if (output_type == "cshort" or output_type == "ishort" )
{
return std::bind(convert_8ic_16ic, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
else if (output_type == "fc32")
else if (output_type == "gr_complex")
{
return std::bind(convert_8ic_32fc, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
}
else if (input_type == "i16")
else if (input_type == "ibyte")
{
if (output_type == "i8")
if (output_type == "cbyte" )
{
size_t input_size = item_type_size(input_type);
return std::bind(copy_converter, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, input_size);
}
else if (output_type == "cshort" or output_type == "ishort")
{
return std::bind(convert_8i_16i, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
else if (output_type == "gr_complex")
{
return std::bind(convert_8i_32f, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
}
else if (input_type == "short")
{
if (output_type == "byte")
{
return std::bind(convert_16i_8i, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
else if (output_type == "f32")
else if (output_type == "float")
{
return std::bind(convert_16i_32f, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
}
else if (input_type == "ic16")
else if (input_type == "cshort")
{
if (output_type == "ic8")
if (output_type == "cbyte" or output_type == "ibyte" )
{
return std::bind(convert_16ic_8ic, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
else if (output_type == "fc32")
if (output_type == "ishort")
{
size_t input_size = item_type_size(input_type);
return std::bind(copy_converter, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, input_size);
}
else if (output_type == "gr_complex")
{
return std::bind(convert_16ic_32fc, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
}
else if (input_type == "i32")
else if (input_type == "ishort")
{
if (output_type == "i8")
if (output_type == "cbyte" or output_type == "ibyte" )
{
return std::bind(convert_32i_8i, std::placeholders::_1,
return std::bind(convert_16i_8i, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
else if (output_type == "i16")
if (output_type == "cshort")
{
return std::bind(convert_32i_16i, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
size_t input_size = item_type_size(input_type);
return std::bind(copy_converter, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, input_size);
}
else if (output_type == "f32")
else if (output_type == "gr_complex")
{
return std::bind(convert_32i_32f, std::placeholders::_1,
return std::bind(convert_16i_32f, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
}
else if (input_type == "ic32")
else if (input_type == "float")
{
if (output_type == "ic8")
{
return std::bind(convert_32ic_8ic, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
else if (output_type == "ic16")
{
return std::bind(convert_32ic_16ic, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
else if (output_type == "fc32")
{
return std::bind(convert_32ic_32fc, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
}
else if (input_type == "f32")
{
if (output_type == "i8")
if (output_type == "byte")
{
return std::bind(convert_32f_8i, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
else if (output_type == "i16")
else if (output_type == "short")
{
return std::bind(convert_32f_16i, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
}
else if (input_type == "fc32")
else if (input_type == "gr_complex")
{
if (output_type == "ic8")
if (output_type == "cbyte" or output_type == "ibyte")
{
return std::bind(convert_32fc_8ic, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
}
else if (output_type == "ic16")
else if (output_type == "cshort" or output_type == "ishort" )
{
return std::bind(convert_32fc_16ic, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);

View File

@ -38,20 +38,13 @@
#include <string>
using item_type_converter_t = std::function<void(void *, const void *, unsigned)>;
/*!
* \brief Convert a gnss-sdr item type string to internal
*/
std::string external_item_type_to_internal(const std::string &external_item_type);
/*!
* \brief Check if a string is a valid item type
*
* \description Valid item types include:
* "i8", "ic8", "i16", "ic16", "i32", "ic32", "f32", "fc32"
* "byte", "short", "float", "ibyte", "ishort", "cbyte", "cshort", "gr_complex"
*
* where "i" denotes integer, "f" denotes float and "c" is for complex and
* the number indicates the number of bits in the representation
*/
bool item_type_valid(const std::string &item_type);
@ -60,6 +53,12 @@ bool item_type_valid(const std::string &item_type);
*/
size_t item_type_size(const std::string &item_type);
/*!
* \brief Determine if an item_type is complex
*/
bool item_type_is_complex(const std::string &item_type);
/*!
* \brief Create a function to convert an array of input_type to an array of output_type
*
@ -71,12 +70,14 @@ size_t item_type_size(const std::string &item_type);
*
* The item types accepted are:
*
* 1. "i8" for 8 bit integers
* 2. "ic8" for complex (interleaved) 8 bit integers
* 3. "i16" for 16 bit integers
* 4. "ic16" for complex (interleaved) 16 bit integers
* 5. "f32" for 32 bit floating point values
* 6. "fc32" for complex (interleaved) 32 bit floating point values
* 1. "byte" for 8 bit integers
* 2. "cbyte" for complex (interleaved) 8 bit integers
* 4. "ibyte" for complex (interleaved) 8 bit integers
* 4. "short" for 16 bit integers
* 5. "cshort" for complex (interleaved) 16 bit integers
* 6. "ishort" for complex (interleaved) 16 bit integers
* 7. "float" for 32 bit floating point values
* 8. "gr_complex" for complex (interleaved) 32 bit floating point values
*
* \returns A function object with the following prototype:
* void convert_fun( void *dest, void *src, int num_items );