OPC Studio User's Guide and Reference
ChangeEventSubscription Method (_EasyAEClient)
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.AlarmsAndEvents.ComTypes Namespace > _EasyAEClient Interface : ChangeEventSubscription Method
Event subscription handle as returned by the SubscribeEvents method
The requested notification rate. The notification rate is in milliseconds and tells the server how often to send event notifications. This is a minimum time - do not send event notifications any faster that this UNLESS the buffer size is reached. A value of 0 for notification rate means that the server should send event notifications as soon as it gets them. This parameter is used to improve communications efficiency between client and server. This parameter is a recommendation from the client, and the server is allowed to ignore the parameter.
An OpcLabs.EasyOpc.AlarmsAndEvents.AESubscriptionFilter that determines the filtering criteria to be used for the event subscription.

The value of this parameter cannot be null (Nothing in Visual Basic).

Activates or deactivates the subscription. If the client deactivates the subscription, then the server will no longer send event notifications to the client based on that subscription, and has no responsibility to buffer or maintain the event notifications. Thus, event notifications may be lost. Even if the subscription is inactive, the Refresh method will still function. In effect, this allows a client to obtain current condition states from time to time (by invoking Refresh) without the need to process event notifications in "real time".

Changes parameters of a particular event subscription.

Changes parameters of an event subscription. Specify new notification rate, subscription filter object, and an "active" flag.

Syntax
'Declaration
 
Sub ChangeEventSubscription( _
   ByVal handle As Integer, _
   ByVal notificationRate As Integer, _
   ByVal filter As Object, _
   ByVal active As Boolean _
) 
'Usage
 
Dim instance As _EasyAEClient
Dim handle As Integer
Dim notificationRate As Integer
Dim filter As Object
Dim active As Boolean
 
instance.ChangeEventSubscription(handle, notificationRate, filter, active)
void ChangeEventSubscription( 
   int handle,
   int notificationRate,
   object filter,
   bool active
)
void ChangeEventSubscription( 
   int handle,
   int notificationRate,
   Object^ filter,
   bool active
) 

Parameters

handle
Event subscription handle as returned by the SubscribeEvents method
notificationRate
The requested notification rate. The notification rate is in milliseconds and tells the server how often to send event notifications. This is a minimum time - do not send event notifications any faster that this UNLESS the buffer size is reached. A value of 0 for notification rate means that the server should send event notifications as soon as it gets them. This parameter is used to improve communications efficiency between client and server. This parameter is a recommendation from the client, and the server is allowed to ignore the parameter.
filter
An OpcLabs.EasyOpc.AlarmsAndEvents.AESubscriptionFilter that determines the filtering criteria to be used for the event subscription.

The value of this parameter cannot be null (Nothing in Visual Basic).

active
Activates or deactivates the subscription. If the client deactivates the subscription, then the server will no longer send event notifications to the client based on that subscription, and has no responsibility to buffer or maintain the event notifications. Thus, event notifications may be lost. Even if the subscription is inactive, the Refresh method will still function. In effect, this allows a client to obtain current condition states from time to time (by invoking Refresh) without the need to process event notifications in "real time".
Exceptions
ExceptionDescription

One of the arguments provided to a method is not valid.

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.

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.

Remarks

The user-defined state, as given when subscribing to the events, cannot be changed.

When you use this method, the OpcLabs.EasyOpc.AlarmsAndEvents.OperationModel.EasyAENotificationEventArgs.Arguments in the event notifications and callbacks may, during the transition period, correspond to an improper (older or newer) value.

This member or type is for use from COM. It is not meant to be used from .NET or Python. Refer to the corresponding .NET member or type instead, if you are developing in .NET or Python.

Example

COM

Rem This example shows how to change the notification rate of an existing subscription.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.

Option Explicit

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient")
WScript.ConnectObject Client, "Client_"

WScript.Echo "Subscribing..."
Dim ServerDescriptor: Set ServerDescriptor = CreateObject("OpcLabs.EasyOpc.ServerDescriptor")
ServerDescriptor.ServerClass = "OPCLabs.KitEventServer.2"
Dim SubscriptionParameters: Set SubscriptionParameters = CreateObject("OpcLabs.EasyOpc.AlarmsAndEvents.AESubscriptionParameters")
SubscriptionParameters.NotificationRate = 500
Dim handle: handle = Client.SubscribeEvents(ServerDescriptor, SubscriptionParameters, True, Nothing)

WScript.Echo "Waiting for 10 seconds..."
WScript.Sleep 10*1000

WScript.Echo "Changing subscription..."
Client.ChangeEventSubscription handle, 5*1000, SubscriptionParameters.Filter, True

WScript.Echo "Waiting for 50 seconds..."
WScript.Sleep 50*1000

Client.UnsubscribeEvents handle



Rem Notification event handler
Sub Client_Notification(Sender, e)
    If Not (e.Succeeded) Then
        WScript.Echo "*** Failure: " & e.ErrorMessageBrief
        Exit Sub
    End If

    If Not e.EventData Is Nothing Then WScript.Echo e.EventData.Message
End Sub
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