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   * Container for data contained in a GPS/QZNSS legacy navigation message.
26   * @param <T> type of the field elements
27   * @param <O> type of the orbital elements (non-field version)
28   * @author Luc Maisonobe
29   * @since 13.0
30   */
31  public abstract class FieldLegacyNavigationMessage<T extends CalculusFieldElement<T>,
32                                                     O extends LegacyNavigationMessage<O>>
33      extends FieldAbstractNavigationMessage<T, O>
34      implements FieldGNSSClockElements<T> {
35  
36      /** Issue of Data, Ephemeris. */
37      private int iode;
38  
39      /** Issue of Data, Clock. */
40      private int iodc;
41  
42      /** The user SV accuracy (m). */
43      private T svAccuracy;
44  
45      /** Satellite health status. */
46      private int svHealth;
47  
48      /** Fit interval. */
49      private int fitInterval;
50  
51      /** Constructor from non-field instance.
52       * @param field    field to which elements belong
53       * @param original regular non-field instance
54       */
55      protected FieldLegacyNavigationMessage(final Field<T> field, final O original) {
56          super(field, original);
57          setIODE(field.getZero().newInstance(original.getIODE()));
58          setIODC(original.getIODC());
59          setSvAccuracy(field.getZero().newInstance(original.getSvAccuracy()));
60          setSvHealth(original.getSvHealth());
61          setFitInterval(original.getFitInterval());
62      }
63  
64      /** Constructor from different field instance.
65       * @param <V> type of the old field elements
66       * @param original regular non-field instance
67       * @param converter for field elements
68       */
69      protected <V extends CalculusFieldElement<V>> FieldLegacyNavigationMessage(final Function<V, T> converter,
70                                                                                 final FieldLegacyNavigationMessage<V, O> original) {
71          super(converter, original);
72          setIODE(getMu().newInstance(original.getIODE()));
73          setIODC(original.getIODC());
74          setSvAccuracy(converter.apply(original.getSvAccuracy()));
75          setSvHealth(original.getSvHealth());
76          setFitInterval(original.getFitInterval());
77      }
78  
79      /**
80       * Getter for the Issue Of Data Ephemeris (IODE).
81       * @return the Issue Of Data Ephemeris (IODE)
82       */
83      public int getIODE() {
84          return iode;
85      }
86  
87      /**
88       * Setter for the Issue of Data Ephemeris.
89       * @param value the IODE to set
90       */
91      public void setIODE(final T value) {
92          // The value is given as a floating number in the navigation message
93          this.iode = (int) value.getReal();
94      }
95  
96      /**
97       * Getter for the Issue Of Data Clock (IODC).
98       * @return the Issue Of Data Clock (IODC)
99       */
100     public int getIODC() {
101         return iodc;
102     }
103 
104     /**
105      * Setter for the Issue of Data Clock.
106      * @param value the IODC to set
107      */
108     public void setIODC(final int value) {
109         this.iodc = value;
110     }
111 
112     /**
113      * Getter for the user SV accuray (meters).
114      * @return the user SV accuracy
115      */
116     public T getSvAccuracy() {
117         return svAccuracy;
118     }
119 
120     /**
121      * Setter for the user SV accuracy.
122      * @param svAccuracy the value to set
123      */
124     public void setSvAccuracy(final T svAccuracy) {
125         this.svAccuracy = svAccuracy;
126     }
127 
128     /**
129      * Getter for the satellite health status.
130      * @return the satellite health status
131      */
132     public int getSvHealth() {
133         return svHealth;
134     }
135 
136     /**
137      * Setter for the satellite health status.
138      * @param svHealth the value to set
139      */
140     public void setSvHealth(final int svHealth) {
141         this.svHealth = svHealth;
142     }
143 
144     /**
145      * Getter for the fit interval.
146      * @return the fit interval
147      */
148     public int getFitInterval() {
149         return fitInterval;
150     }
151 
152     /**
153      * Setter for the fit interval.
154      * @param fitInterval fit interval
155      */
156     public void setFitInterval(final int fitInterval) {
157         this.fitInterval = fitInterval;
158     }
159 
160 }