/// <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 override uint AddNotification(uint varHandle, uint length, AdsTransmissionMode transmissionMode, uint cycleTime, object userData, Type TypeOfValue) { AdsNotification note = new AdsNotification(); note.Symhandle = varHandle; note.UserData = userData; note.TypeOfValue = TypeOfValue; note.ByteValue = new byte[length]; NotificationRequests.Add(note); string varName = GetNameBySymhandle(varHandle); byte[] buffer = new byte[length]; adsStream = Activator.CreateInstance(t_AdsStream, new object[] { buffer }); if (transmissionMode == AdsTransmissionMode.Cyclic) { adsTransMode = AdsTransMode_Cyclic; } else { adsTransMode = AdsTransMode_OnChange; } note.NotificationHandle = (uint)client.AddDeviceNotification( varName, adsStream, (int)0, (int)length, adsTransMode, (int)cycleTime, (int)0, userData); return(note.NotificationHandle); }
public uint AddNotification <T>(string varName, AdsTransmissionMode transmissionMode, uint cycleTime, object userData = null) { var varHandle = GetSymhandleByName(varName); uint length = GenericHelper.GetByteLengthFromType <T>(DefaultStringLength); return(AddNotification(varHandle, length, transmissionMode, cycleTime, userData, typeof(T))); }
public async Task <uint> AddNotificationAsync <T>(string varName, AdsTransmissionMode transmissionMode, uint cycleTime, uint arraylength = 1, object userData = null) { uint varHandle = await GetSymhandleByNameAsync(varName); var length = GenericHelper.GetByteLengthFromType <T>(DefaultStringLength, arraylength); var result = await AddNotificationAsync(varHandle, length, transmissionMode, cycleTime, userData, typeof(T)); return(result); }
public AdsAddDeviceNotificationCommand(uint indexGroup, uint indexOffset, uint readLength, AdsTransmissionMode transmissionMode) : base(AdsCommandId.AddDeviceNotification) { this.readLength = readLength; this.indexGroup = indexGroup; this.indexOffset = indexOffset; this.transmissionMode = transmissionMode; this.notification = new AdsNotification(); }
/// <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);; }
public uint AddNotification <T>(IAdsSymhandle adsSymhandle, AdsTransmissionMode transmissionMode, uint cycleTime, object userData) { return(AddNotification <T>(adsSymhandle.Symhandle, transmissionMode, cycleTime, userData)); }
public uint AddNotification(IAdsSymhandle adsSymhandle, AdsTransmissionMode transmissionMode, uint cycleTime, object userData, Type TypeOfValue) { return(AddNotification(adsSymhandle.Symhandle, adsSymhandle.ByteLength, transmissionMode, cycleTime, userData, TypeOfValue)); }
/// <summary> /// Add a noticiation when a variable changes or cyclic after a defined time in ms /// </summary> /// <typeparam name="T">Type for defining the length of the data that must be send by the notification</typeparam> /// <param name="varHandle">The handle returned by GetSymhandleByNameAsync</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> /// <returns></returns> public uint AddNotification <T>(uint varHandle, AdsTransmissionMode transmissionMode, uint cycleTime, object userData) { uint length = GenericHelper.GetByteLengthFromType <T>(DefaultStringLength); return(AddNotification(varHandle, length, transmissionMode, cycleTime, userData, typeof(T))); }
/// <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> /// <returns>The notification handle</returns> public uint AddNotification(uint varHandle, uint length, AdsTransmissionMode transmissionMode, uint cycleTime, object userData) { return(AddNotification(varHandle, length, transmissionMode, cycleTime, userData, typeof(byte[]))); }
/// <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 override uint AddNotification(uint varHandle, uint length, AdsTransmissionMode transmissionMode, uint cycleTime, object userData, Type TypeOfValue) { AdsNotification note = new AdsNotification(); note.Symhandle = varHandle; note.UserData = userData; note.TypeOfValue = TypeOfValue; note.ByteValue = new byte[length]; NotificationRequests.Add(note); string varName = GetNameBySymhandle(varHandle); byte[] buffer = new byte[length]; adsStream = Activator.CreateInstance(t_AdsStream, new object[] { buffer }); if (transmissionMode == AdsTransmissionMode.Cyclic) adsTransMode = AdsTransMode_Cyclic; else adsTransMode = AdsTransMode_OnChange; note.NotificationHandle = (uint)client.AddDeviceNotification( varName, adsStream, (int)0, (int)length, adsTransMode, (int)cycleTime, (int)0, userData); return note.NotificationHandle; }
public Task <uint> AddNotificationAsync(IAdsSymhandle adsSymhandle, AdsTransmissionMode transmissionMode, uint cycleTime, object userData) { return(AddNotificationAsync(adsSymhandle.Symhandle, adsSymhandle.ByteLength, transmissionMode, cycleTime, userData)); }
/// <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> /// <returns>The notification handle</returns> public Task<uint> AddNotificationAsync(uint varHandle, uint length, AdsTransmissionMode transmissionMode, uint cycleTime, object userData) { return AddNotificationAsync(varHandle, length, transmissionMode, cycleTime, userData, typeof(byte[])); }
public override async Task<uint> AddNotificationAsync(uint varHandle, uint length, AdsTransmissionMode transmissionMode, uint cycleTime, object userData, Type typeOfValue) { return await Task.FromResult( AddNotification(varHandle, length, transmissionMode, cycleTime, userData, typeOfValue) ); }
public Task<uint> AddNotificationAsync<T>(IAdsSymhandle adsSymhandle, AdsTransmissionMode transmissionMode, uint cycleTime, object userData) { return AddNotificationAsync<T>(adsSymhandle.Symhandle, transmissionMode, cycleTime, userData); }
public override async Task <uint> AddNotificationAsync(uint varHandle, uint length, AdsTransmissionMode transmissionMode, uint cycleTime, object userData, Type typeOfValue) { return(await Task.FromResult(AddNotification(varHandle, length, transmissionMode, cycleTime, userData, typeOfValue))); }