org.orekit.propagation.events
Class NthOccurrenceDetector

java.lang.Object
  extended by org.orekit.propagation.events.NthOccurrenceDetector
All Implemented Interfaces:
Serializable, EventDetector

public class NthOccurrenceDetector
extends Object
implements EventDetector

This event detector detects the nth occurrence of an underlying event detector.

However the eventOccurred(SpacecraftState, boolean, boolean) method is triggered at every event of the underlying detector. As a result, the behaviour of this detector is the following:

Warning: the eventOccurred(SpacecraftState, boolean, boolean) method is triggered at every occurrence of the underlying detector, not only at nth occurrence. Hence, overloading this detector should be performed carefully: in the overloaded eventOccurred() method, the check getCurrentOccurrence() == getOccurence() should be performed first to ensure we are at nth occurrence before calling super.eventOccurred().

Since:
1.3
Version:
$Id: NthOccurrenceDetector.java 17582 2017-05-10 12:58:16Z bignon $
Author:
Rami Houdroge
See Also:
Serialized Form
Concurrency :
not thread-safe
Concurrency comment :
use of internal mutable attributes

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.orekit.propagation.events.EventDetector
EventDetector.Action
 
Field Summary
 
Fields inherited from interface org.orekit.propagation.events.EventDetector
DECREASING, INCREASING, INCREASING_DECREASING
 
Constructor Summary
NthOccurrenceDetector(EventDetector eventToDetect, int occurrence, EventDetector.Action actionAtOccurrence)
          Constructor.
NthOccurrenceDetector(EventDetector eventToDetect, int occurrence, EventDetector.Action actionAtOccurrence, boolean remove)
          Constructor.
 
Method Summary
 EventDetector.Action eventOccurred(SpacecraftState s, boolean increasing, boolean forward)
          Handle an event and choose what to do next.
 double g(SpacecraftState s)
          Compute the value of the switching function.
 int getCurrentOccurrence()
          Get the current occurrence (during propagation).
 EventDetector getEvent()
          Get event to detect.
 double getMaxCheckInterval()
          Get maximal time interval between switching function checks.
 int getMaxIterationCount()
          Get maximal number of iterations in the event time search.
 int getOccurence()
          Get the occurrence to detect.
 int getSlopeSelection()
          Get the parameter in charge of the selection of detected events by the slope of the g-function.
 double getThreshold()
          Get the convergence threshold in the event time search.
 void init(SpacecraftState s0, AbsoluteDate t)
          Initialize event handler at the start of a propagation.
 SpacecraftState resetState(SpacecraftState oldState)
          Reset the state (including additional states) prior to continue propagation.
 boolean shouldBeRemoved()
          This method is called after EventDetector.eventOccurred(org.orekit.propagation.SpacecraftState, boolean, boolean) has been triggered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NthOccurrenceDetector

public NthOccurrenceDetector(EventDetector eventToDetect,
                             int occurrence,
                             EventDetector.Action actionAtOccurrence)
Constructor.

Parameters:
eventToDetect - event to detect
occurrence - occurrence of the event to detect
actionAtOccurrence - action at event nth occurrence

NthOccurrenceDetector

public NthOccurrenceDetector(EventDetector eventToDetect,
                             int occurrence,
                             EventDetector.Action actionAtOccurrence,
                             boolean remove)
Constructor.

Parameters:
eventToDetect - event to detect
occurrence - occurrence of the event to detect
actionAtOccurrence - action at event nth occurrence
remove - true if detector should be removed after detection of nth occurrence
Method Detail

init

public void init(SpacecraftState s0,
                 AbsoluteDate t)
Initialize event handler at the start of a propagation.

This method is called once at the start of the propagation. It may be used by the event handler to initialize some internal data if needed.

Specified by:
init in interface EventDetector
Parameters:
s0 - initial state
t - target time for the integration

g

public double g(SpacecraftState s)
         throws OrekitException
Compute the value of the switching function. This function must be continuous (at least in its roots neighborhood), as the integrator will need to find its roots to locate the events.

Specified by:
g in interface EventDetector
Parameters:
s - the current state information: date, kinematics, attitude for forces and events computation, mass provider, and additional states
Returns:
value of the switching function
Throws:
OrekitException - if some specific error occurs

shouldBeRemoved

public boolean shouldBeRemoved()
This method is called after EventDetector.eventOccurred(org.orekit.propagation.SpacecraftState, boolean, boolean) has been triggered. It returns true if the current detector should be removed after first event detection. WARNING: this method can be called only once a event has been triggered. Before, the value is not available.

Specified by:
shouldBeRemoved in interface EventDetector
Returns:
true if the current detector should be removed after first event detection

eventOccurred

public EventDetector.Action eventOccurred(SpacecraftState s,
                                          boolean increasing,
                                          boolean forward)
                                   throws OrekitException
Handle an event and choose what to do next.

The scheduling between this method and the OrekitStepHandler method handleStep(interpolator, isLast) is to call this method first and handleStep afterwards. This scheduling allows the propagator to pass true as the isLast parameter to the step handler to make it aware the step will be the last one if this method returns EventDetector.Action.STOP. As the interpolator may be used to navigate back throughout the last step (as OrekitStepNormalizer does for example), user code called by this method and user code called by step handlers may experience apparently out of order values of the independent time variable. As an example, if the same user object implements both this EventDetector interface and the OrekitFixedStepHandler interface, a forward integration may call its eventOccurred method with a state at 2000-01-01T00:00:10 first and call its handleStep method with a state at 2000-01-01T00:00:09 afterwards. Such out of order calls are limited to the size of the integration step for variable step handlers and to the size of the fixed step for fixed step handlers.

Specified by:
eventOccurred in interface EventDetector
Parameters:
s - the current state information: date, kinematics, attitude for forces and events computation, mass provider, and additional states
increasing - if true, the value of the switching function increases when times increases around event (note that increase is measured with respect to physical time, not with respect to propagation which may go backward in time)
forward - if true, the integration variable (time) increases during integration.
Returns:
one of EventDetector.Action.STOP, EventDetector.Action.RESET_STATE, EventDetector.Action.RESET_DERIVATIVES, EventDetector.Action.CONTINUE
Throws:
OrekitException - if some specific error occurs

resetState

public SpacecraftState resetState(SpacecraftState oldState)
                           throws OrekitException
Reset the state (including additional states) prior to continue propagation.

This method is called after the step handler has returned and before the next step is started, but only when EventDetector.eventOccurred(org.orekit.propagation.SpacecraftState, boolean, boolean) has itself returned the EventDetector.Action.RESET_STATE indicator. It allows the user to reset the state for the next step, without perturbing the step handler of the finishing step. If the EventDetector.eventOccurred(org.orekit.propagation.SpacecraftState, boolean, boolean) never returns the EventDetector.Action.RESET_STATE indicator, this function will never be called, and it is safe to simply return null.

Specified by:
resetState in interface EventDetector
Parameters:
oldState - old state
Returns:
new state
Throws:
OrekitException - if the state cannot be reseted

getThreshold

public double getThreshold()
Get the convergence threshold in the event time search.

Specified by:
getThreshold in interface EventDetector
Returns:
convergence threshold (s)

getMaxCheckInterval

public double getMaxCheckInterval()
Get maximal time interval between switching function checks.

Specified by:
getMaxCheckInterval in interface EventDetector
Returns:
maximal time interval (s) between switching function checks

getMaxIterationCount

public int getMaxIterationCount()
Get maximal number of iterations in the event time search.

Specified by:
getMaxIterationCount in interface EventDetector
Returns:
maximal number of iterations in the event time search

getSlopeSelection

public int getSlopeSelection()
Get the parameter in charge of the selection of detected events by the slope of the g-function.

Specified by:
getSlopeSelection in interface EventDetector
Returns:
EventDetector.INCREASING (0): events related to the increasing g-function;
EventDetector.DECREASING (1): events related to the decreasing g-function;
EventDetector.INCREASING_DECREASING (2): events related to both increasing and decreasing g-function.

getEvent

public EventDetector getEvent()
Get event to detect.

Returns:
event to detect.

getOccurence

public int getOccurence()
Get the occurrence to detect.

Returns:
occurrence to detect

getCurrentOccurrence

public int getCurrentOccurrence()
Get the current occurrence (during propagation).

Returns:
current occurrence


Copyright © 2017 CNES. All Rights Reserved.