GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
signal_generator_c.h
Go to the documentation of this file.
1 /*!
2  * \file signal_generator_c.h
3  * \brief GNU Radio source block that generates synthesized GNSS signal.
4  * \author Marc Molina, 2013. marc.molina.pena@gmail.com
5  *
6  * -----------------------------------------------------------------------------
7  *
8  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
9  *
10  * GNSS-SDR is a software defined Global Navigation
11  * Satellite Systems receiver
12  *
13  * This file is part of GNSS-SDR.
14  *
15  * SPDX-License-Identifier: GPL-3.0-or-later
16  *
17  * -----------------------------------------------------------------------------
18  */
19 
20 #ifndef GNSS_SDR_SIGNAL_GENERATOR_C_H
21 #define GNSS_SDR_SIGNAL_GENERATOR_C_H
22 
23 #include "gnss_signal.h"
24 #include <gnuradio/block.h>
25 #include <random>
26 #include <string>
27 #include <vector>
28 #if GNURADIO_USES_STD_POINTERS
29 #include <memory>
30 #else
31 #include <boost/shared_ptr.hpp>
32 #endif
33 
34 
35 class signal_generator_c;
36 
37 /*
38 * We use std::shared_ptr's instead of raw pointers for all access
39 * to gr_blocks (and many other data structures). The shared_ptr gets
40 * us transparent reference counting, which greatly simplifies storage
41 * management issues.
42 *
43 * See https://www.boost.org/doc/libs/release/libs/smart_ptr/doc/html/smart_ptr.html
44 *
45 * As a convention, the _sptr suffix indicates a std::shared_ptr
46 */
47 #if GNURADIO_USES_STD_POINTERS
48 using signal_generator_c_sptr = std::shared_ptr<signal_generator_c>;
49 #else
50 using signal_generator_c_sptr = boost::shared_ptr<signal_generator_c>;
51 #endif
52 
53 /*!
54 * \brief Return a shared_ptr to a new instance of gen_source.
55 *
56 * To avoid accidental use of raw pointers, gen_source's
57 * constructor is private. signal_make_generator_c is the public
58 * interface for creating new instances.
59 */
60 signal_generator_c_sptr signal_make_generator_c(
61  const std::vector<std::string> &signal1,
62  const std::vector<std::string> &system,
63  const std::vector<unsigned int> &PRN,
64  const std::vector<float> &CN0_dB,
65  const std::vector<float> &doppler_Hz,
66  const std::vector<unsigned int> &delay_chips,
67  const std::vector<unsigned int> &delay_sec,
68  bool data_flag,
69  bool noise_flag,
70  unsigned int fs_in,
71  unsigned int vector_length,
72  float BW_BB);
73 
74 /*!
75 * \brief This class generates synthesized GNSS signal.
76 * \ingroup block
77 *
78 * \sa gen_source for a version that subclasses gr_block.
79 */
80 class signal_generator_c : public gr::block
81 {
82 public:
83  ~signal_generator_c() = default; // public destructor
84 
85  // Where all the action really happens
86  int general_work(int noutput_items,
87  gr_vector_int &ninput_items,
88  gr_vector_const_void_star &input_items,
89  gr_vector_void_star &output_items);
90 
91 private:
92  friend signal_generator_c_sptr signal_make_generator_c(
93  const std::vector<std::string> &signal1,
94  const std::vector<std::string> &system,
95  const std::vector<unsigned int> &PRN,
96  const std::vector<float> &CN0_dB,
97  const std::vector<float> &doppler_Hz,
98  const std::vector<unsigned int> &delay_chips,
99  const std::vector<unsigned int> &delay_sec,
100  bool data_flag,
101  bool noise_flag,
102  unsigned int fs_in,
103  unsigned int vector_length,
104  float BW_BB);
105 
107  std::vector<std::string> signal1,
108  std::vector<std::string> system,
109  const std::vector<unsigned int> &PRN,
110  std::vector<float> CN0_dB,
111  std::vector<float> doppler_Hz,
112  std::vector<unsigned int> delay_chips,
113  std::vector<unsigned int> delay_sec,
114  bool data_flag,
115  bool noise_flag,
116  unsigned int fs_in,
117  unsigned int vector_length,
118  float BW_BB);
119 
120  void init();
121 
122  void generate_codes();
123 
124  std::random_device r;
125  std::uniform_int_distribution<int> uniform_dist;
126  std::normal_distribution<float> normal_dist;
127  std::vector<std::string> signal_;
128  std::vector<std::string> system_;
129  std::vector<std::vector<gr_complex>> sampled_code_data_;
130  std::vector<std::vector<gr_complex>> sampled_code_pilot_;
131  std::vector<gr_complex> current_data_bits_;
132  std::vector<gr_complex> complex_phase_;
133  std::vector<float> CN0_dB_;
134  std::vector<float> doppler_Hz_;
135  std::vector<float> start_phase_rad_;
136  std::vector<unsigned int> PRN_;
137  std::vector<unsigned int> delay_chips_;
138  std::vector<unsigned int> delay_sec_;
139  std::vector<unsigned int> samples_per_code_;
140  std::vector<unsigned int> num_of_codes_per_vector_;
141  std::vector<unsigned int> data_bit_duration_ms_;
142  std::vector<unsigned int> ms_counter_;
143  std::vector<signed int> current_data_bit_int_;
144  std::vector<signed int> data_modulation_;
145  std::vector<signed int> pilot_modulation_;
146  float BW_BB_;
147  unsigned int work_counter_{};
148  unsigned int fs_in_;
149  unsigned int num_sats_;
150  unsigned int vector_length_;
151  bool data_flag_;
152  bool noise_flag_;
153 };
154 
155 #endif // GNSS_SDR_SIGNAL_GENERATOR_C_H
This class generates synthesized GNSS signal.
Implementation of the Gnss_Signal class.
signal_generator_c_sptr signal_make_generator_c(const std::vector< std::string > &signal1, const std::vector< std::string > &system, const std::vector< unsigned int > &PRN, const std::vector< float > &CN0_dB, const std::vector< float > &doppler_Hz, const std::vector< unsigned int > &delay_chips, const std::vector< unsigned int > &delay_sec, bool data_flag, bool noise_flag, unsigned int fs_in, unsigned int vector_length, float BW_BB)
Return a shared_ptr to a new instance of gen_source.
friend signal_generator_c_sptr signal_make_generator_c(const std::vector< std::string > &signal1, const std::vector< std::string > &system, const std::vector< unsigned int > &PRN, const std::vector< float > &CN0_dB, const std::vector< float > &doppler_Hz, const std::vector< unsigned int > &delay_chips, const std::vector< unsigned int > &delay_sec, bool data_flag, bool noise_flag, unsigned int fs_in, unsigned int vector_length, float BW_BB)
Return a shared_ptr to a new instance of gen_source.