1 /* Copyright 2002-2016 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 18 package org.orekit.files.ccsds; 19 20 import java.util.ArrayList; 21 import java.util.Collections; 22 import java.util.List; 23 24 import org.orekit.errors.OrekitException; 25 import org.orekit.errors.OrekitMessages; 26 import org.orekit.files.general.OrbitFile; 27 import org.orekit.files.general.SatelliteTimeCoordinate; 28 import org.orekit.time.AbsoluteDate; 29 import org.orekit.utils.IERSConventions; 30 31 /** 32 * The ODMFile (Orbit Data Message) class represents any of the three orbit messages used by the CCSDS, 33 * i.e. the Orbit Parameter Message (OPM), the Mean-Elements Message (OMM) and the Orbit Ephemeris Message (OEM). 34 * It contains the information of the message's header and configuration data (set in the parser). 35 * @author sports 36 * @since 6.1 37 */ 38 public abstract class ODMFile implements OrbitFile { 39 40 /** CCSDS Format version. */ 41 private double formatVersion; 42 43 /** Header comments. The list contains a string for each line of comment. */ 44 private List<String> headerComment; 45 46 /** File creation date and time in UTC. */ 47 private AbsoluteDate creationDate; 48 49 /** Creating agency or operator. */ 50 private String originator; 51 52 /** Gravitational coefficient set by the user in the parser. */ 53 private double muSet; 54 55 /** Gravitational coefficient parsed in the ODM File. */ 56 private double muParsed; 57 58 /** Gravitational coefficient created from the knowledge of the central body. */ 59 private double muCreated; 60 61 /** IERS conventions used. */ 62 private IERSConventions conventions; 63 64 /** Final gravitational coefficient (used for the public methods that need such a parameter, ex: generateCartesianOrbit). 65 * In order of decreasing priority, finalMU is equal to: the coefficient parsed in the file, the coefficient set by the 66 * user with the parser's method setMu, the coefficient created from the knowledge of the central body. 67 */ 68 private double muUsed; 69 70 /** Initial Date for MET or MRT time systems. */ 71 private AbsoluteDate missionReferenceDate; 72 73 /** ODMFile constructor. */ 74 public ODMFile() { 75 muSet = Double.NaN; 76 muParsed = Double.NaN; 77 muCreated = Double.NaN; 78 muUsed = Double.NaN; 79 } 80 81 /** 82 * Get the gravitational coefficient set by the user. 83 * @return the coefficient 84 */ 85 public double getMuSet() { 86 return muSet; 87 } 88 89 /** 90 * Set the gravitational coefficient set by the user. 91 * @param muSet the coefficient to be set 92 */ 93 void setMuSet(final double muSet) { 94 this.muSet = muSet; 95 } 96 97 /** 98 * Get the gravitational coefficient parsed in the ODM File. 99 * @return the coefficient 100 */ 101 public double getMuParsed() { 102 return muParsed; 103 } 104 105 /** 106 * Set the gravitational coefficient parsed in the ODM File. 107 * @param muParsed the coefficient to be set 108 */ 109 void setMuParsed(final double muParsed) { 110 this.muParsed = muParsed; 111 } 112 113 /** 114 * Get the gravitational coefficient created from the knowledge of the central body. 115 * @return the coefficient 116 */ 117 public double getMuCreated() { 118 return muCreated; 119 } 120 121 /** 122 * Set the gravitational coefficient created from the knowledge of the central body. 123 * @param muCreated the coefficient to be set 124 */ 125 void setMuCreated(final double muCreated) { 126 this.muCreated = muCreated; 127 } 128 129 /** 130 * Get the used gravitational coefficient. 131 * @return the coefficient 132 */ 133 public double getMuUsed() { 134 return muUsed; 135 } 136 137 /** 138 * Set the gravitational coefficient created from the knowledge of the central body. 139 * In order of decreasing priority, finalMU is set equal to: 140 * <ol> 141 * <li>the coefficient parsed in the file,</li> 142 * <li>the coefficient set by the user with the parser's method setMu,</li> 143 * <li>the coefficient created from the knowledge of the central body.</li> 144 * </ol> 145 * @throws OrekitException if no gravitational coefficient can be found 146 */ 147 protected void setMuUsed() throws OrekitException { 148 if (!Double.isNaN(muParsed)) { 149 muUsed = muParsed; 150 } else if (!Double.isNaN(muSet)) { 151 muUsed = muSet; 152 } else if (!Double.isNaN(muCreated)) { 153 muUsed = muCreated; 154 } else { 155 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_GM); 156 } 157 } 158 159 /** Get IERS conventions. 160 * @return conventions IERS conventions 161 * @exception OrekitException if no IERS conventions have been set 162 */ 163 public IERSConventions getConventions() throws OrekitException { 164 if (conventions != null) { 165 return conventions; 166 } else { 167 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS); 168 } 169 } 170 171 /** Set IERS conventions. 172 * @param conventions IERS conventions to be set 173 */ 174 void setConventions(final IERSConventions conventions) { 175 this.conventions = conventions; 176 } 177 178 /** Get reference date for Mission Elapsed Time and Mission Relative Time time systems. 179 * @return the reference date 180 */ 181 public AbsoluteDate getMissionReferenceDate() { 182 return missionReferenceDate; 183 } 184 185 /** Set reference date for Mission Elapsed Time and Mission Relative Time time systems. 186 * @param missionReferenceDate reference date for Mission Elapsed Time and Mission Relative Time time systems. 187 */ 188 void setMissionReferenceDate(final AbsoluteDate missionReferenceDate) { 189 this.missionReferenceDate = missionReferenceDate; 190 } 191 192 /** Get the CCSDS ODM (OPM, OMM or OEM) format version. 193 * @return format version 194 */ 195 public double getFormatVersion() { 196 return formatVersion; 197 } 198 199 /** Set the CCSDS ODM (OPM, OMM or OEM) format version. 200 * @param formatVersion the format version to be set 201 */ 202 void setFormatVersion(final double formatVersion) { 203 this.formatVersion = formatVersion; 204 } 205 206 /** Get the header comment. 207 * @return header comment 208 */ 209 public List<String> getHeaderComment() { 210 return headerComment; 211 } 212 213 /** Set the header comment. 214 * @param headerComment header comment 215 */ 216 void setHeaderComment(final List<String> headerComment) { 217 this.headerComment = new ArrayList<String>(headerComment); 218 } 219 220 /** Get the file creation date and time in UTC. 221 * @return the file creation date and time in UTC. 222 */ 223 public AbsoluteDate getCreationDate() { 224 return creationDate; 225 } 226 227 /** Set the file creation date and time in UTC. 228 * @param creationDate the creation date to be set 229 */ 230 void setCreationDate(final AbsoluteDate creationDate) { 231 this.creationDate = creationDate; 232 } 233 234 /** Get the file originator. 235 * @return originator the file originator. 236 */ 237 public String getOriginator() { 238 return originator; 239 } 240 241 /** Set the file originator. 242 * @param originator the originator to be set 243 */ 244 void setOriginator(final String originator) { 245 this.originator = originator; 246 } 247 248 /** 249 * Not supported by CCSDS orbit messages. 250 * @return always throws an {@link UnsupportedOperationException} 251 * @throws UnsupportedOperationException always 252 */ 253 @Override 254 public double getEpochInterval() { 255 throw new UnsupportedOperationException(); 256 } 257 258 /** 259 * Not supported by CCSDS orbit messages. 260 * @return always throws an {@link UnsupportedOperationException} 261 * @throws UnsupportedOperationException always 262 */ 263 @Override 264 public int getNumberOfEpochs() { 265 throw new UnsupportedOperationException(); 266 } 267 268 /** {@inheritDoc} */ 269 @Override 270 public boolean containsSatellite(final String satId) { 271 return getSatellite(satId) != null; 272 } 273 274 /** {@inheritDoc} */ 275 @Override 276 public List<SatelliteTimeCoordinate> getSatelliteCoordinates(final String satId) { 277 return Collections.emptyList(); 278 } 279 280 } 281