1 /* Copyright 2022-2026 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.hipparchus.Field;
21
22 import java.util.function.Function;
23
24 /**
25 * Container for data contained in a BeiDou navigation message.
26 * @param <T> type of the field elements
27 * @author Luc Maisonobe
28 * @since 13.0
29 */
30 public class FieldBeidouLegacyNavigationMessage<T extends CalculusFieldElement<T>>
31 extends FieldAbstractNavigationMessage<T, BeidouLegacyNavigationMessage> {
32
33 /** Age of Data, Ephemeris. */
34 private int aode;
35
36 /** Age of Data, Clock. */
37 private int aodc;
38
39 /** Health identifier.
40 * @since 14.0
41 */
42 private int satH1;
43
44 /** B1/B3 Group Delay Differential (s). */
45 private T tgd1;
46
47 /** B2/B3 Group Delay Differential (s). */
48 private T tgd2;
49
50 /** The user SV accuracy (m). */
51 private T svAccuracy;
52
53 /** Constructor from non-field instance.
54 * @param field field to which elements belong
55 * @param original regular non-field instance
56 */
57 public FieldBeidouLegacyNavigationMessage(final Field<T> field, final BeidouLegacyNavigationMessage original) {
58 super(field, original);
59 setAODE(field.getZero().newInstance(original.getAODE()));
60 setAODC(field.getZero().newInstance(original.getAODC()));
61 setTGD1(field.getZero().newInstance(original.getTGD1()));
62 setTGD2(field.getZero().newInstance(original.getTGD2()));
63 setSvAccuracy(field.getZero().newInstance(original.getSvAccuracy()));
64 setSatH1(original.getSatH1());
65 }
66
67 /** Constructor from different field instance.
68 * @param <V> type of the old field elements
69 * @param original regular non-field instance
70 * @param converter for field elements
71 */
72 public <V extends CalculusFieldElement<V>> FieldBeidouLegacyNavigationMessage(final Function<V, T> converter,
73 final FieldBeidouLegacyNavigationMessage<V> original) {
74 super(converter, original);
75 setAODE(getMu().newInstance(original.getAODE()));
76 setAODC(getMu().newInstance(original.getAODC()));
77 setTGD1(converter.apply(original.getTGD1()));
78 setTGD2(converter.apply(original.getTGD2()));
79 setSvAccuracy(converter.apply(original.getSvAccuracy()));
80 setSatH1(original.getSatH1());
81 }
82
83 /** {@inheritDoc} */
84 @Override
85 public BeidouLegacyNavigationMessage toNonField() {
86 return new BeidouLegacyNavigationMessage(this);
87 }
88
89 /** {@inheritDoc} */
90 @SuppressWarnings("unchecked")
91 @Override
92 public <U extends CalculusFieldElement<U>, G extends FieldGnssOrbitalElements<U, BeidouLegacyNavigationMessage>>
93 G changeField(final Function<T, U> converter) {
94 return (G) new FieldBeidouLegacyNavigationMessage<>(converter, this);
95 }
96
97 /**
98 * Getter for the Age Of Data Clock (AODC).
99 * @return the Age Of Data Clock (AODC)
100 */
101 public int getAODC() {
102 return aodc;
103 }
104
105 /**
106 * Setter for the age of data clock.
107 * @param aod the age of data to set
108 */
109 public void setAODC(final T aod) {
110 // The value is given as a floating number in the navigation message
111 this.aodc = (int) aod.getReal();
112 }
113
114 /**
115 * Getter for the Age Of Data Ephemeris (AODE).
116 * @return the Age Of Data Ephemeris (AODE)
117 */
118 public int getAODE() {
119 return aode;
120 }
121
122 /**
123 * Setter for the age of data ephemeris.
124 * @param aod the age of data to set
125 */
126 public void setAODE(final T aod) {
127 // The value is given as a floating number in the navigation message
128 this.aode = (int) aod.getReal();
129 }
130
131 /**
132 * Getter for the estimated group delay differential TGD1 for B1I signal.
133 * @return the estimated group delay differential TGD1 for B1I signal (s)
134 */
135 public T getTGD1() {
136 return tgd1;
137 }
138
139 /**
140 * Setter for the B1/B3 Group Delay Differential (s).
141 * @param tgd the group delay differential to set
142 */
143 public void setTGD1(final T tgd) {
144 this.tgd1 = tgd;
145 }
146
147 /**
148 * Getter for the estimated group delay differential TGD for B2I signal.
149 * @return the estimated group delay differential TGD2 for B2I signal (s)
150 */
151 public T getTGD2() {
152 return tgd2;
153 }
154
155 /**
156 * Setter for the B2/B3 Group Delay Differential (s).
157 * @param tgd the group delay differential to set
158 */
159 public void setTGD2(final T tgd) {
160 this.tgd2 = tgd;
161 }
162
163 /**
164 * Getter for the user SV accuray (meters).
165 * @return the user SV accuracy
166 */
167 public T getSvAccuracy() {
168 return svAccuracy;
169 }
170
171 /**
172 * Setter for the user SV accuracy.
173 * @param svAccuracy the value to set
174 */
175 public void setSvAccuracy(final T svAccuracy) {
176 this.svAccuracy = svAccuracy;
177 }
178
179 /** Get the health identifier.
180 * @return health identifier
181 * @since 14.0
182 */
183 public int getSatH1() {
184 return satH1;
185 }
186
187 /** Set the health identifier.
188 * @param satH1 health identifier
189 * @since 14.0
190 */
191 public void setSatH1(final int satH1) {
192 this.satH1 = satH1;
193 }
194
195 }