1   /* Copyright 2002-2022 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.BeidouNavigationMessage;
24  import org.orekit.time.GNSSDate;
25  import org.orekit.time.TimeScales;
26  
27  /**
28   * Container for RTCM 1042 data.
29   * @author Bryan Cazabonne
30   * @since 11.0
31   */
32  public class Rtcm1042Data extends RtcmEphemerisData {
33  
34      /** Beidou navigation message. */
35      private BeidouNavigationMessage beidouNavigationMessage;
36  
37      /** Beidou Time of clock. */
38      private double beidouToc;
39  
40      /** Satellite health status. */
41      private double svHealth;
42  
43      /** Constructor. */
44      public Rtcm1042Data() {
45          // Nothing to do ...
46      }
47  
48      /**
49       * Get the Beidou navigation message corresponding to the current RTCM data.
50       * <p>
51       * This object can be used to initialize a {@link GNSSPropagator}
52       * <p>
53       * This method uses the {@link DataContext#getDefault()} to initialize
54       * the time scales used to configure the reference epochs of the navigation
55       * message.
56       *
57       * @return the Beidou navigation message
58       */
59      @DefaultDataContext
60      public BeidouNavigationMessage getBeidouNavigationMessage() {
61          return getBeidouNavigationMessage(DataContext.getDefault().getTimeScales());
62      }
63  
64      /**
65       * Get the Beidou navigation message corresponding to the current RTCM data.
66       * <p>
67       * This object can be used to initialize a {@link GNSSPropagator}
68       * <p>
69       * When calling this method, the reference epochs of the navigation message
70       * (i.e. ephemeris and clock epochs) are initialized using the provided time scales.
71       *
72       * @param timeScales time scales to use for initializing epochs
73       * @return the Beidou navigation message
74       */
75      public BeidouNavigationMessage getBeidouNavigationMessage(final TimeScales timeScales) {
76  
77          // Satellite system
78          final SatelliteSystem system = SatelliteSystem.BEIDOU;
79  
80          // Week number and time of ephemeris
81          final int    week = beidouNavigationMessage.getWeek();
82          final double toe  = beidouNavigationMessage.getTime();
83  
84          // Set the ephemeris reference data
85          beidouNavigationMessage.setDate(new GNSSDate(week, SEC_TO_MILLI * toe, system, timeScales).getDate());
86          beidouNavigationMessage.setEpochToc(new GNSSDate(week, SEC_TO_MILLI * beidouToc, system, timeScales).getDate());
87  
88          // Return the navigation message
89          return beidouNavigationMessage;
90  
91      }
92  
93      /**
94       * Set the Beidou navigation message.
95       * @param beidouNavigationMessage the Beidou navigation message to set
96       */
97      public void setBeidouNavigationMessage(final BeidouNavigationMessage beidouNavigationMessage) {
98          this.beidouNavigationMessage = beidouNavigationMessage;
99      }
100 
101     /**
102      * Get the Beidou time of clock.
103      * <p>
104      * The Beidou time of clock is given in seconds since
105      * the beginning of the Beidou week.
106      * </p>
107      * @return the Beidou time of clock
108      */
109     public double getBeidouToc() {
110         return beidouToc;
111     }
112 
113     /**
114      * Set the Beidou time of clock.
115      * @param toc the time of clock to set
116      */
117     public void setBeidouToc(final double toc) {
118         this.beidouToc = toc;
119     }
120 
121     /**
122      * Get the satellite health status.
123      * @return the satellite health status
124      */
125     public double getSvHealth() {
126         return svHealth;
127     }
128 
129     /**
130      * Set the satellite health status.
131      * @param svHealth the health status to set
132      */
133     public void setSvHealth(final double svHealth) {
134         this.svHealth = svHealth;
135     }
136 
137 }