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.     /** B1/B3 Group Delay Differential (s). */
  34.     private T tgd1;

  35.     /** B2/B3 Group Delay Differential (s). */
  36.     private T tgd2;

  37.     /** The user SV accuracy (m). */
  38.     private T svAccuracy;

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

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

  65.     /** {@inheritDoc} */
  66.     @Override
  67.     public BeidouLegacyNavigationMessage toNonField() {
  68.         return new BeidouLegacyNavigationMessage(this);
  69.     }

  70.     /** {@inheritDoc} */
  71.     @SuppressWarnings("unchecked")
  72.     @Override
  73.     public <U extends CalculusFieldElement<U>, G extends FieldGnssOrbitalElements<U, BeidouLegacyNavigationMessage>>
  74.         G changeField(final Function<T, U> converter) {
  75.         return (G) new FieldBeidouLegacyNavigationMessage<>(converter, this);
  76.     }

  77.     /**
  78.      * Getter for the Age Of Data Clock (AODC).
  79.      * @return the Age Of Data Clock (AODC)
  80.      */
  81.     public int getAODC() {
  82.         return aodc;
  83.     }

  84.     /**
  85.      * Setter for the age of data clock.
  86.      * @param aod the age of data to set
  87.      */
  88.     public void setAODC(final T aod) {
  89.         // The value is given as a floating number in the navigation message
  90.         this.aodc = (int) aod.getReal();
  91.     }

  92.     /**
  93.      * Getter for the Age Of Data Ephemeris (AODE).
  94.      * @return the Age Of Data Ephemeris (AODE)
  95.      */
  96.     public int getAODE() {
  97.         return aode;
  98.     }

  99.     /**
  100.      * Setter for the age of data ephemeris.
  101.      * @param aod the age of data to set
  102.      */
  103.     public void setAODE(final T aod) {
  104.         // The value is given as a floating number in the navigation message
  105.         this.aode = (int) aod.getReal();
  106.     }

  107.     /**
  108.      * Getter for the estimated group delay differential TGD1 for B1I signal.
  109.      * @return the estimated group delay differential TGD1 for B1I signal (s)
  110.      */
  111.     public T getTGD1() {
  112.         return tgd1;
  113.     }

  114.     /**
  115.      * Setter for the B1/B3 Group Delay Differential (s).
  116.      * @param tgd the group delay differential to set
  117.      */
  118.     public void setTGD1(final T tgd) {
  119.         this.tgd1 = tgd;
  120.     }

  121.     /**
  122.      * Getter for the estimated group delay differential TGD for B2I signal.
  123.      * @return the estimated group delay differential TGD2 for B2I signal (s)
  124.      */
  125.     public T getTGD2() {
  126.         return tgd2;
  127.     }

  128.     /**
  129.      * Setter for the B2/B3 Group Delay Differential (s).
  130.      * @param tgd the group delay differential to set
  131.      */
  132.     public void setTGD2(final T tgd) {
  133.         this.tgd2 = tgd;
  134.     }

  135.     /**
  136.      * Getter for the user SV accuray (meters).
  137.      * @return the user SV accuracy
  138.      */
  139.     public T getSvAccuracy() {
  140.         return svAccuracy;
  141.     }

  142.     /**
  143.      * Setter for the user SV accuracy.
  144.      * @param svAccuracy the value to set
  145.      */
  146.     public void setSvAccuracy(final T svAccuracy) {
  147.         this.svAccuracy = svAccuracy;
  148.     }

  149. }