Parse and encode CCSDS Orbit Parameter Messages (OPM).
Supports both the KVN (Keyword=Value Notation) and XML formats per
CCSDS 502.0-B. An OPM carries a single epoch's Cartesian state plus optional
Keplerian elements, spacecraft parameters, a 6x6 covariance, a list of
maneuvers and USER_DEFINED_* parameters. Every item of CCSDS 502.0-B-3
tables 3-1 to 3-3 is kept, with the comments of each block: a KVN comment
belongs to the block of the keyword after it and is written at the start of
that block.
parse/1 auto-detects the format from the first non-whitespace character: a
leading < is treated as XML, anything else as KVN. Date/time fields are
preserved as raw strings exactly as written.
Examples
{:ok, opm} = Sidereon.CCSDS.OPM.parse(kvn_string)
opm.metadata.object_name
opm.state.position_km # {x, y, z} in km
opm.keplerian.anomaly # {:true_anomaly, deg} or {:mean_anomaly, deg}
# KVN output (default)
{:ok, kvn} = Sidereon.CCSDS.OPM.encode(opm)
# XML output
{:ok, xml} = Sidereon.CCSDS.OPM.encode(opm, format: :xml)
# Round-trip through XML
{:ok, opm2} = Sidereon.CCSDS.OPM.parse(xml)
Summary
Types
Failure reason from the OPM readers and writers, with every field the core
refusal carries (Sidereon.CCSDS.Error.opm/0): a missing or invalid field, a
malformed value, a keyword repeated with a different value, a unit that
contradicts the standard's table, a document holding several messages, a
keyword the standard does not define at its position, a KVN line that is not
blank, a comment or an assignment, text a writer cannot write so that its
reader returns it unchanged, or (writers only) fields that do not form a
message, such as a covariance without exactly 21 lower-triangle values.
A CCSDS OPM. comments are the header comments; classification and
message_id are the optional header items of table 3-1.
A Cartesian triple {x, y, z}.
Functions
Encode an OPM.
Encode an OPM to KVN text explicitly. Returns {:ok, text} or
{:error, reason}.
Encode an OPM to XML text explicitly. Returns {:ok, text} or
{:error, reason}.
Parse an OPM in either KVN or XML format.
Parse an OPM in KVN format explicitly. Skips format auto-detection.
Parse an OPM in XML format explicitly. Skips format auto-detection.
Types
@type error() :: Sidereon.CCSDS.Error.opm()
Failure reason from the OPM readers and writers, with every field the core
refusal carries (Sidereon.CCSDS.Error.opm/0): a missing or invalid field, a
malformed value, a keyword repeated with a different value, a unit that
contradicts the standard's table, a document holding several messages, a
keyword the standard does not define at its position, a KVN line that is not
blank, a comment or an assignment, text a writer cannot write so that its
reader returns it unchanged, or (writers only) fields that do not form a
message, such as a covariance without exactly 21 lower-triangle values.
@type t() :: %Sidereon.CCSDS.OPM{ ccsds_opm_vers: String.t(), classification: String.t() | nil, comments: [String.t()], covariance: Sidereon.CCSDS.OPM.Covariance.t() | nil, creation_date: String.t() | nil, keplerian: Sidereon.CCSDS.OPM.Keplerian.t() | nil, maneuvers: [Sidereon.CCSDS.OPM.Maneuver.t()], message_id: String.t() | nil, metadata: Sidereon.CCSDS.OPM.Metadata.t(), originator: String.t() | nil, spacecraft: Sidereon.CCSDS.OPM.Spacecraft.t() | nil, state: Sidereon.CCSDS.OPM.State.t(), user_defined: [Sidereon.CCSDS.OPM.UserDefined.t()], user_defined_comments: [String.t()] }
A CCSDS OPM. comments are the header comments; classification and
message_id are the optional header items of table 3-1.
A Cartesian triple {x, y, z}.
Functions
Encode an OPM.
Returns {:ok, text}, or {:error, reason} for a message the writer cannot
write so that its reader returns it unchanged (see error/0).
Options
:format-:kvn(default) or:xml
Encode an OPM to KVN text explicitly. Returns {:ok, text} or
{:error, reason}.
Encode an OPM to XML text explicitly. Returns {:ok, text} or
{:error, reason}.
Parse an OPM in either KVN or XML format.
Format is auto-detected from the first non-whitespace character: < routes to
the XML parser, anything else to the KVN parser.
Returns {:ok, %Sidereon.CCSDS.OPM{}} or {:error, reason}.
Parse an OPM in KVN format explicitly. Skips format auto-detection.
Parse an OPM in XML format explicitly. Skips format auto-detection.