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.cdm;
18  
19  import org.orekit.files.ccsds.utils.ContextBinding;
20  import org.orekit.files.ccsds.utils.lexical.ParseToken;
21  import org.orekit.files.ccsds.utils.lexical.TokenType;
22  import org.orekit.utils.units.Unit;
23  
24  /** Keys for {@link ODParameters CDM OD parameters} entries.
25   * @author Melina Vanel
26   * @since 11.2
27   */
28  public enum ODParametersKey {
29  
30      /** Comment entry. */
31      COMMENT((token, context, container) ->
32              token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
33  
34      /** The start of a time interval (UTC) that contains the time of the last accepted observation. */
35      TIME_LASTOB_START((token, context, container) -> token.processAsDate(container::setTimeLastObsStart, context)),
36  
37      /** The start of a time interval (UTC) that contains the time of the last accepted observation. */
38      TIME_LASTOB_END((token, context, container) -> token.processAsDate(container::setTimeLastObsEnd, context)),
39  
40      /** The recommended OD time span calculated for the object. */
41      RECOMMENDED_OD_SPAN((token, context, container) -> token.processAsDouble(Unit.DAY, context.getParsedUnitsBehavior(),
42                                                                               container::setRecommendedOdSpan)),
43  
44      /** Based on the observations available and the RECOMMENDED_OD_SPAN, the actual time span used for the OD of the object. */
45      ACTUAL_OD_SPAN((token, context, container) -> token.processAsDouble(Unit.DAY, context.getParsedUnitsBehavior(),
46                                                                               container::setActualOdSpan)),
47  
48      /** The number of observations available for the OD of the object. */
49      OBS_AVAILABLE((token, context, container) -> token.processAsInteger(container::setObsAvailable)),
50  
51      /** The number of observations accepted for the OD of the object. */
52      OBS_USED((token, context, container) -> token.processAsInteger(container::setObsUsed)),
53  
54      /** The number of sensor tracks available for the OD of the object. */
55      TRACKS_AVAILABLE((token, context, container) -> token.processAsInteger(container::setTracksAvailable)),
56  
57      /** The number of sensor tracks accepted for the OD of the object. */
58      TRACKS_USED((token, context, container) -> token.processAsInteger(container::setTracksUsed)),
59  
60      /** The percentage of residuals accepted in the OD of the object (from 0 to 100). */
61      RESIDUALS_ACCEPTED((token, context, container) -> token.processAsDouble(Unit.PERCENT, context.getParsedUnitsBehavior(),
62                                                                               container::setResidualsAccepted)),
63  
64      /** The weighted Root Mean Square (RMS) of the residuals from a batch least squares OD. */
65      WEIGHTED_RMS((token, context, container) -> token.processAsDouble(Unit.ONE, context.getParsedUnitsBehavior(),
66                                                                               container::setWeightedRMS)),
67  
68      /** The epoch of the orbit determination used for this message (UTC). */
69      OD_EPOCH((token, context, container) -> token.processAsDate(container::setOdEpoch, context));
70  
71  
72      /** Processing method. */
73      private final transient TokenProcessor processor;
74  
75      /** Simple constructor.
76       * @param processor processing method
77       */
78      ODParametersKey(final TokenProcessor processor) {
79          this.processor = processor;
80      }
81  
82      /** Process one token.
83       * @param token token to process
84       * @param context context binding
85       * @param container container to fill
86       * @return true of token was accepted
87       */
88      public boolean process(final ParseToken token, final ContextBinding context, final ODParameters container) {
89          return processor.process(token, context, container);
90      }
91  
92      /** Interface for processing one token. */
93      interface TokenProcessor {
94          /** Process one token.
95           * @param token token to process
96           * @param context context binding
97           * @param container container to fill
98           * @return true of token was accepted
99           */
100         boolean process(ParseToken token, ContextBinding context, ODParameters container);
101     }
102 
103 }