-
Notifications
You must be signed in to change notification settings - Fork 0
DSDL Compound Types, Fields and Constants
The DSDL parser outputs a dictionary with CompoundTypes as values. These objects hold all information about a .uavcan file, whether it is a message, service or a stand-alone datatype.
The Compound type has the following properties:
- MessageType, ENUM, SERVICE or MESSAGE. Stand-alone datatypes are given the value MESSAGE
- SubjectId, uint, The subject ID for the message or service. Is zero for stand-alone datatypes
- Version, Tuple<int, int>, File version, extracted from the file name.
- RequestFields, List, All fields found in the request part of the file.
- ResponseFields, List, All fields found in the response part of the file.
- RequestConstants, List, All constants found in the request part of the file.
- ResponseConstants, List, All constants found in the response part of the file.
A field represents a line in a dsdl file that are not comments or dividers/@ handles. ie:
uint8 command
is a field.
Fields have two properties, a DSDL Type and a name. The DSDL type in the above example is uint8, while the name is "command"
The dsdl type defines the datatype of the given field. There are 4 types:
- PrimitiveType - This is used for primitive types: int, uint, float and bool
- VoidType - This is used for voids
- CompoundType - This is used for stand-alone datatypes, and is a full dsdl file
- ArrayTypes - This is used for arrays, and contains another dsdl type to define the datatype of the array members
Constants are like fields, except that they have a value. As .NET does not support dynamic types very well, this implementation is rather experimental, using ExpandoObjects. The use of a Constant is not straightforward, casting a datatype to a dynamic. The easiest way to use it is through it's ToString method.