Commit 2770917c authored by mvanel's avatar mvanel
Browse files

Finished CDM Parser - Issue 777

parent 3ac96bb2
Pipeline #1800 passed with stages
in 28 minutes and 35 seconds
......@@ -37,6 +37,45 @@ public class Units {
/** m² unit. */
public static final Unit M2 = Unit.parse("m²");
/** m⁴ unit. */
public static final Unit M4 = Unit.parse("m⁴");
/** Meters par second units. */
public static final Unit M_PER_S = Unit.parse("m/s");
/** Meters par second square units. */
public static final Unit M_PER_S2 = Unit.parse("m/s²");
/** Meters square par second units. */
public static final Unit M2_PER_S = Unit.parse("m²/s");
/** Meters square par second units. */
public static final Unit M2_PER_S2 = Unit.parse("m²/s²");
/** Meters square par second units. */
public static final Unit M2_PER_S3 = Unit.parse("m²/s³");
/** Meters square par second units. */
public static final Unit M2_PER_S4 = Unit.parse("m²/s⁴");
/** Meters par kilograms units. */
public static final Unit M2_PER_KG = Unit.parse("m²/kg");
/** Meters cubic par kilograms units. */
public static final Unit M3_PER_KG = Unit.parse("m³/kg");
/** m⁴ par kilograms units. */
public static final Unit M4_PER_KG = Unit.parse("m⁴/kg");
/** m⁴ par kilograms square units. */
public static final Unit M4_PER_KG2 = Unit.parse("m⁴/kg²");
/** Meters cubic par kilograms second units. */
public static final Unit M3_PER_KGS = Unit.parse("m³/(kg.s)");
/** Meters cubic par kilograms (second square) units. */
public static final Unit M3_PER_KGS2 = Unit.parse("m³/(kg.s²)");
/** #/year unit. */
public static final Unit NB_PER_Y = Unit.parse("#/yr");
......@@ -79,6 +118,9 @@ public class Units {
/** Hertz per second unit. */
public static final Unit HZ_PER_S = Unit.parse("Hz/s");
/** Watt par kilograms units. */
public static final Unit W_PER_KG = Unit.parse("W/kg");
/** Private constructor for a utility class.
*/
private Units() {
......
......@@ -73,6 +73,7 @@ public class NdmParser extends AbstractMessageParser<Ndm> {
builders.putAll(builder.buildOcmParser().getSpecialXmlElementsBuilders());
builders.putAll(builder.buildApmParser().getSpecialXmlElementsBuilders());
builders.putAll(builder.buildAemParser().getSpecialXmlElementsBuilders());
builders.putAll(builder.buildCdmParser().getSpecialXmlElementsBuilders());
return builders;
......@@ -156,6 +157,13 @@ public class NdmParser extends AbstractMessageParser<Ndm> {
return manageConstituent(builder::buildAemParser);
}
/** Prepare parsing of a CDM constituent.
* @return always return true
*/
boolean manageCdmConstituent() {
return manageConstituent(builder::buildCdmParser);
}
/** Prepare parsing of a constituent.
* @param parserSupplier supplier for constituent parser
* @return always return true
......
......@@ -51,7 +51,10 @@ enum NdmStructureKey {
apm((token, parser) -> parser.manageApmConstituent()),
/** AEM constituent. */
aem((token, parser) -> parser.manageAemConstituent());
aem((token, parser) -> parser.manageAemConstituent()),
/** CDM constituent. */
cdm((token, parser) -> parser.manageCdmConstituent());
/** Processing method. */
private final TokenProcessor processor;
......
......@@ -20,6 +20,7 @@ import org.orekit.annotation.DefaultDataContext;
import org.orekit.data.DataContext;
import org.orekit.files.ccsds.ndm.adm.aem.AemParser;
import org.orekit.files.ccsds.ndm.adm.apm.ApmParser;
import org.orekit.files.ccsds.ndm.cdm.CdmParser;
import org.orekit.files.ccsds.ndm.odm.ocm.OcmParser;
import org.orekit.files.ccsds.ndm.odm.oem.OemParser;
import org.orekit.files.ccsds.ndm.odm.omm.OmmParser;
......@@ -287,4 +288,12 @@ public class ParserBuilder extends AbstractBuilder<ParserBuilder> {
getParsedUnitsBehavior(), getRangeUnitsConverter());
}
/** Build a parser for {@link org.orekit.files.ccsds.ndm.cdm.Cdm Conjunction Data Messages}.
* @return a new parser
*/
public CdmParser buildCdmParser() {
return new CdmParser(getConventions(), isSimpleEOP(), getDataContext(),
getParsedUnitsBehavior());
}
}
/* Copyright 2002-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.files.ccsds.ndm.cdm;
import org.orekit.files.ccsds.section.CommentsContainer;
/**
* Container for additional parameters data block.
* @author Melina Vanel
* @since 11.2
*/
public class AdditionalParameters extends CommentsContainer {
/** The actual area of the object. */
private double areaPC;
/** The effective area of the object exposed to atmospheric drag. */
private double areaDRG;
/** The effective area of the object exposed to solar radiation pressure. */
private double areaSRP;
/** The mass of the object. */
private double mass;
/** The object’s Cd x A/m used to propagate the state vector and covariance to TCA. */
private double cdAreaOverMass;
/** The object’s Cr x A/m used to propagate the state vector and covariance to TCA. */
private double crAreaOverMass;
/** The object’s acceleration due to in-track thrust used to propagate the state vector and covariance to TCA. */
private double thrustAcceleration;
/** The amount of energy being removed from the object’s orbit by atmospheric drag. This value is an average calculated during the OD. */
private double sedr;
/** Simple constructor.
*/
public AdditionalParameters() {
areaPC = Double.NaN;
areaDRG = Double.NaN;
areaSRP = Double.NaN;
mass = Double.NaN;
cdAreaOverMass = Double.NaN;
crAreaOverMass = Double.NaN;
thrustAcceleration = Double.NaN;
sedr = Double.NaN;
}
/** {@inheritDoc} */
@Override
public void validate(final double version) {
super.validate(version);
}
/**
* Get the actual area of the object.
* @return the object area
*/
public double getAreaPC() {
return areaPC;
}
/**
* Set the actual area of the object.
* @param areaPC area value to be set
*/
public void setAreaPC(final double areaPC) {
refuseFurtherComments();
this.areaPC = areaPC;
}
/**
* Get the effective area of the object exposed to atmospheric drag.
* @return the object area exposed to atmospheric drag
*/
public double getAreaDRG() {
return areaDRG;
}
/**
* Set the effective area of the object exposed to atmospheric drag.
* @param areaDRG area value to be set
*/
public void setAreaDRG(final double areaDRG) {
refuseFurtherComments();
this.areaDRG = areaDRG;
}
/**
* Get the effective area of the object exposed to solar radiation pressure.
* @return the object area exposed to solar radiation pressure
*/
public double getAreaSRP() {
return areaSRP;
}
/**
* Set the effective area of the object exposed to solar radiation pressure.
* @param areaSRP area value to be set
*/
public void setAreaSRP(final double areaSRP) {
refuseFurtherComments();
this.areaSRP = areaSRP;
}
/**
* Get the mass of the object.
* @return the mass of the object
*/
public double getMass() {
return mass;
}
/**
* Set the mass of the object.
* @param mass mass of the object to be set
*/
public void setMass(final double mass) {
refuseFurtherComments();
this.mass = mass;
}
/**
* Get the object’s Cd x A/m used to propagate the state vector and covariance to TCA.
* @return the object’s Cd x A/m
*/
public double getCDAreaOverMass() {
return cdAreaOverMass;
}
/**
* Set the object’s Cd x A/m used to propagate the state vector and covariance to TCA.
* @param CDAreaOverMass object’s Cd x A/m value to be set
*/
public void setCDAreaOverMass(final double CDAreaOverMass) {
refuseFurtherComments();
this.cdAreaOverMass = CDAreaOverMass;
}
/**
* Get the object’s Cr x A/m used to propagate the state vector and covariance to TCA.
* @return the object’s Cr x A/m
*/
public double getCRAreaOverMass() {
return crAreaOverMass;
}
/**
* Set the object’s Cr x A/m used to propagate the state vector and covariance to TCA.
* @param CRAreaOverMass object’s Cr x A/m value to be set
*/
public void setCRAreaOverMass(final double CRAreaOverMass) {
refuseFurtherComments();
this.crAreaOverMass = CRAreaOverMass;
}
/**
* Get the object’s acceleration due to in-track thrust used to propagate the state vector and covariance to TCA.
* @return the object’s acceleration due to in-track thrust
*/
public double getThrustAcceleration() {
return thrustAcceleration;
}
/**
* Set the object’s acceleration due to in-track thrust used to propagate the state vector and covariance to TCA.
* @param thrustAcceleration object’s acceleration due to in-track thrust
*/
public void setThrustAcceleration(final double thrustAcceleration) {
refuseFurtherComments();
this.thrustAcceleration = thrustAcceleration;
}
/**
* Get the amount of energy being removed from the object’s orbit by atmospheric drag. This value is an average calculated during the OD.
* @return the amount of energy being removed from the object’s orbit by atmospheric drag
*/
public double getSEDR() {
return sedr;
}
/**
* Set the amount of energy being removed from the object’s orbit by atmospheric drag. This value is an average calculated during the OD.
* @param SEDR amount of energy being removed from the object’s orbit by atmospheric drag
*/
public void setSEDR(final double SEDR) {
refuseFurtherComments();
this.sedr = SEDR;
}
}
/* Copyright 2002-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.files.ccsds.ndm.cdm;
import org.orekit.files.ccsds.definitions.Units;
import org.orekit.files.ccsds.utils.ContextBinding;
import org.orekit.files.ccsds.utils.lexical.ParseToken;
import org.orekit.files.ccsds.utils.lexical.TokenType;
import org.orekit.utils.units.Unit;
/** Keys for {@link AdditionalParameters CDM additional parameters} entries.
* @author Melina Vanel
* @since 11.2
*/
public enum AdditionalParametersKey {
/** Comment entry. */
COMMENT((token, context, container) ->
token.getType() == TokenType.ENTRY ? container.addComment(token.getContentAsNormalizedString()) : true),
/** The actual area of the object. */
AREA_PC((token, context, container) -> token.processAsDouble(Units.M2, context.getParsedUnitsBehavior(),
container::setAreaPC)),
/** The effective area of the object exposed to atmospheric drag. */
AREA_DRG((token, context, container) -> token.processAsDouble(Units.M2, context.getParsedUnitsBehavior(),
container::setAreaDRG)),
/** The effective area of the object exposed to solar radiation pressure. */
AREA_SRP((token, context, container) -> token.processAsDouble(Units.M2, context.getParsedUnitsBehavior(),
container::setAreaDRG)),
/** The mass of the object. */
MASS((token, context, container) -> token.processAsDouble(Unit.KILOGRAM, context.getParsedUnitsBehavior(),
container::setMass)),
/** The object’s Cd x A/m used to propagate the state vector and covariance to TCA. */
CD_AREA_OVER_MASS((token, context, container) -> token.processAsDouble(Units.M2_PER_KG, context.getParsedUnitsBehavior(),
container::setCDAreaOverMass)),
/** The object’s Cr x A/m used to propagate the state vector and covariance to TCA. */
CR_AREA_OVER_MASS((token, context, container) -> token.processAsDouble(Units.M2_PER_KG, context.getParsedUnitsBehavior(),
container::setCRAreaOverMass)),
/** The object’s acceleration due to in-track thrust used to propagate the state vector and covariance to TCA. */
THRUST_ACCELERATION((token, context, container) -> token.processAsDouble(Units.M_PER_S2, context.getParsedUnitsBehavior(),
container::setThrustAcceleration)),
/** The amount of energy being removed from the object’s orbit by atmospheric drag. This value is an average calculated during the OD. */
SEDR((token, context, container) -> token.processAsDouble(Units.W_PER_KG, context.getParsedUnitsBehavior(),
container::setSEDR));
/** Processing method. */
private final TokenProcessor processor;
/** Simple constructor.
* @param processor processing method
*/
AdditionalParametersKey(final TokenProcessor processor) {
this.processor = processor;
}
/** Process one token.
* @param token token to process
* @param context context binding
* @param container container to fill
* @return true of token was accepted
*/
public boolean process(final ParseToken token, final ContextBinding context, final AdditionalParameters container) {
return processor.process(token, context, container);
}
/** Interface for processing one token. */
interface TokenProcessor {
/** Process one token.
* @param token token to process
* @param context context binding
* @param container container to fill
* @return true of token was accepted
*/
boolean process(ParseToken token, ContextBinding context, AdditionalParameters container);
}
}
/* Copyright 2002-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.files.ccsds.ndm.cdm;
import java.util.List;
import org.orekit.data.DataContext;
import org.orekit.files.ccsds.ndm.NdmConstituent;
import org.orekit.files.ccsds.section.Segment;
import org.orekit.utils.IERSConventions;
/**
* This class stores all the information of the Conjunction Data Message (CDM) File parsed
* by CdmParser. It contains the header and a list of segments each
* containing metadata and a list of data lines.
* @author Melina Vanel
* @since 11.2
*/
public class Cdm extends NdmConstituent<CdmHeader, Segment<CdmMetadata, CdmData>> {
/** Root element for XML files. */
public static final String ROOT = "cdm";
/** Key for format version. */
public static final String FORMAT_VERSION_KEY = "CCSDS_CDM_VERS";
/** Simple constructor.
* @param header file header
* @param segments file segments
* @param conventions IERS conventions
* @param dataContext used for creating frames, time scales, etc.
*/
public Cdm(final CdmHeader header, final List<Segment<CdmMetadata, CdmData>> segments,
final IERSConventions conventions, final DataContext dataContext) {
super(header, segments, conventions, dataContext);
}
/** Get the file metadata.
* @return file metadata
*/
public CdmRelativeMetadata getRelativeMetadata() {
return getSegments().get(0).getMetadata().getRelativeMetadata();
}
/** Get the file metadata.
* @return file metadata
*/
public CdmMetadata getMetadataObject1() {
return getSegments().get(0).getMetadata();
}
/** Get the file metadata.
* @return file metadata
*/
public CdmMetadata getMetadataObject2() {
return getSegments().get(1).getMetadata();
}
/** Get the file data.
* @return file data
*/
public CdmData getDataObject1() {
return getSegments().get(0).getData();
}
/** Get the file data.
* @return file data
*/
public CdmData getDataObject2() {
return getSegments().get(1).getData();
}
}
/* Copyright 2002-2022 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.files.ccsds.ndm.cdm;
import java.util.List;
import org.orekit.files.ccsds.section.CommentsContainer;
import org.orekit.files.ccsds.section.Data;
/**
* Container for Conjunction Data Message data.
* @author Melina Vanel
* @since 11.2
*/
public class CdmData implements Data {
/** General comments block. */
private final CommentsContainer commentsBlock;
/** Quaternion block. */
private final ODParameters ODparametersBlock;
/** Euler angles block. */
private final AdditionalParameters additionalParametersBlock;
/** Spin-stabilized block. */
private final StateVector stateVectorBlock;
/** Spacecraft parameters block. */
private final CovarianceMatrix covarianceMatrixBlock;
/** Simple constructor.
* @param commentsBlock general comments block
* @param ODparametersBlock OD parameters block (may be null)
* @param additionalParametersBlock additionnal parameters block (may be null)
* @param stateVectorBlock state vector block
* @param covarianceMatrixBlock covariance matrix in RTN coordinates frame block
*/
public CdmData(final CommentsContainer commentsBlock,
final ODParameters ODparametersBlock,
final AdditionalParameters additionalParametersBlock,
final StateVector stateVectorBlock,
final CovarianceMatrix covarianceMatrixBlock) {
this.commentsBlock = commentsBlock;
this.ODparametersBlock = ODparametersBlock;
this.additionalParametersBlock = additionalParametersBlock;
this.stateVectorBlock = stateVectorBlock;
this.covarianceMatrixBlock = covarianceMatrixBlock;
}
/** {@inheritDoc} */
@Override
public void validate(final double version) {
if (ODparametersBlock != null) {
ODparametersBlock.validate(version);
}
if (additionalParametersBlock != null) {
additionalParametersBlock.validate(version);
}
stateVectorBlock.validate(version);
covarianceMatrixBlock.validate(version);
}
/** Get the comments.
* @return comments
*/
public List<String> getComments() {
return commentsBlock.getComments();
}
/** Get the OD parameters logical block.
* @return OD parameters block (may be null)
*/