GNSS-SDR  0.0.14
An Open Source GNSS Software Defined Receiver
gnss_flowgraph.h
Go to the documentation of this file.
1 /*!
2  * \file gnss_flowgraph.h
3  * \brief Interface of a GNSS receiver flow graph.
4  * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
5  * Luis Esteve, 2011. luis(at)epsilon-formacion.com
6  * Carles Fernandez-Prades, 2014-2020. cfernandez(at)cttc.es
7  * Álvaro Cebrián Juan, 2018. acebrianjuan(at)gmail.com
8  *
9  * It contains a signal source,
10  * a signal conditioner, a set of channels, an observables block and a pvt.
11  *
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_GNSS_FLOWGRAPH_H
25 #define GNSS_SDR_GNSS_FLOWGRAPH_H
26 
28 #include "concurrent_queue.h"
30 #include "gnss_signal.h"
31 #include "pvt_interface.h"
32 #include <gnuradio/blocks/null_sink.h> // for null_sink
33 #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
34 #include <pmt/pmt.h> // for pmt_t
35 #include <list> // for list
36 #include <map> // for map
37 #include <memory> // for for shared_ptr, dynamic_pointer_cast
38 #include <mutex> // for mutex
39 #include <string> // for string
40 #include <utility> // for pair
41 #include <vector> // for vector
42 #if ENABLE_FPGA
44 #endif
45 
46 /** \addtogroup Core
47  * \{ */
48 /** \addtogroup Core_Receiver
49  * \{ */
50 
51 
52 class ChannelInterface;
54 class GNSSBlockInterface;
55 class Gnss_Satellite;
56 
57 /*! \brief This class represents a GNSS flow graph.
58  *
59  * It contains a signal source,
60  * a signal conditioner, a set of channels, a PVT and an output filter.
61  */
63 {
64 public:
65  /*!
66  * \brief Constructor that initializes the receiver flow graph
67  */
68  GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configuration, std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue);
69 
70  /*!
71  * \brief Destructor
72  */
74 
75  /*!
76  * \brief Start the flow graph
77  */
78  void start();
79 
80  /*!
81  * \brief Stop the flow graph
82  */
83  void stop();
84 
85  /*!
86  * \brief Connects the defined blocks in the flow graph
87  *
88  * Signal Source > Signal conditioner > Channels >> Observables >> PVT > Output filter
89  */
90  void connect();
91 
92  /*!
93  * \brief Disconnect the blocks in the flow graph
94  */
95  void disconnect();
96 
97  /*!
98  * \brief Wait for a flowgraph to complete.
99  *
100  * Flowgraphs complete when either
101  * (1) all blocks indicate that they are done, or
102  * (2) after stop() has been called to request shutdown.
103  */
104  void wait();
105 
106  /*!
107  * \brief Manage satellite acquisition
108  *
109  * \param[in] who Channel ID
110  */
111  void acquisition_manager(unsigned int who);
112 
113  /*!
114  * \brief Applies an action to the flow graph
115  *
116  * \param[in] who Who generated the action
117  * \param[in] what What is the action. 0: acquisition failed; 1: acquisition success; 2: tracking lost
118  */
119  void apply_action(unsigned int who, unsigned int what);
120 
121  /*!
122  * \brief Set flow graph configuratiob
123  */
124  void set_configuration(const std::shared_ptr<ConfigurationInterface>& configuration);
125 
126  bool connected() const
127  {
128  return connected_;
129  }
130 
131  bool running() const
132  {
133  return running_;
134  }
135 
136  /*!
137  * \brief Sends a GNU Radio asynchronous message from telemetry to PVT
138  *
139  * It is used to assist the receiver with external ephemeris data
140  */
141  bool send_telemetry_msg(const pmt::pmt_t& msg);
142 
143  /*!
144  * \brief Returns a smart pointer to the PVT object
145  */
146  std::shared_ptr<PvtInterface> get_pvt()
147  {
148  return std::dynamic_pointer_cast<PvtInterface>(pvt_);
149  }
150 
151  /*!
152  * \brief Priorize visible satellites in the specified vector
153  */
154  void priorize_satellites(const std::vector<std::pair<int, Gnss_Satellite>>& visible_satellites);
155 
156 #ifdef ENABLE_FPGA
157  void start_acquisition_helper();
158 
159  void perform_hw_reset();
160 #endif
161 
162 private:
163  void init(); // Populates the SV PRN list available for acquisition and tracking
164  void set_signals_list();
165  void set_channels_state(); // Initializes the channels state (start acquisition or keep standby)
166  // using the configuration parameters (number of channels and max channels in acquisition)
167  Gnss_Signal search_next_signal(const std::string& searched_signal,
168  const bool pop,
169  bool& is_primary_frequency,
170  bool& assistance_available,
171  float& estimated_doppler,
172  double& RX_time);
173 
174  void push_back_signal(const Gnss_Signal& gs);
175  void remove_signal(const Gnss_Signal& gs);
176 
177  double project_doppler(const std::string& searched_signal, double primary_freq_doppler_hz);
178  bool is_multiband() const;
179 
180  std::vector<std::string> split_string(const std::string& s, char delim);
181 
182  gr::top_block_sptr top_block_;
183 
184  std::shared_ptr<ConfigurationInterface> configuration_;
185  std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue_;
186 
187  std::vector<std::shared_ptr<GNSSBlockInterface>> sig_source_;
188  std::vector<std::shared_ptr<GNSSBlockInterface>> sig_conditioner_;
189  std::vector<std::shared_ptr<ChannelInterface>> channels_;
190  std::shared_ptr<GNSSBlockInterface> observables_;
191  std::shared_ptr<GNSSBlockInterface> pvt_;
192 
193  std::map<std::string, gr::basic_block_sptr> acq_resamplers_;
194  std::vector<gr::blocks::null_sink::sptr> null_sinks_;
195 
196  gr::basic_block_sptr GnssSynchroMonitor_;
197  gr::basic_block_sptr GnssSynchroAcquisitionMonitor_;
198  gr::basic_block_sptr GnssSynchroTrackingMonitor_;
199  channel_status_msg_receiver_sptr channels_status_; // class that receives and stores the current status of the receiver channels
200  gnss_sdr_sample_counter_sptr ch_out_sample_counter_;
201 #if ENABLE_FPGA
202  gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter_;
203 #endif
204 
205  std::vector<unsigned int> channels_state_;
206 
207  std::list<Gnss_Signal> available_GPS_1C_signals_;
208  std::list<Gnss_Signal> available_GPS_2S_signals_;
209  std::list<Gnss_Signal> available_GPS_L5_signals_;
210  std::list<Gnss_Signal> available_SBAS_1C_signals_;
211  std::list<Gnss_Signal> available_GAL_1B_signals_;
212  std::list<Gnss_Signal> available_GAL_5X_signals_;
213  std::list<Gnss_Signal> available_GAL_7X_signals_;
214  std::list<Gnss_Signal> available_GAL_E6_signals_;
215  std::list<Gnss_Signal> available_GLO_1G_signals_;
216  std::list<Gnss_Signal> available_GLO_2G_signals_;
217  std::list<Gnss_Signal> available_BDS_B1_signals_;
218  std::list<Gnss_Signal> available_BDS_B3_signals_;
219 
220  enum StringValue
221  {
222  evGPS_1C,
223  evGPS_2S,
224  evGPS_L5,
225  evSBAS_1C,
226  evGAL_1B,
227  evGAL_5X,
228  evGAL_7X,
229  evGAL_E6,
230  evGLO_1G,
231  evGLO_2G,
232  evBDS_B1,
233  evBDS_B3
234  };
235  std::map<std::string, StringValue> mapStringValues_;
236 
237  std::string config_file_;
238 
239  std::mutex signal_list_mutex_;
240 
241  int sources_count_;
242  int channels_count_;
243  int acq_channels_count_;
244  int max_acq_channels_;
245 
246  bool connected_;
247  bool running_;
248  bool multiband_;
249  bool enable_monitor_;
250  bool enable_acquisition_monitor_;
251  bool enable_tracking_monitor_;
252 };
253 
254 
255 /** \} */
256 /** \} */
257 #endif // GNSS_SDR_GNSS_FLOWGRAPH_H
Interface of a thread-safe std::queue.
void stop()
Stop the flow graph.
This class represents an interface to a PVT block.
Definition: pvt_interface.h:48
This class represents a GNSS flow graph.
void disconnect()
Disconnect the blocks in the flow graph.
bool send_telemetry_msg(const pmt::pmt_t &msg)
Sends a GNU Radio asynchronous message from telemetry to PVT.
~GNSSFlowgraph()
Destructor.
Simple block to report the current receiver time based on the output of the tracking or telemetry blo...
void wait()
Wait for a flowgraph to complete.
This class represents an interface to a PVT block.
Implementation of the Gnss_Signal class.
void acquisition_manager(unsigned int who)
Manage satellite acquisition.
This abstract class represents an interface to configuration parameters.
Simple block to report the current receiver time based on the output of the tracking or telemetry blo...
void set_configuration(const std::shared_ptr< ConfigurationInterface > &configuration)
Set flow graph configuratiob.
This class represents a GNSS satellite.
GNSSFlowgraph(std::shared_ptr< ConfigurationInterface > configuration, std::shared_ptr< Concurrent_Queue< pmt::pmt_t >> queue)
Constructor that initializes the receiver flow graph.
This abstract class represents an interface to a channel GNSS block.
std::shared_ptr< PvtInterface > get_pvt()
Returns a smart pointer to the PVT object.
void connect()
Connects the defined blocks in the flow graph.
This class represents a GNSS signal.
Definition: gnss_signal.h:37
This abstract class represents an interface to GNSS blocks.
GNU Radio block that receives asynchronous channel messages from acquisition and tracking blocks...
void start()
Start the flow graph.
void apply_action(unsigned int who, unsigned int what)
Applies an action to the flow graph.
void priorize_satellites(const std::vector< std::pair< int, Gnss_Satellite >> &visible_satellites)
Priorize visible satellites in the specified vector.