1 /* Copyright 2002-2025 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.adm.apm;
18
19 import java.util.Arrays;
20
21 import org.hipparchus.geometry.euclidean.threed.Vector3D;
22 import org.orekit.files.ccsds.definitions.FrameFacade;
23 import org.orekit.files.ccsds.section.CommentsContainer;
24 import org.orekit.time.AbsoluteDate;
25
26 /**
27 * Maneuver in an APM file.
28 * <p>
29 * Beware that the Orekit getters and setters all rely on SI units. The parsers
30 * and writers take care of converting these SI units into CCSDS mandatory units.
31 * The {@link org.orekit.utils.units.Unit Unit} class provides useful
32 * {@link org.orekit.utils.units.Unit#fromSI(double) fromSi} and
33 * {@link org.orekit.utils.units.Unit#toSI(double) toSI} methods in case the callers
34 * already use CCSDS units instead of the API SI units. The general-purpose
35 * {@link org.orekit.utils.units.Unit Unit} class (without an 's') and the
36 * CCSDS-specific {@link org.orekit.files.ccsds.definitions.Units Units} class
37 * (with an 's') also provide some predefined units. These predefined units and the
38 * {@link org.orekit.utils.units.Unit#fromSI(double) fromSi} and
39 * {@link org.orekit.utils.units.Unit#toSI(double) toSI} conversion methods are indeed
40 * what the parsers and writers use for the conversions.
41 * </p>
42 * @author Bryan Cazabonne
43 * @since 10.2
44 */
45 public class Maneuver extends CommentsContainer {
46
47 /** Epoch of start of maneuver . */
48 private AbsoluteDate epochStart;
49
50 /** Coordinate system for the torque vector. */
51 private FrameFacade frame;
52
53 /** Duration (value is 0 for impulsive maneuver). */
54 private double duration;
55
56 /** Torque vector (N.m). */
57 private final double[] torque;
58
59 /** Mass change during maneuver (kg).
60 * @since 12.0
61 */
62 private double deltaMass;
63
64 /**
65 * Simple constructor.
66 */
67 public Maneuver() {
68 duration = Double.NaN;
69 torque = new double[3];
70 deltaMass = Double.NaN;
71 Arrays.fill(torque, Double.NaN);
72 }
73
74 /** {@inheritDoc} */
75 @Override
76 public void validate(final double version) {
77 super.validate(version);
78 checkNotNull(epochStart, ManeuverKey.MAN_EPOCH_START.name());
79 checkNotNaN(duration, ManeuverKey.MAN_DURATION.name());
80 checkNotNull(frame, ManeuverKey.MAN_REF_FRAME.name());
81 checkNotNaN(torque[0], ManeuverKey.MAN_TOR_1.name());
82 checkNotNaN(torque[1], ManeuverKey.MAN_TOR_2.name());
83 checkNotNaN(torque[2], ManeuverKey.MAN_TOR_3.name());
84 }
85
86 /**
87 * Get epoch start.
88 * @return epoch start
89 */
90 public AbsoluteDate getEpochStart() {
91 return epochStart;
92 }
93
94 /**
95 * Set epoch start.
96 * @param epochStart epoch start
97 */
98 public void setEpochStart(final AbsoluteDate epochStart) {
99 refuseFurtherComments();
100 this.epochStart = epochStart;
101 }
102
103 /**
104 * Get Coordinate system for the torque vector.
105 * @return coordinate system for the torque vector
106 */
107 public FrameFacade getFrame() {
108 return frame;
109 }
110
111 /**
112 * Set Coordinate system for the torque vector.
113 * @param frame coordinate system for the torque vector
114 */
115 public void setFrame(final FrameFacade frame) {
116 refuseFurtherComments();
117 this.frame = frame;
118 }
119
120 /**
121 * Get duration (value is 0 for impulsive maneuver).
122 * @return duration (value is 0 for impulsive maneuver)
123 */
124 public double getDuration() {
125 return duration;
126 }
127
128 /**
129 * Set duration (value is 0 for impulsive maneuver).
130 * @param duration duration (value is 0 for impulsive maneuver)
131 */
132 public void setDuration(final double duration) {
133 refuseFurtherComments();
134 this.duration = duration;
135 }
136
137 /**
138 * Get the torque vector (N.m).
139 * @return torque vector
140 */
141 public Vector3D getTorque() {
142 return new Vector3D(torque);
143 }
144
145 /**
146 * Set the torque vector (N.m).
147 * @param index vector component index (counting from 0)
148 * @param value component value
149 */
150 public void setTorque(final int index, final double value) {
151 refuseFurtherComments();
152 this.torque[index] = value;
153 }
154
155 /**
156 * Get mass change during maneuver.
157 * @return mass change during maneuver (kg, negative)
158 * @since 12.0
159 */
160 public double getDeltaMass() {
161 return deltaMass;
162 }
163
164 /**
165 * Set mass change during maneuver.
166 * @param deltaMass mass change during maneuver (kg)
167 * @since 12.0
168 */
169 public void setDeltaMass(final double deltaMass) {
170 refuseFurtherComments();
171 this.deltaMass = deltaMass;
172 }
173
174 }