1   /* Copyright 2002-2024 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 org.orekit.errors.OrekitException;
21  import org.orekit.errors.OrekitMessages;
22  import org.orekit.files.ccsds.section.CommentsContainer;
23  
24  /** Attitude determination sensor data.
25   * @author Luc Maisonobe
26   * @since 12.0
27   */
28  public class AttitudeDeterminationSensor extends CommentsContainer {
29  
30      /** Sensor number. */
31      private int sensorNumber;
32  
33      /** Sensor used. */
34      private String sensorUsed;
35  
36      /** Number of noise elements for sensor. */
37      private int nbSensorNoiseCovariance;
38  
39      /** Standard deviation of sensor noises for sensor. */
40      private double[] sensorNoiseCovariance;
41  
42      /** Frequency of sensor data. */
43      private double sensorFrequency;
44  
45      /** Simple constructor.
46       */
47      public AttitudeDeterminationSensor() {
48          nbSensorNoiseCovariance = -1;
49          sensorFrequency         = Double.NaN;
50      }
51  
52      /** {@inheritDoc} */
53      @Override
54      public void validate(final double version) {
55          super.validate(version);
56          checkNotNegative(sensorNumber, AttitudeDeterminationSensorKey.SENSOR_NUMBER.name());
57          checkNotNull(sensorUsed, AttitudeDeterminationSensorKey.SENSOR_USED.name());
58          if (nbSensorNoiseCovariance >= 0) {
59              final int n = sensorNoiseCovariance == null ? 0 : sensorNoiseCovariance.length;
60              if (nbSensorNoiseCovariance != n) {
61                  throw new OrekitException(OrekitMessages.INCONSISTENT_NUMBER_OF_ELEMENTS,
62                                            nbSensorNoiseCovariance, n);
63              }
64          }
65      }
66  
67      /** Get number of the sensor.
68       * @return number of the sensor
69       */
70      public int getSensorNumber() {
71          return sensorNumber;
72      }
73  
74      /** Set number of the sensor.
75       * @param sensorNumber number of the sensor
76       */
77      public void setSensorNumber(final int sensorNumber) {
78          this.sensorNumber = sensorNumber;
79      }
80  
81      /** Get sensor used.
82       * @return sensor used
83       */
84      public String getSensorUsed() {
85          return sensorUsed;
86      }
87  
88      /** Set sensor used.
89       * @param sensorUsed sensor used
90       */
91      public void setSensorUsed(final String sensorUsed) {
92          this.sensorUsed = sensorUsed;
93      }
94  
95      /** Get number of noise elements for sensor.
96       * @return number of noise elements for sensor
97       */
98      public int getNbSensorNoiseCovariance() {
99          return nbSensorNoiseCovariance;
100     }
101 
102     /** Set number of noise elements for sensor.
103      * @param n number of noise elements for sensor
104      */
105     public void setNbSensorNoiseCovariance(final int n) {
106         nbSensorNoiseCovariance = n;
107     }
108 
109     /** Get standard deviation of sensor noise for sensor.
110      * @return standard deviation of sensor noise for sensor
111      */
112     public double[] getSensorNoiseCovariance() {
113         return sensorNoiseCovariance == null ? null : sensorNoiseCovariance.clone();
114     }
115 
116     /** Set standard deviation of sensor noise for sensor.
117      * @param stddev standard deviation of sensor noise
118      */
119     public void setSensorNoiseCovariance(final double[] stddev) {
120         if (stddev.length != nbSensorNoiseCovariance) {
121             throw new OrekitException(OrekitMessages.INCONSISTENT_NUMBER_OF_ELEMENTS,
122                                       nbSensorNoiseCovariance, stddev.length);
123         }
124         sensorNoiseCovariance = stddev.clone();
125     }
126 
127     /** Get frequency of sensor data for sensor.
128      * @return frequency of sensor data for sensor
129      */
130     public double getSensorFrequency() {
131         return sensorFrequency;
132     }
133 
134     /** Set frequency of sensor data for sensor.
135      * @param frequency frequency of sensor data for sensor
136      */
137     public void setSensorFrequency(final double frequency) {
138         sensorFrequency = frequency;
139     }
140 
141 }