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