1 /* Copyright 2002-2021 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;
18
19 import java.util.Collections;
20 import java.util.List;
21
22 import org.orekit.data.DataContext;
23 import org.orekit.errors.OrekitException;
24 import org.orekit.errors.OrekitMessages;
25 import org.orekit.files.ccsds.section.Header;
26 import org.orekit.files.ccsds.section.Segment;
27 import org.orekit.utils.IERSConventions;
28
29 /**
30 * Constituents of a CCSDS Navigation Data Message.
31 * Constituents may be Attitude Data Message (ADM), Orbit Data Message (ODM),
32 * Tracking Data Message (TDM)…
33 * Each constituent has its own header and a list of segments.
34 * @param <H> type of the header
35 * @param <S> type of the segments
36 * @author Bryan Cazabonne
37 * @since 10.2
38 */
39 public abstract class NdmConstituent<H extends Header, S extends Segment<?, ?>> {
40
41 /** Header. */
42 private final H header;
43
44 /** segments list. */
45 private final List<S> segments;
46
47 /** IERS conventions used. */
48 private final IERSConventions conventions;
49
50 /** Data context. */
51 private final DataContext dataContext;
52
53 /**
54 * Constructor.
55 * @param header file header
56 * @param segments file segments
57 * @param conventions IERS conventions
58 * @param dataContext used for creating frames, time scales, etc.
59 */
60 protected NdmConstituent(final H header, final List<S> segments,
61 final IERSConventions conventions, final DataContext dataContext) {
62 this.header = header;
63 this.segments = segments;
64 this.conventions = conventions;
65 this.dataContext = dataContext;
66 }
67
68 /**
69 * Get the header.
70 * @return header
71 * @since 11.0
72 */
73 public H getHeader() {
74 return header;
75 }
76
77 /**
78 * Get the segments.
79 * @return segments
80 * @since 11.0
81 */
82 public List<S> getSegments() {
83 return Collections.unmodifiableList(segments);
84 }
85
86 /**
87 * Get IERS conventions.
88 * @return IERS conventions
89 */
90 public IERSConventions getConventions() {
91 if (conventions != null) {
92 return conventions;
93 } else {
94 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
95 }
96 }
97
98 /**
99 * Get the data context.
100 * @return the data context used for creating frames, time scales, etc.
101 */
102 public DataContext getDataContext() {
103 return dataContext;
104 }
105
106 /**
107 * Validate the file message for required and forbidden entries.
108 * <p>
109 * This method throws an exception if file does not meet format requirements.
110 * The requirements may depend on format version, which is found in header.
111 * </p>
112 */
113 public void validate() {
114 header.validate(header.getFormatVersion());
115 for (final S segment : segments) {
116 segment.getMetadata().validate(header.getFormatVersion());
117 segment.getData().validate(header.getFormatVersion());
118 }
119 }
120 }