OpmData.java

  1. /* Copyright 2002-2024 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.ndm.odm.opm;

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

  20. import org.orekit.files.ccsds.ndm.odm.CartesianCovariance;
  21. import org.orekit.files.ccsds.ndm.odm.KeplerianElements;
  22. import org.orekit.files.ccsds.ndm.odm.KeplerianElementsKey;
  23. import org.orekit.files.ccsds.ndm.odm.SpacecraftParameters;
  24. import org.orekit.files.ccsds.ndm.odm.StateVector;
  25. import org.orekit.files.ccsds.ndm.odm.UserDefined;
  26. import org.orekit.files.ccsds.section.Data;

  27. /**
  28.  * Container for Orbit Parameter Message data.
  29.  * @author Luc Maisonobe
  30.  * @since 11.0
  31.  */
  32. public class OpmData implements Data {

  33.     /** State vector block. */
  34.     private final  StateVector stateVectorBlock;

  35.     /** Keplerian elements block. */
  36.     private final KeplerianElements keplerianElementsBlock;

  37.     /** Spacecraft parameters block. */
  38.     private final SpacecraftParameters spacecraftParametersBlock;

  39.     /** Covariance matrix logical block being read. */
  40.     private final CartesianCovariance covarianceBlock;

  41.     /** Maneuvers. */
  42.     private final List<Maneuver> maneuverBlocks;

  43.     /** User defined parameters. */
  44.     private final UserDefined userDefinedBlock;

  45.     /** Mass. */
  46.     private final double mass;

  47.     /** Simple constructor.
  48.      * @param stateVectorBlock state vector logical block
  49.      * @param keplerianElementsBlock Keplerian elements logical block (may be null)
  50.      * @param spacecraftParametersBlock spacecraft parameters logical block (may be null)
  51.      * @param covarianceBlock covariance matrix logical block (may be null)
  52.      * @param maneuverBlocks maneuvers block list
  53.      * @param userDefinedBlock user-defined logical block
  54.      * @param mass mass (always defined, even if there is no {@code spacecraftParameters} block
  55.      */
  56.     public OpmData(final StateVector stateVectorBlock,
  57.                    final KeplerianElements keplerianElementsBlock,
  58.                    final SpacecraftParameters spacecraftParametersBlock,
  59.                    final CartesianCovariance covarianceBlock,
  60.                    final List<Maneuver> maneuverBlocks,
  61.                    final UserDefined userDefinedBlock,
  62.                    final double mass) {
  63.         this.stateVectorBlock          = stateVectorBlock;
  64.         this.keplerianElementsBlock    = keplerianElementsBlock;
  65.         this.spacecraftParametersBlock = spacecraftParametersBlock;
  66.         this.covarianceBlock           = covarianceBlock;
  67.         this.maneuverBlocks            = maneuverBlocks;
  68.         this.userDefinedBlock          = userDefinedBlock;
  69.         this.mass                      = mass;
  70.     }

  71.     /** {@inheritDoc} */
  72.     @Override
  73.     public void validate(final double version) {
  74.         stateVectorBlock.validate(version);
  75.         if (keplerianElementsBlock != null) {
  76.             keplerianElementsBlock.validate(version);
  77.             // in OPM, only semi-major axis is allowed, not mean motion
  78.             keplerianElementsBlock.checkNotNaN(keplerianElementsBlock.getA(),
  79.                                                KeplerianElementsKey.SEMI_MAJOR_AXIS.name());
  80.         }
  81.         if (spacecraftParametersBlock != null) {
  82.             spacecraftParametersBlock.validate(version);
  83.         }
  84.         if (covarianceBlock != null) {
  85.             covarianceBlock.setEpoch(stateVectorBlock.getEpoch());
  86.             covarianceBlock.validate(version);
  87.         }
  88.         for (final Maneuver maneuver : maneuverBlocks) {
  89.             maneuver.validate(version);
  90.         }
  91.         if (userDefinedBlock != null) {
  92.             userDefinedBlock.validate(version);
  93.         }
  94.     }

  95.     /** Get the state vector logical block.
  96.      * @return state vector block
  97.      */
  98.     public StateVector getStateVectorBlock() {
  99.         return stateVectorBlock;
  100.     }

  101.     /** Get the Keplerian elements logical block.
  102.      * @return Keplerian elements block (may be null)
  103.      */
  104.     public KeplerianElements getKeplerianElementsBlock() {
  105.         return keplerianElementsBlock;
  106.     }

  107.     /** Get the spacecraft parameters logical block.
  108.      * @return spacecraft parameters block (may be null)
  109.      */
  110.     public SpacecraftParameters getSpacecraftParametersBlock() {
  111.         return spacecraftParametersBlock;
  112.     }

  113.     /** Get the covariance matrix logical block.
  114.      * @return covariance matrix block (may be null)
  115.      */
  116.     public CartesianCovariance getCovarianceBlock() {
  117.         return covarianceBlock;
  118.     }

  119.     /** Get the mass.
  120.      * @return mass
  121.      */
  122.     public double getMass() {
  123.         return mass;
  124.     }

  125.     /**
  126.      * Get the number of maneuvers present in the APM.
  127.      * @return the number of maneuvers
  128.      */
  129.     public int getNbManeuvers() {
  130.         return maneuverBlocks.size();
  131.     }

  132.     /**
  133.      * Get a list of all maneuvers.
  134.      * @return unmodifiable list of all maneuvers.
  135.      */
  136.     public List<Maneuver> getManeuvers() {
  137.         return Collections.unmodifiableList(maneuverBlocks);
  138.     }

  139.     /**
  140.      * Get a maneuver.
  141.      * @param index maneuver index, counting from 0
  142.      * @return maneuver
  143.      */
  144.     public Maneuver getManeuver(final int index) {
  145.         return maneuverBlocks.get(index);
  146.     }

  147.     /**
  148.      * Get boolean testing whether the APM contains at least one maneuver.
  149.      * @return true if APM contains at least one maneuver
  150.      *         false otherwise
  151.      */
  152.     public boolean hasManeuvers() {
  153.         return !maneuverBlocks.isEmpty();
  154.     }

  155.     /** Get the user defined parameters logical block.
  156.      * @return user defined parameters block (may be null)
  157.      */
  158.     public UserDefined getUserDefinedBlock() {
  159.         return userDefinedBlock;
  160.     }

  161. }