SubFrame1.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. /**
  20.  * Container for sub-frames 1.
  21.  * <p>
  22.  * Table 20-1, sheet 1 and table 40-1, sheet 1 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 SubFrame1 extends SubFrame {

  30.     /** Index of Week Number field. */
  31.     private static final int WEEK_NUMBER = 7;

  32.     /** Index of C/A or P code field. */
  33.     private static final int CA_OR_P = 8;

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

  36.     /** Index of SV Health field. */
  37.     private static final int SV_HEALTH = 10;

  38.     /** Index of IODC field. */
  39.     private static final int IODC  = 11;

  40.     /** Index of L2 P data flag field. */
  41.     private static final int L2_P_DATA = 12;

  42.     /** Index of reserved field in word 4. */
  43.     private static final int RESERVED_4 = 13;

  44.     /** Index of reserved field in word 5. */
  45.     private static final int RESERVED_5 = 14;

  46.     /** Index of reserved field in word 6. */
  47.     private static final int RESERVED_6 = 15;

  48.     /** Index of reserved field in word 7. */
  49.     private static final int RESERVED_7 = 16;

  50.     /** Index of TGD field. */
  51.     private static final int TGD = 17;

  52.     /** Index of TOC field. */
  53.     private static final int TOC  = 18;

  54.     /** Index of AF2 field. */
  55.     private static final int AF2  = 19;

  56.     /** Index of AF1 field. */
  57.     private static final int AF1  = 20;

  58.     /** Index of AF0 field. */
  59.     private static final int AF0  = 21;

  60.     /** */
  61.     /** Simple constructor.
  62.      * @param words raw words
  63.      */
  64.     SubFrame1(final int[] words) {

  65.         // create raw container
  66.         super(words, AF0 + 1);

  67.         // populate container
  68.         setField(WEEK_NUMBER,  3, 20, 10, words);
  69.         setField(CA_OR_P,      3, 18,  2, words);
  70.         setField(URA_INDEX,          3, 14,  4, words);
  71.         setField(SV_HEALTH,    3,  8,  6, words);
  72.         setField(IODC,         3,  6,  2, 8, 22, 8, words);
  73.         setField(L2_P_DATA,    4, 29,  1, words);
  74.         setField(RESERVED_4,   4,  6, 23, words);
  75.         setField(RESERVED_5,   5,  6, 24, words);
  76.         setField(RESERVED_6,   6,  6, 24, words);
  77.         setField(RESERVED_7,   7, 14, 16, words);
  78.         setField(TGD,          7,  6,  8, words);
  79.         setField(TOC,          8,  6, 16, words);
  80.         setField(AF2,          9, 22,  8, words);
  81.         setField(AF1,          9,  6, 16, words);
  82.         setField(AF0,         10,  8, 22, words);

  83.     }

  84.     /** Get Week Number.
  85.      * @return week number
  86.      */
  87.     public int getWeekNumber() {
  88.         return getField(WEEK_NUMBER);
  89.     }

  90.     /** Get C/A or P flag.
  91.      * @return C/A or P flag
  92.      */
  93.     public int getCaOrPFlag() {
  94.         return getField(CA_OR_P);
  95.     }

  96.     /** Get URA index.
  97.      * @return URA index
  98.      */
  99.     public int getUraIndex() {
  100.         return getField(URA_INDEX);
  101.     }

  102.     /** Get SV health.
  103.      * @return SV health
  104.      */
  105.     public int getSvHealth() {
  106.         return getField(SV_HEALTH);
  107.     }

  108.     /** Get IODC.
  109.      * @return IODC
  110.      */
  111.     public int getIODC() {
  112.         return getField(IODC);
  113.     }

  114.     /** Get L2 P data flag.
  115.      * @return L2 P data flag
  116.      */
  117.     public int getL2PDataFlag() {
  118.         return getField(L2_P_DATA);
  119.     }

  120.     /** Get the reserved field in word 4.
  121.      * @return reserved field in word 4
  122.      */
  123.     public int getReserved04() {
  124.         return getField(RESERVED_4);
  125.     }

  126.     /** Get the reserved field in word 5.
  127.      * @return reserved field in word 5
  128.      */
  129.     public int getReserved05() {
  130.         return getField(RESERVED_5);
  131.     }

  132.     /** Get the reserved field in word 6.
  133.      * @return reserved field in word 6
  134.      */
  135.     public int getReserved06() {
  136.         return getField(RESERVED_6);
  137.     }

  138.     /** Get the reserved field in word 7.
  139.      * @return reserved field in word 7
  140.      */
  141.     public int getReserved07() {
  142.         return getField(RESERVED_7);
  143.     }

  144.     /** Get the TGD.
  145.      * @return TGD
  146.      */
  147.     public int getTGD() {
  148.         return getField(TGD);
  149.     }

  150.     /** Get the TOC.
  151.      * @return TOC
  152.      */
  153.     public int getTOC() {
  154.         return getField(TOC);
  155.     }

  156.     /** Get af₂.
  157.      * @return af₂ (second/second²)
  158.      */
  159.     public double getAF2() {
  160.         return FastMath.scalb((double) getField(AF2), -55);
  161.     }

  162.     /** Get af₁.
  163.      * @return af₁ (second/second)
  164.      */
  165.     public double getAF1() {
  166.         return FastMath.scalb((double) getField(AF1), -43);
  167.     }

  168.     /** Get af₀.
  169.      * @return af₀
  170.      */
  171.     public double getAF0() {
  172.         return FastMath.scalb((double) getField(AF0), -31);
  173.     }

  174. }