// This example shows information available about OPC event condition.
using System;
using System.Diagnostics;
using System.Collections.Generic;
using OpcLabs.EasyOpc.AlarmsAndEvents;
using OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace;
using OpcLabs.EasyOpc.OperationModel;
namespace DocExamples.AlarmsAndEvents._AEConditionElement
{
class Properties
{
static void DumpSubconditionNames(IEnumerable<string> subconditionNames)
{
foreach (string name in subconditionNames) Console.WriteLine(" {0}", name);
}
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("Category {0}:", categoryElement);
foreach (AEConditionElement conditionElement in categoryElement.ConditionElements)
{
Debug.Assert(conditionElement != null);
Console.WriteLine(" Information about condition \"{0}\":", conditionElement);
Console.WriteLine(" .Name: {0}", conditionElement.Name);
Console.WriteLine(" .SubconditionNames:");
DumpSubconditionNames(conditionElement.SubconditionNames);
}
}
}
}
}
' This example shows information available about OPC event condition.
Imports OpcLabs.EasyOpc.AlarmsAndEvents
Imports OpcLabs.EasyOpc.AlarmsAndEvents.AddressSpace
Imports OpcLabs.EasyOpc.OperationModel
Namespace DocExamples.AlarmsAndEvents._AEConditionElement
Friend Class Properties
Private Shared Sub DumpSubconditionNames(ByVal subconditionNames As IEnumerable(Of String))
For Each name As String In subconditionNames
Console.WriteLine(" {0}", name)
Next name
End Sub
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("Category {0}:", categoryElement)
For Each conditionElement As AEConditionElement In categoryElement.ConditionElements
Debug.Assert(conditionElement IsNot Nothing)
Console.WriteLine(" Information about condition ""{0}"":", conditionElement)
Console.WriteLine(" .Name: {0}", conditionElement.Name)
Console.WriteLine(" .SubconditionNames:")
DumpSubconditionNames(conditionElement.SubconditionNames)
Next conditionElement
Next categoryElement
End Sub
End Class
End Namespace