Documentation
¶
Overview ¶
Package xtce implements the XML Telemetric and Command Exchange format, version 1.2, as published by the OMG and described by CCSDS 660.1-G-2.
XTCE is the odd one out in this library. Every other package moves bytes to or from a spacecraft. XTCE moves no bytes at all: it is the mission database, the file that says what the bytes mean. A ground system loads one to learn a mission's parameters, how they are encoded, and which packets carry them.
So there is no Encode here, and that is a decision rather than an omission. This package reads mission databases; writing them is a different job, done by database editors, and adding a writer would mean committing to a round-trip fidelity this package does not need.
What loading gives you ¶
db, err := xtce.LoadFile("mission.xml") // parse
err = db.Validate() // check the references resolve
param, err := db.FindParameter("/Root/Sub/Voltage")
Validate is separate from Load on purpose. A database being edited often has references that do not resolve yet, and a loader that refused to parse those would be useless during authoring. Load tells you the file is well-formed XTCE; Validate tells you it is coherent.
No XSD validation ¶
The Go standard library has no XSD validator, and this package takes no dependencies. So "validation" here means semantic checks written in Go: references resolve, inheritance does not loop, names do not collide. A file that violates the XSD in a way these checks do not cover will load. If you need real schema validation, run xmllint over the file first.
Security ¶
Go's encoding/xml does not fetch DTDs and does not expand external entities, so the classic XML attacks — XXE, entity expansion bombs, network callbacks from a document — do not apply. What remains is plain resource abuse: a very large file, or one nested very deeply. MaxDocumentSize and MaxDepth bound both, and the depth check runs as a token scan before any decoding, so deep input is refused rather than recursed into.
Extracting packets ¶
The point of a mission database is decoding real packets with it, which is what Layout and Extract do:
layout, err := db.LayoutOf("/Sat/Housekeeping")
packet, err := layout.Extract(octets)
temp, ok := packet.Get("Temp")
A Layout is a container flattened into the fields a packet of that shape carries, with inheritance worked through and a bit offset and width settled for each. It depends only on the database, so it is built once per packet type and reused.
When you do not know what a packet is, Match searches: it follows each container whose RestrictionCriteria the packet satisfies and takes the deepest one that fits. See docs/guides/xtce.md.
Index ¶
- Constants
- Variables
- type AbsoluteTimeParameterType
- type AggregateParameterType
- type Argument
- type ArgumentAssignment
- type ArgumentAssignmentList
- type ArgumentList
- type ArrayParameterType
- type BaseContainer
- type BaseMetaCommand
- type BinaryDataEncoding
- type BinaryParameterType
- type BlockMetaCommand
- type BooleanParameterType
- type Calibrator
- type CommandMetaData
- type Comparison
- type ComparisonList
- type ContainerRef
- type ContainerSet
- type DataEncoding
- type Entry
- type EntryKind
- type EntryList
- type EnumeratedParameterType
- type Enumeration
- type EnumerationList
- type Field
- type FixedInteger
- type FloatDataEncoding
- type FloatParameterType
- type Header
- type IntegerDataEncoding
- type IntegerParameterType
- type IntegerValue
- type Layout
- type LocationInContainer
- type MatchCriteria
- type MetaCommand
- type MetaCommandRef
- type MetaCommandSet
- type Packet
- type Parameter
- type ParameterSet
- type ParameterType
- type ParameterTypeSet
- type PolynomialCalibrator
- type RawXML
- type ReferenceTime
- type RelativeTimeParameterType
- type Repeat
- type RestrictionCriteria
- type SequenceContainer
- type SpaceSystem
- func (s *SpaceSystem) Containers() []*SequenceContainer
- func (s *SpaceSystem) FindContainer(qualifiedName string) (*SequenceContainer, error)
- func (s *SpaceSystem) FindParameter(qualifiedName string) (*Parameter, error)
- func (s *SpaceSystem) FindParameterType(qualifiedName string) (ParameterType, error)
- func (s *SpaceSystem) FindSpaceSystem(qualifiedName string) (*SpaceSystem, error)
- func (s *SpaceSystem) Humanize() string
- func (s *SpaceSystem) LayoutOf(qualifiedName string) (*Layout, error)
- func (s *SpaceSystem) Match(root *SequenceContainer, packet []byte) (*Packet, error)
- func (s *SpaceSystem) MatchFrom(root *SequenceContainer, packet []byte) (*SequenceContainer, error)
- func (s *SpaceSystem) MetaCommands() []*MetaCommand
- func (s *SpaceSystem) ParameterTypes() []ParameterType
- func (s *SpaceSystem) Parameters() []*Parameter
- func (s *SpaceSystem) Parent() *SpaceSystem
- func (s *SpaceSystem) QualifiedName() string
- func (s *SpaceSystem) ResolveContainer(ref string) (*SequenceContainer, error)
- func (s *SpaceSystem) ResolveParameter(ref string) (*Parameter, error)
- func (s *SpaceSystem) ResolveParameterType(ref string) (ParameterType, error)
- func (s *SpaceSystem) Root() *SpaceSystem
- func (s *SpaceSystem) Validate() error
- func (s *SpaceSystem) Walk(fn func(*SpaceSystem) bool)
- type SplineCalibrator
- type SplinePoint
- type StringDataEncoding
- type StringParameterType
- type StringSize
- type TelemetryMetaData
- type Term
- type TimeEncoding
- type Unit
- type UnitSet
- type ValidationError
- type ValidationErrors
- type Value
Constants ¶
const MaxDepth = 100
MaxDepth is the deepest element nesting Load will accept.
SpaceSystem contains SpaceSystem, so the decoder recurses as it descends and a file nested thousands deep would exhaust the stack before any of this package's code ran. The check therefore happens before decoding, by counting depth over the token stream. Real databases nest a handful of levels.
const MaxDocumentSize = 64 << 20
MaxDocumentSize is the largest document Load will read, 64 MiB.
XTCE sets no limit — a mission database is as big as the mission — so this is a resource bound, not a conformance rule. Real databases run to a few megabytes; 64 MiB leaves room for the large ones while keeping a hostile file from being read into memory unbounded. LoadWithLimit overrides it.
const Namespace = "http://www.omg.org/spec/XTCE/20180204"
Namespace is the XTCE 1.2 target namespace, from the schema's targetNamespace attribute.
The date in the URI is the schema's publication, not a version of its own: this URI is what version 1.2 uses.
Variables ¶
var ( // ErrNotSpaceSystem indicates a document whose root element is not an XTCE // SpaceSystem in the 1.2 namespace. ErrNotSpaceSystem = errors.New("root element is not an XTCE 1.2 SpaceSystem") // ErrInputTooLarge indicates a document larger than the configured limit. // The limit is not in the standard: XTCE puts no ceiling on a file, so a // cap is what stops one hostile document exhausting memory. ErrInputTooLarge = errors.New("XTCE document exceeds the maximum size this loader accepts") // ErrTooDeep indicates element nesting beyond the configured depth. The // SpaceSystem tree is recursive, so an adversarial file can nest deeply // enough to exhaust the stack during decoding. ErrTooDeep = errors.New("XTCE document nests deeper than this loader accepts") // ErrMalformedXML indicates a document that is not well-formed XML. ErrMalformedXML = errors.New("malformed XML") // ErrInvalidValue indicates a document that is well-formed XML with the // right root, but which spells a value in a way its schema type cannot // hold — a FixedValue that is not a number, say. It is distinct from // ErrNotSpaceSystem so a bad value in the middle of a real database is not // misreported as the wrong kind of document. ErrInvalidValue = errors.New("XTCE document has a value that cannot be read as its schema type") // ErrInvalidEncoding indicates a data encoding attribute — encoding, // bitOrder or byteOrder — whose value is not one of the schema's legal // enumeration members. ErrInvalidEncoding = errors.New("data encoding attribute is not a legal value") // ErrUnresolvedReference indicates a name reference that names nothing. ErrUnresolvedReference = errors.New("name reference does not resolve") // ErrContainerCycle indicates a BaseContainer chain that leads back to // itself, which would make container inheritance infinite. ErrContainerCycle = errors.New("container inheritance forms a cycle") // ErrDuplicateName indicates two things with the same name in one set of // one SpaceSystem, which the schema's uniqueness keys forbid. ErrDuplicateName = errors.New("duplicate name within a SpaceSystem") // ErrInvalidReference indicates a name reference whose text does not match // the NameReferenceType pattern. ErrInvalidReference = errors.New("malformed name reference") // ErrNotFound indicates a lookup that found nothing. ErrNotFound = errors.New("not found") // ErrDynamicSize indicates a field whose position or width depends on the // contents of the packet rather than on the database alone, which a layout // built ahead of any packet cannot settle. ErrDynamicSize = errors.New("the field's size or position depends on the packet contents") // ErrUnsupportedEntry indicates an entry this package can parse but cannot // place in a layout. ErrUnsupportedEntry = errors.New("entry cannot be placed in a layout") // ErrUnsupportedEncoding indicates a data encoding this package can parse // but cannot decode a value from. ErrUnsupportedEncoding = errors.New("data encoding is not supported") // ErrPacketTooShort indicates a packet that ends before a field the layout // says it carries. ErrPacketTooShort = errors.New("packet is too short for the container layout") // ErrUnsupportedCalibrator indicates a calibrator this package can parse // but cannot evaluate. ErrUnsupportedCalibrator = errors.New("calibrator is not supported") // ErrNoMatch indicates a packet that satisfies no container's restriction // criteria. It is a normal thing for a ground station to see. ErrNoMatch = errors.New("no container matches the packet") // ErrUnsupportedCriteria indicates restriction criteria this package can // parse but cannot evaluate against a single packet. ErrUnsupportedCriteria = errors.New("restriction criteria are not supported") // ErrInvalidComparison indicates a Comparison whose value attribute cannot // be read as the parameter's type. ErrInvalidComparison = errors.New("comparison value cannot be parsed") )
Sentinel errors returned when loading, resolving and validating a mission database.
Functions ¶
This section is empty.
Types ¶
type AbsoluteTimeParameterType ¶
type AbsoluteTimeParameterType struct {
Name string `xml:"name,attr"`
ShortDescription string `xml:"shortDescription,attr"`
BaseType string `xml:"baseType,attr"`
InitialValue string `xml:"initialValue,attr"`
LongDescription string `xml:"http://www.omg.org/spec/XTCE/20180204 LongDescription"`
// Encoding wraps the data encoding with the scaling that turns a raw count
// into a time.
Encoding_ *TimeEncoding `xml:"http://www.omg.org/spec/XTCE/20180204 Encoding"`
// ReferenceTime says what the count is measured from.
ReferenceTime *ReferenceTime `xml:"http://www.omg.org/spec/XTCE/20180204 ReferenceTime"`
}
AbsoluteTimeParameterType is a point in time.
It does not extend BaseDataType like the others: the schema gives it its own base, where the encoding sits inside an Encoding element that adds units, a scale and an offset. So a spacecraft clock reading is described as "this many bits, in these units, counted from this epoch" — which is what pkg/tcf's CUC and CDS codes need to turn it into a time.
func (*AbsoluteTimeParameterType) Encoding ¶
func (t *AbsoluteTimeParameterType) Encoding() *DataEncoding
Encoding returns the wrapped data encoding, or nil when the type does not say how the time is written.
func (*AbsoluteTimeParameterType) TypeKind ¶
func (t *AbsoluteTimeParameterType) TypeKind() string
TypeKind names the kind.
func (*AbsoluteTimeParameterType) TypeName ¶
func (t *AbsoluteTimeParameterType) TypeName() string
TypeName returns the type's name.
type AggregateParameterType ¶
type AggregateParameterType struct {
Name string `xml:"name,attr"`
ShortDescription string `xml:"shortDescription,attr"`
// Raw holds the member list, undecoded.
Raw []byte `xml:",innerxml"`
}
AggregateParameterType is a struct of members. Kept opaque the same way as ArrayParameterType.
func (*AggregateParameterType) Encoding ¶
func (t *AggregateParameterType) Encoding() *DataEncoding
Encoding returns nil: an opaque type does not say how it is written.
func (*AggregateParameterType) TypeKind ¶
func (t *AggregateParameterType) TypeKind() string
TypeKind names the kind, marking that only the identity is modeled.
func (*AggregateParameterType) TypeName ¶
func (t *AggregateParameterType) TypeName() string
TypeName returns the type's name.
type Argument ¶
type Argument struct {
Name string `xml:"name,attr"`
ShortDescription string `xml:"shortDescription,attr"`
ArgumentTypeRef string `xml:"argumentTypeRef,attr"`
InitialValue string `xml:"initialValue,attr"`
}
Argument is one command argument.
type ArgumentAssignment ¶
type ArgumentAssignment struct {
Name string `xml:"argumentName,attr"`
Value string `xml:"argumentValue,attr"`
}
ArgumentAssignment fixes one argument of the base command to a value.
type ArgumentAssignmentList ¶
type ArgumentAssignmentList struct {
Assignments []ArgumentAssignment `xml:"http://www.omg.org/spec/XTCE/20180204 ArgumentAssignment"`
}
ArgumentAssignmentList is the set of argument values a derived command fixes.
type ArgumentList ¶
type ArgumentList struct {
Arguments []*Argument `xml:"http://www.omg.org/spec/XTCE/20180204 Argument"`
}
ArgumentList is a command's arguments, in order.
type ArrayParameterType ¶
type ArrayParameterType struct {
Name string `xml:"name,attr"`
ShortDescription string `xml:"shortDescription,attr"`
// ArrayTypeRef names the element type.
ArrayTypeRef string `xml:"arrayTypeRef,attr"`
// Raw holds the type's contents — the dimension list — undecoded.
Raw []byte `xml:",innerxml"`
}
ArrayParameterType is an array of another type. It is kept opaque: the name is decoded so references to it resolve, the contents stay raw, and it has no encoding — so Layout refuses a parameter of this type rather than guessing at its width.
func (*ArrayParameterType) Encoding ¶
func (t *ArrayParameterType) Encoding() *DataEncoding
Encoding returns nil: an opaque type does not say how it is written.
func (*ArrayParameterType) TypeKind ¶
func (t *ArrayParameterType) TypeKind() string
TypeKind names the kind, marking that only the identity is modeled.
func (*ArrayParameterType) TypeName ¶
func (t *ArrayParameterType) TypeName() string
TypeName returns the type's name.
type BaseContainer ¶
type BaseContainer struct {
ContainerRef string `xml:"containerRef,attr"`
// RestrictionCriteria says which values of the base's parameters select
// this container. It is what makes container inheritance more than a way
// of sharing a header: it is the test a packet has to pass for this
// container to be the right reading of it.
RestrictionCriteria *RestrictionCriteria `xml:"http://www.omg.org/spec/XTCE/20180204 RestrictionCriteria"`
}
BaseContainer points at the container being extended.
type BaseMetaCommand ¶
type BaseMetaCommand struct {
MetaCommandRef string `xml:"metaCommandRef,attr"`
// ArgumentAssignmentList fixes some of the base command's arguments to
// specific values, which is how a general command is narrowed into a
// specific one. Dropping it would make the derived command look identical
// to its base.
ArgumentAssignmentList *ArgumentAssignmentList `xml:"http://www.omg.org/spec/XTCE/20180204 ArgumentAssignmentList"`
}
BaseMetaCommand points at the command being extended.
type BinaryDataEncoding ¶
type BinaryDataEncoding struct {
// SizeInBits is required by the schema and may be dynamic.
SizeInBits *IntegerValue `xml:"http://www.omg.org/spec/XTCE/20180204 SizeInBits"`
// contains filtered or unexported fields
}
BinaryDataEncoding writes raw octets.
func (BinaryDataEncoding) BitOrderOrDefault ¶
func (c BinaryDataEncoding) BitOrderOrDefault() string
BitOrderOrDefault applies the schema's default.
func (BinaryDataEncoding) ByteOrderOrDefault ¶
func (c BinaryDataEncoding) ByteOrderOrDefault() string
ByteOrderOrDefault applies the schema's default.
type BinaryParameterType ¶
type BinaryParameterType struct {
// InitialValue is hex.
InitialValue string `xml:"initialValue,attr"`
// contains filtered or unexported fields
}
BinaryParameterType is a run of raw octets.
func (*BinaryParameterType) Encoding ¶
func (b *BinaryParameterType) Encoding() *DataEncoding
Encoding returns whichever data encoding the type carries.
func (*BinaryParameterType) TypeKind ¶
func (t *BinaryParameterType) TypeKind() string
TypeKind names the kind.
type BlockMetaCommand ¶
type BlockMetaCommand struct {
Name string `xml:"name,attr"`
ShortDescription string `xml:"shortDescription,attr"`
LongDescription string `xml:"http://www.omg.org/spec/XTCE/20180204 LongDescription"`
// MetaCommandStepList holds the block's steps, raw.
MetaCommandStepList *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 MetaCommandStepList"`
}
BlockMetaCommand is an ordered grouping of commands sent as one.
Only the identity is modeled. The step list — which commands, with which argument values — is kept raw, so a caller who needs it can parse it and a later version can model it without changing what Load accepts.
type BooleanParameterType ¶
type BooleanParameterType struct {
InitialValue string `xml:"initialValue,attr"`
// OneStringValue defaults to "True" and ZeroStringValue to "False"; read
// them through the OrDefault accessors.
OneStringValue string `xml:"oneStringValue,attr"`
ZeroStringValue string `xml:"zeroStringValue,attr"`
// contains filtered or unexported fields
}
BooleanParameterType is a flag, with the words to print for each state.
func (*BooleanParameterType) Encoding ¶
func (b *BooleanParameterType) Encoding() *DataEncoding
Encoding returns whichever data encoding the type carries.
func (*BooleanParameterType) OneStringValueOrDefault ¶
func (t *BooleanParameterType) OneStringValueOrDefault() string
OneStringValueOrDefault returns the word for the true state, applying the schema's default of "True".
func (*BooleanParameterType) TypeKind ¶
func (t *BooleanParameterType) TypeKind() string
TypeKind names the kind.
func (*BooleanParameterType) TypeName ¶
func (b *BooleanParameterType) TypeName() string
TypeName returns the type's name.
func (*BooleanParameterType) ZeroStringValueOrDefault ¶
func (t *BooleanParameterType) ZeroStringValueOrDefault() string
ZeroStringValueOrDefault returns the word for the false state, applying the schema's default of "False".
type Calibrator ¶
type Calibrator struct {
Name string `xml:"name,attr"`
Polynomial *PolynomialCalibrator `xml:"http://www.omg.org/spec/XTCE/20180204 PolynomialCalibrator"`
Spline *SplineCalibrator `xml:"http://www.omg.org/spec/XTCE/20180204 SplineCalibrator"`
// MathOperation is the third form. It is out of scope — evaluating an
// expression tree is a different job — so it is kept raw and Kind reports
// it so a caller is not misled into thinking the type has no calibrator.
MathOperation *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 MathOperationCalibrator"`
}
Calibrator turns a raw value into an engineering one.
type CommandMetaData ¶
type CommandMetaData struct {
ParameterTypeSet *ParameterTypeSet `xml:"http://www.omg.org/spec/XTCE/20180204 ParameterTypeSet"`
ParameterSet *ParameterSet `xml:"http://www.omg.org/spec/XTCE/20180204 ParameterSet"`
MetaCommandSet *MetaCommandSet `xml:"http://www.omg.org/spec/XTCE/20180204 MetaCommandSet"`
}
CommandMetaData holds everything about the uplink.
Only the skeleton is modeled: commands and their argument names. Command containers, verifiers, constraints and significance are not.
type Comparison ¶
type Comparison struct {
// ParameterRef names the parameter to test.
ParameterRef string `xml:"parameterRef,attr"`
// Value is what to test it against, as text.
Value string `xml:"value,attr"`
// ComparisonOperator is one of ==, !=, <, <=, > and >=. It defaults to ==.
ComparisonOperator string `xml:"comparisonOperator,attr"`
// UseCalibratedValue compares against the engineering value rather than
// the raw one. The schema's default is true, so it is a pointer: false has
// to be distinguishable from absent.
UseCalibratedValue *bool `xml:"useCalibratedValue,attr"`
// Instance selects an earlier or later occurrence of the parameter in the
// stream. It defaults to 0, meaning this packet's value.
Instance int64 `xml:"instance,attr"`
}
Comparison tests one parameter against a value.
The value is written as text whatever the parameter's type, and the schema says how to read it: a number is base ten unless it starts with 0x, 0o or 0b, an enumeration is compared by its label, and a binary value is hex.
func (*Comparison) Calibrated ¶
func (c *Comparison) Calibrated() bool
Calibrated reports whether the comparison is against the engineering value, applying the schema's default of true.
func (*Comparison) Operator ¶
func (c *Comparison) Operator() string
Operator returns the comparison operator, applying the schema's default.
type ComparisonList ¶
type ComparisonList struct {
Comparisons []Comparison `xml:"http://www.omg.org/spec/XTCE/20180204 Comparison"`
}
ComparisonList is a set of comparisons that must all hold. The schema calls the "and" between them implicit.
type ContainerRef ¶
type ContainerRef struct {
ContainerRef string `xml:"containerRef,attr"`
}
ContainerRef names a container.
type ContainerSet ¶
type ContainerSet struct {
SequenceContainers []*SequenceContainer `xml:"http://www.omg.org/spec/XTCE/20180204 SequenceContainer"`
}
ContainerSet is the list of containers a SpaceSystem defines.
type DataEncoding ¶
type DataEncoding struct {
Integer *IntegerDataEncoding
Float *FloatDataEncoding
String *StringDataEncoding
Binary *BinaryDataEncoding
}
DataEncoding is whichever of the four encodings a type carries. Exactly one field is set.
func (*DataEncoding) HasContextCalibrators ¶
func (d *DataEncoding) HasContextCalibrators() bool
HasContextCalibrators reports whether the encoding carries a ContextCalibratorList — calibration that depends on another parameter's value, which this package keeps raw. When it is true, the default calibrator alone may be the wrong curve for a given packet, so a consumer computing engineering values should not trust the default blindly.
func (*DataEncoding) SizeInBits ¶
func (d *DataEncoding) SizeInBits() (uint, bool)
SizeInBits returns the encoded width in bits and whether it is known.
It is not always known. A string may be delimited rather than fixed, and a binary encoding may take its size from another parameter. Those cases return false rather than a guess.
type Entry ¶
type Entry struct {
Kind EntryKind
// ElementName is the XML element this entry came from, which matters for
// the kinds folded into EntryOther.
ElementName string
// Ref is the parameterRef or containerRef, whichever this entry carries.
Ref string
// ShortDescription is the entry's own description, not the referent's.
ShortDescription string
// LocationInContainerInBits places the entry when it does not simply
// follow the previous one.
LocationInContainerInBits *LocationInContainer
// RepeatEntry repeats it.
RepeatEntry *Repeat
// IncludeCondition makes it conditional. Kept raw, like
// RestrictionCriteria. Evaluating it is the caller's job.
IncludeCondition *RawXML
}
Entry is one element of an EntryList.
The schema makes EntryList a choice repeated without limit, so the entries are of mixed kinds in a meaningful order — the order they appear in the packet. Go's encoding/xml cannot preserve order across separate struct fields, so EntryList decodes itself and keeps one ordered slice. That is why this type exists rather than a struct per entry kind.
type EntryKind ¶
type EntryKind int
EntryKind says which kind of entry an Entry is.
const ( // EntryParameterRef names a parameter. EntryParameterRef EntryKind = iota // EntryContainerRef names another container, whose entries are spliced in // at this position. EntryContainerRef // EntryOther is an entry kind this package parses but does not model: // ParameterSegmentRefEntry, ContainerSegmentRefEntry, StreamSegmentEntry, // IndirectParameterRefEntry, ArrayParameterRefEntry. EntryOther )
type EntryList ¶
type EntryList struct {
Entries []Entry
}
EntryList is a container's entries, in packet order.
func (*EntryList) UnmarshalXML ¶
UnmarshalXML decodes an EntryList, keeping the entries in document order.
This is hand-written because encoding/xml cannot do it. Given a struct with one slice field per element name, the decoder fills each slice with the elements of that name and the interleaving is lost — and for a packet layout the interleaving is the whole point. So the tokens are walked directly and everything lands in one slice.
type EnumeratedParameterType ¶
type EnumeratedParameterType struct {
InitialValue string `xml:"initialValue,attr"`
// EnumerationList is required by the schema.
EnumerationList EnumerationList `xml:"http://www.omg.org/spec/XTCE/20180204 EnumerationList"`
// contains filtered or unexported fields
}
EnumeratedParameterType maps raw values to labels.
func (*EnumeratedParameterType) Encoding ¶
func (b *EnumeratedParameterType) Encoding() *DataEncoding
Encoding returns whichever data encoding the type carries.
func (*EnumeratedParameterType) TypeKind ¶
func (t *EnumeratedParameterType) TypeKind() string
TypeKind names the kind.
type Enumeration ¶
type Enumeration struct {
Value int64 `xml:"value,attr"`
MaxValue *int64 `xml:"maxValue,attr"`
Label string `xml:"label,attr"`
ShortDescription string `xml:"shortDescription,attr"`
}
Enumeration is one label. MaxValue, when present, makes it a range rather than a single value.
type EnumerationList ¶
type EnumerationList struct {
Enumerations []Enumeration `xml:"http://www.omg.org/spec/XTCE/20180204 Enumeration"`
}
EnumerationList holds the value-to-label mapping.
type Field ¶
type Field struct {
// Name is the parameter's qualified name, so two fields from different
// SpaceSystems are distinguishable.
Name string
// Parameter and Type are what the entry resolved to.
Parameter *Parameter
Type ParameterType
// BitOffset is where the field starts, counted from the first bit of the
// packet. BitSize is how wide it is.
BitOffset uint
BitSize uint
// Container is the container whose EntryList this entry came from, which
// for an inherited field is the base rather than the container asked for.
Container *SequenceContainer
// Entry is the entry itself, for a caller that needs the parts the layout
// does not act on — an IncludeCondition, say.
Entry Entry
}
Field is one parameter at a known place in a packet.
type FixedInteger ¶
type FixedInteger int64
FixedInteger is the schema's FixedIntegerValueType: a union of a decimal integer with the hex, octal and binary spellings, so 18, 0x12, 0o22 and 0b10010 all mean the same number.
It exists because encoding/xml reads an int64 field with strconv in base ten, which makes a legal 0x2A reject the entire document. Every field fed by the union uses this type instead.
func (FixedInteger) Int64 ¶
func (f FixedInteger) Int64() int64
Int64 returns the value as a plain integer.
func (*FixedInteger) UnmarshalXML ¶
func (f *FixedInteger) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML reads the union's element form, <FixedValue>0x2A</FixedValue>.
func (*FixedInteger) UnmarshalXMLAttr ¶
func (f *FixedInteger) UnmarshalXMLAttr(attr xml.Attr) error
UnmarshalXMLAttr reads the union's attribute form.
type FloatDataEncoding ¶
type FloatDataEncoding struct {
// Encoding defaults to IEEE754_1985. The alternatives are MILSTD_1750A and
// the two decimal forms.
Encoding string `xml:"encoding,attr"`
// SizeInBits defaults to 32. The schema allows 16, 32, 40, 48, 64, 80 and
// 128.
SizeInBits uint `xml:"sizeInBits,attr"`
// ChangeThreshold is the smallest change in value that is significant.
// Absent or zero means any change is.
ChangeThreshold *float64 `xml:"changeThreshold,attr"`
DefaultCalibrator *Calibrator `xml:"http://www.omg.org/spec/XTCE/20180204 DefaultCalibrator"`
// ContextCalibratorList is kept raw, the same way as on
// IntegerDataEncoding.
ContextCalibratorList *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 ContextCalibratorList"`
// contains filtered or unexported fields
}
FloatDataEncoding writes a real number.
func (FloatDataEncoding) BitOrderOrDefault ¶
func (c FloatDataEncoding) BitOrderOrDefault() string
BitOrderOrDefault applies the schema's default.
func (FloatDataEncoding) ByteOrderOrDefault ¶
func (c FloatDataEncoding) ByteOrderOrDefault() string
ByteOrderOrDefault applies the schema's default.
func (*FloatDataEncoding) EncodingOrDefault ¶
func (e *FloatDataEncoding) EncodingOrDefault() string
EncodingOrDefault applies the schema's default.
func (*FloatDataEncoding) Size ¶
func (e *FloatDataEncoding) Size() uint
Size applies the schema's default of 32 bits.
type FloatParameterType ¶
type FloatParameterType struct {
// SizeInBits is 32 or 64, defaulting to 32.
SizeInBits uint `xml:"sizeInBits,attr"`
InitialValue string `xml:"initialValue,attr"`
// contains filtered or unexported fields
}
FloatParameterType is a real-number parameter.
func (*FloatParameterType) Encoding ¶
func (b *FloatParameterType) Encoding() *DataEncoding
Encoding returns whichever data encoding the type carries.
func (*FloatParameterType) Size ¶
func (t *FloatParameterType) Size() uint
Size returns the value's width in bits, applying the schema's default of 32. The encoding's width on the wire is the encoding's own Size.
func (*FloatParameterType) TypeKind ¶
func (t *FloatParameterType) TypeKind() string
TypeKind names the kind.
type Header ¶
type Header struct {
Version string `xml:"version,attr"`
Date string `xml:"date,attr"`
Classification string `xml:"classification,attr"`
Validation string `xml:"validationStatus,attr"`
}
Header is the HeaderType of the schema: who produced this database and when.
type IntegerDataEncoding ¶
type IntegerDataEncoding struct {
// Encoding is unsigned, signMagnitude, twosComplement, onesComplement, BCD
// or packedBCD. It defaults to unsigned.
Encoding string `xml:"encoding,attr"`
// SizeInBits defaults to 8.
SizeInBits uint `xml:"sizeInBits,attr"`
// ChangeThreshold is the smallest change in value that is significant.
// Absent or zero means any change is. It is a pointer so an explicit zero
// is distinguishable from absent.
ChangeThreshold *uint64 `xml:"changeThreshold,attr"`
DefaultCalibrator *Calibrator `xml:"http://www.omg.org/spec/XTCE/20180204 DefaultCalibrator"`
// ContextCalibratorList is calibration that depends on another
// parameter's value. It is kept raw, and its presence matters: when it is
// set, the default calibrator alone may be the wrong curve for a given
// packet. HasContextCalibrators on DataEncoding reports it.
ContextCalibratorList *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 ContextCalibratorList"`
// contains filtered or unexported fields
}
IntegerDataEncoding writes a number as a field of bits.
func (IntegerDataEncoding) BitOrderOrDefault ¶
func (c IntegerDataEncoding) BitOrderOrDefault() string
BitOrderOrDefault applies the schema's default.
func (IntegerDataEncoding) ByteOrderOrDefault ¶
func (c IntegerDataEncoding) ByteOrderOrDefault() string
ByteOrderOrDefault applies the schema's default.
func (*IntegerDataEncoding) EncodingOrDefault ¶
func (e *IntegerDataEncoding) EncodingOrDefault() string
EncodingOrDefault applies the schema's default of unsigned.
func (*IntegerDataEncoding) Size ¶
func (e *IntegerDataEncoding) Size() uint
Size applies the schema's default of 8 bits.
type IntegerParameterType ¶
type IntegerParameterType struct {
// SizeInBits is the value's width, defaulting to 32. This is the width of
// the value, which is not necessarily the width on the wire: the encoding
// has its own sizeInBits.
SizeInBits uint `xml:"sizeInBits,attr"`
// Signed defaults to true. It is a pointer because false has to be
// distinguishable from absent.
Signed *bool `xml:"signed,attr"`
InitialValue string `xml:"initialValue,attr"`
// contains filtered or unexported fields
}
IntegerParameterType is a whole-number parameter.
func (*IntegerParameterType) Encoding ¶
func (b *IntegerParameterType) Encoding() *DataEncoding
Encoding returns whichever data encoding the type carries.
func (*IntegerParameterType) IsSigned ¶
func (t *IntegerParameterType) IsSigned() bool
IsSigned reports the signedness, applying the schema's default of true.
func (*IntegerParameterType) Size ¶
func (t *IntegerParameterType) Size() uint
Size returns the value's width in bits, applying the schema's default of 32. This is the width of the value, not the width on the wire — the encoding has its own Size.
func (*IntegerParameterType) TypeKind ¶
func (t *IntegerParameterType) TypeKind() string
TypeKind names the kind.
type IntegerValue ¶
type IntegerValue struct {
FixedValue *FixedInteger `xml:"http://www.omg.org/spec/XTCE/20180204 FixedValue"`
DynamicValue *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 DynamicValue"`
DiscreteLookupList *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 DiscreteLookupList"`
}
IntegerValue is the schema's IntegerValueType: a number that may be fixed, read from another parameter, or looked up.
type Layout ¶
type Layout struct {
// Container is the container this layout was built from.
Container *SequenceContainer
// Fields are in packet order, which is not always offset order: an entry
// placed with LocationInContainerInBits can point backwards.
Fields []Field
// BitSize is the offset just past the furthest field, which is the
// smallest packet this layout can be read from. A packet may be longer;
// XTCE containers do not have to cover every bit.
BitSize uint
}
Layout is a container flattened into the fields a packet of that shape carries, in packet order.
func (*Layout) Extract ¶
Extract reads a packet against this layout.
It returns an error only when the packet is too short for the layout to apply at all. A field that cannot be decoded on its own — an encoding this package does not support, a BCD nibble that is not a digit — is reported in that field's Err and the rest of the packet is still read.
type LocationInContainer ¶
type LocationInContainer struct {
// ReferenceLocation is one of containerStart, containerEnd, previousEntry
// or nextEntry. It defaults to previousEntry; read it through
// ReferenceLocationOrDefault.
ReferenceLocation string `xml:"referenceLocation,attr"`
// FixedValue is the offset in bits when it is a constant, which is the
// usual case.
FixedValue *FixedInteger `xml:"http://www.omg.org/spec/XTCE/20180204 FixedValue"`
// DynamicValue and DiscreteLookupList are the non-constant forms, kept raw.
DynamicValue *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 DynamicValue"`
DiscreteLookupList *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 DiscreteLookupList"`
}
LocationInContainer positions an entry within its container.
func (*LocationInContainer) ReferenceLocationOrDefault ¶
func (l *LocationInContainer) ReferenceLocationOrDefault() string
ReferenceLocationOrDefault returns the anchor the offset is measured from, applying the schema's default of previousEntry.
type MatchCriteria ¶
type MatchCriteria struct {
Comparison *Comparison `xml:"http://www.omg.org/spec/XTCE/20180204 Comparison"`
ComparisonList *ComparisonList `xml:"http://www.omg.org/spec/XTCE/20180204 ComparisonList"`
BooleanExpression *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 BooleanExpression"`
CustomAlgorithm *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 CustomAlgorithm"`
}
MatchCriteria is a condition over parameter values: one comparison, a list of them that must all hold, an arbitrary boolean expression, or an escape to an external algorithm.
The schema makes these a choice, so exactly one is set. The last two are kept raw. A BooleanExpression is a tree of ANDs and ORs that would need its own evaluator, and a CustomAlgorithm is by definition outside the file.
type MetaCommand ¶
type MetaCommand struct {
Name string `xml:"name,attr"`
ShortDescription string `xml:"shortDescription,attr"`
Abstract bool `xml:"abstract,attr"`
LongDescription string `xml:"http://www.omg.org/spec/XTCE/20180204 LongDescription"`
BaseMetaCommand *BaseMetaCommand `xml:"http://www.omg.org/spec/XTCE/20180204 BaseMetaCommand"`
ArgumentList *ArgumentList `xml:"http://www.omg.org/spec/XTCE/20180204 ArgumentList"`
}
MetaCommand is one command, modeled as a skeleton: its name, what it extends, and its argument names and types.
Everything that makes a command safe to send — verifiers, transmission constraints, significance, the command container's bit layout — is out of scope here and is not parsed into the model.
type MetaCommandRef ¶
type MetaCommandRef struct {
Ref string `xml:",chardata"`
}
MetaCommandRef includes a command defined in another SpaceSystem. The schema types the element as a NameReferenceType, so the reference is the element's text.
type MetaCommandSet ¶
type MetaCommandSet struct {
MetaCommands []*MetaCommand `xml:"http://www.omg.org/spec/XTCE/20180204 MetaCommand"`
// MetaCommandRefs are commands included by reference from another
// SpaceSystem. The reference is kept but not resolved.
MetaCommandRefs []*MetaCommandRef `xml:"http://www.omg.org/spec/XTCE/20180204 MetaCommandRef"`
// BlockMetaCommands are ordered groupings of commands. The name is
// modeled; the steps are kept raw.
BlockMetaCommands []*BlockMetaCommand `xml:"http://www.omg.org/spec/XTCE/20180204 BlockMetaCommand"`
}
MetaCommandSet is the list of commands a SpaceSystem defines.
The schema makes it a choice of three element kinds. MetaCommand is the definition; MetaCommandRef includes a command defined elsewhere; and BlockMetaCommand groups several commands into one. All three are kept, so none of a mission's commands vanishes from the model silently.
type Packet ¶
type Packet struct {
// Layout is the container the packet was read against.
Layout *Layout
// Values are in packet order, one per field, including the ones that
// failed.
Values []Value
}
Packet is everything read out of one packet.
func (*Packet) Err ¶
Err returns the first field-level error, or nil when every field decoded.
Extract itself only fails when nothing could be read at all, so this is how a caller who wants all-or-nothing gets it.
type Parameter ¶
type Parameter struct {
Name string `xml:"name,attr"`
ShortDescription string `xml:"shortDescription,attr"`
// ParameterTypeRef names the type, as a NameReference.
ParameterTypeRef string `xml:"parameterTypeRef,attr"`
InitialValue string `xml:"initialValue,attr"`
LongDescription string `xml:"http://www.omg.org/spec/XTCE/20180204 LongDescription"`
}
Parameter is one named piece of telemetry or command data.
A Parameter says almost nothing itself. Its shape lives in the parameter type it points at, which is why an unresolvable ParameterTypeRef makes the parameter meaningless and Validate treats it as an error.
type ParameterSet ¶
type ParameterSet struct {
Parameters []*Parameter `xml:"http://www.omg.org/spec/XTCE/20180204 Parameter"`
}
ParameterSet is the list of parameters a SpaceSystem defines.
type ParameterType ¶
type ParameterType interface {
// TypeName is the type's name, which parameters reference.
TypeName() string
// TypeKind names the kind for display: "integer", "float" and so on.
TypeKind() string
// Encoding returns how the value is written in the packet, or nil when the
// type does not say.
Encoding() *DataEncoding
}
ParameterType is what every modeled parameter type has in common.
type ParameterTypeSet ¶
type ParameterTypeSet struct {
IntegerTypes []*IntegerParameterType `xml:"http://www.omg.org/spec/XTCE/20180204 IntegerParameterType"`
FloatTypes []*FloatParameterType `xml:"http://www.omg.org/spec/XTCE/20180204 FloatParameterType"`
EnumeratedTypes []*EnumeratedParameterType `xml:"http://www.omg.org/spec/XTCE/20180204 EnumeratedParameterType"`
StringTypes []*StringParameterType `xml:"http://www.omg.org/spec/XTCE/20180204 StringParameterType"`
BinaryTypes []*BinaryParameterType `xml:"http://www.omg.org/spec/XTCE/20180204 BinaryParameterType"`
BooleanTypes []*BooleanParameterType `xml:"http://www.omg.org/spec/XTCE/20180204 BooleanParameterType"`
AbsoluteTimeTypes []*AbsoluteTimeParameterType `xml:"http://www.omg.org/spec/XTCE/20180204 AbsoluteTimeParameterType"`
ArrayTypes []*ArrayParameterType `xml:"http://www.omg.org/spec/XTCE/20180204 ArrayParameterType"`
AggregateTypes []*AggregateParameterType `xml:"http://www.omg.org/spec/XTCE/20180204 AggregateParameterType"`
RelativeTimeTypes []*RelativeTimeParameterType `xml:"http://www.omg.org/spec/XTCE/20180204 RelativeTimeParameterType"`
}
ParameterTypeSet holds the parameter types a SpaceSystem defines.
The schema makes this an unordered choice of ten element kinds. Seven are modeled in full. ArrayParameterType, AggregateParameterType and RelativeTimeParameterType are kept opaque: their names are decoded so a parameter pointing at one still resolves and TypeKind says what it found, but their contents stay raw and Layout refuses a parameter of such a type. The coverage matrix records this.
func (*ParameterTypeSet) All ¶
func (p *ParameterTypeSet) All() []ParameterType
All returns every parameter type in the set, whatever its kind, in a stable order: integers, floats, enumerations, strings, binaries, booleans, times, then the opaque kinds — arrays, aggregates, relative times.
The order is this package's, not the document's. The schema makes ParameterTypeSet a Set, so document order carries no meaning, and a stable order makes Humanize output comparable between runs.
func (*ParameterTypeSet) Len ¶
func (p *ParameterTypeSet) Len() int
Len reports how many parameter types the set holds.
type PolynomialCalibrator ¶
type PolynomialCalibrator struct {
Terms []Term `xml:"http://www.omg.org/spec/XTCE/20180204 Term"`
}
PolynomialCalibrator is a sum of terms: coefficient times raw to the power of exponent.
func (*PolynomialCalibrator) Apply ¶
func (p *PolynomialCalibrator) Apply(raw float64) float64
Apply evaluates the polynomial at raw.
The terms are a sum of coefficient times raw to the power of exponent, and the schema does not require them in any order or without gaps, so each is evaluated on its own rather than by Horner's method.
type RawXML ¶
type RawXML struct {
Inner []byte `xml:",innerxml"`
}
RawXML holds an element this package parses but does not model.
Keeping the bytes rather than dropping them means a later version can model the element without changing what Load accepts, and a caller who needs it today can parse it themselves.
type ReferenceTime ¶
type ReferenceTime struct {
// Epoch is a date, a dateTime, or one of the schema's named epochs —
// TAI, J2000, UNIX, GPS.
Epoch string `xml:"http://www.omg.org/spec/XTCE/20180204 Epoch"`
// OffsetFrom names another time parameter to count from. Kept raw.
OffsetFrom *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 OffsetFrom"`
}
ReferenceTime says what an absolute time is measured from: a named epoch, or another parameter's value.
type RelativeTimeParameterType ¶
type RelativeTimeParameterType struct {
Name string `xml:"name,attr"`
ShortDescription string `xml:"shortDescription,attr"`
// Raw holds the type's contents, undecoded.
Raw []byte `xml:",innerxml"`
}
RelativeTimeParameterType is a duration rather than an instant. Kept opaque the same way as ArrayParameterType.
func (*RelativeTimeParameterType) Encoding ¶
func (t *RelativeTimeParameterType) Encoding() *DataEncoding
Encoding returns nil: an opaque type does not say how it is written.
func (*RelativeTimeParameterType) TypeKind ¶
func (t *RelativeTimeParameterType) TypeKind() string
TypeKind names the kind, marking that only the identity is modeled.
func (*RelativeTimeParameterType) TypeName ¶
func (t *RelativeTimeParameterType) TypeName() string
TypeName returns the type's name.
type Repeat ¶
type Repeat struct {
Count *IntegerValue `xml:"http://www.omg.org/spec/XTCE/20180204 Count"`
Offset *IntegerValue `xml:"http://www.omg.org/spec/XTCE/20180204 Offset"`
}
Repeat repeats an entry a number of times.
type RestrictionCriteria ¶
type RestrictionCriteria struct {
MatchCriteria
// NextContainer names a container that must follow this one. Deciding it
// needs the stream rather than the packet, so Match does not evaluate it.
NextContainer *ContainerRef `xml:"http://www.omg.org/spec/XTCE/20180204 NextContainer"`
}
RestrictionCriteria is the schema's RestrictionCriteriaType: a MatchCriteria, plus the option of naming the container that must follow this one in the stream.
type SequenceContainer ¶
type SequenceContainer struct {
Name string `xml:"name,attr"`
ShortDescription string `xml:"shortDescription,attr"`
// Abstract marks a container that is only ever inherited from, never
// matched against a packet on its own.
Abstract bool `xml:"abstract,attr"`
// IdlePattern fills unused space, written as a FixedIntegerValue.
IdlePattern string `xml:"idlePattern,attr"`
LongDescription string `xml:"http://www.omg.org/spec/XTCE/20180204 LongDescription"`
// EntryList is ordered, and the order is the wire order.
EntryList EntryList `xml:"http://www.omg.org/spec/XTCE/20180204 EntryList"`
// BaseContainer names the container this one extends.
BaseContainer *BaseContainer `xml:"http://www.omg.org/spec/XTCE/20180204 BaseContainer"`
// contains filtered or unexported fields
}
SequenceContainer describes a packet layout: an ordered list of entries, each naming a parameter or another container.
Containers inherit. A container names a BaseContainer, and its own entries follow the base's — which is how a mission describes "a CCSDS packet" once and then twenty packet types that extend it.
func (*SequenceContainer) Layout ¶
func (c *SequenceContainer) Layout() (*Layout, error)
Layout flattens a container into the fields a packet of that shape carries.
Every field must have a width the database states outright. A delimited string, a binary field sized by another parameter, or a repeat count read from the packet all make the layout depend on the packet's contents, and this returns ErrDynamicSize rather than guessing. See docs/guides/xtce.md.
func (*SequenceContainer) Owner ¶
func (c *SequenceContainer) Owner() *SpaceSystem
Owner returns the SpaceSystem that defines this container, or nil for one that did not come from Load.
type SpaceSystem ¶
type SpaceSystem struct {
XMLName xml.Name `xml:"http://www.omg.org/spec/XTCE/20180204 SpaceSystem"`
// Name identifies this system among its siblings.
Name string `xml:"name,attr"`
// ShortDescription is a one-line summary.
ShortDescription string `xml:"shortDescription,attr"`
// OperationalStatus is a mission-defined token.
OperationalStatus string `xml:"operationalStatus,attr"`
// LongDescription is free text.
LongDescription string `xml:"http://www.omg.org/spec/XTCE/20180204 LongDescription"`
// Header carries versioning and authorship.
Header *Header `xml:"http://www.omg.org/spec/XTCE/20180204 Header"`
// TelemetryMetaData describes what comes down.
TelemetryMetaData *TelemetryMetaData `xml:"http://www.omg.org/spec/XTCE/20180204 TelemetryMetaData"`
// CommandMetaData describes what goes up.
CommandMetaData *CommandMetaData `xml:"http://www.omg.org/spec/XTCE/20180204 CommandMetaData"`
// SubSystems are the nested SpaceSystems.
SubSystems []*SpaceSystem `xml:"http://www.omg.org/spec/XTCE/20180204 SpaceSystem"`
// contains filtered or unexported fields
}
SpaceSystem is the root of a mission database and also its only recursive element: a SpaceSystem contains SpaceSystems.
The tree is a namespace. A parameter's full name is the path of system names down to it, so /Spacecraft/Power/BusVoltage names BusVoltage inside Power inside Spacecraft.
func Load ¶
func Load(r io.Reader) (*SpaceSystem, error)
Load reads a mission database from r.
It parses and checks the shape of the document: well-formed XML, an XTCE 1.2 SpaceSystem at the root, within the size and depth limits. It does not check that references resolve — call Validate for that. The two are separate because a database under construction usually has references that do not resolve yet, and refusing to read those would make the loader useless during authoring.
func LoadFile ¶
func LoadFile(path string) (*SpaceSystem, error)
LoadFile reads a mission database from a file.
func LoadWithLimit ¶
func LoadWithLimit(r io.Reader, maxSize int64) (*SpaceSystem, error)
LoadWithLimit is Load with a different size cap, in octets.
func (*SpaceSystem) Containers ¶
func (s *SpaceSystem) Containers() []*SequenceContainer
Containers returns this SpaceSystem's containers.
func (*SpaceSystem) FindContainer ¶
func (s *SpaceSystem) FindContainer(qualifiedName string) (*SequenceContainer, error)
FindContainer looks up a container by its qualified name.
func (*SpaceSystem) FindParameter ¶
func (s *SpaceSystem) FindParameter(qualifiedName string) (*Parameter, error)
FindParameter looks up a parameter by its qualified name, from the root of the tree.
This is the entry point for a caller who has a name out of a display page or a configuration file. Unlike ResolveParameter it does not search ancestors: a qualified name says exactly where the parameter is.
func (*SpaceSystem) FindParameterType ¶
func (s *SpaceSystem) FindParameterType(qualifiedName string) (ParameterType, error)
FindParameterType looks up a parameter type by its qualified name.
func (*SpaceSystem) FindSpaceSystem ¶
func (s *SpaceSystem) FindSpaceSystem(qualifiedName string) (*SpaceSystem, error)
FindSpaceSystem looks up a SpaceSystem by its qualified name.
func (*SpaceSystem) Humanize ¶
func (s *SpaceSystem) Humanize() string
Humanize renders the database as an indented tree.
The shape is one block per SpaceSystem: a count line, then the parameters with their types and encoded widths, then the containers with their entries in packet order. It is meant to be read next to the XML when working out why a database does not say what someone thought it said.
func (*SpaceSystem) LayoutOf ¶
func (s *SpaceSystem) LayoutOf(qualifiedName string) (*Layout, error)
LayoutOf flattens the named container.
func (*SpaceSystem) Match ¶
func (s *SpaceSystem) Match(root *SequenceContainer, packet []byte) (*Packet, error)
Match finds the container in this SpaceSystem tree that a packet satisfies, and extracts it.
The search starts at root, follows each derived container whose criteria the packet meets, and goes as deep as it can. The deepest match wins: a packet that satisfies both "is a telemetry packet" and "is a housekeeping telemetry packet" is the latter.
A container only matches if the packet is long enough to hold it, so a truncated packet does not match the type it was on its way to being.
It returns ErrNoMatch when nothing matches, which is a normal thing to happen to a ground station and not necessarily a fault.
func (*SpaceSystem) MatchFrom ¶
func (s *SpaceSystem) MatchFrom(root *SequenceContainer, packet []byte) (*SequenceContainer, error)
MatchFrom returns the container a packet matches, without extracting it.
Use it when the answer you want is "what is this packet", or to hold on to the layout yourself.
func (*SpaceSystem) MetaCommands ¶
func (s *SpaceSystem) MetaCommands() []*MetaCommand
MetaCommands returns this SpaceSystem's commands.
func (*SpaceSystem) ParameterTypes ¶
func (s *SpaceSystem) ParameterTypes() []ParameterType
ParameterTypes returns this SpaceSystem's parameter types.
func (*SpaceSystem) Parameters ¶
func (s *SpaceSystem) Parameters() []*Parameter
Parameters returns this SpaceSystem's parameters, telemetry side then command side.
func (*SpaceSystem) Parent ¶
func (s *SpaceSystem) Parent() *SpaceSystem
Parent returns the enclosing SpaceSystem, or nil at the root.
func (*SpaceSystem) QualifiedName ¶
func (s *SpaceSystem) QualifiedName() string
QualifiedName is the absolute path of this SpaceSystem, starting with a slash.
func (*SpaceSystem) ResolveContainer ¶
func (s *SpaceSystem) ResolveContainer(ref string) (*SequenceContainer, error)
ResolveContainer follows a container reference written in this SpaceSystem.
func (*SpaceSystem) ResolveParameter ¶
func (s *SpaceSystem) ResolveParameter(ref string) (*Parameter, error)
ResolveParameter follows a parameter reference written in this SpaceSystem.
func (*SpaceSystem) ResolveParameterType ¶
func (s *SpaceSystem) ResolveParameterType(ref string) (ParameterType, error)
ResolveParameterType follows a parameter-type reference written in this SpaceSystem.
func (*SpaceSystem) Root ¶
func (s *SpaceSystem) Root() *SpaceSystem
Root walks up to the top of the tree.
func (*SpaceSystem) Validate ¶
func (s *SpaceSystem) Validate() error
Validate checks that a database hangs together.
It returns ValidationErrors, so errors.Is finds any sentinel among them and a type assertion gets the whole list.
func (*SpaceSystem) Walk ¶
func (s *SpaceSystem) Walk(fn func(*SpaceSystem) bool)
Walk visits this SpaceSystem and every system below it, depth first. Return false from fn to stop the walk.
type SplineCalibrator ¶
type SplineCalibrator struct {
// Order defaults to 1, meaning straight lines between points.
Order uint `xml:"order,attr"`
// Extrapolate says whether values outside the points are calibrated by
// extending the end segments.
Extrapolate bool `xml:"extrapolate,attr"`
// Points must number at least two, per the schema.
Points []SplinePoint `xml:"http://www.omg.org/spec/XTCE/20180204 SplinePoint"`
}
SplineCalibrator interpolates between measured points.
func (*SplineCalibrator) Apply ¶
func (s *SplineCalibrator) Apply(raw float64) (float64, error)
Apply interpolates between the spline's points.
Order 1 is a straight line between neighbouring points, which is what a calibration curve measured at a handful of temperatures looks like. Higher orders are in the schema but the schema does not say which spline they mean, and guessing at a curve would put wrong numbers in front of an operator.
type SplinePoint ¶
type SplinePoint struct {
Raw float64 `xml:"raw,attr"`
Calibrated float64 `xml:"calibrated,attr"`
Order uint `xml:"order,attr"`
}
SplinePoint is one measured pair.
type StringDataEncoding ¶
type StringDataEncoding struct {
// Encoding defaults to UTF-8.
Encoding string `xml:"encoding,attr"`
SizeInBits *StringSize `xml:"http://www.omg.org/spec/XTCE/20180204 SizeInBits"`
// Variable is the delimited form, kept raw.
Variable *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 Variable"`
// contains filtered or unexported fields
}
StringDataEncoding writes text. Its size is either fixed or delimited.
func (StringDataEncoding) BitOrderOrDefault ¶
func (c StringDataEncoding) BitOrderOrDefault() string
BitOrderOrDefault applies the schema's default.
func (StringDataEncoding) ByteOrderOrDefault ¶
func (c StringDataEncoding) ByteOrderOrDefault() string
ByteOrderOrDefault applies the schema's default.
func (*StringDataEncoding) EncodingOrDefault ¶
func (e *StringDataEncoding) EncodingOrDefault() string
EncodingOrDefault applies the schema's default of UTF-8.
type StringParameterType ¶
type StringParameterType struct {
InitialValue string `xml:"initialValue,attr"`
RestrictionPattern string `xml:"restrictionPattern,attr"`
CharacterWidth string `xml:"characterWidth,attr"`
// contains filtered or unexported fields
}
StringParameterType is a text parameter.
func (*StringParameterType) Encoding ¶
func (b *StringParameterType) Encoding() *DataEncoding
Encoding returns whichever data encoding the type carries.
func (*StringParameterType) TypeKind ¶
func (t *StringParameterType) TypeKind() string
TypeKind names the kind.
type StringSize ¶
type StringSize struct {
Fixed *FixedInteger `xml:"http://www.omg.org/spec/XTCE/20180204 Fixed>FixedValue"`
// TerminationChar and LeadingSize are the other forms the schema allows.
TerminationChar string `xml:"http://www.omg.org/spec/XTCE/20180204 TerminationChar"`
LeadingSize *RawXML `xml:"http://www.omg.org/spec/XTCE/20180204 LeadingSize"`
}
StringSize is a string's fixed width.
type TelemetryMetaData ¶
type TelemetryMetaData struct {
ParameterTypeSet *ParameterTypeSet `xml:"http://www.omg.org/spec/XTCE/20180204 ParameterTypeSet"`
ParameterSet *ParameterSet `xml:"http://www.omg.org/spec/XTCE/20180204 ParameterSet"`
ContainerSet *ContainerSet `xml:"http://www.omg.org/spec/XTCE/20180204 ContainerSet"`
}
TelemetryMetaData holds everything about the downlink.
The schema also allows MessageSet, StreamSet and AlgorithmSet here. This package does not model them; see docs/pics/xtce-coverage.md.
type Term ¶
type Term struct {
Coefficient float64 `xml:"coefficient,attr"`
Exponent uint `xml:"exponent,attr"`
}
Term is one term of a polynomial.
type TimeEncoding ¶
type TimeEncoding struct {
// Units defaults to "seconds"; read it through UnitsOrDefault.
Units string `xml:"units,attr"`
// Scale defaults to 1 and Offset to 0. Both are pointers so that an
// explicit zero is distinguishable from absent.
Scale *float64 `xml:"scale,attr"`
Offset *float64 `xml:"offset,attr"`
IntegerDataEncoding *IntegerDataEncoding `xml:"http://www.omg.org/spec/XTCE/20180204 IntegerDataEncoding"`
FloatDataEncoding *FloatDataEncoding `xml:"http://www.omg.org/spec/XTCE/20180204 FloatDataEncoding"`
StringDataEncoding *StringDataEncoding `xml:"http://www.omg.org/spec/XTCE/20180204 StringDataEncoding"`
BinaryDataEncoding *BinaryDataEncoding `xml:"http://www.omg.org/spec/XTCE/20180204 BinaryDataEncoding"`
}
TimeEncoding is the schema's EncodingType: a data encoding plus the units, scale and offset that turn the raw count into a time.
func (*TimeEncoding) DataEncoding ¶
func (e *TimeEncoding) DataEncoding() *DataEncoding
DataEncoding returns whichever encoding the element carries.
func (*TimeEncoding) OffsetOrDefault ¶
func (e *TimeEncoding) OffsetOrDefault() float64
OffsetOrDefault returns the offset, applying the schema's default of 0.
func (*TimeEncoding) ScaleOrDefault ¶
func (e *TimeEncoding) ScaleOrDefault() float64
ScaleOrDefault returns the scale, applying the schema's default of 1.
func (*TimeEncoding) UnitsOrDefault ¶
func (e *TimeEncoding) UnitsOrDefault() string
UnitsOrDefault returns what one count of the encoding means, applying the schema's default of "seconds".
type Unit ¶
type Unit struct {
// Power defaults to 1. It is a pointer so an absent power is not read as
// zero, which would say the unit does not appear at all; read it through
// PowerOrDefault.
Power *float64 `xml:"power,attr"`
Factor string `xml:"factor,attr"`
Description string `xml:"description,attr"`
Value string `xml:",chardata"`
}
Unit is one unit, with an optional power and factor.
func (*Unit) PowerOrDefault ¶
PowerOrDefault returns the unit's exponent, applying the schema's default of 1.
type UnitSet ¶
type UnitSet struct {
Units []Unit `xml:"http://www.omg.org/spec/XTCE/20180204 Unit"`
}
UnitSet lists the units a value is in.
type ValidationError ¶
type ValidationError struct {
// SpaceSystem is the qualified name of the system holding the problem.
SpaceSystem string
// Element names what was wrong, such as "Parameter" or "ContainerRefEntry".
Element string
// Detail is the specific complaint.
Detail string
// Err is the sentinel, for errors.Is.
Err error
}
ValidationError is one problem found in a database, with enough context to find it in the file.
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
Unwrap exposes the sentinel.
type ValidationErrors ¶
type ValidationErrors []*ValidationError
ValidationErrors is every problem found in one pass.
Validation collects rather than stopping at the first problem, because someone fixing a database wants the whole list, not one line at a time.
func (ValidationErrors) Error ¶
func (e ValidationErrors) Error() string
Error summarises the problems.
func (ValidationErrors) Is ¶
func (e ValidationErrors) Is(target error) bool
Is reports whether any problem matches the target, so errors.Is finds a sentinel anywhere in the list.
type Value ¶
type Value struct {
// Field is where this came from: the name, the parameter, the type, and
// the position in the packet.
Field Field
// Raw is the value exactly as the packet carried it, before calibration.
// It is a uint64, an int64, a float64, a string or a []byte, depending on
// the data encoding.
Raw any
// Engineering is the value after calibration and after the parameter type
// has had its say: a float64 for a calibrated number, a string for an
// enumeration label or a boolean's word, and whatever Raw held for the
// types that have no further meaning to apply.
Engineering any
// Err is set when this one field could not be decoded, and the other two
// are then meaningless. Extract keeps going past a bad field so that one
// unsupported encoding in the middle of a packet does not hide everything
// after it.
Err error
}
Value is one parameter read out of a packet.