修改:1、修改设备丢包率为0时的bug

This commit is contained in:
pengwang 2020-08-18 21:36:15 +08:00
parent 50bad73285
commit b08eb8a2cf
2 changed files with 6 additions and 3 deletions

View File

@ -4,7 +4,6 @@ import (
"fmt"
"goAdapter/device"
"goAdapter/httpServer"
"goAdapter/mqttClient"
"goAdapter/setting"
"log"
"net/http"
@ -79,7 +78,7 @@ func main() {
cronGetNetStatus.Start()
defer cronGetNetStatus.Stop()
mqttClient.MQTTClient_Init()
//mqttClient.MQTTClient_Init()
/**************httpserver初始化****************/
// 默认启动方式,包含 Logger、Recovery 中间件

View File

@ -116,7 +116,11 @@ func GetDevicePacketLossState(){
deviceCommLossCnt += v.CommTotalCnt-v.CommSuccessCnt
}
}
SystemState.DevicePacketLoss = fmt.Sprintf("%2.1f",float32(deviceCommLossCnt*100.0/deviceCommTotalCnt))
if deviceCommLossCnt == 0{
SystemState.DevicePacketLoss = "0"
}else{
SystemState.DevicePacketLoss = fmt.Sprintf("%2.1f",float32(deviceCommLossCnt*100.0/deviceCommTotalCnt))
}
}
func GetTimeStart(){