From f82cb11a0ac571dc7afd3ec339324000a25207c0 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 28 八月 2023 19:32:23 +0800
Subject: [PATCH] 修改提示语
---
pkg/plc/plc4x.go | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/pkg/plc/plc4x.go b/pkg/plc/plc4x.go
index d38ac67..e52f193 100644
--- a/pkg/plc/plc4x.go
+++ b/pkg/plc/plc4x.go
@@ -46,8 +46,8 @@
return conn, nil
}
}
- // 鍒涘缓涓�涓笂涓嬫枃锛屽苟璁剧疆 5 绉掕秴鏃�
- ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ // 鍒涘缓涓�涓笂涓嬫枃锛屽苟璁剧疆 3 绉掕秴鏃�
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
conn, err := NewGetModbusConnection(ctx, ipAddr)
if err != nil {
@@ -101,12 +101,12 @@
}
// 鍒ゆ柇鍝嶅簲鐮佹槸鍚︽纭�
- if readResult.GetResponse().GetResponseCode("tag") != apiModel.PlcResponseCode_OK {
- fmt.Printf("error an non-ok return code: %s", readResult.GetResponse().GetResponseCode("tag").GetName())
+ if readResult.GetResponse().GetResponseCode(tag) != apiModel.PlcResponseCode_OK {
+ fmt.Printf("error an non-ok return code: %s", readResult.GetResponse().GetResponseCode(tag).GetName())
return nil, nil
}
- value := readResult.GetResponse().GetValue("tag")
+ value := readResult.GetResponse().GetValue(tag)
return value.GetRaw(), err
@@ -131,12 +131,12 @@
}
// 鍒ゆ柇鍝嶅簲鐮佹槸鍚︽纭�
- if readResult.GetResponse().GetResponseCode("tag") != apiModel.PlcResponseCode_OK {
- fmt.Printf("error an non-ok return code: %s", readResult.GetResponse().GetResponseCode("tag").GetName())
- return nil, errors.New("error code: " + readResult.GetResponse().GetResponseCode("tag").GetName())
+ if readResult.GetResponse().GetResponseCode(tag) != apiModel.PlcResponseCode_OK {
+ fmt.Printf("error an non-ok return code: %s", readResult.GetResponse().GetResponseCode(tag).GetName())
+ return nil, errors.New("error code: " + readResult.GetResponse().GetResponseCode(tag).GetName())
}
- value := readResult.GetResponse().GetValue("tag")
+ value := readResult.GetResponse().GetValue(tag)
var result []byte
@@ -174,9 +174,9 @@
}
// 鍒ゆ柇鍝嶅簲鐮佹槸鍚︽纭�
- if writeResult.GetResponse().GetResponseCode("tag") != apiModel.PlcResponseCode_OK {
- fmt.Printf("error an non-ok return code: %s", writeResult.GetResponse().GetResponseCode("tag").GetName())
- return "", errors.New("error code: " + writeResult.GetResponse().GetResponseCode("tag").GetName())
+ if writeResult.GetResponse().GetResponseCode(tag) != apiModel.PlcResponseCode_OK {
+ fmt.Printf("error an non-ok return code: %s", writeResult.GetResponse().GetResponseCode(tag).GetName())
+ return "", errors.New("error code: " + writeResult.GetResponse().GetResponseCode(tag).GetName())
}
result := writeResult.GetResponse().String()
--
Gitblit v1.8.0