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.apm;
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
24
25 /** Keys for {@link Inertia inertia} entries.
26 * @author Luc Maisonobe
27 * @since 12.0
28 */
29 public enum InertiaKey {
30
31 /** Comment entry. */
32 COMMENT((token, context, container) ->
33 token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
34
35 /** Frame in which inertia is defined. */
36 INERTIA_REF_FRAME((token, context, container) -> token.processAsFrame(container::setFrame, context, false, false, true)),
37
38 /** Moment of inertia about X-axis (ADM V1 only). */
39 I11((token, context, container) -> token.processAsDoublyIndexedDouble(0, 0, Units.KG_M2, context.getParsedUnitsBehavior(),
40 container::setInertiaMatrixEntry)),
41
42 /** Moment of inertia about X-axis. */
43 IXX((token, context, container) -> token.processAsDoublyIndexedDouble(0, 0, Units.KG_M2, context.getParsedUnitsBehavior(),
44 container::setInertiaMatrixEntry)),
45
46 /** Moment of inertia about Y-axis (ADM V1 only). */
47 I22((token, context, container) -> token.processAsDoublyIndexedDouble(1, 1, Units.KG_M2, context.getParsedUnitsBehavior(),
48 container::setInertiaMatrixEntry)),
49
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
54 /** Moment of inertia about Z-axis (ADM V1 only). */
55 I33((token, context, container) -> token.processAsDoublyIndexedDouble(2, 2, Units.KG_M2, context.getParsedUnitsBehavior(),
56 container::setInertiaMatrixEntry)),
57
58 /** Moment of inertia about Z-axis. */
59 IZZ((token, context, container) -> token.processAsDoublyIndexedDouble(2, 2, Units.KG_M2, context.getParsedUnitsBehavior(),
60 container::setInertiaMatrixEntry)),
61
62 /** Inertia cross product of the X and Y axes (ADM V1 only). */
63 I12((token, context, container) -> token.processAsDoublyIndexedDouble(0, 1, Units.KG_M2, context.getParsedUnitsBehavior(),
64 container::setInertiaMatrixEntry)),
65
66 /** Inertia cross product of the X and Y axes. */
67 IXY((token, context, container) -> token.processAsDoublyIndexedDouble(0, 1, Units.KG_M2, context.getParsedUnitsBehavior(),
68 container::setInertiaMatrixEntry)),
69
70 /** Inertia cross product of the X and Z axes (ADM V1 only). */
71 I13((token, context, container) -> token.processAsDoublyIndexedDouble(0, 2, 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 (ADM V1 only). */
79 I23((token, context, container) -> token.processAsDoublyIndexedDouble(1, 2, Units.KG_M2, context.getParsedUnitsBehavior(),
80 container::setInertiaMatrixEntry)),
81
82 /** Inertia cross product of the Y and Z axes. */
83 IYZ((token, context, container) -> token.processAsDoublyIndexedDouble(1, 2, Units.KG_M2, context.getParsedUnitsBehavior(),
84 container::setInertiaMatrixEntry));
85
86 /** Processing method. */
87 private final transient TokenProcessor processor;
88
89 /** Simple constructor.
90 * @param processor processing method
91 */
92 InertiaKey(final TokenProcessor processor) {
93 this.processor = processor;
94 }
95
96 /** Process an token.
97 * @param token token to process
98 * @param context context binding
99 * @param data data to fill
100 * @return true of token was accepted
101 */
102 public boolean process(final ParseToken token, final ContextBinding context, final Inertia data) {
103 return processor.process(token, context, data);
104 }
105
106 /** Interface for processing one token. */
107 interface TokenProcessor {
108 /** Process one token.
109 * @param token token to process
110 * @param context context binding
111 * @param data data to fill
112 * @return true of token was accepted
113 */
114 boolean process(ParseToken token, ContextBinding context, Inertia data);
115 }
116
117 }