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}