1   /* Copyright 2002-2025 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.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  import org.orekit.utils.units.Unit;
24  
25  /** Keys for {@link Maneuver APM maneuver} entries.
26   * @author Bryan Cazabonne
27   * @author Luc Maisonobe
28   * @since 11.0
29   */
30  public enum ManeuverKey {
31  
32      /** Comment entry. */
33      COMMENT((token, context, container) ->
34              token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
35  
36      /** Epoch start entry. */
37      MAN_EPOCH_START((token, context, container) -> token.processAsDate(container::setEpochStart, context)),
38  
39      /** Duration entry. */
40      MAN_DURATION((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
41                                                                        container::setDuration)),
42  
43      /** Reference frame entry. */
44      MAN_REF_FRAME((token, context, container) -> token.processAsFrame(container::setFrame, context, true, true, true)),
45  
46      /** First torque vector component entry (ADM V1 only). */
47      MAN_TOR_1((token, context, container) -> token.processAsIndexedDouble(0, Units.N_M, context.getParsedUnitsBehavior(),
48                                                                            container::setTorque)),
49  
50      /** First torque vector component entry.
51       * @since 12.0
52       */
53      MAN_TOR_X((token, context, container) -> token.processAsIndexedDouble(0, Units.N_M, context.getParsedUnitsBehavior(),
54                                                                            container::setTorque)),
55  
56      /** Second torque vector component entry (ADM V1 only). */
57      MAN_TOR_2((token, context, container) -> token.processAsIndexedDouble(1, Units.N_M, context.getParsedUnitsBehavior(),
58                                                                            container::setTorque)),
59  
60      /** Second torque vector component entry.
61       * @since 12.0
62       */
63      MAN_TOR_Y((token, context, container) -> token.processAsIndexedDouble(1, Units.N_M, context.getParsedUnitsBehavior(),
64                                                                            container::setTorque)),
65  
66      /** Third torque vector component entry (ADM V1 only). */
67      MAN_TOR_3((token, context, container) -> token.processAsIndexedDouble(2, Units.N_M, context.getParsedUnitsBehavior(),
68                                                                            container::setTorque)),
69  
70      /** Third torque vector component entry.
71       * @since 12.0
72       */
73      MAN_TOR_Z((token, context, container) -> token.processAsIndexedDouble(2, Units.N_M, context.getParsedUnitsBehavior(),
74                                                                            container::setTorque)),
75  
76      /** Mass change entry.
77       * @since 12.0
78       */
79      MAN_DELTA_MASS((token, context, container) -> token.processAsDouble(Unit.KILOGRAM, context.getParsedUnitsBehavior(),
80                                                                          container::setDeltaMass));
81  
82      /** Processing method. */
83      private final transient TokenProcessor processor;
84  
85      /** Simple constructor.
86       * @param processor processing method
87       */
88      ManeuverKey(final TokenProcessor processor) {
89          this.processor = processor;
90      }
91  
92      /** Process one token.
93       * @param token token to process
94       * @param context context binding
95       * @param container container to fill
96       * @return true of token was accepted
97       */
98      public boolean process(final ParseToken token, final ContextBinding context, final Maneuver container) {
99          return processor.process(token, context, container);
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 container container to fill
108          * @return true of token was accepted
109          */
110         boolean process(ParseToken token, ContextBinding context, Maneuver container);
111     }
112 
113 }