GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
galileo_e5a_noncoherent_iq_acquisition_caf_cc.h
Go to the documentation of this file.
1 /*!
2  * \file galileo_e5a_noncoherent_iq_acquisition_caf_cc.h
3  * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for
4  * Galileo E5a data and pilot Signals
5  * \author Marc Sales, 2014. marcsales92(at)gmail.com
6  * \based on work from:
7  * <ul>
8  * <li> Javier Arribas, 2011. jarribas(at)cttc.es
9  * <li> Luis Esteve, 2012. luis(at)epsilon-formacion.com
10  * <li> Marc Molina, 2013. marc.molina.pena@gmail.com
11  * </ul>
12  *
13  * -----------------------------------------------------------------------------
14  *
15  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
16  *
17  * GNSS-SDR is a software defined Global Navigation
18  * Satellite Systems receiver
19  *
20  * This file is part of GNSS-SDR.
21  *
22  * SPDX-License-Identifier: GPL-3.0-or-later
23  *
24  * -----------------------------------------------------------------------------
25  */
26 
27 #ifndef GNSS_SDR_GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_CC_H
28 #define GNSS_SDR_GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_CC_H
29 
30 #include "channel_fsm.h"
31 #include "gnss_synchro.h"
32 #include <gnuradio/block.h>
33 #include <gnuradio/fft/fft.h>
34 #include <gnuradio/gr_complex.h>
35 #include <fstream>
36 #include <memory>
37 #include <string>
38 #include <utility>
39 #include <vector>
40 #if GNURADIO_USES_STD_POINTERS
41 #else
42 #include <boost/shared_ptr.hpp>
43 #endif
44 
46 
47 #if GNURADIO_USES_STD_POINTERS
48 using galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr = std::shared_ptr<galileo_e5a_noncoherentIQ_acquisition_caf_cc>;
49 #else
50 using galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr = boost::shared_ptr<galileo_e5a_noncoherentIQ_acquisition_caf_cc>;
51 #endif
52 
53 galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make_acquisition_caf_cc(
54  unsigned int sampled_ms,
55  unsigned int max_dwells,
56  unsigned int doppler_max, int64_t fs_in,
57  int samples_per_ms, int samples_per_code,
58  bool bit_transition_flag,
59  bool dump,
60  const std::string& dump_filename,
61  bool both_signal_components_,
62  int CAF_window_hz_,
63  int Zero_padding_);
64 
65 /*!
66  * \brief This class implements a Parallel Code Phase Search Acquisition.
67  *
68  * Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver",
69  * Algorithm 1, for a pseudocode description of this implementation.
70  */
72 {
73 public:
74  /*!
75  * \brief Default destructor.
76  */
78 
79  /*!
80  * \brief Set acquisition/tracking common Gnss_Synchro object pointer
81  * to exchange synchronization data between acquisition and tracking blocks.
82  * \param p_gnss_synchro Satellite information shared by the processing blocks.
83  */
84  inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
85  {
86  d_gnss_synchro = p_gnss_synchro;
87  }
88 
89  /*!
90  * \brief Returns the maximum peak of grid search.
91  */
92  inline unsigned int mag() const
93  {
94  return d_mag;
95  }
96 
97  /*!
98  * \brief Initializes acquisition algorithm.
99  */
100  void init();
101 
102  /*!
103  * \brief Sets local code for PCPS acquisition algorithm.
104  * \param code - Pointer to the PRN code.
105  */
106  void set_local_code(std::complex<float>* code, std::complex<float>* codeQ);
107 
108  /*!
109  * \brief Starts acquisition algorithm, turning from standby mode to
110  * active mode
111  * \param active - bool that activates/deactivates the block.
112  */
113  inline void set_active(bool active)
114  {
115  d_active = active;
116  }
117 
118  /*!
119  * \brief If set to 1, ensures that acquisition starts at the
120  * first available sample.
121  * \param state - int=1 forces start of acquisition
122  */
123  void set_state(int state);
124 
125  /*!
126  * \brief Set acquisition channel unique ID
127  * \param channel - receiver channel.
128  */
129  inline void set_channel(unsigned int channel)
130  {
131  d_channel = channel;
132  }
133 
134  /*!
135  * \brief Set channel fsm associated to this acquisition instance
136  */
137  inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm)
138  {
139  d_channel_fsm = std::move(channel_fsm);
140  }
141 
142  /*!
143  * \brief Set statistics threshold of PCPS algorithm.
144  * \param threshold - Threshold for signal detection (check \ref Navitec2012,
145  * Algorithm 1, for a definition of this threshold).
146  */
147  inline void set_threshold(float threshold)
148  {
149  d_threshold = threshold;
150  }
151 
152  /*!
153  * \brief Set maximum Doppler grid search
154  * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
155  */
156  inline void set_doppler_max(unsigned int doppler_max)
157  {
158  d_doppler_max = doppler_max;
159  }
160 
161  /*!
162  * \brief Set Doppler steps for the grid search
163  * \param doppler_step - Frequency bin of the search grid [Hz].
164  */
165  inline void set_doppler_step(unsigned int doppler_step)
166  {
167  d_doppler_step = doppler_step;
168  }
169 
170  /*!
171  * \brief Parallel Code Phase Search Acquisition signal processing.
172  */
173  int general_work(int noutput_items, gr_vector_int& ninput_items,
174  gr_vector_const_void_star& input_items,
175  gr_vector_void_star& output_items);
176 
177 private:
178  friend galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr
179  galileo_e5a_noncoherentIQ_make_acquisition_caf_cc(
180  unsigned int sampled_ms,
181  unsigned int max_dwells,
182  unsigned int doppler_max, int64_t fs_in,
183  int samples_per_ms, int samples_per_code,
184  bool bit_transition_flag,
185  bool dump,
186  const std::string& dump_filename,
187  bool both_signal_components_,
188  int CAF_window_hz_,
189  int Zero_padding_);
190 
192  unsigned int sampled_ms,
193  unsigned int max_dwells,
194  unsigned int doppler_max, int64_t fs_in,
195  int samples_per_ms, int samples_per_code,
196  bool bit_transition_flag,
197  bool dump,
198  const std::string& dump_filename,
199  bool both_signal_components_,
200  int CAF_window_hz_,
201  int Zero_padding_);
202 
203  void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift,
204  int doppler_offset);
205 
206  float estimate_input_power(gr_complex* in);
207 
208  std::weak_ptr<ChannelFsm> d_channel_fsm;
209  std::unique_ptr<gr::fft::fft_complex> d_fft_if;
210  std::unique_ptr<gr::fft::fft_complex> d_ifft;
211 
212  std::vector<std::vector<gr_complex>> d_grid_doppler_wipeoffs;
213  std::vector<gr_complex> d_fft_code_I_A;
214  std::vector<gr_complex> d_fft_code_I_B;
215  std::vector<gr_complex> d_fft_code_Q_A;
216  std::vector<gr_complex> d_fft_code_Q_B;
217  std::vector<gr_complex> d_inbuffer;
218  std::vector<float> d_magnitudeIA;
219  std::vector<float> d_magnitudeIB;
220  std::vector<float> d_magnitudeQA;
221  std::vector<float> d_magnitudeQB;
222  std::vector<float> d_CAF_vector;
223  std::vector<float> d_CAF_vector_I;
224  std::vector<float> d_CAF_vector_Q;
225 
226  std::string d_satellite_str;
227  std::string d_dump_filename;
228 
229  std::ofstream d_dump_file;
230 
231  Gnss_Synchro* d_gnss_synchro;
232 
233  int64_t d_fs_in;
234  uint64_t d_sample_counter;
235 
236  float d_threshold;
237  float d_doppler_freq;
238  float d_mag;
239  float d_input_power;
240  float d_test_statistics;
241 
242  int d_state;
243  int d_samples_per_ms;
244  int d_samples_per_code;
245  int d_CAF_window_hz;
246  int d_buffer_count;
247  int d_doppler_resolution;
248  int d_doppler_max;
249  int d_doppler_step;
250  int d_fft_size;
251  int d_num_doppler_bins;
252  unsigned int d_gr_stream_buffer;
253  unsigned int d_channel;
254  unsigned int d_max_dwells;
255  unsigned int d_well_count;
256  unsigned int d_sampled_ms;
257  unsigned int d_code_phase;
258 
259  bool d_bit_transition_flag;
260  bool d_active;
261  bool d_dump;
262  bool d_both_signal_components;
263 };
264 
265 #endif // GNSS_SDR_GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_CC_H
void set_threshold(float threshold)
Set statistics threshold of PCPS algorithm.
void init()
Initializes acquisition algorithm.
unsigned int mag() const
Returns the maximum peak of grid search.
Interface of the State Machine for channel.
void set_active(bool active)
Starts acquisition algorithm, turning from standby mode to active mode.
This is the class that contains the information that is shared by the processing blocks.
Definition: gnss_synchro.h:33
void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro)
Set acquisition/tracking common Gnss_Synchro object pointer to exchange synchronization data between ...
This class implements a Parallel Code Phase Search Acquisition.
void set_doppler_max(unsigned int doppler_max)
Set maximum Doppler grid search.
void set_doppler_step(unsigned int doppler_step)
Set Doppler steps for the grid search.
void set_local_code(std::complex< float > *code, std::complex< float > *codeQ)
Sets local code for PCPS acquisition algorithm.
void set_channel_fsm(std::weak_ptr< ChannelFsm > channel_fsm)
Set channel fsm associated to this acquisition instance.
void set_state(int state)
If set to 1, ensures that acquisition starts at the first available sample.
void set_channel(unsigned int channel)
Set acquisition channel unique ID.
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
Parallel Code Phase Search Acquisition signal processing.
~galileo_e5a_noncoherentIQ_acquisition_caf_cc()
Default destructor.
Interface of the Gnss_Synchro class.