From 0c7545a03d2525700288760edd26901962bb4f77 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 01 八月 2023 14:37:26 +0800
Subject: [PATCH] 修复重连机制

---
 collector/collector.go |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/collector/collector.go b/collector/collector.go
index e70421d..15c6325 100644
--- a/collector/collector.go
+++ b/collector/collector.go
@@ -89,16 +89,22 @@
 
 			// 鏍规嵁璁剧疆鐨勫湴鍧�鏌ヨ鏁版嵁锛屼笂鎶�
 			plcResponse.Data = make(map[int][]byte, 0)
+			plcResponse.Message = ""
 			for _, addr := range dev.Address {
 				result, err := ReadHoldingRegister(conn, addr)
 				if err != nil {
 					logger.Warn("plc device Read Holding Register error, %s", err.Error())
+					plcResponse.Message = err.Error()
 				} else {
 					plcResponse.Data[addr] = result
 				}
 			}
 
 			msg.SendDeviceLiveData(&plcResponse)
+			if plcResponse.Message != "" {
+				return
+			}
+
 			// 闂撮殧鏃堕棿
 			time.Sleep(time.Duration(dev.Interval) * time.Second)
 		}

--
Gitblit v1.8.0