1   /* Copyright 2002-2022 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  
18  package org.orekit.forces.maneuvers.trigger;
19  
20  import java.util.Collections;
21  import java.util.List;
22  import java.util.stream.Stream;
23  
24  import org.hipparchus.CalculusFieldElement;
25  import org.hipparchus.Field;
26  import org.orekit.propagation.FieldSpacecraftState;
27  import org.orekit.propagation.SpacecraftState;
28  import org.orekit.propagation.events.EventDetector;
29  import org.orekit.propagation.events.FieldEventDetector;
30  import org.orekit.time.AbsoluteDate;
31  import org.orekit.time.FieldAbsoluteDate;
32  import org.orekit.utils.ParameterDriver;
33  
34  /** Generic interface for the maneuver triggers used in a {@link org.orekit.forces.maneuvers.Maneuver}.
35   * @author Maxime Journot
36   * @since 10.2
37   */
38  public interface ManeuverTriggers {
39  
40      /** Initialization method called at propagation start.
41       * <p>
42       * The default implementation does nothing.
43       * </p>
44       * @param initialState initial spacecraft state (at the start of propagation).
45       * @param target date of propagation. Not equal to {@code initialState.getDate()}.
46       */
47      default void init(SpacecraftState initialState, AbsoluteDate target) {
48          // nothing by default
49      }
50  
51      /** Initialization method called at propagation start.
52       * <p>
53       * The default implementation does nothing.
54       * </p>
55       * @param initialState initial spacecraft state (at the start of propagation).
56       * @param target date of propagation. Not equal to {@code initialState.getDate()}.
57       * @param <T> type of the elements
58       * @since 11.1
59       */
60      default <T extends CalculusFieldElement<T>> void init(FieldSpacecraftState<T> initialState, FieldAbsoluteDate<T> target) {
61          init(initialState.toSpacecraftState(), target.toAbsoluteDate());
62      }
63  
64      /** Get the event detectors associated with the triggers.
65       * @return the event detectors
66       */
67      Stream<EventDetector> getEventsDetectors();
68  
69      /** Get the event detectors associated with the triggers.
70       * @param field field to which the state belongs
71       * @param <T> type of the field elements
72       * @return the event detectors
73       */
74      <T extends CalculusFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventsDetectors(Field<T> field);
75  
76      /** Find out if the maneuver is firing or not.
77       * @param date current date
78       * @param parameters maneuver triggers parameters
79       * @return true if the maneuver is firing, false otherwise
80       */
81      boolean isFiring(AbsoluteDate date, double[] parameters);
82  
83      /** Find out if the maneuver is firing or not.
84       * @param date current date
85       * @param parameters maneuver triggers parameters
86       * @param <T> type of the field elements
87       * @return true if the maneuver is firing, false otherwise
88       */
89      <T extends CalculusFieldElement<T>> boolean isFiring(FieldAbsoluteDate<T> date, T[] parameters);
90  
91      /** Get the maneuver triggers parameter drivers.
92       * @return maneuver triggers parameter drivers
93       */
94      default List<ParameterDriver> getParametersDrivers() {
95          return Collections.emptyList();
96      }
97  
98      /** Get the maneuver name.
99       * @return the maneuver name
100      */
101     default String getName() {
102         return "";
103     }
104 }