1 /* Copyright 2002-2025 CS GROUP
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 import org.orekit.utils.ParameterDriver;
23
24 /** Container for common GNSS data contained in almanac and navigation messages.
25 * @param <O> type of the orbital elements
26 * @author Bryan Cazabonne
27 * @since 11.0
28 */
29 public abstract class CommonGnssData<O extends CommonGnssData<O>>
30 extends GNSSOrbitalElements<O>
31 implements GNSSClockElements {
32
33 /** Name for zero-th order clock correction parameter.
34 * @since 13.0
35 */
36 public static final String AF0 = "GnssClock0";
37
38 /** Name for first order clock correction parameter.
39 * @since 13.0
40 */
41 public static final String AF1 = "GnssClock1";
42
43 /** Name for second order clock correction parameter.
44 * @since 13.0
45 */
46 public static final String AF2 = "GnssClock2";
47
48 /** SV zero-th order clock correction (s). */
49 private final ParameterDriver af0Driver;
50
51 /** SV first order clock correction (s/s). */
52 private final ParameterDriver af1Driver;
53
54 /** SV second order clock correction (s/s²). */
55 private final ParameterDriver af2Driver;
56
57 /** Group delay differential TGD for L1-L2 correction. */
58 private double tgd;
59
60 /** Time Of Clock. */
61 private double toc;
62
63 /**
64 * Constructor.
65 * @param mu Earth's universal gravitational parameter
66 * @param angularVelocity mean angular velocity of the Earth for the GNSS model
67 * @param weeksInCycle number of weeks in the GNSS cycle
68 * @param timeScales known time scales
69 * @param system satellite system to consider for interpreting week number
70 * (may be different from real system, for example in Rinex nav, weeks
71 * are always according to GPS)
72 */
73 protected CommonGnssData(final double mu, final double angularVelocity, final int weeksInCycle,
74 final TimeScales timeScales, final SatelliteSystem system) {
75 super(mu, angularVelocity, weeksInCycle, timeScales, system);
76 this.af0Driver = createDriver(AF0);
77 this.af1Driver = createDriver(AF1);
78 this.af2Driver = createDriver(AF2);
79 }
80
81 /** Constructor from field instance.
82 * @param <T> type of the field elements
83 * @param <A> type of the orbital elements (non-field version)
84 * @param original regular field instance
85 */
86 protected <T extends CalculusFieldElement<T>,
87 A extends CommonGnssData<A>> CommonGnssData(final FieldCommonGnssData<T, A> original) {
88 super(original);
89 this.af0Driver = createDriver(AF0);
90 this.af1Driver = createDriver(AF1);
91 this.af2Driver = createDriver(AF2);
92 setAf0(original.getAf0().getReal());
93 setAf1(original.getAf1().getReal());
94 setAf2(original.getAf2().getReal());
95 setTGD(original.getTGD().getReal());
96 setToc(original.getToc().getReal());
97 }
98
99 /** {@inheritDoc} */
100 @Override
101 public double getAf0() {
102 return af0Driver.getValue();
103 }
104
105 /**
106 * Setter for the SV Clock Bias Correction Coefficient (s).
107 * @param af0 the SV Clock Bias Correction Coefficient to set
108 */
109 public void setAf0(final double af0) {
110 af0Driver.setValue(af0);
111 }
112
113 /** {@inheritDoc} */
114 @Override
115 public double getAf1() {
116 return af1Driver.getValue();
117 }
118
119 /**
120 * Setter for the SV Clock Drift Correction Coefficient (s/s).
121 * @param af1 the SV Clock Drift Correction Coefficient to set
122 */
123 public void setAf1(final double af1) {
124 af1Driver.setValue(af1);
125 }
126
127 /** {@inheritDoc} */
128 @Override
129 public double getAf2() {
130 return af2Driver.getValue();
131 }
132
133 /**
134 * Setter for the Drift Rate Correction Coefficient (s/s²).
135 * @param af2 the Drift Rate Correction Coefficient to set
136 */
137 public void setAf2(final double af2) {
138 af2Driver.setValue(af2);
139 }
140
141 /**
142 * Set the estimated group delay differential TGD for L1-L2 correction.
143 * @param groupDelayDifferential the estimated group delay differential TGD for L1-L2 correction (s)
144 */
145 public void setTGD(final double groupDelayDifferential) {
146 this.tgd = groupDelayDifferential;
147 }
148
149 /** {@inheritDoc} */
150 @Override
151 public double getTGD() {
152 return tgd;
153 }
154
155 /**
156 * Set the time of clock.
157 * @param toc the time of clock (s)
158 * @see #getAf0()
159 * @see #getAf1()
160 * @see #getAf2()
161 */
162 public void setToc(final double toc) {
163 this.toc = toc;
164 }
165
166 /** {@inheritDoc} */
167 @Override
168 public double getToc() {
169 return toc;
170 }
171
172 }