From 0718b07276198334437f52aa5c6c07cca2002225 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 10 八月 2023 18:17:32 +0800
Subject: [PATCH] 完善数据上报程序, 添加测试

---
 msg/send.go |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/msg/send.go b/msg/send.go
index 334d112..3e2d822 100644
--- a/msg/send.go
+++ b/msg/send.go
@@ -3,6 +3,7 @@
 import (
 	"encoding/json"
 	"plc-recorder/util"
+	"time"
 
 	"plc-recorder/config"
 	"plc-recorder/logger"
@@ -17,10 +18,37 @@
 	nsqclient.Produce(config.Options.PubPLCDataTopic, b)
 
 	// aps 鍙戝竷
-	if config.Options.ApsPLCDataWebApi != "" {
-		_, err := util.HttpPost(config.Options.ApsPLCDataWebApi, b)
+	if config.Options.PostPLCDataWebApi != "" {
+		_, err := util.HttpPost(config.Options.PostPLCDataWebApi, b)
 		if err != nil {
 			logger.Warn(err.Error())
 		}
 	}
 }
+
+func TestSendDeviceLiveData() {
+	for i := 1; i > 0; i++ {
+
+		countData := util.IntToBytes(123)
+
+		response := PLCResponse{
+			DeviceID:   "0000",
+			DeviceName: "test",
+			DeviceIP:   "0.0.0.0",
+			Online:     true,
+			Message:    "",
+			PLCData: []PLCData{{
+				StartAddress: 100,
+				Length:       1,
+				Type:         "int",
+				FieldName:    "鐢熶骇璁℃暟",
+				RawData:      countData,
+			},
+			},
+		}
+
+		SendDeviceLiveData(&response)
+
+		time.Sleep(3 * time.Second)
+	}
+}

--
Gitblit v1.8.0