1   /* Copyright 2002-2024 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.opm;
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 Maneuver OPM maneuver} entries.
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 of ignition. */
37      MAN_EPOCH_IGNITION((token, context, container) -> token.processAsDate(container::setEpochIgnition, context)),
38  
39      /** Coordinate system for velocity increment vector. */
40      MAN_REF_FRAME((token, context, container) -> token.processAsFrame(container::setReferenceFrame, context, true, true, false)),
41  
42      /** Maneuver duration (0 for impulsive maneuvers). */
43      MAN_DURATION((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
44                                                                        container::setDuration)),
45  
46      /** Mass change during maneuver (value is < 0). */
47      MAN_DELTA_MASS((token, context, container) -> token.processAsDouble(Unit.KILOGRAM, context.getParsedUnitsBehavior(),
48                                                                          container::setDeltaMass)),
49  
50      /** First component of the velocity increment. */
51      MAN_DV_1((token, context, container) -> token.processAsIndexedDouble(0, Units.KM_PER_S, context.getParsedUnitsBehavior(),
52                                                                           container::setDV)),
53  
54      /** Second component of the velocity increment. */
55      MAN_DV_2((token, context, container) -> token.processAsIndexedDouble(1, Units.KM_PER_S, context.getParsedUnitsBehavior(),
56                                                                           container::setDV)),
57  
58      /** Third component of the velocity increment. */
59      MAN_DV_3((token, context, container) -> token.processAsIndexedDouble(2, Units.KM_PER_S, context.getParsedUnitsBehavior(),
60                                                                           container::setDV));
61  
62      /** Processing method. */
63      private final transient TokenProcessor processor;
64  
65      /** Simple constructor.
66       * @param processor processing method
67       */
68      ManeuverKey(final TokenProcessor processor) {
69          this.processor = processor;
70      }
71  
72      /** Process one token.
73       * @param token token to process
74       * @param context context binding
75       * @param container container to fill
76       * @return true of token was accepted
77       */
78      public boolean process(final ParseToken token, final ContextBinding context, final Maneuver container) {
79          return processor.process(token, context, container);
80      }
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 container container to fill
88           * @return true of token was accepted
89           */
90          boolean process(ParseToken token, ContextBinding context, Maneuver container);
91      }
92  
93  }