1   /* Copyright 2002-2025 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.hipparchus.Field;
21  import org.orekit.gnss.SatelliteSystem;
22  import org.orekit.time.TimeScales;
23  
24  /**
25   * Container for data contained in a BeiDou navigation message.
26   * @author Bryan Cazabonne
27   * @since 11.0
28   */
29  public class BeidouLegacyNavigationMessage extends AbstractNavigationMessage<BeidouLegacyNavigationMessage> {
30  
31      /** Identifier for message type. */
32      public static final String D1 = "D1";
33  
34      /** Identifier for message type. */
35      public static final String D2 = "D2";
36  
37      /** Age of Data, Ephemeris. */
38      private int aode;
39  
40      /** Age of Data, Clock. */
41      private int aodc;
42  
43      /** B1/B3 Group Delay Differential (s). */
44      private double tgd1;
45  
46      /** B2/B3 Group Delay Differential (s). */
47      private double tgd2;
48  
49      /** The user SV accuracy (m). */
50      private double svAccuracy;
51  
52      /** Constructor.
53       * @param timeScales known time scales
54       * @param system     satellite system to consider for interpreting week number
55       *                   (may be different from real system, for example in Rinex nav, weeks
56       *                   are always according to GPS)
57       */
58      public BeidouLegacyNavigationMessage(final TimeScales timeScales,
59                                           final SatelliteSystem system) {
60          super(GNSSConstants.BEIDOU_MU, GNSSConstants.BEIDOU_AV, GNSSConstants.BEIDOU_WEEK_NB,
61                timeScales, system);
62      }
63  
64      /** Constructor from field instance.
65       * @param <T> type of the field elements
66       * @param original regular field instance
67       */
68      public <T extends CalculusFieldElement<T>> BeidouLegacyNavigationMessage(final FieldBeidouLegacyNavigationMessage<T> original) {
69          super(original);
70          setAODE(original.getAODE());
71          setAODC(original.getAODC());
72          setTGD1(original.getTGD1().getReal());
73          setTGD2(original.getTGD2().getReal());
74          setSvAccuracy(original.getSvAccuracy().getReal());
75      }
76  
77      /** {@inheritDoc} */
78      @SuppressWarnings("unchecked")
79      @Override
80      public <T extends CalculusFieldElement<T>, F extends FieldGnssOrbitalElements<T, BeidouLegacyNavigationMessage>>
81          F toField(final Field<T> field) {
82          return (F) new FieldBeidouLegacyNavigationMessage<>(field, this);
83      }
84  
85      /**
86       * Getter for the Age Of Data Clock (AODC).
87       * @return the Age Of Data Clock (AODC)
88       */
89      public int getAODC() {
90          return aodc;
91      }
92  
93      /**
94       * Setter for the age of data clock.
95       * @param aod the age of data to set
96       */
97      public void setAODC(final double aod) {
98          // The value is given as a floating number in the navigation message
99          this.aodc = (int) aod;
100     }
101 
102     /**
103      * Getter for the Age Of Data Ephemeris (AODE).
104      * @return the Age Of Data Ephemeris (AODE)
105      */
106     public int getAODE() {
107         return aode;
108     }
109 
110     /**
111      * Setter for the age of data ephemeris.
112      * @param aod the age of data to set
113      */
114     public void setAODE(final double aod) {
115         // The value is given as a floating number in the navigation message
116         this.aode = (int) aod;
117     }
118 
119     /**
120      * Getter for the estimated group delay differential TGD1 for B1I signal.
121      * @return the estimated group delay differential TGD1 for B1I signal (s)
122      */
123     public double getTGD1() {
124         return tgd1;
125     }
126 
127     /**
128      * Setter for the B1/B3 Group Delay Differential (s).
129      * @param tgd the group delay differential to set
130      */
131     public void setTGD1(final double tgd) {
132         this.tgd1 = tgd;
133     }
134 
135     /**
136      * Getter for the estimated group delay differential TGD for B2I signal.
137      * @return the estimated group delay differential TGD2 for B2I signal (s)
138      */
139     public double getTGD2() {
140         return tgd2;
141     }
142 
143     /**
144      * Setter for the B2/B3 Group Delay Differential (s).
145      * @param tgd the group delay differential to set
146      */
147     public void setTGD2(final double tgd) {
148         this.tgd2 = tgd;
149     }
150 
151     /**
152      * Getter for the user SV accuray (meters).
153      * @return the user SV accuracy
154      */
155     public double getSvAccuracy() {
156         return svAccuracy;
157     }
158 
159     /**
160      * Setter for the user SV accuracy.
161      * @param svAccuracy the value to set
162      */
163     public void setSvAccuracy(final double svAccuracy) {
164         this.svAccuracy = svAccuracy;
165     }
166 
167 }