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;
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 H header;
43
44 /** segments list. */
45 private 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 * Set the header.
79 * @param header the header
80 */
81 public void setHeader(final H header) {
82 this.header = header;
83 }
84
85 /**
86 * Get the segments.
87 * @return segments
88 * @since 11.0
89 */
90 public List<S> getSegments() {
91 return Collections.unmodifiableList(segments);
92 }
93
94 /**
95 * Set the segments.
96 * @param segments the segments
97 */
98 public void setSegments(final List<S> segments) {
99 this.segments = segments;
100 }
101
102 /**
103 * Get IERS conventions.
104 * @return IERS conventions
105 */
106 public IERSConventions getConventions() {
107 if (conventions != null) {
108 return conventions;
109 } else {
110 throw new OrekitException(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS);
111 }
112 }
113
114 /**
115 * Get the data context.
116 * @return the data context used for creating frames, time scales, etc.
117 */
118 public DataContext getDataContext() {
119 return dataContext;
120 }
121
122 /**
123 * Validate the file message for required and forbidden entries.
124 * <p>
125 * This method throws an exception if file does not meet format requirements.
126 * The requirements may depend on format version, which is found in header.
127 * </p>
128 */
129 public void validate() {
130 header.validate(header.getFormatVersion());
131 for (final S segment : segments) {
132 segment.getMetadata().validate(header.getFormatVersion());
133 segment.getData().validate(header.getFormatVersion());
134 }
135 }
136 }