1   /* Copyright 2002-2024 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.QZSSLegacyNavigationMessage;
24  import org.orekit.time.GNSSDate;
25  import org.orekit.time.TimeScales;
26  
27  /**
28   * Container for RTCM 1044 data.
29   * @author Bryan Cazabonne
30   * @since 11.0
31   */
32  public class Rtcm1044Data extends RtcmEphemerisData {
33  
34      /** QZSS navigation message. */
35      private QZSSLegacyNavigationMessage qzssNavigationMessage;
36  
37      /** QZSS Time of clock. */
38      private double qzssToc;
39  
40      /** QZSS code on L2 Channel. */
41      private int qzssCodeOnL2;
42  
43      /** QZSS fit interval. */
44      private int qzssFitInterval;
45  
46      /** Constructor. */
47      public Rtcm1044Data() {
48          // Nothing to do ...
49      }
50  
51      /**
52       * Get the QZSS navigation message corresponding to the current RTCM data.
53       * <p>
54       * This object can be used to initialize a {@link GNSSPropagator}
55       * <p>
56       * This method uses the {@link DataContext#getDefault()} to initialize
57       * the time scales used to configure the reference epochs of the navigation
58       * message.
59       *
60       * @return the QZSS navigation message
61       */
62      @DefaultDataContext
63      public QZSSLegacyNavigationMessage getQzssNavigationMessage() {
64          return getQzssNavigationMessage(DataContext.getDefault().getTimeScales());
65      }
66  
67      /**
68       * Get the QZSS navigation message corresponding to the current RTCM data.
69       * <p>
70       * This object can be used to initialize a {@link GNSSPropagator}
71       * <p>
72       * When calling this method, the reference epochs of the navigation message
73       * (i.e. ephemeris and clock epochs) are initialized using the provided time scales.
74       *
75       * @param timeScales time scales to use for initializing epochs
76       * @return the QZSS navigation message
77       */
78      public QZSSLegacyNavigationMessage getQzssNavigationMessage(final TimeScales timeScales) {
79  
80          // Satellite system
81          final SatelliteSystem system = SatelliteSystem.QZSS;
82  
83          // Week number and time of ephemeris
84          final int    week = qzssNavigationMessage.getWeek();
85          final double toe  = qzssNavigationMessage.getTime();
86  
87          // Set the ephemeris reference data
88          qzssNavigationMessage.setDate(new GNSSDate(week, toe, system, timeScales).getDate());
89          qzssNavigationMessage.setEpochToc(new GNSSDate(week, qzssToc, system, timeScales).getDate());
90  
91          // Return the navigation message
92          return qzssNavigationMessage;
93  
94      }
95  
96      /**
97       * Set the QZSS navigation message.
98       * @param qzssNavigationMessage the QZSS navigation message to set
99       */
100     public void setQzssNavigationMessage(final QZSSLegacyNavigationMessage qzssNavigationMessage) {
101         this.qzssNavigationMessage = qzssNavigationMessage;
102     }
103 
104     /**
105      * Get the QZSS time of clock.
106      * <p>
107      * The QZSS time of clock is given in seconds since
108      * the beginning of the QZSS week.
109      * </p>
110      * @return the QZSS time of clock
111      */
112     public double getQzssToc() {
113         return qzssToc;
114     }
115 
116     /**
117      * Set the QZSS time of clock.
118      * @param toc the time of clock to set
119      */
120     public void setQzssToc(final double toc) {
121         this.qzssToc = toc;
122     }
123 
124     /**
125      * Get the QZSS code on L2 Channel.
126      * @return the QZSS code on L2
127      */
128     public int getQzssCodeOnL2() {
129         return qzssCodeOnL2;
130     }
131 
132     /**
133      * Set the QZSS code on L2.
134      * @param qzssCodeOnL2 the code to set
135      */
136     public void setQzssCodeOnL2(final int qzssCodeOnL2) {
137         this.qzssCodeOnL2 = qzssCodeOnL2;
138     }
139 
140     /**
141      * Get the QZSS fit interval.
142      * @return the QZSS fit interval
143      */
144     public int getQzssFitInterval() {
145         return qzssFitInterval;
146     }
147 
148     /**
149      * Set the QZSS fit interval.
150      * @param qzssFitInterval the QZSS fit interval to set
151      */
152     public void setQzssFitInterval(final int qzssFitInterval) {
153         this.qzssFitInterval = qzssFitInterval;
154     }
155 
156 }