ODMFile.java

  1. /* Copyright 2002-2020 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;

  18. import java.util.ArrayList;
  19. import java.util.List;

  20. import org.orekit.data.DataContext;
  21. import org.orekit.errors.OrekitException;
  22. import org.orekit.errors.OrekitMessages;
  23. import org.orekit.time.AbsoluteDate;
  24. import org.orekit.utils.IERSConventions;

  25. /**
  26.  * The ODMFile (Orbit Data Message) class represents any of the three orbit messages used by the CCSDS,
  27.  * i.e. the Orbit Parameter Message (OPM), the Mean-Elements Message (OMM) and the Orbit Ephemeris Message (OEM).
  28.  * It contains the information of the message's header and configuration data (set in the parser).
  29.  * @author sports
  30.  * @since 6.1
  31.  */
  32. public abstract class ODMFile {

  33.     /** CCSDS Format version. */
  34.     private double formatVersion;

  35.     /** Header comments. The list contains a string for each line of comment. */
  36.     private List<String> headerComment;

  37.     /** File creation date and time in UTC. */
  38.     private AbsoluteDate creationDate;

  39.     /** Creating agency or operator. */
  40.     private String originator;

  41.     /** Gravitational coefficient set by the user in the parser. */
  42.     private double muSet;

  43.     /** Gravitational coefficient parsed in the ODM File. */
  44.     private double muParsed;

  45.     /** Gravitational coefficient created from the knowledge of the central body. */
  46.     private double muCreated;

  47.     /** IERS conventions used. */
  48.     private IERSConventions conventions;

  49.     /** Final gravitational coefficient (used for the public methods that need such a parameter, ex: generateCartesianOrbit).
  50.      * In order of decreasing priority, finalMU is equal to: the coefficient parsed in the file, the coefficient set by the
  51.      * user with the parser's method setMu, the coefficient created from the knowledge of the central body.
  52.      */
  53.     private double muUsed;

  54.     /** Initial Date for MET or MRT time systems. */
  55.     private AbsoluteDate missionReferenceDate;

  56.     /** Data context. */
  57.     private DataContext dataContext;

  58.     /** ODMFile constructor. */
  59.     public ODMFile() {
  60.         muSet     = Double.NaN;
  61.         muParsed  = Double.NaN;
  62.         muCreated = Double.NaN;
  63.         muUsed    = Double.NaN;
  64.     }

  65.     /**
  66.      * Get the gravitational coefficient set by the user.
  67.      * @return the coefficient
  68.      */
  69.     public double getMuSet() {
  70.         return muSet;
  71.     }

  72.     /**
  73.      * Set the gravitational coefficient set by the user.
  74.      * @param muSet the coefficient to be set
  75.      */
  76.     void setMuSet(final double muSet) {
  77.         this.muSet = muSet;
  78.     }

  79.     /**
  80.      * Get the gravitational coefficient parsed in the ODM File.
  81.      * @return the coefficient
  82.      */
  83.     public double getMuParsed() {
  84.         return muParsed;
  85.     }

  86.     /**
  87.      * Set the gravitational coefficient parsed in the ODM File.
  88.      * @param muParsed the coefficient to be set
  89.      */
  90.     void setMuParsed(final double muParsed) {
  91.         this.muParsed = muParsed;
  92.     }

  93.     /**
  94.      * Get the gravitational coefficient created from the knowledge of the central body.
  95.      * @return the coefficient
  96.      */
  97.     public double getMuCreated() {
  98.         return muCreated;
  99.     }

  100.     /**
  101.      * Set the gravitational coefficient created from the knowledge of the central body.
  102.      * @param muCreated the coefficient to be set
  103.      */
  104.     void setMuCreated(final double muCreated) {
  105.         this.muCreated = muCreated;
  106.     }

  107.     /**
  108.      * Get the used gravitational coefficient.
  109.      * @return the coefficient
  110.      */
  111.     public double getMuUsed() {
  112.         return muUsed;
  113.     }

  114.     /**
  115.      * Set the gravitational coefficient created from the knowledge of the central body.
  116.      * In order of decreasing priority, finalMU is set equal to:
  117.      * <ol>
  118.      *   <li>the coefficient parsed in the file,</li>
  119.      *   <li>the coefficient set by the user with the parser's method setMu,</li>
  120.      *   <li>the coefficient created from the knowledge of the central body.</li>
  121.      * </ol>
  122.      */
  123.     protected void setMuUsed() {
  124.         if (!Double.isNaN(muParsed)) {
  125.             muUsed = muParsed;
  126.         } else if (!Double.isNaN(muSet)) {
  127.             muUsed = muSet;
  128.         } else if (!Double.isNaN(muCreated)) {
  129.             muUsed = muCreated;
  130.         } else {
  131.             throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_GM);
  132.         }
  133.     }

  134.     /** Get IERS conventions.
  135.      * @return conventions IERS conventions
  136.      */
  137.     public IERSConventions getConventions() {
  138.         if (conventions != null) {
  139.             return conventions;
  140.         } else {
  141.             throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  142.         }
  143.     }

  144.     /** Set IERS conventions.
  145.      * @param conventions IERS conventions to be set
  146.      */
  147.     void setConventions(final IERSConventions conventions) {
  148.         this.conventions = conventions;
  149.     }

  150.     /** Get reference date for Mission Elapsed Time and Mission Relative Time time systems.
  151.      * @return the reference date
  152.      */
  153.     public AbsoluteDate getMissionReferenceDate() {
  154.         return missionReferenceDate;
  155.     }

  156.     /** Set reference date for Mission Elapsed Time and Mission Relative Time time systems.
  157.      * @param missionReferenceDate reference date for Mission Elapsed Time and Mission Relative Time time systems.
  158.      */
  159.     void setMissionReferenceDate(final AbsoluteDate missionReferenceDate) {
  160.         this.missionReferenceDate = missionReferenceDate;
  161.     }

  162.     /** Get the CCSDS ODM (OPM, OMM or OEM) format version.
  163.      * @return format version
  164.      */
  165.     public double getFormatVersion() {
  166.         return formatVersion;
  167.     }

  168.     /** Set the CCSDS ODM (OPM, OMM or OEM) format version.
  169.      * @param formatVersion the format version to be set
  170.      */
  171.     void setFormatVersion(final double formatVersion) {
  172.         this.formatVersion = formatVersion;
  173.     }

  174.     /** Get the header comment.
  175.      * @return header comment
  176.      */
  177.     public List<String> getHeaderComment() {
  178.         return headerComment;
  179.     }

  180.     /** Set the header comment.
  181.      * @param headerComment header comment
  182.      */
  183.     void setHeaderComment(final List<String> headerComment) {
  184.         this.headerComment = new ArrayList<String>(headerComment);
  185.     }

  186.     /** Get the file creation date and time in UTC.
  187.      * @return the file creation date and time in UTC.
  188.      */
  189.     public AbsoluteDate getCreationDate() {
  190.         return creationDate;
  191.     }

  192.     /** Set the file creation date and time in UTC.
  193.      * @param creationDate the creation date to be set
  194.      */
  195.     void setCreationDate(final AbsoluteDate creationDate) {
  196.         this.creationDate = creationDate;
  197.     }

  198.     /** Get the file originator.
  199.      * @return originator the file originator.
  200.      */
  201.     public String getOriginator() {
  202.         return originator;
  203.     }

  204.     /** Set the file originator.
  205.      * @param originator the originator to be set
  206.      */
  207.     void setOriginator(final String originator) {
  208.         this.originator = originator;
  209.     }

  210.     /**
  211.      * Get the data context.
  212.      *
  213.      * @return the data context used for creating frames, time scales, etc.
  214.      */
  215.     public DataContext getDataContext() {
  216.         return dataContext;
  217.     }

  218.     /**
  219.      * Set the data context.
  220.      *
  221.      * @param dataContext used for creating frames, time scales, etc.
  222.      */
  223.     void setDataContext(final DataContext dataContext) {
  224.         this.dataContext = dataContext;
  225.     }

  226. }