ManeuverWriter.java

  1. /* Copyright 2002-2024 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.odm.opm;

  18. import java.io.IOException;

  19. import org.orekit.files.ccsds.definitions.TimeConverter;
  20. import org.orekit.files.ccsds.definitions.Units;
  21. import org.orekit.files.ccsds.section.AbstractWriter;
  22. import org.orekit.files.ccsds.utils.generation.Generator;
  23. import org.orekit.utils.units.Unit;

  24. /** Writer for maneuver parameters data.
  25.  * @author Luc Maisonobe
  26.  * @since 11.0
  27.  */
  28. class ManeuverWriter extends AbstractWriter {

  29.     /** Maneuver parameters block. */
  30.     private final Maneuver maneuver;

  31.     /** Converter for dates. */
  32.     private final TimeConverter timeConverter;

  33.     /** Create a writer.
  34.      * @param maneuver maneuver to write
  35.      * @param timeConverter converter for dates
  36.      */
  37.     ManeuverWriter(final Maneuver maneuver, final TimeConverter timeConverter) {
  38.         super(XmlSubStructureKey.maneuverParameters.name(), null);
  39.         this.maneuver      = maneuver;
  40.         this.timeConverter = timeConverter;
  41.     }

  42.     /** {@inheritDoc} */
  43.     @Override
  44.     protected void writeContent(final Generator generator) throws IOException {

  45.         // maneuver block
  46.         generator.writeComments(maneuver.getComments());

  47.         generator.writeEntry(ManeuverKey.MAN_EPOCH_IGNITION.name(), timeConverter, maneuver.getEpochIgnition(),   false, true);
  48.         generator.writeEntry(ManeuverKey.MAN_DURATION.name(),       maneuver.getDuration(), Unit.SECOND,          true);
  49.         generator.writeEntry(ManeuverKey.MAN_DELTA_MASS.name(),     maneuver.getDeltaMass(), Unit.KILOGRAM,       true);
  50.         generator.writeEntry(ManeuverKey.MAN_REF_FRAME.name(),      maneuver.getReferenceFrame().getName(), null, true);
  51.         generator.writeEntry(ManeuverKey.MAN_DV_1.name(),           maneuver.getDV().getX(), Units.KM_PER_S,      true);
  52.         generator.writeEntry(ManeuverKey.MAN_DV_2.name(),           maneuver.getDV().getY(), Units.KM_PER_S,      true);
  53.         generator.writeEntry(ManeuverKey.MAN_DV_3.name(),           maneuver.getDV().getZ(), Units.KM_PER_S,      true);

  54.     }

  55. }