Example #1
0
        /// <summary>
        /// This method will be called if plc connection changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _client_OnConnectionChange(object sender, Dacs7.PlcConnectionNotificationEventArgs e)
        {
            PlcConnectionChanged?.Invoke(_subscribers.Keys.ToList(), e.IsConnected);

            if (!e.IsConnected && _reconnectOnConnectionLost)
            {
                Reconnect();
            }
        }
Example #2
0
 /// <summary>
 /// Add subscriber to plc connection changed notification
 /// </summary>
 /// <param name="subscriberId"></param>
 public void AddConnectionSubscriber(string subscriberId)
 {
     if (!_subscribers.ContainsKey(subscriberId))
     {
         if (_subscribers.TryAdd(subscriberId, null))
         {
             //Initial callback
             PlcConnectionChanged?.Invoke(new List <string> {
                 subscriberId
             }, _client.IsConnected);
         }
     }
 }