AngularVelocityWriter.java

  1. /* Copyright 2002-2024 Luc Maisonobe
  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.adm.apm;

  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. /** Writer for angular velocity data.
  23.  * @author Luc Maisonobe
  24.  * @since 12.0
  25.  */
  26. class AngularVelocityWriter extends AbstractWriter {

  27.     /** Angular velocity block. */
  28.     private final AngularVelocity angularVelocity;

  29.     /** Create a writer.
  30.      * @param xmlTag name of the XML tag surrounding the section
  31.      * @param kvnTag name of the KVN tag surrounding the section (may be null)
  32.      * @param angularVelocity angular velocity block
  33.      */
  34.     AngularVelocityWriter(final String xmlTag, final String kvnTag,
  35.                           final AngularVelocity angularVelocity) {
  36.         super(xmlTag, kvnTag);
  37.         this.angularVelocity = angularVelocity;
  38.     }

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

  42.         generator.writeComments(angularVelocity.getComments());

  43.         // endpoints
  44.         generator.writeEntry(AngularVelocityKey.REF_FRAME_A.name(), angularVelocity.getEndpoints().getFrameA().getName(), null, true);
  45.         generator.writeEntry(AngularVelocityKey.REF_FRAME_B.name(), angularVelocity.getEndpoints().getFrameB().getName(), null, true);

  46.         // frame
  47.         generator.writeEntry(AngularVelocityKey.ANGVEL_FRAME.name(), angularVelocity.getFrame().getName(), null, true);

  48.         // velocity
  49.         generator.writeEntry(AngularVelocityKey.ANGVEL_X.name(), angularVelocity.getAngVelX(), Units.DEG_PER_S, true);
  50.         generator.writeEntry(AngularVelocityKey.ANGVEL_Y.name(), angularVelocity.getAngVelY(), Units.DEG_PER_S, true);
  51.         generator.writeEntry(AngularVelocityKey.ANGVEL_Z.name(), angularVelocity.getAngVelZ(), Units.DEG_PER_S, true);

  52.     }

  53. }