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.adm.apm;
18  
19  import org.orekit.errors.OrekitException;
20  import org.orekit.errors.OrekitMessages;
21  import org.orekit.files.ccsds.ndm.adm.AttitudeEndoints;
22  import org.orekit.files.ccsds.section.CommentsContainer;
23  
24  /**
25   * Container for Attitude Parameter Message data lines.
26   * @author Bryan Cazabonne
27   * @since 10.2
28   */
29  public class SpinStabilized extends CommentsContainer {
30  
31      /** Endpoints (i.e. frames A, B and their relationship). */
32      private final AttitudeEndoints endpoints;
33  
34      /** Right ascension of spin axis vector (rad). */
35      private double spinAlpha;
36  
37      /** Declination of the spin axis vector (rad). */
38      private double spinDelta;
39  
40      /** Phase of the satellite about the spin axis (rad). */
41      private double spinAngle;
42  
43      /** Angular velocity of satellite around spin axis (rad/s). */
44      private double spinAngleVel;
45  
46      /** Nutation angle of spin axis (rad). */
47      private double nutation;
48  
49      /** Body nutation period of the spin axis (s). */
50      private double nutationPer;
51  
52      /** Inertial nutation phase (rad). */
53      private double nutationPhase;
54  
55      /** Simple constructor.
56       */
57      public SpinStabilized() {
58          endpoints      = new AttitudeEndoints();
59          spinAlpha      = Double.NaN;
60          spinDelta      = Double.NaN;
61          spinAngle      = Double.NaN;
62          spinAngleVel   = Double.NaN;
63          nutation       = Double.NaN;
64          nutationPer    = Double.NaN;
65          nutationPhase  = Double.NaN;
66      }
67  
68      /** {@inheritDoc} */
69      @Override
70      public void validate(final double version) {
71          super.validate(version);
72          endpoints.checkMandatoryEntriesExceptExternalFrame(SpinStabilizedKey.SPIN_FRAME_A,
73                                                             SpinStabilizedKey.SPIN_FRAME_B,
74                                                             SpinStabilizedKey.SPIN_DIR);
75          endpoints.checkExternalFrame(SpinStabilizedKey.SPIN_FRAME_A, SpinStabilizedKey.SPIN_FRAME_B);
76          checkNotNaN(spinAlpha,    SpinStabilizedKey.SPIN_ALPHA);
77          checkNotNaN(spinDelta,    SpinStabilizedKey.SPIN_DELTA);
78          checkNotNaN(spinAngle,    SpinStabilizedKey.SPIN_ANGLE);
79          checkNotNaN(spinAngleVel, SpinStabilizedKey.SPIN_ANGLE_VEL);
80          if (Double.isNaN(nutation + nutationPer + nutationPhase)) {
81              // if at least one is NaN, all must be NaN (i.e. not initialized)
82              if (!(Double.isNaN(nutation) && Double.isNaN(nutationPer) && Double.isNaN(nutationPhase))) {
83                  throw new OrekitException(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY, "NUTATION*");
84              }
85          }
86      }
87  
88      /** Get the endpoints (i.e. frames A, B and their relationship).
89       * @return endpoints
90       */
91      public AttitudeEndoints getEndpoints() {
92          return endpoints;
93      }
94  
95      /**
96       * Get the right ascension of spin axis vector (rad).
97       * @return the right ascension of spin axis vector
98       */
99      public double getSpinAlpha() {
100         return spinAlpha;
101     }
102 
103     /**
104      * Set the right ascension of spin axis vector (rad).
105      * @param spinAlpha value to be set
106      */
107     public void setSpinAlpha(final double spinAlpha) {
108         refuseFurtherComments();
109         this.spinAlpha = spinAlpha;
110     }
111 
112     /**
113      * Get the declination of the spin axis vector (rad).
114      * @return the declination of the spin axis vector (rad).
115      */
116     public double getSpinDelta() {
117         return spinDelta;
118     }
119 
120     /**
121      * Set the declination of the spin axis vector (rad).
122      * @param spinDelta value to be set
123      */
124     public void setSpinDelta(final double spinDelta) {
125         refuseFurtherComments();
126         this.spinDelta = spinDelta;
127     }
128 
129     /**
130      * Get the phase of the satellite about the spin axis (rad).
131      * @return the phase of the satellite about the spin axis
132      */
133     public double getSpinAngle() {
134         return spinAngle;
135     }
136 
137     /**
138      * Set the phase of the satellite about the spin axis (rad).
139      * @param spinAngle value to be set
140      */
141     public void setSpinAngle(final double spinAngle) {
142         refuseFurtherComments();
143         this.spinAngle = spinAngle;
144     }
145 
146     /**
147      * Get the angular velocity of satellite around spin axis (rad/s).
148      * @return the angular velocity of satellite around spin axis
149      */
150     public double getSpinAngleVel() {
151         return spinAngleVel;
152     }
153 
154     /**
155      * Set the angular velocity of satellite around spin axis (rad/s).
156      * @param spinAngleVel value to be set
157      */
158     public void setSpinAngleVel(final double spinAngleVel) {
159         refuseFurtherComments();
160         this.spinAngleVel = spinAngleVel;
161     }
162 
163     /**
164      * Get the nutation angle of spin axis (rad).
165      * @return the nutation angle of spin axis
166      */
167     public double getNutation() {
168         return nutation;
169     }
170 
171     /**
172      * Set the nutation angle of spin axis (rad).
173      * @param nutation the nutation angle to be set
174      */
175     public void setNutation(final double nutation) {
176         refuseFurtherComments();
177         this.nutation = nutation;
178     }
179 
180     /**
181      * Get the body nutation period of the spin axis (s).
182      * @return the body nutation period of the spin axis
183      */
184     public double getNutationPeriod() {
185         return nutationPer;
186     }
187 
188     /**
189      * Set the body nutation period of the spin axis (s).
190      * @param period the nutation period to be set
191      */
192     public void setNutationPeriod(final double period) {
193         refuseFurtherComments();
194         this.nutationPer = period;
195     }
196 
197     /**
198      * Get the inertial nutation phase (rad).
199      * @return the inertial nutation phase
200      */
201     public double getNutationPhase() {
202         return nutationPhase;
203     }
204 
205     /**
206      * Set the inertial nutation phase (rad).
207      * @param nutationPhase the nutation phase to be set
208      */
209     public void setNutationPhase(final double nutationPhase) {
210         refuseFurtherComments();
211         this.nutationPhase = nutationPhase;
212     }
213 
214 }