class Lock(UaObject, ParentMixin[
Constructor: Lock(minimum_access_level, **kwargs)
Manages exclusive write/execute access rights to the parent UaObject and its children.
Locks are not hierarchical. A child (or children's child, etc.) with its own Lock will not be influenced by this lock.
OPC UA clients first need to request the lock by calling InitLock(). If granted, they now own the lock and get exclusive write and execution rights. (reading, browsing, etc. is always possible). Ideally, clients release the lock as soon as they are done by calling ExitLock(). Locks are automatically released when the client disconnects or is inactive for too long without calling RenewLock().
The request can also fail when the user does not have the required minimum access level for the lock, or the lock is already hold by another client. If it's hold by another client, the client can request the lock by calling BreakLock(). It will succeed only when the priority of the requesting client are larger than of the lock owner.
Based on OPC UA Locking model (https://reference.opcfoundation.org/specs/OPC-10000-100/7).
| Method | __init__ |
Construct new Lock instance with given minimum_access_level. |
| Method | access |
Check whether user is allowed to access this lock. |
| Async Method | break |
Request exclusive access to nodes protected by this Lock. |
| Async Method | exit |
Release exclusive access to nodes protected by this Lock. |
| Async Method | init |
Request exclusive access to nodes protected by this Lock. |
| Async Method | renew |
Renew the remaining lock time before the ownership is lost due to inactivity. |
| Async Method | update |
Update locking status based on user unconditionally. |
| Property | locked |
Whether this Lock is locked. |
| Property | locking |
User instance owning this Lock or None if unlocked. |
| Property | max |
Maximum time in milliseconds a lock owner is allowed to be inactive. |
| Async Method | _check |
Undocumented |
| Async Method | _get |
Undocumented |
| Async Method | _init |
Undocumented |
| Async Method | _lifecycle |
Undocumented |
| Async Method | _on |
Handle session closed events. |
| Async Method | _shutdown |
Undocumented |
| Async Method | _ua |
Undocumented |
| Async Method | _ua |
Undocumented |
| Async Method | _ua |
Undocumented |
| Async Method | _ua |
Undocumented |
| Class Variable | _ua |
Undocumented |
| Class Variable | _ua |
Undocumented |
| Class Variable | _ua |
Undocumented |
| Class Variable | _ua |
Undocumented |
| Instance Variable | _lock |
Used to guarantee atomic updates. |
| Instance Variable | _locking |
Monotonic timestamp when the lock was granted to a user. Used for inactivity timeout. |
| Instance Variable | _locking |
Undocumented |
| Instance Variable | _task |
Undocumented |
UserAuthorization, *, lock_required: bool | None = None) -> bool:
¶
Check whether user is allowed to access this lock.
UserAuthorization, *, session: SessionProtocol | None = None) -> bool:
¶
Request exclusive access to nodes protected by this Lock.
Request will fail if the lock is already owned by a user with higher User.priority than user or if user lacks necessary access rights. Warning: Will steal lock ownership from its current owner!
| Returns | |
bool | Whether user now owns this Lock. |
Release exclusive access to nodes protected by this Lock.
Will fail if user lacks necessary access rights or the lock is owned by another user.
| Returns | |
bool | Whether the lock was released. |
UserAuthorization, *, session: SessionProtocol | None = None) -> bool:
¶
Request exclusive access to nodes protected by this Lock.
Request will fail if the lock is already owned or if user lacks necessary access rights.
| Returns | |
bool | Whether user now owns this Lock. |
UserAuthorization | None, *, session: SessionProtocol | None = None, reason: str = ''):
¶
Update locking status based on user unconditionally.
| Parameters | |
user:UserAuthorization | None | User that will be set as the locking user. None for clearing the releasing the lock. |
session:SessionProtocol | None | (Optional) session instance. Is unavailable for internal user(s). |
reason:str | Short reason description. Only for logging purposes. |
Handle session closed events.
Used to check if the user of that session is owning a lock. If that is the case, it will be released.
ua.NodeId, session: SessionProtocol) -> int | ua.StatusCode:
¶
Undocumented
ua.NodeId, session: SessionProtocol) -> int | ua.StatusCode:
¶
Undocumented
ua.NodeId, session: SessionProtocol, context: str | None = None) -> int | ua.StatusCode:
¶
Undocumented
ua.NodeId, session: SessionProtocol) -> int | ua.StatusCode:
¶
Undocumented