AdsConnection.TryAddDeviceNotification Method (String, Int32, NotificationSettings, Object, UInt32.)

Connects a variable to the ADS client. The ADS client will be notified by the AdsNotification event.

Namespace:  TwinCAT.Ads
Assembly:  TwinCAT.Ads (in TwinCAT.Ads.dll) Version: 6.0.328+39e3229

Syntax

C#

public AdsErrorCode TryAddDeviceNotification(
    string variableName,
    int dataSize,
    NotificationSettings settings,
    Object? userData,
    out uint handle
)

Parameters

variableName

Type: System.String
Name of the variable.

dataSize

Type: System.Int32
Maximum amount of data in bytes to receive with this ADS Notification.

settings

Type: TwinCAT.Ads.NotificationSettings
The notification settings.

userData

Type: System.Object
This object can be used to store user specific data.

handle

Type: System.UInt32.
The notification handle.

Return Value

Type: AdsErrorCode
The ADS ErrorCode.

Implements

IAdsNotifications.TryAddDeviceNotification(String, Int32, NotificationSettings, Object, UInt32.)

Exceptions

Exception

Condition

ObjectDisposedException

Remarks

The

dataSize

Parameter defines the amount of bytes, that will be attached to the AdsNotification as value. Because notifications allocate TwinCAT system resources, a complementary call to TryDeleteDeviceNotification(UInt32) should always be called when the notification is not used anymore.

Reference

AdsConnection Class

TryAddDeviceNotification Overload

TwinCAT.Ads Namespace

AdsConnection.AdsNotification

AdsConnection.TryDeleteDeviceNotification(UInt32)

AddDeviceNotification Overload

AddDeviceNotificationAsync Overload

TryAddDeviceNotification Overload