【增加动力学开启状态】

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() {
if !config.Config.Dynamics.Open {
return
}
// vobc 发来的列车信息
vobc.RegisterTrainInfoHandler(func(info []byte) {
memory.UdpUpdateTime.VobcTime = time.Now().UnixMilli()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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