1   /* Copyright 2002-2026 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.frames.Frame;
21  import org.orekit.orbits.FieldKeplerianOrbit;
22  import org.orekit.orbits.KeplerianOrbit;
23  import org.orekit.time.FieldGNSSDate;
24  import org.orekit.time.GNSSDate;
25  import org.orekit.time.TimeScales;
26  
27  import java.util.function.DoubleFunction;
28  
29  /**
30   * Container for data contained in a Galileo navigation message.
31   * @author Bryan Cazabonne
32   * @since 11.0
33   */
34  public class GalileoNavigationMessage extends AbstractNavigationMessage<GalileoNavigationMessage> {
35  
36      /** Message type.
37       * @since 14.0
38       */
39      public static final String INAV = "INAV";
40  
41      /** Message type.
42       * @since 14.0
43       */
44      public static final String FNAV = "FNAV";
45  
46      /** Issue of Data of the navigation batch. */
47      private final int iodNav;
48  
49      /** Data source.
50       * @since 12.0
51       */
52      private final int dataSource;
53  
54      /** E1/E5a broadcast group delay (s). */
55      private final double bgdE1E5a;
56  
57      /** E5b/E1 broadcast group delay (s). */
58      private final double bgdE5bE1;
59  
60      /** Signal in space accuracy. */
61      private final double sisa;
62  
63      /** Satellite health status. */
64      private final double svHealth;
65  
66      /** Constructor.
67       * @param timeScales       known time scales
68       * @param type             message type
69       * @param prn              PRN number of the satellite
70       * @param toe              time of ephemeris (<em>must</em> be consistent with {@code orbit})
71       * @param orbit            Keplerian orbit in Earth-frozen frame
72       * @param aDot             change rate in semi-major axis (m/s)
73       * @param deltaN0          delta of satellite mean motion
74       * @param deltaN0Dot       change rate in Δn₀
75       * @param iDot             inclination rate (rad/s)
76       * @param omegaDot         rate of right ascension (rad/s)
77       * @param cuc              amplitude of the cosine harmonic correction term to the argument of latitude
78       * @param cus              amplitude of the sine harmonic correction term to the argument of latitude
79       * @param crc              amplitude of the cosine harmonic correction term to the orbit radius
80       * @param crs              amplitude of the sine harmonic correction term to the orbit radius
81       * @param cic              amplitude of the cosine harmonic correction term to the inclination
82       * @param cis              amplitude of the sine harmonic correction term to the inclination
83       * @param af0              zero-th order clock correction (s)
84       * @param af1              first order clock correction (s/s)
85       * @param af2              second order clock correction (s/s²)
86       * @param tgd              group delay differential TGD for L1-L2 correction
87       * @param toc              time of clock
88       * @param transmissionTime transmission time
89       * @param iodNav           issue of Data of the navigation batch
90       * @param dataSource       data source
91       * @param bgdE1E5a         E1/E5a broadcast group delay (s)
92       * @param bgdE5bE1         E5b/E1 broadcast group delay (s)
93       * @param sisa             signal in space accuracy
94       * @param svHealth         satellite health status
95       */
96      public GalileoNavigationMessage(final TimeScales timeScales, final String type,
97                                      final int prn, final GNSSDate toe, final KeplerianOrbit orbit,
98                                      final double aDot, final double deltaN0, final double deltaN0Dot,
99                                      final double iDot, final double omegaDot,
100                                     final double cuc, final double cus,
101                                     final double crc, final double crs,
102                                     final double cic, final double cis,
103                                     final double af0, final double af1, final double af2,
104                                     final double tgd, final GNSSDate toc, final GNSSDate  transmissionTime,
105                                     final int iodNav, final int dataSource,
106                                     final double bgdE1E5a, final double bgdE5bE1,
107                                     final double sisa, final double svHealth) {
108         super(GNSSConstants.GALILEO_AV, GNSSConstants.GALILEO_WEEK_NB,
109               timeScales, type, prn, toe, orbit,
110               aDot, deltaN0, deltaN0Dot, iDot, omegaDot, cuc, cus, crc, crs, cic, cis,
111               af0, af1, af2, tgd, toc, transmissionTime);
112         this.iodNav     = iodNav;
113         this.dataSource = dataSource;
114         this.bgdE1E5a   = bgdE1E5a;
115         this.bgdE5bE1   = bgdE5bE1;
116         this.sisa       = sisa;
117         this.svHealth   = svHealth;
118     }
119 
120     /** Constructor from field instance.
121      * @param <T> type of the field elements
122      * @param original regular field instance
123      */
124     public <T extends CalculusFieldElement<T>> GalileoNavigationMessage(final FieldGalileoNavigationMessage<T> original) {
125         super(original);
126         iodNav     = original.getIODNav();
127         dataSource = original.getDataSource();
128         bgdE1E5a   = original.getBGDE1E5a().getReal();
129         bgdE5bE1   = original.getBGDE5bE1().getReal();
130         sisa       = original.getSisa().getReal();
131         svHealth   = original.getSvHealth().getReal();
132     }
133 
134     /** {@inheritDoc} */
135     @Override
136     public <T extends CalculusFieldElement<T>>
137         FieldGalileoNavigationMessage<T> toField(final FieldKeplerianOrbit<T> orbit,
138                                                  final T[] nonKeplerian,
139                                                  final DoubleFunction<T> converter) {
140         return new FieldGalileoNavigationMessage<>(getAngularVelocity(), getWeeksInCycle(), getTimeScales(),
141                                                    getType(), getPrn(),
142                                                    new FieldGNSSDate<>(orbit.getDate().getField(), getTimeOfEphemeris()),
143                                                    orbit, nonKeplerian,
144                                                    converter.apply(getTgd()),
145                                                    new FieldGNSSDate<>(orbit.getDate().getField(), getTimeOfClock()),
146                                                    new FieldGNSSDate<>(orbit.getDate().getField(), getTransmissionTime()),
147                                                    getIODNav(), getDataSource(),
148                                                    converter.apply(getBGDE1E5a()),
149                                                    converter.apply(getBGDE5bE1()),
150                                                    converter.apply(getSisa()),
151                                                    converter.apply( getSvHealth()));
152     }
153 
154     /** Get the Issue Of Data (IOD).
155      * @return Issue Of Data (IOD)
156      */
157     public int getIODNav() {
158         return iodNav;
159     }
160 
161     /** Get the data source.
162      * @return the data source
163      * @since 12.0
164      */
165     public int getDataSource() {
166         return dataSource;
167     }
168 
169     /** Get the E1/E5a broadcast group delay.
170      * @return the E1/E5a broadcast group delay (s)
171      */
172     public double getBGDE1E5a() {
173         return bgdE1E5a;
174     }
175 
176     /** Get the Broadcast Group Delay E5b/E1.
177      * @return the Broadcast Group Delay E5b/E1 (s)
178      */
179     public double getBGDE5bE1() {
180         return bgdE5bE1;
181     }
182 
183     /** Get the signal in space accuracy (m).
184      * @return the signal in space accuracy
185      */
186     public double getSisa() {
187         return sisa;
188     }
189 
190     /** Get the SV health status.
191      * @return the SV health status
192      */
193     public double getSvHealth() {
194         return svHealth;
195     }
196 
197     /** {@inheritDoc} */
198     @Override
199     public GalileoNavigationMessageFactory baseFactory(final Frame inertial, final Frame bodyFixed) {
200         return new GalileoNavigationMessageFactory(getTimeScales(), getTimeOfEphemeris().getSystem(),
201                                                    getType(), inertial, bodyFixed);
202     }
203 
204 }