ContinuousScheduler.java

  1. /* Copyright 2002-2020 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.estimation.measurements.generation;

  18. import java.util.List;
  19. import java.util.SortedSet;
  20. import java.util.TreeSet;

  21. import org.orekit.estimation.measurements.ObservedMeasurement;
  22. import org.orekit.propagation.SpacecraftState;
  23. import org.orekit.propagation.sampling.OrekitStepInterpolator;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.time.DatesSelector;


  26. /** {@link Scheduler} generating measurements sequences continuously.
  27.  * <p>
  28.  * Continuous schedulers continuously generate measurements following a repetitive pattern.
  29.  * The repetitive pattern can be either a continuous stream of measurements separated by
  30.  * a constant step (for example one measurement every 60s), or several sequences of measurements
  31.  * at high rate up to a maximum number, with a rest period between sequences (for example
  32.  * sequences of up to 256 measurements every 100ms with 300s between each sequence).
  33.  * </p>
  34.  * @param <T> the type of the measurement
  35.  * @author Luc Maisonobe
  36.  * @since 9.3
  37.  */
  38. public class ContinuousScheduler<T extends ObservedMeasurement<T>> extends AbstractScheduler<T> {

  39.     /** Simple constructor.
  40.      * <p>
  41.      * BEWARE! Dates selectors often store internally the last selected dates, so they are not
  42.      * reusable across several {@link EventBasedScheduler instances}. A separate selector
  43.      * should be used for each scheduler.
  44.      * </p>
  45.      * @param builder builder for individual measurements
  46.      * @param selector selector for dates (beware that selectors are generally not
  47.      * reusable across several {@link EventBasedScheduler instances}, each selector should
  48.      * be dedicated to one scheduler
  49.      */
  50.     public ContinuousScheduler(final MeasurementBuilder<T> builder, final DatesSelector selector) {
  51.         super(builder, selector);
  52.     }

  53.     /** {@inheritDoc} */
  54.     @Override
  55.     public SortedSet<T> generate(final List<OrekitStepInterpolator> interpolators) {

  56.         // select dates in the current step, using arbitrarily interpolator 0
  57.         // as all interpolators cover the same range
  58.         final List<AbsoluteDate> dates = getSelector().selectDates(interpolators.get(0).getPreviousState().getDate(),
  59.                                                                    interpolators.get(0).getCurrentState().getDate());

  60.         // generate measurements when feasible
  61.         final SortedSet<T> measurements = new TreeSet<>();
  62.         for (final AbsoluteDate date : dates) {

  63.             // interpolate states at measurement date
  64.             final SpacecraftState[] states = new SpacecraftState[interpolators.size()];
  65.             for (int i = 0; i < states.length; ++i) {
  66.                 states[i] = interpolators.get(i).getInterpolatedState(date);
  67.             }

  68.             // generate measurement
  69.             measurements.add(getBuilder().build(states));

  70.         }

  71.         return measurements;

  72.     }

  73. }