1   /* Copyright 2022-2026 Thales Alenia Space
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.GalileoNavigationMessage;
24  import org.orekit.time.GNSSDate;
25  import org.orekit.time.TimeScales;
26  
27  /**
28   * Container for RTCM 1046 data.
29   * @author Nathan Schiffmacher
30   * @since 14.0
31   */
32  public class Rtcm1046Data extends RtcmEphemerisData {
33  
34      /** Galileo navigation message. */
35      private GalileoNavigationMessage galileoNavigationMessage;
36  
37      /** Galileo Time of clock. */
38      private double galileoToc;
39  
40      /** Constructor. */
41      public Rtcm1046Data() {
42          // Nothing to do ...
43      }
44  
45      /**
46       * Get the Galileo navigation message corresponding to the current RTCM data.
47       * <p>
48       * This object can be used to initialize a {@link GNSSPropagator}
49       * <p>
50       * This method uses the {@link DataContext#getDefault()} to initialize
51       * the time scales used to configure the reference epochs of the navigation
52       * message.
53       *
54       * @return the Galileo navigation message
55       */
56      @DefaultDataContext
57      public GalileoNavigationMessage getGalileoNavigationMessage() {
58          return getGalileoNavigationMessage(DataContext.getDefault().getTimeScales());
59      }
60  
61      /**
62       * Get the Galileo navigation message corresponding to the current RTCM data.
63       * <p>
64       * This object can be used to initialize a {@link GNSSPropagator}
65       * <p>
66       * When calling this method, the reference epochs of the navigation message
67       * (i.e. ephemeris and clock epochs) are initialized using the provided time scales.
68       *
69       * @param timeScales time scales to use for initializing epochs
70       * @return the Galileo navigation message
71       */
72      public GalileoNavigationMessage getGalileoNavigationMessage(final TimeScales timeScales) {
73  
74          // Satellite system
75          final SatelliteSystem system = SatelliteSystem.GALILEO;
76  
77          // Week number and time of ephemeris
78          final int    week = galileoNavigationMessage.getWeek();
79  
80          // Set the ephemeris reference data
81          galileoNavigationMessage.setEpochToc(new GNSSDate(week, galileoToc, system, timeScales).getDate());
82  
83          // Return the navigation message
84          return galileoNavigationMessage;
85  
86      }
87  
88      /**
89       * Set the Galileo navigation message.
90       * @param galileoNavigationMessage the Galileo navigation message to set
91       */
92      public void setGalileoNavigationMessage(final GalileoNavigationMessage galileoNavigationMessage) {
93          this.galileoNavigationMessage = galileoNavigationMessage;
94      }
95  
96      /**
97       * Get the Galileo time of clock.
98       * <p>
99       * The Galileo time of clock is given in seconds since
100      * the beginning of the Galileo week.
101      * </p>
102      * @return the Galileo time of clock
103      */
104     public double getGalileoToc() {
105         return galileoToc;
106     }
107 
108     /**
109      * Set the Galileo time of clock.
110      * @param toc the time of clock to set
111      */
112     public void setGalileoToc(final double toc) {
113         this.galileoToc = toc;
114     }
115 }