1   /* Copyright 2022-2025 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  
18  package org.orekit.files.ccsds.ndm.adm.apm;
19  
20  import java.io.IOException;
21  
22  import org.orekit.files.ccsds.definitions.Units;
23  import org.orekit.files.ccsds.section.AbstractWriter;
24  import org.orekit.files.ccsds.utils.generation.Generator;
25  
26  /** Writer for angular velocity data.
27   * @author Luc Maisonobe
28   * @since 12.0
29   */
30  class AngularVelocityWriter extends AbstractWriter {
31  
32      /** Angular velocity block. */
33      private final AngularVelocity angularVelocity;
34  
35      /** Create a writer.
36       * @param xmlTag name of the XML tag surrounding the section
37       * @param kvnTag name of the KVN tag surrounding the section (may be null)
38       * @param angularVelocity angular velocity block
39       */
40      AngularVelocityWriter(final String xmlTag, final String kvnTag,
41                            final AngularVelocity angularVelocity) {
42          super(xmlTag, kvnTag);
43          this.angularVelocity = angularVelocity;
44      }
45  
46      /** {@inheritDoc} */
47      @Override
48      protected void writeContent(final Generator generator) throws IOException {
49  
50          generator.writeComments(angularVelocity.getComments());
51  
52          // endpoints
53          generator.writeEntry(AngularVelocityKey.REF_FRAME_A.name(), angularVelocity.getEndpoints().getFrameA().getName(), null, true);
54          generator.writeEntry(AngularVelocityKey.REF_FRAME_B.name(), angularVelocity.getEndpoints().getFrameB().getName(), null, true);
55  
56          // frame
57          generator.writeEntry(AngularVelocityKey.ANGVEL_FRAME.name(), angularVelocity.getFrame().getName(), null, true);
58  
59          // velocity
60          generator.writeEntry(AngularVelocityKey.ANGVEL_X.name(), angularVelocity.getAngVelX(), Units.DEG_PER_S, true);
61          generator.writeEntry(AngularVelocityKey.ANGVEL_Y.name(), angularVelocity.getAngVelY(), Units.DEG_PER_S, true);
62          generator.writeEntry(AngularVelocityKey.ANGVEL_Z.name(), angularVelocity.getAngVelZ(), Units.DEG_PER_S, true);
63  
64      }
65  
66  }