SubFrame2.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.FastMath;
  19. import org.orekit.gnss.metric.parser.Units;

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

  31.     /** Index of IODE field. */
  32.     private static final int IODE = 7;

  33.     /** Index of Crs field. */
  34.     private static final int CRS = 8;

  35.     /** Index of Δn field. */
  36.     private static final int DELTA_N = 9;

  37.     /** Index of MO field. */
  38.     private static final int M0 = 10;

  39.     /** Index of Cuc field. */
  40.     private static final int CUC = 11;

  41.     /** Index of e field. */
  42.     private static final int E = 12;

  43.     /** Index of Cus field. */
  44.     private static final int CUS = 13;

  45.     /** Index of √a field. */
  46.     private static final int SQRT_A = 14;

  47.     /** Index of TOE field. */
  48.     private static final int TOE = 15;

  49.     /** Index of it interval field. */
  50.     private static final int FIT_INTERVAL = 16;

  51.     /** Index of AODO field. */
  52.     private static final int AODO = 17;

  53.     /** Simple constructor.
  54.      * @param words raw words
  55.      */
  56.     SubFrame2(final int[] words) {

  57.         // create raw container
  58.         super(words, AODO + 1);

  59.         // populate container
  60.         setField(IODE,          3, 22,  8, words);
  61.         setField(CRS,           3,  6, 16, words);
  62.         setField(DELTA_N,       4, 14, 16, words);
  63.         setField(M0,            4,  6,  8, 5,  6, 24, words);
  64.         setField(CUC,           6, 14, 16, words);
  65.         setField(E,             6,  6,  8, 7,  6, 24, words);
  66.         setField(CUS,           8, 14, 16, words);
  67.         setField(SQRT_A,        8,  6,  8, 9,  6, 24, words);
  68.         setField(TOE,          10, 14, 16, words);
  69.         setField(FIT_INTERVAL, 10, 13,  1, words);
  70.         setField(AODO,         10,  8,  5, words);

  71.     }

  72.     /** Get Issue Of Data (ephemeris).
  73.      * @return Issue Of Data (ephemeris)
  74.      */
  75.     public int getIODE() {
  76.         return getField(IODE);
  77.     }

  78.     /** Get Crs.
  79.      * @return crs (m)
  80.      */
  81.     public double getCrs() {
  82.         return FastMath.scalb((double) getField(CRS), -5);
  83.     }

  84.     /** Get Δn.
  85.      * @return Δn (rad/s)
  86.      */
  87.     public double getDeltaN() {
  88.         return Units.SEMI_CIRCLE.toSI(FastMath.scalb((double) getField(DELTA_N), -43));
  89.     }

  90.     /** Get M₀.
  91.      * @return M₀ (rad)
  92.      */
  93.     public double getM0() {
  94.         return Units.SEMI_CIRCLE.toSI(FastMath.scalb((double) getField(M0), -31));
  95.     }

  96.     /** Get Cuc.
  97.      * @return Cuc (rad)
  98.      */
  99.     public double getCuc() {
  100.         return Units.SEMI_CIRCLE.toSI(FastMath.scalb((double) getField(CUC), -29));
  101.     }

  102.     /** Get e.
  103.      * @return e
  104.      */
  105.     public double getE() {
  106.         return FastMath.scalb((double) getField(E), -33);
  107.     }

  108.     /** Get Cus.
  109.      * @return Cus (rad)
  110.      */
  111.     public double getCus() {
  112.         return Units.SEMI_CIRCLE.toSI(FastMath.scalb((double) getField(CUS), -29));
  113.     }

  114.     /** Get √a.
  115.      * @return d√a (√m)
  116.      */
  117.     public double getSqrtA() {
  118.         return FastMath.scalb((double) getField(SQRT_A), -19);
  119.     }

  120.     /** Get Time Of Ephemeris.
  121.      * @return Time Of Ephemeris
  122.      */
  123.     public int getToe() {
  124.         return getField(TOE) << 4;
  125.     }

  126.     /** Get fit interval.
  127.      * @return fit interval
  128.      */
  129.     public int getFitInterval() {
  130.         return getField(FIT_INTERVAL);
  131.     }

  132.     /** Get Age Of data Offset.
  133.      * @return Age Of Data Offset (s)
  134.      */
  135.     public int getAODO() {
  136.         return getField(AODO) * 900;
  137.     }

  138. }