The following Locking feature is based on the AddIn model specified in OPC 10001-7.

Locking is the means to avoid concurrent modifications to an Object by restricting access to the entity (often a Client but could also be an internal process) that initiated the lock. LockingServices are typically used to make a set of changes (for example, several Write operations and Method invocations) and where a consistent state is available only after all of these changes have been performed.

The context of the lock is specific to the ObjectType where it is applied to (subsequently named "lock-owner"). These specifics need to be described as part of this lock-owner ObjectType. See for example the section on lock in the TopologyElement (clause 4.3) and the Network (clause 5.3).

By default, a lock allows other Applications to view (navigate/read) the locked element. However, Servers may choose to implement an exclusive locking where other Applications have no access at all (e.g. in cases where even read operations require certain settings to Variables).

The LockingServicesType provides Methods to manage the lock and Properties with status information. This section describes the common semantic. The lock-owner ObjectTypes will often extend these semantics.

Figure 31 shows the LockingServicesType definition. It is formally defined in Table 54.

image034.png

Figure 31 – LockingServicesType

Table 54 – LockingServicesType definition

Attribute

Value

BrowseName

LockingServicesType

IsAbstract

False

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

Subtype of the BaseObjectType defined in OPC 10000-5.

HasComponent

Method

InitLock

Defined in 7.5

Mandatory

HasComponent

Method

RenewLock

Defined in 7.7

Mandatory

HasComponent

Method

ExitLock

Defined in 7.6

Mandatory

HasComponent

Method

BreakLock

Defined in 7.8

Mandatory

HasProperty

Variable

0:DefaultInstanceBrowseName

QualifiedName

PropertyType

HasProperty

Variable

Locked

Boolean

PropertyType

Mandatory

HasProperty

Variable

LockingClient

String

PropertyType

Mandatory

HasProperty

Variable

LockingUser

String

PropertyType

Mandatory

HasProperty

Variable

RemainingLockTime

Duration

PropertyType

Mandatory

Conformance Units

DI Locking

The StatusCode Bad_MethodInvalid shall be returned from the Call Service for Objects where locking is not supported. Bad_UserAccessDenied shall be returned if the Client User does not have the permission to call the Methods.

The DefaultInstanceBrowseName Property – defined in OPC 10000-3 – is used to specify the recommended BrowseName for instances of the LockingServicesType. Its Value is defined in Table 55.

Table 55 – LockingServicesType Additional Variable Attributes

Source Path

Value

0:DefaultInstanceBrowseName

Lock

A lock is typically initiated by a Client calling the InitLock Method and removed by calling the ExitLock Method. The lock-owner ObjectTypes can define mechanisms that automatically initiate and remove a lock.

A lock request will be rejected if operations are active that will be prevented by the lock.

The lock is automatically removed if the MaxInactiveLockTime has elapsed (see 7.4). The lock is also removed when the Session ends during inactivity. This is typically the case when the connection to the Client breaks and the Session times out.

The following LockingServices Properties offer lock-status information.

Locked when True indicates that this element has been locked by some Application and that no or just limited access is available for other Applications.

When the lock is initiated by a Client, LockingClient contains the ApplicationUri of the Client as provided in the CreateSession Service call (see OPC 10000-4). Other options to get this information can be specified on the lock-owner ObjectType.

LockingUser contains information to identify the user. When the lock is initiated by a Client it is obtained directly or indirectly from the UserIdentityToken passed by the Client in the ActivateSession Service call (see OPC 10000-4). Other options to get this information can be specified on the lock-owner ObjectType.

RemainingLockTime denotes the remaining time in milliseconds after which the lock will automatically be removed by the Server. This time is based upon MaxInactiveLockTime (see 7.4).

The support of LockingServices for an Object is declared by aggregating an instance of the LockingServicesType as illustrated in Figure 32.

image035.png

Figure 32 – LockingServices

This Object is used as container for the LockingServices Methods and Properties and should have the BrowseName Lock. It shall be referenced using HasComponent or HasAddIn from the lock-owner Object (for example, a Device).

The LockingServiceType and each instance may share the same Methods. All Properties are distinct.

The MaxInactiveLockTime Property shall be added to the ServerCapabilities Object (see OPC 10000-5). It contains a Server-specific period of inactivity in milliseconds after which the Server will revoke the lock.

The Server will initiate a timer based on this time as part of processing the InitLock request and after the last activity caused by the initiator of the lock is finished. Calling the RenewLock Method shall reset the timer.

Inactivity for MaxInactiveLockTime will trigger a timeout. As a result the Server will release the lock.

The MaxInactiveLockTime Property is formally defined in Table 56.

Table 56 – MaxInactiveLockTime Property definition

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

MaxInactiveLockTime

Duration

PropertyType

Mandatory

InitLock restricts access for other UA Applications.

A call of this Method for an element that is already locked will be rejected..

While locked, requests from other Applications to modify the locked element (e.g., writing to Variables, or invoking Methods) will be rejected. However, requests to read or navigate will typically work. Servers may choose to implement an exclusive locking where other Applications have no access at all.

The lock is removed when ExitLock is called. It is automatically removed when the MaxInactiveLockTime elapsed (see 7.4).

The signature of this Method is specified below. Table 57 and Table 58 specify the arguments and AddressSpace representation, respectively.

Signature

InitLock(

[in] String Context,

[out] Int32 InitLockStatus);

Table 57 – InitLock Method Arguments

Argument

Description

Context

A string used to provide context information about the current activity going on in the Client.

InitLockStatus

0 – OK

-1 – E_AlreadyLocked – the element is already locked

-2 – E_Invalid – the element cannot be locked

Table 58 – InitLock Method AddressSpace definition

Attribute

Value

BrowseName

InitLock

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

InputArguments

Argument[]

PropertyType

Mandatory

HasProperty

Variable

OutputArguments

Argument[]

PropertyType

Mandatory

ExitLock removes the lock. This Method may only be called from the same Application which initiated the lock.

The signature of this Method is specified below. Table 59 and Table 60 specify the arguments and AddressSpace representation, respectively.

Signature

ExitLock(

[out] Int32 ExitLockStatus);

Table 59 – ExitLock Method Arguments

Argument

Description

ExitLockStatus

0 – OK

-1 – E_NotLocked – the Object is not locked

Table 60 – ExitLock Method AddressSpace definition

Attribute

Value

BrowseName

ExitLock

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

OutputArguments

Argument[]

PropertyType

Mandatory

The lock timer is automatically renewed whenever the initiator of the lock issues a request for the locked element or while Nodes of the locked element are subscribed to. RenewLock is used to reset the lock timer to the value of the MaxInactiveLockTime Property and prevent the Server from automatically removing the lock. This Method may only be called from the same Application which initiated the lock.

The signature of this Method is specified below. Table 61 and Table 62 specify the arguments and AddressSpace representation, respectively.

Signature

RenewLock(

[out] Int32 RenewLockStatus);

Table 61 – RenewLock Method Arguments

Argument

Description

RenewLockStatus

0 – OK

-1 – E_NotLocked – the Object is not locked

Table 62 – RenewLock Method AddressSpace definition

Attribute

Value

BrowseName

RenewLock

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

OutputArguments

Argument[]

PropertyType

Mandatory

BreakLock allows a Client (with sufficiently high user rights) to break the lock. This Method will typically be available only to users with administrator privileges. BreakLock should be used with care as the locked element may be in an inconsistent state.

The signature of this Method is specified below. Table 63 and Table 64 specify the arguments and AddressSpace representation, respectively.

Signature

BreakLock(

[out] Int32 BreakLockStatus);

Table 63 – BreakLock Method Arguments

Argument

Description

BreakLockStatus

0 – OK

-1 – E_NotLocked – the Object is not locked

Table 64 – BreakLock Method AddressSpace definition

Attribute

Value

BrowseName

BreakLock

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

HasProperty

Variable

OutputArguments

Argument[]

PropertyType

Mandatory