1   /* Copyright 2002-2021 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 ManeuverHistoryMetadata maneuver history container} entries.
27   * @author Luc Maisonobe
28   * @since 11.0
29   */
30  public enum ManeuverHistoryMetadataKey {
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.processAsNormalizedString(container::setManID)),
38  
39      /** Identification number of previous maneuver. */
40      MAN_PREV_ID((token, context, container) -> token.processAsNormalizedString(container::setManPrevID)),
41  
42      /** Identification number of next maneuver. */
43      MAN_NEXT_ID((token, context, container) -> token.processAsNormalizedString(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.processAsNormalizedString(container::setManBasisID)),
50  
51      /** Identifier of the device used for this maneuver.*/
52      MAN_DEVICE_ID((token, context, container) -> token.processAsNormalizedString(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.processAsNormalizedList(container::setManPurpose)),
62  
63      /** Prediction source on which this maneuver is based. */
64      MAN_PRED_SOURCE((token, context, container) -> token.processAsNormalizedString(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(container::setDcRefDir)),
110 
111     /** Spacecraft body frame in which {@link #DC_BODY_TRIGGER} is specified. */
112     DC_BODY_FRAME((token, context, container) -> token.processAsFrame(f -> container.setDcBodyFrame(f.asSpacecraftBodyFrame()),
113                                                                       context, false, false, true)),
114 
115     /** Direction in {@link #DC_BODY_FRAME body frame} for triggering duty cycle. */
116     DC_BODY_TRIGGER((token, context, container) -> token.processAsVector(container::setDcBodyTrigger)),
117 
118     /** Phase angle of pulse start. */
119     DC_PA_START_ANGLE((token, context, container) -> token.processAsDouble(Unit.DEGREE, context.getParsedUnitsBehavior(),
120                                                                            container::setDcPhaseStartAngle)),
121 
122     /** Phase angle of pulse stop. */
123     DC_PA_STOP_ANGLE((token, context, container) -> token.processAsDouble(Unit.DEGREE, context.getParsedUnitsBehavior(),
124                                                                           container::setDcPhaseStopAngle)),
125 
126     /** Maneuver elements of information. */
127     MAN_COMPOSITION((token, context, container) -> token.processAsEnumsList(ManeuverFieldType.class, container::setManComposition)),
128 
129     /** SI units for each elements of the maneuver. */
130     MAN_UNITS((token, context, container) -> token.processAsUnitList(container::setManUnits));
131 
132     /** Processing method. */
133     private final TokenProcessor processor;
134 
135     /** Simple constructor.
136      * @param processor processing method
137      */
138     ManeuverHistoryMetadataKey(final TokenProcessor processor) {
139         this.processor = processor;
140     }
141 
142     /** Process an token.
143      * @param token token to process
144      * @param context context binding
145      * @param container container to fill
146      * @return true of token was accepted
147      */
148     public boolean process(final ParseToken token, final ContextBinding context, final ManeuverHistoryMetadata container) {
149         return processor.process(token, context, container);
150     }
151 
152     /** Interface for processing one token. */
153     interface TokenProcessor {
154         /** Process one token.
155          * @param token token to process
156          * @param context context binding
157          * @param container container to fill
158          * @return true of token was accepted
159          */
160         boolean process(ParseToken token, ContextBinding context, ManeuverHistoryMetadata container);
161     }
162 
163 }