Commit cc4ef9ea authored by Luc Maisonobe's avatar Luc Maisonobe

Merge branch 'issue-474' into develop

parents 985c2d5b 6f9d8f73
Pipeline #1030 passed with stages
in 30 minutes and 10 seconds
......@@ -66,18 +66,18 @@ class ApmQuaternionWriter extends AbstractWriter {
// quaternion
final Quaternion q = quaternion.getQuaternion();
generator.writeEntry(ApmQuaternionKey.Q1.name(), Unit.ONE.fromSI(q.getQ1()), true);
generator.writeEntry(ApmQuaternionKey.Q2.name(), Unit.ONE.fromSI(q.getQ2()), true);
generator.writeEntry(ApmQuaternionKey.Q3.name(), Unit.ONE.fromSI(q.getQ3()), true);
generator.writeEntry(ApmQuaternionKey.QC.name(), Unit.ONE.fromSI(q.getQ0()), true);
generator.writeEntry(ApmQuaternionKey.Q1.name(), q.getQ1(), Unit.ONE, true);
generator.writeEntry(ApmQuaternionKey.Q2.name(), q.getQ2(), Unit.ONE, true);
generator.writeEntry(ApmQuaternionKey.Q3.name(), q.getQ3(), Unit.ONE, true);
generator.writeEntry(ApmQuaternionKey.QC.name(), q.getQ0(), Unit.ONE, true);
// quaternion derivative
if (quaternion.hasRates()) {
final Quaternion qDot = quaternion.getQuaternionDot();
generator.writeEntry(ApmQuaternionKey.Q1_DOT.name(), Unit.ONE.fromSI(qDot.getQ1()), true);
generator.writeEntry(ApmQuaternionKey.Q2_DOT.name(), Unit.ONE.fromSI(qDot.getQ2()), true);
generator.writeEntry(ApmQuaternionKey.Q3_DOT.name(), Unit.ONE.fromSI(qDot.getQ3()), true);
generator.writeEntry(ApmQuaternionKey.QC_DOT.name(), Unit.ONE.fromSI(qDot.getQ0()), true);
generator.writeEntry(ApmQuaternionKey.Q1_DOT.name(), qDot.getQ1(), Unit.ONE, true);
generator.writeEntry(ApmQuaternionKey.Q2_DOT.name(), qDot.getQ2(), Unit.ONE, true);
generator.writeEntry(ApmQuaternionKey.Q3_DOT.name(), qDot.getQ3(), Unit.ONE, true);
generator.writeEntry(ApmQuaternionKey.QC_DOT.name(), qDot.getQ0(), Unit.ONE, true);
}
}
......
......@@ -77,16 +77,16 @@ class EulerWriter extends AbstractWriter {
// if we don't have rates, at least we need angles
// (we may have only rates, as orientation is already given by mandatory quaternion)
final boolean needsAngles = !euler.hasRates();
generator.writeEntry(seq.charAt(0) + ANGLE, Unit.DEGREE.fromSI(angles[0]), needsAngles);
generator.writeEntry(seq.charAt(1) + ANGLE, Unit.DEGREE.fromSI(angles[1]), needsAngles);
generator.writeEntry(seq.charAt(2) + ANGLE, Unit.DEGREE.fromSI(angles[2]), needsAngles);
generator.writeEntry(seq.charAt(0) + ANGLE, angles[0], Unit.DEGREE, needsAngles);
generator.writeEntry(seq.charAt(1) + ANGLE, angles[1], Unit.DEGREE, needsAngles);
generator.writeEntry(seq.charAt(2) + ANGLE, angles[2], Unit.DEGREE, needsAngles);
// rates
if (euler.hasRates()) {
final double[] rates = euler.getRotationRates();
generator.writeEntry(seq.charAt(0) + RATE, Units.DEG_PER_S.fromSI(rates[0]), true);
generator.writeEntry(seq.charAt(1) + RATE, Units.DEG_PER_S.fromSI(rates[1]), true);
generator.writeEntry(seq.charAt(2) + RATE, Units.DEG_PER_S.fromSI(rates[2]), true);
generator.writeEntry(seq.charAt(0) + RATE, rates[0], Units.DEG_PER_S, true);
generator.writeEntry(seq.charAt(1) + RATE, rates[1], Units.DEG_PER_S, true);
generator.writeEntry(seq.charAt(2) + RATE, rates[2], Units.DEG_PER_S, true);
}
}
......
......@@ -59,16 +59,16 @@ class ManeuverWriter extends AbstractWriter {
// time
generator.writeEntry(ManeuverKey.MAN_EPOCH_START.name(), timeConverter, maneuver.getEpochStart(), true);
generator.writeEntry(ManeuverKey.MAN_DURATION.name(), Unit.SECOND.fromSI(maneuver.getDuration()), true);
generator.writeEntry(ManeuverKey.MAN_DURATION.name(), maneuver.getDuration(), Unit.SECOND, true);
// frame
generator.writeEntry(ManeuverKey.MAN_REF_FRAME.name(), maneuver.getRefFrameString(), false);
// torque
final Vector3D torque = maneuver.getTorque();
generator.writeEntry(ManeuverKey.MAN_TOR_1.name(), Units.N_M.fromSI(torque.getX()), true);
generator.writeEntry(ManeuverKey.MAN_TOR_2.name(), Units.N_M.fromSI(torque.getY()), true);
generator.writeEntry(ManeuverKey.MAN_TOR_3.name(), Units.N_M.fromSI(torque.getZ()), true);
generator.writeEntry(ManeuverKey.MAN_TOR_1.name(), torque.getX(), Units.N_M, true);
generator.writeEntry(ManeuverKey.MAN_TOR_2.name(), torque.getY(), Units.N_M, true);
generator.writeEntry(ManeuverKey.MAN_TOR_3.name(), torque.getZ(), Units.N_M, true);
}
......
......@@ -57,12 +57,12 @@ class SpacecraftParametersWriter extends AbstractWriter {
}
// inertia matrix
generator.writeEntry(SpacecraftParametersKey.I11.name(), Units.KG_M2.fromSI(spacecraftParameters.getI11()), true);
generator.writeEntry(SpacecraftParametersKey.I22.name(), Units.KG_M2.fromSI(spacecraftParameters.getI22()), true);
generator.writeEntry(SpacecraftParametersKey.I33.name(), Units.KG_M2.fromSI(spacecraftParameters.getI33()), true);
generator.writeEntry(SpacecraftParametersKey.I12.name(), Units.KG_M2.fromSI(spacecraftParameters.getI12()), true);
generator.writeEntry(SpacecraftParametersKey.I13.name(), Units.KG_M2.fromSI(spacecraftParameters.getI13()), true);
generator.writeEntry(SpacecraftParametersKey.I23.name(), Units.KG_M2.fromSI(spacecraftParameters.getI23()), true);
generator.writeEntry(SpacecraftParametersKey.I11.name(), spacecraftParameters.getI11(), Units.KG_M2, true);
generator.writeEntry(SpacecraftParametersKey.I22.name(), spacecraftParameters.getI22(), Units.KG_M2, true);
generator.writeEntry(SpacecraftParametersKey.I33.name(), spacecraftParameters.getI33(), Units.KG_M2, true);
generator.writeEntry(SpacecraftParametersKey.I12.name(), spacecraftParameters.getI12(), Units.KG_M2, true);
generator.writeEntry(SpacecraftParametersKey.I13.name(), spacecraftParameters.getI13(), Units.KG_M2, true);
generator.writeEntry(SpacecraftParametersKey.I23.name(), spacecraftParameters.getI23(), Units.KG_M2, true);
}
......
......@@ -59,15 +59,15 @@ class SpinStabilizedWriter extends AbstractWriter {
true);
// spin
generator.writeEntry(SpinStabilizedKey.SPIN_ALPHA.name(), Unit.DEGREE.fromSI(spinStabilized.getSpinAlpha()), true);
generator.writeEntry(SpinStabilizedKey.SPIN_DELTA.name(), Unit.DEGREE.fromSI(spinStabilized.getSpinDelta()), true);
generator.writeEntry(SpinStabilizedKey.SPIN_ANGLE.name(), Unit.DEGREE.fromSI(spinStabilized.getSpinAngle()), true);
generator.writeEntry(SpinStabilizedKey.SPIN_ANGLE_VEL.name(), Units.DEG_PER_S.fromSI(spinStabilized.getSpinAngleVel()), true);
generator.writeEntry(SpinStabilizedKey.SPIN_ALPHA.name(), spinStabilized.getSpinAlpha(), Unit.DEGREE, true);
generator.writeEntry(SpinStabilizedKey.SPIN_DELTA.name(), spinStabilized.getSpinDelta(), Unit.DEGREE, true);
generator.writeEntry(SpinStabilizedKey.SPIN_ANGLE.name(), spinStabilized.getSpinAngle(), Unit.DEGREE, true);
generator.writeEntry(SpinStabilizedKey.SPIN_ANGLE_VEL.name(), spinStabilized.getSpinAngleVel(), Units.DEG_PER_S, true);
// nutation
generator.writeEntry(SpinStabilizedKey.NUTATION.name(), Unit.DEGREE.fromSI(spinStabilized.getNutation()), false);
generator.writeEntry(SpinStabilizedKey.NUTATION_PER.name(), Unit.SECOND.fromSI(spinStabilized.getNutationPeriod()), false);
generator.writeEntry(SpinStabilizedKey.NUTATION_PHASE.name(), Unit.DEGREE.fromSI(spinStabilized.getNutationPhase()), false);
generator.writeEntry(SpinStabilizedKey.NUTATION.name(), spinStabilized.getNutation(), Unit.DEGREE, false);
generator.writeEntry(SpinStabilizedKey.NUTATION_PER.name(), spinStabilized.getNutationPeriod(), Unit.SECOND, false);
generator.writeEntry(SpinStabilizedKey.NUTATION_PHASE.name(), spinStabilized.getNutationPhase(), Unit.DEGREE, false);
}
......
......@@ -53,28 +53,28 @@ public class CartesianCovarianceWriter extends AbstractWriter {
// covariance block
generator.writeComments(covariance.getComments());
// note that there are no epochs in the OPM/OMM covariance matrices (but there are epochs in OEM covariance matrices)
generator.writeEntry(CartesianCovarianceKey.COV_REF_FRAME.name(), covariance.getReferenceFrame().getName(), false);
generator.writeEntry(CartesianCovarianceKey.CX_X.name(), Units.KM2.fromSI(matrix.getEntry(0, 0)), true);
generator.writeEntry(CartesianCovarianceKey.CY_X.name(), Units.KM2.fromSI(matrix.getEntry(1, 0)), true);
generator.writeEntry(CartesianCovarianceKey.CY_Y.name(), Units.KM2.fromSI(matrix.getEntry(1, 1)), true);
generator.writeEntry(CartesianCovarianceKey.CZ_X.name(), Units.KM2.fromSI(matrix.getEntry(2, 0)), true);
generator.writeEntry(CartesianCovarianceKey.CZ_Y.name(), Units.KM2.fromSI(matrix.getEntry(2, 1)), true);
generator.writeEntry(CartesianCovarianceKey.CZ_Z.name(), Units.KM2.fromSI(matrix.getEntry(2, 2)), true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_X.name(), Units.KM2_PER_S.fromSI(matrix.getEntry(3, 0)), true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_Y.name(), Units.KM2_PER_S.fromSI(matrix.getEntry(3, 1)), true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_Z.name(), Units.KM2_PER_S.fromSI(matrix.getEntry(3, 2)), true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_X_DOT.name(), Units.KM2_PER_S2.fromSI(matrix.getEntry(3, 3)), true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_X.name(), Units.KM2_PER_S.fromSI(matrix.getEntry(4, 0)), true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Y.name(), Units.KM2_PER_S.fromSI(matrix.getEntry(4, 1)), true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Z.name(), Units.KM2_PER_S.fromSI(matrix.getEntry(4, 2)), true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_X_DOT.name(), Units.KM2_PER_S2.fromSI(matrix.getEntry(4, 3)), true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Y_DOT.name(), Units.KM2_PER_S2.fromSI(matrix.getEntry(4, 4)), true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_X.name(), Units.KM2_PER_S.fromSI(matrix.getEntry(5, 0)), true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Y.name(), Units.KM2_PER_S.fromSI(matrix.getEntry(5, 1)), true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Z.name(), Units.KM2_PER_S.fromSI(matrix.getEntry(5, 2)), true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_X_DOT.name(), Units.KM2_PER_S2.fromSI(matrix.getEntry(5, 3)), true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Y_DOT.name(), Units.KM2_PER_S2.fromSI(matrix.getEntry(5, 4)), true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Z_DOT.name(), Units.KM2_PER_S2.fromSI(matrix.getEntry(5, 5)), true);
generator.writeEntry(CartesianCovarianceKey.COV_REF_FRAME.name(), covariance.getReferenceFrame().getName(), false);
generator.writeEntry(CartesianCovarianceKey.CX_X.name(), matrix.getEntry(0, 0), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CY_X.name(), matrix.getEntry(1, 0), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CY_Y.name(), matrix.getEntry(1, 1), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_X.name(), matrix.getEntry(2, 0), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_Y.name(), matrix.getEntry(2, 1), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_Z.name(), matrix.getEntry(2, 2), Units.KM2, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_X.name(), matrix.getEntry(3, 0), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_Y.name(), matrix.getEntry(3, 1), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_Z.name(), matrix.getEntry(3, 2), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CX_DOT_X_DOT.name(), matrix.getEntry(3, 3), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_X.name(), matrix.getEntry(4, 0), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Y.name(), matrix.getEntry(4, 1), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Z.name(), matrix.getEntry(4, 2), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_X_DOT.name(), matrix.getEntry(4, 3), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CY_DOT_Y_DOT.name(), matrix.getEntry(4, 4), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_X.name(), matrix.getEntry(5, 0), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Y.name(), matrix.getEntry(5, 1), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Z.name(), matrix.getEntry(5, 2), Units.KM2_PER_S, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_X_DOT.name(), matrix.getEntry(5, 3), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Y_DOT.name(), matrix.getEntry(5, 4), Units.KM2_PER_S2, true);
generator.writeEntry(CartesianCovarianceKey.CZ_DOT_Z_DOT.name(), matrix.getEntry(5, 5), Units.KM2_PER_S2, true);
}
......
......@@ -52,25 +52,15 @@ public class SpacecraftParametersWriter extends AbstractWriter {
generator.writeComments(spacecraftParameters.getComments());
// mass
generator.writeEntry(SpacecraftParametersKey.MASS.name(),
Unit.KILOGRAM.fromSI(spacecraftParameters.getMass()),
false);
generator.writeEntry(SpacecraftParametersKey.MASS.name(), spacecraftParameters.getMass(), Unit.KILOGRAM, false);
// solar parameters
generator.writeEntry(SpacecraftParametersKey.SOLAR_RAD_AREA.name(),
Units.M2.fromSI(spacecraftParameters.getSolarRadArea()),
false);
generator.writeEntry(SpacecraftParametersKey.SOLAR_RAD_COEFF.name(),
Unit.ONE.fromSI(spacecraftParameters.getSolarRadCoeff()),
false);
generator.writeEntry(SpacecraftParametersKey.SOLAR_RAD_AREA.name(), spacecraftParameters.getSolarRadArea(), Units.M2, false);
generator.writeEntry(SpacecraftParametersKey.SOLAR_RAD_COEFF.name(), spacecraftParameters.getSolarRadCoeff(), Unit.ONE, false);
// drag parameters
generator.writeEntry(SpacecraftParametersKey.DRAG_AREA.name(),
Units.M2.fromSI(spacecraftParameters.getDragArea()),
false);
generator.writeEntry(SpacecraftParametersKey.DRAG_COEFF.name(),
Unit.ONE.fromSI(spacecraftParameters.getDragCoeff()),
false);
generator.writeEntry(SpacecraftParametersKey.DRAG_AREA.name(), spacecraftParameters.getDragArea(), Units.M2, false);
generator.writeEntry(SpacecraftParametersKey.DRAG_COEFF.name(), spacecraftParameters.getDragCoeff(), Unit.ONE, false);
}
......
......@@ -58,12 +58,12 @@ public class StateVectorWriter extends AbstractWriter {
final TimeStampedPVCoordinates pv = stateVector.toTimeStampedPVCoordinates();
generator.writeComments(stateVector.getComments());
generator.writeEntry(StateVectorKey.EPOCH.name(), timeConverter, pv.getDate(), true);
generator.writeEntry(StateVectorKey.X.name(), Unit.KILOMETRE.fromSI(pv.getPosition().getX()), true);
generator.writeEntry(StateVectorKey.Y.name(), Unit.KILOMETRE.fromSI(pv.getPosition().getY()), true);
generator.writeEntry(StateVectorKey.Z.name(), Unit.KILOMETRE.fromSI(pv.getPosition().getZ()), true);
generator.writeEntry(StateVectorKey.X_DOT.name(), Unit.KILOMETRE.fromSI(pv.getVelocity().getX()), true);
generator.writeEntry(StateVectorKey.Y_DOT.name(), Unit.KILOMETRE.fromSI(pv.getVelocity().getY()), true);
generator.writeEntry(StateVectorKey.Z_DOT.name(), Unit.KILOMETRE.fromSI(pv.getVelocity().getZ()), true);
generator.writeEntry(StateVectorKey.X.name(), pv.getPosition().getX(), Unit.KILOMETRE, true);
generator.writeEntry(StateVectorKey.Y.name(), pv.getPosition().getY(), Unit.KILOMETRE, true);
generator.writeEntry(StateVectorKey.Z.name(), pv.getPosition().getZ(), Unit.KILOMETRE, true);
generator.writeEntry(StateVectorKey.X_DOT.name(), pv.getVelocity().getX(), Unit.KILOMETRE, true);
generator.writeEntry(StateVectorKey.Y_DOT.name(), pv.getVelocity().getY(), Unit.KILOMETRE, true);
generator.writeEntry(StateVectorKey.Z_DOT.name(), pv.getVelocity().getZ(), Unit.KILOMETRE, true);
// note that OPM format does not use X_DDOT, Y_DDOT, Z_DDOT, they are used only in OEM format
}
......
......@@ -24,6 +24,7 @@ import org.hipparchus.linear.RealMatrix;
import org.orekit.files.ccsds.definitions.TimeConverter;
import org.orekit.files.ccsds.definitions.Units;
import org.orekit.files.ccsds.section.AbstractWriter;
import org.orekit.files.ccsds.utils.FileFormat;
import org.orekit.files.ccsds.utils.generation.Generator;
import org.orekit.utils.AccurateFormatter;
import org.orekit.utils.units.Unit;
......@@ -71,9 +72,9 @@ class CovarianceHistoryWriter extends AbstractWriter {
generator.writeEntry(CovarianceHistoryMetadataKey.COV_FRAME_EPOCH.name(), timeConverter, metadata.getCovFrameEpoch(), false);
// scaling
generator.writeEntry(CovarianceHistoryMetadataKey.COV_SCALE_MIN.name(), Unit.ONE.fromSI(metadata.getCovScaleMin()), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_SCALE_MAX.name(), Unit.ONE.fromSI(metadata.getCovScaleMax()), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_CONFIDENCE.name(), Unit.PERCENT.fromSI(metadata.getCovConfidence()), false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_SCALE_MIN.name(), metadata.getCovScaleMin(), Unit.ONE, false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_SCALE_MAX.name(), metadata.getCovScaleMax(), Unit.ONE, false);
generator.writeEntry(CovarianceHistoryMetadataKey.COV_CONFIDENCE.name(), metadata.getCovConfidence(), Unit.PERCENT, false);
// elements
generator.writeEntry(CovarianceHistoryMetadataKey.COV_TYPE.name(), metadata.getCovType(), false);
......@@ -90,8 +91,12 @@ class CovarianceHistoryWriter extends AbstractWriter {
line.append(' ');
line.append(AccurateFormatter.format(units.get(i).fromSI(units.get(j).fromSI(matrix.getEntry(i, j)))));
}
generator.writeRawData(line);
generator.newLine();
if (generator.getFormat() == FileFormat.XML) {
generator.writeEntry(OcmFile.COV_LINE, line.toString(), true);
} else {
generator.writeRawData(line);
generator.newLine();
}
}
}
......
......@@ -23,6 +23,7 @@ import java.util.List;
import org.orekit.files.ccsds.definitions.TimeConverter;
import org.orekit.files.ccsds.definitions.Units;
import org.orekit.files.ccsds.section.AbstractWriter;
import org.orekit.files.ccsds.utils.FileFormat;
import org.orekit.files.ccsds.utils.generation.Generator;
import org.orekit.utils.AccurateFormatter;
import org.orekit.utils.units.Unit;
......@@ -75,19 +76,21 @@ class ManeuverHistoryWriter extends AbstractWriter {
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_PRED_SOURCE.name(), metadata.getManPredSource(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_REF_FRAME.name(), metadata.getManReferenceFrame().getName(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.MAN_FRAME_EPOCH.name(), timeConverter, metadata.getManFrameEpoch(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.GRAV_ASSIST_NAME.name(), metadata.getGravitationalAssist().getName(), false);
if (metadata.getGravitationalAssist() != null) {
generator.writeEntry(ManeuverHistoryMetadataKey.GRAV_ASSIST_NAME.name(), metadata.getGravitationalAssist().getName(), false);
}
// duty cycle
generator.writeEntry(ManeuverHistoryMetadataKey.DC_TYPE.name(), metadata.getDcType(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_WIN_OPEN.name(), timeConverter, metadata.getDcWindowOpen(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_WIN_CLOSE.name(), timeConverter, metadata.getDcWindowClose(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_MIN_CYCLES.name(), metadata.getDcMinCycles(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_MAX_CYCLES.name(), metadata.getDcMaxCycles(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_EXEC_START.name(), timeConverter, metadata.getDcExecStart(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_EXEC_STOP.name(), timeConverter, metadata.getDcExecStop(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_REF_TIME.name(), timeConverter, metadata.getDcRefTime(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_TIME_PULSE_DURATION.name(), Unit.SECOND.fromSI(metadata.getDcTimePulseDuration()), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_TIME_PULSE_PERIOD.name(), Unit.SECOND.fromSI(metadata.getDcTimePulsePeriod()), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_TYPE.name(), metadata.getDcType(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_WIN_OPEN.name(), timeConverter, metadata.getDcWindowOpen(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_WIN_CLOSE.name(), timeConverter, metadata.getDcWindowClose(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_MIN_CYCLES.name(), metadata.getDcMinCycles(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_MAX_CYCLES.name(), metadata.getDcMaxCycles(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_EXEC_START.name(), timeConverter, metadata.getDcExecStart(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_EXEC_STOP.name(), timeConverter, metadata.getDcExecStop(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_REF_TIME.name(), timeConverter, metadata.getDcRefTime(), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_TIME_PULSE_DURATION.name(), metadata.getDcTimePulseDuration(), Unit.SECOND, false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_TIME_PULSE_PERIOD.name(), metadata.getDcTimePulsePeriod(), Unit.SECOND, false);
if (metadata.getDcRefDir() != null) {
final StringBuilder value = new StringBuilder();
value.append(AccurateFormatter.format(Unit.ONE.fromSI(metadata.getDcRefDir().getX())));
......@@ -102,15 +105,15 @@ class ManeuverHistoryWriter extends AbstractWriter {
metadata.getDcBodyFrame().toString().replace(' ', '_'),
false);
}
generator.writeEntry(ManeuverHistoryMetadataKey.DC_PA_START_ANGLE.name(), Unit.DEGREE.fromSI(metadata.getDcPhaseStartAngle()), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_PA_STOP_ANGLE.name(), Unit.DEGREE.fromSI(metadata.getDcPhaseStopAngle()), false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_PA_START_ANGLE.name(), metadata.getDcPhaseStartAngle(), Unit.DEGREE, false);
generator.writeEntry(ManeuverHistoryMetadataKey.DC_PA_STOP_ANGLE.name(), metadata.getDcPhaseStopAngle(), Unit.DEGREE, false);
// elements
final List<ManeuverFieldType> types = metadata.getManComposition();
final StringBuilder composition = new StringBuilder();
for (int i = 0; i < types.size(); ++i) {
if (i > 0) {
composition.append(' ');
composition.append(',');
}
composition.append(types.get(i).name());
}
......@@ -126,8 +129,12 @@ class ManeuverHistoryWriter extends AbstractWriter {
}
line.append(types.get(i).outputField(timeConverter, maneuver));
}
generator.writeRawData(line);
generator.newLine();
if (generator.getFormat() == FileFormat.XML) {
generator.writeEntry(OcmFile.MAN_LINE, line.toString(), true);
} else {
generator.writeRawData(line);
generator.newLine();
}
}
}
......
......@@ -42,6 +42,15 @@ public class OcmFile extends NdmFile<Header, Segment<OcmMetadata, OcmData>>
/** Key for format version. */
public static final String FORMAT_VERSION_KEY = "CCSDS_OCM_VERS";
/** Orbit line element for XML messages. */
public static final String ORB_LINE = "orbLine";
/** Covariance line element for XML messages. */
public static final String COV_LINE = "covLine";
/** Maneuver line element for XML messages. */
public static final String MAN_LINE = "manLine";
/** Gravitational coefficient to use for building Cartesian/Keplerian orbits. */
private final double mu;
......
......@@ -137,10 +137,8 @@ class OcmMetadataWriter extends AbstractWriter {
metadata.getOcmDataElements(), false);
// other times
generator.writeEntry(OcmMetadataKey.SCLK_OFFSET_AT_EPOCH.name(),
Unit.SECOND.fromSI(metadata.getSclkOffsetAtEpoch()), false);
generator.writeEntry(OcmMetadataKey.SCLK_SEC_PER_SI_SEC.name(),
Unit.SECOND.fromSI(metadata.getSclkSecPerSISec()), false);
generator.writeEntry(OcmMetadataKey.SCLK_OFFSET_AT_EPOCH.name(), metadata.getSclkOffsetAtEpoch(), Unit.SECOND, false);
generator.writeEntry(OcmMetadataKey.SCLK_SEC_PER_SI_SEC.name(), metadata.getSclkSecPerSISec(), Unit.SECOND, false);
generator.writeEntry(OcmMetadataKey.PREVIOUS_MESSAGE_EPOCH.name(), timeConverter,
metadata.getPreviousMessageEpoch(), false);
generator.writeEntry(OcmMetadataKey.NEXT_MESSAGE_EPOCH.name(), timeConverter,
......@@ -149,12 +147,9 @@ class OcmMetadataWriter extends AbstractWriter {
metadata.getStartTime(), false);
generator.writeEntry(OcmMetadataKey.STOP_TIME.name(), timeConverter,
metadata.getStopTime(), false);
generator.writeEntry(OcmMetadataKey.TIME_SPAN.name(),
Unit.DAY.fromSI(metadata.getTimeSpan()), false);
generator.writeEntry(OcmMetadataKey.TAIMUTC_AT_TZERO.name(),
Unit.SECOND.fromSI(metadata.getTaimutcT0()), false);
generator.writeEntry(OcmMetadataKey.UT1MUTC_AT_TZERO.name(),
Unit.SECOND.fromSI(metadata.getUt1mutcT0()), false);
generator.writeEntry(OcmMetadataKey.TIME_SPAN.name(), metadata.getTimeSpan(), Unit.DAY, false);
generator.writeEntry(OcmMetadataKey.TAIMUTC_AT_TZERO.name(), metadata.getTaimutcT0(), Unit.SECOND, false);
generator.writeEntry(OcmMetadataKey.UT1MUTC_AT_TZERO.name(), metadata.getUt1mutcT0(), Unit.SECOND, false);
// data sources
generator.writeEntry(OcmMetadataKey.EOP_SOURCE.name(),
......
......@@ -63,12 +63,6 @@ import org.orekit.utils.units.Unit;
*/
public class OcmParser extends CommonParser<OcmFile, OcmParser> implements EphemerisFileParser<OcmFile> {
/** Orbit line element for XML messages. */
private static final String ORB_LINE = "orbLine";
/** User-defined element. */
private static final String USER_DEFINED = "USER_DEFINED";
/** Pattern for splitting strings at blanks. */
private static final Pattern SPLIT_AT_BLANKS = Pattern.compile("\\s+");
......@@ -147,7 +141,7 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
final Map<String, XmlTokenBuilder> builders = super.getSpecialXmlElementsBuilders();
// special handling of user-defined parameters
builders.put(USER_DEFINED, new UserDefinedXmlTokenBuilder());
builders.put(UserDefined.USER_DEFINED_XML_TAG, new UserDefinedXmlTokenBuilder());
return builders;
......@@ -280,6 +274,7 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
currentOrbitStateHistory = new ArrayList<>();
setFallback(this::processOrbitStateToken);
} else {
setFallback(structureProcessor);
if (currentOrbitStateHistoryMetadata.getCenter().getBody() != null) {
setMuCreated(currentOrbitStateHistoryMetadata.getCenter().getBody().getGM());
}
......@@ -304,6 +299,8 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
physicBlock = new PhysicalProperties(metadata.getEpochT0());
}
setFallback(this::processPhysicalPropertyToken);
} else {
setFallback(structureProcessor);
}
return true;
}
......@@ -323,6 +320,7 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
currentCovarianceHistory = new ArrayList<>();
setFallback(this::processCovarianceToken);
} else {
setFallback(structureProcessor);
covarianceBlocks.add(new CovarianceHistory(currentCovarianceHistoryMetadata,
currentCovarianceHistory));
currentCovarianceHistoryMetadata = null;
......@@ -346,6 +344,7 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
currentManeuverHistory = new ArrayList<>();
setFallback(this::processManeuverToken);
} else {
setFallback(structureProcessor);
maneuverBlocks.add(new ManeuverHistory(currentManeuverHistoryMetadata,
currentManeuverHistory));
currentManeuverHistoryMetadata = null;
......@@ -366,6 +365,8 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
perturbationsBlock = new Perturbations(context.getDataContext().getCelestialBodies());
}
setFallback(this::processPerturbationToken);
} else {
setFallback(structureProcessor);
}
return true;
}
......@@ -382,6 +383,8 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
orbitDeterminationBlock = new OrbitDetermination();
}
setFallback(this::processOrbitDeterminationToken);
} else {
setFallback(structureProcessor);
}
return true;
}
......@@ -463,7 +466,7 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
* @return true if token was processed, false otherwise
*/
private boolean processOrbitStateToken(final ParseToken token) {
if (token.getName() != null && !token.getName().equals(ORB_LINE)) {
if (token.getName() != null && !token.getName().equals(OcmFile.ORB_LINE)) {
// we are in the section metadata part
try {
return OrbitStateHistoryMetadataKey.valueOf(token.getName()).
......@@ -523,7 +526,7 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
* @return true if token was processed, false otherwise
*/
private boolean processCovarianceToken(final ParseToken token) {
if (token.getName() != null) {
if (token.getName() != null && !token.getName().equals(OcmFile.COV_LINE)) {
// we are in the section metadata part
try {
return CovarianceHistoryMetadataKey.valueOf(token.getName()).
......@@ -539,6 +542,9 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
currentCovarianceHistoryMetadata.checkMandatoryEntries();
setFallback(this::processDataSubStructureToken);
}
if (token.getType() == TokenType.START || token.getType() == TokenType.STOP) {
return true;
}
try {
final String[] fields = SPLIT_AT_BLANKS.split(token.getRawContent().trim());
final int n = currentCovarianceHistoryMetadata.getCovUnits().size();
......@@ -562,7 +568,7 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
* @return true if token was processed, false otherwise
*/
private boolean processManeuverToken(final ParseToken token) {
if (token.getName() != null) {
if (token.getName() != null && !token.getName().equals(OcmFile.MAN_LINE)) {
// we are in the section metadata part
try {
return ManeuverHistoryMetadataKey.valueOf(token.getName()).
......@@ -578,6 +584,9 @@ public class OcmParser extends CommonParser<OcmFile, OcmParser> implements Ephem
currentManeuverHistoryMetadata.checkMandatoryEntries();
setFallback(this::processDataSubStructureToken);
}
if (token.getType() == TokenType.START || token.getType() == TokenType.STOP) {
return true;
}
try {
final String[] fields = SPLIT_AT_BLANKS.split(token.getRawContent().trim());
final List<ManeuverFieldType> types = currentManeuverHistoryMetadata.getManComposition();
......
......@@ -57,30 +57,38 @@ class OrbitDeterminationWriter extends AbstractWriter {
// identifiers
generator.writeEntry(OrbitDeterminationKey.OD_ID.name(), od.getId(), false);
generator.writeEntry(OrbitDeterminationKey.OD_PREV_ID.name(), od.getPrevId(), false);
generator.writeEntry(OrbitDeterminationKey.OD_METHOD.name(), od.getMethod().getName(), false);
if (od.getMethod() != null) {
final StringBuilder builder = new StringBuilder();
builder.append(od.getMethod().getName());
if (od.getMethod().getTool() != null) {
builder.append(':');
builder.append(od.getMethod().getTool());
}
generator.writeEntry(OrbitDeterminationKey.OD_METHOD.name(), builder.toString(), false);