ManeuverHistoryMetadata.java

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

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

  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.orekit.errors.OrekitException;
  22. import org.orekit.errors.OrekitMessages;
  23. import org.orekit.files.ccsds.definitions.BodyFacade;
  24. import org.orekit.files.ccsds.definitions.DutyCycleType;
  25. import org.orekit.files.ccsds.definitions.FrameFacade;
  26. import org.orekit.files.ccsds.definitions.OrbitRelativeFrame;
  27. import org.orekit.files.ccsds.definitions.SpacecraftBodyFrame;
  28. import org.orekit.files.ccsds.section.CommentsContainer;
  29. import org.orekit.time.AbsoluteDate;
  30. import org.orekit.utils.units.Unit;

  31. /** Metadata for maneuver history.
  32.  * @author Luc Maisonobe
  33.  * @since 11.0
  34.  */
  35. public class ManeuverHistoryMetadata extends CommentsContainer {

  36.     /** Maneuver identification number. */
  37.     private String manID;

  38.     /** Identification number of previous maneuver. */
  39.     private String manPrevID;

  40.     /** Identification number of next maneuver. */
  41.     private String manNextID;

  42.     /** Basis of this maneuver history data. */
  43.     private ManBasis manBasis;

  44.     /** Identification number of the orbit determination or simulation upon which this maneuver is based. */
  45.     private String manBasisID;

  46.     /** Identifier of the device used for this maneuver. */
  47.     private String manDeviceID;

  48.     /** Completion time of previous maneuver. */
  49.     private AbsoluteDate manPrevEpoch;

  50.     /** Start time of next maneuver. */
  51.     private AbsoluteDate manNextEpoch;

  52.     /** Reference frame of the maneuver. */
  53.     private FrameFacade manReferenceFrame;

  54.     /** Epoch of the maneuver reference frame. */
  55.     private AbsoluteDate manFrameEpoch;

  56.     /** Purposes of the maneuver. */
  57.     private List<String> manPurpose;

  58.     /** Prediction source on which this maneuver is based. */
  59.     private String manPredSource;

  60.     /** Origin of maneuver gravitational assist body. */
  61.     private BodyFacade gravitationalAssist;

  62.     /** Type of duty cycle. */
  63.     private DutyCycleType dcType;

  64.     /** Start time of duty cycle-based maneuver window. */
  65.     private AbsoluteDate dcWindowOpen;

  66.     /** End time of duty cycle-based maneuver window. */
  67.     private AbsoluteDate dcWindowClose;

  68.     /** Minimum number of "ON" duty cycles. */
  69.     private int dcMinCycles;

  70.     /** Maximum number of "ON" duty cycles. */
  71.     private int dcMaxCycles;

  72.     /** Start time of initial duty cycle-based maneuver execution. */
  73.     private AbsoluteDate dcExecStart;

  74.     /** End time of final duty cycle-based maneuver execution. */
  75.     private AbsoluteDate dcExecStop;

  76.     /** Duty cycle thrust reference time. */
  77.     private AbsoluteDate dcRefTime;

  78.     /** Duty cycle pulse "ON" duration. */
  79.     private double dcTimePulseDuration;

  80.     /** Duty cycle elapsed time between start of a pulse and start of next pulse. */
  81.     private double dcTimePulsePeriod;

  82.     /** Reference direction for triggering duty cycle. */
  83.     private Vector3D dcRefDir;

  84.     /** Spacecraft body frame in which {@link #dcBodyTrigger} is specified. */
  85.     private SpacecraftBodyFrame dcBodyFrame;

  86.     /** Direction in {@link #dcBodyFrame body frame} for triggering duty cycle. */
  87.     private Vector3D dcBodyTrigger;

  88.     /** Phase angle of pulse start. */
  89.     private double dcPhaseStartAngle;

  90.     /** Phase angle of pulse stop. */
  91.     private double dcPhaseStopAngle;

  92.     /** Maneuver elements of information. */
  93.     private List<ManeuverFieldType> manComposition;

  94.     /** Units of covariance element set. */
  95.     private List<Unit> manUnits;

  96.     /** Simple constructor.
  97.      * @param epochT0 T0 epoch from file metadata
  98.      */
  99.     ManeuverHistoryMetadata(final AbsoluteDate epochT0) {
  100.         // we don't call the setXxx() methods in order to avoid
  101.         // calling refuseFurtherComments as a side effect
  102.         manBasis            = ManBasis.PLANNED;
  103.         manReferenceFrame   = new FrameFacade(null, null,
  104.                                               OrbitRelativeFrame.TNW_INERTIAL, null,
  105.                                               OrbitRelativeFrame.TNW_INERTIAL.name());
  106.         manFrameEpoch       = epochT0;
  107.         manPurpose          = Collections.emptyList();
  108.         dcType              = DutyCycleType.CONTINUOUS;
  109.         dcMinCycles         = 0;
  110.         dcMaxCycles         = 0;
  111.         dcTimePulseDuration = Double.NaN;
  112.         dcTimePulsePeriod   = Double.NaN;
  113.     }

  114.     /** {@inheritDoc} */
  115.     @Override
  116.     public void validate(final double version) {
  117.         super.validate(version);
  118.         checkNotNull(manID,          ManeuverHistoryMetadataKey.MAN_ID);
  119.         checkNotNull(manDeviceID,    ManeuverHistoryMetadataKey.MAN_DEVICE_ID);

  120.         if (dcType != DutyCycleType.CONTINUOUS) {
  121.             checkNotNull(dcWindowOpen,       ManeuverHistoryMetadataKey.DC_WIN_OPEN);
  122.             checkNotNull(dcWindowClose,      ManeuverHistoryMetadataKey.DC_WIN_CLOSE);
  123.             checkNotNull(dcExecStart,        ManeuverHistoryMetadataKey.DC_EXEC_START);
  124.             checkNotNull(dcExecStop,         ManeuverHistoryMetadataKey.DC_EXEC_STOP);
  125.             checkNotNull(dcRefTime,          ManeuverHistoryMetadataKey.DC_REF_TIME);
  126.             checkNotNaN(dcTimePulseDuration, ManeuverHistoryMetadataKey.DC_TIME_PULSE_DURATION);
  127.             checkNotNaN(dcTimePulsePeriod,   ManeuverHistoryMetadataKey.DC_TIME_PULSE_PERIOD);
  128.         }
  129.         if (dcType == DutyCycleType.TIME_AND_ANGLE) {
  130.             checkNotNull(dcRefDir,           ManeuverHistoryMetadataKey.DC_REF_DIR);
  131.             checkNotNull(dcBodyFrame,        ManeuverHistoryMetadataKey.DC_BODY_FRAME);
  132.             checkNotNull(dcBodyTrigger,      ManeuverHistoryMetadataKey.DC_BODY_TRIGGER);
  133.             checkNotNull(dcPhaseStartAngle,  ManeuverHistoryMetadataKey.DC_PA_START_ANGLE);
  134.             checkNotNull(dcPhaseStopAngle,   ManeuverHistoryMetadataKey.DC_PA_STOP_ANGLE);
  135.         }

  136.         checkNotNull(manComposition, ManeuverHistoryMetadataKey.MAN_COMPOSITION);
  137.         if (!manComposition.get(0).isTime()) {
  138.             throw new OrekitException(OrekitMessages.CCSDS_MANEUVER_MISSING_TIME, manID);
  139.         }
  140.         final int firstNonTime = (manComposition.size() > 1 && manComposition.get(1).isTime()) ? 2 : 1;

  141.         if (manUnits != null) {
  142.             if (manUnits.size() != manComposition.size() - firstNonTime) {
  143.                 throw new OrekitException(OrekitMessages.CCSDS_MANEUVER_UNITS_WRONG_NB_COMPONENTS,
  144.                                           manID);
  145.             }
  146.             for (int i = 0; i < manUnits.size(); ++i) {
  147.                 manComposition.get(firstNonTime + i).checkUnit(manUnits.get(i));
  148.             }
  149.         }
  150.     }

  151.     /** Check if a field is a time field.
  152.      * @param Ma
  153.      */
  154.     /** Get maneuver identification number.
  155.      * @return maneuver identification number
  156.      */
  157.     public String getManID() {
  158.         return manID;
  159.     }

  160.     /** Set maneuver identification number.
  161.      * @param manID maneuver identification number
  162.      */
  163.     public void setManID(final String manID) {
  164.         refuseFurtherComments();
  165.         this.manID = manID;
  166.     }

  167.     /** Get identification number of previous maneuver.
  168.      * @return identification number of previous maneuver
  169.      */
  170.     public String getManPrevID() {
  171.         return manPrevID;
  172.     }

  173.     /** Set identification number of previous maneuver.
  174.      * @param manPrevID identification number of previous maneuver
  175.      */
  176.     public void setManPrevID(final String manPrevID) {
  177.         refuseFurtherComments();
  178.         this.manPrevID = manPrevID;
  179.     }

  180.     /** Get identification number of next maneuver.
  181.      * @return identification number of next maneuver
  182.      */
  183.     public String getManNextID() {
  184.         return manNextID;
  185.     }

  186.     /** Set identification number of next maneuver.
  187.      * @param manNextID identification number of next maneuver
  188.      */
  189.     public void setManNextID(final String manNextID) {
  190.         refuseFurtherComments();
  191.         this.manNextID = manNextID;
  192.     }

  193.     /** Get basis of this maneuver history data.
  194.      * @return basis of this maneuver history data
  195.      */
  196.     public ManBasis getManBasis() {
  197.         return manBasis;
  198.     }

  199.     /** Set basis of this maneuver history data.
  200.      * @param manBasis basis of this maneuver history data
  201.      */
  202.     public void setManBasis(final ManBasis manBasis) {
  203.         refuseFurtherComments();
  204.         this.manBasis = manBasis;
  205.     }

  206.     /** Get identification number of the orbit determination or simulation upon which this maneuver is based.
  207.      * @return identification number of the orbit determination or simulation upon which this maneuver is based
  208.      */
  209.     public String getManBasisID() {
  210.         return manBasisID;
  211.     }

  212.     /** Set identification number of the orbit determination or simulation upon which this maneuver is based.
  213.      * @param manBasisID identification number of the orbit determination or simulation upon which this maneuver is based
  214.      */
  215.     public void setManBasisID(final String manBasisID) {
  216.         refuseFurtherComments();
  217.         this.manBasisID = manBasisID;
  218.     }

  219.     /** Get identifier of the device used for this maneuver.
  220.      * @return identifier of the device used for this maneuver
  221.      */
  222.     public String getManDeviceID() {
  223.         return manDeviceID;
  224.     }

  225.     /** Set identifier of the device used for this maneuver.
  226.      * @param manDeviceID identifier of the device used for this maneuver
  227.      */
  228.     public void setManDeviceID(final String manDeviceID) {
  229.         refuseFurtherComments();
  230.         this.manDeviceID = manDeviceID;
  231.     }

  232.     /** Get completion time of previous maneuver.
  233.      * @return completion time of previous maneuver
  234.      */
  235.     public AbsoluteDate getManPrevEpoch() {
  236.         return manPrevEpoch;
  237.     }

  238.     /** Set completion time of previous maneuver.
  239.      * @param manPrevEpoch completion time of previous maneuver
  240.      */
  241.     public void setManPrevEpoch(final AbsoluteDate manPrevEpoch) {
  242.         refuseFurtherComments();
  243.         this.manPrevEpoch = manPrevEpoch;
  244.     }

  245.     /** Get start time of next maneuver.
  246.      * @return start time of next maneuver
  247.      */
  248.     public AbsoluteDate getManNextEpoch() {
  249.         return manNextEpoch;
  250.     }

  251.     /** Set start time of next maneuver.
  252.      * @param manNextEpoch start time of next maneuver
  253.      */
  254.     public void setManNextEpoch(final AbsoluteDate manNextEpoch) {
  255.         refuseFurtherComments();
  256.         this.manNextEpoch = manNextEpoch;
  257.     }

  258.     /** Get the purposes of the maneuver.
  259.      * @return purposes of the maneuver
  260.      */
  261.     public List<String> getManPurpose() {
  262.         return manPurpose;
  263.     }

  264.     /** Set the purposes of the maneuver.
  265.      * @param manPurpose purposes of the maneuver
  266.      */
  267.     public void setManPurpose(final List<String> manPurpose) {
  268.         this.manPurpose = manPurpose;
  269.     }

  270.     /** Get prediction source on which this maneuver is based.
  271.      * @return prediction source on which this maneuver is based
  272.      */
  273.     public String getManPredSource() {
  274.         return manPredSource;
  275.     }

  276.     /** Set prediction source on which this maneuver is based.
  277.      * @param manPredSource prediction source on which this maneuver is based
  278.      */
  279.     public void setManPredSource(final String manPredSource) {
  280.         refuseFurtherComments();
  281.         this.manPredSource = manPredSource;
  282.     }

  283.     /** Get reference frame of the maneuver.
  284.      * @return reference frame of the maneuver
  285.      */
  286.     public FrameFacade getManReferenceFrame() {
  287.         return manReferenceFrame;
  288.     }

  289.     /** Set reference frame of the maneuver.
  290.      * @param manReferenceFrame the reference frame to be set
  291.      */
  292.     public void setManReferenceFrame(final FrameFacade manReferenceFrame) {
  293.         refuseFurtherComments();
  294.         this.manReferenceFrame = manReferenceFrame;
  295.     }

  296.     /** Get epoch of the {@link #getManReferenceFrame() maneuver reference frame}.
  297.      * @return epoch of the {@link #getManReferenceFrame() maneuver reference frame}
  298.      */
  299.     public AbsoluteDate getManFrameEpoch() {
  300.         return manFrameEpoch;
  301.     }

  302.     /** Set epoch of the {@link #getManReferenceFrame() maneuver reference frame}.
  303.      * @param manFrameEpoch epoch of the {@link #getManReferenceFrame() maneuver reference frame}
  304.      */
  305.     public void setManFrameEpoch(final AbsoluteDate manFrameEpoch) {
  306.         refuseFurtherComments();
  307.         this.manFrameEpoch = manFrameEpoch;
  308.     }

  309.     /** Get the origin of gravitational assist.
  310.      * @return the origin of gravitational assist.
  311.      */
  312.     public BodyFacade getGravitationalAssist() {
  313.         return gravitationalAssist;
  314.     }

  315.     /** Set the origin of gravitational assist.
  316.      * @param gravitationalAssist origin of gravitational assist to be set
  317.      */
  318.     public void setGravitationalAssist(final BodyFacade gravitationalAssist) {
  319.         refuseFurtherComments();
  320.         this.gravitationalAssist = gravitationalAssist;
  321.     }

  322.     /** Get type of duty cycle.
  323.      * @return type of duty cycle
  324.      */
  325.     public DutyCycleType getDcType() {
  326.         return dcType;
  327.     }

  328.     /** Set type of duty cycle.
  329.      * @param dcType type of duty cycle
  330.      */
  331.     public void setDcType(final DutyCycleType dcType) {
  332.         this.dcType = dcType;
  333.     }

  334.     /** Get the start time of duty cycle-based maneuver window.
  335.      * @return start time of duty cycle-based maneuver window
  336.      */
  337.     public AbsoluteDate getDcWindowOpen() {
  338.         return dcWindowOpen;
  339.     }

  340.     /** Set the start time of duty cycle-based maneuver window.
  341.      * @param dcWindowOpen start time of duty cycle-based maneuver window
  342.      */
  343.     public void setDcWindowOpen(final AbsoluteDate dcWindowOpen) {
  344.         this.dcWindowOpen = dcWindowOpen;
  345.     }

  346.     /** Get the end time of duty cycle-based maneuver window.
  347.      * @return end time of duty cycle-based maneuver window
  348.      */
  349.     public AbsoluteDate getDcWindowClose() {
  350.         return dcWindowClose;
  351.     }

  352.     /** Set the end time of duty cycle-based maneuver window.
  353.      * @param dcWindowClose end time of duty cycle-based maneuver window
  354.      */
  355.     public void setDcWindowClose(final AbsoluteDate dcWindowClose) {
  356.         this.dcWindowClose = dcWindowClose;
  357.     }

  358.     /** Get the minimum number of "ON" duty cycles.
  359.      * @return minimum number of "ON" duty cycles (-1 if not set)
  360.      */
  361.     public int getDcMinCycles() {
  362.         return dcMinCycles;
  363.     }

  364.     /** Set the minimum number of "ON" duty cycles.
  365.      * @param dcMinCycles minimum number of "ON" duty cycles
  366.      */
  367.     public void setDcMinCycles(final int dcMinCycles) {
  368.         this.dcMinCycles = dcMinCycles;
  369.     }

  370.     /** Get the maximum number of "ON" duty cycles.
  371.      * @return maximum number of "ON" duty cycles (-1 if not set)
  372.      */
  373.     public int getDcMaxCycles() {
  374.         return dcMaxCycles;
  375.     }

  376.     /** Set the maximum number of "ON" duty cycles.
  377.      * @param dcMaxCycles maximum number of "ON" duty cycles
  378.      */
  379.     public void setDcMaxCycles(final int dcMaxCycles) {
  380.         this.dcMaxCycles = dcMaxCycles;
  381.     }

  382.     /** Get the start time of initial duty cycle-based maneuver execution.
  383.      * @return start time of initial duty cycle-based maneuver execution
  384.      */
  385.     public AbsoluteDate getDcExecStart() {
  386.         return dcExecStart;
  387.     }

  388.     /** Set the start time of initial duty cycle-based maneuver execution.
  389.      * @param dcExecStart start time of initial duty cycle-based maneuver execution
  390.      */
  391.     public void setDcExecStart(final AbsoluteDate dcExecStart) {
  392.         this.dcExecStart = dcExecStart;
  393.     }

  394.     /** Get the end time of final duty cycle-based maneuver execution.
  395.      * @return end time of final duty cycle-based maneuver execution
  396.      */
  397.     public AbsoluteDate getDcExecStop() {
  398.         return dcExecStop;
  399.     }

  400.     /** Set the end time of final duty cycle-based maneuver execution.
  401.      * @param dcExecStop end time of final duty cycle-based maneuver execution
  402.      */
  403.     public void setDcExecStop(final AbsoluteDate dcExecStop) {
  404.         this.dcExecStop = dcExecStop;
  405.     }

  406.     /** Get duty cycle thrust reference time.
  407.      * @return duty cycle thrust reference time
  408.      */
  409.     public AbsoluteDate getDcRefTime() {
  410.         return dcRefTime;
  411.     }

  412.     /** Set duty cycle thrust reference time.
  413.      * @param dcRefTime duty cycle thrust reference time
  414.      */
  415.     public void setDcRefTime(final AbsoluteDate dcRefTime) {
  416.         this.dcRefTime = dcRefTime;
  417.     }

  418.     /** Get duty cycle pulse "ON" duration.
  419.      * @return duty cycle pulse "ON" duration
  420.      */
  421.     public double getDcTimePulseDuration() {
  422.         return dcTimePulseDuration;
  423.     }

  424.     /** Set duty cycle pulse "ON" duration.
  425.      * @param dcTimePulseDuration duty cycle pulse "ON" duration
  426.      */
  427.     public void setDcTimePulseDuration(final double dcTimePulseDuration) {
  428.         this.dcTimePulseDuration = dcTimePulseDuration;
  429.     }

  430.     /** Get duty cycle elapsed time between start of a pulse and start of next pulse.
  431.      * @return duty cycle elapsed time between start of a pulse and start of next pulse
  432.      */
  433.     public double getDcTimePulsePeriod() {
  434.         return dcTimePulsePeriod;
  435.     }

  436.     /** Set duty cycle elapsed time between start of a pulse and start of next pulse.
  437.      * @param dcTimePulsePeriod duty cycle elapsed time between start of a pulse and start of next pulse
  438.      */
  439.     public void setDcTimePulsePeriod(final double dcTimePulsePeriod) {
  440.         this.dcTimePulsePeriod = dcTimePulsePeriod;
  441.     }

  442.     /** Get reference direction for triggering duty cycle.
  443.      * @return reference direction for triggering duty cycle
  444.      */
  445.     public Vector3D getDcRefDir() {
  446.         return dcRefDir;
  447.     }

  448.     /** Set reference direction for triggering duty cycle.
  449.      * @param dcRefDir reference direction for triggering duty cycle
  450.      */
  451.     public void setDcRefDir(final Vector3D dcRefDir) {
  452.         this.dcRefDir = dcRefDir;
  453.     }

  454.     /** Get spacecraft body frame in which {@link #getDcBodyTrigger()} is specified.
  455.      * @return spacecraft body frame in which {@link #getDcBodyTrigger()} is specified
  456.      */
  457.     public SpacecraftBodyFrame getDcBodyFrame() {
  458.         return dcBodyFrame;
  459.     }

  460.     /** Set spacecraft body frame in which {@link #getDcBodyTrigger()} is specified.
  461.      * @param dcBodyFrame spacecraft body frame in which {@link #getDcBodyTrigger()} is specified
  462.      */
  463.     public void setDcBodyFrame(final SpacecraftBodyFrame dcBodyFrame) {
  464.         this.dcBodyFrame = dcBodyFrame;
  465.     }

  466.     /** Get direction in {@link #getDcBodyFrame() body frame} for triggering duty cycle.
  467.      * @return direction in {@link #getDcBodyFrame() body frame} for triggering duty cycle
  468.      */
  469.     public Vector3D getDcBodyTrigger() {
  470.         return  dcBodyTrigger;
  471.     }

  472.     /** Set direction in {@link #getDcBodyFrame() body frame} for triggering duty cycle.
  473.      * @param dcBodyTrigger direction in {@link #getDcBodyFrame() body frame} for triggering duty cycle
  474.      */
  475.     public void setDcBodyTrigger(final Vector3D dcBodyTrigger) {
  476.         this.dcBodyTrigger = dcBodyTrigger;
  477.     }

  478.     /** Get phase angle of pulse start.
  479.      * @return phase angle of pulse start
  480.      */
  481.     public double getDcPhaseStartAngle() {
  482.         return dcPhaseStartAngle;
  483.     }

  484.     /** Set phase angle of pulse start.
  485.      * @param dcPhaseStartAngle phase angle of pulse start
  486.      */
  487.     public void setDcPhaseStartAngle(final double dcPhaseStartAngle) {
  488.         this.dcPhaseStartAngle = dcPhaseStartAngle;
  489.     }

  490.     /** Get phase angle of pulse stop.
  491.      * @return phase angle of pulse stop
  492.      */
  493.     public double getDcPhaseStopAngle() {
  494.         return dcPhaseStopAngle;
  495.     }

  496.     /** Set phase angle of pulse stop.
  497.      * @param dcPhaseStopAngle phase angle of pulse stop
  498.      */
  499.     public void setDcPhaseStopAngle(final double dcPhaseStopAngle) {
  500.         this.dcPhaseStopAngle = dcPhaseStopAngle;
  501.     }

  502.     /** Get maneuver elements of information.
  503.      * @return maneuver element of information
  504.      */
  505.     public List<ManeuverFieldType> getManComposition() {
  506.         return manComposition;
  507.     }

  508.     /** Set maneuver element of information.
  509.      * @param manComposition maneuver element of information
  510.      */
  511.     public void setManComposition(final List<ManeuverFieldType> manComposition) {
  512.         refuseFurtherComments();
  513.         this.manComposition = manComposition;
  514.     }

  515.     /** Get maneuver elements of information units.
  516.      * @return maneuver element of information units
  517.      */
  518.     public List<Unit> getManUnits() {
  519.         return manUnits;
  520.     }

  521.     /** Set maneuver element of information units.
  522.      * @param manUnits maneuver element of information units
  523.      */
  524.     public void setManUnits(final List<Unit> manUnits) {
  525.         refuseFurtherComments();
  526.         this.manUnits = manUnits;
  527.     }

  528. }