
'Declaration
<CLSCompliantAttribute(True)> <ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.AlarmsAndEvents.ComTypes._AESubscriptionFilter)> <ComVisibleAttribute(True)> <GuidAttribute("EB62D579-F210-4ACB-BFB9-AA10FA6A8790")> <TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)> <ValueControlAttribute("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.82.174.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=False, Export=True, PageId=10001)> <SerializableAttribute()> Public NotInheritable Class AESubscriptionFilter Inherits OpcLabs.BaseLib.Info Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.EasyOpc.AlarmsAndEvents.ComTypes._AESubscriptionFilter, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
'Usage
Dim instance As AESubscriptionFilter
[CLSCompliant(true)] [ComDefaultInterface(OpcLabs.EasyOpc.AlarmsAndEvents.ComTypes._AESubscriptionFilter)] [ComVisible(true)] [Guid("EB62D579-F210-4ACB-BFB9-AA10FA6A8790")] [TypeConverter(System.ComponentModel.ExpandableObjectConverter)] [ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.82.174.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=false, Export=true, PageId=10001)] [Serializable()] public sealed class AESubscriptionFilter : OpcLabs.BaseLib.Info, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.EasyOpc.AlarmsAndEvents.ComTypes._AESubscriptionFilter, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
[CLSCompliant(true)] [ComDefaultInterface(OpcLabs.EasyOpc.AlarmsAndEvents.ComTypes._AESubscriptionFilter)] [ComVisible(true)] [Guid("EB62D579-F210-4ACB-BFB9-AA10FA6A8790")] [TypeConverter(System.ComponentModel.ExpandableObjectConverter)] [ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.82.174.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=false, Export=true, PageId=10001)] [Serializable()] public ref class AESubscriptionFilter sealed : public OpcLabs.BaseLib.Info, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.EasyOpc.AlarmsAndEvents.ComTypes._AESubscriptionFilter, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
Examples:
Filtering by category or categories:
Filtering by source or sources:
// This example shows how to set the filtering criteria to be used for the event subscription. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. 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._AESubscriptionFilter { class Properties { // 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(); public static void Main1() { var eventHandler = new EasyAENotificationEventHandler(aeClient_Notification); AEClient.Notification += eventHandler; Console.WriteLine("Processing event notifications..."); var subscriptionFilter = new AESubscriptionFilter { Sources = new AENodeDescriptor[] { "Simulation.ConditionState1", "Simulation.ConditionState3" } }; // You can also filter using event types, categories, severity, and areas. int handle = AEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, null, subscriptionFilter); // Allow time for initial refresh Thread.Sleep(5 * 1000); // Set some events to active state. try { // The activation below will come from a source contained in a filter and the notification will arrive. DAClient.WriteItemValue("", "OPCLabs.KitServer.2", "SimulateEvents.ConditionState1.Activate", true); // The activation below will come from a source that is not contained in a filter and the notification will not arrive. DAClient.WriteItemValue("", "OPCLabs.KitServer.2", "SimulateEvents.ConditionState2.Activate", true); } catch (OpcException opcException) { Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message); return; } Thread.Sleep(10 * 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); } } } }
' This example shows how to set the filtering criteria to be used for the event subscription. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports System.Threading Imports OpcLabs.EasyOpc.AlarmsAndEvents Imports OpcLabs.EasyOpc.AlarmsAndEvents.OperationModel Imports OpcLabs.EasyOpc.DataAccess Imports OpcLabs.EasyOpc.OperationModel Namespace AlarmsAndEvents._AESubscriptionFilter Friend Class Properties _ Private Shared ReadOnly AEClient As New EasyAEClient() _ Private Shared ReadOnly DAClient As New EasyDAClient() Public Shared Sub Main1() Dim eventHandler = New EasyAENotificationEventHandler(AddressOf AEClient_Notification) AddHandler AEClient.Notification, eventHandler Console.WriteLine("Processing event notifications...") Dim subscriptionFilter As New AESubscriptionFilter subscriptionFilter.Sources = New AENodeDescriptor() {"Simulation.ConditionState1", "Simulation.ConditionState3"} ' You can also filter using event types, categories, severity, and areas. Dim handle As Integer = AEClient.SubscribeEvents("", "OPCLabs.KitEventServer.2", 1000, Nothing, subscriptionFilter) ' Allow time for initial refresh Thread.Sleep(5 * 1000) ' Set some events to active state. Try ' The activation below will come from a source contained in a filter and the notification will arrive. DAClient.WriteItemValue("", "OPCLabs.KitServer.2", "SimulateEvents.ConditionState1.Activate", True) ' The activation below will come from a source that is not contained in a filter and the notification will not arrive. DAClient.WriteItemValue("", "OPCLabs.KitServer.2", "SimulateEvents.ConditionState2.Activate", True) Catch opcException As OpcException Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message) Exit Sub End Try Thread.Sleep(10 * 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) End If End Sub End Class End Namespace
# This example shows how to set the filtering criteria to be used for the event subscription. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc import time # Import .NET namespaces. from OpcLabs.EasyOpc import * from OpcLabs.EasyOpc.AlarmsAndEvents import * from OpcLabs.EasyOpc.DataAccess import * from OpcLabs.EasyOpc.OperationModel import * # Notification event handler def notification(sender, e): if not e.Succeeded: print('*** Failure: ', e.ErrorMessageBrief, sep='') return print('Refresh: ', e.Refresh, sep='') print('RefreshComplete: ', e.RefreshComplete, sep='') eventData = e.EventData if eventData is not None: print('Event.QualifiedSourceName: ', eventData.QualifiedSourceName, sep='') print('Event.Message: ', eventData.Message, sep='') print('Event.Active: ', eventData.Active, sep='') print('Event.Acknowledged: ', eventData.Acknowledged, sep='') # Instantiate the OPC-A&E client object. aeClient = EasyAEClient() # Instantiate the OPC-DA client object. daClient = EasyDAClient() # aeClient.Notification += notification print('Processing event notifications...') subscriptionFilter = AESubscriptionFilter() subscriptionFilter.Sources = [ AENodeDescriptor('Simulation.ConditionState1'), AENodeDescriptor('Simulation.ConditionState3'), ] # You can also filter using event types, categories, severity, and areas. handle = IEasyAEClientExtension.SubscribeEvents(aeClient, '', 'OPCLabs.KitEventServer.2', 1000, None, subscriptionFilter) # Allow time for initial refresh time.sleep(5) # Set some events to active state. try: # The activation below will come from a source contained in a filter and the notification will arrive. IEasyDAClientExtension.WriteItemValue(daClient, '', 'OPCLabs.KitServer.2', 'SimulateEvents.ConditionState1.Activate', True) # The activation below will come from a source that is not contained in a filter and the notification will not # arrive. IEasyDAClientExtension.WriteItemValue(daClient, '', 'OPCLabs.KitServer.2', 'SimulateEvents.ConditionState2.Activate', True) except OpcException as opcException: print('*** Failure: ' + opcException.GetBaseException().Message) exit() time.sleep(10) aeClient.UnsubscribeAllEvents() aeClient.Notification -= notification print('Finished.')
System.Object
OpcLabs.BaseLib.Object2
OpcLabs.BaseLib.Info
OpcLabs.EasyOpc.AlarmsAndEvents.AESubscriptionFilter