Acm.java

  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. import java.util.Collections;
  19. import java.util.List;
  20. import java.util.Map;

  21. import org.orekit.data.DataContext;
  22. import org.orekit.files.ccsds.ndm.NdmConstituent;
  23. import org.orekit.files.ccsds.ndm.adm.AdmHeader;
  24. import org.orekit.files.ccsds.section.Segment;
  25. import org.orekit.files.general.AttitudeEphemerisFile;
  26. import org.orekit.utils.IERSConventions;
  27. import org.orekit.utils.TimeStampedAngularCoordinates;

  28. /** This class gathers the informations present in the Attitude Comprehensive Message (ACM).
  29.  * @author Luc Maisonobe
  30.  * @since 12.0
  31.  */
  32. public class Acm extends NdmConstituent<AdmHeader, Segment<AcmMetadata, AcmData>>
  33.     implements AttitudeEphemerisFile<TimeStampedAngularCoordinates, AttitudeStateHistory> {

  34.     /** Root element for XML messages. */
  35.     public static final String ROOT = "acm";

  36.     /** Key for format version. */
  37.     public static final String FORMAT_VERSION_KEY = "CCSDS_ACM_VERS";

  38.     /** Attitude line element for XML messages. */
  39.     public static final String ATT_LINE = "attLine";

  40.     /** Covariance line element for XML messages. */
  41.     public static final String COV_LINE = "covLine";

  42.     /** Default name for unknown object. */
  43.     public static final String UNKNOWN_OBJECT = "UNKNOWN";

  44.     /** Simple constructor.
  45.      * @param header file header
  46.      * @param segments ile segments
  47.      * @param conventions IERS conventions
  48.      * @param dataContext used for creating frames, time scales, etc.
  49.      */
  50.     public Acm(final AdmHeader header, final List<Segment<AcmMetadata, AcmData>> segments,
  51.                final IERSConventions conventions, final DataContext dataContext) {
  52.         super(header, segments, conventions, dataContext);
  53.     }

  54.     /** Get the metadata from the single {@link #getSegments() segment}.
  55.      * @return metadata from the single {@link #getSegments() segment}
  56.      */
  57.     public AcmMetadata getMetadata() {
  58.         return getSegments().get(0).getMetadata();
  59.     }

  60.     /** Get the data from the single {@link #getSegments() segment}.
  61.      * @return data from the single {@link #getSegments() segment}
  62.      */
  63.     public AcmData getData() {
  64.         return getSegments().get(0).getData();
  65.     }

  66.     /** {@inheritDoc} */
  67.     @Override
  68.     public Map<String, AcmSatelliteEphemeris> getSatellites() {
  69.         // the ACM file has only one segment and a deep structure
  70.         // the real ephemeris is buried within the attitude state time history logical block
  71.         final String name;
  72.         if (getMetadata().getObjectName() != null) {
  73.             name = getMetadata().getObjectName();
  74.         } else if (getMetadata().getInternationalDesignator() != null) {
  75.             name = getMetadata().getInternationalDesignator();
  76.         } else if (getMetadata().getObjectDesignator() != null) {
  77.             name = getMetadata().getObjectDesignator();
  78.         } else {
  79.             name = UNKNOWN_OBJECT;
  80.         }
  81.         final List<AttitudeStateHistory> histories = getSegments().get(0).getData().getAttitudeBlocks();
  82.         return (histories == null) ?
  83.                Collections.emptyMap() :
  84.                Collections.singletonMap(name, new AcmSatelliteEphemeris(name, histories));
  85.     }

  86. }