QuickOPC User's Guide and Reference
AcknowledgeCondition(String,String,String,String,DateTime,Int64) Method
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.AlarmsAndEvents Namespace > EasyAEClient Class > AcknowledgeCondition Method : AcknowledgeCondition(String,String,String,String,DateTime,Int64) Method
Name of the machine. Determines the computer on which the OPC server is located. May be an empty string, in which case the OPC server is assumed to exist on the local computer or at the computer specified for it by DCOM configuration.
Contains ProgID of the OPC server.
Fully qualified source name. Identifies the source of the condition that is being acknowledged, e.g. FIC101.
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".
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 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.
Acknowledges a condition in the Event Server. Uses computer name and server class for specifying the OPC server. Use default acknowledger ID and an empty comment.
Syntax
'Declaration
 
<ComVisibleAttribute(False)>
Public Overloads Sub AcknowledgeCondition( _
   ByVal machineName As String, _
   ByVal serverClass As String, _
   ByVal qualifiedSourceName As String, _
   ByVal conditionName As String, _
   ByVal activeTime As Date, _
   ByVal cookie As Long _
) 
'Usage
 
Dim instance As EasyAEClient
Dim machineName As String
Dim serverClass As String
Dim qualifiedSourceName As String
Dim conditionName As String
Dim activeTime As Date
Dim cookie As Long
 
instance.AcknowledgeCondition(machineName, serverClass, qualifiedSourceName, conditionName, activeTime, cookie)

Parameters

machineName
Name of the machine. Determines the computer on which the OPC server is located. May be an empty string, in which case the OPC server is assumed to exist on the local computer or at the computer specified for it by DCOM configuration.
serverClass
Contains ProgID of the OPC server.
qualifiedSourceName
Fully qualified source name. Identifies the source of the condition that is being acknowledged, e.g. FIC101.
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".
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 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.
Example
// This example shows how to acknowledge an event condition in the OPC server.

using System;
using System.Threading;
using OpcLabs.EasyOpc.AlarmsAndEvents;
using OpcLabs.EasyOpc.AlarmsAndEvents.OperationModel;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.AlarmsAndEvents._EasyAEClient
{
    class AcknowledgeCondition
    {
        // Instantiate the OPC-A&E client object.
        static readonly EasyAEClient AEClient = new EasyAEClient();

        // Instantiate the OPC-DA client object.
        static readonly EasyDAClient DAClient = new EasyDAClient();

        static volatile bool _done;

        public static void Main1()
        {
            var eventHandler = new EasyAENotificationEventHandler(AEClient_Notification);
            AEClient.Notification += eventHandler;

            Console.WriteLine("Processing event notifications for 1 minute...");
            var subscriptionFilter = new AESubscriptionFilter
            {
                Sources = new AENodeDescriptor[] { "Simulation.ConditionState1" }
            };
            int handle = AEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, null, subscriptionFilter);

            // Give the refresh operation time to complete
            Thread.Sleep(5 * 1000);

            // Trigger an acknowledgeable event
            try
            {
                DAClient.WriteItemValue("", "OPCLabs.KitServer.2", "SimulateEvents.ConditionState1.Activate", true);
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            _done = false;
            DateTime endTime = DateTime.Now + new TimeSpan(0, 0, 5);
            while ((!_done) && (DateTime.Now < endTime))
                Thread.Sleep(1000);

            // Give some time to also receive the acknowledgement notification
            Thread.Sleep(5 * 1000);

            AEClient.UnsubscribeEvents(handle);
            AEClient.Notification -= eventHandler;
        }

        // Notification event handler
        static void AEClient_Notification(object sender, EasyAENotificationEventArgs e)
        {
            Console.WriteLine();
            if (!e.Succeeded)
            {
                Console.WriteLine("*** Failure: {0}", e.ErrorMessageBrief);
                return;
            }

            Console.WriteLine("Refresh: {0}", e.Refresh);
            Console.WriteLine("RefreshComplete: {0}", e.RefreshComplete);
            AEEventData eventData = e.EventData;
            if (!(eventData is null))
            {
                Console.WriteLine("Event.QualifiedSourceName: {0}", eventData.QualifiedSourceName);
                Console.WriteLine("Event.Message: {0}", eventData.Message);
                Console.WriteLine("Event.Active: {0}", eventData.Active);
                Console.WriteLine("Event.Acknowledged: {0}", eventData.Acknowledged);
                Console.WriteLine("Event.AcknowledgeRequired: {0}", eventData.AcknowledgeRequired);

                if (eventData.AcknowledgeRequired)
                {
                    Console.WriteLine(">>>>> ACKNOWLEDGING THIS EVENT");
                    try
                    {
                        AEClient.AcknowledgeCondition("", "OPCLabs.KitEventServer.2", "Simulation.ConditionState1", "Simulated",
                            eventData.ActiveTime, eventData.Cookie);
                    }
                    catch (OpcException opcException)
                    {
                        Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                        return;
                    }
                    Console.WriteLine(">>>>> EVENT ACKNOWLEDGED");
                    _done = true;
                }
            }
        }
    }
}
' This example shows how to acknowledge an event condition in the OPC server.

Imports System.Threading
Imports OpcLabs.EasyOpc.AlarmsAndEvents
Imports OpcLabs.EasyOpc.AlarmsAndEvents.OperationModel
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace AlarmsAndEvents._EasyAEClient

    Friend Class AcknowledgeCondition
        _
        Private Shared ReadOnly AEClient As New EasyAEClient()
        _
        Private Shared ReadOnly DAClient As New EasyDAClient()

        Private Shared _done As Boolean ' volatile

        Public Shared Sub Main1()
            Dim eventHandler = New EasyAENotificationEventHandler(AddressOf AEClient_Notification)
            AddHandler AEClient.Notification, eventHandler

            Console.WriteLine("Processing event notifications for 1 minute...")
            Dim subscriptionFilter As New AESubscriptionFilter
            subscriptionFilter.Sources = New AENodeDescriptor() {"Simulation.ConditionState1"}
            Dim handle As Integer = AEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, Nothing, subscriptionFilter)

            ' Give the refresh operation time to complete
            Thread.Sleep(5 * 1000)

            ' Trigger an acknowledgeable event
            Try
                DAClient.WriteItemValue("", "OPCLabs.KitServer.2", "SimulateEvents.ConditionState1.Activate", True)
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            _done = False
            Dim endTime As Date = Date.Now + New TimeSpan(0, 0, 5)
            Do While ((Not _done)) AndAlso (Date.Now < endTime)
                Thread.Sleep(1000)
            Loop

            ' Give some time to also receive the acknowledgement notification
            Thread.Sleep(5 * 1000)

            AEClient.UnsubscribeEvents(handle)
            RemoveHandler AEClient.Notification, eventHandler
        End Sub

        ' Notification event handler
        Private Shared Sub AEClient_Notification(ByVal sender As Object, ByVal e As EasyAENotificationEventArgs)
            Console.WriteLine()
            If Not e.Succeeded Then
                Console.WriteLine("*** Failure: {0}", e.ErrorMessageBrief)
                Exit Sub
            End If

            Console.WriteLine("Refresh: {0}", e.Refresh)
            Console.WriteLine("RefreshComplete: {0}", e.RefreshComplete)
            If e.EventData IsNot Nothing Then
                Dim eventData As AEEventData = e.EventData
                Console.WriteLine("EventData.QualifiedSourceName: {0}", eventData.QualifiedSourceName)
                Console.WriteLine("EventData.Message: {0}", eventData.Message)
                Console.WriteLine("EventData.Active: {0}", eventData.Active)
                Console.WriteLine("EventData.Acknowledged: {0}", eventData.Acknowledged)
                Console.WriteLine("EventData.AcknowledgeRequired: {0}", eventData.AcknowledgeRequired)

                If eventData.AcknowledgeRequired Then
                    Console.WriteLine(">>>>> ACKNOWLEDGING THIS EVENT")
                    Try
                        AEClient.AcknowledgeCondition("", "OPCLabs.KitEventServer.2", "Simulation.ConditionState1", "Simulated", eventData.ActiveTime, eventData.Cookie)
                    Catch opcException As OpcException
                        Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                        Exit Sub
                    End Try
                    Console.WriteLine(">>>>> EVENT ACKNOWLEDGED")
                    _done = True
                End If
            End If
        End Sub
    End Class
End Namespace
Requirements

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

See Also