1 /* Copyright 2002-2015 CS Systèmes d'Information
2 * Licensed to CS Systèmes d'Information (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.events;
18
19 import java.io.Serializable;
20
21 import org.orekit.errors.OrekitException;
22 import org.orekit.propagation.SpacecraftState;
23 import org.orekit.propagation.events.handlers.EventHandler.Action;
24 import org.orekit.time.AbsoluteDate;
25
26 /** This interface represents space-dynamics aware events detectors.
27 *
28 * <p>It mirrors the {@link org.apache.commons.math3.ode.events.EventHandler
29 * EventHandler} interface from <a href="http://commons.apache.org/math/">
30 * Apache Commons Math</a> but provides a space-dynamics interface to the
31 * methods.</p>
32 *
33 * <p>Events detectors are a useful solution to meet the requirements
34 * of propagators concerning discrete conditions. The state of each
35 * event detector is queried by the integrator at each step. When the
36 * sign of the underlying g switching function changes, the step is rejected
37 * and reduced, in order to make sure the sign changes occur only at steps
38 * boundaries.</p>
39 *
40 * <p>When step ends exactly at a switching function sign change, the corresponding
41 * event is triggered, by calling the {@link #eventOccurred(SpacecraftState, boolean)}
42 * method. The method can do whatever it needs with the event (logging it, performing
43 * some processing, ignore it ...). The return value of the method will be used by
44 * the propagator to stop or resume propagation, possibly changing the state vector.<p>
45 *
46 * @author Luc Maisonobe
47 * @author Véronique Pommier-Maurussane
48 */
49 public interface EventDetector extends Serializable {
50
51 /** Initialize event handler at the start of a propagation.
52 * <p>
53 * This method is called once at the start of the propagation. It
54 * may be used by the event handler to initialize some internal data
55 * if needed.
56 * </p>
57 * @param s0 initial state
58 * @param t target time for the integration
59 */
60 void init(SpacecraftState s0, AbsoluteDate t);
61
62 /** Compute the value of the switching function.
63 * This function must be continuous (at least in its roots neighborhood),
64 * as the integrator will need to find its roots to locate the events.
65 * @param s the current state information: date, kinematics, attitude
66 * @return value of the switching function
67 * @exception OrekitException if some specific error occurs
68 */
69 double g(SpacecraftState s) throws OrekitException;
70
71 /** Get the convergence threshold in the event time search.
72 * @return convergence threshold (s)
73 */
74 double getThreshold();
75
76 /** Get maximal time interval between switching function checks.
77 * @return maximal time interval (s) between switching function checks
78 */
79 double getMaxCheckInterval();
80
81 /** Get maximal number of iterations in the event time search.
82 * @return maximal number of iterations in the event time search
83 */
84 int getMaxIterationCount();
85
86 /** Handle the event.
87 * @param s SpaceCraft state to be used in the evaluation
88 * @param increasing with the event occured in an "increasing" or "decreasing" slope direction
89 * @return the Action that the calling detector should pass back to the evaluation system
90 * @exception OrekitException if some specific error occurs
91 * @since 7.0
92 */
93 Action eventOccurred(SpacecraftState s, boolean increasing) throws OrekitException;
94
95 /** Reset the state prior to continue propagation.
96 * <p>This method is called after the step handler has returned and
97 * before the next step is started, but only when {@link
98 * #eventOccurred} has itself returned the {@link Action#RESET_STATE}
99 * indicator. It allows the user to reset the state for the next step,
100 * without perturbing the step handler of the finishing step. If the
101 * {@link #eventOccurred} never returns the {@link Action#RESET_STATE}
102 * indicator, this function will never be called, and it is safe to simply return null.</p>
103 * @param oldState old state
104 * @return new state
105 * @exception OrekitException if the state cannot be reseted
106 * @since 7.0
107 */
108 SpacecraftState resetState(SpacecraftState oldState) throws OrekitException;
109
110 }