AttitudeEntryKey.java

  1. /* Copyright 2002-2025 CS GROUP
  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.files.ccsds.ndm.adm.aem;

  18. import org.orekit.files.ccsds.definitions.Units;
  19. import org.orekit.files.ccsds.ndm.adm.AttitudeType;
  20. import org.orekit.files.ccsds.utils.ContextBinding;
  21. import org.orekit.files.ccsds.utils.lexical.ParseToken;
  22. import org.orekit.utils.units.Unit;


  23. /** Keys for {@link AttitudeEntry attitude entries} in XML messages.
  24.  * @author Luc Maisonobe
  25.  * @since 11.0
  26.  */
  27. public enum AttitudeEntryKey {

  28.     /** Quaternion state sub-section (only for ADM V1). */
  29.     quaternionState((token, context, container) -> true),

  30.     /** Quaternion state sub-section.
  31.      * @since 12.0
  32.      */
  33.     quaternionEphemeris((token, context, container) -> true),

  34.     /** Quaternion/derivative sub-section. */
  35.     quaternionDerivative((token, context, container) -> true),

  36.     /** Quaternion/rate sub-section (only for ADM V1). */
  37.     quaternionEulerRate((token, context, container) -> true),

  38.     /** Quaternion/angular velocity sub-section.
  39.      * @since 12.0
  40.      */
  41.     quaternionAngVel((token, context, container) -> true),

  42.     /** Euler angle sub-section. */
  43.     eulerAngle((token, context, container) -> true),

  44.     /** Euler angle/rate sub-section (only for ADM V1). */
  45.     eulerAngleRate((token, context, container) -> true),

  46.     /** Euler angle/derivative sub-section.
  47.      * @since 12.0
  48.      */
  49.     eulerAngleDerivative((token, context, container) -> true),

  50.     /** Euler angle/angular velocity sub-section.
  51.      * @since 12.0
  52.      */
  53.     eulerAngleAngVel((token, context, container) -> true),

  54.     /** Spin sub-section. */
  55.     spin((token, context, container) -> true),

  56.     /** Spin/nutation sub-section. */
  57.     spinNutation((token, context, container) -> true),

  58.     /** Spin/nutation/momentum sub-section.
  59.      * @since 12.0
  60.      */
  61.     spinNutationMom((token, context, container) -> true),

  62.     /** Quaternion sub-sub-section. */
  63.     quaternion((token, context, container) -> true),

  64.     /** Quaternion rate sub-sub-section(only for ADM V1). */
  65.     quaternionRate((token, context, container) -> true),

  66.     /** Quaternion rate sub-sub-section.
  67.      * @since 12.0
  68.      */
  69.     quaternionDot((token, context, container) -> true),

  70.     /** Rotation angles sub-sub-section (only for ADM V1). */
  71.     rotationAngles((token, context, container) -> true),

  72.     /** Rotation rates sub-sub-section (only for ADM V1). */
  73.     rotationRates((token, context, container) -> true),

  74.     /** Angular velocity sub-sub-section.
  75.      * @since 12.0
  76.      */
  77.     angVel((token, context, container) -> true),

  78.     /** Entry epoch. */
  79.     EPOCH((token, context, container) -> token.processAsDate(container::setEpoch, context)),

  80.     /** Quaternion first vectorial component. */
  81.     Q1((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().isFirst() ? 1 : 0,
  82.                                                                    Unit.ONE, context.getParsedUnitsBehavior(),
  83.                                                                    container::setComponent)),

  84.     /** Quaternion second vectorial component. */
  85.     Q2((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().isFirst() ? 2 : 1,
  86.                                                                    Unit.ONE, context.getParsedUnitsBehavior(),
  87.                                                                    container::setComponent)),

  88.     /** Quaternion third vectorial component. */
  89.     Q3((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().isFirst() ? 3 : 2,
  90.                                                                    Unit.ONE, context.getParsedUnitsBehavior(),
  91.                                                                    container::setComponent)),

  92.     /** Quaternion scalar component. */
  93.     QC((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().isFirst() ? 0 : 3,
  94.                                                                    Unit.ONE, context.getParsedUnitsBehavior(),
  95.                                                                    container::setComponent)),

  96.     /** Quaternion first vectorial component. */
  97.     Q1_DOT((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().isFirst() ? 5 : 4,
  98.                                                                        Units.ONE_PER_S, context.getParsedUnitsBehavior(),
  99.                                                                        container::setComponent)),

  100.     /** Quaternion second vectorial component. */
  101.     Q2_DOT((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().isFirst() ? 6 : 5,
  102.                                                                        Units.ONE_PER_S, context.getParsedUnitsBehavior(),
  103.                                                                        container::setComponent)),

  104.     /** Quaternion third vectorial component. */
  105.     Q3_DOT((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().isFirst() ? 7 : 6,
  106.                                                                        Units.ONE_PER_S, context.getParsedUnitsBehavior(),
  107.                                                                        container::setComponent)),

  108.     /** Quaternion scalar component. */
  109.     QC_DOT((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().isFirst() ? 4 : 7,
  110.                                                                        Units.ONE_PER_S, context.getParsedUnitsBehavior(),
  111.                                                                        container::setComponent)),

  112.     /** Angular velocity about X axis.
  113.      * @since 12.0
  114.      */
  115.     ANGVEL_X((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().getAttitudeType() == AttitudeType.QUATERNION_ANGVEL ? 4 : 3,
  116.                                                                          Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  117.                                                                          container::setComponent)),

  118.     /** Angular velocity about Y axis.
  119.      * @since 12.0
  120.      */
  121.     ANGVEL_Y((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().getAttitudeType() == AttitudeType.QUATERNION_ANGVEL ? 5 : 4,
  122.                                                                          Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  123.                                                                          container::setComponent)),

  124.     /** Angular velocity about Z axis.
  125.      * @since 12.0
  126.      */
  127.     ANGVEL_Z((token, context, container) -> token.processAsIndexedDouble(container.getMetadata().getAttitudeType() == AttitudeType.QUATERNION_ANGVEL ? 6 : 5,
  128.                                                                          Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  129.                                                                          container::setComponent)),

  130.     /** Rotation about first axis.
  131.      * @since 12.0
  132.      */
  133.     ANGLE_1((token, context, container) -> token.processAsIndexedDouble(0,
  134.                                                                         Unit.DEGREE, context.getParsedUnitsBehavior(),
  135.                                                                         container::setComponent)),

  136.     /** Rotation about second axis.
  137.      * @since 12.0
  138.      */
  139.     ANGLE_2((token, context, container) -> token.processAsIndexedDouble(1,
  140.                                                                         Unit.DEGREE, context.getParsedUnitsBehavior(),
  141.                                                                         container::setComponent)),

  142.     /** Rotation about third axis.
  143.      * @since 12.0
  144.      */
  145.     ANGLE_3((token, context, container) -> token.processAsIndexedDouble(2,
  146.                                                                         Unit.DEGREE, context.getParsedUnitsBehavior(),
  147.                                                                         container::setComponent)),

  148.     /** Rotation about first axis.
  149.      * @since 12.0
  150.      */
  151.     ANGLE_1_DOT((token, context, container) -> token.processAsIndexedDouble(3,
  152.                                                                             Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  153.                                                                             container::setComponent)),

  154.     /** Rotation about second axis.
  155.      * @since 12.0
  156.      */
  157.     ANGLE_2_DOT((token, context, container) -> token.processAsIndexedDouble(4,
  158.                                                                             Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  159.                                                                             container::setComponent)),

  160.     /** Rotation about third axis.
  161.      * @since 12.0
  162.      */
  163.     ANGLE_3_DOT((token, context, container) -> token.processAsIndexedDouble(5,
  164.                                                                             Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  165.                                                                             container::setComponent)),

  166.     /** Rotation about X axis (only for ADM V1). */
  167.     X_ANGLE((token, context, container) -> token.processAsLabeledDouble('X', Unit.DEGREE, context.getParsedUnitsBehavior(),
  168.                                                                         container::setLabeledAngle)),

  169.     /** Rotation about Y axis (only for ADM V1). */
  170.     Y_ANGLE((token, context, container) -> token.processAsLabeledDouble('Y', Unit.DEGREE, context.getParsedUnitsBehavior(),
  171.                                                                         container::setLabeledAngle)),

  172.     /** Rotation about Z axis (only for ADM V1). */
  173.     Z_ANGLE((token, context, container) -> token.processAsLabeledDouble('Z', Unit.DEGREE, context.getParsedUnitsBehavior(),
  174.                                                                         container::setLabeledAngle)),

  175.     /** Rotation about X axis (only for ADM V1). */
  176.     X_RATE((token, context, container) -> token.processAsLabeledDouble('X',
  177.                                                                        Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  178.                                                                        container::setLabeledRate)),

  179.     /** Rotation about Y axis (only for ADM V1). */
  180.     Y_RATE((token, context, container) -> token.processAsLabeledDouble('Y',
  181.                                                                        Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  182.                                                                        container::setLabeledRate)),

  183.     /** Rotation about Z axis (only for ADM V1). */
  184.     Z_RATE((token, context, container) -> token.processAsLabeledDouble('Z',
  185.                                                                        Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  186.                                                                        container::setLabeledRate)),

  187.     /** Right ascension of spin axis vector. */
  188.     SPIN_ALPHA((token, context, container) -> token.processAsIndexedDouble(0, Unit.DEGREE, context.getParsedUnitsBehavior(),
  189.                                                                            container::setComponent)),

  190.     /** Declination of spin axis vector. */
  191.     SPIN_DELTA((token, context, container) -> token.processAsIndexedDouble(1, Unit.DEGREE, context.getParsedUnitsBehavior(),
  192.                                                                            container::setComponent)),

  193.     /** Phase of satellite about spin axis. */
  194.     SPIN_ANGLE((token, context, container) -> token.processAsIndexedDouble(2, Unit.DEGREE, context.getParsedUnitsBehavior(),
  195.                                                                            container::setComponent)),

  196.     /** angular velocity of satellite around spin axis. */
  197.     SPIN_ANGLE_VEL((token, context, container) -> token.processAsIndexedDouble(3, Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  198.                                                                                container::setComponent)),

  199.     /** Nutation angle entry. */
  200.     NUTATION((token, context, container) -> token.processAsIndexedDouble(4, Unit.DEGREE, context.getParsedUnitsBehavior(),
  201.                                                                          container::setComponent)),

  202.     /** Nutation period entry. */
  203.     NUTATION_PER((token, context, container) -> token.processAsIndexedDouble(5, Unit.SECOND, context.getParsedUnitsBehavior(),
  204.                                                                              container::setComponent)),

  205.     /** Nutation phase entry. */
  206.     NUTATION_PHASE((token, context, container) -> token.processAsIndexedDouble(6, Unit.DEGREE, context.getParsedUnitsBehavior(),
  207.                                                                                container::setComponent)),

  208.     /** Right ascension of angular momentum vector.
  209.      * @since 12.0
  210.      */
  211.     MOMENTUM_ALPHA((token, context, container) -> token.processAsIndexedDouble(4, Unit.DEGREE, context.getParsedUnitsBehavior(),
  212.                                                                                container::setComponent)),

  213.     /** Declination of angular momentum vector.
  214.      * @since 12.0
  215.      */
  216.     MOMENTUM_DELTA((token, context, container) -> token.processAsIndexedDouble(5, Unit.DEGREE, context.getParsedUnitsBehavior(),
  217.                                                                                container::setComponent)),

  218.     /** Nutation velocity entry.
  219.      * @since 12.0
  220.      */
  221.     NUTATION_VEL((token, context, container) -> token.processAsIndexedDouble(6, Units.DEG_PER_S, context.getParsedUnitsBehavior(),
  222.                                                                                container::setComponent));

  223.     /** Processing method. */
  224.     private final transient TokenProcessor processor;

  225.     /** Simple constructor.
  226.      * @param processor processing method
  227.      */
  228.     AttitudeEntryKey(final TokenProcessor processor) {
  229.         this.processor = processor;
  230.     }

  231.     /** Process an token.
  232.      * @param token token to process
  233.      * @param context context binding
  234.      * @param container container to fill
  235.      * @return true of token was accepted
  236.      */
  237.     public boolean process(final ParseToken token, final ContextBinding context, final AttitudeEntry container) {
  238.         return processor.process(token, context, container);
  239.     }

  240.     /** Interface for processing one token. */
  241.     interface TokenProcessor {
  242.         /** Process one token.
  243.          * @param token token to process
  244.          * @param context context binding
  245.          * @param container container to fill
  246.          * @return true of token was accepted
  247.          */
  248.         boolean process(ParseToken token, ContextBinding context, AttitudeEntry container);
  249.     }

  250. }