1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-11-10 20:10:05 +00:00

Fix formatting

This commit is contained in:
Victor Castillo 2024-08-17 23:31:27 +02:00
parent a99ceafe85
commit 27465f6a70
No known key found for this signature in database
GPG Key ID: 8EF1FC8B7182F608
9 changed files with 117 additions and 106 deletions

View File

@ -14,13 +14,13 @@
* -----------------------------------------------------------------------------
*/
#include "ion_gsms_signal_source.h"
#include "gnss_sdr_flags.h"
#include "gnss_sdr_string_literals.h"
#include "ion_gsms_signal_source.h"
#include <gnuradio/blocks/copy.h>
#include <string>
#include <vector>
#include <unordered_set>
#include <vector>
#if USE_GLOG_AND_GFLAGS
#include <glog/logging.h>
@ -53,7 +53,7 @@ IONGSMSSignalSource::IONGSMSSignalSource(const ConfigurationInterface* configura
const std::string& role,
unsigned int in_streams,
unsigned int out_streams,
Concurrent_Queue<pmt::pmt_t>* queue)
Concurrent_Queue<pmt::pmt_t>* queue __attribute__((unused)))
: SignalSourceBase(configuration, role, "ION_GSMS_Signal_Source"s),
metadata_file_(configuration->property(role + ".metadata_filename"s, "../data/example_capture_metadata.sdrx"s)),
stream_ids_(parse_comma_list(configuration->property(role + ".streams"s, ""s))),
@ -71,7 +71,7 @@ IONGSMSSignalSource::IONGSMSSignalSource(const ConfigurationInterface* configura
for (const auto& source : sources_)
{
for (int i = 0; i < source->output_stream_count(); ++i)
for (std::size_t i = 0; i < source->output_stream_count(); ++i)
{
copy_blocks_.push_back(gr::blocks::copy::make(source->output_stream_item_size(i)));
}
@ -84,7 +84,7 @@ void IONGSMSSignalSource::connect(gr::top_block_sptr top_block)
std::size_t cumulative_index = 0;
for (const auto& source : sources_)
{
for (int i = 0; i < source->output_stream_count(); ++i, ++cumulative_index)
for (std::size_t i = 0; i < source->output_stream_count(); ++i, ++cumulative_index)
{
top_block->connect(source, i, copy_blocks_[cumulative_index], 0);
}
@ -96,7 +96,7 @@ void IONGSMSSignalSource::disconnect(gr::top_block_sptr top_block)
std::size_t cumulative_index = 0;
for (const auto& source : sources_)
{
for (int i = 0; i < source->output_stream_count(); ++i, ++cumulative_index)
for (std::size_t i = 0; i < source->output_stream_count(); ++i, ++cumulative_index)
{
top_block->disconnect(source, i, copy_blocks_[cumulative_index], 0);
}

View File

@ -57,6 +57,7 @@ protected:
{
return (*sources_.begin())->output_stream_item_size(0);
}
private:
std::string metadata_file_;
std::vector<std::string> stream_ids_;

View File

@ -14,25 +14,24 @@
* -----------------------------------------------------------------------------
*/
#include "gnuradio/block.h"
#include "ion_gsms.h"
#include <memory>
#include "gnuradio/block.h"
#include <algorithm>
#include <memory>
#include <vector>
#if USE_GLOG_AND_GFLAGS
#include <glog/logging.h>
#else
#include <absl/log/log.h>
#include <utility>
#endif
using namespace std::string_literals;
IONGSMSFileSource::IONGSMSFileSource(
const ConfigurationInterface* configuration,
const std::string& role,
const ConfigurationInterface* configuration __attribute__((unused)),
const std::string& role __attribute__((unused)),
const std::filesystem::path& metadata_filepath,
const GnssMetadata::File& file,
const GnssMetadata::Block& block,
@ -75,18 +74,18 @@ IONGSMSFileSource::~IONGSMSFileSource()
int IONGSMSFileSource::work(
int noutput_items,
gr_vector_const_void_star& input_items,
gr_vector_const_void_star& input_items __attribute__((unused)),
gr_vector_void_star& output_items)
{
const std::size_t max_sample_output = std::floor((noutput_items-1.0) / maximum_item_rate_);
const std::size_t max_sample_output = std::floor((noutput_items - 1.0) / maximum_item_rate_);
io_buffer_.resize(max_sample_output * chunk_cycle_length_);
io_buffer_offset_ = 0;
std::fread(io_buffer_.data(), sizeof(decltype(io_buffer_)::value_type), io_buffer_.size(), fd_);
items_produced_.resize(output_items.size());
for (std::size_t i = 0; i < items_produced_.size(); ++i)
for (int& i : items_produced_)
{
items_produced_[i] = 0;
i = 0;
}
while (io_buffer_offset_ < io_buffer_.size())
@ -121,7 +120,7 @@ std::size_t IONGSMSFileSource::output_stream_item_size(std::size_t stream_index)
gr::io_signature::sptr IONGSMSFileSource::make_output_signature(const GnssMetadata::Block& block, const std::vector<std::string>& stream_ids)
{
int nstreams = 0;
std::vector<size_t> item_sizes{};
std::vector<int> item_sizes{};
for (const auto& chunk : block.Chunks())
{
@ -129,9 +128,16 @@ gr::io_signature::sptr IONGSMSFileSource::make_output_signature(const GnssMetada
{
for (const auto& stream : lump.Streams())
{
if (std::ranges::any_of(stream_ids.begin(), stream_ids.end(), [&](const std::string& it) {
return stream.Id() == it;
}))
bool found = false;
for (const auto& stream_id : stream_ids)
{
if (stream_id == stream.Id())
{
found = true;
break;
}
}
if (found)
{
++nstreams;
std::size_t sample_bitsize = stream.Packedbits() / stream.RateFactor();
@ -146,10 +152,8 @@ gr::io_signature::sptr IONGSMSFileSource::make_output_signature(const GnssMetada
}
}
return gr::io_signature::make(
return gr::io_signature::makev(
nstreams,
nstreams,
item_sizes);
}

View File

@ -17,14 +17,14 @@
#ifndef GNSS_SDR_ION_GNSS_SDR_METADATA_STANDARD_H
#define GNSS_SDR_ION_GNSS_SDR_METADATA_STANDARD_H
#include "configuration_interface.h"
#include "gnss_block_interface.h"
#include "ion_gsms_chunk_data.h"
#include "configuration_interface.h"
#include <gnuradio/block.h>
#include <gnuradio/sync_block.h>
#include <filesystem>
#include <string>
#include <memory>
#include <string>
#include <vector>

View File

@ -30,8 +30,7 @@ IONGSMSChunkData::IONGSMSChunkData(const GnssMetadata::Chunk& chunk, const std::
sizeword_(chunk_.SizeWord()),
countwords_(chunk_.CountWords())
{
with_word_type(sizeword_, [&]<typename WordType>
{
with_word_type(sizeword_, [&]<typename WordType> {
buffer_ = new WordType[countwords_];
});
@ -44,9 +43,16 @@ IONGSMSChunkData::IONGSMSChunkData(const GnssMetadata::Chunk& chunk, const std::
{
used_bitsize += stream.Packedbits();
if (std::ranges::any_of(stream_ids.begin(), stream_ids.end(), [&](const std::string& it) {
return stream.Id() == it;
}))
bool found = false;
for (const auto& stream_id : stream_ids)
{
if (stream_id == stream.Id())
{
found = true;
break;
}
}
if (found)
{
streams_.emplace_back(lump, stream, GnssMetadata::encoding_from_string(stream.Encoding()), output_streams + output_stream_offset);
++output_streams;
@ -75,8 +81,7 @@ IONGSMSChunkData::IONGSMSChunkData(const GnssMetadata::Chunk& chunk, const std::
IONGSMSChunkData::~IONGSMSChunkData()
{
with_word_type(sizeword_, [&]<typename WordType>
{
with_word_type(sizeword_, [&]<typename WordType> {
delete[] static_cast<WordType*>(buffer_);
});
}
@ -215,7 +220,6 @@ void IONGSMSChunkData::write_n_samples(
{
*sample = 0;
ctx.shift_sample(sample_bitsize, sample);
dump_sample(*sample);
decode_sample(sample_bitsize, sample, stream_encoding);
--sample;
}
@ -227,7 +231,6 @@ void IONGSMSChunkData::write_n_samples(
{
*sample = 0;
ctx.shift_sample(sample_bitsize, sample);
dump_sample(*sample);
decode_sample(sample_bitsize, sample, stream_encoding);
++sample;
}
@ -237,7 +240,6 @@ void IONGSMSChunkData::write_n_samples(
}
// Static utilities
void IONGSMSChunkData::decode_sample(const uint8_t sample_bitsize, auto* sample, const GnssMetadata::StreamEncoding encoding)
{
@ -262,14 +264,3 @@ void IONGSMSChunkData::decode_sample(const uint8_t sample_bitsize, auto* sample,
break;
}
}
void IONGSMSChunkData::dump_sample(auto value)
{
static int count = 100;
if (count > 0)
{
--count;
// std::cout << "SAMPLE: [0x" << std::hex << value << "] " << std::bitset<32>(value) << std::endl;
}
}

View File

@ -18,8 +18,8 @@
#define ION_GSM_CHUNK_DATA_H
#include "GnssMetadata.h"
#include "ion_gsms_stream_encodings.h"
#include "ion_gsms_chunk_unpacking_ctx.h"
#include "ion_gsms_stream_encodings.h"
#include <gnuradio/block.h>
#include <string>
#include <vector>
@ -120,8 +120,6 @@ private:
static void decode_sample(uint8_t sample_bitsize, auto* sample, GnssMetadata::StreamEncoding encoding);
static void dump_sample(auto value);
private:
const GnssMetadata::Chunk& chunk_;
uint8_t sizeword_;
@ -137,6 +135,17 @@ private:
const GnssMetadata::IonStream& stream;
GnssMetadata::StreamEncoding stream_encoding;
int output_index = -1;
stream_metadata_t(
const GnssMetadata::Lump& lump_,
const GnssMetadata::IonStream& stream_,
GnssMetadata::StreamEncoding stream_encoding_,
int output_index_ = -1) : lump(lump_),
stream(stream_),
stream_encoding(stream_encoding_),
output_index(output_index_)
{
}
};
std::vector<stream_metadata_t> streams_;

View File

@ -64,6 +64,7 @@ std::vector<IONGSMSFileSource::sptr> IONGSMSMetadataHandler::make_stream_sources
{
for (const auto& block : lane.Blocks())
{
bool block_done = false;
for (const auto& chunk : block.Chunks())
{
for (const auto& lump : chunk.Lumps())
@ -71,7 +72,7 @@ std::vector<IONGSMSFileSource::sptr> IONGSMSMetadataHandler::make_stream_sources
for (const auto& stream : lump.Streams())
{
bool found = false;
for (const auto & stream_id : stream_ids)
for (const auto& stream_id : stream_ids)
{
if (stream_id == stream.Id())
{
@ -93,12 +94,21 @@ std::vector<IONGSMSFileSource::sptr> IONGSMSMetadataHandler::make_stream_sources
// This file source will take care of any other matching streams in this block
// We can skip the rest of this block
goto next_block;
block_done = true;
break;
}
}
if (block_done)
{
break;
}
}
if (block_done)
{
break;
}
}
next_block:
}
break;
}
@ -107,4 +117,3 @@ std::vector<IONGSMSFileSource::sptr> IONGSMSMetadataHandler::make_stream_sources
return sources;
}

View File

@ -104,67 +104,63 @@ inline StreamEncoding encoding_from_string(const std::string& str)
}
template <typename T>
inline T two_bit_look_up[11][4]
{
[0] = {},
[1 /*OB*/] = {-2, -1, 0, 1},
[2 /*SM*/] = {0, 1, 0, -1},
[3 /*MS*/] = {0, 0, 1, -1},
[4 /*TC*/] = {0, 1, -2, -1},
[5 /*OG*/] = {-2, -1, 1, 0},
[6 /*OBA*/] = {-3, -1, 1, 3},
[7 /*SMA*/] = {1, 3, -1, -3},
[8 /*MSA*/] = {1, -1, 3, -3},
[9 /*TCA*/] = {1, 3, -3, -1},
[10 /*OGA*/] = {-3, -1, 3, 1},
inline T two_bit_look_up[11][4]{
{}, // [0]
{-2, -1, 0, 1}, // [1 /*OB*/]
{0, 1, 0, -1}, // [2 /*SM*/]
{0, 0, 1, -1}, // [3 /*MS*/]
{0, 1, -2, -1}, // [4 /*TC*/]
{-2, -1, 1, 0}, // [5 /*OG*/]
{-3, -1, 1, 3}, // [6 /*OBA*/]
{1, 3, -1, -3}, // [7 /*SMA*/]
{1, -1, 3, -3}, // [8 /*MSA*/]
{1, 3, -3, -1}, // [9 /*TCA*/]
{-3, -1, 3, 1}, // [10 /*OGA*/]
};
template <typename T>
inline T three_bit_look_up[11][8]
{
[0] = {},
[1 /*OB*/] = {-4, -3, -2, -1, 0, 1, 2, 3},
[2 /*SM*/] = {0, 1, 2, 3, 0, -1, -2, -3},
[3 /*MS*/] = {0, 0, 1, -1, 0, 0, 1, -1},
[4 /*TC*/] = {0, 1, 2, 3, -4, -3, -2, -1},
[5 /*OG*/] = {-4, -3, -1, -2, 3, 2, 0, 1},
[6 /*OBA*/] = {-7, -5, -3, -1, 1, 3, 5, 7},
[7 /*SMA*/] = {1, 3, 5, 7, -1, -3, -5, -7},
[8 /*MSA*/] = {1, -1, 3, -3, 5, -5, 7, -7},
[9 /*TCA*/] = {1, 3, 5, 7, -7, -5, -3, -1},
[10 /*OGA*/] = {-7, -5, -1, -3, 7, 5, 1, 3},
inline T three_bit_look_up[11][8]{
{}, // [0]
{-4, -3, -2, -1, 0, 1, 2, 3}, // [1 /*OB*/]
{0, 1, 2, 3, 0, -1, -2, -3}, // [2 /*SM*/]
{0, 0, 1, -1, 0, 0, 1, -1}, // [3 /*MS*/]
{0, 1, 2, 3, -4, -3, -2, -1}, // [4 /*TC*/]
{-4, -3, -1, -2, 3, 2, 0, 1}, // [5 /*OG*/]
{-7, -5, -3, -1, 1, 3, 5, 7}, // [6 /*OBA*/]
{1, 3, 5, 7, -1, -3, -5, -7}, // [7 /*SMA*/]
{1, -1, 3, -3, 5, -5, 7, -7}, // [8 /*MSA*/]
{1, 3, 5, 7, -7, -5, -3, -1}, // [9 /*TCA*/]
{-7, -5, -1, -3, 7, 5, 1, 3}, // [10 /*OGA*/]
};
template <typename T>
inline T four_bit_look_up[11][16]
{
[0] = {},
[1 /*OB*/] = {-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7},
[2 /*SM*/] = {0, 1, 2, 3, 4, 5, 6, 7, 0, -1, -2, -3, -4, -5, -6, -7},
[3 /*MS*/] = {0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1},
[4 /*TC*/] = {0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1},
[5 /*OG*/] = {-8, -7, -5, -6, -1, -2, -4, -3, 7, 6, 4, 5, 0, 1, 3, 2},
[6 /*OBA*/] = {-15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15},
[7 /*SMA*/] = {1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15},
[8 /*MSA*/] = {1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -15},
[9 /*TCA*/] = {1, 3, 5, 7, 9, 11, 13, 15, -15, -13, -11, -9, -7, -5, -3, -1},
[10 /*OGA*/] = {-15, -13, -9, -11, -1, -3, -7, -5, 15, 13, 9, 11, 1, 3, 7, 5},
inline T four_bit_look_up[11][16]{
{}, // [0]
{-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}, // [1 /*OB*/]
{0, 1, 2, 3, 4, 5, 6, 7, 0, -1, -2, -3, -4, -5, -6, -7}, // [2 /*SM*/]
{0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1}, // [3 /*MS*/]
{0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1}, // [4 /*TC*/]
{-8, -7, -5, -6, -1, -2, -4, -3, 7, 6, 4, 5, 0, 1, 3, 2}, // [5 /*OG*/]
{-15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15}, // [6 /*OBA*/]
{1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15}, // [7 /*SMA*/]
{1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -15}, // [8 /*MSA*/]
{1, 3, 5, 7, 9, 11, 13, 15, -15, -13, -11, -9, -7, -5, -3, -1}, // [9 /*TCA*/]
{-15, -13, -9, -11, -1, -3, -7, -5, 15, 13, 9, 11, 1, 3, 7, 5}, // [10 /*OGA*/]
};
template <typename T>
inline T five_bit_look_up[11][32]
{
[0] = {},
[1 /*OB*/] = {-16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
[2 /*SM*/] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15},
[3 /*MS*/] = {0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1},
[4 /*TC*/] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1},
[5 /*OG*/] = {-16, -15, -13, -14, -9, -10, -12, -11, -1, -2, -4, -3, -8, -7, -5, -6, 15, 14, 12, 13, 8, 9, 11, 10, 0, 1, 3, 2, 7, 6, 4, 5},
[6 /*OBA*/] = {-31, -29, -27, -25, -23, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31},
[7 /*SMA*/] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, -1, -3, -5, -7, -9, -11, -13, -15, -17, -19, -21, -23, -25, -27, -29, -31},
[8 /*MSA*/] = {1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -15, 17, -17, 19, -19, 21, -21, 23, -23, 25, -25, 27, -27, 29, -29, 31, -31},
[9 /*TCA*/] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, -31, -29, -27, -25, -23, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1},
[10 /*OGA*/] = {-31, -29, -25, -27, -17, -19, -23, -21, -1, -3, -7, -5, -15, -13, -9, -11, 31, 29, 25, 27, 17, 19, 23, 21, 1, 3, 7, 5, 15, 13, 9, 11},
inline T five_bit_look_up[11][32]{
{}, // [0]
{-16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, // [1 /*OB*/]
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15}, // [2 /*SM*/]
{0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1}, // [3 /*MS*/]
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1}, // [4 /*TC*/]
{-16, -15, -13, -14, -9, -10, -12, -11, -1, -2, -4, -3, -8, -7, -5, -6, 15, 14, 12, 13, 8, 9, 11, 10, 0, 1, 3, 2, 7, 6, 4, 5}, // [5 /*OG*/]
{-31, -29, -27, -25, -23, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}, // [6 /*OBA*/]
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, -1, -3, -5, -7, -9, -11, -13, -15, -17, -19, -21, -23, -25, -27, -29, -31}, // [7 /*SMA*/]
{1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -15, 17, -17, 19, -19, 21, -21, 23, -23, 25, -25, 27, -27, 29, -29, 31, -31}, // [8 /*MSA*/]
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, -31, -29, -27, -25, -23, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1}, // [9 /*TCA*/]
{-31, -29, -25, -27, -17, -19, -23, -21, -1, -3, -7, -5, -15, -13, -9, -11, 31, 29, 25, 27, 17, 19, 23, 21, 1, 3, 7, 5, 15, 13, 9, 11}, // [10 /*OGA*/]
};
} // namespace GnssMetadata

View File

@ -197,6 +197,7 @@
#endif
#if ENABLE_ION_SOURCE
#undef Owner
#include "ion_gsms_signal_source.h"
#endif