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.propagation.numerical;
18  
19  import org.hipparchus.ode.nonstiff.ClassicalRungeKuttaIntegrator;
20  import org.orekit.annotation.DefaultDataContext;
21  import org.orekit.attitudes.AttitudeProvider;
22  import org.orekit.attitudes.InertialProvider;
23  import org.orekit.data.DataContext;
24  import org.orekit.frames.Frame;
25  import org.orekit.propagation.Propagator;
26  import org.orekit.propagation.analytical.gnss.data.GLONASSOrbitalElements;
27  
28  /**
29   * This nested class aims at building a GLONASSNumericalPropagator.
30   * <p>It implements the classical builder pattern.</p>
31   * @author Bryan Cazabonne
32   * @since 11.0
33   */
34  public class GLONASSNumericalPropagatorBuilder {
35  
36      //////////
37      // Required parameter
38      //////////
39  
40      /** The GLONASS orbital elements. */
41      private final GLONASSOrbitalElements orbit;
42  
43      /** The 4th order Runge-Kutta integrator. */
44      private final ClassicalRungeKuttaIntegrator integrator;
45  
46      /** Flag for availability of projections of acceleration transmitted within the navigation message. */
47      private final boolean isAccAvailable;
48  
49      ///////////
50      // Optional parameters
51      //////////
52  
53      /** The attitude provider. */
54      private AttitudeProvider attitudeProvider;
55  
56      /** The mass. */
57      private double mass;
58  
59      /** The ECI frame. */
60      private Frame eci;
61  
62      /** Data context for the propagator. */
63      private DataContext dataContext;
64  
65      /**
66       * Initializes the builder.
67       * <p>The attitude provider is set by default to EME2000 aligned in the
68       *  default data context.<br>
69       * The mass is set by default to the
70       *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
71       * The data context is by default to the
72       *  {@link DataContext#getDefault() default data context}.<br>
73       * The ECI frame is set by default to the
74       *  {@link org.orekit.frames.Predefined#EME2000 EME2000 frame} in the default data
75       *  context.<br>
76       * </p>
77       *
78       * @param integrator 4th order Runge-Kutta as recommended by GLONASS ICD
79       * @param glonassOrbElt the GLONASS orbital elements to be used by the GLONASSNumericalPropagator.
80       * @param isAccAvailable flag for availability of the projections of accelerations transmitted within
81       *        the navigation message
82       * @see #attitudeProvider(AttitudeProvider provider)
83       * @see #mass(double mass)
84       * @see #eci(Frame inertial)
85       */
86      @DefaultDataContext
87      public GLONASSNumericalPropagatorBuilder(final ClassicalRungeKuttaIntegrator integrator,
88                                               final GLONASSOrbitalElements glonassOrbElt,
89                                               final boolean isAccAvailable) {
90          this(integrator, glonassOrbElt, isAccAvailable, DataContext.getDefault());
91      }
92  
93  
94      /**
95       * Initializes the builder.
96       * <p>The attitude provider is set by default to EME2000 aligned in the
97       *  provided data context.<br>
98       * The mass is set by default to the
99       *  {@link org.orekit.propagation.Propagator#DEFAULT_MASS DEFAULT_MASS}.<br>
100      * The ECI frame is set by default to the
101      *  {@link org.orekit.frames.Predefined#EME2000 EME2000 frame} in the default data
102      *  context.<br>
103      * </p>
104      *
105      * @param integrator 4th order Runge-Kutta as recommended by GLONASS ICD
106      * @param glonassOrbElt the GLONASS orbital elements to be used by the GLONASSNumericalPropagator.
107      * @param isAccAvailable flag for availability of the projections of accelerations transmitted within
108      *        the navigation message
109      * @param context data context
110      * @see #attitudeProvider(AttitudeProvider provider)
111      * @see #mass(double mass)
112      * @see #eci(Frame inertial)
113      */
114     public GLONASSNumericalPropagatorBuilder(final ClassicalRungeKuttaIntegrator integrator,
115                                              final GLONASSOrbitalElements glonassOrbElt,
116                                              final boolean isAccAvailable,
117                                              final DataContext context) {
118         this.isAccAvailable   = isAccAvailable;
119         this.integrator       = integrator;
120         this.orbit            = glonassOrbElt;
121         this.mass             = Propagator.DEFAULT_MASS;
122         this.dataContext      = context;
123         this.eci              = dataContext.getFrames().getEME2000();
124         this.attitudeProvider = InertialProvider.of(this.eci);
125     }
126 
127     /**
128      * Sets the attitude provider.
129      *
130      * @param userProvider the attitude provider
131      * @return the updated builder
132      */
133     public GLONASSNumericalPropagatorBuilder attitudeProvider(final AttitudeProvider userProvider) {
134         this.attitudeProvider = userProvider;
135         return this;
136     }
137 
138     /**
139      * Sets the mass.
140      *
141      * @param userMass the mass (in kg)
142      * @return the updated builder
143      */
144     public GLONASSNumericalPropagatorBuilder mass(final double userMass) {
145         this.mass = userMass;
146         return this;
147     }
148 
149     /**
150      * Sets the Earth Centered Inertial frame used for propagation.
151      *
152      * @param inertial the ECI frame
153      * @return the updated builder
154      */
155     public GLONASSNumericalPropagatorBuilder eci(final Frame inertial) {
156         this.eci = inertial;
157         return this;
158     }
159 
160     /**
161      * Finalizes the build.
162      *
163      * @return the built Glonass numerical propagator
164      */
165     public GLONASSNumericalPropagator build() {
166         return new GLONASSNumericalPropagator(integrator, orbit, eci, attitudeProvider,
167                                               mass, dataContext, isAccAvailable);
168     }
169 
170 }