EventUsingEventDetector 4.1

De Wiki
Aller à : navigation, rechercher
public class EventUsingEventDetector implements EventDetector {
 
    private static final long serialVersionUID = 1L;
    private final AbsoluteDate date;
 
    /**
     * Constructor
     * @param date absolute date when event will occured.
     */
    public EventUsingEventDetector( final AbsoluteDate date ) {
        this.date = date;
    }
 
    public Action eventOccurred(SpacecraftState s, boolean increasing,
            boolean forward) throws PatriusException {
        return EventDetector.Action.STOP;
    }
 
    public double g(SpacecraftState s) throws PatriusException {
        return s.getDate().durationFrom(date);
    }
 
    public double getMaxCheckInterval() {
        return AbstractDetector.DEFAULT_MAXCHECK;
    }
 
    public int getMaxIterationCount() {
        return 20;
    }
 
    public int getSlopeSelection() {
        // TODO Auto-generated method stub
        return AbstractDetector.INCREASING_DECREASING;
    }
 
    public double getThreshold() {
        return AbstractDetector.DEFAULT_THRESHOLD;
    }
 
    public void init(SpacecraftState s0, AbsoluteDate t) {
        // Nothing specific to do ...
    }
 
    public SpacecraftState resetState(SpacecraftState oldState)
            throws PatriusException {
        return oldState;
    }
 
    public boolean shouldBeRemoved() {
        return false;
    }
 
    @Override
    public EventDetector copy() {
        final AbsoluteDate newDate = new AbsoluteDate(date, 0.);
        return new EventUsingEventDetector(newDate);
    }
 
    /**
     * @param args
     * @throws OrekitException 
     */
    public static void main(String[] args) throws PatriusException {
 
        // Patrius Dataset initialization (needed for example to get the UTC time)
        PatriusDataset.addResourcesFromPatriusDataset() ;
 
        // Recovery of the UTC time scale using a "factory" (not to duplicate such unique object)
        final TimeScale TUC = TimeScalesFactory.getUTC();
 
        // Date of the orbit (given in UTC time scale)
        final AbsoluteDate date = new AbsoluteDate("2010-01-01T12:00:00.000", TUC);
 
        EventUsingEventDetector event = new EventUsingEventDetector(date);
 
        System.out.println("Max check interval of the event: " + event.getMaxCheckInterval() + " s");
        System.out.println("Threshold of the event: " + event.getThreshold() + " s");
        System.out.println("Remove the event after occuring: " + event.shouldBeRemoved());
 
    }
 
}