SpacecraftParametersKey.java

  1. /* Copyright 2002-2023 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 SpacecraftParameters ODM spacecraft parameters} entries.
  24.  * @author Luc Maisonobe
  25.  * @since 11.0
  26.  */
  27. public enum SpacecraftParametersKey {

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

  31.     /** Spacecraft mass. */
  32.     MASS((token, context, container) -> token.processAsDouble(Unit.KILOGRAM, context.getParsedUnitsBehavior(),
  33.                                                               container::setMass)),

  34.     /** Solar radiation pressure area. */
  35.     SOLAR_RAD_AREA((token, context, container) -> token.processAsDouble(Units.M2, context.getParsedUnitsBehavior(),
  36.                                                                         container::setSolarRadArea)),

  37.     /** Solar radiation pressure coefficient. */
  38.     SOLAR_RAD_COEFF((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
  39.                                                                          container::setSolarRadCoeff)),

  40.     /** Drag area. */
  41.     DRAG_AREA((token, context, container) -> token.processAsDouble(Units.M2, context.getParsedUnitsBehavior(),
  42.                                                                    container::setDragArea)),

  43.     /** Drag coefficient. */
  44.     DRAG_COEFF((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
  45.                                                                     container::setDragCoeff));

  46.     /** Processing method. */
  47.     private final TokenProcessor processor;

  48.     /** Simple constructor.
  49.      * @param processor processing method
  50.      */
  51.     SpacecraftParametersKey(final TokenProcessor processor) {
  52.         this.processor = processor;
  53.     }

  54.     /** Process one token.
  55.      * @param token token to process
  56.      * @param context context binding
  57.      * @param container container to fill
  58.      * @return true of token was accepted
  59.      */
  60.     public boolean process(final ParseToken token, final ContextBinding context, final SpacecraftParameters container) {
  61.         return processor.process(token, context, container);
  62.     }

  63.     /** Interface for processing one token. */
  64.     interface TokenProcessor {
  65.         /** Process one token.
  66.          * @param token token to process
  67.          * @param context context binding
  68.          * @param container container to fill
  69.          * @return true of token was accepted
  70.          */
  71.         boolean process(ParseToken token, ContextBinding context, SpacecraftParameters container);
  72.     }

  73. }