diff --git a/api/simulation.go b/api/simulation.go index 39132fb..e74ea02 100644 --- a/api/simulation.go +++ b/api/simulation.go @@ -34,6 +34,8 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle authed.POST("/train/update", updateTrain) authed.POST("/train/control", controlTrain) authed.POST("/train/conn", trainConnThird) + authed.GET("/train/conn/type/:id", trainConnTypeList) + authed.POST("/switch/operation", turnoutOperation) authed.POST("/relay/operation", relayOperation) authed.POST("/signal/operation", signalOperation) @@ -309,6 +311,27 @@ func trainConnThird(c *gin.Context) { c.JSON(http.StatusOK, "ok") } +// ATS测试仿真-列车连接三方类型列表 +// +// @Summary ATS测试仿真-列车连接三方类型列表 +// +// @Security JwtAuth +// +// @Description ATS测试仿真-列车连接三方类型列表 +// @Tags ATS测试仿真Api +// @Accept json +// @Produce json +// @Param Authorization header string true "JWT Token" +// @Param id path int true "仿真id" +// @Success 200 {object} dto.AddTrainRspDto +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/simulation/train/conn/type/{id} [get] +func trainConnTypeList(c *gin.Context) { + simId := c.Param("id") + simulation := checkDeviceDataAndReturn(simId) + c.JSON(http.StatusOK, simulation.FindTrainConnTypes()) +} + // ATS测试仿真-修改列车控制 // // @Summary ATS测试仿真-修改列车控制 diff --git a/dto/projectRunConfig.go b/dto/projectRunConfig.go index 72eb5da..df11320 100644 --- a/dto/projectRunConfig.go +++ b/dto/projectRunConfig.go @@ -1,6 +1,9 @@ package dto -import "joylink.club/bj-rtsts-server/db/model" +import ( + "joylink.club/bj-rtsts-server/db/model" + "joylink.club/bj-rtsts-server/dto/state_proto" +) type PageProjectRunConfigReqDto struct { PageQueryDto @@ -36,6 +39,10 @@ type RunConfigSelectOption struct { Value int32 `json:"value" form:"value"` } +type TrainConnTypeConfigDto struct { + ConnType state_proto.TrainConnState_TrainConnType `json:"connType" form:"connType"` // NONE = 0 未知连接 ;VOBC = 1; //半实物;PC_SIM = 2; //PC仿真 +} + func ConvertToRunConfigDto(gi *model.ProjectRunConfig) *ProjectRunConfigDto { return &ProjectRunConfigDto{ Id: gi.ID, diff --git a/ts/simulation/wayside/memory/wayside_memory_train.go b/ts/simulation/wayside/memory/wayside_memory_train.go index 102cb87..a5ddd51 100644 --- a/ts/simulation/wayside/memory/wayside_memory_train.go +++ b/ts/simulation/wayside/memory/wayside_memory_train.go @@ -119,11 +119,23 @@ func TrainConnTypeUpdate(vs *VerifySimulation, ct *dto.TrainConnThirdDto) { if !ok { panic(sys_error.New(fmt.Sprintf("列车【%s】不存在", ct.Id))) } - train := data.(*state_proto.TrainState) - train.ConnState.Conn = true + var conn = true if ct.ConnType == state_proto.TrainConnState_NONE { - train.ConnState.Conn = false + conn = false } + if conn { + allTrainMap.Range(func(k, v any) bool { + tmpTrain := v.(*state_proto.TrainState) + if tmpTrain.ConnState.Conn { + panic(sys_error.New(fmt.Sprintf("列车【%s】已经连接,此列车无法联系", k))) + return false + } + return true + }) + } + train := data.(*state_proto.TrainState) + train.ConnState.Conn = conn + train.ConnState.ConnType = ct.ConnType } diff --git a/ts/simulation/wayside/memory/wayside_simulation.go b/ts/simulation/wayside/memory/wayside_simulation.go index 1dd5d96..8455f45 100644 --- a/ts/simulation/wayside/memory/wayside_simulation.go +++ b/ts/simulation/wayside/memory/wayside_simulation.go @@ -486,6 +486,16 @@ func (s *VerifySimulation) CollectInterlockRelayInfo(code string) *message.Inter } return nil } +func (s *VerifySimulation) FindTrainConnTypes() []dto.TrainConnTypeConfigDto { + typeConfig := make([]dto.TrainConnTypeConfigDto, 0) + if s.runConfig.Vobc.Open /*&& s.runConfig.Vobc.Ip != ""*/ { + typeConfig = append(typeConfig, dto.TrainConnTypeConfigDto{ConnType: state_proto.TrainConnState_VOBC}) + } + if s.runConfig.PcSimConfig.Open /*&& s.runConfig.PcSimConfig.PcSimIp != ""*/ { + typeConfig = append(typeConfig, dto.TrainConnTypeConfigDto{ConnType: state_proto.TrainConnState_PC_SIM}) + } + return typeConfig +} // 获取电机转速参数 func (s *VerifySimulation) GetElectricMachineryRunConfig() *config.ElectricMachineryConfig {