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.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      /** Codes on L2 channel.
52       * @since 14.0
53       */
54      private int l2Codes;
55  
56      /** L2 P data flags.
57       * @since 14.0
58       */
59      private int l2PFlags;
60  
61      /** Constructor from non-field instance.
62       * @param field    field to which elements belong
63       * @param original regular non-field instance
64       */
65      protected FieldLegacyNavigationMessage(final Field<T> field, final O original) {
66          super(field, original);
67          setIODE(field.getZero().newInstance(original.getIODE()));
68          setIODC(original.getIODC());
69          setSvAccuracy(field.getZero().newInstance(original.getSvAccuracy()));
70          setSvHealth(original.getSvHealth());
71          setFitInterval(original.getFitInterval());
72          setL2Codes(original.getL2Codes());
73          setL2PFlags(original.getL2PFlags());
74      }
75  
76      /** Constructor from different field instance.
77       * @param <V> type of the old field elements
78       * @param original regular non-field instance
79       * @param converter for field elements
80       */
81      protected <V extends CalculusFieldElement<V>> FieldLegacyNavigationMessage(final Function<V, T> converter,
82                                                                                 final FieldLegacyNavigationMessage<V, O> original) {
83          super(converter, original);
84          setIODE(getMu().newInstance(original.getIODE()));
85          setIODC(original.getIODC());
86          setSvAccuracy(converter.apply(original.getSvAccuracy()));
87          setSvHealth(original.getSvHealth());
88          setFitInterval(original.getFitInterval());
89          setL2Codes(original.getL2Codes());
90          setL2PFlags(original.getL2PFlags());
91      }
92  
93      /**
94       * Getter for the Issue Of Data Ephemeris (IODE).
95       * @return the Issue Of Data Ephemeris (IODE)
96       */
97      public int getIODE() {
98          return iode;
99      }
100 
101     /**
102      * Setter for the Issue of Data Ephemeris.
103      * @param value the IODE to set
104      */
105     public void setIODE(final T value) {
106         // The value is given as a floating number in the navigation message
107         this.iode = (int) value.getReal();
108     }
109 
110     /**
111      * Getter for the Issue Of Data Clock (IODC).
112      * @return the Issue Of Data Clock (IODC)
113      */
114     public int getIODC() {
115         return iodc;
116     }
117 
118     /**
119      * Setter for the Issue of Data Clock.
120      * @param value the IODC to set
121      */
122     public void setIODC(final int value) {
123         this.iodc = value;
124     }
125 
126     /**
127      * Getter for the user SV accuray (meters).
128      * @return the user SV accuracy
129      */
130     public T getSvAccuracy() {
131         return svAccuracy;
132     }
133 
134     /**
135      * Setter for the user SV accuracy.
136      * @param svAccuracy the value to set
137      */
138     public void setSvAccuracy(final T svAccuracy) {
139         this.svAccuracy = svAccuracy;
140     }
141 
142     /**
143      * Getter for the satellite health status.
144      * @return the satellite health status
145      */
146     public int getSvHealth() {
147         return svHealth;
148     }
149 
150     /**
151      * Setter for the satellite health status.
152      * @param svHealth the value to set
153      */
154     public void setSvHealth(final int svHealth) {
155         this.svHealth = svHealth;
156     }
157 
158     /**
159      * Getter for the fit interval.
160      * @return the fit interval
161      */
162     public int getFitInterval() {
163         return fitInterval;
164     }
165 
166     /**
167      * Setter for the fit interval.
168      * @param fitInterval fit interval
169      */
170     public void setFitInterval(final int fitInterval) {
171         this.fitInterval = fitInterval;
172     }
173 
174     /** Get the codes on L2 channel.
175      * @return codes on L2 channel
176      * @since 14.0
177      */
178     public int getL2Codes() {
179         return l2Codes;
180     }
181 
182     /** Set the codes on L2 channel.
183      * @param l2Codes codes on L2 channel
184      * @since 14.0
185      */
186     public void setL2Codes(final int l2Codes) {
187         this.l2Codes = l2Codes;
188     }
189 
190     /** Get the L2 P data flags.
191      * @return L2 P data flags
192      * @since 14.0
193      */
194     public int getL2PFlags() {
195         return l2PFlags;
196     }
197 
198     /** Set the L2 P data flags.
199      * @param l2PFlags L2 P data flags
200      * @since 14.0
201      */
202     public void setL2PFlags(final int l2PFlags) {
203         this.l2PFlags = l2PFlags;
204     }
205 
206 }