From 941901954f3be5ed5e54576842f72c8bcf55d8a9 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Sun, 8 Oct 2023 09:41:42 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8D=8A=E5=AE=9E=E7=89=A9=E3=80=81?= =?UTF-8?q?=E5=8A=A8=E5=8A=9B=E5=AD=A6=E5=BC=80=E5=90=AF=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/bj_local.yml | 1 + config/config.go | 1 + config/dev.yml | 1 + config/test_local.yml | 1 + dynamics/udp.go | 6 ++++++ vobc/udp.go | 5 ++++- 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config/bj_local.yml b/config/bj_local.yml index 4ee62df..6bc9d74 100644 --- a/config/bj_local.yml +++ b/config/bj_local.yml @@ -17,6 +17,7 @@ vobc: ip: 10.60.1.59 localPort: 10000 remotePort: 4000 + open: true # 数据源 datasource: diff --git a/config/config.go b/config/config.go index eaa5067..ad35d0f 100644 --- a/config/config.go +++ b/config/config.go @@ -59,6 +59,7 @@ type vobc struct { Ip string LocalPort int RemotePort int + Open bool } var Config AppConfig diff --git a/config/dev.yml b/config/dev.yml index 81f7414..719b521 100644 --- a/config/dev.yml +++ b/config/dev.yml @@ -17,6 +17,7 @@ vobc: ip: 10.60.1.59 localPort: 10000 remotePort: 4000 + open: false # 数据源 datasource: diff --git a/config/test_local.yml b/config/test_local.yml index d0c1e81..18c017d 100644 --- a/config/test_local.yml +++ b/config/test_local.yml @@ -17,6 +17,7 @@ vobc: ip: 10.60.1.59 localPort: 10000 remotePort: 4000 + open: true # 数据源 datasource: diff --git a/dynamics/udp.go b/dynamics/udp.go index 7bdbfda..f444cbf 100644 --- a/dynamics/udp.go +++ b/dynamics/udp.go @@ -16,6 +16,9 @@ import ( ) func init() { + if !config.Config.Dynamics.Open { + return + } go func() { for { info := <-trainInfoChan @@ -114,6 +117,9 @@ func RunUdpServer() { } func Run(tiFunc TurnoutInfoFunc) error { + if !config.Config.Dynamics.Open { + return nil + } mutex.Lock() defer mutex.Unlock() trainLifeSignalInit = false diff --git a/vobc/udp.go b/vobc/udp.go index e9ed6a6..0b01e6f 100644 --- a/vobc/udp.go +++ b/vobc/udp.go @@ -26,6 +26,9 @@ var ( ) func init() { + if !config.Config.Vobc.Open { + return + } go func() { for { info := <-vobcMsgInfoChan @@ -103,7 +106,7 @@ func RegisterTrainInfoHandler(handler VobcDataHandler) { // 创建UDP服务 func RunUdpServer() { - if !config.Config.Dynamics.Open { + if !config.Config.Vobc.Open { return } server := &udpServer{addr: fmt.Sprintf("udp://:%d", config.Config.Vobc.LocalPort), multicore: false}