1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 20:50:33 +00:00

bds_b3i: fixing code with clang format

This commit is contained in:
Damian Miralles 2019-03-17 18:57:45 -05:00
parent 3136817737
commit 5a4227507d
No known key found for this signature in database
GPG Key ID: 8A92BA854ED245E1
4 changed files with 620 additions and 679 deletions

View File

@ -1,6 +1,6 @@
/*! /*!
* \file beidou_b3i_telemetry_decoder.cc * \file beidou_b3i_telemetry_decoder.cc
* \brief Implementation of an adapter of a Beidou B1I NAV data decoder block * \brief Implementation of an adapter of a Beidou B3I NAV data decoder block
* to a TelemetryDecoderInterface * to a TelemetryDecoderInterface
* \author Damian Miralles, 2019. dmiralles2009@gmail.com * \author Damian Miralles, 2019. dmiralles2009@gmail.com
* *
@ -29,78 +29,56 @@
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
#include "beidou_b3i_telemetry_decoder.h" #include "beidou_b3i_telemetry_decoder.h"
#include "configuration_interface.h" #include "configuration_interface.h"
#include <gnuradio/io_signature.h>
#include <glog/logging.h> #include <glog/logging.h>
BeidouB3iTelemetryDecoder::BeidouB3iTelemetryDecoder(
BeidouB3iTelemetryDecoder::BeidouB3iTelemetryDecoder(ConfigurationInterface* configuration, ConfigurationInterface *configuration, std::string role,
std::string role, unsigned int in_streams, unsigned int out_streams)
unsigned int in_streams, : role_(role), in_streams_(in_streams), out_streams_(out_streams) {
unsigned int out_streams) : role_(role), std::string default_dump_filename = "./navigation.dat";
in_streams_(in_streams), DLOG(INFO) << "role " << role;
out_streams_(out_streams) dump_ = configuration->property(role + ".dump", false);
{ dump_filename_ =
std::string default_dump_filename = "./navigation.dat"; configuration->property(role + ".dump_filename", default_dump_filename);
DLOG(INFO) << "role " << role; // make telemetry decoder object
dump_ = configuration->property(role + ".dump", false); telemetry_decoder_ = beidou_b3i_make_telemetry_decoder_gs(satellite_, dump_);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")";
// make telemetry decoder object channel_ = 0;
telemetry_decoder_ = beidou_b3i_make_telemetry_decoder_gs(satellite_, dump_); if (in_streams_ > 1) {
DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; LOG(ERROR) << "This implementation only supports one input stream";
channel_ = 0; }
if (in_streams_ > 1) if (out_streams_ > 1) {
{ LOG(ERROR) << "This implementation only supports one output stream";
LOG(ERROR) << "This implementation only supports one input stream"; }
}
if (out_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one output stream";
}
} }
BeidouB3iTelemetryDecoder::~BeidouB3iTelemetryDecoder() = default;
BeidouB3iTelemetryDecoder::~BeidouB3iTelemetryDecoder() void BeidouB3iTelemetryDecoder::set_satellite(const Gnss_Satellite &satellite) {
{ satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
telemetry_decoder_->set_satellite(satellite_);
DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_;
} }
void BeidouB3iTelemetryDecoder::connect(gr::top_block_sptr top_block) {
void BeidouB3iTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) if (top_block) { /* top_block is not null */
{ };
satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); // Nothing to connect internally
telemetry_decoder_->set_satellite(satellite_); DLOG(INFO) << "nothing to connect internally";
DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_;
} }
void BeidouB3iTelemetryDecoder::disconnect(gr::top_block_sptr top_block) {
void BeidouB3iTelemetryDecoder::connect(gr::top_block_sptr top_block) if (top_block) { /* top_block is not null */
{ };
if (top_block) // Nothing to disconnect
{ /* top_block is not null */
};
// Nothing to connect internally
DLOG(INFO) << "nothing to connect internally";
} }
gr::basic_block_sptr BeidouB3iTelemetryDecoder::get_left_block() {
void BeidouB3iTelemetryDecoder::disconnect(gr::top_block_sptr top_block) return telemetry_decoder_;
{
if (top_block)
{ /* top_block is not null */
};
// Nothing to disconnect
} }
gr::basic_block_sptr BeidouB3iTelemetryDecoder::get_right_block() {
gr::basic_block_sptr BeidouB3iTelemetryDecoder::get_left_block() return telemetry_decoder_;
{
return telemetry_decoder_;
}
gr::basic_block_sptr BeidouB3iTelemetryDecoder::get_right_block()
{
return telemetry_decoder_;
} }

View File

@ -29,69 +29,58 @@
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
#ifndef GNSS_SDR_BEIDOU_B3I_TELEMETRY_DECODER_H_ #ifndef GNSS_SDR_BEIDOU_B3I_TELEMETRY_DECODER_H_
#define GNSS_SDR_BEIDOU_B3I_TELEMETRY_DECODER_H_ #define GNSS_SDR_BEIDOU_B3I_TELEMETRY_DECODER_H_
#include "beidou_b3i_telemetry_decoder_gs.h" #include "beidou_b3i_telemetry_decoder_gs.h"
#include "gnss_satellite.h" // for Gnss_Satellite #include "gnss_satellite.h" // for Gnss_Satellite
#include "telemetry_decoder_interface.h" #include "telemetry_decoder_interface.h"
#include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr #include <cstddef> // for size_t
#include <cstddef> // for size_t #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
#include <string> #include <string>
class ConfigurationInterface; class ConfigurationInterface;
/*! /*!
* \brief This class implements a NAV data decoder for BEIDOU B1I * \brief This class implements a NAV data decoder for BEIDOU B1I
*/ */
class BeidouB3iTelemetryDecoder : public TelemetryDecoderInterface class BeidouB3iTelemetryDecoder : public TelemetryDecoderInterface {
{
public: public:
BeidouB3iTelemetryDecoder(ConfigurationInterface* configuration, BeidouB3iTelemetryDecoder(ConfigurationInterface *configuration,
std::string role, std::string role, unsigned int in_streams,
unsigned int in_streams, unsigned int out_streams);
unsigned int out_streams);
virtual ~BeidouB3iTelemetryDecoder(); virtual ~BeidouB3iTelemetryDecoder();
inline std::string role() override inline std::string role() override { return role_; }
{
return role_;
}
//! Returns "BEIDOU_B3I_Telemetry_Decoder" //! Returns "BEIDOU_B3I_Telemetry_Decoder"
inline std::string implementation() override inline std::string implementation() override {
{ return "BEIDOU_B3I_Telemetry_Decoder";
return "BEIDOU_B3I_Telemetry_Decoder"; }
}
void connect(gr::top_block_sptr top_block) override; void connect(gr::top_block_sptr top_block) override;
void disconnect(gr::top_block_sptr top_block) override; void disconnect(gr::top_block_sptr top_block) override;
gr::basic_block_sptr get_left_block() override; gr::basic_block_sptr get_left_block() override;
gr::basic_block_sptr get_right_block() override; gr::basic_block_sptr get_right_block() override;
void set_satellite(const Gnss_Satellite& satellite) override; void set_satellite(const Gnss_Satellite &satellite) override;
inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } inline void set_channel(int channel) override {
telemetry_decoder_->set_channel(channel);
}
inline void reset() override inline void reset() override { return; }
{
return;
}
inline size_t item_size() override inline size_t item_size() override { return 0; }
{
return 0;
}
private: private:
beidou_b3i_telemetry_decoder_gs_sptr telemetry_decoder_; beidou_b3i_telemetry_decoder_gs_sptr telemetry_decoder_;
Gnss_Satellite satellite_; Gnss_Satellite satellite_;
int channel_; int channel_;
bool dump_; bool dump_;
std::string dump_filename_; std::string dump_filename_;
std::string role_; std::string role_;
unsigned int in_streams_; unsigned int in_streams_;
unsigned int out_streams_; unsigned int out_streams_;
}; };
#endif #endif

View File

@ -34,83 +34,87 @@
#include "beidou_dnav_navigation_message.h" #include "beidou_dnav_navigation_message.h"
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include <boost/circular_buffer.hpp> #include <boost/circular_buffer.hpp>
#include <boost/shared_ptr.hpp> // for boost::shared_ptr #include <boost/shared_ptr.hpp> // for boost::shared_ptr
#include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <cstdint> #include <cstdint>
#include <fstream> #include <fstream>
#include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <string> #include <string>
class beidou_b3i_telemetry_decoder_gs; class beidou_b3i_telemetry_decoder_gs;
using beidou_b3i_telemetry_decoder_gs_sptr = boost::shared_ptr<beidou_b3i_telemetry_decoder_gs>; using beidou_b3i_telemetry_decoder_gs_sptr =
boost::shared_ptr<beidou_b3i_telemetry_decoder_gs>;
beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); beidou_b3i_telemetry_decoder_gs_sptr
beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite,
bool dump);
/*! /*!
* \brief This class implements a block that decodes the BeiDou DNAV data. * \brief This class implements a block that decodes the BeiDou DNAV data.
* *
*/ */
class beidou_b3i_telemetry_decoder_gs : public gr::block class beidou_b3i_telemetry_decoder_gs : public gr::block {
{
public: public:
~beidou_b3i_telemetry_decoder_gs(); //!< Class destructor ~beidou_b3i_telemetry_decoder_gs(); //!< Class destructor
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
void set_channel(int channel); //!< Set receiver's channel void set_channel(int channel); //!< Set receiver's channel
/*! /*!
* \brief This is where all signal processing takes place * \brief This is where all signal processing takes place
*/ */
int general_work(int noutput_items, gr_vector_int &ninput_items, int general_work(int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
private: private:
friend beidou_b3i_telemetry_decoder_gs_sptr friend beidou_b3i_telemetry_decoder_gs_sptr
beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite,
beidou_b3i_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump); bool dump);
beidou_b3i_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
void decode_subframe(double *symbols); void decode_subframe(double *symbols);
void decode_word(int32_t word_counter, const double *enc_word_symbols, int32_t* dec_word_symbols); void decode_word(int32_t word_counter, const double *enc_word_symbols,
void decode_bch15_11_01(const int32_t *bits, int32_t *decbits); int32_t *dec_word_symbols);
void decode_bch15_11_01(const int32_t *bits, int32_t *decbits);
// Preamble decoding
int32_t *d_preamble_samples;
int32_t *d_secondary_code_symbols;
uint32_t d_samples_per_symbol;
int32_t d_symbols_per_preamble;
int32_t d_samples_per_preamble;
int32_t d_preamble_period_samples;
double *d_subframe_symbols;
uint32_t d_required_symbols;
// Preamble decoding // Storage for incoming data
int32_t *d_preamble_samples; boost::circular_buffer<float> d_symbol_history;
int32_t *d_secondary_code_symbols;
uint32_t d_samples_per_symbol;
int32_t d_symbols_per_preamble;
int32_t d_samples_per_preamble;
int32_t d_preamble_period_samples;
double *d_subframe_symbols;
uint32_t d_required_symbols;
// Storage for incoming data // Variables for internal functionality
boost::circular_buffer<float> d_symbol_history; uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc)
// indicating number of samples processed
uint64_t d_preamble_index; // Index of sample number where preamble was found
uint32_t d_stat; // Status of decoder
bool d_flag_frame_sync; // Indicate when a frame sync is achieved
bool d_flag_preamble; // Flag indicating when preamble was found
int32_t d_CRC_error_counter; // Number of failed CRC operations
bool flag_SOW_set; // Indicates when time of week is set
// Variables for internal functionality //!< Navigation Message variable
uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed Beidou_Dnav_Navigation_Message d_nav;
uint64_t d_preamble_index; // Index of sample number where preamble was found
uint32_t d_stat; // Status of decoder
bool d_flag_frame_sync; // Indicate when a frame sync is achieved
bool d_flag_preamble; // Flag indicating when preamble was found
int32_t d_CRC_error_counter; // Number of failed CRC operations
bool flag_SOW_set; // Indicates when time of week is set
//!< Navigation Message variable //!< Values to populate gnss synchronization structure
Beidou_Dnav_Navigation_Message d_nav; uint32_t d_TOW_at_Preamble_ms;
uint32_t d_TOW_at_current_symbol_ms;
bool Flag_valid_word;
//!< Values to populate gnss synchronization structure //!< Satellite Information and logging capacity
uint32_t d_TOW_at_Preamble_ms; Gnss_Satellite d_satellite;
uint32_t d_TOW_at_current_symbol_ms; int32_t d_channel;
bool Flag_valid_word; bool d_dump;
std::string d_dump_filename;
//!< Satellite Information and logging capacity std::ofstream d_dump_file;
Gnss_Satellite d_satellite;
int32_t d_channel;
bool d_dump;
std::string d_dump_filename;
std::ofstream d_dump_file;
}; };
#endif #endif