QuickOPC User's Guide and Reference
AECategoryElementCollection Class
Members 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace Namespace : AECategoryElementCollection Class
A collection of category elements (AECategoryElement), keyed by their Category Ids.
Object Model
AECategoryElementCollection ClassAECategoryElement Class
Syntax
'Declaration
 
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.ComTypes._AECategoryElementCollection)>
<ComVisibleAttribute(True)>
<GuidAttribute("D4383639-C033-4A56-8731-7A18CABDE5BE")>
<CLSCompliantAttribute(True)>
<TypeConverterAttribute(OpcLabs.BaseLib.Collections.ObjectModel.Implementation.KeyedCollection2TypeConverter)>
<DefaultMemberAttribute("Item")>
<DebuggerTypeProxyAttribute(System.Collections.Generic.Mscorlib_KeyedCollectionDebugView`2)>
<DebuggerDisplayAttribute("Count = {Count}")>
<SerializableAttribute()>
Public NotInheritable Class AECategoryElementCollection 
   Inherits OpcLabs.BaseLib.Collections.ObjectModel.KeyedCollection2(Of Long,AECategoryElement)
   Implements OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.ComTypes._AECategoryElementCollection, System.Collections.Generic.ICollection(Of AECategoryElement), System.Collections.Generic.IEnumerable(Of AECategoryElement), System.Collections.Generic.IList(Of AECategoryElement), System.Collections.Generic.IReadOnlyCollection(Of AECategoryElement), System.Collections.Generic.IReadOnlyList(Of AECategoryElement), System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ICloneable, System.Xml.Serialization.IXmlSerializable 
'Usage
 
Dim instance As AECategoryElementCollection
[ComDefaultInterface(OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.ComTypes._AECategoryElementCollection)]
[ComVisible(true)]
[Guid("D4383639-C033-4A56-8731-7A18CABDE5BE")]
[CLSCompliant(true)]
[TypeConverter(OpcLabs.BaseLib.Collections.ObjectModel.Implementation.KeyedCollection2TypeConverter)]
[DefaultMember("Item")]
[DebuggerTypeProxy(System.Collections.Generic.Mscorlib_KeyedCollectionDebugView`2)]
[DebuggerDisplay("Count = {Count}")]
[Serializable()]
public sealed class AECategoryElementCollection : OpcLabs.BaseLib.Collections.ObjectModel.KeyedCollection2<long,AECategoryElement>, OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.ComTypes._AECategoryElementCollection, System.Collections.Generic.ICollection<AECategoryElement>, System.Collections.Generic.IEnumerable<AECategoryElement>, System.Collections.Generic.IList<AECategoryElement>, System.Collections.Generic.IReadOnlyCollection<AECategoryElement>, System.Collections.Generic.IReadOnlyList<AECategoryElement>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ICloneable, System.Xml.Serialization.IXmlSerializable  
[ComDefaultInterface(OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.ComTypes._AECategoryElementCollection)]
[ComVisible(true)]
[Guid("D4383639-C033-4A56-8731-7A18CABDE5BE")]
[CLSCompliant(true)]
[TypeConverter(OpcLabs.BaseLib.Collections.ObjectModel.Implementation.KeyedCollection2TypeConverter)]
[DefaultMember("Item")]
[DebuggerTypeProxy(System.Collections.Generic.Mscorlib_KeyedCollectionDebugView`2)]
[DebuggerDisplay("Count = {Count}")]
[Serializable()]
public ref class AECategoryElementCollection sealed : public OpcLabs.BaseLib.Collections.ObjectModel.KeyedCollection2<int64,AECategoryElement>, OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.ComTypes._AECategoryElementCollection, System.Collections.Generic.ICollection<AECategoryElement>, System.Collections.Generic.IEnumerable<AECategoryElement>, System.Collections.Generic.IList<AECategoryElement>, System.Collections.Generic.IReadOnlyCollection<AECategoryElement>, System.Collections.Generic.IReadOnlyList<AECategoryElement>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.ICloneable, System.Xml.Serialization.IXmlSerializable  
Remarks
This collection is returned by the browsing methods.

 

Each OPC Alarms and Events server supports a set of specific event categories. The OPC specifications define a set of recommended categories; however, each OPC server is free to implement some more, vendor-specific event categories as well.

If you want to retrieve a list of all categories available in a given OPC server, call the QueryEventCategories method. You will receive back an AECategoryElementCollection object.

// This example shows how to enumerate all event categories provided by the OPC server. For each category, it displays its Id 
// and description.

using System;
using System.Diagnostics;
using OpcLabs.EasyOpc.AlarmsAndEvents;
using OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.AlarmsAndEvents._EasyAEClient
{
    class QueryEventCategories 
    { 
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyAEClient();

            AECategoryElementCollection categoryElements;
            try
            {
                categoryElements = client.QueryEventCategories("", "OPCLabs.KitEventServer.2");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (AECategoryElement categoryElement in categoryElements)
            {
                Debug.Assert(categoryElement != null);
                Console.WriteLine("CategoryElements[\"{0}\"].Description: {1}", categoryElement.CategoryId, categoryElement.Description);
            }
        }
    } 
}
' This example shows how to enumerate all event categories provided by the OPC server. For each category, it displays its Id 
' and description.

Imports OpcLabs.EasyOpc.AlarmsAndEvents
Imports OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace
Imports OpcLabs.EasyOpc.OperationModel

Namespace DocExamples.AlarmsAndEvents._EasyAEClient

    Friend Class QueryEventCategories
        Public Shared Sub Main1()
            Dim client = New EasyAEClient()

            Dim categoryElements As AECategoryElementCollection
            Try
                categoryElements = client.QueryEventCategories("", "OPCLabs.KitEventServer.2")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            For Each categoryElement As AECategoryElement In categoryElements
                Debug.Assert(categoryElement IsNot Nothing)
                Console.WriteLine("CategoryElements[""{0}""].Description: {1}", categoryElement.CategoryId, categoryElement.Description)
            Next categoryElement
        End Sub
    End Class

End Namespace
Rem This example shows how to enumerate all event categories provided by the OPC server. For each category, it displays its Id 
Rem and description.

Option Explicit

Const AEEventTypes_All = 7

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

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient")
On Error Resume Next
Dim CategoryElements: Set CategoryElements = Client.QueryEventCategories(ServerDescriptor, AEEventTypes_All)
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim CategoryElement: For Each CategoryElement In CategoryElements
    WScript.Echo "CategoryElements(" & CategoryElement.CategoryId & ").Description: " & CategoryElement.Description
Next

 

Each AECategoryElement contains information about one OPC event category, such as its (numeric) CategoryId, readable description, and associated event conditions and attributes. The CategoryId can be later used when creating an event filter, and is provided to you in event notifications.

// This example shows information available about OPC event category.

using System;
using System.Diagnostics;
using OpcLabs.EasyOpc.AlarmsAndEvents;
using OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.AlarmsAndEvents._AECategoryElement 
{ 
    class Properties 
    { 
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyAEClient();

            AECategoryElementCollection categoryElements;
            try
            {
                categoryElements = client.QueryEventCategories("", "OPCLabs.KitEventServer.2");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (AECategoryElement categoryElement in categoryElements)
            {
                Debug.Assert(!(categoryElement is null));

                Console.WriteLine("Information about category {0}:", categoryElement);
                Console.WriteLine("    .CategoryId: {0}", categoryElement.CategoryId);
                Console.WriteLine("    .Description: {0}", categoryElement.Description);
                Console.WriteLine("    .ConditionElements:");
                if (!(categoryElement.ConditionElements.Keys is null))
                    foreach (string conditionKey in categoryElement.ConditionElements.Keys)
                        Console.WriteLine("        {0}", conditionKey);
                Console.WriteLine("    .AttributeElements:");
                if (!(categoryElement.AttributeElements.Keys is null))
                    foreach (long attributeKey in categoryElement.AttributeElements.Keys)
                        Console.WriteLine("        {0}", attributeKey);
            }
        }
    } 
}
' This example shows information available about OPC event category.

Imports OpcLabs.EasyOpc.AlarmsAndEvents
Imports OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace
Imports OpcLabs.EasyOpc.OperationModel

Namespace DocExamples.AlarmsAndEvents._AECategoryElement

    Friend Class Properties
        Public Shared Sub Main1()
            Dim client = New EasyAEClient()

            Dim categoryElements As AECategoryElementCollection
            Try
                categoryElements = client.QueryEventCategories("", "OPCLabs.KitEventServer.2")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            For Each categoryElement As AECategoryElement In categoryElements
                Debug.Assert(categoryElement IsNot Nothing)

                Console.WriteLine("Information about category {0}:", categoryElement)
                Console.WriteLine("    .CategoryId: {0}", categoryElement.CategoryId)
                Console.WriteLine("    .Description: {0}", categoryElement.Description)
                Console.WriteLine("    .ConditionElements:")
                If categoryElement.ConditionElements.Keys IsNot Nothing Then
                    For Each conditionKey As String In categoryElement.ConditionElements.Keys
                        Console.WriteLine("        {0}", conditionKey)
                    Next conditionKey
                End If
                Console.WriteLine("    .AttributeElements:")
                If categoryElement.AttributeElements.Keys IsNot Nothing Then
                    For Each attributeKey As Long In categoryElement.AttributeElements.Keys
                        Console.WriteLine("        {0}", attributeKey)
                    Next attributeKey
                End If
            Next categoryElement
        End Sub
    End Class

End Namespace
Rem This example shows information available about OPC event category.

Option Explicit

Const AEEventTypes_All = 7

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

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient")
On Error Resume Next
Dim CategoryElements: Set CategoryElements = Client.QueryEventCategories(ServerDescriptor, AEEventTypes_All)
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim CategoryElement: For Each CategoryElement In CategoryElements
    WScript.Echo "Information about category " & CategoryElement & ":"
    With CategoryElement
        WScript.Echo Space(4) & ".CategoryId: " & .CategoryId
        WScript.Echo Space(4) & ".Description: " & .Description
        WScript.Echo Space(4) & ".ConditionElements:"
        Dim ConditionElement: For Each ConditionElement In .ConditionElements: WScript.Echo Space(8) & ConditionElement: Next
        WScript.Echo Space(4) & ".AttributeElements:"
        Dim AttributeElement: For Each AttributeElement In .AttributeElements: WScript.Echo Space(8) & AttributeElement: Next
    End With
Next

 

 

 

Inheritance Hierarchy

System.Object
   System.Collections.ObjectModel.Collection<T>
      System.Collections.ObjectModel.KeyedCollection<TKey,TItem>
            OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace.AECategoryElementCollection

Requirements

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

See Also

Reference

AECategoryElementCollection Members
OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace Namespace