PhysicalPropertiesWriter.java

  1. /* Copyright 2002-2022 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.utils.units.Unit;

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

  30.     /** Physical properties block. */
  31.     private final PhysicalProperties phys;

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

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

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

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

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

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

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

  59.         // Optimally Enclosing Box
  60.         generator.writeEntry(PhysicalPropertiesKey.OEB_PARENT_FRAME.name(),       phys.getOebParentFrame().getName(),           null, false);
  61.         generator.writeEntry(PhysicalPropertiesKey.OEB_PARENT_FRAME_EPOCH.name(), timeConverter, phys.getOebParentFrameEpoch(),       false);
  62.         generator.writeEntry(PhysicalPropertiesKey.OEB_Q1.name(),                 phys.getOebQ().getQ1(), Unit.ONE,                   false);
  63.         generator.writeEntry(PhysicalPropertiesKey.OEB_Q2.name(),                 phys.getOebQ().getQ2(), Unit.ONE,                   false);
  64.         generator.writeEntry(PhysicalPropertiesKey.OEB_Q3.name(),                 phys.getOebQ().getQ3(), Unit.ONE,                   false);
  65.         generator.writeEntry(PhysicalPropertiesKey.OEB_QC.name(),                 phys.getOebQ().getQ0(), Unit.ONE,                   false);
  66.         generator.writeEntry(PhysicalPropertiesKey.OEB_MAX.name(),                phys.getOebMax(), Unit.METRE,                       false);
  67.         generator.writeEntry(PhysicalPropertiesKey.OEB_INT.name(),                phys.getOebIntermediate(), Unit.METRE,              false);
  68.         generator.writeEntry(PhysicalPropertiesKey.OEB_MIN.name(),                phys.getOebMin(), Unit.METRE,                       false);
  69.         generator.writeEntry(PhysicalPropertiesKey.AREA_ALONG_OEB_MAX.name(),     phys.getOebAreaAlongMax(), Units.M2,                false);
  70.         generator.writeEntry(PhysicalPropertiesKey.AREA_ALONG_OEB_INT.name(),     phys.getOebAreaAlongIntermediate(), Units.M2,       false);
  71.         generator.writeEntry(PhysicalPropertiesKey.AREA_ALONG_OEB_MIN.name(),     phys.getOebAreaAlongMin(), Units.M2,                false);

  72.         // collision probability
  73.         generator.writeEntry(PhysicalPropertiesKey.AREA_MIN_FOR_PC.name(), phys.getMinAreaForCollisionProbability(), Units.M2, false);
  74.         generator.writeEntry(PhysicalPropertiesKey.AREA_MAX_FOR_PC.name(), phys.getMaxAreaForCollisionProbability(), Units.M2, false);
  75.         generator.writeEntry(PhysicalPropertiesKey.AREA_TYP_FOR_PC.name(), phys.getTypAreaForCollisionProbability(), Units.M2, false);

  76.         // radar cross section
  77.         generator.writeEntry(PhysicalPropertiesKey.RCS.name(),     phys.getRcs(), Units.M2,    false);
  78.         generator.writeEntry(PhysicalPropertiesKey.RCS_MIN.name(), phys.getMinRcs(), Units.M2, false);
  79.         generator.writeEntry(PhysicalPropertiesKey.RCS_MAX.name(), phys.getMaxRcs(), Units.M2, false);

  80.         // solar radiation pressure
  81.         generator.writeEntry(PhysicalPropertiesKey.SRP_CONST_AREA.name(),        phys.getSrpConstantArea(), Units.M2,    false);
  82.         generator.writeEntry(PhysicalPropertiesKey.SOLAR_RAD_COEFF.name(),       phys.getSrpCoefficient(), Unit.ONE,     false);
  83.         generator.writeEntry(PhysicalPropertiesKey.SOLAR_RAD_UNCERTAINTY.name(), phys.getSrpUncertainty(), Unit.PERCENT, false);

  84.         // visual magnitude
  85.         generator.writeEntry(PhysicalPropertiesKey.VM_ABSOLUTE.name(),     phys.getVmAbsolute(), Unit.ONE,    false);
  86.         generator.writeEntry(PhysicalPropertiesKey.VM_APPARENT_MIN.name(), phys.getVmApparentMin(), Unit.ONE, false);
  87.         generator.writeEntry(PhysicalPropertiesKey.VM_APPARENT.name(),     phys.getVmApparent(), Unit.ONE,    false);
  88.         generator.writeEntry(PhysicalPropertiesKey.VM_APPARENT_MAX.name(), phys.getVmApparentMax(), Unit.ONE, false);
  89.         generator.writeEntry(PhysicalPropertiesKey.REFLECTIVITY.name(),    phys.getReflectivity(), Unit.ONE,  false);

  90.         // attitude
  91.         generator.writeEntry(PhysicalPropertiesKey.ATT_CONTROL_MODE.name(),  phys.getAttitudeControlMode(),       null,        false);
  92.         generator.writeEntry(PhysicalPropertiesKey.ATT_ACTUATOR_TYPE.name(), phys.getAttitudeActuatorType(),      null,        false);
  93.         generator.writeEntry(PhysicalPropertiesKey.ATT_KNOWLEDGE.name(),     phys.getAttitudeKnowledgeAccuracy(), Unit.DEGREE, false);
  94.         generator.writeEntry(PhysicalPropertiesKey.ATT_CONTROL.name(),       phys.getAttitudeControlAccuracy(),   Unit.DEGREE, false);
  95.         generator.writeEntry(PhysicalPropertiesKey.ATT_POINTING.name(),      phys.getAttitudePointingAccuracy(),  Unit.DEGREE, false);

  96.         // maneuvers
  97.         generator.writeEntry(PhysicalPropertiesKey.AVG_MANEUVER_FREQ.name(), phys.getManeuversFrequency(), Units.NB_PER_Y, false);
  98.         generator.writeEntry(PhysicalPropertiesKey.MAX_THRUST.name(),        phys.getMaxThrust(),          Unit.NEWTON,    false);
  99.         generator.writeEntry(PhysicalPropertiesKey.DV_BOL.name(),            phys.getBolDv(),              Units.KM_PER_S, false);
  100.         generator.writeEntry(PhysicalPropertiesKey.DV_REMAINING.name(),      phys.getRemainingDv(),        Units.KM_PER_S, false);

  101.         // inertia
  102.         final RealMatrix inertia = phys.getInertiaMatrix();
  103.         if (inertia != null) {
  104.             generator.writeEntry(PhysicalPropertiesKey.IXX.name(), inertia.getEntry(0, 0), Units.KG_M2, true);
  105.             generator.writeEntry(PhysicalPropertiesKey.IYY.name(), inertia.getEntry(1, 1), Units.KG_M2, true);
  106.             generator.writeEntry(PhysicalPropertiesKey.IZZ.name(), inertia.getEntry(2, 2), Units.KG_M2, true);
  107.             generator.writeEntry(PhysicalPropertiesKey.IXY.name(), inertia.getEntry(0, 1), Units.KG_M2, true);
  108.             generator.writeEntry(PhysicalPropertiesKey.IXZ.name(), inertia.getEntry(0, 2), Units.KG_M2, true);
  109.             generator.writeEntry(PhysicalPropertiesKey.IYZ.name(), inertia.getEntry(1, 2), Units.KG_M2, true);
  110.         }

  111.     }

  112. }