/// <summary> /// Add a noticiation when a variable changes or cyclic after a defined time in ms /// </summary> /// <param name="varHandle">The handle returned by GetSymhandleByName</param> /// <param name="length">The length of the data that must be send by the notification</param> /// <param name="transmissionMode">On change or cyclic</param> /// <param name="cycleTime">The cyclic time in ms. If used with OnChange, then the value is send once after this time in ms</param> /// <param name="userData">A custom object that can be used in the callback</param> /// <param name="TypeOfValue">The type of the returned notification value</param> /// <returns>The notification handle</returns> public uint AddNotification(uint varHandle, uint length, AdsTransmissionMode transmissionMode, uint cycleTime, object userData, Type TypeOfValue) { var adsCommand = new AdsAddDeviceNotificationCommand(0x0000F005, varHandle, length, transmissionMode); adsCommand.CycleTime = cycleTime; adsCommand.UserData = userData; adsCommand.TypeOfValue = TypeOfValue; var result = adsCommand.Run(this.ams); adsCommand.Notification.NotificationHandle = result.NotificationHandle; return result.NotificationHandle; }
/// <summary> /// Add a noticiation when a variable changes or cyclic after a defined time in ms /// </summary> /// <param name="varHandle">The handle returned by GetSymhandleByNameAsync</param> /// <param name="length">The length of the data that must be send by the notification</param> /// <param name="transmissionMode">On change or cyclic</param> /// <param name="cycleTime">The cyclic time in ms. If used with OnChange, then the value is send once after this time in ms</param> /// <param name="userData">A custom object that can be used in the callback</param> /// <param name="typeOfValue">The type of the returned notification value</param> /// <returns>The notification handle</returns> public async Task <uint> AddNotificationAsync(uint varHandle, uint length, AdsTransmissionMode transmissionMode, uint cycleTime, object userData, Type typeOfValue) { var adsCommand = new AdsAddDeviceNotificationCommand(0x0000F005, varHandle, length, transmissionMode); adsCommand.CycleTime = cycleTime; adsCommand.UserData = userData; adsCommand.TypeOfValue = typeOfValue; var result = await adsCommand.RunAsync(this.ams); adsCommand.Notification.NotificationHandle = result.NotificationHandle; return(result.NotificationHandle);; }