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   * Class for BeiDou almanac.
26   *
27   * @see "BeiDou Navigation Satellite System, Signal In Space, Interface Control Document,
28   *      Version 2.1, Table 5-12"
29   *
30   * @param <T> type of the field elements
31   * @author Luc Maisonobe
32   * @since 13.0
33   *
34   */
35  public class FieldBeidouAlmanac<T extends CalculusFieldElement<T>>
36      extends FieldAbstractAlmanac<T, BeidouAlmanac> {
37  
38      /** Health status. */
39      private int health;
40  
41      /** Constructor from non-field instance.
42       * @param field    field to which elements belong
43       * @param original regular non-field instance
44       */
45      public FieldBeidouAlmanac(final Field<T> field, final BeidouAlmanac original) {
46          super(field, original);
47          setHealth(original.getHealth());
48      }
49  
50      /** Constructor from different field instance.
51       * @param <V> type of the old field elements
52       * @param original regular non-field instance
53       * @param converter for field elements
54       */
55      public <V extends CalculusFieldElement<V>> FieldBeidouAlmanac(final Function<V, T> converter,
56                                                                    final FieldBeidouAlmanac<V> original) {
57          super(converter, original);
58          setHealth(original.getHealth());
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public BeidouAlmanac toNonField() {
64          return new BeidouAlmanac(this);
65      }
66  
67      /** {@inheritDoc} */
68      @SuppressWarnings("unchecked")
69      @Override
70      public <U extends CalculusFieldElement<U>, G extends FieldGnssOrbitalElements<U, BeidouAlmanac>>
71          G changeField(final Function<T, U> converter) {
72          return (G) new FieldBeidouAlmanac<>(converter, this);
73      }
74  
75      /**
76       * Sets the Square Root of Semi-Major Axis (m^1/2).
77       * <p>
78       * In addition, this method set the value of the Semi-Major Axis.
79       * </p>
80       * @param sqrtA the Square Root of Semi-Major Axis (m^1/2)
81       */
82      public void setSqrtA(final T sqrtA) {
83          setSma(sqrtA.square());
84      }
85  
86      /**
87       * Sets the Inclination Angle at Reference Time (rad).
88       *
89       * @param inc the orbit reference inclination
90       * @param dinc the correction of orbit reference inclination at reference time
91       */
92      public void setI0(final T inc, final T dinc) {
93          setI0(inc.add(dinc));
94      }
95  
96      /**
97       * Gets the Health status.
98       *
99       * @return the Health status
100      */
101     public int getHealth() {
102         return health;
103     }
104 
105     /**
106      * Sets the health status.
107      *
108      * @param health the health status to set
109      */
110     public void setHealth(final int health) {
111         this.health = health;
112     }
113 
114 }