| | |
| | | "apsClient/model/response" |
| | | _ "apsClient/model/response" |
| | | "apsClient/pkg/contextx" |
| | | "apsClient/pkg/ecode" |
| | | "apsClient/pkg/plc" |
| | | "apsClient/service" |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/spf13/cast" |
| | | ) |
| | |
| | | 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() { |
| | | if resp.FinishNumber > 0 { //生产 |
| | | plcStatus = 2 |
| | | } else { //待机 |
| | | plcStatus = 3 |
| | | } |
| | | } |
| | | resp.PlcStatus = plcStatus |
| | | |
| | | ctx.OkWithDetailed(resp) |
| | | } |
| | | |