Пример #1
0
        /// <summary>
        /// Protocol handler connection status has changed.
        /// </summary>
        /// <param name="sender">The protocol handler.</param>
        /// <param name="e"><see cref="ConnectionStateChangedEventArgs"/> with information about the connection state change.</param>
        private void ProtocolHandler_ConnectionStateChanged(object sender, ConnectionStateChangedEventArgs e)
        {
            if (!e.Connected)
            {
                Log.Info($"Connection disconnected");
                this.keepEventThreadAlive = false;
                CommandData cmd;
                while (this.commandQueue.TryDequeue(out cmd))
                {
                    Log.Info($"Clearing command from queue due to disconnect {cmd}");
                }

                this.CommunicationFailure?.Invoke(this, new CommunicationFailureEventArgs(FailureType.Disconnect, $"Device disconnected"));
            }
            else
            {
                this.commTimeoutTimer.Stop();
                this.commTimeoutTimer.Start();
            }
        }
Пример #2
0
 /// <summary>
 /// Handles a connection state change in the communication channel.
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event data.</param>
 private void CommunicationChannel_ConnectionStateChanged(object sender, ConnectionStateChangedEventArgs e)
 {
     this.ConnectionStateChanged?.Invoke(this, e);
 }