StateVectorKey.java

  1. /* Copyright 2002-2022 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.odm;

  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 StateVector ODM state vector container} entries.
  24.  * @author Luc Maisonobe
  25.  * @since 11.0
  26.  */
  27. public enum StateVectorKey {

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

  31.     /** Epoch of state vector and optional Keplerian elements. */
  32.     EPOCH((token, context, container) -> token.processAsDate(container::setEpoch, context)),

  33.     /** Position vector X-component. */
  34.     X((token, context, container) -> token.processAsIndexedDouble(0, Unit.KILOMETRE, context.getParsedUnitsBehavior(),
  35.                                                                   container::setP)),

  36.     /** Position vector Y-component. */
  37.     Y((token, context, container) -> token.processAsIndexedDouble(1, Unit.KILOMETRE, context.getParsedUnitsBehavior(),
  38.                                                                   container::setP)),

  39.     /** Position vector Z-component. */
  40.     Z((token, context, container) -> token.processAsIndexedDouble(2, Unit.KILOMETRE, context.getParsedUnitsBehavior(),
  41.                                                                   container::setP)),

  42.     /** Velocity vector X-component. */
  43.     X_DOT((token, context, container) -> token.processAsIndexedDouble(0, Units.KM_PER_S, context.getParsedUnitsBehavior(),
  44.                                                                       container::setV)),

  45.     /** Velocity vector Y-component. */
  46.     Y_DOT((token, context, container) -> token.processAsIndexedDouble(1, Units.KM_PER_S, context.getParsedUnitsBehavior(),
  47.                                                                       container::setV)),

  48.     /** Velocity vector Z-component. */
  49.     Z_DOT((token, context, container) -> token.processAsIndexedDouble(2, Units.KM_PER_S, context.getParsedUnitsBehavior(),
  50.                                                                       container::setV)),

  51.     /** Acceleration vector X-component. */
  52.     X_DDOT((token, context, container) -> token.processAsIndexedDouble(0, Units.KM_PER_S2, context.getParsedUnitsBehavior(),
  53.                                                                        container::setA)),

  54.     /** Acceleration vector Y-component. */
  55.     Y_DDOT((token, context, container) -> token.processAsIndexedDouble(1, Units.KM_PER_S2, context.getParsedUnitsBehavior(),
  56.                                                                        container::setA)),

  57.     /** Acceleration vector Z-component. */
  58.     Z_DDOT((token, context, container) -> token.processAsIndexedDouble(2, Units.KM_PER_S2, context.getParsedUnitsBehavior(),
  59.                                                                        container::setA));

  60.     /** Processing method. */
  61.     private final TokenProcessor processor;

  62.     /** Simple constructor.
  63.      * @param processor processing method
  64.      */
  65.     StateVectorKey(final TokenProcessor processor) {
  66.         this.processor = processor;
  67.     }

  68.     /** Process one token.
  69.      * @param token token to process
  70.      * @param context context binding
  71.      * @param container container to fill
  72.      * @return true of token was accepted
  73.      */
  74.     public boolean process(final ParseToken token, final ContextBinding context, final StateVector container) {
  75.         return processor.process(token, context, container);
  76.     }

  77.     /** Interface for processing one token. */
  78.     interface TokenProcessor {
  79.         /** Process one token.
  80.          * @param token token to process
  81.          * @param context context binding
  82.          * @param container container to fill
  83.          * @return true of token was accepted
  84.          */
  85.         boolean process(ParseToken token, ContextBinding context, StateVector container);
  86.     }

  87. }