OPC Studio User's Guide and Reference
AcknowledgeCondition Method (_EasyAEClient)
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.AlarmsAndEvents.ComTypes Namespace > _EasyAEClient Interface : AcknowledgeCondition Method
The OPC server involved in the operation.

Because the OpcLabs.EasyOpc.ServerDescriptor has an implicit conversion from System.Guid, System.String and OpcLabs.EasyOpc.ServerElement, in languages that support implicit conversion operators (such as C# or VB.NET), you can simply use a GUID (representing the CLSID of the server), a string (representing the so-called OPC server descriptor string, such as a ProgID or the URL of the server), or a OpcLabs.EasyOpc.ServerElement object (result from OPC browsing), in place of this parameter, and the corresponding OPC server descriptor will be constructed automatically. When the implicit conversion operators are not supported (such as with Python.NET), you can use the OpcLabs.EasyOpc.ServerDescriptor.FromGuid, OpcLabs.EasyOpc.ServerDescriptor.FromString or OpcLabs.EasyOpc.ServerDescriptor.FromServerElement static method instead.

The value of this parameter cannot be null (Nothing in Visual Basic).

Contains fully qualified source name. Identifies the source of the condition that is being acknowledged, e.g. FIC101.

Because the OpcLabs.EasyOpc.AlarmsAndEvents.AENodeDescriptor has an implicit conversion from System.String and OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.AENodeElement, in languages that support implicit conversion operators (such as C# or VB.NET), you can simply use a string (representing the qualified name of the node), or a OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.AENodeElement object (result from OPC browsing), in place of this parameter, and the corresponding OPC A&E node descriptor will be constructed automatically. When the implicit conversion operators are not supported (such as with Python.NET), you can use the OpcLabs.EasyOpc.AlarmsAndEvents.AENodeDescriptor.FromString or OpcLabs.EasyOpc.AlarmsAndEvents.AENodeDescriptor.FromAENodeElement static method instead.

The value of this parameter cannot be null (Nothing in Visual Basic).

A condition name, identifying the condition that is being acknowledged. Condition Names are unique within the scope of the event server. Examples of Condition Names might be "LevelAlarm" or "Deviation".

The value of this parameter can be null (Nothing in Visual Basic).

An active time corresponding to the Source and Condition Name pair. This parameter uniquely identifies a specific transition of the condition to the active state or into a different sub-condition and is the same as the OpcLabs.EasyOpc.AlarmsAndEvents.AEConditionState.SubconditionActiveTime condition attribute. Active Times are passed to the client in the event notification. If the condition has become active again or transitioned into a different sub-condition at a later time, this acknowledgment will be ignored.
A server supplied "cookie" corresponding to the Source and Condition Name pair that in addition to the Active Time uniquely identifies a specific event notification. Cookies are passed to the client in the event notification. The client is responsible for returning the same cookie parameter, received in the event notification, back to the server in the condition acknowledgment.

The value of this parameter can be null (Nothing in Visual Basic).

The value of this parameter can be null (Nothing in Visual Basic).

Acknowledges a condition in the Event Server. Uses server descriptor for specifying the OPC server. Use default acknowledger ID and an empty comment.
Syntax
'Declaration
 
Sub AcknowledgeCondition( _
   ByVal serverDescriptor As Object, _
   ByVal sourceDescriptor As Object, _
   ByVal conditionName As String, _
   ByVal activeTime As Date, _
   ByVal cookie As Integer, _
   ByVal acknowledgerId As String, _
   ByVal comment As String _
) 
'Usage
 
Dim instance As _EasyAEClient
Dim serverDescriptor As Object
Dim sourceDescriptor As Object
Dim conditionName As String
Dim activeTime As Date
Dim cookie As Integer
Dim acknowledgerId As String
Dim comment As String
 
instance.AcknowledgeCondition(serverDescriptor, sourceDescriptor, conditionName, activeTime, cookie, acknowledgerId, comment)

Parameters

serverDescriptor
The OPC server involved in the operation.

Because the OpcLabs.EasyOpc.ServerDescriptor has an implicit conversion from System.Guid, System.String and OpcLabs.EasyOpc.ServerElement, in languages that support implicit conversion operators (such as C# or VB.NET), you can simply use a GUID (representing the CLSID of the server), a string (representing the so-called OPC server descriptor string, such as a ProgID or the URL of the server), or a OpcLabs.EasyOpc.ServerElement object (result from OPC browsing), in place of this parameter, and the corresponding OPC server descriptor will be constructed automatically. When the implicit conversion operators are not supported (such as with Python.NET), you can use the OpcLabs.EasyOpc.ServerDescriptor.FromGuid, OpcLabs.EasyOpc.ServerDescriptor.FromString or OpcLabs.EasyOpc.ServerDescriptor.FromServerElement static method instead.

The value of this parameter cannot be null (Nothing in Visual Basic).

sourceDescriptor
Contains fully qualified source name. Identifies the source of the condition that is being acknowledged, e.g. FIC101.

Because the OpcLabs.EasyOpc.AlarmsAndEvents.AENodeDescriptor has an implicit conversion from System.String and OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.AENodeElement, in languages that support implicit conversion operators (such as C# or VB.NET), you can simply use a string (representing the qualified name of the node), or a OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.AENodeElement object (result from OPC browsing), in place of this parameter, and the corresponding OPC A&E node descriptor will be constructed automatically. When the implicit conversion operators are not supported (such as with Python.NET), you can use the OpcLabs.EasyOpc.AlarmsAndEvents.AENodeDescriptor.FromString or OpcLabs.EasyOpc.AlarmsAndEvents.AENodeDescriptor.FromAENodeElement static method instead.

The value of this parameter cannot be null (Nothing in Visual Basic).

conditionName
A condition name, identifying the condition that is being acknowledged. Condition Names are unique within the scope of the event server. Examples of Condition Names might be "LevelAlarm" or "Deviation".

The value of this parameter can be null (Nothing in Visual Basic).

activeTime
An active time corresponding to the Source and Condition Name pair. This parameter uniquely identifies a specific transition of the condition to the active state or into a different sub-condition and is the same as the OpcLabs.EasyOpc.AlarmsAndEvents.AEConditionState.SubconditionActiveTime condition attribute. Active Times are passed to the client in the event notification. If the condition has become active again or transitioned into a different sub-condition at a later time, this acknowledgment will be ignored.
cookie
A server supplied "cookie" corresponding to the Source and Condition Name pair that in addition to the Active Time uniquely identifies a specific event notification. Cookies are passed to the client in the event notification. The client is responsible for returning the same cookie parameter, received in the event notification, back to the server in the condition acknowledgment.
acknowledgerId

The value of this parameter can be null (Nothing in Visual Basic).

comment

The value of this parameter can be null (Nothing in Visual Basic).

Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

The value of an argument is outside the allowable range of values as defined by the invoked method.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

The OPC "Classic" (or OPC XML-DA) operation has failed. This operation exception in uniformly used to allow common handling of various kinds of errors. The System.Exception.InnerException always contains information about the actual error cause.

This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately.

Remarks

This member or type is for use from COM. It is not meant to be used from .NET or Python. Refer to the corresponding .NET member or type instead, if you are developing in .NET or Python.

Example

COM

Rem This example shows how to acknowledge an event condition in the OPC server.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Dim DAClient: Set DAClient = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
Dim AEClient: Set AEClient = CreateObject("OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient")

WScript.Echo "Hooking event handler..."
WScript.ConnectObject AEClient, "AEClient_"

Dim ServerDescriptor: Set ServerDescriptor = CreateObject("OpcLabs.EasyOpc.ServerDescriptor")
ServerDescriptor.ServerClass = "OPCLabs.KitEventServer.2"

Dim SourceDescriptor: Set SourceDescriptor = CreateObject("OpcLabs.EasyOpc.AlarmsAndEvents.AENodeDescriptor")
SourceDescriptor.QualifiedName = "Simulation.ConditionState1"

WScript.Echo "Processing event notifications for 1 minute..."
Dim SubscriptionParameters: Set SubscriptionParameters = CreateObject("OpcLabs.EasyOpc.AlarmsAndEvents.AESubscriptionParameters")
SubscriptionParameters.Filter.Sources = Array(SourceDescriptor)
SubscriptionParameters.NotificationRate = 1000
Dim handle: handle = AEClient.SubscribeEvents(ServerDescriptor, SubscriptionParameters, True, Nothing)

WScript.Echo "Give the refresh operation time to complete: Waiting for 5 seconds..."
WScript.Sleep 5*1000

WScript.Echo "Triggering an acknowledgeable event..."
On Error Resume Next
DAClient.WriteItemValue "", "OPCLabs.KitServer.2", "SimulateEvents.ConditionState1.Activate", True
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim done: done = False
Dim endTime: endTime = Now() + 5*(1/24/60/60)
While (Not done) And (Now() < endTime)
    WScript.Sleep 1000
WEnd

WScript.Echo "Give some time to also receive the acknowledgement notification: Waiting for 5 seconds..."
WScript.Sleep 5*1000

WScript.Echo "Unsubscribing events..."
AEClient.UnsubscribeEvents handle

WScript.Echo "Unhooking event handler..."
WScript.DisconnectObject AEClient

WScript.Echo "Finished."



Rem Notification event handler
Sub AEClient_Notification(Sender, e)
    If Not (e.Succeeded) Then
        WScript.Echo "*** Failure: " & e.ErrorMessageBrief
        Exit Sub
    End If

    WScript.Echo 
    WScript.Echo "Refresh: " & e.Refresh
    WScript.Echo "RefreshComplete: " & e.RefreshComplete
    If Not (e.EventData Is Nothing) Then
        With e.EventData
            WScript.Echo "EventData.QualifiedSourceName: " & .QualifiedSourceName
            WScript.Echo "EventData.Message: " & .Message
            WScript.Echo "EventData.Active: " & .Active
            WScript.Echo "EventData.Acknowledged: " & .Acknowledged
            WScript.Echo "EventData.AcknowledgeRequired: " & .AcknowledgeRequired

            If .AcknowledgeRequired Then
                WScript.Echo ">>>>> ACKNOWLEDGING THIS EVENT"
                On Error Resume Next
                AEClient.AcknowledgeCondition ServerDescriptor, SourceDescriptor, "Simulated", _
                    .ActiveTime, .Cookie, "aUser", ""
                If Err.Number <> 0 Then
                    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
                    Exit Sub
                End If
                On Error Goto 0
                WScript.Echo ">>>>> EVENT ACKNOWLEDGED"
                done = True
            End If
        End With
    End If
End Sub
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also