QuickOPC User's Guide and Reference
AddComment Method
Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.AlarmsAndConditions.Extensions Namespace > IEasyUAClientExtension Class : AddComment Method
The client object that will perform the operation.
Endpoint descriptor. Identifies the OPC-UA server.
Node descriptor. Identifies the node in OPC server's address space.
EventId identifying a particular Event Notification where a state was reported for a Condition.
A localized text to be applied to the Condition.
The AddComment Method is used to apply a comment to a specific state of a Condition instance.
Syntax
'Declaration
 
<ExtensionAttribute()>
Public Shared Sub AddComment( _
   ByVal client As IEasyUAClient, _
   ByVal endpointDescriptor As UAEndpointDescriptor, _
   ByVal objectOrConditionNodeDescriptor As UANodeDescriptor, _
   ByVal eventId() As Byte, _
   ByVal comment As String _
) 
'Usage
 
Dim client As IEasyUAClient
Dim endpointDescriptor As UAEndpointDescriptor
Dim objectOrConditionNodeDescriptor As UANodeDescriptor
Dim eventId() As Byte
Dim comment As String
 
IEasyUAClientExtension.AddComment(client, endpointDescriptor, objectOrConditionNodeDescriptor, eventId, comment)

Parameters

client
The client object that will perform the operation.
endpointDescriptor
Endpoint descriptor. Identifies the OPC-UA server.
objectOrConditionNodeDescriptor
Node descriptor. Identifies the node in OPC server's address space.
eventId
EventId identifying a particular Event Notification where a state was reported for a Condition.
comment
A localized text to be applied to the Condition.
Remarks
Normally, the NodeId of the object instance as the ObjectId is passed to the Call Service. However, some Servers do not expose Condition instances in the AddressSpace. Therefore all Servers shall also allow Clients to call the AddComments Method by specifying ConditionId as the ObjectId. The Method cannot be called with an ObjectId of the ConditionType Node.
Example
// This example shows how to acknowledge an event.

using System;
using System.Threading;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.AddressSpace.Standard;
using OpcLabs.EasyOpc.UA.AlarmsAndConditions;
using OpcLabs.EasyOpc.UA.AlarmsAndConditions.Extensions;
using OpcLabs.EasyOpc.UA.Filtering;

namespace UADocExamples._EasyUAClient
{
    class Acknowledge
    {
        public static void Main1()
        {
            // Instantiate the client object
            var easyUAClient = new EasyUAClient();

            UANodeId nodeId = null;
            byte[] eventId = null;
            var anEvent = new ManualResetEvent(initialState: false);

            Console.WriteLine("Subscribing...");
            easyUAClient.SubscribeEvent(
                "opc.tcp://opcua.demo-this.com:62544/Quickstarts/AlarmConditionServer",
                UAObjectIds.Server,
                1000,
                new UAEventFilterBuilder(
                    UAFilterElements.Equals(
                    UABaseEventObject.Operands.NodeId,
                        new UANodeId(expandedText: "nsu=http://opcfoundation.org/Quickstarts/AlarmCondition;ns=2;s=1:Colours/EastTank?Yellow")),
                    UABaseEventObject.AllFields),
                (sender, eventArgs) =>
                {
                    if (!eventArgs.Succeeded)
                    {
                        Console.WriteLine(eventArgs.ErrorMessageBrief);
                        return;
                    }
                    if (eventArgs.EventData != null)
                    {
                        UABaseEventObject baseEventObject = eventArgs.EventData.BaseEvent;
                        Console.WriteLine(baseEventObject);

                        // Make sure we do not catch the event more than once
                        if (anEvent.WaitOne(0))
                            return;

                        nodeId = baseEventObject.NodeId;
                        eventId = baseEventObject.EventId;

                        anEvent.Set();
                    }
                },
                state:null);

            Console.WriteLine("Waiting for an event for 30 seconds...");
            if (!anEvent.WaitOne(30*1000))
            {
                Console.WriteLine("Event not received");
                return;
            }

            Console.WriteLine("Acknowledging an event...");
            easyUAClient.Acknowledge(
                "opc.tcp://opcua.demo-this.com:62544/Quickstarts/AlarmConditionServer",
                nodeId,
                eventId,
                "Acknowledged by an automated example code");

            Console.WriteLine("Waiting for 5 seconds...");
            Thread.Sleep(5 * 1000);

            Console.WriteLine("Unsubscribing...");
            easyUAClient.UnsubscribeAllMonitoredItems();

            Console.WriteLine("Waiting for 5 seconds...");
            Thread.Sleep(5 * 1000);
        }
    }
}
Requirements

Target Platforms: Windows 7 with SP1, Windows Server 2008 R2 with SP1

See Also

Reference

IEasyUAClientExtension Class
IEasyUAClientExtension Members