1 /* Copyright 2013 Applied Defense Solutions, Inc. 2 * Licensed to CS Communication & Systèmes (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.handlers; 18 19 import org.orekit.errors.OrekitException; 20 import org.orekit.propagation.SpacecraftState; 21 import org.orekit.propagation.events.EventDetector; 22 23 24 /** 25 * An interface defining how to override event handling behavior in the standard 26 * propagator eventing classes without requiring subclassing. In cases where 27 * one wishes to use anonymous classes rather than explicit subclassing this 28 * allows for a more direct way to override the behavior. Event classes have to 29 * specifically support this capability. 30 * 31 * @author Hank Grabowski 32 * 33 * @param <T> object type that the handler is called from 34 * @since 6.1 35 */ 36 public interface EventHandler<T extends EventDetector> { 37 38 /** Enumerate for actions to be performed when an event occurs. */ 39 public enum Action { 40 41 /** Stop indicator. 42 * <p>This value should be used as the return value of the {@link 43 * #eventOccurred eventOccurred} method when the propagation should be 44 * stopped after the event ending the current step.</p> 45 */ 46 STOP, 47 48 /** Reset state indicator. 49 * <p>This value should be used as the return value of the {@link 50 * #eventOccurred eventOccurred} method when the propagation should 51 * go on after the event ending the current step, with a new state 52 * (which will be retrieved thanks to the {@link #resetState 53 * resetState} method).</p> 54 */ 55 RESET_STATE, 56 57 /** Reset derivatives indicator. 58 * <p>This value should be used as the return value of the {@link 59 * #eventOccurred eventOccurred} method when the propagation should 60 * go on after the event ending the current step, with recomputed 61 * derivatives vector.</p> 62 */ 63 RESET_DERIVATIVES, 64 65 /** Continue indicator. 66 * <p>This value should be used as the return value of the {@link 67 * #eventOccurred eventOccurred} method when the propagation should go 68 * on after the event ending the current step.</p> 69 */ 70 CONTINUE; 71 72 } 73 74 /** 75 * eventOccurred method mirrors the same interface method as in {@link EventDetector} 76 * and its subclasses, but with an additional parameter that allows the calling 77 * method to pass in an object from the detector which would have potential 78 * additional data to allow the implementing class to determine the correct 79 * return state. 80 * 81 * @param s SpaceCraft state to be used in the evaluation 82 * @param detector object with appropriate type that can be used in determining correct return state 83 * @param increasing with the event occured in an "increasing" or "decreasing" slope direction 84 * @return the Action that the calling detector should pass back to the evaluation system 85 * 86 * @exception OrekitException if some specific error occurs 87 */ 88 Action eventOccurred(SpacecraftState s, T detector, boolean increasing) throws OrekitException; 89 90 /** Reset the state prior to continue propagation. 91 * <p>This method is called after the step handler has returned and 92 * before the next step is started, but only when {@link 93 * #eventOccurred} has itself returned the {@link Action#RESET_STATE} 94 * indicator. It allows the user to reset the state for the next step, 95 * without perturbing the step handler of the finishing step. If the 96 * {@link #eventOccurred} never returns the {@link Action#RESET_STATE} 97 * indicator, this function will never be called, and it is safe to simply return null.</p> 98 * @param detector object with appropriate type that can be used in determining correct return state 99 * @param oldState old state 100 * @return new state 101 * @exception OrekitException if the state cannot be reseted 102 */ 103 SpacecraftState resetState(T detector, SpacecraftState oldState) throws OrekitException; 104 105 }