From 17e4c7e3e7b3ef60d9da6de3b2a39a14a53c38a0 Mon Sep 17 00:00:00 2001 From: z8018 <1282578289@qq.com> Date: 星期三, 12 三月 2025 14:11:33 +0800 Subject: [PATCH] 1 --- WIDESEAWCS_Server/WIDESEAWCS_Communicator/Inovance/InovanceTcpCommunicator.cs | 40 ++++++++++++++++++++++++++-------------- 1 files changed, 26 insertions(+), 14 deletions(-) diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Inovance/InovanceTcpCommunicator.cs b/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Inovance/InovanceTcpCommunicator.cs index fef7815..ca116fa 100644 --- a/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Inovance/InovanceTcpCommunicator.cs +++ b/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Inovance/InovanceTcpCommunicator.cs @@ -53,6 +53,11 @@ /// 鑾峰彇褰撳墠閫氳鍣ㄦ槸鍚﹀凡杩炴帴鍒癙LC銆� /// </summary> public override bool IsConnected => _connected; + + /// <summary> + /// 鏄惁鍦ㄥ啓鍏ユ暟鎹悗璇诲彇鏁版嵁纭銆� + /// </summary> + public override bool IsReadAfterWrite { get; set; } = true; #endregion #region Constructor Function @@ -126,24 +131,31 @@ } else { - object? obj = null; - for (int i = 0; i < 5; i++) + if (IsReadAfterWrite) { - T readValue = Read<T>(address); - stringBuilder.AppendLine(string.Format(CommunicationInfoMessage.WriteAfterRead, readValue, value)); - obj = readValue; - if (readValue.Equals(value)) + object? obj = null; + for (int i = 0; i < 5; i++) { - stringBuilder.AppendLine(string.Format(CommunicationInfoMessage.WriteAndReadCheckSuccess, address, value, readValue)); - return true; + T readValue = Read<T>(address); + stringBuilder.AppendLine(string.Format(CommunicationInfoMessage.WriteAfterRead, readValue, value)); + obj = readValue; + if (readValue.Equals(value)) + { + stringBuilder.AppendLine(string.Format(CommunicationInfoMessage.WriteAndReadCheckSuccess, address, value, readValue)); + return true; + } + else if (i < 4) + { + Write(address, value); + } } - else if (i < 4) - { - Write(address, value); - } + stringBuilder.AppendLine(string.Format(CommunicationExceptionMessage.WriteAndReadCheckFaild, address, value, obj)); + throw new CommunicationException(stringBuilder.ToString(), CommunicationErrorType.WriteFailed); } - stringBuilder.AppendLine(string.Format(CommunicationExceptionMessage.WriteAndReadCheckFaild, address, value, obj)); - throw new CommunicationException(stringBuilder.ToString(), CommunicationErrorType.WriteFailed); + else + { + return true; + } } } catch (Exception ex) -- Gitblit v1.9.3