OrbitPhysicalPropertiesWriter.java

  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. package org.orekit.files.ccsds.ndm.odm.ocm;

  18. import java.io.IOException;

  19. import org.hipparchus.linear.RealMatrix;
  20. import org.orekit.files.ccsds.definitions.TimeConverter;
  21. import org.orekit.files.ccsds.definitions.Units;
  22. import org.orekit.files.ccsds.section.AbstractWriter;
  23. import org.orekit.files.ccsds.utils.generation.Generator;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.utils.units.Unit;

  26. /** Writer for physical properties data.
  27.  * @author Luc Maisonobe
  28.  * @since 11.0
  29.  */
  30. class OrbitPhysicalPropertiesWriter extends AbstractWriter {

  31.     /** Physical properties block. */
  32.     private final OrbitPhysicalProperties phys;

  33.     /** Converter for dates. */
  34.     private final TimeConverter timeConverter;

  35.     /** Create a writer.
  36.      * @param phys physical properties to write
  37.      * @param timeConverter converter for dates
  38.      */
  39.     OrbitPhysicalPropertiesWriter(final OrbitPhysicalProperties phys, final TimeConverter timeConverter) {
  40.         super(OcmDataSubStructureKey.phys.name(), OcmDataSubStructureKey.PHYS.name());
  41.         this.phys          = phys;
  42.         this.timeConverter = timeConverter;
  43.     }

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

  47.         // physical properties block
  48.         generator.writeComments(phys.getComments());

  49.         generator.writeEntry(OrbitPhysicalPropertiesKey.MANUFACTURER.name(), phys.getManufacturer(), null, false);
  50.         generator.writeEntry(OrbitPhysicalPropertiesKey.BUS_MODEL.name(),    phys.getBusModel(),     null, false);
  51.         generator.writeEntry(OrbitPhysicalPropertiesKey.DOCKED_WITH.name(),  phys.getDockedWith(),         false);

  52.         // drag
  53.         generator.writeEntry(OrbitPhysicalPropertiesKey.DRAG_CONST_AREA.name(),  phys.getDragConstantArea(), Units.M2,    false);
  54.         generator.writeEntry(OrbitPhysicalPropertiesKey.DRAG_COEFF_NOM.name(),   phys.getDragCoefficient(), Unit.ONE,     false);
  55.         generator.writeEntry(OrbitPhysicalPropertiesKey.DRAG_UNCERTAINTY.name(), phys.getDragUncertainty(), Unit.PERCENT, false);

  56.         // mass
  57.         generator.writeEntry(OrbitPhysicalPropertiesKey.INITIAL_WET_MASS.name(), phys.getInitialWetMass(), Unit.KILOGRAM, false);
  58.         generator.writeEntry(OrbitPhysicalPropertiesKey.WET_MASS.name(),         phys.getWetMass(), Unit.KILOGRAM,        false);
  59.         generator.writeEntry(OrbitPhysicalPropertiesKey.DRY_MASS.name(),         phys.getDryMass(), Unit.KILOGRAM,        false);

  60.         // Optimally Enclosing Box
  61.         generator.writeEntry(OrbitPhysicalPropertiesKey.OEB_PARENT_FRAME.name(),       phys.getOebParentFrame().getName(),           null, false);
  62.         final AbsoluteDate oebParentFrameEpoch = phys.getOebParentFrameEpoch();
  63.         // oebParentFrameEpoch may be null. Usually checked in writeEntry(...)
  64.         if (!timeConverter.getReferenceDate().equals(oebParentFrameEpoch) &&
  65.             phys.getOebParentFrame().asOrbitRelativeFrame() == null &&
  66.             phys.getOebParentFrame().asSpacecraftBodyFrame() == null) {
  67.             generator.writeEntry(OrbitPhysicalPropertiesKey.OEB_PARENT_FRAME_EPOCH.name(), timeConverter, oebParentFrameEpoch, true, false);
  68.         }
  69.         generator.writeEntry(OrbitPhysicalPropertiesKey.OEB_Q1.name(),                 phys.getOebQ().getQ1(), Unit.ONE,                   false);
  70.         generator.writeEntry(OrbitPhysicalPropertiesKey.OEB_Q2.name(),                 phys.getOebQ().getQ2(), Unit.ONE,                   false);
  71.         generator.writeEntry(OrbitPhysicalPropertiesKey.OEB_Q3.name(),                 phys.getOebQ().getQ3(), Unit.ONE,                   false);
  72.         generator.writeEntry(OrbitPhysicalPropertiesKey.OEB_QC.name(),                 phys.getOebQ().getQ0(), Unit.ONE,                   false);
  73.         generator.writeEntry(OrbitPhysicalPropertiesKey.OEB_MAX.name(),                phys.getOebMax(), Unit.METRE,                       false);
  74.         generator.writeEntry(OrbitPhysicalPropertiesKey.OEB_INT.name(),                phys.getOebIntermediate(), Unit.METRE,              false);
  75.         generator.writeEntry(OrbitPhysicalPropertiesKey.OEB_MIN.name(),                phys.getOebMin(), Unit.METRE,                       false);
  76.         generator.writeEntry(OrbitPhysicalPropertiesKey.AREA_ALONG_OEB_MAX.name(),     phys.getOebAreaAlongMax(), Units.M2,                false);
  77.         generator.writeEntry(OrbitPhysicalPropertiesKey.AREA_ALONG_OEB_INT.name(),     phys.getOebAreaAlongIntermediate(), Units.M2,       false);
  78.         generator.writeEntry(OrbitPhysicalPropertiesKey.AREA_ALONG_OEB_MIN.name(),     phys.getOebAreaAlongMin(), Units.M2,                false);

  79.         // collision probability
  80.         generator.writeEntry(OrbitPhysicalPropertiesKey.AREA_MIN_FOR_PC.name(), phys.getMinAreaForCollisionProbability(), Units.M2, false);
  81.         generator.writeEntry(OrbitPhysicalPropertiesKey.AREA_MAX_FOR_PC.name(), phys.getMaxAreaForCollisionProbability(), Units.M2, false);
  82.         generator.writeEntry(OrbitPhysicalPropertiesKey.AREA_TYP_FOR_PC.name(), phys.getTypAreaForCollisionProbability(), Units.M2, false);

  83.         // radar cross section
  84.         generator.writeEntry(OrbitPhysicalPropertiesKey.RCS.name(),     phys.getRcs(), Units.M2,    false);
  85.         generator.writeEntry(OrbitPhysicalPropertiesKey.RCS_MIN.name(), phys.getMinRcs(), Units.M2, false);
  86.         generator.writeEntry(OrbitPhysicalPropertiesKey.RCS_MAX.name(), phys.getMaxRcs(), Units.M2, false);

  87.         // solar radiation pressure
  88.         generator.writeEntry(OrbitPhysicalPropertiesKey.SRP_CONST_AREA.name(),        phys.getSrpConstantArea(), Units.M2,    false);
  89.         generator.writeEntry(OrbitPhysicalPropertiesKey.SOLAR_RAD_COEFF.name(),       phys.getSrpCoefficient(), Unit.ONE,     false);
  90.         generator.writeEntry(OrbitPhysicalPropertiesKey.SOLAR_RAD_UNCERTAINTY.name(), phys.getSrpUncertainty(), Unit.PERCENT, false);

  91.         // visual magnitude
  92.         generator.writeEntry(OrbitPhysicalPropertiesKey.VM_ABSOLUTE.name(),     phys.getVmAbsolute(),    Unit.ONE, false);
  93.         generator.writeEntry(OrbitPhysicalPropertiesKey.VM_APPARENT_MIN.name(), phys.getVmApparentMin(), Unit.ONE, false);
  94.         generator.writeEntry(OrbitPhysicalPropertiesKey.VM_APPARENT.name(),     phys.getVmApparent(),    Unit.ONE, false);
  95.         generator.writeEntry(OrbitPhysicalPropertiesKey.VM_APPARENT_MAX.name(), phys.getVmApparentMax(), Unit.ONE, false);
  96.         generator.writeEntry(OrbitPhysicalPropertiesKey.REFLECTANCE.name(),     phys.getReflectance(),   Unit.ONE, false);

  97.         // attitude
  98.         generator.writeEntry(OrbitPhysicalPropertiesKey.ATT_CONTROL_MODE.name(),  phys.getAttitudeControlMode(),       null,        false);
  99.         generator.writeEntry(OrbitPhysicalPropertiesKey.ATT_ACTUATOR_TYPE.name(), phys.getAttitudeActuatorType(),      null,        false);
  100.         generator.writeEntry(OrbitPhysicalPropertiesKey.ATT_KNOWLEDGE.name(),     phys.getAttitudeKnowledgeAccuracy(), Unit.DEGREE, false);
  101.         generator.writeEntry(OrbitPhysicalPropertiesKey.ATT_CONTROL.name(),       phys.getAttitudeControlAccuracy(),   Unit.DEGREE, false);
  102.         generator.writeEntry(OrbitPhysicalPropertiesKey.ATT_POINTING.name(),      phys.getAttitudePointingAccuracy(),  Unit.DEGREE, false);

  103.         // maneuvers
  104.         generator.writeEntry(OrbitPhysicalPropertiesKey.AVG_MANEUVER_FREQ.name(), phys.getManeuversFrequency(), Units.NB_PER_Y, false);
  105.         generator.writeEntry(OrbitPhysicalPropertiesKey.MAX_THRUST.name(),        phys.getMaxThrust(),          Unit.NEWTON,    false);
  106.         generator.writeEntry(OrbitPhysicalPropertiesKey.DV_BOL.name(),            phys.getBolDv(),              Units.KM_PER_S, false);
  107.         generator.writeEntry(OrbitPhysicalPropertiesKey.DV_REMAINING.name(),      phys.getRemainingDv(),        Units.KM_PER_S, false);

  108.         // inertia
  109.         final RealMatrix inertia = phys.getInertiaMatrix();
  110.         if (inertia != null) {
  111.             generator.writeEntry(OrbitPhysicalPropertiesKey.IXX.name(), inertia.getEntry(0, 0), Units.KG_M2, false);
  112.             generator.writeEntry(OrbitPhysicalPropertiesKey.IYY.name(), inertia.getEntry(1, 1), Units.KG_M2, false);
  113.             generator.writeEntry(OrbitPhysicalPropertiesKey.IZZ.name(), inertia.getEntry(2, 2), Units.KG_M2, false);
  114.             generator.writeEntry(OrbitPhysicalPropertiesKey.IXY.name(), inertia.getEntry(0, 1), Units.KG_M2, false);
  115.             generator.writeEntry(OrbitPhysicalPropertiesKey.IXZ.name(), inertia.getEntry(0, 2), Units.KG_M2, false);
  116.             generator.writeEntry(OrbitPhysicalPropertiesKey.IYZ.name(), inertia.getEntry(1, 2), Units.KG_M2, false);
  117.         }

  118.     }

  119. }