fr.cnes.sirius.patrius.events.multi
Class MultiGenericCodingEventDetector

java.lang.Object
  extended by fr.cnes.sirius.patrius.events.multi.MultiGenericCodingEventDetector
All Implemented Interfaces:
MultiCodingEventDetector, MultiEventDetector

public class MultiGenericCodingEventDetector
extends Object
implements MultiCodingEventDetector

This class is copied from GenericCodingEventDetector and adapted to multi propagation.

This class represents an all-purpose implementation of the MultiCodingEventDetector interface.
It works using the MultiEventDetector 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:
3.0
Version:
$Id: MultiGenericCodingEventDetector.java 17586 2017-05-10 13:29:16Z bignon $
Author:
maggioranic
See Also:
MultiCodingEventDetector
Concurrency :
not thread-safe or thread-hostile
Concurrency comment :
As of now, existing MultiEventDetector 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 MultiEventDetector should be thread-safe.

Field Summary
 
Fields inherited from interface org.orekit.propagation.events.multi.MultiEventDetector
DECREASING, INCREASING, INCREASING_DECREASING
 
Constructor Summary
MultiGenericCodingEventDetector(MultiEventDetector multiEventDetectorIn, String increasingCodeIn, String decreasingCodeIn)
          Constructor for a MultiGenericCodingEventDetector that does not support a Phenomenon.
MultiGenericCodingEventDetector(MultiEventDetector multiEventDetectorIn, String increasingCodeIn, String decreasingCodeIn, boolean increasingIsStartIn, String phenomenonCodeIn)
          Constructor for a MultiGenericCodingEventDetector that supports a Phenomenon.
No delays and no occurrence numbers are associated to the events detected by this detector.
MultiGenericCodingEventDetector(MultiEventDetector multiEventDetectorIn, String increasingCodeIn, String decreasingCodeIn, boolean increasingIsStartIn, String phenomenonCodeIn, double delayIn, int occurrenceIn)
          Constructor for a MultiGenericCodingEventDetector 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.
MultiGenericCodingEventDetector(MultiEventDetector multiEventDetectorIn, String increasingCodeIn, String decreasingCodeIn, double delayIn, int occurrenceIn)
          Constructor for a MultiGenericCodingEventDetector 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(Map<String,SpacecraftState> states, boolean increasing)
          Build a CodedEvent instance appropriate for the provided map of SpacecraftState.
 CodedEvent buildDelayedCodedEvent(Map<String,SpacecraftState> states, boolean increasing)
          Build a delayed CodedEvent instance appropriate for the provided map of SpacecraftState.
 CodedEvent buildOccurrenceCodedEvent(Map<String,SpacecraftState> states, boolean increasing)
          Build a CodedEvent instance appropriate for the provided map of SpacecraftState.
 EventDetector.Action eventOccurred(Map<String,SpacecraftState> s, boolean increasing, boolean forward)
          Handle an event and choose what to do next.
 double g(Map<String,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(Map<String,SpacecraftState> s0, AbsoluteDate t)
          Initialize event handler at the start of a propagation.
 boolean isStateActive(Map<String,SpacecraftState> states)
          Tells if the multi 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 MultiEventDetector classes in Patrius: 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.
 Map<String,SpacecraftState> resetStates(Map<String,SpacecraftState> oldStates)
          Reset the states (including additional states) prior to continue propagation.
 boolean shouldBeRemoved()
          This method is called after the step handler has returned and before the next step is started, but only when MultiEventDetector.eventOccurred(java.util.Map, boolean, boolean) has been called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiGenericCodingEventDetector

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

Parameters:
multiEventDetectorIn - the MultiEventDetector 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:
MultiCodingEventDetector, MultiEventDetector, Phenomenon

MultiGenericCodingEventDetector

public MultiGenericCodingEventDetector(MultiEventDetector multiEventDetectorIn,
                                       String increasingCodeIn,
                                       String decreasingCodeIn,
                                       boolean increasingIsStartIn,
                                       String phenomenonCodeIn,
                                       double delayIn,
                                       int occurrenceIn)
Constructor for a MultiGenericCodingEventDetector 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:
multiEventDetectorIn - the MultiEventDetector 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:
MultiCodingEventDetector, MultiEventDetector, Phenomenon

MultiGenericCodingEventDetector

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

Parameters:
multiEventDetectorIn - the MultiEventDetector of the current event
increasingCodeIn - code identifying the "increasing" event
decreasingCodeIn - code identifying the "decreasing" event
See Also:
MultiCodingEventDetector, MultiEventDetector

MultiGenericCodingEventDetector

public MultiGenericCodingEventDetector(MultiEventDetector multiEventDetectorIn,
                                       String increasingCodeIn,
                                       String decreasingCodeIn,
                                       double delayIn,
                                       int occurrenceIn)
Constructor for a MultiGenericCodingEventDetector 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:
multiEventDetectorIn - the MultiEventDetector 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:
MultiCodingEventDetector, MultiEventDetector
Method Detail

init

public void init(Map<String,SpacecraftState> s0,
                 AbsoluteDate t)
Description copied from interface: MultiEventDetector
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 MultiEventDetector
Parameters:
s0 - map of initial states
t - target time for the integration

g

public double g(Map<String,SpacecraftState> s)
         throws OrekitException
Description copied from interface: MultiEventDetector
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 MultiEventDetector
Parameters:
s - the current states information: date, kinematics, attitudes for forces and events computation, and additional states for each states
Returns:
value of the switching function
Throws:
OrekitException - if some specific error occurs

eventOccurred

public EventDetector.Action eventOccurred(Map<String,SpacecraftState> s,
                                          boolean increasing,
                                          boolean forward)
                                   throws OrekitException
Description copied from interface: MultiEventDetector
Handle an event and choose what to do next.

The scheduling between this method and the MultiOrekitStepHandler method handleStep 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 MultiOrekitStepNormalizer 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 MultiEventDetector interface and the MultiOrekitFixedStepHandler 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 MultiOrekitStepHandler and to the size of the fixed step for MultiOrekitFixedStepHandler.

Specified by:
eventOccurred in interface MultiEventDetector
Parameters:
s - the current states information: date, kinematics, attitude for forces and events computation, and additional states for each 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: MultiEventDetector

This method is called after the step handler has returned and before the next step is started, but only when MultiEventDetector.eventOccurred(java.util.Map, boolean, boolean) has been called.

Specified by:
shouldBeRemoved in interface MultiEventDetector
Returns:
true if the current detector should be removed

resetStates

public Map<String,SpacecraftState> resetStates(Map<String,SpacecraftState> oldStates)
                                        throws OrekitException
Description copied from interface: MultiEventDetector
Reset the states (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 MultiEventDetector.eventOccurred(java.util.Map, 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 MultiEventDetector.eventOccurred(java.util.Map, 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:
resetStates in interface MultiEventDetector
Parameters:
oldStates - old states
Returns:
new states
Throws:
OrekitException - if the states cannot be reseted

getThreshold

public double getThreshold()
Description copied from interface: MultiEventDetector
Get the convergence threshold in the event time search.

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

getMaxCheckInterval

public double getMaxCheckInterval()
Description copied from interface: MultiEventDetector
Get maximal time interval between switching function checks.

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

getMaxIterationCount

public int getMaxIterationCount()
Description copied from interface: MultiEventDetector
Get maximal number of iterations in the event time search.

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

getSlopeSelection

public int getSlopeSelection()
Description copied from interface: MultiEventDetector
Get the parameter in charge of the selection of detected events by the slope of the g-function.

Specified by:
getSlopeSelection in interface MultiEventDetector
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.

buildCodedEvent

public CodedEvent buildCodedEvent(Map<String,SpacecraftState> states,
                                  boolean increasing)
Description copied from interface: MultiCodingEventDetector
Build a CodedEvent instance appropriate for the provided map of SpacecraftState.

Specified by:
buildCodedEvent in interface MultiCodingEventDetector
Parameters:
states - the current states information
increasing - if true, g function increases around event date.
Returns:
the CodedEvent

buildDelayedCodedEvent

public CodedEvent buildDelayedCodedEvent(Map<String,SpacecraftState> states,
                                         boolean increasing)
Description copied from interface: MultiCodingEventDetector
Build a delayed CodedEvent instance appropriate for the provided map of SpacecraftState. This instance will have a delay with respect to the associated detected event.

Specified by:
buildDelayedCodedEvent in interface MultiCodingEventDetector
Parameters:
states - the current states information
increasing - if true, g function increases around event date.
Returns:
the CodedEvent

buildOccurrenceCodedEvent

public CodedEvent buildOccurrenceCodedEvent(Map<String,SpacecraftState> states,
                                            boolean increasing)
Description copied from interface: MultiCodingEventDetector
Build a CodedEvent instance appropriate for the provided map of 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 MultiCodingEventDetector
Parameters:
states - the current states information
increasing - if true, g function increases around event date.
Returns:
the CodedEvent

positiveSignMeansActive

public boolean positiveSignMeansActive()
Description copied from interface: MultiCodingEventDetector
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 MultiEventDetector classes in Patrius: 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 MultiCodingEventDetector
Returns:
true for positive, false for negative.

getPhenomenonCode

public String getPhenomenonCode()
Description copied from interface: MultiCodingEventDetector
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 MultiCodingEventDetector
Returns:
either a code, or null if Phenomena are not supported.

isStateActive

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

Parameters:
states - the input map of 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 String getEventType()
Description copied from interface: MultiCodingEventDetector
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 MultiCodingEventDetector
Returns:
the type of event to log


Copyright © 2017 CNES. All Rights Reserved.