The mutation chokepoint: the one place a Binding's nodes are made.
Declared Bindings create their nodes once at init and never move them. The three cases where the
address space grows at run time (graph-driven, client-driven and content-driven) all go
through here. This module renders a Projection's plan under an opensmi container
(ROS2MutationMixin.render_plan) and announces each batch as one GeneralModelChangeEvent
(nothing is announced at init). Nodes are created and added to, never removed.
Structure is nesting. A message becomes one complex Variable whose value is the whole
structure, with a child Variable per field and a nested complex Variable per nested message, and a
group (a Binding, a ROS2 parameter namespace, a Keyed member) is a variable group. A message is
written once, at the root of its complex Variable, and opensmi brings the children in step. A plan
with a leaf no structure field can carry (a DateTime, say) renders its levels as variable groups of
plain Variables instead. Growth is capped, per Binding (ROS2MutationMixin.mutation_node_cap)
and per Machine (ROS2MutationMixin.machine_mutation_node_cap). Reaching a cap refuses the
whole addition and reports it as a BindingEvent. Caps count mutations only, not what a declaration
asks for at init.
| Class | |
One plan's nodes to create in one container, on behalf of one Binding. |
| Class | |
The nodes one plan became, written and read by the names the plan gave its entries. |
| Class | |
The one door through which a machinery item's Monitoring may grow. |
| Async Function | add |
Turn one plan entry into an opensmi UaVariable, add it to a container, and type it. |
| Async Function | ended |
Cancel one task and wait for it, tolerating a task that has already finished. |
| Async Function | ensure |
Return the variable group at the end of a chain of levels, creating those that do not exist yet. |
| Function | plan |
Return what a variable stores in the form a projection builds a message from. |
| Function | require |
Refuse a variable name something on this container has already claimed. |
| Function | wire |
Return a plan value in the form its variable stores. |
| Constant | CAP |
The BindingEvent code a refused addition carries, for a client that wants to know why. |
| Class | _ |
The leaves below one path rendered as a complex Variable, which holds their whole structure. |
| Class | _ |
A plan entry rendered as a Variable of its own. |
| Async Function | _add |
Add a variable to a container, leaving nothing registered when that fails. |
| Function | _node |
Return the model change one created node is, with the type it was instantiated as. |
| Function | _planned |
Return how many nodes one addition creates: its member group, its levels and its leaves. |
| Function | _record |
Note a node made and the fields below it, for the model-change event. |
| Function | _require |
Refuse a plan whose names opensmi would not derive from its field names. |
| Function | _require |
Refuse two value sets minted under one DataType name. |
| Function | _split |
Sort a plan into its leaves, the entries that are Variables of their own, and the structures. |
| Function | _structure |
Return the write check of a structure, or of an array of one: the codec's, then the caller's. |
| Async Function | _write |
Write a node's DisplayName, which is where the raw ROS2 name, key or frame id goes. |
| Async Function | _write |
Publish an array's length as unknown. Through write_attribute, as asyncua types it as one int. |
| Constant | _ENUM |
The namespace enumeration DataTypes are minted into: the server's own. |
| Constant | _MACHINERY |
The AddIns a Status group references, by their browse names below MachineryBuildingBlocks. |
| Constant | _NODE |
ModelChangeStructureVerb.NodeAdded, announced for every creation here. |
| Constant | _STATUS |
The Machinery Monitoring sub-structure that references the item's state machines (OPC 40001-1 section 16.1). |
| Constant | _UNKNOWN |
The ArrayDimensions entry every array variable publishes: length unknown. |
UaVariableContainer, name: str, entry: PlanVariable, datatype: ua.NodeId | None, *, writable: bool = False, write_check: Callable[ [ Any], Awaitable[ None]] | None = None, unit: str | None = None, value_range: tuple[ float, float] | None = None) -> UaVariable[ Any]:
¶
Turn one plan entry into an opensmi UaVariable, add it to a container, and type it.
This is the one place DataType, ValueRank and ArrayDimensions of a plain Variable are decided. The variable is created with an explicit Variant (an empty sequence implies no type, and opensmi writes later values with the initial VariantType) and with these attributes:
- ValueRank OneDimension for an array, Scalar otherwise.
- ArrayDimensions [0] for an array (length unknown), written after the add since opensmi has no parameter for it. A bounded ROS2 sequence publishes no bound.
- DataType: the plan's own, else the built-in type of the variant type. opensmi refuses one on a variable with a unit (an AnalogUnitRangeType), so that one is written after the add.
An array of structures (plan DataType a structure class) is created empty, with the resolved DataType. Its write check refuses with BadTypeMismatch a value that is not an array of that structure, then runs the caller's write_check.
A failed add leaves nothing registered: the variable is removed from the container again and any variable it replaced is put back. The attribute writes pass no write check.
| Parameters | |
container:UaVariableContainer | The opensmi container to add the variable to. |
name:str | The variable's BrowseName. |
entry:PlanVariable | The plan entry it is made from. Its DisplayName is the raw ROS2 name. |
datatype:ua.NodeId | None | The DataType the plan names, resolved on this server, or None. Required for an array of structures; its namespace index is the structure's encoding namespace. |
writable:bool | Whether a client may write it. |
writeCallable[ | An async check opensmi awaits before storing a written value. |
unit:str | None | The engineering unit's symbol, for a variable that is not a ROS2 field. opensmi requires a range with it. |
valuetuple[ | The bounds opensmi publishes as an EURange and refuses a write outside. |
| Returns | |
UaVariable[ | Undocumented |
| Raises | |
DeclarationError | When the plan names a structure for something that is not an array, or no resolved DataType comes with it. |
UaVariableContainer, levels: Iterable[ NodeLevel]) -> UaVariableContainer:
¶
Return the variable group at the end of a chain of levels, creating those that do not exist yet.
A level's name is its browse name and its display name the raw ROS2 name. A group two plans share (a ROS2 parameter namespace) is created by the first and found by the second.
Return what a variable stores in the form a projection builds a message from.
The inverse of wire_value: an array of structures comes back as maps.
| Raises | |
ValueError | When an array of structures holds something else, which the write check normally refuses first. |
Refuse a variable name something on this container has already claimed.
opensmi's container has no such check: it files a variable with setattr, so a second one would replace the first. Shared by the chokepoint and by Skills and Methods.
| Parameters | |
name:str | The browse name being claimed. |
taken:Iterable[ | Every place a name may already be recorded, tested in order. |
where:str | What to call the container in the refusal, from a reader's point of view. |
| Raises | |
DuplicateVariableNameError | When the name is taken. |
Return a plan value in the form its variable stores.
An array of structures stores instances of the structure's dataclass. Other variables store the value as is.
| Raises | |
ValueError | When the value for an array of structures is not a list. |
The BindingEvent code a refused addition carries, for a client that wants to know why.
| Value |
|
Add a variable to a container, leaving nothing registered when that fails.
opensmi files a variable before creating its node, so a failed add would leave a node-less variable that breaks later iteration, and would replace what the name held. Both are undone.
Refuse a plan whose names opensmi would not derive from its field names.
The children of a complex Variable are named by opensmi from the field names of the structure, which are the DisplayNames: child_frame_id is ChildFrameId. A name that is not already spelled that way (a Projection that names an entry data) would browse as another name than the plan says, so it is refused instead of renamed silently.
| Raises | |
DeclarationError | When a name on a node path differs from the one opensmi derives. |
Refuse two value sets minted under one DataType name.
Reachable only when two ROS2 types with the same last name part are curated on one Component. Sharing the first definition would give a client another type's labels.
| Raises | |
DuplicateProjectionError | When the two do not agree. |
Sequence[ PlanEntry], root: str | None, where: str) -> tuple[ list[ PlanVariable], list[ tuple[ str, PlanVariable]], dict[ str, list[ PlanVariable]]]:
¶
Sort a plan into its leaves, the entries that are Variables of their own, and the structures.
The entries are listed with the name their Variable takes; a structure by its top-level name, which is root when there is one.
| Raises | |
UnprojectableFieldError | When an entry is an Object or has no name. |
Callable[ [], UaVariable[ Any]], name: str, structure: type, then: Callable[ [ Any], Awaitable[ None]] | None, *, array: bool = True) -> Callable[ [ Any], Awaitable[ None]]:
¶
Return the write check of a structure, or of an array of one: the codec's, then the caller's.
It refuses with BadTypeMismatch a value that is not one (or an array of them), a null field, or a fixed-size array of the wrong length, which the encoding does not publish.
| Parameters | |
variable:Callable[ | The variable the check belongs to, resolved lazily since the check is made first. |
name:str | Undocumented |
structure:type | Undocumented |
then:Callable[ | The caller's check, awaited when the value passed. |
array:bool | Whether the variable holds an array of the structure and not one. |
| Returns | |
Callable[ | Undocumented |
The AddIns a Status group references, by their browse names below MachineryBuildingBlocks.
| Value |
|
ModelChangeStructureVerb.NodeAdded, announced for every creation here.
| Value |
|
The Machinery Monitoring sub-structure that references the item's state machines (OPC 40001-1 section 16.1).
| Value |
|
The ArrayDimensions entry every array variable publishes: length unknown.
| Value |
|