FieldEventState.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF 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. import org.hipparchus.Field;
  19. import org.hipparchus.RealFieldElement;
  20. import org.hipparchus.analysis.UnivariateFunction;
  21. import org.hipparchus.analysis.solvers.BracketedUnivariateSolver;
  22. import org.hipparchus.analysis.solvers.BracketedUnivariateSolver.Interval;
  23. import org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver;
  24. import org.hipparchus.exception.MathRuntimeException;
  25. import org.hipparchus.ode.events.Action;
  26. import org.hipparchus.util.FastMath;
  27. import org.hipparchus.util.Precision;
  28. import org.orekit.errors.OrekitInternalError;
  29. import org.orekit.propagation.FieldSpacecraftState;
  30. import org.orekit.propagation.sampling.FieldOrekitStepInterpolator;
  31. import org.orekit.time.FieldAbsoluteDate;

  32. /** This class handles the state for one {@link FieldEventDetector
  33.  * event detector} during integration steps.
  34.  *
  35.  * <p>This class is heavily based on the class with the same name from the
  36.  * Hipparchus library. The changes performed consist in replacing
  37.  * raw types (double and double arrays) with space dynamics types
  38.  * ({@link FieldAbsoluteDate}, {@link FieldSpacecraftState}).</p>
  39.  * <p>Each time the propagator proposes a step, the event detector
  40.  * should be checked. This class handles the state of one detector
  41.  * during one propagation step, with references to the state at the
  42.  * end of the preceding step. This information is used to determine if
  43.  * the detector should trigger an event or not during the proposed
  44.  * step (and hence the step should be reduced to ensure the event
  45.  * occurs at a bound rather than inside the step).</p>
  46.  * @author Luc Maisonobe
  47.  * @param <D> class type for the generic version
  48.  */
  49. public class FieldEventState<D extends FieldEventDetector<T>, T extends RealFieldElement<T>> {

  50.     /** Event detector. */
  51.     private D detector;

  52.     /** Time of the previous call to g. */
  53.     private FieldAbsoluteDate<T> lastT;

  54.     /** Value from the previous call to g. */
  55.     private T lastG;

  56.     /** Time at the beginning of the step. */
  57.     private FieldAbsoluteDate<T> t0;

  58.     /** Value of the event detector at the beginning of the step. */
  59.     private T g0;

  60.     /** Simulated sign of g0 (we cheat when crossing events). */
  61.     private boolean g0Positive;

  62.     /** Indicator of event expected during the step. */
  63.     private boolean pendingEvent;

  64.     /** Occurrence time of the pending event. */
  65.     private FieldAbsoluteDate<T> pendingEventTime;

  66.     /**
  67.      * Time to stop propagation if the event is a stop event. Used to enable stopping at
  68.      * an event and then restarting after that event.
  69.      */
  70.     private FieldAbsoluteDate<T> stopTime;

  71.     /** Time after the current event. */
  72.     private FieldAbsoluteDate<T> afterEvent;

  73.     /** Value of the g function after the current event. */
  74.     private T afterG;

  75.     /** The earliest time considered for events. */
  76.     private FieldAbsoluteDate<T> earliestTimeConsidered;

  77.     /** Integration direction. */
  78.     private boolean forward;

  79.     /** Variation direction around pending event.
  80.      *  (this is considered with respect to the integration direction)
  81.      */
  82.     private boolean increasing;

  83.     /** Simple constructor.
  84.      * @param detector monitored event detector
  85.      */
  86.     public FieldEventState(final D detector) {

  87.         this.detector = detector;

  88.         // some dummy values ...
  89.         final Field<T> field   = detector.getMaxCheckInterval().getField();
  90.         final T nan            = field.getZero().add(Double.NaN);
  91.         lastT                  = FieldAbsoluteDate.getPastInfinity(field);
  92.         lastG                  = nan;
  93.         t0                     = null;
  94.         g0                     = nan;
  95.         g0Positive             = true;
  96.         pendingEvent           = false;
  97.         pendingEventTime       = null;
  98.         stopTime               = null;
  99.         increasing             = true;
  100.         earliestTimeConsidered = null;
  101.         afterEvent             = null;
  102.         afterG                 = nan;

  103.     }

  104.     /** Get the underlying event detector.
  105.      * @return underlying event detector
  106.      */
  107.     public D getEventDetector() {
  108.         return detector;
  109.     }

  110.     /** Initialize event handler at the start of a propagation.
  111.      * <p>
  112.      * This method is called once at the start of the propagation. It
  113.      * may be used by the event handler to initialize some internal data
  114.      * if needed.
  115.      * </p>
  116.      * @param s0 initial state
  117.      * @param t target time for the integration
  118.      *
  119.      */
  120.     public void init(final FieldSpacecraftState<T> s0,
  121.                      final FieldAbsoluteDate<T> t) {
  122.         detector.init(s0, t);
  123.         final Field<T> field = detector.getMaxCheckInterval().getField();
  124.         lastT = FieldAbsoluteDate.getPastInfinity(field);
  125.         lastG = field.getZero().add(Double.NaN);
  126.     }

  127.     /** Compute the value of the switching function.
  128.      * This function must be continuous (at least in its roots neighborhood),
  129.      * as the integrator will need to find its roots to locate the events.
  130.      * @param s the current state information: date, kinematics, attitude
  131.      * @return value of the switching function
  132.      */
  133.     private T g(final FieldSpacecraftState<T> s) {
  134.         if (!s.getDate().equals(lastT)) {
  135.             lastT = s.getDate();
  136.             lastG = detector.g(s);
  137.         }
  138.         return lastG;
  139.     }

  140.     /** Reinitialize the beginning of the step.
  141.      * @param interpolator interpolator valid for the current step
  142.      */
  143.     public void reinitializeBegin(final FieldOrekitStepInterpolator<T> interpolator) {
  144.         forward = interpolator.isForward();
  145.         final FieldSpacecraftState<T> s0 = interpolator.getPreviousState();
  146.         this.t0 = s0.getDate();
  147.         g0 = g(s0);
  148.         while (g0.getReal() == 0) {
  149.             // extremely rare case: there is a zero EXACTLY at interval start
  150.             // we will use the sign slightly after step beginning to force ignoring this zero
  151.             // try moving forward by half a convergence interval
  152.             final T dt = detector.getThreshold().multiply(forward ? 0.5 : -0.5);
  153.             FieldAbsoluteDate<T> startDate = t0.shiftedBy(dt);
  154.             // if convergence is too small move an ulp
  155.             if (t0.equals(startDate)) {
  156.                 startDate = nextAfter(startDate);
  157.             }
  158.             t0 = startDate;
  159.             g0 = g(interpolator.getInterpolatedState(t0));
  160.         }
  161.         g0Positive = g0.getReal() > 0;
  162.         // "last" event was increasing
  163.         increasing = g0Positive;
  164.     }

  165.     /** Evaluate the impact of the proposed step on the event detector.
  166.      * @param interpolator step interpolator for the proposed step
  167.      * @return true if the event detector triggers an event before
  168.      * the end of the proposed step (this implies the step should be
  169.      * rejected)
  170.      * @exception MathRuntimeException if an event cannot be located
  171.      */
  172.     public boolean evaluateStep(final FieldOrekitStepInterpolator<T> interpolator)
  173.         throws MathRuntimeException {
  174.         forward = interpolator.isForward();
  175.         final FieldSpacecraftState<T> s1 = interpolator.getCurrentState();
  176.         final FieldAbsoluteDate<T> t1 = s1.getDate();
  177.         final T dt = t1.durationFrom(t0);
  178.         if (FastMath.abs(dt.getReal()) < detector.getThreshold().getReal()) {
  179.             // we cannot do anything on such a small step, don't trigger any events
  180.             return false;
  181.         }
  182.         // number of points to check in the current step
  183.         final int n = FastMath.max(1, (int) FastMath.ceil(FastMath.abs(dt.getReal()) / detector.getMaxCheckInterval().getReal()));
  184.         final T h = dt.divide(n);


  185.         FieldAbsoluteDate<T> ta = t0;
  186.         T ga = g0;
  187.         for (int i = 0; i < n; ++i) {

  188.             // evaluate handler value at the end of the substep
  189.             final FieldAbsoluteDate<T> tb = (i == n - 1) ? t1 : t0.shiftedBy(h.multiply(i + 1));
  190.             final T gb = g(interpolator.getInterpolatedState(tb));

  191.             // check events occurrence
  192.             if (gb.getReal() == 0.0 || (g0Positive ^ (gb.getReal() > 0))) {
  193.                 // there is a sign change: an event is expected during this step
  194.                 if (findRoot(interpolator, ta, ga, tb, gb)) {
  195.                     return true;
  196.                 }
  197.             } else {
  198.                 // no sign change: there is no event for now
  199.                 ta = tb;
  200.                 ga = gb;
  201.             }
  202.         }

  203.         // no event during the whole step
  204.         pendingEvent     = false;
  205.         pendingEventTime = null;
  206.         return false;

  207.     }

  208.     /**
  209.      * Find a root in a bracketing interval.
  210.      *
  211.      * <p> When calling this method one of the following must be true. Either ga == 0, gb
  212.      * == 0, (ga < 0  and gb > 0), or (ga > 0 and gb < 0).
  213.      *
  214.      * @param interpolator that covers the interval.
  215.      * @param ta           earliest possible time for root.
  216.      * @param ga           g(ta).
  217.      * @param tb           latest possible time for root.
  218.      * @param gb           g(tb).
  219.      * @return if a zero crossing was found.
  220.      */
  221.     private boolean findRoot(final FieldOrekitStepInterpolator<T> interpolator,
  222.                              final FieldAbsoluteDate<T> ta, final T ga,
  223.                              final FieldAbsoluteDate<T> tb, final T gb) {

  224.         final T zero = ga.getField().getZero();

  225.         // check there appears to be a root in [ta, tb]
  226.         check(ga.getReal() == 0.0 || gb.getReal() == 0.0 || (ga.getReal() > 0.0 && gb.getReal() < 0.0) || (ga.getReal() < 0.0 && gb.getReal() > 0.0));
  227.         final T convergence = detector.getThreshold();
  228.         final int maxIterationCount = detector.getMaxIterationCount();
  229.         final BracketedUnivariateSolver<UnivariateFunction> solver =
  230.                 new BracketingNthOrderBrentSolver(0, convergence.getReal(), 0, 5);

  231.         // event time, just at or before the actual root.
  232.         FieldAbsoluteDate<T> beforeRootT = null;
  233.         T beforeRootG = zero.add(Double.NaN);
  234.         // time on the other side of the root.
  235.         // Initialized the the loop below executes once.
  236.         FieldAbsoluteDate<T> afterRootT = ta;
  237.         T afterRootG = zero;

  238.         // check for some conditions that the root finders don't like
  239.         // these conditions cannot not happen in the loop below
  240.         // the ga == 0.0 case is handled by the loop below
  241.         if (ta.equals(tb)) {
  242.             // both non-zero but times are the same. Probably due to reset state
  243.             beforeRootT = ta;
  244.             beforeRootG = ga;
  245.             afterRootT = shiftedBy(beforeRootT, convergence);
  246.             afterRootG = g(interpolator.getInterpolatedState(afterRootT));
  247.         } else if (ga.getReal() != 0.0 && gb.getReal() == 0.0) {
  248.             // hard: ga != 0.0 and gb == 0.0
  249.             // look past gb by up to convergence to find next sign
  250.             // throw an exception if g(t) = 0.0 in [tb, tb + convergence]
  251.             beforeRootT = tb;
  252.             beforeRootG = gb;
  253.             afterRootT = shiftedBy(beforeRootT, convergence);
  254.             afterRootG = g(interpolator.getInterpolatedState(afterRootT));
  255.         } else if (ga.getReal() != 0.0) {
  256.             final T newGa = g(interpolator.getInterpolatedState(ta));
  257.             if (ga.getReal() > 0 != newGa.getReal() > 0) {
  258.                 // both non-zero, step sign change at ta, possibly due to reset state
  259.                 beforeRootT = ta;
  260.                 beforeRootG = newGa;
  261.                 afterRootT = minTime(shiftedBy(beforeRootT, convergence), tb);
  262.                 afterRootG = g(interpolator.getInterpolatedState(afterRootT));
  263.             }
  264.         }
  265.         // loop to skip through "fake" roots, i.e. where g(t) = g'(t) = 0.0
  266.         // executed once if we didn't hit a special case above
  267.         FieldAbsoluteDate<T> loopT = ta;
  268.         T loopG = ga;
  269.         while ((afterRootG.getReal() == 0.0 || afterRootG.getReal() > 0.0 == g0Positive) &&
  270.                 strictlyAfter(afterRootT, tb)) {
  271.             if (loopG.getReal() == 0.0) {
  272.                 // ga == 0.0 and gb may or may not be 0.0
  273.                 // handle the root at ta first
  274.                 beforeRootT = loopT;
  275.                 beforeRootG = loopG;
  276.                 afterRootT = minTime(shiftedBy(beforeRootT, convergence), tb);
  277.                 afterRootG = g(interpolator.getInterpolatedState(afterRootT));
  278.             } else {
  279.                 // both non-zero, the usual case, use a root finder.
  280.                 // time zero for evaluating the function f. Needs to be final
  281.                 final FieldAbsoluteDate<T> fT0 = loopT;
  282.                 final UnivariateFunction f = dt -> {
  283.                     return g(interpolator.getInterpolatedState(fT0.shiftedBy(dt))).getReal();
  284.                 };
  285.                 // tb as a double for use in f
  286.                 final T tbDouble = tb.durationFrom(fT0);
  287.                 if (forward) {
  288.                     final Interval interval =
  289.                             solver.solveInterval(maxIterationCount, f, 0, tbDouble.getReal());
  290.                     beforeRootT = fT0.shiftedBy(interval.getLeftAbscissa());
  291.                     beforeRootG = zero.add(interval.getLeftValue());
  292.                     afterRootT = fT0.shiftedBy(interval.getRightAbscissa());
  293.                     afterRootG = zero.add(interval.getRightValue());
  294.                 } else {
  295.                     final Interval interval =
  296.                             solver.solveInterval(maxIterationCount, f, tbDouble.getReal(), 0);
  297.                     beforeRootT = fT0.shiftedBy(interval.getRightAbscissa());
  298.                     beforeRootG = zero.add(interval.getRightValue());
  299.                     afterRootT = fT0.shiftedBy(interval.getLeftAbscissa());
  300.                     afterRootG = zero.add(interval.getLeftValue());
  301.                 }
  302.             }
  303.             // tolerance is set to less than 1 ulp
  304.             // assume tolerance is 1 ulp
  305.             if (beforeRootT.equals(afterRootT)) {
  306.                 afterRootT = nextAfter(afterRootT);
  307.                 afterRootG = g(interpolator.getInterpolatedState(afterRootT));
  308.             }
  309.             // check loop is making some progress
  310.             check((forward && afterRootT.compareTo(beforeRootT) > 0) ||
  311.                   (!forward && afterRootT.compareTo(beforeRootT) < 0));
  312.             // setup next iteration
  313.             loopT = afterRootT;
  314.             loopG = afterRootG;
  315.         }

  316.         // figure out the result of root finding, and return accordingly
  317.         if (afterRootG.getReal() == 0.0 || afterRootG.getReal() > 0.0 == g0Positive) {
  318.             // loop gave up and didn't find any crossing within this step
  319.             return false;
  320.         } else {
  321.             // real crossing
  322.             check(beforeRootT != null && !Double.isNaN(beforeRootG.getReal()));
  323.             // variation direction, with respect to the integration direction
  324.             increasing = !g0Positive;
  325.             pendingEventTime = beforeRootT;
  326.             stopTime = beforeRootG.getReal() == 0.0 ? beforeRootT : afterRootT;
  327.             pendingEvent = true;
  328.             afterEvent = afterRootT;
  329.             afterG = afterRootG;

  330.             // check increasing set correctly
  331.             check(afterG.getReal() > 0 == increasing);
  332.             check(increasing == gb.getReal() >= ga.getReal());

  333.             return true;
  334.         }

  335.     }

  336.     /**
  337.      * Get the next number after the given number in the current propagation direction.
  338.      *
  339.      * @param t input time
  340.      * @return t +/- 1 ulp depending on the direction.
  341.      */
  342.     private FieldAbsoluteDate<T> nextAfter(final FieldAbsoluteDate<T> t) {
  343.         return t.shiftedBy(forward ? +Precision.EPSILON : -Precision.EPSILON);
  344.     }


  345.     /** Get the occurrence time of the event triggered in the current
  346.      * step.
  347.      * @return occurrence time of the event triggered in the current
  348.      * step.
  349.      */
  350.     public FieldAbsoluteDate<T> getEventDate() {
  351.         return pendingEventTime;
  352.     }

  353.     /**
  354.      * Try to accept the current history up to the given time.
  355.      *
  356.      * <p> It is not necessary to call this method before calling {@link
  357.      * #doEvent(FieldSpacecraftState)} with the same state. It is necessary to call this
  358.      * method before you call {@link #doEvent(FieldSpacecraftState)} on some other event
  359.      * detector.
  360.      *
  361.      * @param state        to try to accept.
  362.      * @param interpolator to use to find the new root, if any.
  363.      * @return if the event detector has an event it has not detected before that is on or
  364.      * before the same time as {@code state}. In other words {@code false} means continue
  365.      * on while {@code true} means stop and handle my event first.
  366.      */
  367.     public boolean tryAdvance(final FieldSpacecraftState<T> state,
  368.                               final FieldOrekitStepInterpolator<T> interpolator) {
  369.         final FieldAbsoluteDate<T> t = state.getDate();
  370.         // check this is only called before a pending event.
  371.         check(!pendingEvent || !strictlyAfter(pendingEventTime, t));

  372.         final boolean meFirst;

  373.         if (strictlyAfter(t, earliestTimeConsidered)) {
  374.             // just found an event and we know the next time we want to search again
  375.             meFirst = false;
  376.         } else {
  377.             // check g function to see if there is a new event
  378.             final T g = g(state);
  379.             final boolean positive = g.getReal() > 0;

  380.             if (positive == g0Positive) {
  381.                 // g function has expected sign
  382.                 g0 = g; // g0Positive is the same
  383.                 meFirst = false;
  384.             } else {
  385.                 // found a root we didn't expect -> find precise location
  386.                 final FieldAbsoluteDate<T> oldPendingEventTime = pendingEventTime;
  387.                 final boolean foundRoot = findRoot(interpolator, t0, g0, t, g);
  388.                 // make sure the new root is not the same as the old root, if one exists
  389.                 meFirst = foundRoot && !pendingEventTime.equals(oldPendingEventTime);
  390.             }
  391.         }

  392.         if (!meFirst) {
  393.             // advance t0 to the current time so we can't find events that occur before t
  394.             t0 = t;
  395.         }

  396.         return meFirst;
  397.     }

  398.     /**
  399.      * Notify the user's listener of the event. The event occurs wholly within this method
  400.      * call including a call to {@link FieldEventDetector#resetState(FieldSpacecraftState)}
  401.      * if necessary.
  402.      *
  403.      * @param state the state at the time of the event. This must be at the same time as
  404.      *              the current value of {@link #getEventDate()}.
  405.      * @return the user's requested action and the new state if the action is {@link
  406.      * Action#RESET_STATE}. Otherwise
  407.      * the new state is {@code state}. The stop time indicates what time propagation should
  408.      * stop if the action is {@link Action#STOP}.
  409.      * This guarantees the integration will stop on or after the root, so that integration
  410.      * may be restarted safely.
  411.      */
  412.     public EventOccurrence<T> doEvent(final FieldSpacecraftState<T> state) {
  413.         // check event is pending and is at the same time
  414.         check(pendingEvent);
  415.         check(state.getDate().equals(this.pendingEventTime));

  416.         final Action action = detector.eventOccurred(state, increasing == forward);
  417.         final FieldSpacecraftState<T> newState;
  418.         if (action == Action.RESET_STATE) {
  419.             newState = detector.resetState(state);
  420.         } else {
  421.             newState = state;
  422.         }
  423.         // clear pending event
  424.         pendingEvent     = false;
  425.         pendingEventTime = null;
  426.         // setup for next search
  427.         earliestTimeConsidered = afterEvent;
  428.         t0 = afterEvent;
  429.         g0 = afterG;
  430.         g0Positive = increasing;
  431.         // check g0Positive set correctly
  432.         check(g0.getReal() == 0.0 || g0Positive == (g0.getReal() > 0));
  433.         return new EventOccurrence<T>(action, newState, stopTime);
  434.     }

  435.     /**
  436.      * Shift a time value along the current integration direction: {@link #forward}.
  437.      *
  438.      * @param t     the time to shift.
  439.      * @param delta the amount to shift.
  440.      * @return t + delta if forward, else t - delta. If the result has to be rounded it
  441.      * will be rounded to be before the true value of t + delta.
  442.      */
  443.     private FieldAbsoluteDate<T> shiftedBy(final FieldAbsoluteDate<T> t, final T delta) {
  444.         if (forward) {
  445.             final FieldAbsoluteDate<T> ret = t.shiftedBy(delta);
  446.             if (ret.durationFrom(t).getReal() > delta.getReal()) {
  447.                 return ret.shiftedBy(-Precision.EPSILON);
  448.             } else {
  449.                 return ret;
  450.             }
  451.         } else {
  452.             final FieldAbsoluteDate<T> ret = t.shiftedBy(delta.negate());
  453.             if (t.durationFrom(ret).getReal() > delta.getReal()) {
  454.                 return ret.shiftedBy(+Precision.EPSILON);
  455.             } else {
  456.                 return ret;
  457.             }
  458.         }
  459.     }

  460.     /**
  461.      * Get the time that happens first along the current propagation direction: {@link
  462.      * #forward}.
  463.      *
  464.      * @param a first time
  465.      * @param b second time
  466.      * @return min(a, b) if forward, else max (a, b)
  467.      */
  468.     private FieldAbsoluteDate<T> minTime(final FieldAbsoluteDate<T> a, final FieldAbsoluteDate<T> b) {
  469.         return (forward ^ (a.compareTo(b) > 0)) ? a : b;
  470.     }

  471.     /**
  472.      * Check the ordering of two times.
  473.      *
  474.      * @param t1 the first time.
  475.      * @param t2 the second time.
  476.      * @return true if {@code t2} is strictly after {@code t1} in the propagation
  477.      * direction.
  478.      */
  479.     private boolean strictlyAfter(final FieldAbsoluteDate<T> t1, final FieldAbsoluteDate<T> t2) {
  480.         if (t1 == null || t2 == null) {
  481.             return false;
  482.         } else {
  483.             return forward ? t1.compareTo(t2) < 0 : t2.compareTo(t1) < 0;
  484.         }
  485.     }

  486.     /**
  487.      * Same as keyword assert, but throw a {@link MathRuntimeException}.
  488.      *
  489.      * @param condition to check
  490.      * @throws MathRuntimeException if {@code condition} is false.
  491.      */
  492.     private void check(final boolean condition) throws MathRuntimeException {
  493.         if (!condition) {
  494.             throw new OrekitInternalError(null);
  495.         }
  496.     }

  497.     /**
  498.      * Class to hold the data related to an event occurrence that is needed to decide how
  499.      * to modify integration.
  500.      */
  501.     public static class EventOccurrence<T extends RealFieldElement<T>> {

  502.         /** User requested action. */
  503.         private final Action action;
  504.         /** New state for a reset action. */
  505.         private final FieldSpacecraftState<T> newState;
  506.         /** The time to stop propagation if the action is a stop event. */
  507.         private final FieldAbsoluteDate<T> stopDate;

  508.         /**
  509.          * Create a new occurrence of an event.
  510.          *
  511.          * @param action   the user requested action.
  512.          * @param newState for a reset event. Should be the current state unless the
  513.          *                 action is {@link Action#RESET_STATE}.
  514.          * @param stopDate to stop propagation if the action is {@link Action#STOP}. Used
  515.          *                 to move the stop time to just after the root.
  516.          */
  517.         EventOccurrence(final Action action,
  518.                         final FieldSpacecraftState<T> newState,
  519.                         final FieldAbsoluteDate<T> stopDate) {
  520.             this.action = action;
  521.             this.newState = newState;
  522.             this.stopDate = stopDate;
  523.         }

  524.         /**
  525.          * Get the user requested action.
  526.          *
  527.          * @return the action.
  528.          */
  529.         public Action getAction() {
  530.             return action;
  531.         }

  532.         /**
  533.          * Get the new state for a reset action.
  534.          *
  535.          * @return the new state.
  536.          */
  537.         public FieldSpacecraftState<T> getNewState() {
  538.             return newState;
  539.         }

  540.         /**
  541.          * Get the new time for a stop action.
  542.          *
  543.          * @return when to stop propagation.
  544.          */
  545.         public FieldAbsoluteDate<T> getStopDate() {
  546.             return stopDate;
  547.         }

  548.     }

  549.     /**Get PendingEvent.
  550.      * @return if there is a pending event or not
  551.      * */

  552.     public boolean getPendingEvent() {
  553.         return pendingEvent;
  554.     }

  555. }