WriterBuilder.java

  1. /* Copyright 2002-2021 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.files.ccsds.ndm;

  18. import org.orekit.annotation.DefaultDataContext;
  19. import org.orekit.data.DataContext;
  20. import org.orekit.files.ccsds.ndm.adm.aem.AemWriter;
  21. import org.orekit.files.ccsds.ndm.adm.apm.ApmWriter;
  22. import org.orekit.files.ccsds.ndm.odm.ocm.OcmWriter;
  23. import org.orekit.files.ccsds.ndm.odm.oem.OemWriter;
  24. import org.orekit.files.ccsds.ndm.odm.omm.OmmWriter;
  25. import org.orekit.files.ccsds.ndm.odm.opm.OpmWriter;
  26. import org.orekit.files.ccsds.ndm.tdm.IdentityConverter;
  27. import org.orekit.files.ccsds.ndm.tdm.RangeUnits;
  28. import org.orekit.files.ccsds.ndm.tdm.RangeUnitsConverter;
  29. import org.orekit.files.ccsds.ndm.tdm.TdmWriter;
  30. import org.orekit.time.AbsoluteDate;
  31. import org.orekit.utils.IERSConventions;

  32. /** Builder for all {@link NdmConstituent CCSDS Message} files writers.
  33.  * <p>
  34.  * This builder can be used for building all CCSDS Messages writers types.
  35.  * It is particularly useful in multi-threaded context as writers cannot
  36.  * be shared between threads and thus several independent writers must be
  37.  * built in this case.
  38.  * </p>
  39.  * @author Luc Maisonobe
  40.  * @since 11.0
  41.  */
  42. public class WriterBuilder extends AbstractBuilder<WriterBuilder> {

  43.     /**
  44.      * Simple constructor.
  45.      * <p>
  46.      * This constructor creates a builder with
  47.      * <ul>
  48.      *   <li>{@link #getConventions() IERS conventions} set to {@link IERSConventions#IERS_2010}</li>
  49.      *   <li>{@link #getDataContext() data context} set to {@link DataContext#getDefault() default context}</li>
  50.      *   <li>{@link #getMissionReferenceDate() mission reference date} set to {@code null}</li>
  51.      *   <li>{@link #getRangeUnitsConverter() converter for range units} set to {@link IdentityConverter}</li>
  52.      * </ul>
  53.      */
  54.     @DefaultDataContext
  55.     public WriterBuilder() {
  56.         this(DataContext.getDefault());
  57.     }

  58.     /**
  59.      * Simple constructor.
  60.      * <p>
  61.      * This constructor creates a builder with
  62.      * <ul>
  63.      *   <li>{@link #getConventions() IERS conventions} set to {@link IERSConventions#IERS_2010}</li>
  64.      *   <li>{@link #getMissionReferenceDate() mission reference date} set to {@code null}</li>
  65.      *   <li>{@link #getRangeUnitsConverter() converter for range units} set to {@link IdentityConverter}</li>
  66.      * </ul>
  67.      * @param dataContext data context used to retrieve frames, time scales, etc.
  68.      */
  69.     public WriterBuilder(final DataContext dataContext) {
  70.         this(IERSConventions.IERS_2010, dataContext, null, new IdentityConverter());
  71.     }

  72.     /** Complete constructor.
  73.      * @param conventions IERS Conventions
  74.      * @param dataContext used to retrieve frames, time scales, etc.
  75.      * @param missionReferenceDate reference date for Mission Elapsed Time or Mission Relative Time time systems
  76.      * @param rangeUnitsConverter converter for {@link RangeUnits#RU Range Units}
  77.      */
  78.     private WriterBuilder(final IERSConventions conventions, final DataContext dataContext,
  79.                           final AbsoluteDate missionReferenceDate, final RangeUnitsConverter rangeUnitsConverter) {
  80.         super(conventions, dataContext, missionReferenceDate, rangeUnitsConverter);
  81.     }

  82.     /** {@inheritDoc} */
  83.     @Override
  84.     protected WriterBuilder create(final IERSConventions newConventions, final DataContext newDataContext,
  85.                                    final AbsoluteDate newMissionReferenceDate, final RangeUnitsConverter newRangeUnitsConverter) {
  86.         return new WriterBuilder(newConventions, newDataContext, newMissionReferenceDate, newRangeUnitsConverter);
  87.     }

  88.     /** Build a writer for {@link org.orekit.files.ccsds.ndm.Ndm Navigation Data Messages}.
  89.      * @return a new writer
  90.      */
  91.     public NdmWriter buildNdmWriter() {
  92.         return new NdmWriter(this);
  93.     }

  94.     /** Build a writer for {@link org.orekit.files.ccsds.ndm.odm.opm.Opm Orbit Parameters Messages}.
  95.      * @return a new writer
  96.      */
  97.     public OpmWriter buildOpmWriter() {
  98.         return new OpmWriter(getConventions(), getDataContext(), getMissionReferenceDate());
  99.     }

  100.     /** Build a writer for {@link org.orekit.files.ccsds.ndm.odm.omm.Omm Orbit Mean elements Messages}.
  101.      * @return a new writer
  102.      */
  103.     public OmmWriter buildOmmWriter() {
  104.         return new OmmWriter(getConventions(), getDataContext(), getMissionReferenceDate());
  105.     }

  106.     /** Build a writer for {@link org.orekit.files.ccsds.ndm.odm.oem.Oem Orbit Ephemeris Messages}.
  107.      * @return a new writer
  108.      */
  109.     public OemWriter buildOemWriter() {
  110.         return new OemWriter(getConventions(), getDataContext(), getMissionReferenceDate());
  111.     }

  112.     /** Build a writer for {@link org.orekit.files.ccsds.ndm.odm.ocm.Ocm Orbit Comprehensive Messages}.
  113.      * @return a new writer
  114.      */
  115.     public OcmWriter buildOcmWriter() {
  116.         return new OcmWriter(getConventions(), getDataContext());
  117.     }

  118.     /** Build a writer for {@link org.orekit.files.ccsds.ndm.adm.apm.Apm Attitude Parameters Messages}.
  119.      * @return a new writer
  120.      */
  121.     public ApmWriter buildApmWriter() {
  122.         return new ApmWriter(getConventions(), getDataContext(), getMissionReferenceDate());
  123.     }

  124.     /** Build a writer for {@link org.orekit.files.ccsds.ndm.adm.aem.Aem Attitude Ephemeris Messages}.
  125.      * @return a new writer
  126.      */
  127.     public AemWriter buildAemWriter() {
  128.         return new AemWriter(getConventions(), getDataContext(), getMissionReferenceDate());
  129.     }

  130.     /** Build a writer for {@link org.orekit.files.ccsds.ndm.tdm.Tdm Tracking Data Messages}.
  131.      * @return a new writer
  132.      */
  133.     public TdmWriter buildTdmWriter() {
  134.         return new TdmWriter(getConventions(), getDataContext(), getRangeUnitsConverter());
  135.     }

  136. }