QuickOPC User's Guide and Reference
QuerySourceConditions Method (IEasyAEClient)
Example 



OpcLabs.EasyOpcClassicCore Assembly > OpcLabs.EasyOpc.AlarmsAndEvents Namespace > IEasyAEClient Interface : QuerySourceConditions Method
The OPC server involved in the operation.
A source node descriptor, usually expressed as qualified source name. Only the conditions associated with this source are returned.
Finds out event conditions associated with the specified source name. Uses server descriptor for specifying the OPC server.
Syntax
'Declaration
 
<ElementsNotNullAttribute()>
<NotNullAttribute()>
Function QuerySourceConditions( _
   ByVal serverDescriptor As ServerDescriptor, _
   ByVal sourceNodeDescriptor As AENodeDescriptor _
) As AEConditionElementCollection
'Usage
 
Dim instance As IEasyAEClient
Dim serverDescriptor As ServerDescriptor
Dim sourceNodeDescriptor As AENodeDescriptor
Dim value As AEConditionElementCollection
 
value = instance.QuerySourceConditions(serverDescriptor, sourceNodeDescriptor)
[ElementsNotNull()]
[NotNull()]
AEConditionElementCollection QuerySourceConditions( 
   ServerDescriptor serverDescriptor,
   AENodeDescriptor sourceNodeDescriptor
)

Parameters

serverDescriptor
The OPC server involved in the operation.
sourceNodeDescriptor
A source node descriptor, usually expressed as qualified source name. Only the conditions associated with this source are returned.

Return Value

A collection of condition elements, one element for each condition of the given source.
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 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.

Example

.NET

// This example shows how to enumerate all event conditions associated with the specified event source.

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

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

            AEConditionElementCollection conditionElements;
            try
            {
                conditionElements = client.QuerySourceConditions("", "OPCLabs.KitEventServer.2", 
                    "Simulation.ConditionState1");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (AEConditionElement conditionElement in conditionElements)
            {
                Debug.Assert(conditionElement != null);
                Console.WriteLine("ConditionElements[\"{0}\"]: {1} subcondition(s)", 
                    conditionElement.Name, conditionElement.SubconditionNames.Length);
            }
        }
    } 
}
# This example shows how to enumerate all event conditions associated with the specified event source.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.AlarmsAndEvents import *
from OpcLabs.EasyOpc.OperationModel import *


# Instantiate the client object.
client = EasyAEClient()

# Perform the operation.
try:
    conditionElements = IEasyAEClientExtension.QuerySourceConditions(client, '', 'OPCLabs.KitEventServer.2',
                                                                     AENodeDescriptor('Simulation.ConditionState1'))
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

# Display results.
for conditionElement in conditionElements:
    assert conditionElement is not None
    print('ConditionElements[', conditionElement.Name, ']: ',
          conditionElement.SubconditionNames.Length, ' subcondition(s)',
          sep='')

print()
print('Finished.')
' This example shows how to enumerate all event conditions associated with the specified event source.

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

Namespace AlarmsAndEvents._EasyAEClient

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

            Dim conditionElements As AEConditionElementCollection
            Try
                conditionElements = client.QuerySourceConditions( _
                    "", "OPCLabs.KitEventServer.2", "Simulation.ConditionState1")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            For Each conditionElement As AEConditionElement In conditionElements
                Debug.Assert(conditionElement IsNot Nothing)
                Console.WriteLine("ConditionElements[""{0}""]: {1} subcondition(s)", _
                                  conditionElement.Name, conditionElement.SubconditionNames.Length)
            Next conditionElement
        End Sub
    End Class

End Namespace
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