internal NotificationSymbolInfo(ISymbol symbol, int handle, SymbolNotificationType notificationType, NotificationSettings settings) { this.Symbol = symbol; this.NotificationType = notificationType; this.Handle = handle; this.Settings = settings; }
public override void OnRegisterNotification(ISymbol symbol, SymbolNotificationType type, INotificationSettings settings) { if (symbol == null) { throw new ArgumentNullException("symbol"); } if (settings == null) { throw new ArgumentNullException("settings"); } NotificationSettings settings2 = null; if (!this._notificationTable.TryGetRegisteredNotificationSettings(symbol, out settings2)) { this.RegisterNotification(symbol, type, (NotificationSettings)settings); } else if (settings2.CompareTo(settings) >= 0) { this.RegisterNotification(symbol, type, settings2); } else { this.UnregisterNotification(symbol, type); this.RegisterNotification(symbol, type, (NotificationSettings)settings); } }
private void onAdsNotification(ISymbol symbol, AdsNotificationEventArgs args) { byte[] rawValue = null; DateTime utcTwinCATTime = DateTime.FromFileTimeUtc(args.TimeStamp); DateTime utcNow = DateTime.UtcNow; DataType dataType = (DataType)symbol.DataType; object obj2 = this._syncNotification; lock (obj2) { int byteSize = symbol.ByteSize; byte[] destinationArray = new byte[byteSize]; Array.Copy(args.DataStream.GetBuffer(), args.Offset, destinationArray, 0, byteSize); rawValue = destinationArray; } SymbolNotificationType notificationType = this._notificationTable.GetNotificationType(symbol); if ((notificationType & SymbolNotificationType.RawValue) == SymbolNotificationType.RawValue) { this.OnRawValueChanged(symbol, rawValue, utcTwinCATTime, utcNow); } if ((notificationType & SymbolNotificationType.Value) == SymbolNotificationType.Value) { this.OnValueChanged(symbol, rawValue, utcTwinCATTime, utcNow); } }
public override void OnUnregisterNotification(ISymbol symbol, SymbolNotificationType type) { if (symbol == null) { throw new ArgumentNullException("symbol"); } this.UnregisterNotification(symbol, type); }
public override void OnUnregisterNotification(ISymbol symbol, SymbolNotificationType type) { IAccessorNotification notification = this._inner as IAccessorNotification; if (this._inner == null) { throw new ValueAccessorException($"Accessor '{this._inner}' doesn't support INotificationAccessor", this._inner); } notification.OnUnregisterNotification(symbol, type); }
internal SymbolNotificationType GetNotificationType(ISymbol symbol) { SymbolNotificationType none = SymbolNotificationType.None; NotificationSymbolInfo info = null; object obj2 = this._sync; lock (obj2) { if (this._notificationSymbolDict.TryGetValue(symbol, out info)) { none = info.NotificationType; } } return(none); }
internal void Update(ISymbol symbol, SymbolNotificationType type, NotificationSettings settings) { NotificationSymbolInfo info = null; object obj2 = this._sync; lock (obj2) { if (!this._notificationSymbolDict.TryGetValue(symbol, out info)) { throw new ArgumentException("Symbol is not registered for Notifications!"); } info.Settings = settings; info.NotificationType |= type; } }
internal void Add(ISymbol symbol, int handle, SymbolNotificationType notificationType, NotificationSettings settings) { NotificationSymbolInfo info = null; object obj2 = this._sync; lock (obj2) { if (this._notificationHandleDict.TryGetValue(handle, out info)) { throw new ArgumentException("Symbol already registered!"); } NotificationSymbolInfo info2 = new NotificationSymbolInfo(symbol, handle, notificationType, settings); this._notificationHandleDict.Add(handle, info2); this._notificationSymbolDict.Add(symbol, info2); } }
private bool UnregisterNotification(ISymbol symbol, SymbolNotificationType type) { if (symbol == null) { throw new ArgumentNullException("symbol"); } if (this.Connection == null) { throw new AdsException("Connection not established!"); } bool flag = false; int handle = 0; if (this._notificationTable.TryGetNotificationHandle(symbol, out handle)) { flag = this._notificationTable.Remove(symbol, type); if (flag) { AdsConnectionRestore restore = new AdsConnectionRestore(this); try { this.Connection.DeleteDeviceNotification(handle); } catch (AdsErrorException exception) { Module.Trace.TraceError(exception); flag = false; } finally { if (restore != null) { restore.Dispose(); } } } } int largestSymbolSize = this._notificationTable.GetLargestSymbolSize(); this.resizeNotificationStream(largestSymbolSize); return(flag); }
internal bool Remove(ISymbol symbol, SymbolNotificationType notificationType) { bool flag = false; NotificationSymbolInfo info = null; object obj2 = this._sync; lock (obj2) { if (this._notificationSymbolDict.TryGetValue(symbol, out info)) { SymbolNotificationType type = SymbolNotificationType.Both & ~notificationType; info.NotificationType &= type; if (info.NotificationType == SymbolNotificationType.None) { this._notificationHandleDict.Remove(info.Handle); flag = this._notificationSymbolDict.Remove(symbol); } } } return(flag); }
private void RegisterNotification(ISymbol symbol, SymbolNotificationType type, NotificationSettings settings) { if (symbol == null) { throw new ArgumentNullException("symbol"); } if (this.Connection == null) { throw new AdsException("Connection not established!"); } int byteSize = symbol.ByteSize; int length = Math.Max(byteSize, this._notificationTable.GetLargestSymbolSize()); this.resizeNotificationStream(length); if (!this._notificationTable.Contains(symbol)) { IAdsSymbol symbol2 = (IAdsSymbol)Symbol.Unwrap(symbol); ValueAccessMode mode = this.calcAccessMethod(symbol2); int handle = 0; using (new AdsConnectionRestore(this)) { if (mode == ValueAccessMode.IndexGroupOffset) { handle = this.Connection.AddDeviceNotification(symbol2.IndexGroup, symbol2.IndexOffset, this._notificationStream, 0, byteSize, settings.NotificationMode, settings.CycleTime, settings.MaxDelay, symbol); } else { if (mode != ValueAccessMode.Symbolic) { throw new NotSupportedException("Value access mode not supported!"); } handle = this.Connection.AddDeviceNotification(symbol.InstancePath, this._notificationStream, 0, byteSize, settings.NotificationMode, settings.CycleTime, settings.MaxDelay, symbol); } this._notificationTable.Add(symbol, handle, type, settings); return; } } this._notificationTable.Update(symbol, type, settings); }
public abstract void OnUnregisterNotification(ISymbol symbol, SymbolNotificationType type);
public abstract void OnRegisterNotification(ISymbol symbol, SymbolNotificationType type, INotificationSettings settings);