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.orekit.orbits.FieldKeplerianOrbit;
21  import org.orekit.time.FieldGNSSDate;
22  import org.orekit.time.TimeScales;
23  
24  import java.util.function.Function;
25  
26  /**
27   * Container for data contained in a Beidou civilian navigation message.
28   * @param <T> type of the field elements
29   * @author Luc Maisonobe
30   * @since 13.0
31   */
32  public class FieldBeidouCivilianNavigationMessage<T extends CalculusFieldElement<T>>
33      extends FieldAbstractNavigationMessage<T, BeidouCivilianNavigationMessage> {
34  
35      /** Beidou civilian message type.
36       * @since 14.0
37       */
38      private final BeidouCivilianType beidouType;
39  
40      /** Issue of Data, Ephemeris. */
41      private final int iode;
42  
43      /** Issue of Data, Clock. */
44      private final int iodc;
45  
46      /** Inter Signal Delay for B1 CD. */
47      private final T iscB1CD;
48  
49      /** Inter Signal Delay for B1 CP. */
50      private final T iscB1CP;
51  
52      /** Inter Signal Delay for B2 AD. */
53      private final T iscB2AD;
54  
55      /** Signal In Space Accuracy Index (along track and across track). */
56      private final int sisaiOe;
57  
58      /** Signal In Space Accuracy Index (radial and clock). */
59      private final int sisaiOcb;
60  
61      /** Signal In Space Accuracy Index (clock drift accuracy). */
62      private final int sisaiOc1;
63  
64      /** Signal In Space Accuracy Index (clock drift rate accuracy). */
65      private final int sisaiOc2;
66  
67      /** Signal In Space Monitoring Accuracy Index. */
68      private final int sismai;
69  
70      /** Health. */
71      private final int health;
72  
73      /** Integrity flags. */
74      private final int integrityFlags;
75  
76      /** B1/B3 Group Delay Differential (s). */
77      private final T tgdB1Cp;
78  
79      /** B2 AP Group Delay Differential (s). */
80      private final T tgdB2ap;
81  
82      /** B2B_i / B3I Group Delay Differential (s). */
83      private final T tgdB2bI;
84  
85      /** Satellite type. */
86      private final BeidouSatelliteType satelliteType;
87  
88      /** Creates a new instance.
89       * @param beidouType       Beidou civilian message type
90       * @param angularVelocity  mean angular velocity of the Earth for the GNSS model
91       * @param weeksInCycle     number of weeks in the GNSS cycle
92       * @param timeScales       known time scales
93       * @param type             type (null if not a navigation message)
94       * @param prn              PRN number of the satellite
95       * @param toe              time of ephemeris (<em>must</em> be consistent with {@code orbit})
96       * @param orbit            Keplerian orbit in Earth-frozen frame
97       * @param nonKeplerian     15 non-Keplerian parameters (in the order given by {@link NonKeplerianDriversFactory}
98       * @param tgd              group delay differential TGD for L1-L2 correction
99       * @param toc              time of clock
100      * @param transmissionTime transmission time
101      * @param iode             issue of data, ephemeris
102      * @param iodc             issue of data, clock
103      * @param iscB1CD          inter signal delay for B1 CD
104      * @param iscB1CP          inter signal delay for B1 CP
105      * @param iscB2AD          inter signal delay for B2 AD
106      * @param sisaiOe          signal in space accuracy index (along track and across track)
107      * @param sisaiOcb         signal in space accuracy index (radial and clock)
108      * @param sisaiOc1         signal in space accuracy index (clock drift accuracy)
109      * @param sisaiOc2         signal in space accuracy index (clock drift rate accuracy)
110      * @param sismai           signal in space monitoring accuracy index
111      * @param health           health
112      * @param integrityFlags   integrity flags
113      * @param tgdB1Cp          B1/B3 Group Delay Differential (s)
114      * @param tgdB2ap          B2 AP Group Delay Differential (s)
115      * @param tgdB2bI          B2B_i / B3I Group Delay Differential (s)
116      * @param satelliteType    satellite type
117      * @since 14.0
118      */
119     public FieldBeidouCivilianNavigationMessage(final BeidouCivilianType beidouType,
120                                                 final double angularVelocity, final int weeksInCycle,
121                                                 final TimeScales timeScales, final String type, final int prn,
122                                                 final FieldGNSSDate<T> toe, final FieldKeplerianOrbit<T> orbit,
123                                                 final T[] nonKeplerian, final T tgd,
124                                                 final FieldGNSSDate<T> toc, final FieldGNSSDate<T>  transmissionTime,
125                                                 final int iode, final int iodc,
126                                                 final T iscB1CD, final T iscB1CP, final T iscB2AD,
127                                                 final int sisaiOe, final int sisaiOcb,
128                                                 final int sisaiOc1, final int sisaiOc2,
129                                                 final int sismai, final int health, final int integrityFlags,
130                                                 final T tgdB1Cp, final T tgdB2ap, final T tgdB2bI,
131                                                 final BeidouSatelliteType satelliteType) {
132         super(angularVelocity, weeksInCycle, timeScales, type, prn, toe, orbit, nonKeplerian,
133               tgd, toc, transmissionTime);
134         this.beidouType     = beidouType;
135         this.iode           = iode;
136         this.iodc           = iodc;
137         this.iscB1CD        = iscB1CD;
138         this.iscB1CP        = iscB1CP;
139         this.iscB2AD        = iscB2AD;
140         this.sisaiOe        = sisaiOe;
141         this.sisaiOcb       = sisaiOcb;
142         this.sisaiOc1       = sisaiOc1;
143         this.sisaiOc2       = sisaiOc2;
144         this.sismai         = sismai;
145         this.health         = health;
146         this.integrityFlags = integrityFlags;
147         this.tgdB1Cp        = tgdB1Cp;
148         this.tgdB2ap        = tgdB2ap;
149         this.tgdB2bI        = tgdB2bI;
150         this.satelliteType  = satelliteType;
151     }
152 
153     /** Get the Beidou civilian message type.
154      * @return Beidou civilian message type
155      * @since 14.0
156      */
157     public BeidouCivilianType getBeidouType() {
158         return beidouType;
159     }
160 
161     /** {@inheritDoc} */
162     @Override
163     public boolean isCivilianMessage() {
164         return true;
165     }
166 
167     /** {@inheritDoc} */
168     @Override
169     public BeidouCivilianNavigationMessage toNonField() {
170         return new BeidouCivilianNavigationMessage(this);
171     }
172 
173     /** {@inheritDoc} */
174     @Override
175     public <U extends CalculusFieldElement<U>>
176         FieldBeidouCivilianNavigationMessage<U> toField(final FieldKeplerianOrbit<U> orbit,
177                                                         final U[] nonKeplerian,
178                                                         final Function<T, U> converter) {
179         return new FieldBeidouCivilianNavigationMessage<>(getBeidouType(),
180                                                           getAngularVelocity(), getWeeksInCycle(), getTimeScales(),
181                                                           getType(), getPrn(),
182                                                           new FieldGNSSDate<>(orbit.getDate().getField(),
183                                                                               getTimeOfEphemeris().getGnssDate()),
184                                                           orbit, nonKeplerian,
185                                                           converter.apply(getTgd()),
186                                                           new FieldGNSSDate<>(orbit.getDate().getField(),
187                                                                               getTimeOfClock().getGnssDate()),
188                                                           new FieldGNSSDate<>(orbit.getDate().getField(),
189                                                                            getTransmissionTime().getGnssDate()),
190                                                           getIODE(), getIODC(),
191                                                           converter.apply(getIscB1CD()),
192                                                           converter.apply(getIscB1CP()),
193                                                           converter.apply(getIscB2AD()),
194                                                           getSisaiOe(), getSisaiOcb(),
195                                                           getSisaiOc1(), getSisaiOc2(),
196                                                           getSismai(), getHealth(), getIntegrityFlags(),
197                                                           converter.apply(getTgdB1Cp()),
198                                                           converter.apply(getTgdB2ap()),
199                                                           converter.apply(getTgdB2bI()),
200                                                           getSatelliteType());
201     }
202 
203     /**
204      * Getter for the Issue Of Data Ephemeris (IODE).
205      * @return the Issue Of Data Ephemeris (IODE)
206      */
207     public int getIODE() {
208         return iode;
209     }
210 
211     /**
212      * Getter for the Issue Of Data Clock (IODC).
213      * @return the Issue Of Data Clock (IODC)
214      */
215     public int getIODC() {
216         return iodc;
217     }
218 
219     /**
220      * Getter for inter Signal Delay for B1 CD.
221      * @return inter signal delay
222      */
223     public T getIscB1CD() {
224         return iscB1CD;
225     }
226 
227     /**
228      * Getter for inter Signal Delay for B2 AD.
229      * @return inter signal delay
230      */
231     public T getIscB2AD() {
232         return iscB2AD;
233     }
234 
235     /**
236      * Getter for inter Signal Delay for B1 CP.
237      * @return inter signal delay
238      */
239     public T getIscB1CP() {
240         return iscB1CP;
241     }
242 
243     /**
244      * Getter for Signal In Space Accuracy Index (along track and across track).
245      * @return Signal In Space Accuracy Index (along track and across track)
246      */
247     public int getSisaiOe() {
248         return sisaiOe;
249     }
250 
251     /**
252      * Getter for Signal In Space Accuracy Index (radial and clock).
253      * @return Signal In Space Accuracy Index (radial and clock)
254      */
255     public int getSisaiOcb() {
256         return sisaiOcb;
257     }
258 
259     /**
260      * Getter for Signal In Space Accuracy Index (clock drift accuracy).
261      * @return Signal In Space Accuracy Index (clock drift accuracy)
262      */
263     public int getSisaiOc1() {
264         return sisaiOc1;
265     }
266 
267     /**
268      * Getter for Signal In Space Accuracy Index (clock drift rate accuracy).
269      * @return Signal In Space Accuracy Index (clock drift rate accuracy)
270      */
271     public int getSisaiOc2() {
272         return sisaiOc2;
273     }
274 
275     /**
276      * Getter for Signal In Space Monitoring Accuracy Index.
277      * @return Signal In Space Monitoring Accuracy Index
278      */
279     public int getSismai() {
280         return sismai;
281     }
282 
283     /**
284      * Getter for health.
285      * @return health
286      */
287     public int getHealth() {
288         return health;
289     }
290 
291     /**
292      * Getter for B1C integrity flags.
293      * @return B1C integrity flags
294      */
295     public int getIntegrityFlags() {
296         return integrityFlags;
297     }
298 
299     /**
300      * Getter for B1/B3 Group Delay Differential (s).
301      * @return B1/B3 Group Delay Differential (s)
302      */
303     public T getTgdB1Cp() {
304         return tgdB1Cp;
305     }
306 
307     /**
308      * Getter for B2 AP Group Delay Differential (s).
309      * @return B2 AP Group Delay Differential (s)
310      */
311     public T getTgdB2ap() {
312         return tgdB2ap;
313     }
314 
315     /**
316      * Getter for B2B_i / B3I Group Delay Differential (s).
317      * @return B2B_i / B3I Group Delay Differential (s)
318      */
319     public T getTgdB2bI() {
320         return tgdB2bI;
321     }
322 
323     /**
324      * Getter for satellite type.
325      * @return satellite type
326      */
327     public BeidouSatelliteType getSatelliteType() {
328         return satelliteType;
329     }
330 
331 }