/// <summary> /// 创建Socket结果回调 /// </summary> /// <param name="ar"></param> void AsyncCallback(IAsyncResult ar) { if (Client != null && Client.Connected) { IsSuccess = true; listSands.Clear(); socketId = DateTime.Now.ToString(); ModbusLinkSuccess?.Invoke(this.Name, $"{Name}链接成功"); //Finit(); // 心跳包保证链接 //Task.Run(() => //{ // while (Client != null && Client.Connected && IsSuccess) // { // Finit(); // Thread.Sleep(2000); // } //}); } else { IsSuccess = false; } }
/// <summary> /// 保持通信请求 /// </summary> private void Finit() { ModbusLinkSuccess?.Invoke(this.Name, $"{Name}链接中"); F05(PLCSite.M(0), true, null); }