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

Locking is the means to avoid concurrent modifications to an Objectby restricting access to the entity (often a Clientbut could also be an internal process) that initiated the lock. LockingServicesare typically used to make a set of changes (for example, several Writeoperations and Methodinvocations) 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 ObjectTypewhere 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 Applicationsto view (navigate/read) the locked element. However, Serversmay choose to implement an exclusive locking where other Applicationshave no access at all (e.g. in cases where even read operations require certain settings to Variables).

The LockingServicesTypeprovides Methodsto manage the lock and Propertieswith status information. This section describes the common semantic. The lock-owner ObjectTypeswill often extend these semantics.

Figure 31shows the LockingServicesTypedefinition. It is formally defined in Table 59.

image034.png

Figure 31– LockingServicesType

Table 59– LockingServicesType definition

Attribute

Value

BrowseName

LockingServicesType

IsAbstract

False

References

NodeClass

BrowseName

DataType

TypeDefinition

Other

Subtype of the BaseObjectType defined in OPC 10000-5.

0:HasComponent

Method

InitLock

Defined in 7.5

M

0:HasComponent

Method

RenewLock

Defined in 7.7

M

0:HasComponent

Method

ExitLock

Defined in 7.6

M

0:HasComponent

Method

BreakLock

Defined in 7.8

M

0:HasProperty

Variable

0:DefaultInstanceBrowseName

0:QualifiedName

0:PropertyType

0:HasProperty

Variable

Locked

0:Boolean

0:PropertyType

M

0:HasProperty

Variable

LockingClient

0:String

0:PropertyType

M

0:HasProperty

Variable

LockingUser

0:String

0:PropertyType

M

0:HasProperty

Variable

RemainingLockTime

0:Duration

0:PropertyType

M

Conformance Units

DI Locking

The StatusCode Bad_MethodInvalidshall be returned from the Call Servicefor Objectswhere locking is not supported. Bad_UserAccessDeniedshall be returned if the Client Userdoes not have the permission to call the Methods.

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

Table 60– LockingServicesType Additional Variable Attributes

Source Path

Value

0:DefaultInstanceBrowseName

Lock

A lock is typically initiated by a Clientcalling the InitLock Methodand removed by calling the ExitLock Method. The lock-owner ObjectTypescan 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 MaxInactiveLockTimehas elapsed (see 7.4). The lock is also removed when the Sessionends during inactivity. This is typically the case when the connection to the Clientbreaks and the Sessiontimes out.

The following LockingServices Propertiesoffer lock-status information.

Lockedwhen True indicates that this element has been locked by some Applicationand that no or just limited access is available for other Applications.

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

LockingUsercontains information to identify the user. When the lock is initiated by a Clientit is obtained directly or indirectly from the UserIdentityToken passed by the Clientin the ActivateSession Servicecall (see OPC 10000-4). Other options to get this information can be specified on the lock-owner ObjectType.

RemainingLockTimedenotes 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 LockingServicesfor an Objectis declared by aggregating an instance of the LockingServicesTypeas illustrated in Figure 32.

image035.png

Figure 32– LockingServices

This Objectis used as container for the LockingServices Methodsand Propertiesand should have the BrowseName Lock. It shall be referenced using HasComponentor HasAddInfrom the lock-owner Object(for example, a Device).

The LockingServiceTypeand each instance may share the same Methods. All Propertiesare distinct.

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

The Serverwill initiate a timer based on this time as part of processing the InitLockrequest and after the last activity caused by the initiator of the lock is finished. Calling the RenewLock Methodshall reset the timer.

Inactivity for MaxInactiveLockTimewill trigger a timeout. As a result, the Serverwill release the lock.

The MaxInactiveLockTime Propertyis formally defined in Table 61.

Table 61– MaxInactiveLockTime Property definition

References

NodeClass

BrowseName

DataType

TypeDefinition

Other

0:HasProperty

Variable

MaxInactiveLockTime

0:Duration

0:PropertyType

M

InitLockrestricts access for other UA Applications.

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

While locked, requests from other Applicationsto modify the locked element (e.g., writing to Variables, or invoking Methods) should be rejected with Bad_Locked. However, requests to read or navigate will typically work. Serversmay choose to implement an exclusive locking where other Applicationshave no access at all.

The lock is removed when ExitLockis called. It is automatically removed when the MaxInactiveLockTimeelapsed (see 7.4).

The signature of this Methodis specified below. Table 62and Table 63specify the arguments and AddressSpacerepresentation, respectively.

Signature

InitLock(

[in] 0:String Context,

[out] 0:Int32 InitLockStatus);

Table 62– 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 63– InitLock Method AddressSpace definition

Attribute

Value

BrowseName

InitLock

References

NodeClass

BrowseName

DataType

TypeDefinition

Other

0:HasProperty

Variable

InputArguments

0:Argument[]

0:PropertyType

M

0:HasProperty

Variable

OutputArguments

0:Argument[]

0:PropertyType

M

Conformance Units

DI Locking

ExitLockremoves the lock. This Methodmay only be called from the same Applicationwhich initiated the lock.

The signature of this Methodis specified below. Table 64and Table 65specify the arguments and AddressSpacerepresentation, respectively.

Signature

ExitLock(

[out] 0:Int32 ExitLockStatus);

Table 64– ExitLock Method Arguments

Argument

Description

ExitLockStatus

0 – OK

-1 – E_NotLocked – the Object is not locked

Table 65– ExitLock Method AddressSpace definition

Attribute

Value

BrowseName

ExitLock

References

NodeClass

BrowseName

DataType

TypeDefinition

Other

0:HasProperty

Variable

OutputArguments

0:Argument[]

0:PropertyType

M

Conformance Units

DI Locking

The lock timer is automatically renewed whenever the initiator of the lock issues a request for the locked element or while Nodesof the locked element are subscribed to. RenewLockis used to reset the lock timer to the value of the MaxInactiveLockTime Propertyand prevent the Serverfrom automatically removing the lock. This Methodmay only be called from the same Applicationwhich initiated the lock.

The signature of this Method is specified below. Table 66and Table 67specify the arguments and AddressSpacerepresentation, respectively.

Signature

RenewLock(

[out] 0:Int32 RenewLockStatus);

Table 66– RenewLock Method Arguments

Argument

Description

RenewLockStatus

0 – OK

-1 – E_NotLocked – the Object is not locked

Table 67– RenewLock Method AddressSpace definition

Attribute

Value

BrowseName

RenewLock

References

NodeClass

BrowseName

DataType

TypeDefinition

Other

0:HasProperty

Variable

OutputArguments

0:Argument[]

0:PropertyType

M

Conformance Units

DI Locking

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

The signature of this Methodis specified below. Table 68and Table 69specify the arguments and AddressSpacerepresentation, respectively.

Signature

BreakLock(

[out] 0:Int32 BreakLockStatus);

Table 68– BreakLock Method Arguments

Argument

Description

BreakLockStatus

0 – OK

-1 – E_NotLocked – the Object is not locked

Table 69– BreakLock Method AddressSpace definition

Attribute

Value

BrowseName

BreakLock

References

NodeClass

BrowseName

DataType

TypeDefinition

Other

0:HasProperty

Variable

OutputArguments

0:Argument[]

0:PropertyType

M

Conformance Units

DI Locking