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.odm;
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 SpacecraftParameters ODM spacecraft parameters} entries.
27   * @author Luc Maisonobe
28   * @since 11.0
29   */
30  public enum SpacecraftParametersKey {
31  
32      /** Comment entry. */
33      COMMENT((token, context, container) ->
34              token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
35  
36      /** Spacecraft mass. */
37      MASS((token, context, container) -> token.processAsDouble(Unit.KILOGRAM, context.getParsedUnitsBehavior(),
38                                                                container::setMass)),
39  
40      /** Solar radiation pressure area. */
41      SOLAR_RAD_AREA((token, context, container) -> token.processAsDouble(Units.M2, context.getParsedUnitsBehavior(),
42                                                                          container::setSolarRadArea)),
43  
44      /** Solar radiation pressure coefficient. */
45      SOLAR_RAD_COEFF((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
46                                                                           container::setSolarRadCoeff)),
47  
48      /** Drag area. */
49      DRAG_AREA((token, context, container) -> token.processAsDouble(Units.M2, context.getParsedUnitsBehavior(),
50                                                                     container::setDragArea)),
51  
52      /** Drag coefficient. */
53      DRAG_COEFF((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
54                                                                      container::setDragCoeff));
55  
56      /** Processing method. */
57      private final transient TokenProcessor processor;
58  
59      /** Simple constructor.
60       * @param processor processing method
61       */
62      SpacecraftParametersKey(final TokenProcessor processor) {
63          this.processor = processor;
64      }
65  
66      /** Process one token.
67       * @param token token to process
68       * @param context context binding
69       * @param container container to fill
70       * @return true of token was accepted
71       */
72      public boolean process(final ParseToken token, final ContextBinding context, final SpacecraftParameters container) {
73          return processor.process(token, context, container);
74      }
75  
76      /** Interface for processing one token. */
77      interface TokenProcessor {
78          /** Process one token.
79           * @param token token to process
80           * @param context context binding
81           * @param container container to fill
82           * @return true of token was accepted
83           */
84          boolean process(ParseToken token, ContextBinding context, SpacecraftParameters container);
85      }
86  
87  }