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  
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  import org.orekit.utils.units.Unit;
24  
25  
26  /** Keys for {@link AttitudePhysicalProperties physical properties data} entries.
27   * @author Luc Maisonobe
28   * @since 12.0
29   */
30  public enum AttitudePhysicalPropertiesKey {
31  
32      /** Comment entry. */
33      COMMENT((token, context, container) ->
34              token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
35  
36      /** Drag coefficient. */
37      DRAG_COEFF((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
38                                                                      container::setDragCoefficient)),
39  
40      /** Total mass at T₀. */
41      WET_MASS((token, context, container) -> token.processAsDouble(Unit.KILOGRAM, context.getParsedUnitsBehavior(),
42                                                                    container::setWetMass)),
43  
44      /** Mass without propellant. */
45      DRY_MASS((token, context, container) -> token.processAsDouble(Unit.KILOGRAM, context.getParsedUnitsBehavior(),
46                                                                    container::setDryMass)),
47  
48      /** Reference frame for center of pressure. */
49      CP_REF_FRAME((token, context, container) -> token.processAsFrame(container::setCenterOfPressureReferenceFrame, context, false, false, true)),
50  
51      /** Center of pressure. */
52      CP((token, context, container) -> token.processAsVector(Unit.METRE, context.getParsedUnitsBehavior(),
53                                                              container::setCenterOfPressure)),
54  
55      /** Inertia reference frame. */
56      INERTIA_REF_FRAME((token, context, container) -> token.processAsFrame(container::setInertiaReferenceFrame, context, false, false, true)),
57  
58      /** Moment of inertia about X-axis. */
59      IXX((token, context, container) -> token.processAsDoublyIndexedDouble(0, 0, Units.KG_M2, context.getParsedUnitsBehavior(),
60                                                                            container::setInertiaMatrixEntry)),
61  
62      /** Moment of inertia about Y-axis. */
63      IYY((token, context, container) -> token.processAsDoublyIndexedDouble(1, 1, Units.KG_M2, context.getParsedUnitsBehavior(),
64                                                                            container::setInertiaMatrixEntry)),
65  
66      /** Moment of inertia about Z-axis. */
67      IZZ((token, context, container) -> token.processAsDoublyIndexedDouble(2, 2, Units.KG_M2, context.getParsedUnitsBehavior(),
68                                                                            container::setInertiaMatrixEntry)),
69  
70      /** Inertia cross product of the X and Y axes. */
71      IXY((token, context, container) -> token.processAsDoublyIndexedDouble(0, 1, Units.KG_M2, context.getParsedUnitsBehavior(),
72                                                                            container::setInertiaMatrixEntry)),
73  
74      /** Inertia cross product of the X and Z axes. */
75      IXZ((token, context, container) -> token.processAsDoublyIndexedDouble(0, 2, Units.KG_M2, context.getParsedUnitsBehavior(),
76                                                                            container::setInertiaMatrixEntry)),
77  
78      /** Inertia cross product of the Y and Z axes. */
79      IYZ((token, context, container) -> token.processAsDoublyIndexedDouble(1, 2, Units.KG_M2, context.getParsedUnitsBehavior(),
80                                                                            container::setInertiaMatrixEntry));
81  
82      /** Processing method. */
83      private final transient TokenProcessor processor;
84  
85      /** Simple constructor.
86       * @param processor processing method
87       */
88      AttitudePhysicalPropertiesKey(final TokenProcessor processor) {
89          this.processor = processor;
90      }
91  
92      /** Process an token.
93       * @param token token to process
94       * @param context context binding
95       * @param data data to fill
96       * @return true of token was accepted
97       */
98      public boolean process(final ParseToken token, final ContextBinding context, final AttitudePhysicalProperties data) {
99          return processor.process(token, context, data);
100     }
101 
102     /** Interface for processing one token. */
103     interface TokenProcessor {
104         /** Process one token.
105          * @param token token to process
106          * @param context context binding
107          * @param data data to fill
108          * @return true of token was accepted
109          */
110         boolean process(ParseToken token, ContextBinding context, AttitudePhysicalProperties data);
111     }
112 
113 }