【增加动力学开启状态】

This commit is contained in:
weizhihong 2023-10-08 09:31:33 +08:00
parent 32725e8f14
commit 3fe1b3e330
7 changed files with 23 additions and 2 deletions

View File

@ -23,6 +23,9 @@ import (
) )
func init() { func init() {
if !config.Config.Dynamics.Open {
return
}
// vobc 发来的列车信息 // vobc 发来的列车信息
vobc.RegisterTrainInfoHandler(func(info []byte) { vobc.RegisterTrainInfoHandler(func(info []byte) {
memory.UdpUpdateTime.VobcTime = time.Now().UnixMilli() memory.UdpUpdateTime.VobcTime = time.Now().UnixMilli()

View File

@ -11,6 +11,7 @@ dynamics:
udpRemotePort: 3000 udpRemotePort: 3000
udpRemoteTrainPort: 3001 udpRemoteTrainPort: 3001
httpPort: 7800 httpPort: 7800
open: true
# VOBC # VOBC
vobc: vobc:
ip: 10.60.1.59 ip: 10.60.1.59

View File

@ -53,6 +53,7 @@ type dynamics struct {
UdpRemotePort int UdpRemotePort int
UdpRemoteTrainPort int UdpRemoteTrainPort int
HttpPort int HttpPort int
Open bool
} }
type vobc struct { type vobc struct {
Ip string Ip string

View File

@ -11,6 +11,7 @@ dynamics:
udpRemotePort: 3000 udpRemotePort: 3000
udpRemoteTrainPort: 3001 udpRemoteTrainPort: 3001
httpPort: 7800 httpPort: 7800
open: false
# VOBC # VOBC
vobc: vobc:
ip: 10.60.1.59 ip: 10.60.1.59

View File

@ -11,6 +11,7 @@ dynamics:
udpRemotePort: 3000 udpRemotePort: 3000
udpRemoteTrainPort: 3001 udpRemoteTrainPort: 3001
httpPort: 7800 httpPort: 7800
open: true
# VOBC # VOBC
vobc: vobc:
ip: 10.60.1.59 ip: 10.60.1.59

View File

@ -11,6 +11,9 @@ import (
) )
func SendInitTrainReq(info *InitTrainInfo) (int, *[]byte, error) { func SendInitTrainReq(info *InitTrainInfo) (int, *[]byte, error) {
if !config.Config.Dynamics.Open {
return http.StatusOK, nil, nil
}
baseUrl := getUrlBase() baseUrl := getUrlBase()
uri := "/api/aerodynamics/init/train/" uri := "/api/aerodynamics/init/train/"
url := baseUrl + uri url := baseUrl + uri
@ -33,6 +36,9 @@ func SendInitTrainReq(info *InitTrainInfo) (int, *[]byte, error) {
} }
func SendRemoveTrainReq(info *InitTrainInfo) (int, *[]byte, error) { func SendRemoveTrainReq(info *InitTrainInfo) (int, *[]byte, error) {
if !config.Config.Dynamics.Open {
return http.StatusOK, nil, nil
}
baseUrl := getUrlBase() baseUrl := getUrlBase()
uri := "/api/aerodynamics/remove/train/" uri := "/api/aerodynamics/remove/train/"
url := baseUrl + uri url := baseUrl + uri
@ -55,6 +61,9 @@ func SendRemoveTrainReq(info *InitTrainInfo) (int, *[]byte, error) {
} }
func SendSimulationStartReq(base *LineBaseInfo) (int, *[]byte, error) { func SendSimulationStartReq(base *LineBaseInfo) (int, *[]byte, error) {
if !config.Config.Dynamics.Open {
return http.StatusOK, nil, nil
}
baseUrl := getUrlBase() baseUrl := getUrlBase()
uri := "/api/start/" uri := "/api/start/"
url := baseUrl + uri url := baseUrl + uri
@ -74,6 +83,9 @@ func SendSimulationStartReq(base *LineBaseInfo) (int, *[]byte, error) {
} }
func SendSimulationEndReq() (int, *[]byte, error) { func SendSimulationEndReq() (int, *[]byte, error) {
if !config.Config.Dynamics.Open {
return http.StatusOK, nil, nil
}
baseUrl := getUrlBase() baseUrl := getUrlBase()
uri := "/api/end/" uri := "/api/end/"
url := baseUrl + uri url := baseUrl + uri

View File

@ -40,8 +40,10 @@ func main() {
docs.SwaggerInfo.Title = "CBTC测试系统API" docs.SwaggerInfo.Title = "CBTC测试系统API"
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
go dynamics.RunUdpServer() if config.Config.Dynamics.Open {
go vobc.RunUdpServer() go dynamics.RunUdpServer()
go vobc.RunUdpServer()
}
serverConfig := config.Config.Server serverConfig := config.Config.Server
if serverConfig.Port == 0 { if serverConfig.Port == 0 {