Merge branch 'develop' into mqtt
This commit is contained in:
commit
a80973902c
|
@ -3,4 +3,4 @@ AppMode = debug
|
|||
HttpPort = :8080
|
||||
|
||||
[serial]
|
||||
Name = /dev/tty.usbserial-1410,/dev/ttyS1
|
||||
Name = /dev/tty.usbserial-1410,/dev/ttyS1,/dev/tty.SLAB_USBtoUART
|
|
@ -159,7 +159,7 @@ func (c *CommunicationManageTemplate)CommunicationManageDel() {
|
|||
//--------------组包---------------------------
|
||||
txBuf,ok := v.GenerateGetRealVariables(v.Addr,step)
|
||||
if ok == false{
|
||||
//log.Printf("getVariables false\n")
|
||||
log.Printf("getVariables finish\n")
|
||||
goto LoopCommon
|
||||
}
|
||||
step++
|
||||
|
@ -238,6 +238,12 @@ func (c *CommunicationManageTemplate)CommunicationManageDel() {
|
|||
LoopCommon:
|
||||
}
|
||||
}
|
||||
c.DeviceNodeOnlineCnt = 0
|
||||
for _,v := range c.DeviceNodeMap{
|
||||
if v.CommStatus == "onLine"{
|
||||
c.DeviceNodeOnlineCnt++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,11 @@ func (c *CommunicationSerialTemplate)WriteData(data []byte) int{
|
|||
log.Printf("len is %d\n",len(data))
|
||||
//log.Printf("c %+v\n",c)
|
||||
|
||||
if c.Port == nil{
|
||||
log.Println("serial writeData err")
|
||||
return 0
|
||||
}
|
||||
|
||||
cnt,err := c.Port.Write(data)
|
||||
if err != nil{
|
||||
log.Println(err)
|
||||
|
@ -94,6 +99,10 @@ func (c *CommunicationSerialTemplate)WriteData(data []byte) int{
|
|||
|
||||
func (c *CommunicationSerialTemplate)ReadData(data []byte) int{
|
||||
|
||||
if c.Port == nil{
|
||||
return 0
|
||||
}
|
||||
|
||||
cnt,_ := c.Port.Read(data)
|
||||
|
||||
return cnt
|
||||
|
|
|
@ -570,6 +570,7 @@ func apiGetNodeVariableFromCache(context *gin.Context) {
|
|||
Name string `json:"name"` //变量名
|
||||
Lable string `json:"lable"` //变量标签
|
||||
Value interface{} `json:"value"` //变量值
|
||||
Explain interface{} `json:"explain"`
|
||||
TimeStamp string `json:"timestamp"` //变量时间戳
|
||||
Type string `json:"type"` //变量类型
|
||||
}
|
||||
|
@ -601,9 +602,11 @@ func apiGetNodeVariableFromCache(context *gin.Context) {
|
|||
if len(v.Value) > 0{
|
||||
index = len(v.Value)-1
|
||||
variable.Value = v.Value[index].Value
|
||||
variable.Explain = v.Value[index].Explain
|
||||
variable.TimeStamp = v.Value[index].TimeStamp
|
||||
}else{
|
||||
variable.Value = ""
|
||||
variable.Explain = ""
|
||||
variable.TimeStamp = ""
|
||||
}
|
||||
variable.Type = v.Type
|
||||
|
|
2
main.go
2
main.go
|
@ -63,7 +63,7 @@ func main() {
|
|||
str := fmt.Sprintf("/%d */%d * * * ?",v.PollPeriod%60,v.PollPeriod/60)
|
||||
log.Printf("str %+v\n",str)
|
||||
|
||||
cronGetNetStatus.AddFunc("* */1 * * * *", CommunicationManage.CommunicationManagePoll)
|
||||
cronGetNetStatus.AddFunc("*/60 * * * * *", CommunicationManage.CommunicationManagePoll)
|
||||
|
||||
go CommunicationManage.CommunicationManageDel()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue