FieldEventHandler.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.CalculusFieldElement;
  19. import org.hipparchus.ode.events.Action;
  20. import org.orekit.propagation.FieldSpacecraftState;
  21. import org.orekit.propagation.events.FieldEventDetector;
  22. import org.orekit.time.FieldAbsoluteDate;


  23. /** An interface defining how to handle events occurring during propagation..
  24.  *
  25.  * @author Hank Grabowski
  26.  *
  27.  * @param <T> type of the field element
  28.  * @since 6.1
  29.  */
  30. public interface FieldEventHandler<T extends CalculusFieldElement<T>> {

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

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

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


  75.     /**
  76.      * This method finalize event handler at the end of a propagation.
  77.      * <p>
  78.      * The default implementation does nothing
  79.      * </p>
  80.      * @param finalState state at propagation end
  81.      * @param detector event detector related to the event handler
  82.      * @since 12.2
  83.      */
  84.     default void finish(final FieldSpacecraftState<T> finalState, final FieldEventDetector<T> detector) {
  85.         // nothing by default
  86.     }

  87. }