1   /* Copyright 2002-2025 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  
18  package org.orekit.files.ccsds.ndm.odm.opm;
19  
20  import java.io.IOException;
21  
22  import org.orekit.files.ccsds.definitions.TimeConverter;
23  import org.orekit.files.ccsds.definitions.Units;
24  import org.orekit.files.ccsds.section.AbstractWriter;
25  import org.orekit.files.ccsds.utils.generation.Generator;
26  import org.orekit.utils.units.Unit;
27  
28  /** Writer for maneuver parameters data.
29   * @author Luc Maisonobe
30   * @since 11.0
31   */
32  class ManeuverWriter extends AbstractWriter {
33  
34      /** Maneuver parameters block. */
35      private final Maneuver maneuver;
36  
37      /** Converter for dates. */
38      private final TimeConverter timeConverter;
39  
40      /** Create a writer.
41       * @param maneuver maneuver to write
42       * @param timeConverter converter for dates
43       */
44      ManeuverWriter(final Maneuver maneuver, final TimeConverter timeConverter) {
45          super(XmlSubStructureKey.maneuverParameters.name(), null);
46          this.maneuver      = maneuver;
47          this.timeConverter = timeConverter;
48      }
49  
50      /** {@inheritDoc} */
51      @Override
52      protected void writeContent(final Generator generator) throws IOException {
53  
54          // maneuver block
55          generator.writeComments(maneuver.getComments());
56  
57          generator.writeEntry(ManeuverKey.MAN_EPOCH_IGNITION.name(), timeConverter, maneuver.getEpochIgnition(),   false, true);
58          generator.writeEntry(ManeuverKey.MAN_DURATION.name(),       maneuver.getDuration(), Unit.SECOND,          true);
59          generator.writeEntry(ManeuverKey.MAN_DELTA_MASS.name(),     maneuver.getDeltaMass(), Unit.KILOGRAM,       true);
60          generator.writeEntry(ManeuverKey.MAN_REF_FRAME.name(),      maneuver.getReferenceFrame().getName(), null, true);
61          generator.writeEntry(ManeuverKey.MAN_DV_1.name(),           maneuver.getDV().getX(), Units.KM_PER_S,      true);
62          generator.writeEntry(ManeuverKey.MAN_DV_2.name(),           maneuver.getDV().getY(), Units.KM_PER_S,      true);
63          generator.writeEntry(ManeuverKey.MAN_DV_3.name(),           maneuver.getDV().getZ(), Units.KM_PER_S,      true);
64  
65      }
66  
67  }