列车前端操作接口,列车连接三方映射接口及ws返回列车连接状态

This commit is contained in:
tiger_zhou 2024-03-15 17:50:18 +08:00
parent 521e6c3d59
commit 51a715bf7a
4 changed files with 56 additions and 4 deletions

View File

@ -34,6 +34,8 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
authed.POST("/train/update", updateTrain) authed.POST("/train/update", updateTrain)
authed.POST("/train/control", controlTrain) authed.POST("/train/control", controlTrain)
authed.POST("/train/conn", trainConnThird) authed.POST("/train/conn", trainConnThird)
authed.GET("/train/conn/type/:id", trainConnTypeList)
authed.POST("/switch/operation", turnoutOperation) authed.POST("/switch/operation", turnoutOperation)
authed.POST("/relay/operation", relayOperation) authed.POST("/relay/operation", relayOperation)
authed.POST("/signal/operation", signalOperation) authed.POST("/signal/operation", signalOperation)
@ -309,6 +311,27 @@ func trainConnThird(c *gin.Context) {
c.JSON(http.StatusOK, "ok") 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测试仿真-修改列车控制 // ATS测试仿真-修改列车控制
// //
// @Summary ATS测试仿真-修改列车控制 // @Summary ATS测试仿真-修改列车控制

View File

@ -1,6 +1,9 @@
package dto 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 { type PageProjectRunConfigReqDto struct {
PageQueryDto PageQueryDto
@ -36,6 +39,10 @@ type RunConfigSelectOption struct {
Value int32 `json:"value" form:"value"` 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 { func ConvertToRunConfigDto(gi *model.ProjectRunConfig) *ProjectRunConfigDto {
return &ProjectRunConfigDto{ return &ProjectRunConfigDto{
Id: gi.ID, Id: gi.ID,

View File

@ -119,11 +119,23 @@ func TrainConnTypeUpdate(vs *VerifySimulation, ct *dto.TrainConnThirdDto) {
if !ok { if !ok {
panic(sys_error.New(fmt.Sprintf("列车【%s】不存在", ct.Id))) panic(sys_error.New(fmt.Sprintf("列车【%s】不存在", ct.Id)))
} }
train := data.(*state_proto.TrainState) var conn = true
train.ConnState.Conn = true
if ct.ConnType == state_proto.TrainConnState_NONE { 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 train.ConnState.ConnType = ct.ConnType
} }

View File

@ -486,6 +486,16 @@ func (s *VerifySimulation) CollectInterlockRelayInfo(code string) *message.Inter
} }
return nil 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 { func (s *VerifySimulation) GetElectricMachineryRunConfig() *config.ElectricMachineryConfig {