From 51a715bf7a54f560f4ac0b8e6754bb40f85773fa Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Fri, 15 Mar 2024 17:50:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BD=A6=E5=89=8D=E7=AB=AF=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=88=97=E8=BD=A6=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E4=B8=89=E6=96=B9=E6=98=A0=E5=B0=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=8Aws=E8=BF=94=E5=9B=9E=E5=88=97=E8=BD=A6=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/simulation.go | 23 +++++++++++++++++++ dto/projectRunConfig.go | 9 +++++++- .../wayside/memory/wayside_memory_train.go | 18 ++++++++++++--- .../wayside/memory/wayside_simulation.go | 10 ++++++++ 4 files changed, 56 insertions(+), 4 deletions(-) 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 {