GNSS-SDR  0.0.21
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 "galileo_tow_map.h"
32 #include "gnss_signal.h"
33 #include "osnma_msg_receiver.h"
34 #include "pvt_interface.h"
35 #include <gnuradio/blocks/null_sink.h> // for null_sink
36 #include <gnuradio/runtime_types.h> // for basic_block_sptr, top_block_sptr
37 #include <pmt/pmt.h> // for pmt_t
38 #include <list> // for list
39 #include <map> // for map
40 #include <memory> // for for shared_ptr, dynamic_pointer_cast
41 #include <mutex> // for mutex
42 #include <string> // for string
43 #include <unordered_map> // for unordered_map
44 #include <utility> // for pair
45 #include <vector> // for vector
46 #if ENABLE_FPGA
48 #endif
49 
50 /** \addtogroup Core
51  * \{ */
52 /** \addtogroup Core_Receiver
53  * \{ */
54 
55 
56 class ChannelInterface;
58 class GNSSBlockInterface;
59 class Gnss_Satellite;
61 
62 /*! \brief This class represents a GNSS flow graph.
63  *
64  * It contains a signal source,
65  * a signal conditioner, a set of channels, a PVT and an output filter.
66  */
68 {
69 public:
70  /*!
71  * \brief Constructor that initializes the receiver flow graph
72  */
73  GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configuration, std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue);
74 
75  /*!
76  * \brief Destructor
77  */
79 
80  /*!
81  * \brief Start the flow graph
82  */
83  void start();
84 
85  /*!
86  * \brief Stop the flow graph
87  */
88  void stop();
89 
90  /*!
91  * \brief Connects the defined blocks in the flow graph
92  *
93  * Signal Source > Signal conditioner > Channels >> Observables >> PVT > Output filter
94  */
95  void connect();
96 
97  /*!
98  * \brief Disconnect the blocks in the flow graph
99  */
100  void disconnect();
101 
102  /*!
103  * \brief Wait for a flowgraph to complete.
104  *
105  * Flowgraphs complete when either
106  * (1) all blocks indicate that they are done, or
107  * (2) after stop() has been called to request shutdown.
108  */
109  void wait();
110 
111  /*!
112  * \brief Manage satellite acquisition
113  *
114  * \param[in] who Channel ID
115  */
116  void acquisition_manager(unsigned int who);
117 
118  /*!
119  * \brief Applies an action to the flow graph
120  *
121  * \param[in] who Who generated the action
122  * \param[in] what What is the action. 0: acquisition failed; 1: acquisition success; 2: tracking lost
123  */
124  void apply_action(unsigned int who, unsigned int what);
125 
126  /*!
127  * \brief Set flow graph configuratiob
128  */
129  void set_configuration(const std::shared_ptr<ConfigurationInterface>& configuration);
130 
131  bool connected() const
132  {
133  return connected_;
134  }
135 
136  bool running() const
137  {
138  return running_;
139  }
140 
141  /*!
142  * \brief Sends a GNU Radio asynchronous message from telemetry to PVT
143  *
144  * It is used to assist the receiver with external ephemeris data
145  */
146  bool send_telemetry_msg(const pmt::pmt_t& msg);
147 
148  /*!
149  * \brief Returns a smart pointer to the PVT object
150  */
151  std::shared_ptr<PvtInterface> get_pvt()
152  {
153  return std::dynamic_pointer_cast<PvtInterface>(pvt_);
154  }
155 
156  /*!
157  * \brief Prioritize visible satellites in the specified vector
158  */
159  void priorize_satellites(const std::vector<std::pair<int, Gnss_Satellite>>& visible_satellites);
160 
161 #if ENABLE_FPGA
162  void start_acquisition_helper();
163 
164  void perform_hw_reset();
165 #endif
166 
167 private:
168  void init(); // Populates the SV PRN list available for acquisition and tracking
169  int connect_desktop_flowgraph();
170 
171  int connect_signal_sources();
172  int connect_signal_conditioners();
173  int connect_channels();
174  int connect_observables();
175  int connect_pvt();
176  int connect_sample_counter();
177  int connect_galileo_tow_map();
178 
179  int connect_signal_sources_to_signal_conditioners();
180  int connect_signal_conditioners_to_channels();
181  int connect_channels_to_observables();
182  int connect_observables_to_pvt();
183  int connect_monitors();
184  int connect_osnma();
185  int connect_gal_e6_has();
186  int connect_gnss_synchro_monitor();
187  int connect_acquisition_monitor();
188  int connect_tracking_monitor();
189  int connect_navdata_monitor();
190 
191 #if ENABLE_FPGA
192  int connect_fpga_flowgraph();
193  int connect_fpga_sample_counter();
194 #endif
195 
196  int assign_channels();
197  void check_signal_conditioners();
198 
199  void set_signals_list();
200  void set_channels_state(); // Initializes the channels state (start acquisition or keep standby)
201  // using the configuration parameters (number of channels and max channels in acquisition)
202  Gnss_Signal search_next_signal(const std::string& searched_signal,
203  bool& is_primary_frequency,
204  bool& assistance_available,
205  float& estimated_doppler,
206  double& RX_time);
207 
208  void push_back_signal(const Gnss_Signal& gs);
209  void remove_signal(const Gnss_Signal& gs);
210  void print_help();
211  void check_desktop_conf_in_fpga_env();
212 
213  double project_doppler(const std::string& searched_signal, double primary_freq_doppler_hz);
214  bool is_multiband() const;
215 
216  std::vector<std::string> split_string(const std::string& s, char delim);
217  std::vector<bool> signal_conditioner_connected_;
218 
219  gr::top_block_sptr top_block_;
220 
221  std::shared_ptr<ConfigurationInterface> configuration_;
222  std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue_;
223 
224  std::vector<std::shared_ptr<SignalSourceInterface>> sig_source_;
225  std::vector<std::shared_ptr<GNSSBlockInterface>> sig_conditioner_;
226  std::vector<std::shared_ptr<ChannelInterface>> channels_;
227  std::shared_ptr<GNSSBlockInterface> observables_;
228  std::shared_ptr<GNSSBlockInterface> pvt_;
229 
230  std::map<std::string, gr::basic_block_sptr> acq_resamplers_;
231  std::vector<gr::blocks::null_sink::sptr> null_sinks_;
232 
233  gr::basic_block_sptr GnssSynchroMonitor_;
234  gr::basic_block_sptr GnssSynchroAcquisitionMonitor_;
235  gr::basic_block_sptr GnssSynchroTrackingMonitor_;
236  gr::basic_block_sptr NavDataMonitor_;
237  channel_status_msg_receiver_sptr channels_status_; // class that receives and stores the current status of the receiver channels
238  galileo_e6_has_msg_receiver_sptr gal_e6_has_rx_;
239  galileo_tow_map_sptr galileo_tow_map_;
240  osnma_msg_receiver_sptr osnma_rx_;
241 
242  gnss_sdr_sample_counter_sptr ch_out_sample_counter_;
243 #if ENABLE_FPGA
244  gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter_;
245 #endif
246 
247  std::vector<unsigned int> channels_state_; // 0 - Idle, 1 - Assigned, 2 - Acquisition, 3 - Tracking
248 
249  std::unordered_map<std::string, std::list<Gnss_Signal>> available_signals_map_;
250 
251  enum StringValue
252  {
253  evGPS_1C,
254  evGPS_2S,
255  evGPS_L5,
256  evSBAS_1C,
257  evGAL_1B,
258  evGAL_5X,
259  evGAL_7X,
260  evGAL_E6,
261  evGLO_1G,
262  evGLO_2G,
263  evBDS_B1,
264  evBDS_B3,
265  evQZS_J1,
266  evQZS_J5
267  };
268  std::map<std::string, StringValue> mapStringValues_;
269 
270  std::string config_file_;
271  std::string help_hint_;
272 
273  std::mutex signal_list_mutex_;
274 
275  int sources_count_;
276  int channels_count_;
277  int acq_channels_count_;
278  int max_acq_channels_;
279 
280  bool connected_;
281  bool running_;
282  bool multiband_;
283  bool enable_monitor_;
284  bool enable_acquisition_monitor_;
285  bool enable_tracking_monitor_;
286  bool enable_navdata_monitor_;
287  bool enable_fpga_offloading_;
288  bool enable_osnma_rx_;
289  bool enable_e6_has_rx_;
290 };
291 
292 
293 /** \} */
294 /** \} */
295 #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 abstract class represents an interface to signal_source GNSS block.
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.
GNU Radio block that stores TOW for Galileo channels.
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.
GNU Radio block that processes Galileo OSNMA data received from Galileo E1B telemetry blocks...
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:38
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)
Prioritize visible satellites in the specified vector.
GNU Radio block that processes Galileo HAS message pages received from Galileo E6B telemetry blocks...