【增加动力学开启状态】
This commit is contained in:
parent
32725e8f14
commit
3fe1b3e330
@ -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()
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
6
main.go
6
main.go
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user