AttitudeDeterminationKey.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.files.ccsds.ndm.adm.acm;

  18. import org.orekit.files.ccsds.definitions.AdMethodType;
  19. import org.orekit.files.ccsds.definitions.Units;
  20. import org.orekit.files.ccsds.utils.ContextBinding;
  21. import org.orekit.files.ccsds.utils.lexical.ParseToken;
  22. import org.orekit.files.ccsds.utils.lexical.TokenType;


  23. /** Keys for {@link AttitudeDetermination attitude determination data} entries.
  24.  * @author Luc Maisonobe
  25.  * @since 12.0
  26.  */
  27. public enum AttitudeDeterminationKey {

  28.     /** Comment entry. */
  29.     COMMENT((token, parser, context, container) ->
  30.             token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),

  31.     /** Identification number. */
  32.     AD_ID((token, parser, context, container) -> token.processAsFreeTextString(container::setId)),

  33.     /** Identification of previous attitude determination. */
  34.     AD_PREV_ID((token, parser, context, container) -> token.processAsFreeTextString(container::setPrevId)),

  35.     /** Attitude determination method. */
  36.     AD_METHOD((token, parser, context, container) -> token.processAsEnum(AdMethodType.class, container::setMethod)),

  37.     /** Source of attitude estimate. */
  38.     ATTITUDE_SOURCE((token, parser, context, container) -> token.processAsFreeTextString(container::setSource)),

  39.     /** Rotation sequence entry. */
  40.     EULER_ROT_SEQ((token, parser, context, container) -> token.processAsRotationOrder(container::setEulerRotSeq)),

  41.     /** Number of states. */
  42.     NUMBER_STATES((token, parser, context, container) -> token.processAsInteger(container::setNbStates)),

  43.     /** Attitude states. */
  44.     ATTITUDE_STATES((token, parser, context, container) -> token.processAsEnum(AttitudeElementsType.class, container::setAttitudeStates)),

  45.     /** Type of attitude error state. */
  46.     COV_TYPE((token, parser, context, container) -> token.processAsEnum(AttitudeCovarianceType.class, container::setCovarianceType)),

  47.     /** Reference frame defining the starting point of the transformation. */
  48.     REF_FRAME_A((token, parser, context, container) -> token.processAsFrame(container.getEndpoints()::setFrameA, context, true, true, false)),

  49.     /** Reference frame defining the end point of the transformation. */
  50.     REF_FRAME_B((token, parser, context, container) -> token.processAsFrame(container.getEndpoints()::setFrameB, context, false, false, true)),

  51.     /** Attitude rate states. */
  52.     RATE_STATES((token, parser, context, container) -> token.processAsEnum(RateElementsType.class, container::setRateStates)),

  53.     /** Rate random walk if {@link #RATE_STATES} is {@link RateElementsType#GYRO_BIAS}. */
  54.     SIGMA_U((token, parser, context, container) -> token.processAsDouble(Units.DEG_PER_S_3_2, context.getParsedUnitsBehavior(),
  55.                                                                          container::setSigmaU)),

  56.     /** Angle random walk if {@link #RATE_STATES} is {@link RateElementsType#GYRO_BIAS}. */
  57.     SIGMA_V((token, parser, context, container) -> token.processAsDouble(Units.DEG_PER_S_1_2, context.getParsedUnitsBehavior(),
  58.                                                                          container::setSigmaV)),

  59.     /** Process noise standard deviation if {@link #RATE_STATES} is {@link RateElementsType#ANGVEL}. */
  60.     RATE_PROCESS_NOISE_STDDEV((token, parser, context, container) -> token.processAsDouble(Units.DEG_PER_S_3_2, context.getParsedUnitsBehavior(),
  61.                                                                                            container::setRateProcessNoiseStdDev)),

  62.     /** Sensor block sub-structure. */
  63.     SENSOR((token, parser, context, container) -> parser.manageAttitudeDeterminationSensorSection(token.getType() == TokenType.START));

  64.     /** Processing method. */
  65.     private final transient TokenProcessor processor;

  66.     /** Simple constructor.
  67.      * @param processor processing method
  68.      */
  69.     AttitudeDeterminationKey(final TokenProcessor processor) {
  70.         this.processor = processor;
  71.     }

  72.     /** Process an token.
  73.      * @param token token to process
  74.      * @param parser ACM file parser
  75.      * @param context context binding
  76.      * @param container container to fill
  77.      * @return true of token was accepted
  78.      */
  79.     public boolean process(final ParseToken token, final AcmParser parser, final ContextBinding context,
  80.                            final AttitudeDetermination container) {
  81.         return processor.process(token, parser, context, container);
  82.     }

  83.     /** Interface for processing one token. */
  84.     interface TokenProcessor {
  85.         /** Process one token.
  86.          * @param token token to process
  87.          * @param parser ACM file parser
  88.          * @param context context binding
  89.          * @param container container to fill
  90.          * @return true of token was accepted
  91.          */
  92.         boolean process(ParseToken token, AcmParser parser, ContextBinding context, AttitudeDetermination container);
  93.     }

  94. }