1
z8018
2025-03-12 17e4c7e3e7b3ef60d9da6de3b2a39a14a53c38a0
WIDESEAWCS_Server/WIDESEAWCS_Communicator/Omron/OmronEtherNetCommunicator.cs
@@ -71,6 +71,11 @@
        /// </summary>
        public override bool IsConnected => _connected;
        /// <summary>
        /// 是否在写入数据后读取数据确认。
        /// </summary>
        public override bool IsReadAfterWrite { get; set; } = true;
        #endregion Public Member
        #region Constructor Function
@@ -144,6 +149,8 @@
                }
                else
                {
                    if (IsReadAfterWrite)
                    {
                    object? obj = null;
                    for (int i = 0; i < 5; i++)
                    {
@@ -162,6 +169,11 @@
                    }
                    stringBuilder.AppendLine(string.Format(CommunicationExceptionMessage.WriteAndReadCheckFaild, address, value, obj));
                    throw new CommunicationException(stringBuilder.ToString(), CommunicationErrorType.WriteFailed);
                    }
                    else
                    {
                        return true;
                    }
                }
            }
            catch (Exception ex)
@@ -586,6 +598,8 @@
                stringBuilder.AppendLine(string.Format(CommunicationInfoMessage.WriteData, address, JsonConvert.SerializeObject(value)));
                if (operateResult.IsSuccess)
                {
                    if (IsReadAfterWrite)
                    {
                    object? obj = null;
                    for (int i = 0; i < 5; i++)
                    {
@@ -616,6 +630,11 @@
                }
                else
                {
                        return true;
                    }
                }
                else
                {
                    throw new CommunicationException(string.Format(CommunicationExceptionMessage.WriteFailedException, typeof(T).Name, address, JsonConvert.SerializeObject(value), operateResult.Message), CommunicationErrorType.WriteFailed);
                }
            }