EventHandler.java

  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. import org.hipparchus.ode.events.Action;
  19. import org.orekit.propagation.SpacecraftState;
  20. import org.orekit.propagation.events.EventDetector;
  21. import org.orekit.time.AbsoluteDate;


  22. /** An interface defining how to handle events occurring during propagation.
  23.  *
  24.  * @author Hank Grabowski
  25.  *
  26.  * @since 6.1
  27.  */
  28. public interface EventHandler {

  29.     /** Initialize event handler at the start of a propagation.
  30.      * <p>
  31.      * This method is called once at the start of the propagation. It
  32.      * may be used by the event handler to initialize some internal data
  33.      * if needed.
  34.      * </p>
  35.      * <p>
  36.      * The default implementation does nothing
  37.      * </p>
  38.      * @param initialState initial state
  39.      * @param target target date for the propagation
  40.      * @param detector event detector related to the event handler
  41.      *
  42.      */
  43.     default void init(SpacecraftState initialState, AbsoluteDate target, final EventDetector detector) {
  44.         // nothing by default
  45.     }

  46.     /** Handle an event.
  47.      *
  48.      * @param s SpaceCraft state to be used in the evaluation
  49.      * @param detector object with appropriate type that can be used in determining correct return state
  50.      * @param increasing with the event occurred in an "increasing" or "decreasing" slope direction
  51.      * @return the Action that the calling detector should pass back to the evaluation system
  52.      *
  53.      */
  54.     Action eventOccurred(SpacecraftState s, EventDetector detector, boolean increasing);

  55.     /** Reset the state prior to continue propagation.
  56.      * <p>This method is called after the step handler has returned and
  57.      * before the next step is started, but only when {@link
  58.      * #eventOccurred} has itself returned the {@link Action#RESET_STATE}
  59.      * indicator. It allows the user to reset the state for the next step,
  60.      * without perturbing the step handler of the finishing step. If the
  61.      * {@link #eventOccurred} never returns the {@link Action#RESET_STATE}
  62.      * indicator, this function will never be called, and it is safe to simply return null.</p>
  63.      * <p>
  64.      * The default implementation simply return its argument.
  65.      * </p>
  66.      * @param detector object with appropriate type that can be used in determining correct return state
  67.      * @param oldState old state
  68.      * @return new state
  69.      */
  70.     default SpacecraftState resetState(EventDetector detector, SpacecraftState oldState) {
  71.         return oldState;
  72.     }


  73.     /**
  74.      * This method finalizes the event handler's job.
  75.      * <p>
  76.      * The default implementation does nothing
  77.      * </p>
  78.      * @param finalState state at propagation end
  79.      * @param detector event detector related to the event handler
  80.      * @since 12.2
  81.      */
  82.     default void finish(final SpacecraftState finalState, final EventDetector detector) {
  83.         // nothing by default
  84.     }

  85. }