ManeuverTriggers.java

  1. /* Copyright 2002-2022 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.orekit.forces.maneuvers.trigger;

  18. import java.util.Collections;
  19. import java.util.List;
  20. import java.util.stream.Stream;

  21. import org.hipparchus.CalculusFieldElement;
  22. import org.hipparchus.Field;
  23. import org.orekit.propagation.FieldSpacecraftState;
  24. import org.orekit.propagation.SpacecraftState;
  25. import org.orekit.propagation.events.EventDetector;
  26. import org.orekit.propagation.events.FieldEventDetector;
  27. import org.orekit.time.AbsoluteDate;
  28. import org.orekit.time.FieldAbsoluteDate;
  29. import org.orekit.utils.ParameterDriver;

  30. /** Generic interface for the maneuver triggers used in a {@link org.orekit.forces.maneuvers.Maneuver}.
  31.  * @author Maxime Journot
  32.  * @since 10.2
  33.  */
  34. public interface ManeuverTriggers {

  35.     /** Initialization method called at propagation start.
  36.      * <p>
  37.      * The default implementation does nothing.
  38.      * </p>
  39.      * @param initialState initial spacecraft state (at the start of propagation).
  40.      * @param target date of propagation. Not equal to {@code initialState.getDate()}.
  41.      */
  42.     default void init(SpacecraftState initialState, AbsoluteDate target) {
  43.         // nothing by default
  44.     }

  45.     /** Initialization method called at propagation start.
  46.      * <p>
  47.      * The default implementation does nothing.
  48.      * </p>
  49.      * @param initialState initial spacecraft state (at the start of propagation).
  50.      * @param target date of propagation. Not equal to {@code initialState.getDate()}.
  51.      * @param <T> type of the elements
  52.      * @since 11.1
  53.      */
  54.     default <T extends CalculusFieldElement<T>> void init(FieldSpacecraftState<T> initialState, FieldAbsoluteDate<T> target) {
  55.         init(initialState.toSpacecraftState(), target.toAbsoluteDate());
  56.     }

  57.     /** Get the event detectors associated with the triggers.
  58.      * @return the event detectors
  59.      */
  60.     Stream<EventDetector> getEventsDetectors();

  61.     /** Get the event detectors associated with the triggers.
  62.      * @param field field to which the state belongs
  63.      * @param <T> type of the field elements
  64.      * @return the event detectors
  65.      */
  66.     <T extends CalculusFieldElement<T>> Stream<FieldEventDetector<T>> getFieldEventsDetectors(Field<T> field);

  67.     /** Find out if the maneuver is firing or not.
  68.      * @param date current date
  69.      * @param parameters maneuver triggers parameters
  70.      * @return true if the maneuver is firing, false otherwise
  71.      */
  72.     boolean isFiring(AbsoluteDate date, double[] parameters);

  73.     /** Find out if the maneuver is firing or not.
  74.      * @param date current date
  75.      * @param parameters maneuver triggers parameters
  76.      * @param <T> type of the field elements
  77.      * @return true if the maneuver is firing, false otherwise
  78.      */
  79.     <T extends CalculusFieldElement<T>> boolean isFiring(FieldAbsoluteDate<T> date, T[] parameters);

  80.     /** Get the maneuver triggers parameter drivers.
  81.      * @return maneuver triggers parameter drivers
  82.      */
  83.     default List<ParameterDriver> getParametersDrivers() {
  84.         return Collections.emptyList();
  85.     }

  86.     /** Get the maneuver name.
  87.      * @return the maneuver name
  88.      */
  89.     default String getName() {
  90.         return "";
  91.     }
  92. }