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