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