From 840a2baa6a642d90406bfdc97cd9346c2ae1653c Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Tue, 24 Oct 2023 10:19:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/simulation.go | 30 ++++++++++++++++++- .../wayside/memory/wayside_memory_section.go | 16 ++++++++++ dto/simulation.go | 1 + 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/api/simulation.go b/api/simulation.go index 7a69938..eaf04ea 100644 --- a/api/simulation.go +++ b/api/simulation.go @@ -35,6 +35,7 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle authed.GET("/getDataChannelName", getDataChannelName) authed.POST("/relay/operation", relayOperation) authed.POST("/signal/operation", signalOperation) + authed.POST("/axleSection/operation", axleSectionOperation) authed.POST("/esbBtn/operation", esbBtnOperation) authed.POST("/ibp/btn/operation", ibpBtnOperation) authed.POST("/ibp/key/operation", ibpKeyOperation) @@ -277,7 +278,7 @@ func switchOperation(c *gin.Context) { func signalOperation(c *gin.Context) { req := &dto.SignalOperationReqDto{} if err := c.ShouldBind(&req); err != nil { - panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()}) + panic(sys_error.New("输入参数格式错误", err)) } simulation := checkDeviceDataAndReturn(req.SimulationId) slog.Info("传入状态参数", req) @@ -285,6 +286,33 @@ func signalOperation(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 AxleSectionOperationReqDto body dto.AxleSectionOperationReqDto true "ATS测试仿真-操作计轴区段" +// +// @Success 200 {object} string +// @Failure 500 {object} dto.ErrorDto +// @Router /api/v1/simulation/axleSection/operation [post] +func axleSectionOperation(c *gin.Context) { + req := &dto.AxleSectionOperationReqDto{} + if err := c.ShouldBind(&req); err != nil { + panic(sys_error.New("输入参数格式错误", err)) + } + simulation := checkDeviceDataAndReturn(req.SimulationId) + slog.Info("传入状态参数", req) + memory.ChangeAxleSectionState(simulation, req) + c.JSON(http.StatusOK, "ok") +} + // ATS测试-ESB按钮操作 // // @Summary ATS测试-ESB按钮操作 diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_section.go b/ats/verify/simulation/wayside/memory/wayside_memory_section.go index 48b60db..fb40e66 100644 --- a/ats/verify/simulation/wayside/memory/wayside_memory_section.go +++ b/ats/verify/simulation/wayside/memory/wayside_memory_section.go @@ -3,9 +3,12 @@ package memory import ( "joylink.club/bj-rtsts-server/ats/verify/protos/graphicData" "joylink.club/bj-rtsts-server/ats/verify/protos/state" + "joylink.club/bj-rtsts-server/dto" + "joylink.club/bj-rtsts-server/dto/request_proto" "joylink.club/ecs" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/entity" + "joylink.club/rtsssimulation/fi" ) func GetMapAllSectionState(sim *VerifySimulation, mapId int32) []*state.SectionState { @@ -36,3 +39,16 @@ func handlerSectionState(w ecs.World, uid string) *state.SectionState { } return nil } +func ChangeAxleSectionState(simulation *VerifySimulation, req *dto.AxleSectionOperationReqDto) { + sectionUid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &graphicData.Section{}) + switch req.Operation { + case request_proto.Section_Drst: + fi.DriveAxleSectionDrst(simulation.World, sectionUid, req.Reset) + case request_proto.Section_Pdrst: + fi.DriveAxleSectionPdrst(simulation.World, sectionUid, req.Reset) + case request_proto.Section_TrainIn: + fi.DriveAxleSectionTrainIn(simulation.World, sectionUid) + case request_proto.Section_TrainOut: + fi.DriveAxleSectionTrainOut(simulation.World, sectionUid) + } +} diff --git a/dto/simulation.go b/dto/simulation.go index 747a3ce..153a86c 100644 --- a/dto/simulation.go +++ b/dto/simulation.go @@ -85,6 +85,7 @@ type AxleSectionOperationReqDto struct { MapId int32 `json:"mapId" from:"mapId" binding:"required"` DeviceId string `form:"id" json:"id" binding:"required"` Operation request_proto.Section_AxleOperation `form:"operation" json:"operation"` + Reset bool `form:"reset" json:"reset"` //当操作为直接复位或预复位时有效,true-复位,false-取消或结束复位 } type EsbButtonOperationReqDto struct {