1   /* Copyright 2022-2025 Luc Maisonobe
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.adm.acm;
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 AcmMetadata ACM container} entries.
25   * @author Luc Maisonobe
26   * @since 12.0
27   */
28  public enum AcmMetadataKey {
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      /** Programmatic Point Of Contact at originator. */
41      ORIGINATOR_POC((token, context, container) -> token.processAsFreeTextString(container::setOriginatorPOC)),
42  
43      /** Position of Programmatic Point Of Contact at originator. */
44      ORIGINATOR_POSITION((token, context, container) -> token.processAsFreeTextString(container::setOriginatorPosition)),
45  
46      /** Phone number of Programmatic Point Of Contact at originator. */
47      ORIGINATOR_PHONE((token, context, container) -> token.processAsFreeTextString(container::setOriginatorPhone)),
48  
49      /** Email address of Programmatic Point Of Contact at originator. */
50      ORIGINATOR_EMAIL((token, context, container) -> token.processAsFreeTextString(container::setOriginatorEmail)),
51  
52      /** Address of Programmatic Point Of Contact at originator. */
53      ORIGINATOR_ADDRESS((token, context, container) -> token.processAsFreeTextString(container::setOriginatorAddress)),
54  
55      /** Unique identifier of Orbit Data Message linked to this Attitude Data Message. */
56      ODM_MSG_LINK((token, context, container) -> token.processAsFreeTextString(container::setOdmMessageLink)),
57  
58      /** Default epoch to which <em>all</em> relative times are referenced in data blocks,
59       * unless overridden by block-specific {@link #EPOCH_TZERO} values. */
60      EPOCH_TZERO((token, context, container) -> token.processAsDate(container::setEpochT0, context)),
61  
62      /** List of elements of information data blocks included in this message. */
63      ACM_DATA_ELEMENTS((token, context, container) -> token.processAsEnumsList(AcmElements.class, container::setAcmDataElements)),
64  
65      /** Start time entry. */
66      START_TIME((token, context, container) -> token.processAsDate(container::setStartTime, context)),
67  
68      /** Stop time entry. */
69      STOP_TIME((token, context, container) -> token.processAsDate(container::setStopTime, context)),
70  
71      /** Difference (TAI – UTC) in seconds at epoch {@link #EPOCH_TZERO}. */
72      TAIMUTC_AT_TZERO((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
73                                                                            container::setTaimutcT0)),
74  
75      /** Epoch of next leap second. */
76      NEXT_LEAP_EPOCH((token, context, container) -> token.processAsDate(container::setNextLeapEpoch, context)),
77  
78      /** Difference (TAI – UTC) in seconds incorporated at {@link #NEXT_LEAP_EPOCH}. */
79      NEXT_LEAP_TAIMUTC((token, context, container) -> token.processAsDouble(Unit.SECOND, context.getParsedUnitsBehavior(),
80                                                                             container::setNextLeapTaimutc));
81  
82      /** Processing method. */
83      private final transient TokenProcessor processor;
84  
85      /** Simple constructor.
86       * @param processor processing method
87       */
88      AcmMetadataKey(final TokenProcessor processor) {
89          this.processor = processor;
90      }
91  
92      /** Process an token.
93       * @param token token to process
94       * @param context context binding
95       * @param container container to fill
96       * @return true of token was accepted
97       */
98      public boolean process(final ParseToken token, final ContextBinding context, final AcmMetadata container) {
99          return processor.process(token, context, container);
100     }
101 
102     /** Interface for processing one token. */
103     interface TokenProcessor {
104         /** Process one token.
105          * @param token token to process
106          * @param context context binding
107          * @param container container to fill
108          * @return true of token was accepted
109          */
110         boolean process(ParseToken token, ContextBinding context, AcmMetadata container);
111     }
112 
113 }