ManeuverKey.java

  1. /* Copyright 2002-2024 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.apm;

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

  23. /** Keys for {@link Maneuver APM maneuver} entries.
  24.  * @author Bryan Cazabonne
  25.  * @author Luc Maisonobe
  26.  * @since 11.0
  27.  */
  28. public enum ManeuverKey {

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

  32.     /** Epoch start entry. */
  33.     MAN_EPOCH_START((token, context, container) -> token.processAsDate(container::setEpochStart, context)),

  34.     /** Duration entry. */
  35.     MAN_DURATION((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
  36.                                                                       container::setDuration)),

  37.     /** Reference frame entry. */
  38.     MAN_REF_FRAME((token, context, container) -> token.processAsFrame(container::setFrame, context, true, true, true)),

  39.     /** First torque vector component entry (ADM V1 only). */
  40.     MAN_TOR_1((token, context, container) -> token.processAsIndexedDouble(0, Units.N_M, context.getParsedUnitsBehavior(),
  41.                                                                           container::setTorque)),

  42.     /** First torque vector component entry.
  43.      * @since 12.0
  44.      */
  45.     MAN_TOR_X((token, context, container) -> token.processAsIndexedDouble(0, Units.N_M, context.getParsedUnitsBehavior(),
  46.                                                                           container::setTorque)),

  47.     /** Second torque vector component entry (ADM V1 only). */
  48.     MAN_TOR_2((token, context, container) -> token.processAsIndexedDouble(1, Units.N_M, context.getParsedUnitsBehavior(),
  49.                                                                           container::setTorque)),

  50.     /** Second torque vector component entry.
  51.      * @since 12.0
  52.      */
  53.     MAN_TOR_Y((token, context, container) -> token.processAsIndexedDouble(1, Units.N_M, context.getParsedUnitsBehavior(),
  54.                                                                           container::setTorque)),

  55.     /** Third torque vector component entry (ADM V1 only). */
  56.     MAN_TOR_3((token, context, container) -> token.processAsIndexedDouble(2, Units.N_M, context.getParsedUnitsBehavior(),
  57.                                                                           container::setTorque)),

  58.     /** Third torque vector component entry.
  59.      * @since 12.0
  60.      */
  61.     MAN_TOR_Z((token, context, container) -> token.processAsIndexedDouble(2, Units.N_M, context.getParsedUnitsBehavior(),
  62.                                                                           container::setTorque)),

  63.     /** Mass change entry.
  64.      * @since 12.0
  65.      */
  66.     MAN_DELTA_MASS((token, context, container) -> token.processAsDouble(Unit.KILOGRAM, context.getParsedUnitsBehavior(),
  67.                                                                         container::setDeltaMass));

  68.     /** Processing method. */
  69.     private final transient TokenProcessor processor;

  70.     /** Simple constructor.
  71.      * @param processor processing method
  72.      */
  73.     ManeuverKey(final TokenProcessor processor) {
  74.         this.processor = processor;
  75.     }

  76.     /** Process one token.
  77.      * @param token token to process
  78.      * @param context context binding
  79.      * @param container container to fill
  80.      * @return true of token was accepted
  81.      */
  82.     public boolean process(final ParseToken token, final ContextBinding context, final Maneuver container) {
  83.         return processor.process(token, context, container);
  84.     }

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

  95. }