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