module documentation

The ROS2 side of the Structure DataTypes: a message level as a dataclass.

structure_class makes a dataclass from a name and its fields, and opensmi.server.structures creates the DataType, its encoding and its definition from that class and encodes its instances. What is left here is the mapping between the maps a projection works with and those instances, and the checks a write needs that the encoding does not make.

Class DuplicateStructureError Two descriptions of one structure name disagree.
Function structure_class Return the dataclass of a name and fields, the same one for equal arguments.
Function structure_elements Return the elements of an array a client wrote as maps, or refuse the array as a whole.
Function structure_instance Return the instance of a structure that a map of its values describes.
Constant NAME_SEPARATOR Joins the names of the levels above a field in the maps a projection works with.
Type Alias StructureField A field as its name, its annotation and the length of a fixed-size array (zero otherwise).
Function _inner Return the structure class an annotation names, or None, and whether it is a list.
Function _values Undocumented
@cache
def structure_class(name: str, fields: tuple[StructureField, ...]) -> type:

Return the dataclass of a name and fields, the same one for equal arguments.

The length of a fixed-size array is kept in the field's metadata, for the write check.

def structure_elements(cls: type, value: object) -> list[dict[str, object]]:

Return the elements of an array a client wrote as maps, or refuse the array as a whole.

Raises
ValueErrorWhen the value is not an array of the structure, when a field is null, or when a fixed-size array has the wrong length. The message names the element by its position.
def structure_instance(cls: type, values: Mapping[str, object], prefix: str = '') -> Any:

Return the instance of a structure that a map of its values describes.

Parameters
cls:typeUndocumented
values:Mapping[str, object]The values by flat name, the field names of the levels above joined with dots. An array of structures holds one such map per element.
prefix:strUndocumented
Returns
AnyUndocumented
Raises
KeyErrorWhen a field has no value.
NAME_SEPARATOR: str =

Joins the names of the levels above a field in the maps a projection works with.

It spells a key, not a BrowseName: the nodes nest.

Value
'.'
StructureField: TypeAlias =

A field as its name, its annotation and the length of a fixed-size array (zero otherwise).

The annotation is a ua class, a structure class, or a list of one of them.

Value
tuple[str, Any, int]
def _inner(annotation: Any) -> tuple[type | None, bool]:

Return the structure class an annotation names, or None, and whether it is a list.

def _values(cls: type, element: object, prefix: str = '') -> dict[str, object]:

Undocumented