GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
glonass_gnav_navigation_message.h
Go to the documentation of this file.
1 /*!
2  * \file glonass_gnav_navigation_message.h
3  * \brief Interface of a GLONASS GNAV Data message decoder as described in GLONASS ICD (Edition 5.1)
4  * \note Code added as part of GSoC 2017 program
5  * \author Damian Miralles, 2017. dmiralles2009(at)gmail.com
6  * \see <a href="http://russianspacesystems.ru/wp-content/uploads/2016/08/ICD_GLONASS_eng_v5.1.pdf">GLONASS ICD</a>
7  *
8  * -----------------------------------------------------------------------------
9  *
10  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
11  * This file is part of GNSS-SDR.
12  *
13  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
14  * SPDX-License-Identifier: GPL-3.0-or-later
15  *
16  * -----------------------------------------------------------------------------
17  */
18 
19 
20 #ifndef GNSS_SDR_GLONASS_GNAV_NAVIGATION_MESSAGE_H
21 #define GNSS_SDR_GLONASS_GNAV_NAVIGATION_MESSAGE_H
22 
23 
24 #include "GLONASS_L1_L2_CA.h"
25 #include "glonass_gnav_almanac.h"
26 #include "glonass_gnav_ephemeris.h"
27 #include "glonass_gnav_utc_model.h"
28 #include <bitset>
29 #include <cstdint>
30 #include <map>
31 #include <string>
32 #include <utility> // for pair
33 #include <vector> // for vector
34 
35 /** \addtogroup Core
36  * \{ */
37 /** \addtogroup System_Parameters
38  * \{ */
39 
40 
41 /*!
42  * \brief This class decodes a GLONASS GNAV Data message as described in GLONASS ICD (Edition 5.1)
43  * \note Code added as part of GSoC 2017 program
44  * \see <a href="http://russianspacesystems.ru/wp-content/uploads/2016/08/ICD_GLONASS_eng_v5.1.pdf">GLONASS ICD</a>
45  */
47 {
48 public:
49  /*!
50  * Default constructor
51  */
53 
54  /*!
55  * \brief Compute CRC for GLONASS GNAV strings
56  * \param bits Bits of the string message where to compute CRC
57  */
58  bool CRC_test(std::bitset<GLONASS_GNAV_STRING_BITS>& bits) const;
59 
60  /*!
61  * \brief Computes the frame number being decoded given the satellite slot number
62  * \param satellite_slot_number [in] Satellite slot number identifier
63  * \returns Frame number being decoded, 0 if operation was not successful.
64  */
65  uint32_t get_frame_number(uint32_t satellite_slot_number);
66 
67  /*!
68  * \brief Obtain a GLONASS GNAV SV Ephemeris class filled with current SV data
69  */
71  {
72  return gnav_ephemeris;
73  }
74 
75  /*!
76  * \brief Obtain a GLONASS GNAV UTC model parameters class filled with current SV data
77  */
79  {
80  return gnav_utc_model;
81  }
82 
83  /*!
84  * \brief Returns a Glonass_Gnav_Almanac object filled with the latest navigation data received
85  * \param satellite_slot_number Slot number identifier for the satellite
86  * \returns Returns the Glonass_Gnav_Almanac object for the input slot number
87  */
88  Glonass_Gnav_Almanac get_almanac(uint32_t satellite_slot_number) const;
89 
90  /*!
91  * \brief Returns true if a new Glonass_Gnav_Ephemeris object has arrived.
92  */
93  bool have_new_ephemeris();
94 
95  /*!
96  * \brief Returns true if new Glonass_Gnav_Utc_Model object has arrived
97  */
98  bool have_new_utc_model();
99 
100  /*!
101  * \brief Returns true if new Glonass_Gnav_Almanac object has arrived.
102  */
103  bool have_new_almanac();
104 
105  /*!
106  * \brief Decodes the GLONASS GNAV string
107  * \param frame_string [in] is the string message within the parsed frame
108  * \returns Returns the ID of the decoded string
109  */
110  int32_t string_decoder(const std::string& frame_string);
111 
112  inline bool get_flag_CRC_test() const
113  {
114  return flag_CRC_test;
115  }
116 
117  inline void set_rf_link(int32_t rf_link)
118  {
119  gnav_ephemeris.i_satellite_freq_channel = rf_link;
120  }
121 
122  inline uint32_t get_alm_satellite_slot_number() const
123  {
124  return i_alm_satellite_slot_number;
125  }
126 
127  inline bool get_flag_update_slot_number() const
128  {
129  return flag_update_slot_number;
130  }
131 
132  inline void set_flag_update_slot_number(bool flag_slot)
133  {
134  flag_update_slot_number = flag_slot;
135  }
136 
137  inline bool get_flag_TOW_new() const
138  {
139  return flag_TOW_new;
140  }
141 
142  inline void set_flag_TOW_new(bool tow_new)
143  {
144  flag_TOW_new = tow_new;
145  }
146 
147  inline bool is_flag_TOW_set() const
148  {
149  return flag_TOW_set;
150  }
151 
152  inline void set_flag_ephemeris_str_1(bool ephemeris_str_1)
153  {
154  flag_ephemeris_str_1 = ephemeris_str_1;
155  }
156 
157  inline void set_flag_ephemeris_str_2(bool ephemeris_str_2)
158  {
159  flag_ephemeris_str_2 = ephemeris_str_2;
160  }
161 
162  inline void set_flag_ephemeris_str_3(bool ephemeris_str_3)
163  {
164  flag_ephemeris_str_3 = ephemeris_str_3;
165  }
166 
167  inline void set_flag_ephemeris_str_4(bool ephemeris_str_4)
168  {
169  flag_ephemeris_str_4 = ephemeris_str_4;
170  }
171 
172 private:
173  uint64_t read_navigation_unsigned(const std::bitset<GLONASS_GNAV_STRING_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
174  int64_t read_navigation_signed(const std::bitset<GLONASS_GNAV_STRING_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
175  bool read_navigation_bool(const std::bitset<GLONASS_GNAV_STRING_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
176 
177  Glonass_Gnav_Ephemeris gnav_ephemeris{}; // Ephemeris information decoded
178  Glonass_Gnav_Utc_Model gnav_utc_model{}; // UTC model information
179  Glonass_Gnav_Almanac gnav_almanac[GLONASS_CA_NBR_SATS]{}; // Almanac information for all 24 satellites
180 
181  std::map<int, std::string> satelliteBlock; // Map that stores to which block the PRN belongs
182 
183  double d_previous_tb{}; // Previous iode for the Glonass_Gnav_Ephemeris object. Used to determine when new data arrives
184  double d_previous_Na[GLONASS_CA_NBR_SATS]{}; // Previous time for almanac of the Glonass_Gnav_Almanac object
185 
186  uint32_t d_frame_ID{};
187  uint32_t d_string_ID{};
188  uint32_t i_alm_satellite_slot_number{}; // SV Orbit Slot Number
189 
190  bool flag_CRC_test{};
191  bool flag_update_slot_number{};
192 
193  // Ephemeris Flags and control variables
194  bool flag_all_ephemeris{}; // Flag indicating that all strings containing ephemeris have been received
195  bool flag_ephemeris_str_1{}; // Flag indicating that ephemeris 1/4 (string 1) have been received
196  bool flag_ephemeris_str_2{}; // Flag indicating that ephemeris 2/4 (string 2) have been received
197  bool flag_ephemeris_str_3{}; // Flag indicating that ephemeris 3/4 (string 3) have been received
198  bool flag_ephemeris_str_4{}; // Flag indicating that ephemeris 4/4 (string 4) have been received
199 
200  // Almanac Flags
201  bool flag_almanac_str_6{}; // Flag indicating that almanac of string 6 have been received
202  bool flag_almanac_str_7{}; // Flag indicating that almanac of string 7 have been received
203  bool flag_almanac_str_8{}; // Flag indicating that almanac of string 8 have been received
204  bool flag_almanac_str_9{}; // Flag indicating that almanac of string 9 have been received
205  bool flag_almanac_str_10{}; // Flag indicating that almanac of string 10 have been received
206  bool flag_almanac_str_11{}; // Flag indicating that almanac of string 11 have been received
207  bool flag_almanac_str_12{}; // Flag indicating that almanac of string 12 have been received
208  bool flag_almanac_str_13{}; // Flag indicating that almanac of string 13 have been received
209  bool flag_almanac_str_14{}; // Flag indicating that almanac of string 14 have been received
210  bool flag_almanac_str_15{}; // Flag indicating that almanac of string 15 have been received
211 
212  // UTC and System Clocks Flags
213  bool flag_utc_model_str_5{}; // Clock info send in string 5 of navigation data
214 
215  bool flag_TOW_set{}; // Flag indicating when the TOW has been set
216  bool flag_TOW_new{}; // Flag indicating when a new TOW has been computed
217 };
218 
219 
220 /** \} */
221 /** \} */
222 #endif // GNSS_SDR_GLONASS_GNAV_NAVIGATION_MESSAGE_H
bool have_new_ephemeris()
Returns true if a new Glonass_Gnav_Ephemeris object has arrived.
int32_t i_satellite_freq_channel
SV Frequency Channel Number.
Defines system parameters for GLONASS L1 C/A signal and NAV data.
Interface of a GLONASS EPHEMERIS storage.
Interface of a GLONASS GNAV UTC MODEL storage.
Interface of a GLONASS GNAV ALMANAC storage.
bool CRC_test(std::bitset< GLONASS_GNAV_STRING_BITS > &bits) const
Compute CRC for GLONASS GNAV strings.
Glonass_Gnav_Utc_Model get_utc_model() const
Obtain a GLONASS GNAV UTC model parameters class filled with current SV data.
This class is a storage and orbital model functions for the GLONASS SV ephemeris data as described in...
bool have_new_almanac()
Returns true if new Glonass_Gnav_Almanac object has arrived.
This class is a storage for the GLONASS GNAV UTC MODEL data as described in GLONASS ICD (Edition 5...
int32_t string_decoder(const std::string &frame_string)
Decodes the GLONASS GNAV string.
uint32_t get_frame_number(uint32_t satellite_slot_number)
Computes the frame number being decoded given the satellite slot number.
This class is a storage for the GLONASS SV ALMANAC data as described GLONASS ICD (Edition 5...
bool have_new_utc_model()
Returns true if new Glonass_Gnav_Utc_Model object has arrived.
Glonass_Gnav_Ephemeris get_ephemeris() const
Obtain a GLONASS GNAV SV Ephemeris class filled with current SV data.
This class decodes a GLONASS GNAV Data message as described in GLONASS ICD (Edition 5...
Glonass_Gnav_Almanac get_almanac(uint32_t satellite_slot_number) const
Returns a Glonass_Gnav_Almanac object filled with the latest navigation data received.