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  
18  package org.orekit.files.ccsds.ndm.odm.opm;
19  
20  import java.util.Arrays;
21  
22  import org.hipparchus.geometry.euclidean.threed.Vector3D;
23  import org.orekit.files.ccsds.definitions.FrameFacade;
24  import org.orekit.files.ccsds.section.CommentsContainer;
25  import org.orekit.time.AbsoluteDate;
26  
27  /** Maneuver in an OPM file.
28   * @author sports
29   * @since 6.1
30   */
31  public class Maneuver extends CommentsContainer {
32  
33      /** Epoch ignition. */
34      private AbsoluteDate epochIgnition;
35  
36      /** Coordinate system for velocity increment vector, for absolute frames. */
37      private FrameFacade referenceFrame;
38  
39      /** Duration (value is 0 for impulsive maneuver). */
40      private double duration;
41  
42      /** Mass change during maneuver (value is < 0). */
43      private double deltaMass;
44  
45      /** Velocity increment. */
46      private double[] dV;
47  
48      /** Simple constructor.
49       */
50      public Maneuver() {
51          duration  = Double.NaN;
52          deltaMass = Double.NaN;
53          dV        = new double[3];
54          Arrays.fill(dV, Double.NaN);
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public void validate(final double version) {
60          super.validate(version);
61          checkNotNull(epochIgnition,  ManeuverKey.MAN_EPOCH_IGNITION.name());
62          checkNotNull(referenceFrame, ManeuverKey.MAN_REF_FRAME.name());
63          checkNotNaN(duration,        ManeuverKey.MAN_DURATION.name());
64          checkNotNaN(deltaMass,       ManeuverKey.MAN_DELTA_MASS.name());
65          checkNotNaN(dV[0],           ManeuverKey.MAN_DV_1.name());
66          checkNotNaN(dV[1],           ManeuverKey.MAN_DV_2.name());
67          checkNotNaN(dV[2],           ManeuverKey.MAN_DV_3.name());
68      }
69  
70      /** Get epoch ignition.
71       * @return epoch ignition
72       */
73      public AbsoluteDate getEpochIgnition() {
74          return epochIgnition;
75      }
76  
77      /** Set epoch ignition.
78       * @param epochIgnition epoch ignition
79       */
80      public void setEpochIgnition(final AbsoluteDate epochIgnition) {
81          this.epochIgnition = epochIgnition;
82      }
83  
84      /** Get Coordinate system for velocity increment vector.
85       * @return coordinate system for velocity increment vector
86       */
87      public FrameFacade getReferenceFrame() {
88          return referenceFrame;
89      }
90  
91      /** Set Coordinate system for velocity increment vector.
92       * @param referenceFrame coordinate system for velocity increment vector
93       */
94      public void setReferenceFrame(final FrameFacade referenceFrame) {
95          this.referenceFrame = referenceFrame;
96      }
97  
98      /** Get duration (value is 0 for impulsive maneuver).
99       * @return duration (value is 0 for impulsive maneuver)
100      */
101     public double getDuration() {
102         return duration;
103     }
104 
105     /** Set duration (value is 0 for impulsive maneuver).
106      * @param duration duration (value is 0 for impulsive maneuver)
107      */
108     public void setDuration(final double duration) {
109         this.duration = duration;
110     }
111 
112     /** Get mass change during maneuver (value is &lt; 0).
113      * @return mass change during maneuver (value is &lt; 0)
114      */
115     public double getDeltaMass() {
116         return deltaMass;
117     }
118 
119     /** Set mass change during maneuver (value is &lt; 0).
120      * @param deltaMass mass change during maneuver (value is &lt; 0)
121      */
122     public void setDeltaMass(final double deltaMass) {
123         this.deltaMass = deltaMass;
124     }
125 
126     /** Get velocity increment.
127      * @return velocity increment
128      */
129     public Vector3D getDV() {
130         return new Vector3D(dV);
131     }
132 
133     /** Set velocity increment component.
134      * @param i component index
135      * @param dVi velocity increment component
136      */
137     public void setDV(final int i, final double dVi) {
138         dV[i] = dVi;
139     }
140 
141     /** Check if maneuver has been completed.
142      * @return true if maneuver has been completed
143      */
144     public boolean completed() {
145         return !(epochIgnition == null ||
146                  referenceFrame == null ||
147                  Double.isNaN(duration + deltaMass + dV[0] + dV[1] + dV[2]));
148     }
149 
150 }