EventUsingEventDetector

De Patrius
Version datée du 13 février 2018 à 12:16 par Admin (discussion | contributions) (Page créée avec « <syntaxhighlight lang="java"> public class EventUsingEventDetector implements EventDetector { private static final long serialVersionUID = 1L; private final Absol... »)
(diff) ← Version précédente | Version actuelle (diff) | Version suivante → (diff)
Aller à la navigation Aller à la recherche
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;
    }
    
    /**
     * @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());
        
    }

}