fr.cnes.sirius.patrius.events
Class GenericCodingEventDetector

java.lang.Object
  extended by fr.cnes.sirius.patrius.events.GenericCodingEventDetector
All Implemented Interfaces:
CodingEventDetector, Serializable, EventDetector

public class GenericCodingEventDetector
extends Object
implements CodingEventDetector

This class represents an all-purpose implementation of the CodingEventDetector interface.
It works using the EventDetector provided in the constructor.

This detector is able to build a CodedEvent for a given date using the method buildCodedEvent.
You cannot set the CodedEvent comment through this implementation. Subclassing is permitted for the purpose of adding functionality.

It supports phenomena or not, depending on which constructor was used. When it does support phenomena, the user can know for a given input if the state is active using the method isStateActive.

Since:
1.1
Version:
$Id: GenericCodingEventDetector.java 14677 2015-11-25 14:52:39Z rodrigues $
Author:
Pierre Cardoso, Tiziana Sabatini
See Also:
CodingEventDetector, Serialized Form
Concurrency :
not thread-safe or thread-hostile
Concurrency comment :
As of now, existing Orekit EventDetector implementations are either not thread-safe or thread-hostile, so this class also is. But this class could probably become conditionally thread-safe; the main thread safety condition would then be that the included EventDetector should be thread-safe.

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
GenericCodingEventDetector(EventDetector eventDetectorIn, String increasingCodeIn, String decreasingCodeIn)
          Constructor for a GenericCodingEventDetector that does not support a Phenomenon.
GenericCodingEventDetector(EventDetector eventDetectorIn, String increasingCodeIn, String decreasingCodeIn, boolean increasingIsStartIn, String phenomenonCodeIn)
          Constructor for a GenericCodingEventDetector that supports a Phenomenon.
No delays and no occurrence numbers are associated to the events detected by this detector.
GenericCodingEventDetector(EventDetector eventDetectorIn, String increasingCodeIn, String decreasingCodeIn, boolean increasingIsStartIn, String phenomenonCodeIn, double delayIn, int occurrenceIn)
          Constructor for a GenericCodingEventDetector that supports a Phenomenon.
A delay and/or an occurrence number can be associated to the events detected by this detector.
When a delay is added to the detected events, two kinds of events will be coded:
- the original events, with their original codes;
- the delayed events, whose codes will be "DELAYED_" followed by the original code.
GenericCodingEventDetector(EventDetector eventDetectorIn, String increasingCodeIn, String decreasingCodeIn, double delayIn, int occurrenceIn)
          Constructor for a GenericCodingEventDetector that does not support a Phenomenon.
When a delay is added to the detected events, two kinds of events will be coded:
- the original events, with their original codes;
- the delayed events, whose codes will be "DELAYED_" followed by the original code.
 
Method Summary
 CodedEvent buildCodedEvent(SpacecraftState s, boolean increasing)
          Build a CodedEvent instance appropriate for the provided SpacecraftState.
 CodedEvent buildDelayedCodedEvent(SpacecraftState s, boolean increasing)
          Build a delayed CodedEvent instance appropriate for the provided SpacecraftState.
 CodedEvent buildOccurrenceCodedEvent(SpacecraftState s, boolean increasing)
          Build a CodedEvent instance appropriate for the provided SpacecraftState.
 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.
 String getEventType()
          Gets a code indicating the type of event we want to log: DELAY when a delay is associated to the logged events with respect to the detected events, N_OCCURRENCE when we want to log the nth occurrence of the detected events, STANDARD when no delays and no occurrence numbers are taken into consideration.
 double getMaxCheckInterval()
          Get maximal time interval between switching function checks.
 int getMaxIterationCount()
          Get maximal number of iterations in the event time search.
 String getPhenomenonCode()
          If the implementation supports a Phenomenon, provides a code for the phenomenon associated to the event.
 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.
 boolean isStateActive(SpacecraftState state)
          Tells if the event state is "active" for the given input.
 boolean positiveSignMeansActive()
          Get the sign of the g method that means "the phenomenon associated to the event is active".
This method has been implemented because of the inconsistency of the sign of the g functions in the EventDetector classes in Orekit: for some events, g is positive when its associated phenomenon is active, and for others, g is positive when its phenomenon is not active.
WARNING : If Phenomena are not supported, the behavior of this method is undefined.
 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

GenericCodingEventDetector

public GenericCodingEventDetector(EventDetector eventDetectorIn,
                                  String increasingCodeIn,
                                  String decreasingCodeIn,
                                  boolean increasingIsStartIn,
                                  String phenomenonCodeIn)
Constructor for a GenericCodingEventDetector that supports a Phenomenon.
No delays and no occurrence numbers are associated to the events detected by this detector.

Parameters:
eventDetectorIn - the EventDetector of the current event
increasingCodeIn - code identifying the "increasing" event
decreasingCodeIn - code identifying the "decreasing" event
increasingIsStartIn - true if increasing of the g function represents the "beginning" of the associated phenomenon
phenomenonCodeIn - code identifying the phenomenon associated to the event
See Also:
CodingEventDetector, EventDetector, Phenomenon

GenericCodingEventDetector

public GenericCodingEventDetector(EventDetector eventDetectorIn,
                                  String increasingCodeIn,
                                  String decreasingCodeIn,
                                  boolean increasingIsStartIn,
                                  String phenomenonCodeIn,
                                  double delayIn,
                                  int occurrenceIn)
Constructor for a GenericCodingEventDetector that supports a Phenomenon.
A delay and/or an occurrence number can be associated to the events detected by this detector.
When a delay is added to the detected events, two kinds of events will be coded:
- the original events, with their original codes;
- the delayed events, whose codes will be "DELAYED_" followed by the original code.

Parameters:
eventDetectorIn - the EventDetector of the current event
increasingCodeIn - code identifying the "increasing" event
decreasingCodeIn - code identifying the "decreasing" event
increasingIsStartIn - true if increasing of the g function represents the "beginning" of the associated phenomenon
phenomenonCodeIn - code identifying the phenomenon associated to the event
delayIn - the delay of the output events with respect to the events detected during propagation; if it is set to zero, no delay will be added to the events
occurrenceIn - the occurrence number of the output event (only the nth event will be detected); if it is set to zero, all events will be detected
See Also:
CodingEventDetector, EventDetector, Phenomenon

GenericCodingEventDetector

public GenericCodingEventDetector(EventDetector eventDetectorIn,
                                  String increasingCodeIn,
                                  String decreasingCodeIn)
Constructor for a GenericCodingEventDetector that does not support a Phenomenon. No delays and no occurrence numbers are associated to the events detected by this detector.

Parameters:
eventDetectorIn - the EventDetector of the current event
increasingCodeIn - code identifying the "increasing" event
decreasingCodeIn - code identifying the "decreasing" event
See Also:
CodingEventDetector, EventDetector

GenericCodingEventDetector

public GenericCodingEventDetector(EventDetector eventDetectorIn,
                                  String increasingCodeIn,
                                  String decreasingCodeIn,
                                  double delayIn,
                                  int occurrenceIn)
Constructor for a GenericCodingEventDetector that does not support a Phenomenon.
When a delay is added to the detected events, two kinds of events will be coded:
- the original events, with their original codes;
- the delayed events, whose codes will be "DELAYED_" followed by the original code.

Parameters:
eventDetectorIn - the EventDetector of the current event
increasingCodeIn - code identifying the "increasing" event
decreasingCodeIn - code identifying the "decreasing" event
delayIn - the delay of the output events with respect to the events detected during propagation; if it is set to zero, no delay will be added to the events
occurrenceIn - the occurrence number of the output event (only the nth event will be detected); if it is set to zero, all events will be detected
See Also:
CodingEventDetector, EventDetector
Method Detail

g

public final double g(SpacecraftState s)
               throws OrekitException
Description copied from interface: EventDetector
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

eventOccurred

public final EventDetector.Action eventOccurred(SpacecraftState s,
                                                boolean increasing,
                                                boolean forward)
                                         throws OrekitException
Description copied from interface: EventDetector
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

shouldBeRemoved

public boolean shouldBeRemoved()
Description copied from interface: EventDetector
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

resetState

public final SpacecraftState resetState(SpacecraftState oldState)
                                 throws OrekitException
Description copied from interface: EventDetector
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 final double getThreshold()
Description copied from interface: EventDetector
Get the convergence threshold in the event time search.

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

getMaxCheckInterval

public final double getMaxCheckInterval()
Description copied from interface: EventDetector
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 final int getMaxIterationCount()
Description copied from interface: EventDetector
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

buildCodedEvent

public final CodedEvent buildCodedEvent(SpacecraftState s,
                                        boolean increasing)
Description copied from interface: CodingEventDetector
Build a CodedEvent instance appropriate for the provided SpacecraftState.

Specified by:
buildCodedEvent in interface CodingEventDetector
Parameters:
s - the current state information : date, kinematics, attitude
increasing - if true, g function increases around event date.
Returns:
the CodedEvent

buildDelayedCodedEvent

public final CodedEvent buildDelayedCodedEvent(SpacecraftState s,
                                               boolean increasing)
Description copied from interface: CodingEventDetector
Build a delayed CodedEvent instance appropriate for the provided SpacecraftState. This instance will have a delay with respect to the associated detected event.

Specified by:
buildDelayedCodedEvent in interface CodingEventDetector
Parameters:
s - the current state information : date, kinematics, attitude
increasing - if true, g function increases around event date.
Returns:
the CodedEvent

buildOccurrenceCodedEvent

public final CodedEvent buildOccurrenceCodedEvent(SpacecraftState s,
                                                  boolean increasing)
Description copied from interface: CodingEventDetector
Build a CodedEvent instance appropriate for the provided SpacecraftState. This method will return an instance only if it is be the nth occurrence of the corresponding event, otherwise it will return null. A delay can be applied to the event.

Specified by:
buildOccurrenceCodedEvent in interface CodingEventDetector
Parameters:
s - the current state information : date, kinematics, attitude
increasing - if true, g function increases around event date.
Returns:
the CodedEvent

positiveSignMeansActive

public final boolean positiveSignMeansActive()
Description copied from interface: CodingEventDetector
Get the sign of the g method that means "the phenomenon associated to the event is active".
This method has been implemented because of the inconsistency of the sign of the g functions in the EventDetector classes in Orekit: for some events, g is positive when its associated phenomenon is active, and for others, g is positive when its phenomenon is not active.
WARNING : If Phenomena are not supported, the behavior of this method is undefined.

Specified by:
positiveSignMeansActive in interface CodingEventDetector
Returns:
true for positive, false for negative.

getPhenomenonCode

public final String getPhenomenonCode()
Description copied from interface: CodingEventDetector
If the implementation supports a Phenomenon, provides a code for the phenomenon associated to the event. If not, returns null.

Specified by:
getPhenomenonCode in interface CodingEventDetector
Returns:
either a code, or null if Phenomena are not supported.

isStateActive

public final boolean isStateActive(SpacecraftState state)
                            throws OrekitException
Tells if the event state is "active" for the given input. If phenomena are unsupported by this instance, it will always return false.

Parameters:
state - the input SpacecraftState
Returns:
true if the state is "active" according to the convention chosen in the constructor.
Throws:
OrekitException - from the wrapped event detector.

getEventType

public final String getEventType()
Description copied from interface: CodingEventDetector
Gets a code indicating the type of event we want to log: DELAY when a delay is associated to the logged events with respect to the detected events, N_OCCURRENCE when we want to log the nth occurrence of the detected events, STANDARD when no delays and no occurrence numbers are taken into consideration.

Specified by:
getEventType in interface CodingEventDetector
Returns:
the type of event to log

init

public void init(SpacecraftState s0,
                 AbsoluteDate t)
Description copied from interface: EventDetector
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

getSlopeSelection

public int getSlopeSelection()
Description copied from interface: EventDetector
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.


Copyright © 2016 CNES. All Rights Reserved.