ODMFile.java

  1. /* Copyright 2002-2018 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.errors.OrekitException;
  21. import org.orekit.errors.OrekitMessages;
  22. import org.orekit.time.AbsoluteDate;
  23. import org.orekit.utils.IERSConventions;

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

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

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

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

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

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

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

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

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

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

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

  55.     /** ODMFile constructor. */
  56.     public ODMFile() {
  57.         muSet     = Double.NaN;
  58.         muParsed  = Double.NaN;
  59.         muCreated = Double.NaN;
  60.         muUsed    = Double.NaN;
  61.     }

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

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

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

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

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

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

  104.     /**
  105.      * Get the used gravitational coefficient.
  106.      * @return the coefficient
  107.      */
  108.     public double getMuUsed() {
  109.         return muUsed;
  110.     }

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

  132.     /** Get IERS conventions.
  133.      * @return conventions IERS conventions
  134.      * @exception OrekitException if no IERS conventions have been set
  135.      */
  136.     public IERSConventions getConventions() throws OrekitException {
  137.         if (conventions != null) {
  138.             return conventions;
  139.         } else {
  140.             throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
  141.         }
  142.     }

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

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

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

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

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

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

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

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

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

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

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

  209. }