1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.files.ccsds.ndm.adm.aem;
18
19 import org.hipparchus.geometry.euclidean.threed.RotationOrder;
20 import org.orekit.errors.OrekitException;
21 import org.orekit.errors.OrekitMessages;
22 import org.orekit.files.ccsds.definitions.FrameFacade;
23 import org.orekit.files.ccsds.ndm.adm.AdmMetadata;
24 import org.orekit.files.ccsds.ndm.adm.AttitudeEndpoints;
25 import org.orekit.files.ccsds.ndm.adm.AttitudeType;
26 import org.orekit.time.AbsoluteDate;
27
28
29
30
31
32 public class AemMetadata extends AdmMetadata {
33
34
35 private final AttitudeEndpoints endpoints;
36
37
38 private AbsoluteDate startTime;
39
40
41 private AbsoluteDate stopTime;
42
43
44 private AbsoluteDate useableStartTime;
45
46
47 private AbsoluteDate useableStopTime;
48
49
50 private AttitudeType attitudeType;
51
52
53 private Boolean isFirst;
54
55
56 private RotationOrder eulerRotSeq;
57
58
59 private Boolean rateFrameIsA;
60
61
62
63
64 private FrameFacade angvelFrame;
65
66
67 private String interpolationMethod;
68
69
70 private int interpolationDegree;
71
72
73
74
75 public AemMetadata(final int defaultInterpolationDegree) {
76 endpoints = new AttitudeEndpoints();
77 interpolationDegree = defaultInterpolationDegree;
78 }
79
80
81 @Override
82 public void validate(final double version) {
83
84 super.validate(version);
85
86 checkMandatoryEntriesExceptDatesAndExternalFrame(version);
87 endpoints.checkExternalFrame(AemMetadataKey.REF_FRAME_A, AemMetadataKey.REF_FRAME_B);
88
89 checkNotNull(startTime, AemMetadataKey.START_TIME.name());
90 checkNotNull(stopTime, AemMetadataKey.STOP_TIME.name());
91
92 if (version >= 2.0 && isFirst()) {
93 throw new OrekitException(OrekitMessages.CCSDS_KEYWORD_NOT_ALLOWED_IN_VERSION,
94 AemMetadataKey.QUATERNION_TYPE, version);
95 }
96
97 }
98
99
100
101
102
103
104
105
106
107
108
109 void checkMandatoryEntriesExceptDatesAndExternalFrame(final double version) {
110
111 super.validate(version);
112
113 endpoints.checkMandatoryEntriesExceptExternalFrame(version,
114 AemMetadataKey.REF_FRAME_A,
115 AemMetadataKey.REF_FRAME_B,
116 AemMetadataKey.ATTITUDE_DIR);
117
118 checkNotNull(attitudeType, AemMetadataKey.ATTITUDE_TYPE.name());
119 if (version < 2.0) {
120 if (attitudeType == AttitudeType.QUATERNION ||
121 attitudeType == AttitudeType.QUATERNION_DERIVATIVE) {
122 checkNotNull(isFirst, AemMetadataKey.QUATERNION_TYPE.name());
123 }
124 if (attitudeType == AttitudeType.EULER_ANGLE_DERIVATIVE) {
125 checkNotNull(rateFrameIsA, AemMetadataKey.RATE_FRAME.name());
126 }
127 } else {
128 if (attitudeType == AttitudeType.QUATERNION_ANGVEL) {
129 checkNotNull(angvelFrame, AemMetadataKey.ANGVEL_FRAME.name());
130 }
131 }
132
133 if (attitudeType == AttitudeType.EULER_ANGLE ||
134 attitudeType == AttitudeType.EULER_ANGLE_DERIVATIVE) {
135 checkNotNull(eulerRotSeq, AemMetadataKey.EULER_ROT_SEQ.name());
136 }
137
138 }
139
140
141
142
143 public AttitudeEndpoints getEndpoints() {
144 return endpoints;
145 }
146
147
148
149
150 public boolean rateFrameIsA() {
151 return rateFrameIsA == null ? false : rateFrameIsA;
152 }
153
154
155
156
157 public void setRateFrameIsA(final boolean rateFrameIsA) {
158 refuseFurtherComments();
159 this.rateFrameIsA = rateFrameIsA;
160 }
161
162
163
164
165
166 public void setAngvelFrame(final FrameFacade angvelFrame) {
167 this.angvelFrame = angvelFrame;
168 }
169
170
171
172
173
174 public FrameFacade getFrameAngvelFrame() {
175 return angvelFrame;
176 }
177
178
179
180
181
182
183
184
185
186 public boolean isSpacecraftBodyRate() {
187 return rateFrameIsA() ^ endpoints.getFrameA().asSpacecraftBodyFrame() == null;
188 }
189
190
191
192
193
194
195 public AttitudeType getAttitudeType() {
196 return attitudeType;
197 }
198
199
200
201
202
203 public void setAttitudeType(final AttitudeType type) {
204 refuseFurtherComments();
205 this.attitudeType = type;
206 }
207
208
209
210
211
212
213
214 public Boolean isFirst() {
215 return isFirst == null ? Boolean.FALSE : isFirst;
216 }
217
218
219
220
221
222 public void setIsFirst(final boolean isFirst) {
223 refuseFurtherComments();
224 this.isFirst = isFirst;
225 }
226
227
228
229
230
231 public RotationOrder getEulerRotSeq() {
232 return eulerRotSeq;
233 }
234
235
236
237
238
239 public void setEulerRotSeq(final RotationOrder eulerRotSeq) {
240 refuseFurtherComments();
241 this.eulerRotSeq = eulerRotSeq;
242 }
243
244
245
246
247
248 public AbsoluteDate getStartTime() {
249 return startTime;
250 }
251
252
253
254
255
256 public void setStartTime(final AbsoluteDate startTime) {
257 refuseFurtherComments();
258 this.startTime = startTime;
259 }
260
261
262
263
264
265 public AbsoluteDate getStopTime() {
266 return stopTime;
267 }
268
269
270
271
272
273 public void setStopTime(final AbsoluteDate stopTime) {
274 refuseFurtherComments();
275 this.stopTime = stopTime;
276 }
277
278
279
280
281
282 public AbsoluteDate getUseableStartTime() {
283 return useableStartTime;
284 }
285
286
287
288
289
290 public void setUseableStartTime(final AbsoluteDate useableStartTime) {
291 refuseFurtherComments();
292 this.useableStartTime = useableStartTime;
293 }
294
295
296
297
298
299 public AbsoluteDate getUseableStopTime() {
300 return useableStopTime;
301 }
302
303
304
305
306
307 public void setUseableStopTime(final AbsoluteDate useableStopTime) {
308 refuseFurtherComments();
309 this.useableStopTime = useableStopTime;
310 }
311
312
313
314
315
316
317 public AbsoluteDate getStart() {
318
319 final AbsoluteDate start = this.getUseableStartTime();
320 if (start != null) {
321 return start;
322 } else {
323 return this.getStartTime();
324 }
325 }
326
327
328
329
330
331
332 public AbsoluteDate getStop() {
333
334 final AbsoluteDate stop = this.getUseableStopTime();
335 if (stop != null) {
336 return stop;
337 } else {
338 return this.getStopTime();
339 }
340 }
341
342
343
344
345
346
347 public String getInterpolationMethod() {
348 return interpolationMethod;
349 }
350
351
352
353
354
355 public void setInterpolationMethod(final String interpolationMethod) {
356 refuseFurtherComments();
357 this.interpolationMethod = interpolationMethod;
358 }
359
360
361
362
363
364 public int getInterpolationDegree() {
365 return interpolationDegree;
366 }
367
368
369
370
371
372 public void setInterpolationDegree(final int interpolationDegree) {
373 refuseFurtherComments();
374 this.interpolationDegree = interpolationDegree;
375 }
376
377
378
379
380
381
382 public int getInterpolationSamples() {
383
384 return getInterpolationDegree() + 1;
385 }
386
387
388
389
390
391 AemMetadata copy(final double version) {
392
393 checkMandatoryEntriesExceptDatesAndExternalFrame(version);
394
395
396 final AemMetadata copy = new AemMetadata(getInterpolationDegree());
397
398
399 for (String comment : getComments()) {
400 copy.addComment(comment);
401 }
402
403
404 copy.setObjectName(getObjectName());
405 copy.setObjectID(getObjectID());
406 if (getCenter() != null) {
407 copy.setCenter(getCenter());
408 }
409
410
411 copy.getEndpoints().setFrameA(getEndpoints().getFrameA());
412 copy.getEndpoints().setFrameB(getEndpoints().getFrameB());
413 copy.getEndpoints().setA2b(getEndpoints().isA2b());
414 copy.setRateFrameIsA(rateFrameIsA());
415
416
417 copy.setTimeSystem(getTimeSystem());
418
419
420 copy.setAttitudeType(getAttitudeType());
421 if (isFirst() != null) {
422 copy.setIsFirst(isFirst());
423 }
424 if (getEulerRotSeq() != null) {
425 copy.setEulerRotSeq(getEulerRotSeq());
426 }
427
428
429 if (getInterpolationMethod() != null) {
430 copy.setInterpolationMethod(getInterpolationMethod());
431 }
432
433 return copy;
434
435 }
436
437 }