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 navigation message.
28   * @param <T> type of the field elements
29   * @author Luc Maisonobe
30   * @since 13.0
31   */
32  public class FieldBeidouLegacyNavigationMessage<T extends CalculusFieldElement<T>>
33      extends FieldAbstractNavigationMessage<T, BeidouLegacyNavigationMessage> {
34  
35      /** Indicator for D2 messages.
36       * @since 14.0
37       */
38      private final boolean d2;
39  
40      /** Age of Data, Ephemeris. */
41      private final int aode;
42  
43      /** Age of Data, Clock. */
44      private final int aodc;
45  
46      /** Health identifier.
47       * @since 14.0
48       */
49      private final int satH1;
50  
51      /** B1/B3 Group Delay Differential (s). */
52      private final T tgd1;
53  
54      /** B2/B3 Group Delay Differential (s). */
55      private final T tgd2;
56  
57      /** The user SV accuracy (m). */
58      private final T svAccuracy;
59  
60      /** Creates a new instance.
61       * @param d2               indicator for D2 messages
62       * @param angularVelocity  mean angular velocity of the Earth for the GNSS model
63       * @param weeksInCycle     number of weeks in the GNSS cycle
64       * @param timeScales       known time scales
65       * @param type             type (null if not a navigation message)
66       * @param prn              PRN number of the satellite
67       * @param toe              time of ephemeris (<em>must</em> be consistent with {@code orbit})
68       * @param orbit            Keplerian orbit in Earth-frozen frame
69       * @param nonKeplerian     15 non-Keplerian parameters (in the order given by {@link NonKeplerianDriversFactory}
70       * @param tgd              group delay differential TGD for L1-L2 correction
71       * @param toc              time of clock
72       * @param transmissionTime transmission time
73       * @param aode             age of data, ephemeris
74       * @param aodc             age of data, clock
75       * @param satH1            health identifier
76       * @param tgd1             B1/B3 Group Delay Differential (s)
77       * @param tgd2             B2/B3 Group Delay Differential (s)
78       * @param svAccuracy       user SV accuracy (m)
79       * @since 14.0
80       */
81      public FieldBeidouLegacyNavigationMessage(final boolean d2,
82                                                final double angularVelocity, final int weeksInCycle,
83                                                final TimeScales timeScales, final String type, final int prn,
84                                                final FieldGNSSDate<T> toe, final FieldKeplerianOrbit<T> orbit,
85                                                final T[] nonKeplerian, final T tgd,
86                                                final FieldGNSSDate<T> toc, final FieldGNSSDate<T>  transmissionTime,
87                                                final int aode, final int aodc, final int satH1,
88                                                final T tgd1, final T tgd2, final T svAccuracy) {
89          super(angularVelocity, weeksInCycle, timeScales, type, prn, toe, orbit, nonKeplerian,
90                tgd, toc, transmissionTime);
91          this.d2         = d2;
92          this.aode       = aode;
93          this.aodc       = aodc;
94          this.satH1      = satH1;
95          this.tgd1       = tgd1;
96          this.tgd2       = tgd2;
97          this.svAccuracy = svAccuracy;
98      }
99  
100     /** {@inheritDoc} */
101     @Override
102     public BeidouLegacyNavigationMessage toNonField() {
103         return new BeidouLegacyNavigationMessage(this);
104     }
105 
106     /** {@inheritDoc} */
107     @Override
108     public <U extends CalculusFieldElement<U>>
109         FieldBeidouLegacyNavigationMessage<U> toField(final FieldKeplerianOrbit<U> orbit,
110                                                       final U[] nonKeplerian,
111                                                       final Function<T, U> converter) {
112         return new FieldBeidouLegacyNavigationMessage<>(isD2(),
113                                                         getAngularVelocity(), getWeeksInCycle(), getTimeScales(),
114                                                         getType(), getPrn(),
115                                                         new FieldGNSSDate<>(orbit.getDate().getField(),
116                                                                             getTimeOfEphemeris().getGnssDate()),
117                                                         orbit, nonKeplerian,
118                                                         converter.apply(getTgd()),
119                                                         new FieldGNSSDate<>(orbit.getDate().getField(),
120                                                                             getTimeOfClock().getGnssDate()),
121                                                         new FieldGNSSDate<>(orbit.getDate().getField(),
122                                                                             getTransmissionTime().getGnssDate()),
123                                                         getAODE(), getAODC(), getSatH1(),
124                                                         converter.apply(getTGD1()),
125                                                         converter.apply(getTGD2()),
126                                                         converter.apply(getSvAccuracy()));
127     }
128 
129     /**
130      * Check if message is a D2 message.
131      * @return true if message is a D2 message
132      * @since 14.0
133      */
134     public boolean isD2() {
135         return d2;
136     }
137 
138     /**
139      * Getter for the Age Of Data Clock (AODC).
140      * @return the Age Of Data Clock (AODC)
141      */
142     public int getAODC() {
143         return aodc;
144     }
145 
146     /**
147      * Getter for the Age Of Data Ephemeris (AODE).
148      * @return the Age Of Data Ephemeris (AODE)
149      */
150     public int getAODE() {
151         return aode;
152     }
153 
154     /**
155      * Getter for the estimated group delay differential TGD1 for B1I signal.
156      * @return the estimated group delay differential TGD1 for B1I signal (s)
157      */
158     public T getTGD1() {
159         return tgd1;
160     }
161 
162     /**
163      * Getter for the estimated group delay differential TGD for B2I signal.
164      * @return the estimated group delay differential TGD2 for B2I signal (s)
165      */
166     public T getTGD2() {
167         return tgd2;
168     }
169 
170     /**
171      * Getter for the user SV accuray (meters).
172      * @return the user SV accuracy
173      */
174     public T getSvAccuracy() {
175         return svAccuracy;
176     }
177 
178     /** Get the health identifier.
179      * @return health identifier
180      * @since 14.0
181      */
182     public int getSatH1() {
183         return satH1;
184     }
185 
186 }