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.ocm;
18  
19  import org.orekit.files.ccsds.definitions.DutyCycleType;
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 OrbitManeuverHistoryMetadata maneuver history container} entries.
27   * @author Luc Maisonobe
28   * @since 11.0
29   */
30  public enum OrbitManeuverHistoryMetadataKey {
31  
32      /** Comment entry. */
33      COMMENT((token, context, container) ->
34              token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
35  
36      /** Maneuver identification number. */
37      MAN_ID((token, context, container) -> token.processAsFreeTextString(container::setManID)),
38  
39      /** Identification number of previous maneuver. */
40      MAN_PREV_ID((token, context, container) -> token.processAsFreeTextString(container::setManPrevID)),
41  
42      /** Identification number of next maneuver. */
43      MAN_NEXT_ID((token, context, container) -> token.processAsFreeTextString(container::setManNextID)),
44  
45      /** Basis of this maneuver history data. */
46      MAN_BASIS((token, context, container) -> token.processAsEnum(ManBasis.class, container::setManBasis)),
47  
48      /** Identification number of the orbit determination or simulation upon which this maneuver is based.*/
49      MAN_BASIS_ID((token, context, container) -> token.processAsFreeTextString(container::setManBasisID)),
50  
51      /** Identifier of the device used for this maneuver.*/
52      MAN_DEVICE_ID((token, context, container) -> token.processAsFreeTextString(container::setManDeviceID)),
53  
54      /** Completion time of previous maneuver. */
55      MAN_PREV_EPOCH((token, context, container) -> token.processAsDate(container::setManPrevEpoch, context)),
56  
57      /** Start time of next maneuver. */
58      MAN_NEXT_EPOCH((token, context, container) -> token.processAsDate(container::setManNextEpoch, context)),
59  
60      /** Purposes of the maneuver. */
61      MAN_PURPOSE((token, context, container) -> token.processAsFreeTextList(container::setManPurpose)),
62  
63      /** Prediction source on which this maneuver is based. */
64      MAN_PRED_SOURCE((token, context, container) -> token.processAsFreeTextString(container::setManPredSource)),
65  
66      /** Reference frame of the maneuver. */
67      MAN_REF_FRAME((token, context, container) -> token.processAsFrame(container::setManReferenceFrame, context, true, true, false)),
68  
69      /** Epoch of the {@link #MAN_REF_FRAME maneuver reference frame}. */
70      MAN_FRAME_EPOCH((token, context, container) -> token.processAsDate(container::setManFrameEpoch, context)),
71  
72      /** Origin of maneuver gravitational assist body. */
73      GRAV_ASSIST_NAME((token, context, container) -> token.processAsCenter(container::setGravitationalAssist,
74                                                                            context.getDataContext().getCelestialBodies())),
75  
76      /** Type of duty cycle. */
77      DC_TYPE((token, context, container) -> token.processAsEnum(DutyCycleType.class, container::setDcType)),
78  
79      /** Start time of duty cycle-based maneuver window. */
80      DC_WIN_OPEN((token, context, container) -> token.processAsDate(container::setDcWindowOpen, context)),
81  
82      /** Start time of duty cycle-based maneuver window. */
83      DC_WIN_CLOSE((token, context, container) -> token.processAsDate(container::setDcWindowClose, context)),
84  
85      /** Minimum number of "ON" duty cycles. */
86      DC_MIN_CYCLES((token, context, container) -> token.processAsInteger(container::setDcMinCycles)),
87  
88      /** Maximum number of "ON" duty cycles. */
89      DC_MAX_CYCLES((token, context, container) -> token.processAsInteger(container::setDcMaxCycles)),
90  
91      /** Start time of initial duty cycle-based maneuver execution. */
92      DC_EXEC_START((token, context, container) -> token.processAsDate(container::setDcExecStart, context)),
93  
94      /** End time of final duty cycle-based maneuver execution. */
95      DC_EXEC_STOP((token, context, container) -> token.processAsDate(container::setDcExecStop, context)),
96  
97      /** Duty cycle thrust reference time. */
98      DC_REF_TIME((token, context, container) -> token.processAsDate(container::setDcRefTime, context)),
99  
100     /** Duty cycle pulse "ON" duration. */
101     DC_TIME_PULSE_DURATION((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
102                                                                                 container::setDcTimePulseDuration)),
103 
104     /** Duty cycle elapsed time between start of a pulse and start of next pulse. */
105     DC_TIME_PULSE_PERIOD((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
106                                                                               container::setDcTimePulsePeriod)),
107 
108     /** Reference direction for triggering duty cycle. */
109     DC_REF_DIR((token, context, container) -> token.processAsVector(Unit.NONE, context.getParsedUnitsBehavior(),
110                                                                     container::setDcRefDir)),
111 
112     /** Spacecraft body frame in which {@link #DC_BODY_TRIGGER} is specified. */
113     DC_BODY_FRAME((token, context, container) -> token.processAsFrame(f -> container.setDcBodyFrame(f.asSpacecraftBodyFrame()),
114                                                                       context, false, false, true)),
115 
116     /** Direction in {@link #DC_BODY_FRAME body frame} for triggering duty cycle. */
117     DC_BODY_TRIGGER((token, context, container) -> token.processAsVector(Unit.NONE, context.getParsedUnitsBehavior(),
118                                                                          container::setDcBodyTrigger)),
119 
120     /** Phase angle of pulse start. */
121     DC_PA_START_ANGLE((token, context, container) -> token.processAsDouble(Unit.DEGREE, context.getParsedUnitsBehavior(),
122                                                                            container::setDcPhaseStartAngle)),
123 
124     /** Phase angle of pulse stop. */
125     DC_PA_STOP_ANGLE((token, context, container) -> token.processAsDouble(Unit.DEGREE, context.getParsedUnitsBehavior(),
126                                                                           container::setDcPhaseStopAngle)),
127 
128     /** Maneuver elements of information. */
129     MAN_COMPOSITION((token, context, container) -> token.processAsEnumsList(ManeuverFieldType.class, container::setManComposition)),
130 
131     /** SI units for each elements of the maneuver. */
132     MAN_UNITS((token, context, container) -> token.processAsUnitList(container::setManUnits));
133 
134     /** Processing method. */
135     private final transient TokenProcessor processor;
136 
137     /** Simple constructor.
138      * @param processor processing method
139      */
140     OrbitManeuverHistoryMetadataKey(final TokenProcessor processor) {
141         this.processor = processor;
142     }
143 
144     /** Process an token.
145      * @param token token to process
146      * @param context context binding
147      * @param container container to fill
148      * @return true of token was accepted
149      */
150     public boolean process(final ParseToken token, final ContextBinding context, final OrbitManeuverHistoryMetadata container) {
151         return processor.process(token, context, container);
152     }
153 
154     /** Interface for processing one token. */
155     interface TokenProcessor {
156         /** Process one token.
157          * @param token token to process
158          * @param context context binding
159          * @param container container to fill
160          * @return true of token was accepted
161          */
162         boolean process(ParseToken token, ContextBinding context, OrbitManeuverHistoryMetadata container);
163     }
164 
165 }