GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
serdes_gps_eph.h
Go to the documentation of this file.
1 /*!
2  * \file serdes_gps_eph.h
3  * \brief Serialization / Deserialization of Gps_Ephemeris objects using
4  * Protocol Buffers
5  * \author Javier Arribas, 2021. jarribas(at)cttc.es
6  *
7  * -----------------------------------------------------------------------------
8  *
9  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
10  * This file is part of GNSS-SDR.
11  *
12  * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
13  * SPDX-License-Identifier: GPL-3.0-or-later
14  *
15  * -----------------------------------------------------------------------------
16  */
17 
18 #ifndef GNSS_SDR_SERDES_GPS_EPH_H
19 #define GNSS_SDR_SERDES_GPS_EPH_H
20 
21 #include "gps_ephemeris.h"
22 #include "gps_ephemeris.pb.h" // file created by Protocol Buffers at compile time
23 #include <memory>
24 #include <string>
25 #include <utility>
26 
27 /** \addtogroup PVT
28  * \{ */
29 /** \addtogroup PVT_libs
30  * \{ */
31 
32 /*!
33  * \brief This class implements serialization and deserialization of
34  * Gps_Ephemeris objects using Protocol Buffers.
35  */
37 {
38 public:
40  {
41  // Verify that the version of the library that we linked against is
42  // compatible with the version of the headers we compiled against.
43  GOOGLE_PROTOBUF_VERIFY_VERSION;
44  }
45 
47  {
48  // google::protobuf::ShutdownProtobufLibrary();
49  }
50 
51  inline Serdes_Gps_Eph(const Serdes_Gps_Eph& other) noexcept : monitor_(other.monitor_) //!< Copy constructor
52  {
53  }
54 
55  inline Serdes_Gps_Eph& operator=(const Serdes_Gps_Eph& rhs) noexcept //!< Copy assignment operator
56  {
57  Serdes_Gps_Eph temp(rhs);
58  std::swap(this->monitor_, temp.monitor_);
59  return *this;
60  }
61 
62  inline Serdes_Gps_Eph(Serdes_Gps_Eph&& other) noexcept : monitor_(std::move(other.monitor_)) //!< Move constructor
63  {
64  }
65 
66  inline Serdes_Gps_Eph& operator=(Serdes_Gps_Eph&& other) noexcept //!< Move assignment operator
67  {
68  std::swap(this->monitor_, other.monitor_);
69  return *this;
70  }
71 
72  inline std::string createProtobuffer(const std::shared_ptr<Gps_Ephemeris> monitor) //!< Serialization into a string
73  {
74  monitor_.Clear();
75  std::string data;
76 
77  monitor_.set_prn(monitor->PRN);
78  monitor_.set_m_0(monitor->M_0);
79  monitor_.set_delta_n(monitor->delta_n);
80  monitor_.set_ecc(monitor->ecc);
81  monitor_.set_sqrta(monitor->sqrtA);
82  monitor_.set_omega_0(monitor->OMEGA_0);
83  monitor_.set_i_0(monitor->i_0);
84  monitor_.set_omega(monitor->omega);
85  monitor_.set_omegadot(monitor->OMEGAdot);
86  monitor_.set_idot(monitor->idot);
87  monitor_.set_cuc(monitor->Cuc);
88  monitor_.set_cus(monitor->Cus);
89  monitor_.set_crc(monitor->Crc);
90  monitor_.set_crs(monitor->Crs);
91  monitor_.set_cic(monitor->Cic);
92  monitor_.set_cis(monitor->Cis);
93  monitor_.set_toe(monitor->toe);
94  monitor_.set_toc(monitor->toc);
95  monitor_.set_af0(monitor->af0);
96  monitor_.set_af1(monitor->af1);
97  monitor_.set_af2(monitor->af2);
98  monitor_.set_satclkdrift(monitor->satClkDrift);
99  monitor_.set_dtr(monitor->dtr);
100  monitor_.set_wn(monitor->WN);
101  monitor_.set_tow(monitor->tow);
102 
103  // GPS-specific parameters
104  monitor_.set_code_on_l2(monitor->code_on_L2);
105  monitor_.set_l2_p_data_flag(monitor->L2_P_data_flag);
106  monitor_.set_sv_accuracy(monitor->SV_accuracy);
107  monitor_.set_sv_health(monitor->SV_health);
108  monitor_.set_tgd(monitor->TGD);
109  monitor_.set_iodc(monitor->IODC);
110  monitor_.set_iode_sf2(monitor->IODE_SF2);
111  monitor_.set_iode_sf3(monitor->IODE_SF3);
112  monitor_.set_aodo(monitor->AODO);
113  monitor_.set_fit_interval_flag(monitor->fit_interval_flag);
114  monitor_.set_spare1(monitor->spare1);
115  monitor_.set_spare2(monitor->spare2);
116  monitor_.set_integrity_status_flag(monitor->integrity_status_flag);
117  monitor_.set_alert_flag(monitor->alert_flag);
118  monitor_.set_antispoofing_flag(monitor->antispoofing_flag);
119 
120  monitor_.SerializeToString(&data);
121  return data;
122  }
123 
124  inline Gps_Ephemeris readProtobuffer(const gnss_sdr::GpsEphemeris& mon) const //!< Deserialization
125  {
126  Gps_Ephemeris monitor;
127 
128  monitor.PRN = mon.prn();
129  monitor.M_0 = mon.m_0();
130  monitor.delta_n = mon.delta_n();
131  monitor.ecc = mon.ecc();
132  monitor.sqrtA = mon.sqrta();
133  monitor.OMEGA_0 = mon.omega_0();
134  monitor.i_0 = mon.i_0();
135  monitor.omega = mon.omega();
136  monitor.OMEGAdot = mon.omegadot();
137  monitor.idot = mon.idot();
138  monitor.Cuc = mon.cuc();
139  monitor.Cus = mon.cus();
140  monitor.Crc = mon.crc();
141  monitor.Crs = mon.crs();
142  monitor.Cic = mon.cic();
143  monitor.Cis = mon.cis();
144  monitor.toe = mon.toe();
145  monitor.toc = mon.toc();
146  monitor.af0 = mon.af0();
147  monitor.af1 = mon.af1();
148  monitor.af2 = mon.af2();
149  monitor.satClkDrift = mon.satclkdrift();
150  monitor.dtr = mon.dtr();
151  monitor.WN = mon.wn();
152  monitor.tow = mon.tow();
153 
154  // GPS-specific parameters
155  monitor.code_on_L2 = mon.code_on_l2();
156  monitor.L2_P_data_flag = mon.l2_p_data_flag();
157  monitor.SV_accuracy = mon.sv_accuracy();
158  monitor.SV_health = mon.sv_health();
159  monitor.TGD = mon.tgd();
160  monitor.IODC = mon.iodc();
161  monitor.IODE_SF2 = mon.iode_sf2();
162  monitor.IODE_SF3 = mon.iode_sf3();
163  monitor.AODO = mon.aodo();
164  monitor.fit_interval_flag = mon.fit_interval_flag();
165  monitor.spare1 = mon.spare1();
166  monitor.spare2 = mon.spare2();
167  monitor.integrity_status_flag = mon.integrity_status_flag();
168  monitor.alert_flag = mon.alert_flag();
169  monitor.antispoofing_flag = mon.antispoofing_flag();
170 
171  return monitor;
172  }
173 
174 private:
175  gnss_sdr::GpsEphemeris monitor_{};
176 };
177 
178 
179 /** \} */
180 /** \} */
181 #endif // GNSS_SDR_SERDES_GPS_EPH_H
Gps_Ephemeris readProtobuffer(const gnss_sdr::GpsEphemeris &mon) const
< Deserialization
bool alert_flag
If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our o...
Definition: gps_ephemeris.h:75
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in IS-...
Definition: gps_ephemeris.h:40
int32_t code_on_L2
If 1, P code ON in L2; if 2, C/A code ON in L2;.
Definition: gps_ephemeris.h:48
bool integrity_status_flag
If true, enhanced level of integrity assurance.
Definition: gps_ephemeris.h:74
int32_t AODO
Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subfra...
Definition: gps_ephemeris.h:56
int32_t SV_accuracy
User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning se...
Definition: gps_ephemeris.h:50
double i_0
Inclination angle at reference time [rad].
Serdes_Gps_Eph & operator=(const Serdes_Gps_Eph &rhs) noexcept
< Copy assignment operator
double OMEGA_0
Longitude of ascending node of orbital plane at weekly epoch [rad].
int32_t IODE_SF3
Issue of Data, Ephemeris (IODE), subframe 3.
Definition: gps_ephemeris.h:55
double TGD
Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(...
Definition: gps_ephemeris.h:52
int32_t toc
Clock correction data reference Time of Week [sec].
int32_t IODC
Issue of Data, Clock.
Definition: gps_ephemeris.h:53
double Crc
Amplitude of the cosine harmonic correction term to the orbit radius [meters].
bool L2_P_data_flag
When true, indicates that the NAV data stream was commanded OFF on the P-code of the L2 channel...
Definition: gps_ephemeris.h:49
double af2
SV clock drift rate correction coefficient [s/s^2].
bool antispoofing_flag
If true, the AntiSpoofing mode is ON in that SV.
Definition: gps_ephemeris.h:76
uint32_t PRN
SV ID.
double Cis
Amplitude of the sine harmonic correction term to the angle of inclination [rad]. ...
This class implements serialization and deserialization of Gps_Ephemeris objects using Protocol Buffe...
double af0
SV clock bias correction coefficient [s].
bool fit_interval_flag
indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in d...
Definition: gps_ephemeris.h:58
double ecc
Eccentricity.
double M_0
Mean anomaly at reference time [rad].
int32_t WN
Week number.
int32_t toe
Ephemeris reference time [s].
int32_t tow
Time of Week.
double Cus
Amplitude of the sine harmonic correction term to the argument of latitude [rad]. ...
int32_t SV_health
Satellite heath status.
Definition: gps_ephemeris.h:51
double OMEGAdot
Rate of right ascension [rad/sec].
double delta_n
Mean motion difference from computed value [rad/sec].
double idot
Rate of inclination angle [rad/sec].
Serdes_Gps_Eph & operator=(Serdes_Gps_Eph &&other) noexcept
< Move assignment operator
Interface of a GPS EPHEMERIS storage.
std::string createProtobuffer(const std::shared_ptr< Gps_Ephemeris > monitor)
double Cic
Amplitude of the cosine harmonic correction term to the angle of inclination [rad].
int32_t IODE_SF2
Issue of Data, Ephemeris (IODE), subframe 2.
Definition: gps_ephemeris.h:54
double Cuc
Amplitude of the cosine harmonic correction term to the argument of latitude [rad].
double omega
Argument of perigee [rad].
double af1
SV clock drift correction coefficient [s/s].
double Crs
Amplitude of the sine harmonic correction term to the orbit radius [meters].
double satClkDrift
SV clock drift.
double dtr
Relativistic clock correction term.
double sqrtA
Square root of the semi-major axis [meters^1/2].