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.gnss.metric.messages.rtcm.ephemeris;
18  
19  import org.orekit.annotation.DefaultDataContext;
20  import org.orekit.data.DataContext;
21  import org.orekit.gnss.SatelliteSystem;
22  import org.orekit.propagation.analytical.gnss.GNSSPropagator;
23  import org.orekit.propagation.analytical.gnss.data.GPSLegacyNavigationMessage;
24  import org.orekit.time.GNSSDate;
25  import org.orekit.time.TimeScales;
26  
27  /**
28   * Container for RTCM 1019 data.
29   * @author Bryan Cazabonne
30   * @since 11.0
31   */
32  public class Rtcm1019Data extends RtcmEphemerisData {
33  
34      /** GPS navigation message. */
35      private GPSLegacyNavigationMessage gpsNavigationMessage;
36  
37      /** GPS Time of clock. */
38      private double gpsToc;
39  
40      /** GPS code on L2. */
41      private int gpsCodeOnL2;
42  
43      /** GPS L2 P data flag. */
44      private boolean gpsL2PDataFlag;
45  
46      /** GPS fit interval. */
47      private int gpsFitInterval;
48  
49      /** Constructor. */
50      public Rtcm1019Data() {
51          // Nothing to do ...
52      }
53  
54      /**
55       * Get the GPS navigation message corresponding to the current RTCM data.
56       * <p>
57       * This object can be used to initialize a {@link GNSSPropagator}
58       * <p>
59       * This method uses the {@link DataContext#getDefault()} to initialize
60       * the time scales used to configure the reference epochs of the navigation
61       * message.
62       *
63       * @return the GPS navigation message
64       */
65      @DefaultDataContext
66      public GPSLegacyNavigationMessage getGpsNavigationMessage() {
67          return getGpsNavigationMessage(DataContext.getDefault().getTimeScales());
68      }
69  
70      /**
71       * Get the GPS navigation message corresponding to the current RTCM data.
72       * <p>
73       * This object can be used to initialize a {@link GNSSPropagator}
74       * <p>
75       * When calling this method, the reference epochs of the navigation message
76       * (i.e. ephemeris and clock epochs) are initialized using the provided time scales.
77       *
78       * @param timeScales time scales to use for initializing epochs
79       * @return the GPS navigation message
80       */
81      public GPSLegacyNavigationMessage getGpsNavigationMessage(final TimeScales timeScales) {
82  
83          // Satellite system
84          final SatelliteSystem system = SatelliteSystem.GPS;
85  
86          // Week number and time of ephemeris
87          final int    week = gpsNavigationMessage.getWeek();
88  
89          // Set the ephemeris reference data
90          gpsNavigationMessage.setEpochToc(new GNSSDate(week, gpsToc, system, timeScales).getDate());
91  
92          // Return the navigation message
93          return gpsNavigationMessage;
94  
95      }
96  
97      /**
98       * Set the GPS navigation message.
99       * @param gpsNavigationMessage the GPS navigation message to set
100      */
101     public void setGpsNavigationMessage(final GPSLegacyNavigationMessage gpsNavigationMessage) {
102         this.gpsNavigationMessage = gpsNavigationMessage;
103     }
104 
105     /**
106      * Get the GPS time of clock.
107      * <p>
108      * The GPS time of clock is given in seconds since
109      * the beginning of the GPS week.
110      * </p>
111      * @return the GPS time of clock
112      */
113     public double getGpsToc() {
114         return gpsToc;
115     }
116 
117     /**
118      * Set the GPS time of clock.
119      * @param toc the time of clock to set
120      */
121     public void setGpsToc(final double toc) {
122         this.gpsToc = toc;
123     }
124 
125     /**
126      * Get the GPS code on L2.
127      * <ul>
128      *   <li>0: Reserved</li>
129      *   <li>1: P code on</li>
130      *   <li>2: C/A code on</li>
131      *   <li>3: L2C on</li>
132      * </ul>
133      * @return the GPS code on L2
134      */
135     public int getGpsCodeOnL2() {
136         return gpsCodeOnL2;
137     }
138 
139     /**
140      * Set the GPS code on L2.
141      * @param gpsCodeOnL2 the code to set
142      */
143     public void setGpsCodeOnL2(final int gpsCodeOnL2) {
144         this.gpsCodeOnL2 = gpsCodeOnL2;
145     }
146 
147     /**
148      * Get the GPS L2 P-Code data flag.
149      * @return true L2 P-Code NAV data ON
150      */
151     public boolean getGpsL2PDataFlag() {
152         return gpsL2PDataFlag;
153     }
154 
155     /**
156      * Set the GPS L2 P-code data flag.
157      * @param gpsL2PDataFlag the flag to set
158      */
159     public void setGpsL2PDataFlag(final boolean gpsL2PDataFlag) {
160         this.gpsL2PDataFlag = gpsL2PDataFlag;
161     }
162 
163     /**
164      * Get the GPS fit interval.
165      * @return the GPS fit interval
166      */
167     public int getGpsFitInterval() {
168         return gpsFitInterval;
169     }
170 
171     /**
172      * Set the GPS fit interval.
173      * @param gpsFitInterval the GPS fit interval to set
174      */
175     public void setGpsFitInterval(final int gpsFitInterval) {
176         this.gpsFitInterval = gpsFitInterval;
177     }
178 
179 }