From 98ea38910b2795c86023c54b83d70030c7bb08c5 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 16 九月 2023 22:06:18 +0800
Subject: [PATCH] 更改:UINT to DINT

---
 api/v1/plc.go |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/api/v1/plc.go b/api/v1/plc.go
index 3ed79a8..5f3b279 100644
--- a/api/v1/plc.go
+++ b/api/v1/plc.go
@@ -6,10 +6,8 @@
 	"apsClient/model/response"
 	_ "apsClient/model/response"
 	"apsClient/pkg/contextx"
-	"apsClient/pkg/ecode"
-	"apsClient/pkg/plc"
+	"apsClient/pkg/plc/apacheplc4x"
 	"apsClient/service"
-	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/spf13/cast"
 )
@@ -29,21 +27,15 @@
 	if !ok {
 		return
 	}
-	finishNumber, _ := service.PlcCacheGet(constvar.PlcCacheKeyFinishNumber)
-	totalNumber, _ := service.PlcCacheGet(constvar.PlcCacheKeyTotalNumber)
+	finishNumber, _ := service.PlcCacheGet(params.Position, constvar.PlcCacheKeyFinishNumber)
+	totalNumber, _ := service.PlcCacheGet(params.Position, constvar.PlcCacheKeyTotalNumber)
 	resp := new(response.ProductProgress)
 	resp.FinishNumber = cast.ToInt(finishNumber)
 	resp.TotalNumber = cast.ToInt(totalNumber)
 
-	plcConfig, code := service.NewDevicePlcService().GetDevicePlc()
-	if code != ecode.OK {
-		return
-	}
 	plcStatus := 1 //鏂紑杩炴帴
-	ipAddr := fmt.Sprintf("%s:%v", plcConfig.Address, plcConfig.Port)
-
-	conn, err := plc.GetModbusConnection(ipAddr)
-	if err == nil && conn.IsConnected() {
+	isConnect := apacheplc4x.IsConnect()
+	if isConnect {
 		if resp.FinishNumber > 0 { //鐢熶骇
 			plcStatus = 2
 		} else { //寰呮満

--
Gitblit v1.8.0