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.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 /** B1/B3 Group Delay Differential (s). */
40 private T tgd1;
41
42 /** B2/B3 Group Delay Differential (s). */
43 private T tgd2;
44
45 /** The user SV accuracy (m). */
46 private T svAccuracy;
47
48 /** Constructor from non-field instance.
49 * @param field field to which elements belong
50 * @param original regular non-field instance
51 */
52 public FieldBeidouLegacyNavigationMessage(final Field<T> field, final BeidouLegacyNavigationMessage original) {
53 super(field, original);
54 setAODE(field.getZero().newInstance(original.getAODE()));
55 setAODC(field.getZero().newInstance(original.getAODC()));
56 setTGD1(field.getZero().newInstance(original.getTGD1()));
57 setTGD2(field.getZero().newInstance(original.getTGD2()));
58 setSvAccuracy(field.getZero().newInstance(original.getSvAccuracy()));
59 }
60
61 /** Constructor from different field instance.
62 * @param <V> type of the old field elements
63 * @param original regular non-field instance
64 * @param converter for field elements
65 */
66 public <V extends CalculusFieldElement<V>> FieldBeidouLegacyNavigationMessage(final Function<V, T> converter,
67 final FieldBeidouLegacyNavigationMessage<V> original) {
68 super(converter, original);
69 setAODE(getMu().newInstance(original.getAODE()));
70 setAODC(getMu().newInstance(original.getAODC()));
71 setTGD1(converter.apply(original.getTGD1()));
72 setTGD2(converter.apply(original.getTGD2()));
73 setSvAccuracy(converter.apply(original.getSvAccuracy()));
74 }
75
76 /** {@inheritDoc} */
77 @Override
78 public BeidouLegacyNavigationMessage toNonField() {
79 return new BeidouLegacyNavigationMessage(this);
80 }
81
82 /** {@inheritDoc} */
83 @SuppressWarnings("unchecked")
84 @Override
85 public <U extends CalculusFieldElement<U>, G extends FieldGnssOrbitalElements<U, BeidouLegacyNavigationMessage>>
86 G changeField(final Function<T, U> converter) {
87 return (G) new FieldBeidouLegacyNavigationMessage<>(converter, this);
88 }
89
90 /**
91 * Getter for the Age Of Data Clock (AODC).
92 * @return the Age Of Data Clock (AODC)
93 */
94 public int getAODC() {
95 return aodc;
96 }
97
98 /**
99 * Setter for the age of data clock.
100 * @param aod the age of data to set
101 */
102 public void setAODC(final T aod) {
103 // The value is given as a floating number in the navigation message
104 this.aodc = (int) aod.getReal();
105 }
106
107 /**
108 * Getter for the Age Of Data Ephemeris (AODE).
109 * @return the Age Of Data Ephemeris (AODE)
110 */
111 public int getAODE() {
112 return aode;
113 }
114
115 /**
116 * Setter for the age of data ephemeris.
117 * @param aod the age of data to set
118 */
119 public void setAODE(final T aod) {
120 // The value is given as a floating number in the navigation message
121 this.aode = (int) aod.getReal();
122 }
123
124 /**
125 * Getter for the estimated group delay differential TGD1 for B1I signal.
126 * @return the estimated group delay differential TGD1 for B1I signal (s)
127 */
128 public T getTGD1() {
129 return tgd1;
130 }
131
132 /**
133 * Setter for the B1/B3 Group Delay Differential (s).
134 * @param tgd the group delay differential to set
135 */
136 public void setTGD1(final T tgd) {
137 this.tgd1 = tgd;
138 }
139
140 /**
141 * Getter for the estimated group delay differential TGD for B2I signal.
142 * @return the estimated group delay differential TGD2 for B2I signal (s)
143 */
144 public T getTGD2() {
145 return tgd2;
146 }
147
148 /**
149 * Setter for the B2/B3 Group Delay Differential (s).
150 * @param tgd the group delay differential to set
151 */
152 public void setTGD2(final T tgd) {
153 this.tgd2 = tgd;
154 }
155
156 /**
157 * Getter for the user SV accuray (meters).
158 * @return the user SV accuracy
159 */
160 public T getSvAccuracy() {
161 return svAccuracy;
162 }
163
164 /**
165 * Setter for the user SV accuracy.
166 * @param svAccuracy the value to set
167 */
168 public void setSvAccuracy(final T svAccuracy) {
169 this.svAccuracy = svAccuracy;
170 }
171
172 }