1   /* Copyright 2022-2026 Luc Maisonobe
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  
18  package org.orekit.files.ccsds.ndm.adm.acm;
19  
20  import java.util.List;
21  import java.util.Optional;
22  
23  import org.orekit.annotation.Nullable;
24  import org.orekit.files.ccsds.ndm.odm.UserDefined;
25  import org.orekit.files.ccsds.section.Data;
26  import org.orekit.files.ccsds.utils.Initializer;
27  
28  /** Data container for Attitude Comprehensive Messages.
29   * @author Luc Maisonobe
30   * @since 12.0
31   */
32  public class AcmData implements Data {
33  
34      /** Attitude state histories logical blocks. */
35      private final List<AttitudeStateHistory> attitudeBlocks;
36  
37      /** Physical properties logical block. */
38      @Nullable
39      private final AttitudePhysicalProperties physicBlock;
40  
41      /** Covariance logical blocks. */
42      private final List<AttitudeCovarianceHistory> covarianceBlocks;
43  
44      /** Maneuvers logical blocks. */
45      private final List<AttitudeManeuver> maneuverBlocks;
46  
47      /** Attitude determination logical block. */
48      @Nullable
49      private final AttitudeDetermination attitudeDeterminationBlock;
50  
51      /** User defined parameters logical block. */
52      @Nullable
53      private final UserDefined userDefinedBlock;
54  
55      /** Simple constructor.
56       * @param attitudeBlocks attitude state histories logical blocks (may be empty)
57       * @param physicBlock physical properties logical block (may be null)
58       * @param covarianceBlocks covariance logical blocks (may be empty)
59       * @param maneuverBlocks maneuvers logical blocks (may be empty)
60       * @param attitudeDeterminationBlock attitude determination logical block (may be null)
61       * @param userDefinedBlock user defined parameters logical block (may be null)
62       */
63      public AcmData(final List<AttitudeStateHistory>      attitudeBlocks,
64                     final AttitudePhysicalProperties      physicBlock,
65                     final List<AttitudeCovarianceHistory> covarianceBlocks,
66                     final List<AttitudeManeuver>          maneuverBlocks,
67                     final AttitudeDetermination           attitudeDeterminationBlock,
68                     final UserDefined                     userDefinedBlock) {
69          this.attitudeBlocks             = Initializer.emptyListIfNull(attitudeBlocks);
70          this.physicBlock                = physicBlock;
71          this.covarianceBlocks           = Initializer.emptyListIfNull(covarianceBlocks);
72          this.maneuverBlocks             = Initializer.emptyListIfNull(maneuverBlocks);
73          this.attitudeDeterminationBlock = attitudeDeterminationBlock;
74          this.userDefinedBlock           = userDefinedBlock;
75      }
76  
77      /** {@inheritDoc} */
78      @Override
79      public void validate(final double version) {
80          if (!attitudeBlocks.isEmpty()) {
81              for (final AttitudeStateHistory ash : attitudeBlocks) {
82                  ash.getMetadata().validate(version);
83              }
84          }
85          if (physicBlock != null) {
86              physicBlock.validate(version);
87          }
88          if (!covarianceBlocks.isEmpty()) {
89              for (final AttitudeCovarianceHistory ch : covarianceBlocks) {
90                  ch.getMetadata().validate(version);
91              }
92          }
93          if (!maneuverBlocks.isEmpty()) {
94              for (final AttitudeManeuver m : maneuverBlocks) {
95                  m.validate(version);
96              }
97          }
98          if (attitudeDeterminationBlock != null) {
99              attitudeDeterminationBlock.validate(version);
100         }
101         if (userDefinedBlock != null) {
102             userDefinedBlock.validate(version);
103         }
104     }
105 
106     /** Get attitude state histories logical blocks.
107      * @return attitude state histories logical blocks (may be null)
108      */
109     public List<AttitudeStateHistory> getAttitudeBlocks() {
110         return attitudeBlocks;
111     }
112 
113     /** Get physical properties logical block.
114      * @return physical properties logical block (may be null)
115      */
116     public Optional<AttitudePhysicalProperties> getPhysicBlock() {
117         return Optional.ofNullable(physicBlock);
118     }
119 
120     /** Get covariance logical blocks.
121      * @return covariance logical blocks (may be null)
122      */
123     public List<AttitudeCovarianceHistory> getCovarianceBlocks() {
124         return covarianceBlocks;
125     }
126 
127     /** Get maneuvers logical blocks.
128      * @return maneuvers logical block (may be null)
129      */
130     public List<AttitudeManeuver> getManeuverBlocks() {
131         return maneuverBlocks;
132     }
133 
134     /** Get attitude determination logical block.
135      * @return attitude determination logical block (may be null)
136      */
137     public Optional<AttitudeDetermination> getAttitudeDeterminationBlock() {
138         return Optional.ofNullable(attitudeDeterminationBlock);
139     }
140 
141     /** Get user defined parameters logical block.
142      * @return user defined parameters logical block (may be null)
143      */
144     public Optional<UserDefined> getUserDefinedBlock() {
145         return Optional.ofNullable(userDefinedBlock);
146     }
147 
148 }