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  import org.hipparchus.util.FastMath;
22  
23  import java.util.function.Function;
24  
25  /**
26   * Class for Galileo almanac.
27   *
28   * @see "European GNSS (Galileo) Open Service, Signal In Space,
29   *      Interface Control Document, Table 75"
30   *
31   * @param <T> type of the field elements
32   * @author Luc Maisonobe
33   * @since 13.0
34   *
35   */
36  public class FieldGalileoAlmanac<T extends CalculusFieldElement<T>>
37      extends FieldAbstractAlmanac<T, GalileoAlmanac> {
38  
39      /** Nominal inclination (Ref: Galileo ICD - Table 75). */
40      private static final double I0 = FastMath.toRadians(56.0);
41  
42      /** Nominal semi-major axis in meters (Ref: Galileo ICD - Table 75). */
43      private static final double A0 = 29600000;
44  
45      /** Satellite E5a signal health status. */
46      private int healthE5a;
47  
48      /** Satellite E5b signal health status. */
49      private int healthE5b;
50  
51      /** Satellite E1-B/C signal health status. */
52      private int healthE1;
53  
54      /** Almanac Issue Of Data. */
55      private int iod;
56  
57      /** Constructor from non-field instance.
58       * @param field    field to which elements belong
59       * @param original regular non-field instance
60       */
61      public FieldGalileoAlmanac(final Field<T> field, final GalileoAlmanac original) {
62          super(field, original);
63          setHealthE5a(original.getHealthE5a());
64          setHealthE5b(original.getHealthE5b());
65          setHealthE1(original.getHealthE1());
66          setIOD(original.getIOD());
67      }
68  
69      /** Constructor from different field instance.
70       * @param <V> type of the old field elements
71       * @param original regular non-field instance
72       * @param converter for field elements
73       */
74      public <V extends CalculusFieldElement<V>> FieldGalileoAlmanac(final Function<V, T> converter,
75                                                                     final FieldGalileoAlmanac<V> original) {
76          super(converter, original);
77          setHealthE5a(original.getHealthE5a());
78          setHealthE5b(original.getHealthE5b());
79          setHealthE1(original.getHealthE1());
80          setIOD(original.getIOD());
81      }
82  
83      /** {@inheritDoc} */
84      @Override
85      public GalileoAlmanac toNonField() {
86          return new GalileoAlmanac(this);
87      }
88  
89      /** {@inheritDoc} */
90      @SuppressWarnings("unchecked")
91      @Override
92      public <U extends CalculusFieldElement<U>, G extends FieldGnssOrbitalElements<U, GalileoAlmanac>>
93          G changeField(final Function<T, U> converter) {
94          return (G) new FieldGalileoAlmanac<>(converter, this);
95      }
96  
97      /**
98       * Sets the difference between the square root of the semi-major axis
99       * and the square root of the nominal semi-major axis.
100      * <p>
101      * In addition, this method set the value of the Semi-Major Axis.
102      * </p>
103      * @param dsqa the value to set
104      */
105     public void setDeltaSqrtA(final T dsqa) {
106         final T sqrtA = dsqa.add(FastMath.sqrt(A0));
107         setSma(sqrtA.square());
108     }
109 
110     /**
111      * Sets the the correction of orbit reference inclination at reference time.
112      * <p>
113      * In addition, this method set the value of the reference inclination.
114      * </p>
115      * @param dinc correction of orbit reference inclination at reference time in radians
116      */
117     public void setDeltaInc(final T dinc) {
118         setI0(dinc.add(I0));
119     }
120 
121     /**
122      * Gets the Issue of Data (IOD).
123      *
124      * @return the Issue Of Data
125      */
126     public int getIOD() {
127         return iod;
128     }
129 
130     /**
131      * Sets the Issue of Data (IOD).
132      *
133      * @param iodValue the value to set
134      */
135     public void setIOD(final int iodValue) {
136         this.iod = iodValue;
137     }
138 
139     /**
140      * Gets the E1-B/C signal health status.
141      *
142      * @return the E1-B/C signal health status
143      */
144     public int getHealthE1() {
145         return healthE1;
146     }
147 
148     /**
149      * Sets the E1-B/C signal health status.
150      *
151      * @param healthE1 health status to set
152      */
153     public void setHealthE1(final int healthE1) {
154         this.healthE1 = healthE1;
155     }
156 
157     /**
158      * Gets the E5a signal health status.
159      *
160      * @return the E5a signal health status
161      */
162     public int getHealthE5a() {
163         return healthE5a;
164     }
165 
166     /**
167      * Sets the E5a signal health status.
168      *
169      * @param healthE5a health status to set
170      */
171     public void setHealthE5a(final int healthE5a) {
172         this.healthE5a = healthE5a;
173     }
174 
175     /**
176      * Gets the E5b signal health status.
177      *
178      * @return the E5b signal health status
179      */
180     public int getHealthE5b() {
181         return healthE5b;
182     }
183 
184     /**
185      * Sets the E5b signal health status.
186      *
187      * @param healthE5b health status to set
188      */
189     public void setHealthE5b(final int healthE5b) {
190         this.healthE5b = healthE5b;
191     }
192 
193 }