- Introduction
- Getting Started
- Systems and Subsystems
- Parameters
- Encodings
- Containers: Telemetry Packets
- Calibrators
- Alarms
- Commands
- Command Verification
- Algorithms
- Expressions
- CCSDS and CSP Headers
- Structuring Large Models
- Generating XTCE
Appendices
Generating XTCE¶
Once the tree is built, each top-level system exports itself with
dump() (to a file-like object) or dumps() (to a string):
with open("mysat.xml", "wt") as f:
satellite.dump(f)
xml = satellite.dumps()
Every top-level system produces one XTCE file; a model with a spacecraft system and a GSE system is exported as two files.
Export options¶
Both methods accept the same keyword-only options:
format"xtce-1.2"(the default, natively supported by Yamcs) or"xtce-1.3".indentIndentation string per level, default two spaces. Use
""for the most compact output.top_commentThe XML comment inserted at the top of the file. By default this is a notice that the file is generated; pass a string to customize it, or
Falseto omit it.skip_parameters,skip_containers,skip_commands,skip_algorithms,skip_subsystemsLeave the corresponding sections out of the export. Useful for partial exports, e.g. producing a telemetry-only file.
If the model contains something that cannot be represented in the chosen
format, the export raises ExportError with a message naming the
offending item. Since generation walks the entire tree, running the export
is also the quickest overall sanity check of a model.
Loading into Yamcs¶
Reference the generated file(s) from the mdb section of the Yamcs
instance configuration:
mdb:
- type: xtce
args:
file: mdb/mysat.xml
- type: xtce
args:
file: mdb/gse.xml
Yamcs reads the file at startup: after regenerating, restart Yamcs (or the instance) to pick up the changes.
Validation checks¶
The yamcs.pymdb.checks module offers read-only sanity checks to run
over a finished model, before or alongside the export. Each function
walks the full tree, prints a line per finding, and returns True when
all is well — convenient for turning into a build failure:
from yamcs.pymdb import checks
ok = checks.check_complete_verifiers(satellite)
ok &= checks.check_float_encoding(satellite)
assert ok, "MDB validation failed"
Function |
Verifies that… |
|---|---|
|
every non-abstract command has a verifier able to complete it successfully (see Command Verification) |
|
no 32-bit float parameter/argument uses a 64-bit encoding (a common precision bug) |
|
all multi-byte integer encodings are little endian — for projects
whose hardware is uniformly little endian, this catches a
forgotten |
These checks are optional helpers, not part of the export; a model that fails them still exports fine.
Errors¶
The library raises three exception types of its own:
|
The model cannot be represented in the requested XTCE format. |
|
An object was created with a name already used by a sibling of the same kind (see Systems and Subsystems). |
|
A fixed bit size could not be determined, e.g.
|