GNSS-SDR  0.0.13
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  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
16  *
17  * GNSS-SDR is a software defined Global Navigation
18  * Satellite Systems receiver
19  *
20  * This file is part of GNSS-SDR.
21  *
22  * SPDX-License-Identifier: GPL-3.0-or-later
23  *
24  * -----------------------------------------------------------------------------
25  */
26 
27 #ifndef GNSS_SDR_GNSS_FLOWGRAPH_H
28 #define GNSS_SDR_GNSS_FLOWGRAPH_H
29 
31 #include "concurrent_queue.h"
33 #include "gnss_signal.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 <utility> // for pair
44 #include <vector> // for vector
45 #if ENABLE_FPGA
47 #endif
48 
49 class ChannelInterface;
51 class GNSSBlockInterface;
52 class Gnss_Satellite;
53 
54 /*! \brief This class represents a GNSS flow graph.
55  *
56  * It contains a signal source,
57  * a signal conditioner, a set of channels, a PVT and an output filter.
58  */
60 {
61 public:
62  /*!
63  * \brief Constructor that initializes the receiver flow graph
64  */
65  GNSSFlowgraph(std::shared_ptr<ConfigurationInterface> configuration, std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue);
66 
67  /*!
68  * \brief Destructor
69  */
71 
72  /*!
73  * \brief Start the flow graph
74  */
75  void start();
76 
77  /*!
78  * \brief Stop the flow graph
79  */
80  void stop();
81 
82  /*!
83  * \brief Connects the defined blocks in the flow graph
84  *
85  * Signal Source > Signal conditioner > Channels >> Observables >> PVT > Output filter
86  */
87  void connect();
88 
89  /*!
90  * \brief Disconnect the blocks in the flow graph
91  */
92  void disconnect();
93 
94  /*!
95  * \brief Wait for a flowgraph to complete.
96  *
97  * Flowgraphs complete when either
98  * (1) all blocks indicate that they are done, or
99  * (2) after stop() has been called to request shutdown.
100  */
101  void wait();
102 
103  /*!
104  * \brief Manage satellite acquisition
105  *
106  * \param[in] who Channel ID
107  */
108  void acquisition_manager(unsigned int who);
109 
110  /*!
111  * \brief Applies an action to the flow graph
112  *
113  * \param[in] who Who generated the action
114  * \param[in] what What is the action. 0: acquisition failed; 1: acquisition success; 2: tracking lost
115  */
116  void apply_action(unsigned int who, unsigned int what);
117 
118  /*!
119  * \brief Set flow graph configuratiob
120  */
121  void set_configuration(const std::shared_ptr<ConfigurationInterface>& configuration);
122 
123  bool connected() const
124  {
125  return connected_;
126  }
127 
128  bool running() const
129  {
130  return running_;
131  }
132 
133  /*!
134  * \brief Sends a GNU Radio asynchronous message from telemetry to PVT
135  *
136  * It is used to assist the receiver with external ephemeris data
137  */
138  bool send_telemetry_msg(const pmt::pmt_t& msg);
139 
140  /*!
141  * \brief Returns a smart pointer to the PVT object
142  */
143  std::shared_ptr<PvtInterface> get_pvt()
144  {
145  return std::dynamic_pointer_cast<PvtInterface>(pvt_);
146  }
147 
148  /*!
149  * \brief Priorize visible satellites in the specified vector
150  */
151  void priorize_satellites(const std::vector<std::pair<int, Gnss_Satellite>>& visible_satellites);
152 
153 #ifdef ENABLE_FPGA
154  void start_acquisition_helper();
155 
156  void perform_hw_reset();
157 #endif
158 
159 private:
160  void init(); // Populates the SV PRN list available for acquisition and tracking
161  void set_signals_list();
162  void set_channels_state(); // Initializes the channels state (start acquisition or keep standby)
163  // using the configuration parameters (number of channels and max channels in acquisition)
164  Gnss_Signal search_next_signal(const std::string& searched_signal,
165  const bool pop,
166  bool& is_primary_frequency,
167  bool& assistance_available,
168  float& estimated_doppler,
169  double& RX_time);
170 
171  void push_back_signal(const Gnss_Signal& gs);
172  void remove_signal(const Gnss_Signal& gs);
173 
174  double project_doppler(const std::string& searched_signal, double primary_freq_doppler_hz);
175  bool is_multiband() const;
176 
177  std::vector<std::string> split_string(const std::string& s, char delim);
178 
179  gr::top_block_sptr top_block_;
180 
181  std::shared_ptr<ConfigurationInterface> configuration_;
182  std::shared_ptr<Concurrent_Queue<pmt::pmt_t>> queue_;
183 
184  std::vector<std::shared_ptr<GNSSBlockInterface>> sig_source_;
185  std::vector<std::shared_ptr<GNSSBlockInterface>> sig_conditioner_;
186  std::vector<std::shared_ptr<ChannelInterface>> channels_;
187  std::shared_ptr<GNSSBlockInterface> observables_;
188  std::shared_ptr<GNSSBlockInterface> pvt_;
189 
190  std::map<std::string, gr::basic_block_sptr> acq_resamplers_;
191  std::vector<gr::blocks::null_sink::sptr> null_sinks_;
192 
193  gr::basic_block_sptr GnssSynchroMonitor_;
194  channel_status_msg_receiver_sptr channels_status_; // class that receives and stores the current status of the receiver channels
195  gnss_sdr_sample_counter_sptr ch_out_sample_counter_;
196 #if ENABLE_FPGA
197  gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter_;
198 #endif
199 
200  std::vector<unsigned int> channels_state_;
201 
202  std::list<Gnss_Signal> available_GPS_1C_signals_;
203  std::list<Gnss_Signal> available_GPS_2S_signals_;
204  std::list<Gnss_Signal> available_GPS_L5_signals_;
205  std::list<Gnss_Signal> available_SBAS_1C_signals_;
206  std::list<Gnss_Signal> available_GAL_1B_signals_;
207  std::list<Gnss_Signal> available_GAL_5X_signals_;
208  std::list<Gnss_Signal> available_GAL_7X_signals_;
209  std::list<Gnss_Signal> available_GLO_1G_signals_;
210  std::list<Gnss_Signal> available_GLO_2G_signals_;
211  std::list<Gnss_Signal> available_BDS_B1_signals_;
212  std::list<Gnss_Signal> available_BDS_B3_signals_;
213 
214  enum StringValue
215  {
216  evGPS_1C,
217  evGPS_2S,
218  evGPS_L5,
219  evSBAS_1C,
220  evGAL_1B,
221  evGAL_5X,
222  evGAL_7X,
223  evGLO_1G,
224  evGLO_2G,
225  evBDS_B1,
226  evBDS_B3
227  };
228  std::map<std::string, StringValue> mapStringValues_;
229 
230  std::string config_file_;
231 
232  std::mutex signal_list_mutex_;
233 
234  int sources_count_;
235  int channels_count_;
236  int acq_channels_count_;
237  int max_acq_channels_;
238 
239  bool connected_;
240  bool running_;
241  bool multiband_;
242  bool enable_monitor_;
243 };
244 
245 #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:45
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:33
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.