class documentation

class ROS2MutationMixin(MonitoringMixin, ROS2EventsMixin):

Constructor: ROS2MutationMixin(*args, **kwargs)

View In Hierarchy

The one door through which a machinery item's Monitoring may grow.

Mixed in ahead of opensmi's class. It brings opensmi's Monitoring container, where the variables go, and extends the events mixin because a refused mutation is a BindingEvent.

Method __init__ Start out having mutated nothing, and pass every argument to opensmi.
Async Method machinery_group Return the Machinery Monitoring sub-structure of that name in a container, creating it the first time.
Async Method mint_structure Return the NodeId of a Structure DataType, creating it and what it names the first time.
Async Method mutate_address_space Create nodes, keep their names unique, and announce the change once for all.
Async Method mutate_address_space_with Create nodes a caller builds itself, under the same caps and announcement.
Method note_machine_mutation Add to this Machine's mutation tally. Called by every item on it, including itself.
Async Method render_plan Create the nodes of one plan in a container, and return how to write them.
Async Method resolve_plan_datatype Return the NodeId a plan's DataType means on this server.
Class Variable machine_mutation_node_cap How many nodes one Machine may gain by mutation, across every machinery item on it.
Class Variable mutation_node_cap How many nodes one Binding may gain by mutation. A Component with a larger Binding overrides it.
Property machine_mutation_node_total Return how many nodes this Machine has gained by mutation, across every item.
Property mutation_node_counts Return how many nodes each Binding on this item has gained by mutation.
Property ros2_enum_datatypes Return the enumeration DataTypes minted on this Machine, by browse name.
Property ros2_projection_qualifier Return what distinguishes this item's minted DataTypes from another item's.
Method _count Add one addition's nodes to this Binding's tally and to the Machine's.
Async Method _create_addition Create one addition: its Machinery group and member group if it has them, and the plan's nodes in it.
Async Method _drop_machinery_group Remove a Machinery group a failed addition made, keeping the AddIns a Status group references.
Async Method _machinery_state Return the item's MachineryItemState and MachineryOperationMode, those it has.
Async Method _minted_enum Return the NodeId of an enumeration DataType, minting it the first time it is asked for.
Async Method _render_groups Render a subtree no DataType can describe: groups for its levels, plain Variables for its leaves.
Async Method _render_structure Create the complex Variable of the structure at one path, holding its initial value.
Async Method _within_the_caps Return whether one addition fits, reporting it as a BindingEvent when it does not.
Instance Variable _machine_mutation_nodes Undocumented
Instance Variable _mutation_nodes Undocumented
Instance Variable _ros2_enum_datatypes Undocumented
Property _byte_string_ceiling Return how many bytes a bulk payload on this item may carry.
def __init__(self, *args: Any, **kwargs: Any):

Start out having mutated nothing, and pass every argument to opensmi.

async def machinery_group(self, container: UaVariableContainer, name: str, changes: list[ua.ModelChangeStructureDataType] | None = None) -> UaVariableContainer:

Return the Machinery Monitoring sub-structure of that name in a container, creating it the first time.

It is a FolderType Object shared by every Binding that names it. A Status group references this item's MachineryItemState and MachineryOperationMode with HasComponent when the item provides them, as OPC 40001-1 section 16.1 asks. A group is never removed once a Binding is in it: nothing leaves the address space while the server runs.

Parameters
container:UaVariableContainerUndocumented
name:strUndocumented
changes:list[ua.ModelChangeStructureDataType] | NoneWhere to record the group when it is made, for the model-change event.
Returns
UaVariableContainerUndocumented
async def mint_structure(self, datatype: type) -> ua.NodeId:

Return the NodeId of a Structure DataType, creating it and what it names the first time.

Dependencies first, into the ROS2 nodeset's namespace, through Server.ensure_structure of opensmi-server.

Raises
DuplicateStructureErrorWhen another description of the type is already on the server. Nothing is created in that case.
async def mutate_address_space(self, additions: Iterable[NodeAddition], *, at_init: bool = False) -> list[RenderedPlan | None]:

Create nodes, keep their names unique, and announce the change once for all.

Parameters
additions:Iterable[NodeAddition]What to create.
at_init:boolWhether the address space is being built rather than changed. At init nothing is announced and nothing counts against a cap.
Returns
list[RenderedPlan | None]What each addition became, in order; None for one a cap refused, which created nothing.
Raises
DuplicateVariableNameErrorWhen a name is already taken in its container.
UnprojectableFieldErrorWhen a plan carries an Object.
async def mutate_address_space_with(self, *, binding: str, path: str, nodes: int, build: Callable[[], Awaitable[Sequence[tuple[Node, ua.NodeId | int]]]]) -> bool:

Create nodes a caller builds itself, under the same caps and announcement.

Unlike mutate_address_space, the caller makes the nodes. This exists for OPC 10000-210 Locations (opensmi's CartesianFrame), which are not variables of a plan.

Parameters
binding:strThe Binding these nodes belong to, which the cap counts against.
path:strThe ROS2 path of that Binding, for a refusal's BindingEvent.
nodes:intHow many nodes the build will create. The caller states it, since only the caller knows.
build:Callable[[], Awaitable[Sequence[tuple[Node, ua.NodeId | int]]]]What to create, answering each node made and the type it instantiated (what a client filtering model changes by type reads).
Returns
boolWhether it happened. False means a cap refused it and nothing was created.
def note_machine_mutation(self, nodes: int):

Add to this Machine's mutation tally. Called by every item on it, including itself.

async def render_plan(self, container: UaVariableContainer, plan: Sequence[PlanEntry], *, message_type: type[Message], qualifier: str, where: str, root: str | None = None, writable: bool = False, changes: list[ua.ModelChangeStructureDataType] | None = None) -> RenderedPlan:

Create the nodes of one plan in a container, and return how to write them.

With root the whole message is one complex Variable of that name. Without it, each top-level field is a child of the container, and a nested message a complex Variable. A complex Variable carries the structure of its level, minted here. A plan with a leaf that no structure field can carry (a DateTime) is rendered with variable groups for its levels and plain Variables for its leaves, so it keeps its names and loses only the atomic read. Every name is checked before any node is made.

Parameters
container:UaVariableContainerThe opensmi container the nodes are added to.
plan:Sequence[PlanEntry]What to create.
message_type:type[Message]The ROS2 type the plan was shaped from.
qualifier:strWhat names the structures of curated levels, such as Platform.Odom.
where:strHow a refusal names the container, from a reader's side.
root:str | NoneThe name of the complex Variable the whole plan is rendered as.
writable:boolWhether a client may write the Variables.
changes:list[ua.ModelChangeStructureDataType] | NoneWhere to record each node made, for the model-change event.
Returns
RenderedPlanUndocumented
Raises
UnprojectableFieldErrorWhen an entry is an Object or has no name.
DuplicateVariableNameErrorWhen a name is already taken in the container.
async def resolve_plan_datatype(self, datatype: PlanDataType | None) -> ua.NodeId | None:

Return the NodeId a plan's DataType means on this server.

A plan is a pure value. The NodeId of this package's types depends on the namespace index the server imported it at, and an enumeration has none until minted. Public because Skills create their nodes outside the chokepoint but need their DataTypes minted here.

machine_mutation_node_cap: int =

How many nodes one Machine may gain by mutation, across every machinery item on it.

mutation_node_cap: int =

How many nodes one Binding may gain by mutation. A Component with a larger Binding overrides it.

@property
machine_mutation_node_total: int =

Return how many nodes this Machine has gained by mutation, across every item.

Only meaningful on a Machine, which is the item every other one reports to.

@property
mutation_node_counts: Mapping[str, int] =

Return how many nodes each Binding on this item has gained by mutation.

@property
ros2_enum_datatypes: dict[str, tuple[EnumDataType, ua.NodeId]] =

Return the enumeration DataTypes minted on this Machine, by browse name.

Only the Machine's is read, by every item on it. Beside each NodeId is the definition it was minted from, so one name asked for with two value sets is refused.

@property
ros2_projection_qualifier: str =

Return what distinguishes this item's minted DataTypes from another item's.

The Machine's name and the item's own, unique together in a server: two Machines in one process may each have a Component called camera, and DataTypes are server-wide.

def _count(self, binding: str, nodes: int):

Add one addition's nodes to this Binding's tally and to the Machine's.

async def _create_addition(self, addition: NodeAddition, changes: list[ua.ModelChangeStructureDataType]) -> RenderedPlan:

Create one addition: its Machinery group and member group if it has them, and the plan's nodes in it.

A Machinery group this addition created is removed again when the plan fails, so an unused one never stays behind.

async def _drop_machinery_group(self, container: UaVariableContainer, name: str):

Remove a Machinery group a failed addition made, keeping the AddIns a Status group references.

The removal is recursive and follows HasComponent, so the references go first.

async def _machinery_state(self) -> list[Node]:

Return the item's MachineryItemState and MachineryOperationMode, those it has.

opensmi files both AddIns under MachineryBuildingBlocks. An item without them has none.

async def _minted_enum(self, datatype: EnumDataType) -> ua.NodeId:

Return the NodeId of an enumeration DataType, minting it the first time it is asked for.

Minted once per server and remembered on the Machine; the generated name is qualified by its Component for that reason. It uses asyncua directly and not opensmi's ensure_enum, which needs an IntEnum numbered from zero, while ROS2 constants may start at 1 or skip numbers.

async def _render_groups(self, container: UaVariableContainer, name: str, leaves: list[PlanVariable], *, root: str | None, writable: bool) -> list[_Plain]:

Render a subtree no DataType can describe: groups for its levels, plain Variables for its leaves.

async def _render_structure(self, container: UaVariableContainer, name: str, leaves: list[PlanVariable], classes: Mapping[NodePath, type], path: NodePath, *, display: str, description: str, writable: bool, changes: list[ua.ModelChangeStructureDataType] | None) -> _Complex:

Create the complex Variable of the structure at one path, holding its initial value.

async def _within_the_caps(self, *, binding: str, path: str, planned: int) -> bool:

Return whether one addition fits, reporting it as a BindingEvent when it does not.

_machine_mutation_nodes: int =

Undocumented

_mutation_nodes: dict[str, int] =

Undocumented

_ros2_enum_datatypes: dict[str, tuple[EnumDataType, ua.NodeId]] =

Undocumented

@property
_byte_string_ceiling: int =

Return how many bytes a bulk payload on this item may carry.

The Machine's. Zero (no ceiling) outside a Machine.