SubFrame5B.java

  1. /* Copyright 2022-2025 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.rflink.gps;

  18. import org.hipparchus.util.MathUtils;

  19. /**
  20.  * Container for sub-frames 5, page 25.
  21.  * <p>
  22.  * Table 20-1, sheet 5 and table 40-1, sheet 5 in
  23.  * <a href="https://navcen.uscg.gov/sites/default/files/pdf/gps/IS-GPS-200N.pdf">NAVSTAR
  24.  * GPS Space Segment/Navigation User Segment Interface</a>, IS-GPS-200N, 22 Aug 2022
  25.  * </p>
  26.  * @author Luc Maisonobe
  27.  * @since 12.0
  28.  */
  29. public class SubFrame5B extends SubFrame45 {

  30.     /** Number of SV health words. */
  31.     private static final int SVH_WORDS = 6;

  32.     /** Size of SV health fields per word. */
  33.     private static final int SVH_FIELDS = 4;

  34.     /** Index of TOA field. */
  35.     private static final int TOA = 9;

  36.     /** Index of Week Number field. */
  37.     private static final int WEEK_NUMBER = 10;

  38.     /** Index of reserved field A in word 10. */
  39.     private static final int RESERVED_A_10 = WEEK_NUMBER + SVH_WORDS * SVH_FIELDS + 1;

  40.     /** Index of reserved field B in word 10. */
  41.     private static final int RESERVED_B_10 = RESERVED_A_10 + 1;

  42.     /** Simple constructor.
  43.      * @param words raw words
  44.      */
  45.     SubFrame5B(final int[] words) {

  46.         // create raw container
  47.         super(words, RESERVED_B_10 + 1);

  48.         // populate container
  49.         setField(TOA,              3, 14,  8, words);
  50.         setField(WEEK_NUMBER,      3,  6,  8, words);
  51.         int fieldIndex = WEEK_NUMBER + 1;
  52.         for (int i = 0; i < SVH_WORDS; ++i) {
  53.             for (int j = 0; j < SVH_FIELDS; ++j) {
  54.                 setField(fieldIndex++, 4 + i, 18 - 6 * j, 6, words);
  55.             }
  56.         }
  57.         setField(RESERVED_A_10, 10, 24,  6, words);
  58.         setField(RESERVED_B_10, 10,  8, 16, words);

  59.     }

  60.     /** Get Time of Almanac.
  61.      * @return time of almanac (seconds)
  62.      */
  63.     public int getTOA() {
  64.         return getField(TOA) << 12;
  65.     }

  66.     /** Get the almanac week number.
  67.      * @return almanac week number
  68.      */
  69.     public int getWeekNumber() {
  70.         return getField(WEEK_NUMBER);
  71.     }

  72.     /** Get the SV Health for a satellite.
  73.      * @param index in the sub-frame (from 1 to 24, beware it is not the satellite number,
  74.      * it is also related to {@link #getDataId()})
  75.      * @return SV health
  76.      */
  77.     public int getSvHealth(final int index) {
  78.         MathUtils.checkRangeInclusive(index, 1, 24);
  79.         return getField(WEEK_NUMBER + index);
  80.     }

  81.     /** Get the reserved field A in word 10.
  82.      * @return reserved field A in word 10
  83.      */
  84.     public int getReservedA10() {
  85.         return getField(RESERVED_A_10);
  86.     }

  87.     /** Get the reserved field B in word 10.
  88.      * @return reserved field B in word 10
  89.      */
  90.     public int getReservedB10() {
  91.         return getField(RESERVED_B_10);
  92.     }

  93. }