AttitudePhysicalPropertiesKey.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.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 AttitudePhysicalProperties physical properties data} entries.
  24.  * @author Luc Maisonobe
  25.  * @since 12.0
  26.  */
  27. public enum AttitudePhysicalPropertiesKey {

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

  31.     /** Drag coefficient. */
  32.     DRAG_COEFF((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
  33.                                                                     container::setDragCoefficient)),

  34.     /** Total mass at Tâ‚€. */
  35.     WET_MASS((token, context, container) -> token.processAsDouble(Unit.KILOGRAM, context.getParsedUnitsBehavior(),
  36.                                                                   container::setWetMass)),

  37.     /** Mass without propellant. */
  38.     DRY_MASS((token, context, container) -> token.processAsDouble(Unit.KILOGRAM, context.getParsedUnitsBehavior(),
  39.                                                                   container::setDryMass)),

  40.     /** Reference frame for center of pressure. */
  41.     CP_REF_FRAME((token, context, container) -> token.processAsFrame(container::setCenterOfPressureReferenceFrame, context, false, false, true)),

  42.     /** Center of pressure. */
  43.     CP((token, context, container) -> token.processAsVector(Unit.METRE, context.getParsedUnitsBehavior(),
  44.                                                             container::setCenterOfPressure)),

  45.     /** Inertia reference frame. */
  46.     INERTIA_REF_FRAME((token, context, container) -> token.processAsFrame(container::setInertiaReferenceFrame, context, false, false, true)),

  47.     /** Moment of inertia about X-axis. */
  48.     IXX((token, context, container) -> token.processAsDoublyIndexedDouble(0, 0, Units.KG_M2, context.getParsedUnitsBehavior(),
  49.                                                                           container::setInertiaMatrixEntry)),

  50.     /** Moment of inertia about Y-axis. */
  51.     IYY((token, context, container) -> token.processAsDoublyIndexedDouble(1, 1, Units.KG_M2, context.getParsedUnitsBehavior(),
  52.                                                                           container::setInertiaMatrixEntry)),

  53.     /** Moment of inertia about Z-axis. */
  54.     IZZ((token, context, container) -> token.processAsDoublyIndexedDouble(2, 2, Units.KG_M2, context.getParsedUnitsBehavior(),
  55.                                                                           container::setInertiaMatrixEntry)),

  56.     /** Inertia cross product of the X and Y axes. */
  57.     IXY((token, context, container) -> token.processAsDoublyIndexedDouble(0, 1, Units.KG_M2, context.getParsedUnitsBehavior(),
  58.                                                                           container::setInertiaMatrixEntry)),

  59.     /** Inertia cross product of the X and Z axes. */
  60.     IXZ((token, context, container) -> token.processAsDoublyIndexedDouble(0, 2, Units.KG_M2, context.getParsedUnitsBehavior(),
  61.                                                                           container::setInertiaMatrixEntry)),

  62.     /** Inertia cross product of the Y and Z axes. */
  63.     IYZ((token, context, container) -> token.processAsDoublyIndexedDouble(1, 2, Units.KG_M2, context.getParsedUnitsBehavior(),
  64.                                                                           container::setInertiaMatrixEntry));

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

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

  73.     /** Process an token.
  74.      * @param token token to process
  75.      * @param context context binding
  76.      * @param data data to fill
  77.      * @return true of token was accepted
  78.      */
  79.     public boolean process(final ParseToken token, final ContextBinding context, final AttitudePhysicalProperties data) {
  80.         return processor.process(token, context, data);
  81.     }

  82.     /** Interface for processing one token. */
  83.     interface TokenProcessor {
  84.         /** Process one token.
  85.          * @param token token to process
  86.          * @param context context binding
  87.          * @param data data to fill
  88.          * @return true of token was accepted
  89.          */
  90.         boolean process(ParseToken token, ContextBinding context, AttitudePhysicalProperties data);
  91.     }

  92. }