添加delete log 机制,添加上传指令返回结果
This commit is contained in:
parent
a2249d1102
commit
68ad6e1fee
|
@ -149,7 +149,7 @@
|
|||
"device":"yunhorn_kgl_c16_v1_1"
|
||||
},
|
||||
{
|
||||
"adr":"0c0a2017",
|
||||
"adr":"0c2d1319",
|
||||
"location_type":"changing_desk",
|
||||
"location_code":"spao",
|
||||
"location_data":"data12",
|
||||
|
|
|
@ -114,7 +114,7 @@ websocketurl: ["192.168.3.216:8080", "/echo"]
|
|||
post_to_server: "https://smartoilets.cn/ydc/statis/push" #数据收集服务器
|
||||
debug: true #是否打印debug log
|
||||
openserial: false #是否采集串口数据
|
||||
open_tcp_server: true #是否开启TCP端口接收无线数据
|
||||
open_tcp_server: false #是否开启TCP端口接收无线数据
|
||||
check_serial: true
|
||||
dpark_location: "spaoDevs"
|
||||
tcp_port: 10090
|
||||
|
@ -122,7 +122,8 @@ api_port: 10086 #本地web api port
|
|||
pro_category: 1
|
||||
syn_data: false
|
||||
syn_extension_Time: false
|
||||
record_log_path: "" #/usr/local/dpark #无线原始数据收集的log目录
|
||||
record_log_path: "./logs/" #/usr/local/dpark #无线原始数据收集的log目录
|
||||
record_log_retention_time: 10 #default 60 day
|
||||
mqtt_open: false
|
||||
mqtt_keepAlive: 30 #mqtt心跳时间间隔 单位是s
|
||||
mqtt_timeout: 10 #mqtt超时时间 单位s
|
||||
|
@ -132,4 +133,5 @@ mqtt_username: "dpark"
|
|||
mqtt_password: "Jev@nwd0409"
|
||||
|
||||
|
||||
|
||||
#2019/08/16 06:50:00 Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub
|
||||
|
|
|
@ -51,6 +51,7 @@ type Conf struct {
|
|||
SYNDATA bool `json:"syn_data"`
|
||||
SYNEXTENSIONTIME bool `json:"syn_extension_Time"`
|
||||
RECORD_LOG_PATH string `json:"record_log_path"`
|
||||
RECORD_LOG_RETENTION_TIME int `json:"record_log_retention_time"`
|
||||
MQTT_OPEN bool `json:"mqtt_open"`
|
||||
MQTT_BROKER string `json:"mqtt_broker"`
|
||||
MQTT_USERNAME string `json:"mqtt_username"`
|
||||
|
|
71
main.go
71
main.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
|
@ -97,6 +98,10 @@ func main() {
|
|||
}
|
||||
})
|
||||
|
||||
c.AddFunc("0, *, *, *, *, *", func() {
|
||||
ClearLog()
|
||||
})
|
||||
|
||||
// c.AddFunc("*/10, *, *, *, *, *", func() {
|
||||
// devices := []Device{}
|
||||
// log.Println(string(build_data(1001,devices)))
|
||||
|
@ -154,3 +159,69 @@ func check(err error) {
|
|||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func GetAllFile(pathname string) error {
|
||||
// log.Println("begin for folder ", pathname)
|
||||
rd, err := ioutil.ReadDir(pathname)
|
||||
|
||||
sep := string(os.PathSeparator)
|
||||
|
||||
nowtime := time.Now()
|
||||
|
||||
for _, fi := range rd {
|
||||
//",update time:" + fi.ModTime()
|
||||
// log.Printf("file is dir %b name : %s ", fi.IsDir(), fi.Name())
|
||||
|
||||
var duration = nowtime.Sub(fi.ModTime()).Hours()
|
||||
var durationAsInt64 = int(duration) / 24
|
||||
|
||||
if fi.IsDir() {
|
||||
// log.Println("begin in folder", pathname+sep+fi.Name(), fi.ModTime(), durationAsInt64)
|
||||
|
||||
if durationAsInt64 > conf.RECORD_LOG_RETENTION_TIME {
|
||||
log.Println("begin read folder ", pathname+sep+fi.Name())
|
||||
rd2, err2 := ioutil.ReadDir(pathname + sep + fi.Name())
|
||||
if err2 != nil {
|
||||
log.Println("readir fail:", err2)
|
||||
}
|
||||
if len(rd2) == 0 {
|
||||
err3 := os.Remove(pathname + sep + fi.Name())
|
||||
if err3 != nil {
|
||||
log.Println("remove folder fail", pathname+sep+fi.Name(), err3)
|
||||
}
|
||||
// log.Println("delete folder name : %s %d", fi.Name(), len(rd2))
|
||||
}
|
||||
}
|
||||
|
||||
GetAllFile(pathname + fi.Name() + sep)
|
||||
} else {
|
||||
//RECORD_LOG_RETENTION_TIME conf
|
||||
// var duration = nowtime.Sub(loraNode.(LoraNode).TIME).Seconds()
|
||||
// var durationAsInt64 = int(duration)
|
||||
|
||||
log.Println("file name:", fi.Name(), fi.ModTime(), durationAsInt64)
|
||||
|
||||
if durationAsInt64 > conf.RECORD_LOG_RETENTION_TIME {
|
||||
log.Println("delete file name :", fi.Name())
|
||||
err3 := os.Remove(pathname + sep + fi.Name())
|
||||
if err3 != nil {
|
||||
log.Println("remove file fail", pathname+sep+fi.Name(), err3)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func ClearLog() {
|
||||
folder := conf.RECORD_LOG_PATH
|
||||
log.Println("logfile task begin ", folder)
|
||||
if folder != "" && conf.RECORD_LOG_RETENTION_TIME > 0 {
|
||||
err2 := os.MkdirAll(folder, os.ModePerm)
|
||||
if err2 != nil {
|
||||
log.Println(err2)
|
||||
}
|
||||
GetAllFile(folder)
|
||||
}
|
||||
}
|
||||
|
|
24
router.go
24
router.go
|
@ -230,8 +230,24 @@ func dealDatav3(data []byte, loragwip string) string {
|
|||
|
||||
datatype := data[5]
|
||||
|
||||
if datatype == 0 {
|
||||
|
||||
var R_data P1004_6
|
||||
R_data.CODE = 1008
|
||||
R_data.ID = adr
|
||||
//尿布台
|
||||
R_data.VERSION = "sts_hps_3ir"
|
||||
R_data.ONLINE = true
|
||||
R_data.DATA = make(map[string]interface{})
|
||||
R_data.DATA["restart"] = data[6]
|
||||
|
||||
data_bufTmp, _ := json.Marshal(R_data)
|
||||
data_buf := string(data_bufTmp)
|
||||
go post_to_server(data_buf)
|
||||
|
||||
} else if datatype == 1 || datatype == 2 {
|
||||
|
||||
//dpark 1-尿布台 2-吸顶
|
||||
if datatype == 1 || datatype == 2 {
|
||||
|
||||
//过滤无效数据 adr
|
||||
|
||||
|
@ -631,6 +647,12 @@ func get_renliu_api(c *gin.Context) {
|
|||
|
||||
var rl_data EventNotificationAlert
|
||||
|
||||
var debugInt = 2
|
||||
if debugInt > 1 {
|
||||
c.JSON(http.StatusOK, gin.H{"status": http.StatusOK, "data": rl_data})
|
||||
return
|
||||
}
|
||||
|
||||
err := c.Bind(&rl_data)
|
||||
if conf.DEBUG {
|
||||
log.Println(rl_data)
|
||||
|
|
132
tcpserver.go
132
tcpserver.go
|
@ -11,36 +11,34 @@ import (
|
|||
// "go-study/socket/config"
|
||||
"bytes"
|
||||
"strconv"
|
||||
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
* 从loragw的组中获取到范围内的所有node,给符合addr的node发送command
|
||||
**/
|
||||
|
||||
func sendCommand(addr string,command int){
|
||||
func sendCommand(addr string, command int) {
|
||||
log.Println("begin sendCommand")
|
||||
log.Println("yunhorn.loragw.sendCommand|",addr,command)
|
||||
log.Println("yunhorn.loragw.sendCommand|", addr, command)
|
||||
commands := []byte{0x01}
|
||||
byteAddr,ok := sensorMap.Load(addr)
|
||||
if !ok{
|
||||
log.Println("send command fail,invalid addr|",addr)
|
||||
return;
|
||||
byteAddr, ok := sensorMap.Load(addr)
|
||||
if !ok {
|
||||
log.Println("send command fail,invalid addr|", addr)
|
||||
return
|
||||
}
|
||||
|
||||
loraNode,ok := loraNodeMap.Load(addr)
|
||||
if !ok{
|
||||
log.Println("send command fail,invalid addr|",addr)
|
||||
return;
|
||||
loraNode, ok := loraNodeMap.Load(addr)
|
||||
if !ok {
|
||||
log.Println("send command fail,invalid addr|", addr)
|
||||
return
|
||||
}
|
||||
if command == 1{
|
||||
if command == 1 {
|
||||
commands = []byte{0x01}
|
||||
}else if command == 2{
|
||||
} else if command == 2 {
|
||||
commands = []byte{0x02}
|
||||
}else{
|
||||
log.Println("send command fail,invalid command|",command)
|
||||
return;
|
||||
} else {
|
||||
log.Println("send command fail,invalid command|", command)
|
||||
return
|
||||
}
|
||||
|
||||
// strconv.Itoa
|
||||
|
@ -50,23 +48,22 @@ func sendCommand(addr string,command int){
|
|||
|
||||
// log.Println("loragws ",loraNode.(LoraNode).LORA_GWS)
|
||||
|
||||
for _,loragwip := range loraNode.(LoraNode).LORA_GWS{
|
||||
loraconn,ok := loragwMap.Load(loragwip)
|
||||
if ok{
|
||||
log.Println("yunhorn.loragw.begin push tcp command ",buffer.Bytes())
|
||||
for _, loragwip := range loraNode.(LoraNode).LORA_GWS {
|
||||
loraconn, ok := loragwMap.Load(loragwip)
|
||||
if ok {
|
||||
log.Println("yunhorn.loragw.begin push tcp command ", buffer.Bytes())
|
||||
_, err := loraconn.(net.Conn).Write(buffer.Bytes())
|
||||
if err != nil {
|
||||
log.Println("yunhorn.loragw.write msg error!", err)
|
||||
return;
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func handleConn(conn net.Conn) {
|
||||
|
||||
if connTest==nil{
|
||||
if connTest == nil {
|
||||
connTest = conn
|
||||
}
|
||||
|
||||
|
@ -134,22 +131,22 @@ func readConn(conn net.Conn, readChan chan<- []byte, stopChan chan<- bool) {
|
|||
buffer := new(bytes.Buffer)
|
||||
continueCount := 0
|
||||
// log.Println("yunhorndeug.push.data.tcp.reqLen|data",reqLen,data)
|
||||
log.Println("$$$$$$$$$$$$$$$$$$$$$$$$$",data[:reqLen])
|
||||
log.Println("$$$$$$$$$$$$$$$$$$$$$$$$$", data[:reqLen])
|
||||
now := time.Now()
|
||||
// log.Println("yunhorndeug.push.data.tcp.begin handleConn,cliendAddr:", conn.RemoteAddr())
|
||||
|
||||
for i, b := range data[:reqLen] {
|
||||
|
||||
if reqLen<7{
|
||||
if reqLen < 7 {
|
||||
break
|
||||
}
|
||||
|
||||
if continueCount>0{
|
||||
if continueCount > 0 {
|
||||
continueCount--
|
||||
continue;
|
||||
continue
|
||||
}
|
||||
|
||||
if b!=254{
|
||||
if b != 254 {
|
||||
s := strconv.FormatInt(int64(b&0xff), 16)
|
||||
if len(s) == 1 {
|
||||
buffer.WriteString("0")
|
||||
|
@ -157,57 +154,58 @@ func readConn(conn net.Conn, readChan chan<- []byte, stopChan chan<- bool) {
|
|||
buffer.WriteString(s)
|
||||
}
|
||||
|
||||
end :=0
|
||||
end := 0
|
||||
//254为分隔符
|
||||
if b==254 && i>3{
|
||||
addrs := data[i-4:i]
|
||||
if b == 254 && i > 3 {
|
||||
addrs := data[i-4 : i]
|
||||
|
||||
//尿布台数据,地址1位 数据2位
|
||||
dataType := data[i+1]
|
||||
|
||||
//0是通用类型
|
||||
if dataType!=0 && dataType!=1 && dataType!=2 && dataType!=3 && dataType!=4{
|
||||
continue;
|
||||
//0是通用类型 命令交互
|
||||
if dataType != 0 && dataType != 1 && dataType != 2 && dataType != 3 && dataType != 4 {
|
||||
continue
|
||||
}
|
||||
|
||||
values := make([]byte,0)
|
||||
values := make([]byte, 0)
|
||||
|
||||
if dataType ==0{
|
||||
if dataType == 0 {
|
||||
continueCount = 2
|
||||
end = 3
|
||||
}else if dataType == 1 {
|
||||
values = data[i+2 : i+3]
|
||||
} else if dataType == 1 {
|
||||
|
||||
continueCount = 3
|
||||
end = 4
|
||||
|
||||
if i+4>reqLen{
|
||||
log.Println("yunhorndeug.push.data.tcp.fq",buffer.String(),addrs,dataType)
|
||||
if i+4 > reqLen {
|
||||
log.Println("yunhorndeug.push.data.tcp.fq", buffer.String(), addrs, dataType)
|
||||
continue
|
||||
}
|
||||
|
||||
//类型为1 数据量为2
|
||||
values = data[i+2:i+4]
|
||||
values = data[i+2 : i+4]
|
||||
|
||||
}else if dataType == 2{
|
||||
} else if dataType == 2 {
|
||||
//类型为2 数据量位1
|
||||
|
||||
continueCount = 2
|
||||
end = 3
|
||||
|
||||
if i+3 >reqLen{
|
||||
log.Println("yunhorndeug.push.data.tcp.fq",buffer.String(),addrs,dataType)
|
||||
if i+3 > reqLen {
|
||||
log.Println("yunhorndeug.push.data.tcp.fq", buffer.String(), addrs, dataType)
|
||||
continue
|
||||
}
|
||||
values = data[i+2:i+3]
|
||||
}else if dataType ==4 {
|
||||
values = data[i+2 : i+3]
|
||||
} else if dataType == 4 {
|
||||
//空气质量
|
||||
continueCount = 19
|
||||
end = 20
|
||||
if i+end >reqLen{
|
||||
log.Println("yunhorndeug.push.data.tcp.fq",buffer.String(),addrs,dataType)
|
||||
if i+end > reqLen {
|
||||
log.Println("yunhorndeug.push.data.tcp.fq", buffer.String(), addrs, dataType)
|
||||
continue
|
||||
}
|
||||
values = data[i+2:i+end]
|
||||
values = data[i+2 : i+end]
|
||||
// log.Println("pm25data1",data[i+15])
|
||||
// log.Println("pm25data2",data[i+16])
|
||||
// nh3data := uint32(data[i+7])*256+uint32(data[i+8])
|
||||
|
@ -231,16 +229,16 @@ func readConn(conn net.Conn, readChan chan<- []byte, stopChan chan<- bool) {
|
|||
// if err != nil {
|
||||
// log.Println("write msg error!", err)
|
||||
// }
|
||||
}else if dataType ==3{
|
||||
} else if dataType == 3 {
|
||||
continueCount = 2
|
||||
end = 3
|
||||
|
||||
if i+3 >reqLen{
|
||||
log.Println("yunhorndeug.push.data.tcp.fq",buffer.String(),addrs,dataType)
|
||||
if i+3 > reqLen {
|
||||
log.Println("yunhorndeug.push.data.tcp.fq", buffer.String(), addrs, dataType)
|
||||
continue
|
||||
}
|
||||
|
||||
values = data[i+2:i+end]
|
||||
values = data[i+2 : i+end]
|
||||
// values = data[i+2]
|
||||
|
||||
//28 3C 00 00 47 46
|
||||
|
@ -264,11 +262,11 @@ func readConn(conn net.Conn, readChan chan<- []byte, stopChan chan<- bool) {
|
|||
// }
|
||||
}
|
||||
|
||||
log.Println("yunhorndeug.push.data.tcp:",buffer.String(),addrs,dataType,values)
|
||||
log.Println("yunhorndeug.push.data.tcp:", buffer.String(), addrs, dataType, values)
|
||||
|
||||
loraNode,ok := loraNodeMap.Load(buffer.String())
|
||||
if !ok{
|
||||
log.Println("yunhorndeug.push.data.tcp.dev not exist:",buffer.String(),dataType,values)
|
||||
loraNode, ok := loraNodeMap.Load(buffer.String())
|
||||
if !ok {
|
||||
log.Println("yunhorndeug.push.data.tcp.dev not exist:", buffer.String(), dataType, values)
|
||||
buffer = new(bytes.Buffer)
|
||||
continue
|
||||
}
|
||||
|
@ -276,33 +274,31 @@ func readConn(conn net.Conn, readChan chan<- []byte, stopChan chan<- bool) {
|
|||
if !loraNode.(LoraNode).UPDATE_TIME.IsZero() {
|
||||
var duration = now.Sub(loraNode.(LoraNode).UPDATE_TIME).Seconds()
|
||||
var durationAsInt64 = int(duration)
|
||||
if(durationAsInt64<=1){
|
||||
log.Println("repeat.sensor.data:",addrs)
|
||||
continue;
|
||||
if durationAsInt64 <= 1 {
|
||||
log.Println("repeat.sensor.data:", addrs)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
sensorMap.Store(buffer.String(),addrs)
|
||||
|
||||
sensorMap.Store(buffer.String(), addrs)
|
||||
|
||||
buffer = new(bytes.Buffer)
|
||||
|
||||
if conf.RECORD_LOG_PATH!=""{
|
||||
go write_log_channel(data[i-4:i+end])
|
||||
if conf.RECORD_LOG_PATH != "" {
|
||||
go write_log_channel(data[i-4 : i+end])
|
||||
}
|
||||
|
||||
go dealDatav3(data[i-4:i+end],conn.RemoteAddr().String())
|
||||
go dealDatav3(data[i-4:i+end], conn.RemoteAddr().String())
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 转化为字符串
|
||||
// log.Println("yunhorndeug.push.data.tcp.16data:",buffer.String())
|
||||
|
||||
Rdata2 = make([]byte, reqLen)
|
||||
for i,v := range data[:reqLen]{
|
||||
Rdata2[i]=v
|
||||
for i, v := range data[:reqLen] {
|
||||
Rdata2[i] = v
|
||||
}
|
||||
|
||||
// log.Println("===========================yunhorndeug.push.data.tcp.origin.Rdata:",Rdata2)
|
||||
|
|
71
worker.go
71
worker.go
|
@ -1,16 +1,16 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"github.com/tarm/serial"
|
||||
"log"
|
||||
"os"
|
||||
_ "math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
"encoding/json"
|
||||
"time"
|
||||
"bytes"
|
||||
)
|
||||
|
||||
type Devicedatas struct {
|
||||
|
@ -26,9 +26,8 @@ type Device struct {
|
|||
DATA map[string]interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type baseMessage struct{
|
||||
type baseMessage struct {
|
||||
Ip string `json:"ip"`
|
||||
|
||||
}
|
||||
|
||||
//处理通过tcp发送过来的数据
|
||||
|
@ -84,71 +83,67 @@ func yunhorn_xdy_l_v1(data_buf []byte) {
|
|||
}
|
||||
|
||||
//wirte data to log channel
|
||||
func write_log_channel(data []byte){
|
||||
func write_log_channel(data []byte) {
|
||||
logch <- data
|
||||
}
|
||||
|
||||
//get data from log channel and write file
|
||||
func record_log_channel(){
|
||||
func record_log_channel() {
|
||||
|
||||
for {
|
||||
data_buf := <- logch
|
||||
data_buf := <-logch
|
||||
|
||||
addrs := data_buf[:4]
|
||||
|
||||
|
||||
buffer := new(bytes.Buffer)
|
||||
|
||||
for i:=0;i<len(addrs);i++{
|
||||
for i := 0; i < len(addrs); i++ {
|
||||
s := strconv.FormatInt(int64(addrs[i]&0xff), 16)
|
||||
buffer.WriteString(s)
|
||||
}
|
||||
|
||||
|
||||
adr := buffer.String()
|
||||
|
||||
// log.Println("addrs and data",adr,data_buf)
|
||||
|
||||
now := time.Now()
|
||||
|
||||
oldTime,ok := nodeUpdateMap.Load(adr);
|
||||
if(ok){
|
||||
oldTime, ok := nodeUpdateMap.Load(adr)
|
||||
if ok {
|
||||
//have data
|
||||
var duration = now.Sub(oldTime.(time.Time)).Seconds()
|
||||
var durationAsInt64 = int(duration)
|
||||
if(durationAsInt64>1){
|
||||
if durationAsInt64 > 1 {
|
||||
record_log(data_buf)
|
||||
}
|
||||
//same data
|
||||
}else{
|
||||
} else {
|
||||
//not data
|
||||
// log.Println("save adr:",adr)
|
||||
nodeUpdateMap.Store(adr,now)
|
||||
nodeUpdateMap.Store(adr, now)
|
||||
record_log(data_buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//打印原始数据进log
|
||||
func record_log(data_buf []byte){
|
||||
func record_log(data_buf []byte) {
|
||||
time := today
|
||||
folder := conf.RECORD_LOG_PATH+"/"+time
|
||||
err2 :=os.MkdirAll(folder,os.ModePerm)
|
||||
if err2!=nil{
|
||||
folder := conf.RECORD_LOG_PATH + "/" + time
|
||||
err2 := os.MkdirAll(folder, os.ModePerm)
|
||||
if err2 != nil {
|
||||
log.Println(err2)
|
||||
}
|
||||
f, err := os.OpenFile(folder+"/"+time+".log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||
if err != nil{
|
||||
if err != nil {
|
||||
log.Fatalln("HHHHH")
|
||||
}
|
||||
record := log.New(f,"",log.Llongfile)
|
||||
record := log.New(f, "", log.Llongfile)
|
||||
//debugLog.SetPrefix("[Debug]")
|
||||
record.SetFlags(log.Ldate | log.Ltime)
|
||||
record.Println(data_buf)
|
||||
}
|
||||
|
||||
|
||||
func yunhorn_lora_l_v1(data_buf []byte) {
|
||||
|
||||
// for _, i := range conf.RS485DEVICES {
|
||||
|
@ -183,12 +178,12 @@ func yunhorn_lora_l_v1(data_buf []byte) {
|
|||
}
|
||||
|
||||
//发送心跳包
|
||||
func yunhorn_hb_dpark_v1(){
|
||||
func yunhorn_hb_dpark_v1() {
|
||||
|
||||
log.Println("begin yunhorn_hb_dpark_v1")
|
||||
|
||||
// var datalist [len(conf.LORANODES)]LoraNode
|
||||
datalist := make([]LoraNode,len(conf.LORANODES))
|
||||
datalist := make([]LoraNode, len(conf.LORANODES))
|
||||
|
||||
var R_data P1004_6
|
||||
//心跳数据
|
||||
|
@ -199,13 +194,13 @@ func yunhorn_hb_dpark_v1(){
|
|||
R_data.VERSION = "yunhorn_hb_dpark"
|
||||
R_data.ONLINE = true
|
||||
R_data.DATA = make(map[string]interface{})
|
||||
R_data.DATA["data"]=datalist
|
||||
R_data.DATA["data"] = datalist
|
||||
|
||||
for i,v := range conf.LORANODES {
|
||||
loraNode,ok :=loraNodeMap.Load(v.ADR)
|
||||
for i, v := range conf.LORANODES {
|
||||
loraNode, ok := loraNodeMap.Load(v.ADR)
|
||||
if !ok {
|
||||
log.Println("hb load loraNode fail ", ok)
|
||||
continue;
|
||||
continue
|
||||
}
|
||||
newLoraNode := LoraNode{}
|
||||
newLoraNode.CURRENT_DATA = loraNode.(LoraNode).CURRENT_DATA
|
||||
|
@ -215,9 +210,9 @@ func yunhorn_hb_dpark_v1(){
|
|||
newLoraNode.LOCATION_CODE = ""
|
||||
newLoraNode.LOCATION_DATA = loraNode.(LoraNode).LOCATION_DATA
|
||||
newLoraNode.ADR = loraNode.(LoraNode).ADR
|
||||
datalist[i]=newLoraNode
|
||||
datalist[i] = newLoraNode
|
||||
}
|
||||
R_data.TIMESTAMP=time.Now().Unix()
|
||||
R_data.TIMESTAMP = time.Now().Unix()
|
||||
|
||||
data_bufTmp, _ := json.Marshal(R_data)
|
||||
data_buf := string(data_bufTmp)
|
||||
|
@ -254,7 +249,6 @@ func yunhorn_ys_l_v1(data_buf []byte) {
|
|||
demoDevice.DATA["data"+strconv.Itoa(2)] = 0
|
||||
demoDevice.DATA["data"+strconv.Itoa(3)] = 0
|
||||
|
||||
|
||||
if data_int0[0] == 0 && data_int1[0] == 0 && data_type[0] == 0 {
|
||||
demoDevice.DATA["data"+strconv.Itoa(8)] = data_int[0]
|
||||
var device Device
|
||||
|
@ -267,9 +261,9 @@ func yunhorn_ys_l_v1(data_buf []byte) {
|
|||
device.Unlock()
|
||||
DEVICEDATAS.DATA[demoDevice.VERSION+"_1"].DATA["data8"] = data_int[0]
|
||||
} else {
|
||||
if data_int[0] == 0{
|
||||
if data_int[0] == 0 {
|
||||
demoDevice.DATA["data"+strconv.Itoa(7)] = 1
|
||||
}else{
|
||||
} else {
|
||||
demoDevice.DATA["data"+strconv.Itoa(7)] = 0
|
||||
}
|
||||
var device Device
|
||||
|
@ -279,10 +273,9 @@ func yunhorn_ys_l_v1(data_buf []byte) {
|
|||
device.ONLINE = demoDevice.ONLINE
|
||||
device.DATA = make(map[string]interface{})
|
||||
|
||||
|
||||
if data_int[0] == 0{
|
||||
if data_int[0] == 0 {
|
||||
device.DATA["data7"] = 1
|
||||
}else{
|
||||
} else {
|
||||
device.DATA["data7"] = 0
|
||||
}
|
||||
|
||||
|
@ -291,7 +284,7 @@ func yunhorn_ys_l_v1(data_buf []byte) {
|
|||
|
||||
DEVICEDATAS.DATA[demoDevice.VERSION+"_1"].DATA["data7"] = data_int[0]
|
||||
|
||||
// DEVICEDATAS.DATA[demoDevice.VERSION+"_1"].DATA["data7"] = device.DATA["data7"]
|
||||
// DEVICEDATAS.DATA[demoDevice.VERSION+"_1"].DATA["data7"] = device.DATA["data7"]
|
||||
|
||||
}
|
||||
device.DATA = demoDevice.DATA
|
||||
|
|
Loading…
Reference in New Issue