1   /* Copyright 2022-2025 Luc Maisonobe
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.orekit.propagation.analytical.gnss.data;
18  
19  import org.hipparchus.CalculusFieldElement;
20  import org.orekit.gnss.SatelliteSystem;
21  import org.orekit.time.TimeScales;
22  
23  /**
24   * Container for data contained in a GPS/QZNSS civilian navigation message.
25   * @param <O> type of the orbital elements
26   * @author Luc Maisonobe
27   * @since 12.0
28   */
29  public abstract class CivilianNavigationMessage<O extends CivilianNavigationMessage<O>> extends AbstractNavigationMessage<O> implements GNSSClockElements {
30  
31      /** Identifier for message type. */
32      public static final String CNAV = "CNAV";
33  
34      /** Identifier for message type. */
35      public static final String CNV2 = "CNV2";
36  
37      /** Identifier for message type.
38       * @since 13.0
39       */
40      public static final String L1NV = "L1NV";
41  
42      /** Indicator for CNV 2 messages. */
43      private final boolean cnv2;
44  
45      /** Change rate in semi-major axis (m/s). */
46      private double aDot;
47  
48      /** Change rate in Δn₀. */
49      private double deltaN0Dot;
50  
51      /** The user SV accuracy (m). */
52      private double svAccuracy;
53  
54      /** Satellite health status. */
55      private int svHealth;
56  
57      /** Inter Signal Delay for L1 C/A. */
58      private double iscL1CA;
59  
60      /** Inter Signal Delay for L1 CD. */
61      private double iscL1CD;
62  
63      /** Inter Signal Delay for L1 CP. */
64      private double iscL1CP;
65  
66      /** Inter Signal Delay for L2 C. */
67      private double iscL2C;
68  
69      /** Inter Signal Delay for L5I. */
70      private double iscL5I5;
71  
72      /** Inter Signal Delay for L5Q. */
73      private double iscL5Q5;
74  
75      /** Elevation-Dependent User Range Accuracy. */
76      private int uraiEd;
77  
78      /** Term 0 of Non-Elevation-Dependent User Range Accuracy. */
79      private int uraiNed0;
80  
81      /** Term 1 of Non-Elevation-Dependent User Range Accuracy. */
82      private int uraiNed1;
83  
84      /** Term 2 of Non-Elevation-Dependent User Range Accuracy. */
85      private int uraiNed2;
86  
87      /**
88       * Constructor.
89       * @param cnv2            indicator for CNV2 messages
90       * @param mu              Earth's universal gravitational parameter
91       * @param angularVelocity mean angular velocity of the Earth for the GNSS model
92       * @param weeksInCycle    number of weeks in the GNSS cycle
93       * @param timeScales      known time scales
94       * @param system          satellite system to consider for interpreting week number
95       *                        (may be different from real system, for example in Rinex nav, weeks
96       *                        are always according to GPS)
97       */
98      protected CivilianNavigationMessage(final boolean cnv2,
99                                          final double mu, final double angularVelocity, final int weeksInCycle,
100                                         final TimeScales timeScales, final SatelliteSystem system) {
101         super(mu, angularVelocity, weeksInCycle, timeScales, system);
102         this.cnv2 = cnv2;
103     }
104 
105     /** Constructor from field instance.
106      * @param <T> type of the field elements
107      * @param <A> type of the orbital elements (non-field version)
108      * @param original regular field instance
109      */
110     protected <T extends CalculusFieldElement<T>,
111                A extends CivilianNavigationMessage<A>> CivilianNavigationMessage(final FieldCivilianNavigationMessage<T, A> original) {
112         super(original);
113         this.cnv2 = original.isCnv2();
114         setADot(original.getADot().getReal());
115         setDeltaN0Dot(original.getDeltaN0Dot().getReal());
116         setSvAccuracy(original.getSvAccuracy().getReal());
117         setSvHealth(original.getSvHealth());
118         setIscL1CA(original.getIscL1CA().getReal());
119         setIscL1CD(original.getIscL1CD().getReal());
120         setIscL1CP(original.getIscL1CP().getReal());
121         setIscL2C(original.getIscL2C().getReal());
122         setIscL5I5(original.getIscL5I5().getReal());
123         setIscL5Q5(original.getIscL5Q5().getReal());
124         setUraiEd(original.getUraiEd());
125         setUraiNed0(original.getUraiNed0());
126         setUraiNed1(original.getUraiNed1());
127         setUraiNed2(original.getUraiNed2());
128     }
129 
130     /** Check it message is a CNV2 message.
131      * @return true if message is a CNV2 message
132      */
133     public boolean isCnv2() {
134         return cnv2;
135     }
136 
137     /** {@inheritDoc} */
138     @Override
139     public double getADot() {
140         return aDot;
141     }
142 
143     /**
144      * Setter for the change rate in semi-major axis.
145      * @param value the change rate in semi-major axis
146      */
147     public void setADot(final double value) {
148         this.aDot = value;
149     }
150 
151     /** {@inheritDoc} */
152     @Override
153     public double getDeltaN0Dot() {
154         return deltaN0Dot;
155     }
156 
157     /**
158      * Setter for change rate in Δn₀.
159      * @param deltaN0Dot change rate in Δn₀
160      */
161     public void setDeltaN0Dot(final double deltaN0Dot) {
162         this.deltaN0Dot = deltaN0Dot;
163     }
164 
165     /**
166      * Getter for the user SV accuray (meters).
167      * @return the user SV accuracy
168      */
169     public double getSvAccuracy() {
170         return svAccuracy;
171     }
172 
173     /**
174      * Setter for the user SV accuracy.
175      * @param svAccuracy the value to set
176      */
177     public void setSvAccuracy(final double svAccuracy) {
178         this.svAccuracy = svAccuracy;
179     }
180 
181     /**
182      * Getter for the satellite health status.
183      * @return the satellite health status
184      */
185     public int getSvHealth() {
186         return svHealth;
187     }
188 
189     /**
190      * Setter for the satellite health status.
191      * @param svHealth the value to set
192      */
193     public void setSvHealth(final int svHealth) {
194         this.svHealth = svHealth;
195     }
196 
197     /**
198      * Getter for inter Signal Delay for L1 C/A.
199      * @return inter signal delay
200      */
201     public double getIscL1CA() {
202         return iscL1CA;
203     }
204 
205     /**
206      * Setter for inter Signal Delay for L1 C/A.
207      * @param delay delay to set
208      */
209     public void setIscL1CA(final double delay) {
210         this.iscL1CA = delay;
211     }
212 
213     /**
214      * Getter for inter Signal Delay for L1 CD.
215      * @return inter signal delay
216      */
217     public double getIscL1CD() {
218         return iscL1CD;
219     }
220 
221     /**
222      * Setter for inter Signal Delay for L1 CD.
223      * @param delay delay to set
224      */
225     public void setIscL1CD(final double delay) {
226         this.iscL1CD = delay;
227     }
228 
229     /**
230      * Getter for inter Signal Delay for L1 CP.
231      * @return inter signal delay
232      */
233     public double getIscL1CP() {
234         return iscL1CP;
235     }
236 
237     /**
238      * Setter for inter Signal Delay for L1 CP.
239      * @param delay delay to set
240      */
241     public void setIscL1CP(final double delay) {
242         this.iscL1CP = delay;
243     }
244 
245     /**
246      * Getter for inter Signal Delay for L2 C.
247      * @return inter signal delay
248      */
249     public double getIscL2C() {
250         return iscL2C;
251     }
252 
253     /**
254      * Setter for inter Signal Delay for L2 C.
255      * @param delay delay to set
256      */
257     public void setIscL2C(final double delay) {
258         this.iscL2C = delay;
259     }
260 
261     /**
262      * Getter for inter Signal Delay for L5I.
263      * @return inter signal delay
264      */
265     public double getIscL5I5() {
266         return iscL5I5;
267     }
268 
269     /**
270      * Setter for inter Signal Delay for L5I.
271      * @param delay delay to set
272      */
273     public void setIscL5I5(final double delay) {
274         this.iscL5I5 = delay;
275     }
276 
277     /**
278      * Getter for inter Signal Delay for L5Q.
279      * @return inter signal delay
280      */
281     public double getIscL5Q5() {
282         return iscL5Q5;
283     }
284 
285     /**
286      * Setter for inter Signal Delay for L5Q.
287      * @param delay delay to set
288      */
289     public void setIscL5Q5(final double delay) {
290         this.iscL5Q5 = delay;
291     }
292 
293     /**
294      * Getter for Elevation-Dependent User Range Accuracy.
295      * @return Elevation-Dependent User Range Accuracy
296      */
297     public int getUraiEd() {
298         return uraiEd;
299     }
300 
301     /**
302      * Setter for Elevation-Dependent User Range Accuracy.
303      * @param uraiEd Elevation-Dependent User Range Accuracy
304      */
305     public void setUraiEd(final int uraiEd) {
306         this.uraiEd = uraiEd;
307     }
308 
309     /**
310      * Getter for term 0 of Non-Elevation-Dependent User Range Accuracy.
311      * @return term 0 of Non-Elevation-Dependent User Range Accuracy
312      */
313     public int getUraiNed0() {
314         return uraiNed0;
315     }
316 
317     /**
318      * Setter for term 0 of Non-Elevation-Dependent User Range Accuracy.
319      * @param uraiNed0 term 0 of Non-Elevation-Dependent User Range Accuracy
320      */
321     public void setUraiNed0(final int uraiNed0) {
322         this.uraiNed0 = uraiNed0;
323     }
324 
325     /**
326      * Getter for term 1 of Non-Elevation-Dependent User Range Accuracy.
327      * @return term 1 of Non-Elevation-Dependent User Range Accuracy
328      */
329     public int getUraiNed1() {
330         return uraiNed1;
331     }
332 
333     /**
334      * Setter for term 1 of Non-Elevation-Dependent User Range Accuracy.
335      * @param uraiNed1 term 1 of Non-Elevation-Dependent User Range Accuracy
336      */
337     public void setUraiNed1(final int uraiNed1) {
338         this.uraiNed1 = uraiNed1;
339     }
340 
341     /**
342      * Getter for term 2 of Non-Elevation-Dependent User Range Accuracy.
343      * @return term 2 of Non-Elevation-Dependent User Range Accuracy
344      */
345     public int getUraiNed2() {
346         return uraiNed2;
347     }
348 
349     /**
350      * Setter for term 2 of Non-Elevation-Dependent User Range Accuracy.
351      * @param uraiNed2 term 2 of Non-Elevation-Dependent User Range Accuracy
352      */
353     public void setUraiNed2(final int uraiNed2) {
354         this.uraiNed2 = uraiNed2;
355     }
356 
357 }