| | |
| | | /// </summary> |
| | | public override bool IsConnected => _connected; |
| | | |
| | | /// <summary> |
| | | /// 是否在写入数据后读取数据确认。 |
| | | /// </summary> |
| | | public override bool IsReadAfterWrite { get; set; } = true; |
| | | |
| | | #endregion Public Member |
| | | |
| | | #region Constructor Function |
| | |
| | | } |
| | | else |
| | | { |
| | | if (IsReadAfterWrite) |
| | | { |
| | | object? obj = null; |
| | | for (int i = 0; i < 5; i++) |
| | | { |
| | |
| | | } |
| | | stringBuilder.AppendLine(string.Format(CommunicationExceptionMessage.WriteAndReadCheckFaild, address, value, obj)); |
| | | throw new CommunicationException(stringBuilder.ToString(), CommunicationErrorType.WriteFailed); |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public override void Dispose() |
| | | { |
| | | _isPing = false; |
| | |
| | | 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++) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | throw new CommunicationException(string.Format(CommunicationExceptionMessage.WriteFailedException, typeof(T).Name, address, JsonConvert.SerializeObject(value), operateResult.Message), CommunicationErrorType.WriteFailed); |
| | | } |
| | | } |