The Keyed Binding: one ROS2 path, many OPC UA objects, membership taken from the messages.
A Keyed Binding's message carries a repeated field, and a key inside each element names the object
it belongs to: /diagnostics keyed by status[] on hardware_id and name. Membership
is the content-driven case. Each member is a variable group in the Binding's Monitoring that
carries the variables the element type's Projection shapes (a nested message is a complex
Variable), browses under its key with the characters of a RelativePath replaced
(member_browse_name), shows the raw key as its DisplayName and holds it as a String[]
variable. The Binding's name is the group above the members. Members are created
through the mutation chokepoint, so the caps and one model-change event per batch apply, and they
are never removed. Two keys that sanitise to one browse name are reported once as a BindingEvent
and the second gets no member.
An optional declared state field adds two things: a BindingEvent when a member's state changes (at the severity the declaration maps it to), and one variable holding the highest state any member holds. Nothing reads the aggregate back, so a foreign publisher cannot halt a Machine . The mechanism is generic and has no diagnostics-specific code.
| Class | |
Keeps a machinery item's Keyed Bindings' members in sync with what arrives on their topics. |
| Function | member |
Return the browse name a member is filed under: each reserved character of its key becomes _. |
| Function | member |
Return the key one element of a repeated field carries, field by field. |
| Function | severity |
Return the house band a transition into one state is reported at. |
| Function | state |
Return whether writing current over previous is a transition worth an event. |
| Function | worst |
Return the highest state any member holds, or initial when no member holds one. |
| Constant | KEY |
The browse name of the raw-key variable on every member (DisplayName key). |
| Constant | KEY |
The BindingEvent code a second key that sanitises onto an existing member carries. |
| Constant | MEMBER |
The BindingEvent code a member's declared state field changing value carries. |
| Constant | WORST |
What the aggregate variable's name is built from: Worst<State>, such as WorstLevel. |
| Class | _ |
One Keyed Binding, live: its subscription, the plan each member is built from, its members. |
| Class | _ |
One member of a Keyed Binding: its key, the nodes it became, and what they read. |
| Function | _is |
Return whether a state value is a number to order and look labels or bands up by. |
| Function | _keyed |
Return one member's plan, with its raw key as the initial value of the key variable. |
| Function | _labelled |
Return a state value as an event's text should read it: the label, and the number. |
| Function | _member |
Return the plan one member is built from: the raw key, then whatever the Projection shaped. |
| Function | _repeated |
Return the message type one Binding's repeated field carries. |
| Function | _require |
Refuse a key field that cannot name a member. |
| Function | _state |
Return the variable a Binding's declared state field renders as, with its labels named. |
| Function | _with |
Return the member plan with the state field's variable as the state entry describes it. |
| Constant | _KEY |
The DisplayName of the raw-key variable. |
| Constant | _RESERVED |
The characters the OPC UA RelativePath text form reserves. Each in a member's key becomes one underscore, so a generic client never has to escape a key. |
| Constant | _UNNAMED |
What a key with nothing usable in it browses as, because refusing would drop the member. |
Return the browse name a member is filed under: each reserved character of its key becomes _.
The parts of a multi-field key are joined with _. "robot 1: left motor" browses as "robot 1_ left motor" and the raw key is the DisplayName. The mapping is not injective, and the caller refuses a collision.
Return the key one element of a repeated field carries, field by field.
The fields are read in declaration order and rendered as text. Key fields are validated as scalar leaves when the Binding is built.
| Parameters | |
element:Message | One element of the Binding's repeated field, as it crossed the seam. |
keySequence[ | The ROS2 field names the declaration keys on. |
| Returns | |
tuple[ | Undocumented |
Return the house band a transition into one state is reported at.
The map comes from the declaration (see ~opensmi.ros2.server.events.Severity). With no
map every transition is INFO; with a map, a value outside it is a WARNING.
Return whether writing current over previous is a transition worth an event.
A member is created holding the plan's initial (for a level, the first declared constant), so a healthy unit announces nothing when it first appears and a broken one does.
Return the highest state any member holds, or initial when no member holds one.
Highest by the ROS2 constants' numbering, which for DiagnosticStatus is the worst level. Non-numeric states have no order, so the aggregate stays at initial.
| Parameters | |
states:Iterable[ | What each member's state variable currently reads. |
initial:object | What the aggregate was created holding, which is what an empty set reads. |
| Returns | |
object | Undocumented |
The browse name of the raw-key variable on every member (DisplayName key).
A Binding whose element type already has a field that browses as this is refused at init.
| Value |
|
The BindingEvent code a second key that sanitises onto an existing member carries.
| Value |
|
The BindingEvent code a member's declared state field changing value carries.
| Value |
|
Return whether a state value is a number to order and look labels or bands up by.
bool is excluded: a state field is not a flag.
Return one member's plan, with its raw key as the initial value of the key variable.
The node is created holding the key, so a client never reads it empty.
Return the plan one member is built from: the raw key, then whatever the Projection shaped.
| Raises | |
DeclarationError | When the element type already renders something called KEY. |
Return the message type one Binding's repeated field carries.
| Raises | |
UnprojectableFieldError | When the named field does not exist or does not repeat a message. |
Refuse a key field that cannot name a member.
| Raises | |
DeclarationError | When a key field is absent from the element type, or is not a scalar leaf of it. |
tuple[ PlanEntry, ...], binding: KeyedBinding, element_type: type[ Message], qualifier: str) -> PlanVariable | None:
¶
Return the variable a Binding's declared state field renders as, with its labels named.
The labels come from the declaration, not the Projection, so the member's state variable and the aggregate share one enumeration.
| Raises | |
DeclarationError | When the element's Projection renders no variable of that name (the field was excluded or renamed). |
tuple[ PlanEntry, ...], state: PlanVariable | None) -> tuple[ PlanEntry, ...]:
¶
Return the member plan with the state field's variable as the state entry describes it.
The characters the OPC UA RelativePath text form reserves. Each in a member's key becomes one underscore, so a generic client never has to escape a key.
| Value |
|