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
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.Field;
25 import org.hipparchus.CalculusFieldElement;
26 import org.orekit.forces.maneuvers.Maneuver;
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 Maneuver}.
35 * @author Maxime Journot
36 * @since 10.2
37 */
38 public interface ManeuverTriggers {
39
40 /** Initialization method.
41 * Called in when Maneuver.init(...) is called (from ForceModel.init(...)).
42 * @param initialState initial spacecraft state (at the start of propagation).
43 * @param target date of propagation. Not equal to {@code initialState.getDate()}.
44 */
45 default void init(SpacecraftState initialState, AbsoluteDate target) {
46 }
47
48 /** Get the event detectors associated with the triggers.
49 * @return the event detectors
50 */
51 Stream<EventDetector> getEventsDetectors();
52
53 /** Get the event detectors associated with the triggers.
54 * @param field field to which the state belongs
55 * @param <T> extends CalculusFieldElement<T>
56 * @return the event detectors
57 */
58 <T extends CalculusFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventsDetectors(Field<T> field);
59
60 /** Find out if the maneuver is firing or not.
61 * @param date current date
62 * @param parameters maneuver triggers parameters
63 * @return true if the maneuver is firing, false otherwise
64 */
65 boolean isFiring(AbsoluteDate date, double[] parameters);
66
67 /** Find out if the maneuver is firing or not.
68 * @param date current date
69 * @param parameters maneuver triggers parameters
70 * @param <T> extends CalculusFieldElement<T>
71 * @return true if the maneuver is firing, false otherwise
72 */
73 <T extends CalculusFieldElement<T>> boolean isFiring(FieldAbsoluteDate<T> date, T[] parameters);
74
75 /** Get the maneuver triggers parameter drivers.
76 * @return maneuver triggers parameter drivers
77 */
78 default List<ParameterDriver> getParametersDrivers() {
79 return Collections.emptyList();
80 }
81
82 /** Get the maneuver name.
83 * @return the maneuver name
84 */
85 default String getName() {
86 return "";
87 }
88 }