FieldBeidouLegacyNavigationMessage.java

  1. /* Copyright 2022-2025 Luc Maisonobe
  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.propagation.analytical.gnss.data;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.Field;

  20. import java.util.function.Function;

  21. /**
  22.  * Container for data contained in a BeiDou navigation message.
  23.  * @param <T> type of the field elements
  24.  * @author Luc Maisonobe
  25.  * @since 13.0
  26.  */
  27. public class FieldBeidouLegacyNavigationMessage<T extends CalculusFieldElement<T>>
  28.     extends FieldAbstractNavigationMessage<T, BeidouLegacyNavigationMessage> {

  29.     /** Age of Data, Ephemeris. */
  30.     private int aode;

  31.     /** Age of Data, Clock. */
  32.     private int aodc;

  33.     /** Health identifier.
  34.      * @since 14.0
  35.      */
  36.     private int satH1;

  37.     /** B1/B3 Group Delay Differential (s). */
  38.     private T tgd1;

  39.     /** B2/B3 Group Delay Differential (s). */
  40.     private T tgd2;

  41.     /** The user SV accuracy (m). */
  42.     private T svAccuracy;

  43.     /** Constructor from non-field instance.
  44.      * @param field    field to which elements belong
  45.      * @param original regular non-field instance
  46.      */
  47.     public FieldBeidouLegacyNavigationMessage(final Field<T> field, final BeidouLegacyNavigationMessage original) {
  48.         super(field, original);
  49.         setAODE(field.getZero().newInstance(original.getAODE()));
  50.         setAODC(field.getZero().newInstance(original.getAODC()));
  51.         setTGD1(field.getZero().newInstance(original.getTGD1()));
  52.         setTGD2(field.getZero().newInstance(original.getTGD2()));
  53.         setSvAccuracy(field.getZero().newInstance(original.getSvAccuracy()));
  54.         setSatH1(original.getSatH1());
  55.     }

  56.     /** Constructor from different field instance.
  57.      * @param <V> type of the old field elements
  58.      * @param original regular non-field instance
  59.      * @param converter for field elements
  60.      */
  61.     public <V extends CalculusFieldElement<V>> FieldBeidouLegacyNavigationMessage(final Function<V, T> converter,
  62.                                                                                   final FieldBeidouLegacyNavigationMessage<V> original) {
  63.         super(converter, original);
  64.         setAODE(getMu().newInstance(original.getAODE()));
  65.         setAODC(getMu().newInstance(original.getAODC()));
  66.         setTGD1(converter.apply(original.getTGD1()));
  67.         setTGD2(converter.apply(original.getTGD2()));
  68.         setSvAccuracy(converter.apply(original.getSvAccuracy()));
  69.         setSatH1(original.getSatH1());
  70.     }

  71.     /** {@inheritDoc} */
  72.     @Override
  73.     public BeidouLegacyNavigationMessage toNonField() {
  74.         return new BeidouLegacyNavigationMessage(this);
  75.     }

  76.     /** {@inheritDoc} */
  77.     @SuppressWarnings("unchecked")
  78.     @Override
  79.     public <U extends CalculusFieldElement<U>, G extends FieldGnssOrbitalElements<U, BeidouLegacyNavigationMessage>>
  80.         G changeField(final Function<T, U> converter) {
  81.         return (G) new FieldBeidouLegacyNavigationMessage<>(converter, this);
  82.     }

  83.     /**
  84.      * Getter for the Age Of Data Clock (AODC).
  85.      * @return the Age Of Data Clock (AODC)
  86.      */
  87.     public int getAODC() {
  88.         return aodc;
  89.     }

  90.     /**
  91.      * Setter for the age of data clock.
  92.      * @param aod the age of data to set
  93.      */
  94.     public void setAODC(final T aod) {
  95.         // The value is given as a floating number in the navigation message
  96.         this.aodc = (int) aod.getReal();
  97.     }

  98.     /**
  99.      * Getter for the Age Of Data Ephemeris (AODE).
  100.      * @return the Age Of Data Ephemeris (AODE)
  101.      */
  102.     public int getAODE() {
  103.         return aode;
  104.     }

  105.     /**
  106.      * Setter for the age of data ephemeris.
  107.      * @param aod the age of data to set
  108.      */
  109.     public void setAODE(final T aod) {
  110.         // The value is given as a floating number in the navigation message
  111.         this.aode = (int) aod.getReal();
  112.     }

  113.     /**
  114.      * Getter for the estimated group delay differential TGD1 for B1I signal.
  115.      * @return the estimated group delay differential TGD1 for B1I signal (s)
  116.      */
  117.     public T getTGD1() {
  118.         return tgd1;
  119.     }

  120.     /**
  121.      * Setter for the B1/B3 Group Delay Differential (s).
  122.      * @param tgd the group delay differential to set
  123.      */
  124.     public void setTGD1(final T tgd) {
  125.         this.tgd1 = tgd;
  126.     }

  127.     /**
  128.      * Getter for the estimated group delay differential TGD for B2I signal.
  129.      * @return the estimated group delay differential TGD2 for B2I signal (s)
  130.      */
  131.     public T getTGD2() {
  132.         return tgd2;
  133.     }

  134.     /**
  135.      * Setter for the B2/B3 Group Delay Differential (s).
  136.      * @param tgd the group delay differential to set
  137.      */
  138.     public void setTGD2(final T tgd) {
  139.         this.tgd2 = tgd;
  140.     }

  141.     /**
  142.      * Getter for the user SV accuray (meters).
  143.      * @return the user SV accuracy
  144.      */
  145.     public T getSvAccuracy() {
  146.         return svAccuracy;
  147.     }

  148.     /**
  149.      * Setter for the user SV accuracy.
  150.      * @param svAccuracy the value to set
  151.      */
  152.     public void setSvAccuracy(final T svAccuracy) {
  153.         this.svAccuracy = svAccuracy;
  154.     }

  155.     /** Get the health identifier.
  156.      * @return health identifier
  157.      * @since 14.0
  158.      */
  159.     public int getSatH1() {
  160.         return satH1;
  161.     }

  162.     /** Set the health identifier.
  163.      * @param satH1 health identifier
  164.      * @since 14.0
  165.      */
  166.     public void setSatH1(final int satH1) {
  167.         this.satH1 = satH1;
  168.     }

  169. }