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.util.FastMath;
21  import org.orekit.gnss.SatelliteSystem;
22  import org.orekit.time.AbsoluteDate;
23  import org.orekit.time.TimeScales;
24  
25  /**
26   * Base class for GNSS navigation messages.
27   * @param <O> type of the orbital elements
28   * @author Bryan Cazabonne
29   * @since 11.0
30   *
31   * @see GPSLegacyNavigationMessage
32   * @see GalileoNavigationMessage
33   * @see BeidouLegacyNavigationMessage
34   * @see QZSSLegacyNavigationMessage
35   * @see NavICLegacyNavigationMessage
36   */
37  public abstract class AbstractNavigationMessage<O extends AbstractNavigationMessage<O>> extends AbstractAlmanac<O> {
38  
39      /** Mean Motion Difference from Computed Value. */
40      private double deltaN0;
41  
42      /** Time of clock epoch. */
43      private AbsoluteDate epochToc;
44  
45      /** Transmission time.
46       * @since 12.0
47       */
48      private double transmissionTime;
49  
50      /**
51       * Constructor.
52       * @param mu Earth's universal gravitational parameter
53       * @param angularVelocity mean angular velocity of the Earth for the GNSS model
54       * @param weeksInCycle number of weeks in the GNSS cycle
55       * @param timeScales      known time scales
56       * @param system          satellite system to consider for interpreting week number
57       *                        (may be different from real system, for example in Rinex nav, weeks
58       *                        are always according to GPS)
59       */
60      protected AbstractNavigationMessage(final double mu, final double angularVelocity, final int weeksInCycle,
61                                          final TimeScales timeScales, final SatelliteSystem system) {
62          super(mu, angularVelocity, weeksInCycle, timeScales, system);
63      }
64  
65      /** Constructor from field instance.
66       * @param <T> type of the field elements
67       * @param <A> type of the orbital elements (non-field version)
68       * @param original regular field instance
69       */
70      protected <T extends CalculusFieldElement<T>,
71                 A extends AbstractNavigationMessage<A>> AbstractNavigationMessage(final FieldAbstractNavigationMessage<T, A> original) {
72          super(original);
73          setDeltaN0(original.getDeltaN0().getReal());
74          setEpochToc(original.getEpochToc().toAbsoluteDate());
75          setTransmissionTime(original.getTransmissionTime().getReal());
76      }
77  
78      /**
79       * Getter for Square Root of Semi-Major Axis (√m).
80       * @return Square Root of Semi-Major Axis (√m)
81       */
82      public double getSqrtA() {
83          return FastMath.sqrt(getSma());
84      }
85  
86      /**
87       * Setter for the Square Root of Semi-Major Axis (√m).
88       * <p>
89       * In addition, this method set the value of the Semi-Major Axis.
90       * </p>
91       * @param sqrtA the Square Root of Semi-Major Axis (√m)
92       */
93      public void setSqrtA(final double sqrtA) {
94          getSmaDriver().setValue(sqrtA * sqrtA);
95      }
96  
97      /** {@inheritDoc} */
98      @Override
99      public double getDeltaN0() {
100         return deltaN0;
101     }
102 
103     /**
104      * Setter for the delta of satellite mean motion.
105      * @param deltaN0 the value to set
106      */
107     public void setDeltaN0(final double deltaN0) {
108         this.deltaN0 = deltaN0;
109     }
110 
111     /**
112      * Getter for the time of clock epoch.
113      * @return the time of clock epoch
114      */
115     public AbsoluteDate getEpochToc() {
116         return epochToc;
117     }
118 
119     /**
120      * Setter for the time of clock epoch.
121      * @param epochToc the epoch to set
122      */
123     public void setEpochToc(final AbsoluteDate epochToc) {
124         this.epochToc = epochToc;
125     }
126 
127     /**
128      * Getter for transmission time.
129      * @return transmission time
130      * @since 12.0
131      */
132     public double getTransmissionTime() {
133         return transmissionTime;
134     }
135 
136     /**
137      * Setter for transmission time.
138      * @param transmissionTime transmission time
139      * @since 12.0
140      */
141     public void setTransmissionTime(final double transmissionTime) {
142         this.transmissionTime = transmissionTime;
143     }
144 
145 }