SpacecraftParametersWriter.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;

  18. import java.io.IOException;

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

  23. /** Writer for spacecraft parameters data.
  24.  * @author Luc Maisonobe
  25.  * @since 11.0
  26.  */
  27. public class SpacecraftParametersWriter extends AbstractWriter {

  28.     /** Spacecraft parameters block. */
  29.     private final SpacecraftParameters spacecraftParameters;

  30.     /** Create a writer.
  31.      * @param xmlTag name of the XML tag surrounding the section
  32.      * @param kvnTag name of the KVN tag surrounding the section (may be null)
  33.      * @param spacecraftParameters spacecraft parameters to write
  34.      */
  35.     public SpacecraftParametersWriter(final String xmlTag, final String kvnTag,
  36.                                       final SpacecraftParameters spacecraftParameters) {
  37.         super(xmlTag, kvnTag);
  38.         this.spacecraftParameters = spacecraftParameters;
  39.     }

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

  43.         // spacecraft parameters block
  44.         generator.writeComments(spacecraftParameters.getComments());

  45.         // mass
  46.         generator.writeEntry(SpacecraftParametersKey.MASS.name(), spacecraftParameters.getMass(), Unit.KILOGRAM, false);

  47.         // solar parameters
  48.         generator.writeEntry(SpacecraftParametersKey.SOLAR_RAD_AREA.name(),  spacecraftParameters.getSolarRadArea(),  Units.M2, false);
  49.         generator.writeEntry(SpacecraftParametersKey.SOLAR_RAD_COEFF.name(), spacecraftParameters.getSolarRadCoeff(), Unit.ONE, false);

  50.         // drag parameters
  51.         generator.writeEntry(SpacecraftParametersKey.DRAG_AREA.name(),  spacecraftParameters.getDragArea(),  Units.M2, false);
  52.         generator.writeEntry(SpacecraftParametersKey.DRAG_COEFF.name(), spacecraftParameters.getDragCoeff(), Unit.ONE, false);

  53.     }

  54. }