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