| | |
| | | for (int i = 0; i < 5; i++) |
| | | { |
| | | T readValue = Read<T>(address); |
| | | stringBuilder.AppendLine(string.Format(CommunicationInfoMessage.WriteAfterRead, readValue, value)); |
| | | stringBuilder.AppendLine(string.Format(CommunicationInfoMessage.WriteAfterRead, address, value)); |
| | | obj = readValue; |
| | | if (readValue.Equals(value)) |
| | | { |
| | |
| | | { |
| | | LogNet.WriteInfo(Name, stringBuilder.ToString()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | //实例化一个西门子的S7协议的通讯对象 |
| | | plc = new SiemensS7Net(SiemensPLCS.S1500) |
| | | { |
| | |
| | | catch (Exception ex) |
| | | { |
| | | //写入异常时抛出自定义通讯异常类 |
| | | throw new CommunicationException($"写入数据异常,地址:【{address}】,错误信息: {ex.Message}", CommunicationErrorType.ReadFailed, innerException: ex); |
| | | throw new CommunicationException($"写入数据异常,地址:【{address}】,错误信息: {ex.Message}", CommunicationErrorType.WriteFailed, innerException: ex); |
| | | } |
| | | } |
| | | |
| | |
| | | LogNet.WriteException(Name, $"【{Name}】PLC读取异常,地址:【{address}】,错误信息:【{ex.Message}】", ex); |
| | | throw new CommunicationException(ex.Message, CommunicationErrorType.ReadException, innerException: ex); |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | |
| | |
| | | { |
| | | LogNet.WriteInfo(Name, stringBuilder.ToString()); |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | |