class SubscriptionManager:
Constructor: SubscriptionManager(ua_client, publishing_interval_ms, heartbeat_stale_after, max_items_per_call)
Centrally manages all OPC UA subscription needs.
It bundles subscriptions using only one subscription to an OPC UA server to stay within max. subscription limits of certain OPC UA servers.
| Method | __init__ |
Create a new instance. |
| Async Method | clear |
Delete the OPC UA subscription and forget all registered handlers. |
| Async Method | datachange |
Handle OPC UA data change notifications callback. |
| Async Method | event |
Handle OPC UA event notifications callback. |
| Async Method | init |
Create the subscription and start heartbeat monitoring. |
| Async Method | shutdown |
Stop heartbeat monitoring and delete the OPC UA subscription. |
| Async Method | status |
Handle OPC UA status notifications callback. |
| Async Method | subscribe |
Add given handler to receive data change notifications for given nodes. |
| Async Method | subscribe |
Subscribe many handlers to many nodes using as few server calls as possible. |
| Async Method | subscribe |
Add given handler to receive event notifications for given node. |
| Async Method | unsubscribe |
Remove handler for given nodes; removes server subscription once it has no handlers left. |
| Async Method | unsubscribe |
Remove handler for events of given node; removes server subscription once it has no handlers left. |
| Instance Variable | logger |
Undocumented |
| Property | no |
Return the number of monitored nodes. |
| Method | _attach |
Undocumented |
| Method | _collect |
Undocumented |
| Async Method | _create |
Batches node subscriptions respecting server's max items per call limit. |
| Async Method | _create |
Undocumented |
| Async Method | _delete |
Best-effort deletion of the server-side subscription; the maps are left untouched. |
| Method | _find |
Undocumented |
| Async Method | _heartbeat |
Undocumented |
| Method | _invalidate |
Undocumented |
| Async Method | _read |
Undocumented |
| Method | _refresh |
Take over the monitored item IDs asyncua currently knows. |
| Async Method | _renew |
Undocumented |
| Async Method | _renew |
Undocumented |
| Async Method | _renew |
Undocumented |
| Method | _require |
Return the OPC UA subscription or raise ConnectionError if there is none. |
| Async Method | _subscribe |
Undocumented |
| Async Method | _unsubscribe |
Undocumented |
| Instance Variable | _data |
Maps a OPC UA node to a handle and a list of handlers for data change notifications. |
| Instance Variable | _event |
Maps a OPC UA node to a handle and a list of handlers for event notifications. |
| Instance Variable | _heartbeat |
Undocumented |
| Instance Variable | _heartbeat |
Undocumented |
| Instance Variable | _last |
Undocumented |
| Instance Variable | _max |
Undocumented |
| Instance Variable | _publishing |
Undocumented |
| Instance Variable | _ua |
Undocumented |
| Instance Variable | _ua |
None before init, after shutdown and while renewing. |
Client, publishing_interval_ms: float = 100, heartbeat_stale_after: float = 10.0, max_items_per_call: int | None = None):
¶
Create a new instance.
| Parameters | |
uaClient | OPC UA client to use. |
publishingfloat | Requested publishing interval in milliseconds for OPC UA subscription. May be revised by the server. |
heartbeatfloat | Time in seconds until any subscription should be received. |
maxint | None | Maximum number of OPC UA monitored items per call. If None, will be read from the servers MaxMonitoredItemsPerCall. |
Create the subscription and start heartbeat monitoring.
Must be called once before any subscribe_* method.
UaDataChangeSubscriber, nodes: Node | NodeId | Iterable[ Node | NodeId]) -> dict[ Node, ua.StatusCode]:
¶
Add given handler to receive data change notifications for given nodes.
Note: Any given handler can only be subscribed once to each node.
| Returns | |
dict[ | OPC UA error status codes for all failed subscriptions. Mapping of node to status code. |
Iterable[ tuple[ UaDataChangeSubscriber, Node | NodeId | Iterable[ Node | NodeId]]]) -> dict[ Node, ua.StatusCode]:
¶
Subscribe many handlers to many nodes using as few server calls as possible.
| Parameters | |
subscriptions:Iterable[ | Pairs of (handler, nodes). A node may appear for several handlers. |
| Returns | |
dict[ | OPC UA error status codes for all failed subscriptions. Mapping of node to status code. |
UaEventSubscriber, source_node: Node | NodeId, *, event_types: Sequence[ NodeId] = ()):
¶
Add given handler to receive event notifications for given node.
| Parameters | |
handler:UaEventSubscriber | Undocumented |
sourceNode | NodeId | Undocumented |
eventSequence[ | Additional event types beside BaseEventType to subscribe. |
UaDataChangeSubscriber, nodes: Node | NodeId | Iterable[ Node | NodeId]):
¶
Remove handler for given nodes; removes server subscription once it has no handlers left.
Iterable[ tuple[ UaDataChangeSubscriber, Node | NodeId | Iterable[ Node | NodeId]]]) -> dict[ NodeId, _Wanted]:
¶
Undocumented
Batches node subscriptions respecting server's max items per call limit.
| Returns | |
list[ | List of handles of the subscription or status codes on failure. |
Take over the monitored item IDs asyncua currently knows.
When the server lost the session, asyncua recreates the subscription on auto-reconnect and the server assigns new monitored item IDs.
list[ Node], wanted: dict[ NodeId, _Wanted]) -> dict[ Node, ua.StatusCode]:
¶
Undocumented
_HandlerType, node_id: NodeId, subscription_map: dict[ NodeId, _MonitoredItem[ _HandlerType]]):
¶
Undocumented