def adsSyncAddDeviceNotificationReqEx(<EOL>port, adr, data_name, pNoteAttrib, callback, user_handle=None<EOL>):<EOL>
global callback_store<EOL>if NOTEFUNC is None:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>adsSyncAddDeviceNotificationReqFct = _adsDLL.AdsSyncAddDeviceNotificationReqEx<EOL>pAmsAddr = ctypes.pointer(adr.amsAddrStruct())<EOL>hnl = adsSyncReadWriteReqEx2(<EOL>port, adr, ADSIGRP_SYM_HNDBYNAME, <NUM_LIT>, PLCTYPE_UDINT, data_name, PLCTYPE_STRING<EOL>)<EOL>nIndexGroup = ctypes.c_ulong(ADSIGRP_SYM_VALBYHND)<EOL>nIndexOffset = ctypes.c_ulong(hnl)<EOL>attrib = pNoteAttrib.notificationAttribStruct()<EOL>pNotification = ctypes.c_ulong()<EOL>nHUser = ctypes.c_ulong(hnl)<EOL>if user_handle is not None:<EOL><INDENT>nHUser = ctypes.c_ulong(user_handle)<EOL><DEDENT>adsSyncAddDeviceNotificationReqFct.argtypes = [<EOL>ctypes.c_ulong,<EOL>ctypes.POINTER(SAmsAddr),<EOL>ctypes.c_ulong,<EOL>ctypes.c_ulong,<EOL>ctypes.POINTER(SAdsNotificationAttrib),<EOL>NOTEFUNC,<EOL>ctypes.c_ulong,<EOL>ctypes.POINTER(ctypes.c_ulong),<EOL>]<EOL>adsSyncAddDeviceNotificationReqFct.restype = ctypes.c_long<EOL>def wrapper(addr, notification, user):<EOL><INDENT>return callback(notification, data_name)<EOL><DEDENT>c_callback = NOTEFUNC(wrapper)<EOL>err_code = adsSyncAddDeviceNotificationReqFct(<EOL>port,<EOL>pAmsAddr,<EOL>nIndexGroup,<EOL>nIndexOffset,<EOL>ctypes.byref(attrib),<EOL>c_callback,<EOL>nHUser,<EOL>ctypes.byref(pNotification),<EOL>)<EOL>if err_code:<EOL><INDENT>raise ADSError(err_code)<EOL><DEDENT>callback_store[pNotification.value] = c_callback<EOL>return (pNotification.value, hnl)<EOL>
Add a device notification.

    :param int port: local AMS port as returned by adsPortOpenEx()
    :param pyads.structs.AmsAddr adr: local or remote AmsAddr
    :param string data_name: PLC storage address
    :param pyads.structs.NotificationAttrib pNoteAttrib: notification attributes
    :param callback: Callback function to handle notification
    :param user_handle: User Handle
    :rtype: (int, int)
    :returns: notification handle, user handle