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.utils.ContextBinding;
20  import org.orekit.files.ccsds.utils.lexical.ParseToken;
21  import org.orekit.utils.units.Unit;
22  
23  
24  /** Keys for {@link OcmMetadata OCM container} entries.
25   * @author Luc Maisonobe
26   * @since 11.0
27   */
28  public enum OcmMetadataKey {
29  
30      /** International designator for the object as assigned by the UN Committee
31       * on Space Research (COSPAR) and the US National Space Science Data Center (NSSDC). */
32      INTERNATIONAL_DESIGNATOR((token, context, container) -> token.processAsNormalizedString(container::setInternationalDesignator)),
33  
34      /** Specification of satellite catalog source. */
35      CATALOG_NAME((token, context, container) -> token.processAsNormalizedString(container::setCatalogName)),
36  
37      /** Unique satellite identification designator for the object. */
38      OBJECT_DESIGNATOR((token, context, container) -> token.processAsNormalizedString(container::setObjectDesignator)),
39  
40      /** Alternate names fir this space object. */
41      ALTERNATE_NAMES((token, context, container) -> token.processAsNormalizedList(container::setAlternateNames)),
42  
43      /** Programmatic Point Of Contact at originator. */
44      ORIGINATOR_POC((token, context, container) -> token.processAsFreeTextString(container::setOriginatorPOC)),
45  
46      /** Position of Programmatic Point Of Contact at originator. */
47      ORIGINATOR_POSITION((token, context, container) -> token.processAsFreeTextString(container::setOriginatorPosition)),
48  
49      /** Phone number of Programmatic Point Of Contact at originator. */
50      ORIGINATOR_PHONE((token, context, container) -> token.processAsFreeTextString(container::setOriginatorPhone)),
51  
52      /** Email address of Programmatic Point Of Contact at originator.
53       * @since 11.2
54       */
55      ORIGINATOR_EMAIL((token, context, container) -> token.processAsFreeTextString(container::setOriginatorEmail)),
56  
57      /** Address of Programmatic Point Of Contact at originator. */
58      ORIGINATOR_ADDRESS((token, context, container) -> token.processAsFreeTextString(container::setOriginatorAddress)),
59  
60      /** Creating agency or operator. */
61      TECH_ORG((token, context, container) -> token.processAsFreeTextString(container::setTechOrg)),
62  
63      /** Technical Point Of Contact at originator. */
64      TECH_POC((token, context, container) -> token.processAsFreeTextString(container::setTechPOC)),
65  
66      /** Position of Technical Point Of Contact at originator. */
67      TECH_POSITION((token, context, container) -> token.processAsFreeTextString(container::setTechPosition)),
68  
69      /** Phone number of Technical Point Of Contact at originator. */
70      TECH_PHONE((token, context, container) -> token.processAsFreeTextString(container::setTechPhone)),
71  
72      /** Email address of Technical Point Of Contact at originator.
73       * @since 11.2
74       */
75      TECH_EMAIL((token, context, container) -> token.processAsFreeTextString(container::setTechEmail)),
76  
77      /** Address of Technical Point Of Contact at originator. */
78      TECH_ADDRESS((token, context, container) -> token.processAsFreeTextString(container::setTechAddress)),
79  
80      /** Unique ID identifying previous message from a given originator. */
81      PREVIOUS_MESSAGE_ID((token, context, container) -> token.processAsFreeTextString(container::setPreviousMessageID)),
82  
83      /** Unique ID identifying next message from a given originator. */
84      NEXT_MESSAGE_ID((token, context, container) -> token.processAsFreeTextString(container::setNextMessageID)),
85  
86      /** Unique identifier of Attitude Data Message linked to this Orbit Data Message. */
87      ADM_MSG_LINK((token, context, container) -> token.processAsFreeTextString(container::setAdmMessageLink)),
88  
89      /** Unique identifier of Conjunction Data Message linked to this Orbit Data Message. */
90      CDM_MSG_LINK((token, context, container) -> token.processAsFreeTextString(container::setCdmMessageLink)),
91  
92      /** Unique identifier of Pointing Request Message linked to this Orbit Data Message. */
93      PRM_MSG_LINK((token, context, container) -> token.processAsFreeTextString(container::setPrmMessageLink)),
94  
95      /** Unique identifier of Reentry Data Message linked to this Orbit Data Message. */
96      RDM_MSG_LINK((token, context, container) -> token.processAsFreeTextString(container::setRdmMessageLink)),
97  
98      /** Unique identifier of Tracking Data Message linked to this Orbit Data Message. */
99      TDM_MSG_LINK((token, context, container) -> token.processAsFreeTextString(container::setTdmMessageLink)),
100 
101     /** Operator of the space object. */
102     OPERATOR((token, context, container) -> token.processAsFreeTextString(container::setOperator)),
103 
104     /** Owner of the space object. */
105     OWNER((token, context, container) -> token.processAsFreeTextString(container::setOwner)),
106 
107     /** Name of the country where the space object owner is based. */
108     COUNTRY((token, context, container) -> token.processAsFreeTextString(container::setCountry)),
109 
110     /** Name of the constellation this space object belongs to. */
111     CONSTELLATION((token, context, container) -> token.processAsFreeTextString(container::setConstellation)),
112 
113     /** Type of object.
114      * @see ObjectType
115      */
116     OBJECT_TYPE((token, context, container) -> token.processAsEnum(ObjectType.class, container::setObjectType)),
117 
118     /** Default epoch to which <em>all</em> relative times are referenced in data blocks,
119      * unless overridden by block-specific {@link #EPOCH_TZERO} values. */
120     EPOCH_TZERO((token, context, container) -> token.processAsDate(container::setEpochT0, context)),
121 
122     /** Operational status.
123      * @see OpsStatus
124      */
125     OPS_STATUS((token, context, container) -> token.processAsEnum(OpsStatus.class, container::setOpsStatus)),
126 
127     /** Orbit category.
128      * @see OrbitCategory
129      */
130     ORBIT_CATEGORY((token, context, container) -> token.processAsEnum(OrbitCategory.class, container::setOrbitCategory)),
131 
132     /** List of elements of information data blocks included in this message. */
133     OCM_DATA_ELEMENTS((token, context, container) -> token.processAsEnumsList(OcmElements.class, container::setOcmDataElements)),
134 
135     /** Spacecraft clock count at {@link #EPOCH_TZERO}. */
136     SCLK_OFFSET_AT_EPOCH((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
137                                                                               container::setSclkOffsetAtEpoch)),
138 
139     /** Number of clock seconds occurring during one SI second. */
140     SCLK_SEC_PER_SI_SEC((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
141                                                                              container::setSclkSecPerSISec)),
142 
143     /** Creation date of previous message from a given originator. */
144     PREVIOUS_MESSAGE_EPOCH((token, context, container) -> token.processAsDate(container::setPreviousMessageEpoch, context)),
145 
146     /** Creation date of next message from a given originator. */
147     NEXT_MESSAGE_EPOCH((token, context, container) -> token.processAsDate(container::setNextMessageEpoch, context)),
148 
149     /** Start time entry. */
150     START_TIME((token, context, container) -> token.processAsDate(container::setStartTime, context)),
151 
152     /** Stop time entry. */
153     STOP_TIME((token, context, container) -> token.processAsDate(container::setStopTime, context)),
154 
155     /** Span of time that the OCM covers. */
156     TIME_SPAN((token, context, container) -> token.processAsDouble(Unit.DAY, context.getParsedUnitsBehavior(),
157                                                                    container::setTimeSpan)),
158 
159     /** Difference (TAI – UTC) in seconds at epoch {@link #EPOCH_TZERO}. */
160     TAIMUTC_AT_TZERO((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
161                                                                           container::setTaimutcT0)),
162 
163     /** Epoch of next leap second.
164      * @since 11.2
165      */
166     NEXT_LEAP_EPOCH((token, context, container) -> token.processAsDate(container::setNextLeapEpoch, context)),
167 
168     /** Difference (TAI – UTC) in seconds incorporated at {@link #NEXT_LEAP_EPOCH}.
169      * @since 11.2
170      */
171     NEXT_LEAP_TAIMUTC((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
172                                                                            container::setNextLeapTaimutc)),
173 
174     /** Difference (UT1 – UTC) in seconds at epoch {@link #EPOCH_TZERO}. */
175     UT1MUTC_AT_TZERO((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
176                                                                           container::setUt1mutcT0)),
177 
178     /** Source and version of Earth Orientation Parameters. */
179     EOP_SOURCE((token, context, container) -> token.processAsFreeTextString(container::setEopSource)),
180 
181     /** Interpolation method for Earth Orientation Parameters. */
182     INTERP_METHOD_EOP((token, context, container) -> token.processAsNormalizedString(container::setInterpMethodEOP)),
183 
184     /** Source and version of celestial body (e.g. Sun/Earth/Planetary). */
185     CELESTIAL_SOURCE((token, context, container) -> token.processAsFreeTextString(container::setCelestialSource));
186 
187     /** Processing method. */
188     private final transient TokenProcessor processor;
189 
190     /** Simple constructor.
191      * @param processor processing method
192      */
193     OcmMetadataKey(final TokenProcessor processor) {
194         this.processor = processor;
195     }
196 
197     /** Process an token.
198      * @param token token to process
199      * @param context context binding
200      * @param container container to fill
201      * @return true of token was accepted
202      */
203     public boolean process(final ParseToken token, final ContextBinding context, final OcmMetadata container) {
204         return processor.process(token, context, container);
205     }
206 
207     /** Interface for processing one token. */
208     interface TokenProcessor {
209         /** Process one token.
210          * @param token token to process
211          * @param context context binding
212          * @param container container to fill
213          * @return true of token was accepted
214          */
215         boolean process(ParseToken token, ContextBinding context, OcmMetadata container);
216     }
217 
218 }