完善有线方案和无线方案的初始化

This commit is contained in:
yu 2019-05-13 16:52:17 +08:00
parent 77d7fac622
commit 69c9c2d829
5 changed files with 46 additions and 37 deletions

View File

@ -224,5 +224,6 @@
"tcp_port":10090,
"api_port":10086,
"pro_category":1,
"syn_data":true
"syn_data":false,
"syn_extension_Time":false
}

View File

@ -9,5 +9,6 @@
"tcp_port" 程序tcp端口
"api_port" 程序api端口
"pro_category":程序类别 0-有线,1-无线,2-混合
"syn_data" 定时同步数据开关, 0-关,1-开
"syn_data" 定时同步数据开关, false-关,true-开
"syn_extension_Time" 定时获取数据防抖时间开关 进入以及离开时间配置 目前是dpark使用 true为打开,false为关闭

View File

@ -41,6 +41,7 @@ type Conf struct {
APIPORT int `json:"api_port"`
PROCATEGORY int `json:"pro_category"`
SYNDATA bool `json:"syn_data"`
SYNEXTENSIONTIME bool `json:"syn_extension_Time"`
}
//无线 下位机

13
main.go
View File

@ -16,9 +16,15 @@ func main() {
go serial_run()
c := cron.New()
// send_data(CODE1001)
//获取数据防抖处理时间配置
if conf.SYNEXTENSIONTIME {
go getConf()
}
//有线方案,发送全部数据,包括gateway配置
if conf.PROCATEGORY == PRO_CATEGORY_WIRED {
go send_data(CODE1001)
}
//一分钟一次 同步数据
c.AddFunc("0, *, *, *, *, *", func() {
@ -37,7 +43,10 @@ func main() {
// })
c.AddFunc("*/30, *, *, *, *, *", func() {
//dpark客户需要拉取api获取数据防抖时间配置
if conf.SYNEXTENSIONTIME {
getConf()
}
})
c.AddFunc("0, */10, *, *, *, *", savedata_cron)
@ -45,6 +54,7 @@ func main() {
c.AddFunc("0, 0, *, *, *, *", get_weather)
c.Start()
if conf.OPENTCPSETVER {
tcp_port := strconv.Itoa(conf.TCPPORT)
listener, err := net.Listen("tcp", "0.0.0.0:"+tcp_port)
@ -53,7 +63,6 @@ func main() {
return
}
if conf.OPENTCPSETVER {
for {
conn, err := listener.Accept()
if err != nil {

View File

@ -37,9 +37,6 @@ func serial_run() {
Baud: conf.SERIALPORTS_LIST[i].BAUDS,
Parity: PARITY,
ReadTimeout: time.Millisecond * time.Duration(conf.SERIALPORTS_LIST[i].READTIMEOUT),
// ReadTimeout: time.Second * time.Duration(conf.SERIALPORTS_LIST[i].READTIMEOUT),
})
check(err)
defer SERIAL_PORT[i].Close()