public override unsafe int AddNotification(string variableName, AdsStream data, int offset, int length, int transMode, int cycleTime, int maxDelay, object userData, out AdsErrorCode result) { result = AdsErrorCode.NoError; int clientHandle = 0; result = base._symbolTable.TryCreateVariableHandle(variableName, out clientHandle); if (result != AdsErrorCode.NoError) { return(0); } uint serverHandle = base._symbolTable.GetServerHandle(clientHandle, out result); if (result != AdsErrorCode.NoError) { return(0); } AdsNotificationAttrib noteAttrib = new AdsNotificationAttrib { cbLength = length, nCycleTime = cycleTime, nMaxDelay = maxDelay, nTransMode = transMode }; int hNotification = 0; int nextClientHandle = 0; if (!base._bInitialized) { this.Init(); } result = base._syncPort.AddDeviceNotification(0xf005, serverHandle, ¬eAttrib, this._adsNotificationDelegate, 0, false, out hNotification); if (result == AdsErrorCode.NoError) { nextClientHandle = this.GetNextClientHandle(); base.AddNotification(hNotification, nextClientHandle, clientHandle, data, offset, length, userData); this._clientHandleTable.Add(nextClientHandle, hNotification); } return(nextClientHandle); }
public override unsafe int AddNotification(uint indexGroup, uint indexOffset, AdsStream data, int offset, int length, int transMode, int cycleTime, int maxDelay, object userData, out AdsErrorCode result) { AdsNotificationAttrib noteAttrib = new AdsNotificationAttrib { cbLength = length, nCycleTime = cycleTime, nMaxDelay = maxDelay, nTransMode = transMode }; int hNotification = 0; int clientHandle = 0; if (!base._bInitialized) { this.Init(); } result = base._syncPort.AddDeviceNotification(indexGroup, indexOffset, ¬eAttrib, this._adsNotificationDelegate, 0, false, out hNotification); if (result == AdsErrorCode.NoError) { clientHandle = this.GetNextClientHandle(); base.AddNotification(hNotification, clientHandle, 0, data, offset, length, userData); this._clientHandleTable.Add(clientHandle, hNotification); } return(clientHandle); }