public ServerCycleNotificationMngt(TcAdsSyncPort syncPort, SymbolTable symbolTable, bool synchronize) : base(syncPort, symbolTable, synchronize)
 {
     this._curHandle               = 0;
     this._bPeak                   = false;
     this._bPeakError              = false;
     this._clientHandleTable       = new Dictionary <int, int>();
     this._enqueueEvent            = new ManualResetEvent(false);
     this._queue                   = new Queue <QueueElement>(500);
     this._adsNotificationDelegate = new TcAdsDllWrapper.AdsNotificationDelegate(this.OnNotification);
 }
Example #2
0
 public NotificationMngt(TcAdsSyncPort syncPort, SymbolTable symbolTable, bool synchronize)
 {
     if (synchronize)
     {
         this._syncWindow = new SyncWindow(syncPort, this);
     }
     this._bSynchronize      = synchronize;
     this._symbolTable       = symbolTable;
     this._syncPort          = syncPort;
     this._bInitialized      = false;
     this._notificationTable = new Dictionary <int, NotificationEntry>();
     this._exceptionQueue    = new Queue <Exception>(10);
     this._errorEvent        = new AutoResetEvent(false);
 }
Example #3
0
 public ClientCycleNotificationMngt(TcAdsSyncPort syncPort, SymbolTable symbolTable, bool synchronize) : base(syncPort, symbolTable, synchronize)
 {
     this._bSumupRead = false;
     this._bStopTimer = false;
     this._curHandle  = 0;
     if (synchronize)
     {
         this._timer = new WindowsFormTimer();
     }
     else
     {
         this._timer = new ThreadTimer();
     }
 }
Example #4
0
        public void CloseSyncPort(TcAdsSyncPort syncPort)
        {
            object obj2 = s_instLock;

            lock (obj2)
            {
                this._syncPortDict.Remove(syncPort.Id);
                object[] args = new object[] { syncPort.Id };
                Module.Trace.TraceVerbose("SyncPort {0} removed!", args);
                syncPort.Dispose();
                int num = this._refCount - 1;
                this._refCount = num;
                if (num == 0)
                {
                    base.Dispose();
                }
            }
        }
Example #5
0
        public TcAdsSyncPort CreateSyncPort(AmsAddress addr, INotificationReceiver iNoteReceiver, bool clientCycle, bool synchronize)
        {
            object obj2 = s_instLock;

            lock (obj2)
            {
                TcAdsSyncPort target = !this._routerPort ? new TcAdsSyncPort(addr, this, iNoteReceiver, clientCycle, synchronize) : new TcAdsSyncPortRouter(addr, this, iNoteReceiver, clientCycle, synchronize);
                target.Connect();
                WeakReference reference = new WeakReference(target, false);
                this._syncPortDict.Add(target.Id, reference);
                object[] args = new object[] { target.Id };
                Module.Trace.TraceVerbose("SyncPort {0} added!", args);
                this.AddRef();
                if (!this._routerNotificationsRegistered && (this._routerNotificationTimer == null))
                {
                    this._routerNotificationTimer          = new ThreadTimer();
                    this._routerNotificationTimer.Interval = 50;
                    this._routerNotificationTimer.Tick    += new EventHandler(this._routerNotificationTimer_Tick);
                    this._routerNotificationTimer.Enabled  = true;
                }
                return(target);
            }
        }
Example #6
0
        public void OnRouterNotification(AmsRouterState state)
        {
            IList <WeakReference> list = null;
            object obj2 = s_instLock;

            lock (obj2)
            {
                this._routerState = state;
                list = new List <WeakReference>(this._syncPortDict.Values);
            }
            try
            {
                foreach (WeakReference reference in list)
                {
                    if (!reference.IsAlive)
                    {
                        continue;
                    }
                    TcAdsSyncPort target = (TcAdsSyncPort)reference.Target;
                    if (target != null)
                    {
                        if (!target.IsDisposed)
                        {
                            target.OnRouterNotification(this._routerState);
                            continue;
                        }
                        string message = $"SyncPort '{target.Id}' is already disposed!";
                        Module.Trace.TraceWarning(message);
                    }
                }
            }
            catch (Exception exception)
            {
                Module.Trace.TraceError(exception);
            }
        }