2023-07-28 14:36:16 +08:00
|
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
2023-07-31 17:27:05 +08:00
|
|
|
|
"fmt"
|
2023-10-12 10:10:23 +08:00
|
|
|
|
"log/slog"
|
2023-07-28 14:36:16 +08:00
|
|
|
|
"net/http"
|
2023-10-13 18:10:06 +08:00
|
|
|
|
"sort"
|
2023-07-31 17:27:05 +08:00
|
|
|
|
"strconv"
|
2023-07-28 14:36:16 +08:00
|
|
|
|
|
|
|
|
|
jwt "github.com/appleboy/gin-jwt/v2"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
2023-07-31 17:27:05 +08:00
|
|
|
|
"github.com/golang/protobuf/proto"
|
2023-07-28 14:36:16 +08:00
|
|
|
|
"joylink.club/bj-rtsts-server/dto"
|
2024-01-11 10:24:56 +08:00
|
|
|
|
"joylink.club/bj-rtsts-server/dto/data_proto"
|
2023-10-13 17:43:48 +08:00
|
|
|
|
"joylink.club/bj-rtsts-server/dto/request_proto"
|
2024-01-11 10:24:56 +08:00
|
|
|
|
"joylink.club/bj-rtsts-server/dto/state_proto"
|
2023-08-30 09:28:21 +08:00
|
|
|
|
"joylink.club/bj-rtsts-server/middleware"
|
2023-08-01 17:08:45 +08:00
|
|
|
|
"joylink.club/bj-rtsts-server/service"
|
2023-10-20 15:08:47 +08:00
|
|
|
|
"joylink.club/bj-rtsts-server/sys_error"
|
2023-10-26 17:16:07 +08:00
|
|
|
|
"joylink.club/bj-rtsts-server/ts"
|
|
|
|
|
"joylink.club/bj-rtsts-server/ts/simulation/wayside/memory"
|
2023-07-28 14:36:16 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
2023-08-30 09:28:21 +08:00
|
|
|
|
authed := api.Group("/v1/simulation").Use(authMiddleware.MiddlewareFunc(), middleware.PermissMiddleware)
|
2023-08-30 13:25:57 +08:00
|
|
|
|
authed.POST("/createByProject", createByProjectId)
|
2023-07-28 17:24:58 +08:00
|
|
|
|
authed.POST("/destroy/:id", destroy)
|
2023-07-28 15:49:44 +08:00
|
|
|
|
authed.GET("/list", findAllSimulations)
|
|
|
|
|
authed.POST("/check/data", checkSimMapData)
|
2023-07-31 17:27:05 +08:00
|
|
|
|
authed.POST("/train/add", addTrain)
|
2024-01-16 17:53:54 +08:00
|
|
|
|
authed.POST("/train/config", configTrain)
|
2023-07-28 15:49:44 +08:00
|
|
|
|
authed.POST("/train/remove", removeTrain)
|
2024-02-04 18:22:52 +08:00
|
|
|
|
authed.POST("/train/remove/all", removeAllTrain)
|
2023-11-13 15:57:32 +08:00
|
|
|
|
authed.POST("/train/update", updateTrain)
|
2024-03-15 16:03:47 +08:00
|
|
|
|
authed.POST("/train/control", controlTrain)
|
|
|
|
|
authed.POST("/train/conn", trainConnThird)
|
2024-03-15 17:50:18 +08:00
|
|
|
|
authed.GET("/train/conn/type/:id", trainConnTypeList)
|
|
|
|
|
|
2023-10-31 11:22:50 +08:00
|
|
|
|
authed.POST("/switch/operation", turnoutOperation)
|
2023-10-07 17:48:39 +08:00
|
|
|
|
authed.POST("/relay/operation", relayOperation)
|
2023-10-13 14:41:55 +08:00
|
|
|
|
authed.POST("/signal/operation", signalOperation)
|
2023-10-24 10:19:51 +08:00
|
|
|
|
authed.POST("/axleSection/operation", axleSectionOperation)
|
2024-02-04 18:22:52 +08:00
|
|
|
|
authed.POST("/esbBtn/operation", esbBtnOperation) //1
|
|
|
|
|
authed.POST("/ibp/btn/operation", ibpBtnOperation) //1
|
|
|
|
|
authed.POST("/ibp/key/operation", ibpKeyOperation) //1
|
2023-10-19 17:42:01 +08:00
|
|
|
|
authed.GET("/:id/getMapKilometerRange", getMapKilometerRange)
|
2024-02-04 18:22:52 +08:00
|
|
|
|
authed.POST("/psl/operation", pslBtnOperation) //1
|
2023-11-02 15:50:03 +08:00
|
|
|
|
authed.POST("/psd/operation", psdOperation)
|
2024-01-10 14:06:01 +08:00
|
|
|
|
authed.PUT("/balise/position/modify", balisePositionModify)
|
2024-03-20 14:35:35 +08:00
|
|
|
|
authed.PUT("/balise/position/reset", balisePositionReset)
|
2024-01-10 14:06:01 +08:00
|
|
|
|
authed.PUT("/balise/telegram/modify", baliseTelegramModify)
|
|
|
|
|
authed.PUT("/balise/telegram/reset", baliseTelegramReset)
|
2024-02-06 09:30:58 +08:00
|
|
|
|
authed.PUT("/balise/telegram/stop", baliseTelegramStop)
|
|
|
|
|
authed.PUT("/balise/telegram/send", baliseTelegramSend)
|
2024-01-10 14:06:01 +08:00
|
|
|
|
authed.PUT("/balise/reset", baliseReset)
|
2024-03-20 14:35:35 +08:00
|
|
|
|
authed.PUT("/ckm/operation")
|
2024-02-06 10:49:46 +08:00
|
|
|
|
//authed.POST("/bypass/operation", bypassBtnOrKeyOperation)
|
2023-07-31 08:41:42 +08:00
|
|
|
|
|
2023-08-01 17:08:45 +08:00
|
|
|
|
// 初始化地图信息
|
|
|
|
|
initPublishMapInfo()
|
2023-07-28 14:36:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-01 17:08:45 +08:00
|
|
|
|
func initPublishMapInfo() {
|
2023-11-17 16:22:22 +08:00
|
|
|
|
mapArr := service.ListAllPublished()
|
2023-10-13 18:10:06 +08:00
|
|
|
|
sort.SliceStable(mapArr, func(i, j int) bool { return mapArr[i].Type != 0 })
|
2023-08-01 17:08:45 +08:00
|
|
|
|
for _, v := range mapArr {
|
|
|
|
|
memory.PublishMapVerifyStructure(v)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-30 13:25:57 +08:00
|
|
|
|
// 创建ATS测试仿真通过项目ID
|
|
|
|
|
//
|
|
|
|
|
// @Summary 创建ATS测试仿真
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 创建ATS测试仿真通过项目ID
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param SimulationCreateReqDto body dto.SimulationCreateReqDto true "创建仿真请求"
|
|
|
|
|
// @Success 200 {object} dto.SimulationCreateRspDto
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/createByProject [post]
|
|
|
|
|
func createByProjectId(c *gin.Context) {
|
|
|
|
|
req := dto.SimulationCreateReqDto{}
|
|
|
|
|
if err := c.ShouldBind(&req); nil != err {
|
2023-10-20 15:08:47 +08:00
|
|
|
|
panic(sys_error.New("测试启动失败,请求参数异常", err))
|
2023-08-30 13:25:57 +08:00
|
|
|
|
}
|
2023-10-26 15:06:26 +08:00
|
|
|
|
// 地图信息
|
2023-11-17 16:22:22 +08:00
|
|
|
|
mapInfos := service.QueryProjectPublished(req.ProjectId)
|
2023-08-30 13:25:57 +08:00
|
|
|
|
if len(mapInfos) == 0 {
|
2023-10-20 15:08:47 +08:00
|
|
|
|
panic(sys_error.New("测试启动失败,项目未关联发布图"))
|
2023-08-30 13:25:57 +08:00
|
|
|
|
}
|
2023-11-30 10:59:34 +08:00
|
|
|
|
var mapIds []int32
|
|
|
|
|
for _, mapInfo := range mapInfos {
|
2024-01-11 10:24:56 +08:00
|
|
|
|
if mapInfo.Type == data_proto.PictureType_value[data_proto.PictureType_TrainData.String()] {
|
2023-11-30 10:59:34 +08:00
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
mapIds = append(mapIds, mapInfo.ID)
|
2023-09-19 11:02:50 +08:00
|
|
|
|
}
|
2023-10-26 15:06:26 +08:00
|
|
|
|
// 运行环境配置
|
|
|
|
|
runConfig := service.QueryRunConfig(req.ProjectRunConfigId)
|
2023-10-26 18:09:09 +08:00
|
|
|
|
simulationId, err := ts.CreateSimulation(req.ProjectId, mapIds, runConfig)
|
2023-10-20 15:08:47 +08:00
|
|
|
|
if err != nil {
|
|
|
|
|
panic(sys_error.New("测试启动失败", err))
|
|
|
|
|
}
|
2023-10-26 18:09:09 +08:00
|
|
|
|
rsp := dto.SimulationCreateRspDto{
|
|
|
|
|
ProjectId: req.ProjectId,
|
|
|
|
|
MapId: mapIds[0],
|
|
|
|
|
MapIds: mapIds,
|
|
|
|
|
ProjectRunConfigId: req.ProjectRunConfigId,
|
|
|
|
|
}
|
2023-10-20 15:08:47 +08:00
|
|
|
|
rsp.SimulationId = simulationId
|
2023-07-28 14:36:16 +08:00
|
|
|
|
c.JSON(http.StatusOK, &rsp)
|
|
|
|
|
}
|
2023-07-28 15:49:44 +08:00
|
|
|
|
|
|
|
|
|
// 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} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
2023-07-31 15:44:08 +08:00
|
|
|
|
// @Router /api/v1/simulation/destroy/{id} [post]
|
2023-07-28 15:49:44 +08:00
|
|
|
|
func destroy(c *gin.Context) {
|
|
|
|
|
simId := c.Param("id")
|
2023-10-12 10:10:23 +08:00
|
|
|
|
slog.Debug("ATS测试仿真-ATS仿真销毁 请求:", simId)
|
2023-10-26 17:16:07 +08:00
|
|
|
|
ts.DestroySimulation(simId)
|
2023-07-28 15:49:44 +08:00
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取ATS测试系统所有仿真实例的基本信息
|
|
|
|
|
//
|
2023-08-30 13:25:57 +08:00
|
|
|
|
// @Summary 获取ATS测试系统所有仿真实例的基本信息
|
2023-07-28 15:49:44 +08:00
|
|
|
|
//
|
2023-08-30 13:25:57 +08:00
|
|
|
|
// @Security JwtAuth
|
2023-07-28 15:49:44 +08:00
|
|
|
|
//
|
2023-08-30 13:25:57 +08:00
|
|
|
|
// @Description 获取ATS测试系统所有仿真实例的基本信息
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Success 200 {object} dto.SimulationInfoRspDtoArr
|
2023-07-28 15:49:44 +08:00
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
2023-08-30 13:25:57 +08:00
|
|
|
|
// @Router /api/v1/simulation/list [get]
|
2023-07-28 15:49:44 +08:00
|
|
|
|
func findAllSimulations(c *gin.Context) {
|
2023-10-26 17:16:07 +08:00
|
|
|
|
c.JSON(http.StatusOK, ts.ListAllSimulations())
|
2023-07-28 15:49:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ATS测试仿真地图数据校验
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试仿真地图数据校验
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
2023-08-30 13:25:57 +08:00
|
|
|
|
// @Description 地图数据校验
|
2023-07-28 15:49:44 +08:00
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param RemoveTrainDto body dto.CheckMapDataReqDto true "ATS测试仿真-地图数据"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} dto.CheckMapDataRspDto
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/check/data [post]
|
|
|
|
|
func checkSimMapData(c *gin.Context) {
|
2023-07-31 17:27:05 +08:00
|
|
|
|
rt := &dto.CheckMapDataReqDto{}
|
|
|
|
|
if err := c.ShouldBind(&rt); nil != err {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New("请求参数异常", err))
|
2023-07-31 17:27:05 +08:00
|
|
|
|
}
|
2024-01-11 10:24:56 +08:00
|
|
|
|
err := proto.Unmarshal(rt.Data, &data_proto.RtssGraphicStorage{})
|
2023-07-28 15:49:44 +08:00
|
|
|
|
if err != nil {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New("非平面布置图数据"))
|
2023-07-28 15:49:44 +08:00
|
|
|
|
}
|
2023-08-31 16:16:18 +08:00
|
|
|
|
c.JSON(http.StatusOK, &dto.CheckMapDataRspDto{Success: true})
|
2023-07-28 15:49:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-16 17:53:54 +08:00
|
|
|
|
// 列车动力学参数配置修改
|
|
|
|
|
//
|
|
|
|
|
// @Summary 列车动力学参数配置修改
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 地图数据校验
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param RemoveTrainDto body dto.ConfigTrainReqDto true "动力学参数配置"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/train/config [post]
|
|
|
|
|
func configTrain(c *gin.Context) {
|
|
|
|
|
req := &dto.ConfigTrainReqDto{}
|
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(sys_error.New("修改列车配置失败,请求参数异常", err))
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
memory.UpdateConfigTrain(simulation, req)
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-31 17:27:05 +08:00
|
|
|
|
// ATS测试仿真-添加列车
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试仿真-添加列车
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试仿真-添加列车
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
2024-01-17 15:53:14 +08:00
|
|
|
|
// @Param AddTrainReqDto body dto.AddTrainReqDtoNew true "ATS测试仿真-添加列车"
|
2023-07-31 17:27:05 +08:00
|
|
|
|
// @Success 200 {object} dto.AddTrainRspDto
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/train/add [post]
|
|
|
|
|
func addTrain(c *gin.Context) {
|
2024-01-17 15:53:14 +08:00
|
|
|
|
//req := dto.AddTrainReqDto{}
|
|
|
|
|
req := dto.AddTrainReqDtoNew{}
|
2023-07-31 17:27:05 +08:00
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New("添加列车失败,请求参数异常", err))
|
2023-07-31 17:27:05 +08:00
|
|
|
|
}
|
2023-08-01 17:08:45 +08:00
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
2024-03-19 08:28:50 +08:00
|
|
|
|
|
2024-02-04 18:22:52 +08:00
|
|
|
|
if req.TrainId < 0 || req.TrainId >= 255 {
|
|
|
|
|
panic(sys_error.New("列车编号不能小于0,大于255"))
|
2023-07-31 17:27:05 +08:00
|
|
|
|
}
|
2024-01-11 10:24:56 +08:00
|
|
|
|
rsp := &state_proto.TrainState{
|
2024-02-04 18:22:52 +08:00
|
|
|
|
Id: fmt.Sprintf("%v", req.TrainId),
|
2023-11-13 14:15:56 +08:00
|
|
|
|
HeadDeviceId: req.Id,
|
|
|
|
|
HeadOffset: req.HeadOffset,
|
|
|
|
|
DevicePort: req.DevicePort,
|
|
|
|
|
RunDirection: req.RunDirection,
|
|
|
|
|
TrainLength: req.TrainLength,
|
|
|
|
|
WheelDiameter: req.WheelDiameter,
|
2024-02-04 18:22:52 +08:00
|
|
|
|
Speed: req.TrainSpeed,
|
2024-03-19 11:00:19 +08:00
|
|
|
|
ConnState: &state_proto.TrainConnState{TrainControlMapId: req.TrainControlMapId, Conn: false, ConnType: state_proto.TrainConnState_NONE},
|
2023-08-31 16:16:18 +08:00
|
|
|
|
}
|
2024-02-23 10:43:06 +08:00
|
|
|
|
var err *sys_error.BusinessError = memory.AddTrainStateNew(simulation,
|
|
|
|
|
rsp, req.ConfigTrain, req.TrainEndsA, req.TrainEndsB, req.MapId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(sys_error.New("添加列车失败", err))
|
|
|
|
|
}
|
2023-08-31 16:16:18 +08:00
|
|
|
|
c.JSON(http.StatusOK, &rsp)
|
2023-07-31 17:27:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-13 15:57:32 +08:00
|
|
|
|
// ATS测试仿真-修改列车基础信息
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试仿真-修改列车基础信息
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试仿真-修改列车基础信息
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param UpdateTrainReqDto body dto.UpdateTrainReqDto true "ATS测试仿真-修改列车基础信息"
|
|
|
|
|
// @Success 200 {object} dto.AddTrainRspDto
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/train/update [post]
|
|
|
|
|
func updateTrain(c *gin.Context) {
|
|
|
|
|
req := dto.UpdateTrainReqDto{}
|
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(sys_error.New("添加列车失败,请求参数异常", err))
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
2024-01-11 10:24:56 +08:00
|
|
|
|
rsp := &state_proto.TrainState{
|
2023-11-13 15:57:32 +08:00
|
|
|
|
Id: req.Id,
|
|
|
|
|
TrainLength: req.TrainLength,
|
|
|
|
|
WheelDiameter: req.WheelDiameter,
|
|
|
|
|
}
|
|
|
|
|
memory.UpdateTrainInfo(simulation, rsp)
|
|
|
|
|
c.JSON(http.StatusOK, &rsp)
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-15 16:03:47 +08:00
|
|
|
|
// ATS测试仿真-列车连接三方
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试仿真-列车连接三方
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试仿真-列车连接三方
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param TrainConnThirdDto body dto.TrainConnThirdDto true "ATS测试仿真-修改列车基础信息"
|
|
|
|
|
// @Success 200 {object} dto.AddTrainRspDto
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/train/conn [post]
|
|
|
|
|
func trainConnThird(c *gin.Context) {
|
|
|
|
|
req := &dto.TrainConnThirdDto{}
|
|
|
|
|
if err := c.ShouldBind(req); err != nil {
|
|
|
|
|
panic(sys_error.New("修改列车控制参数失败,请求参数异常", err))
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
memory.TrainConnTypeUpdate(simulation, req)
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-15 17:50:18 +08:00
|
|
|
|
// ATS测试仿真-列车连接三方类型列表
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试仿真-列车连接三方类型列表
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试仿真-列车连接三方类型列表
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
2024-03-19 09:16:30 +08:00
|
|
|
|
// @Param id path string true "仿真id"
|
2024-03-15 17:50:18 +08:00
|
|
|
|
// @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())
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-15 16:03:47 +08:00
|
|
|
|
// ATS测试仿真-修改列车控制
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试仿真-修改列车控制
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试仿真-修改列车控制
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param ControlTrainReqDtos body dto.ControlTrainReqDtos true "ATS测试仿真-修改列车基础信息"
|
|
|
|
|
// @Success 200 {object} dto.AddTrainRspDto
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/train/control [post]
|
|
|
|
|
func controlTrain(c *gin.Context) {
|
2024-03-19 08:28:50 +08:00
|
|
|
|
req := &request_proto.TrainControl{}
|
|
|
|
|
|
2024-03-15 16:03:47 +08:00
|
|
|
|
if err := c.ShouldBind(req); err != nil {
|
|
|
|
|
panic(sys_error.New("修改列车控制参数失败,请求参数异常", err))
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
memory.ControlTrainUpdate(simulation, req)
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-04 18:22:52 +08:00
|
|
|
|
// ATS测试仿真-移除所有列车
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试仿真-移除列车
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试仿真-移除列车
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param RemoveTrainDto body dto.RemoveAllTrainRspDto true "ATS测试仿真-移除所有列车"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/train/remove/all [post]
|
|
|
|
|
func removeAllTrain(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
rt := &dto.RemoveAllTrainRspDto{}
|
|
|
|
|
if err := c.ShouldBind(&rt); err != nil {
|
|
|
|
|
panic(sys_error.New("移除所有列车失败,请求参数异常", err))
|
|
|
|
|
}
|
|
|
|
|
slog.Debug("ATS测试仿真-移除所有列车,请求:", rt)
|
|
|
|
|
simulation := checkDeviceDataAndReturn(rt.SimulationId)
|
|
|
|
|
memory.RemoveAllTrain(simulation)
|
|
|
|
|
//TODO 后续调用列车删除操作
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-28 16:14:31 +08:00
|
|
|
|
// ATS测试仿真-移除列车
|
2023-07-28 15:49:44 +08:00
|
|
|
|
//
|
2023-07-28 16:14:31 +08:00
|
|
|
|
// @Summary ATS测试仿真-移除列车
|
2023-07-28 15:49:44 +08:00
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
2023-07-28 16:14:31 +08:00
|
|
|
|
// @Description ATS测试仿真-移除列车
|
2023-07-28 15:49:44 +08:00
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param RemoveTrainDto body dto.RemoveTrainDto true "ATS测试仿真-移除列车"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/train/remove [post]
|
|
|
|
|
func removeTrain(c *gin.Context) {
|
|
|
|
|
rt := &dto.RemoveTrainDto{}
|
2023-07-31 17:27:05 +08:00
|
|
|
|
if err := c.ShouldBind(&rt); err != nil {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New("移除列车失败,请求参数异常", err))
|
2023-07-28 15:49:44 +08:00
|
|
|
|
}
|
2023-10-12 10:10:23 +08:00
|
|
|
|
slog.Debug("ATS测试仿真-移除列车,请求:", rt)
|
2023-08-01 17:08:45 +08:00
|
|
|
|
simulation := checkDeviceDataAndReturn(rt.SimulationId)
|
|
|
|
|
memory.RemoveTrainState(simulation, rt.TrainId)
|
2023-07-31 17:27:05 +08:00
|
|
|
|
//TODO 后续调用列车删除操作
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
2023-07-28 15:49:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取ATS测试-操作道岔
|
|
|
|
|
//
|
|
|
|
|
// @Summary 获取ATS测试-操作道岔
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
2023-08-30 13:25:57 +08:00
|
|
|
|
// @Description ATS测试-操作道岔
|
2023-07-28 15:49:44 +08:00
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
2024-01-18 17:18:50 +08:00
|
|
|
|
// @Param TurnoutOperationReq body request_proto.PointsOperationReq true "ATS测试仿真-操作道岔"
|
2023-07-28 15:49:44 +08:00
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/switch/operation [post]
|
2023-10-31 11:22:50 +08:00
|
|
|
|
func turnoutOperation(c *gin.Context) {
|
2024-01-17 17:49:11 +08:00
|
|
|
|
req := &request_proto.PointsOperationReq{}
|
2023-07-31 17:27:05 +08:00
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New("道岔操作失败,请求参数异常", err))
|
2023-07-31 17:27:05 +08:00
|
|
|
|
}
|
2023-08-01 17:08:45 +08:00
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
2023-10-19 09:33:40 +08:00
|
|
|
|
slog.Info("传入状态参数", "request", req)
|
2024-01-17 17:49:11 +08:00
|
|
|
|
err := memory.HandlePointsOperation(simulation, req)
|
2023-11-03 17:27:37 +08:00
|
|
|
|
if err != nil {
|
|
|
|
|
panic(sys_error.New(fmt.Sprintf("道岔操作失败, %s", err), err))
|
|
|
|
|
}
|
2023-07-31 17:27:05 +08:00
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
2023-07-28 15:49:44 +08:00
|
|
|
|
|
2023-10-13 14:41:55 +08:00
|
|
|
|
// ATS测试-信号机操作
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试-信号机操作
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试-信号机操作
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
2024-01-18 17:18:50 +08:00
|
|
|
|
// @Param SignalOperationReqDto body request_proto.SignalOperationReq true "ATS测试仿真-操作信号机"
|
2023-10-13 14:41:55 +08:00
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/signal/operation [post]
|
|
|
|
|
func signalOperation(c *gin.Context) {
|
2024-01-17 17:49:11 +08:00
|
|
|
|
req := &request_proto.SignalOperationReq{}
|
2023-10-13 14:41:55 +08:00
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
2023-10-24 10:19:51 +08:00
|
|
|
|
panic(sys_error.New("输入参数格式错误", err))
|
2023-10-13 14:41:55 +08:00
|
|
|
|
}
|
2023-10-16 10:37:59 +08:00
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
2023-10-13 14:41:55 +08:00
|
|
|
|
slog.Info("传入状态参数", req)
|
2024-01-17 17:49:11 +08:00
|
|
|
|
memory.HandleSignalOperation(simulation, req)
|
2023-10-13 14:41:55 +08:00
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-24 10:19:51 +08:00
|
|
|
|
// 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]
|
2023-10-31 15:55:17 +08:00
|
|
|
|
func axleSectionOperation(c *gin.Context) { //操作:设置故障占用、取消故障占用
|
2024-01-22 15:56:40 +08:00
|
|
|
|
req := &request_proto.SectionOperationReq{}
|
2023-10-24 10:19:51 +08:00
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(sys_error.New("输入参数格式错误", err))
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
2024-01-22 15:56:40 +08:00
|
|
|
|
slog.Info("传入状态参数", "req", req)
|
|
|
|
|
err := memory.HandleSectionOperation(simulation, req)
|
2023-11-01 11:08:26 +08:00
|
|
|
|
if err != nil {
|
2024-01-22 15:56:40 +08:00
|
|
|
|
panic(sys_error.New("区段操作失败", err))
|
2023-11-01 11:08:26 +08:00
|
|
|
|
}
|
2023-10-24 10:19:51 +08:00
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-18 13:53:17 +08:00
|
|
|
|
// ATS测试-ESB按钮操作
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试-ESB按钮操作
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试-ESB按钮操作
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
2023-10-20 13:50:22 +08:00
|
|
|
|
// @Param EsbButtonOperationReqDto body dto.EsbButtonOperationReqDto true "ATS测试仿真-ESB按钮操作"
|
2023-10-18 13:53:17 +08:00
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/esbBtn/operation [post]
|
|
|
|
|
func esbBtnOperation(c *gin.Context) {
|
2023-10-20 13:50:22 +08:00
|
|
|
|
req := &dto.EsbButtonOperationReqDto{}
|
2023-10-18 13:53:17 +08:00
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New("紧急关闭按钮操作失败,请求参数异常", err))
|
2023-10-18 13:53:17 +08:00
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
slog.Info("传入状态参数", req)
|
2023-11-06 14:30:09 +08:00
|
|
|
|
err := memory.ChangeEsbButtonState(simulation, req.MapId, req.Id, req.Down)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(sys_error.New(fmt.Sprintf("紧急关闭按钮操作失败,%s", err.Error()), err))
|
|
|
|
|
}
|
2023-10-18 13:53:17 +08:00
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ATS测试-IBP按钮操作
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试-IBP按钮操作
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试-IBP按钮操作
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
2023-10-20 13:50:22 +08:00
|
|
|
|
// @Param IBPButtonOperationReqDto body dto.IBPButtonOperationReqDto true "ATS测试仿真-IBP按钮操作"
|
2023-10-18 13:53:17 +08:00
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
2023-10-20 13:50:22 +08:00
|
|
|
|
// @Router /api/v1/simulation/ibp/btn/operation [post]
|
2023-10-18 13:53:17 +08:00
|
|
|
|
func ibpBtnOperation(c *gin.Context) {
|
2023-10-20 13:50:22 +08:00
|
|
|
|
req := &dto.IBPButtonOperationReqDto{}
|
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New("IBP按钮操作失败,请求参数异常", err))
|
2023-10-20 13:50:22 +08:00
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
slog.Info("传入状态参数", req)
|
2024-02-20 14:18:42 +08:00
|
|
|
|
err := memory.ChangeIBPButtonState(simulation, req.MapId, req.IbpId, req.ButtonId, req.Down)
|
2023-11-06 14:30:09 +08:00
|
|
|
|
if err != nil {
|
|
|
|
|
panic(sys_error.New(fmt.Sprintf("IBP按钮操作失败,%s", err.Error()), err))
|
|
|
|
|
}
|
2023-10-20 13:50:22 +08:00
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ATS测试-IBP钥匙操作
|
|
|
|
|
//
|
|
|
|
|
// @Summary ATS测试-IBP钥匙操作
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试-IBP钥匙操作
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param KeyOperationReqDto body dto.KeyOperationReqDto true "ATS测试仿真-IBP钥匙操作"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/ibp/key/operation [post]
|
|
|
|
|
func ibpKeyOperation(c *gin.Context) {
|
|
|
|
|
req := &dto.KeyOperationReqDto{}
|
2023-10-18 13:53:17 +08:00
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New("IBP开关操作失败,请求参数异常", err))
|
2023-10-18 13:53:17 +08:00
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
slog.Info("传入状态参数", req)
|
2024-02-20 14:18:42 +08:00
|
|
|
|
err := memory.ChangeIBPKeyState(simulation, req.MapId, req.IbpId, req.KeyId, req.Gear)
|
2023-11-06 14:30:09 +08:00
|
|
|
|
if err != nil {
|
|
|
|
|
panic(sys_error.New(fmt.Sprintf("IBP开关操作失败,%s", err.Error()), err))
|
|
|
|
|
}
|
2023-10-18 13:53:17 +08:00
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
2023-10-13 14:41:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-02 15:50:03 +08:00
|
|
|
|
// PSL按钮操作
|
2023-10-19 17:09:57 +08:00
|
|
|
|
//
|
|
|
|
|
// @Summary PSL操作
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description PSL操作
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
2023-10-20 13:50:22 +08:00
|
|
|
|
// @Param PslOperationReqDto body dto.PslOperationReqDto true "PSL操作"
|
2023-10-19 17:09:57 +08:00
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
2023-11-02 15:50:03 +08:00
|
|
|
|
// @Router /api/v1/simulation/psl/operation [post]
|
2023-10-19 17:09:57 +08:00
|
|
|
|
func pslBtnOperation(c *gin.Context) {
|
|
|
|
|
req := &dto.PslOperationReqDto{}
|
2023-10-18 13:53:17 +08:00
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
slog.Info("传入状态参数", req)
|
2024-03-26 13:12:17 +08:00
|
|
|
|
var err *sys_error.BusinessError = memory.ChangePSLButtonState(simulation, req.MapId, req.PslId, req.ButtonCode, req.Down)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
2023-10-18 13:53:17 +08:00
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
2023-10-13 14:41:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-02 15:50:03 +08:00
|
|
|
|
// 屏蔽门操作
|
|
|
|
|
//
|
|
|
|
|
// @Summary 屏蔽门操作
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 屏蔽门操作
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param PsdOperationReq body request_proto.PsdOperationReq true "屏蔽门操作"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/psd/operation [post]
|
|
|
|
|
func psdOperation(c *gin.Context) {
|
|
|
|
|
req := &request_proto.PsdOperationReq{}
|
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
slog.Info("传入状态参数", req)
|
|
|
|
|
if err := memory.HandlePsdOperation(simulation, req); err != nil {
|
2023-12-08 17:43:21 +08:00
|
|
|
|
panic(sys_error.New(err.Error(), err))
|
2023-11-02 15:50:03 +08:00
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-19 17:42:01 +08:00
|
|
|
|
// 获取仿真地图的公里标范围
|
|
|
|
|
//
|
|
|
|
|
// @Summary 获取仿真地图的公里标范围
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 获取仿真地图的公里标范围
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/:id/getMapKilometerRange [get]
|
|
|
|
|
func getMapKilometerRange(c *gin.Context) {
|
|
|
|
|
id, exist := c.Params.Get("id")
|
|
|
|
|
if !exist {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New("缺少仿真编号"))
|
2023-10-19 17:42:01 +08:00
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(id)
|
|
|
|
|
c.JSON(http.StatusOK, simulation.Repo.GetCoordinateInfo())
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-07 17:48:39 +08:00
|
|
|
|
// 获取ATS测试-操作继电器
|
|
|
|
|
//
|
|
|
|
|
// @Summary 获取ATS测试-操作继电器
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description ATS测试-操作继电器
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param RelayOperationReqDto body dto.RelayOperationReqDto true "ATS测试仿真-操作继电器"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/relay/operation [post]
|
|
|
|
|
func relayOperation(c *gin.Context) {
|
2024-01-10 11:13:13 +08:00
|
|
|
|
req := &request_proto.RelayOperationReq{}
|
2023-10-07 17:48:39 +08:00
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New("继电器操作失败,请求参数异常", err))
|
2023-10-07 17:48:39 +08:00
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
2024-01-10 11:13:13 +08:00
|
|
|
|
slog.Info("传入状态参数", "param", req)
|
|
|
|
|
err := memory.HandleRelayOperation(simulation, req)
|
2023-11-06 14:30:09 +08:00
|
|
|
|
if err != nil {
|
|
|
|
|
panic(sys_error.New(fmt.Sprintf("继电器操作失败,%s", err.Error()), err))
|
|
|
|
|
}
|
2023-10-07 17:48:39 +08:00
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-10 14:06:01 +08:00
|
|
|
|
// 应答器移位
|
2024-01-08 17:45:24 +08:00
|
|
|
|
//
|
2024-01-10 14:06:01 +08:00
|
|
|
|
// @Summary 应答器移位
|
2024-01-08 17:45:24 +08:00
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
2024-01-10 14:06:01 +08:00
|
|
|
|
// @Description 应答器移位
|
2024-01-08 17:45:24 +08:00
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
2024-01-10 14:06:01 +08:00
|
|
|
|
// @Param BaliseMoveReqDto body dto.BaliseMoveReqDto true "应答器移位"
|
2024-01-08 17:45:24 +08:00
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
2024-01-10 14:06:01 +08:00
|
|
|
|
// @Router /api/v1/simulation/balise/position/modify [put]
|
|
|
|
|
func balisePositionModify(c *gin.Context) {
|
|
|
|
|
req := &dto.BaliseMoveReqDto{}
|
2024-01-08 17:45:24 +08:00
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(sys_error.New("应答器移位操作失败,请求参数异常", err))
|
|
|
|
|
}
|
2024-01-09 14:51:57 +08:00
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
2024-01-08 17:45:24 +08:00
|
|
|
|
slog.Info("传入状态参数", req)
|
2024-01-18 10:08:55 +08:00
|
|
|
|
var err *sys_error.BusinessError = memory.BalisePositionModify(simulation, req)
|
2024-01-08 17:45:24 +08:00
|
|
|
|
if err != nil {
|
2024-01-18 10:08:55 +08:00
|
|
|
|
panic(err)
|
2024-01-08 17:45:24 +08:00
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-10 14:06:01 +08:00
|
|
|
|
// 应答器复位
|
|
|
|
|
//
|
|
|
|
|
// @Summary 应答器复位
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 应答器复位
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param BaliseReqDto body dto.BaliseReqDto true "应答器复位"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/balise/position/reset [put]
|
2024-03-20 14:35:35 +08:00
|
|
|
|
func balisePositionReset(c *gin.Context) {
|
2024-01-10 14:06:01 +08:00
|
|
|
|
req := &dto.BaliseReqDto{}
|
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(sys_error.New("应答器复位操作失败,请求参数异常", err))
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
slog.Info("传入状态参数", req)
|
|
|
|
|
err := memory.BalisePositionReset(simulation, req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(sys_error.New(fmt.Sprintf("应答器复位操作失败,%s", err.Error()), err))
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 修改应答器报文
|
|
|
|
|
//
|
|
|
|
|
// @Summary 修改应答器报文
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 修改应答器报文
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param BaliseModifyTelegramReqDto body dto.BaliseModifyTelegramReqDto true "修改应答器报文"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/balise/telegram/modify [put]
|
|
|
|
|
func baliseTelegramModify(c *gin.Context) {
|
|
|
|
|
req := &dto.BaliseModifyTelegramReqDto{}
|
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(sys_error.New("应答器修改报文操作失败,请求参数异常", err))
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
slog.Info("传入状态参数", req)
|
2024-01-24 17:45:16 +08:00
|
|
|
|
var err *sys_error.BusinessError = memory.BaliseTelegramModify(simulation, req)
|
2024-01-10 14:06:01 +08:00
|
|
|
|
if err != nil {
|
2024-01-24 17:45:16 +08:00
|
|
|
|
panic(err)
|
2024-01-10 14:06:01 +08:00
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重置应答器报文
|
|
|
|
|
//
|
|
|
|
|
// @Summary 重置应答器报文
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 重置应答器报文
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param BaliseReqDto body dto.BaliseReqDto true "重置应答器报文"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/balise/telegram/reset [put]
|
|
|
|
|
func baliseTelegramReset(c *gin.Context) {
|
|
|
|
|
req := &dto.BaliseReqDto{}
|
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(sys_error.New("应答器重置报文操作失败,请求参数异常", err))
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
slog.Info("传入状态参数", req)
|
2024-02-06 09:30:58 +08:00
|
|
|
|
var err *sys_error.BusinessError = memory.BaliseTelegramReset(simulation, req)
|
2024-01-10 14:06:01 +08:00
|
|
|
|
if err != nil {
|
2024-02-06 09:30:58 +08:00
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 应答器报文停止发送
|
|
|
|
|
//
|
|
|
|
|
// @Summary 应答器报文停止发送
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 应答器报文停止发送
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param BaliseReqDto body dto.BaliseReqDto true "应答器报文停止发送"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/balise/telegram/stop [put]
|
|
|
|
|
func baliseTelegramStop(c *gin.Context) {
|
|
|
|
|
req := &dto.BaliseReqDto{}
|
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(sys_error.New("应答器停止报文操作失败,请求参数异常", err))
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
slog.Info("传入状态参数", req)
|
|
|
|
|
var err *sys_error.BusinessError = memory.BaliseTelegramStop(simulation, req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 应答器报文重新开始发送
|
|
|
|
|
//
|
|
|
|
|
// @Summary 应答器报文重新开始发送
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 应答器报文停止发送
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param BaliseReqDto body dto.BaliseReqDto true "应答器报文重新开始发送"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/balise/telegram/send [put]
|
|
|
|
|
func baliseTelegramSend(c *gin.Context) {
|
|
|
|
|
req := &dto.BaliseReqDto{}
|
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(sys_error.New("应答器停止报文操作失败,请求参数异常", err))
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
slog.Info("传入状态参数", req)
|
|
|
|
|
var err *sys_error.BusinessError = memory.BaliseTelegramSend(simulation, req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
2024-01-10 14:06:01 +08:00
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重置应答器状态
|
|
|
|
|
//
|
|
|
|
|
// @Summary 重置应答器状态
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 重置应答器状态
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
2024-01-11 10:24:56 +08:00
|
|
|
|
// @Param simulationId query string true "重置应答器状态"
|
2024-01-10 14:06:01 +08:00
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/balise/reset [put]
|
|
|
|
|
func baliseReset(c *gin.Context) {
|
2024-01-11 10:24:56 +08:00
|
|
|
|
//req := &dto.BaliseReqDto{}
|
|
|
|
|
//if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
// panic(sys_error.New("应答器状态重置操作失败,请求参数异常", err))
|
|
|
|
|
//}
|
|
|
|
|
simulationId := c.Query("simulationId")
|
|
|
|
|
simulation := checkDeviceDataAndReturn(simulationId)
|
|
|
|
|
err := memory.BaliseReset(simulation)
|
2024-01-10 14:06:01 +08:00
|
|
|
|
if err != nil {
|
|
|
|
|
panic(sys_error.New(fmt.Sprintf("应答器状态重置操作失败,%s", err.Error()), err))
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-20 14:35:35 +08:00
|
|
|
|
// 车库门操作
|
|
|
|
|
//
|
|
|
|
|
// @Summary 车库门操作
|
|
|
|
|
//
|
|
|
|
|
// @Security JwtAuth
|
|
|
|
|
//
|
|
|
|
|
// @Description 车库门操作
|
|
|
|
|
// @Tags ATS测试仿真Api
|
|
|
|
|
// @Accept json
|
|
|
|
|
// @Param Authorization header string true "JWT Token"
|
|
|
|
|
// @Param CkmOperationReq body request_proto.CkmOperationReq true "车库门操作"
|
|
|
|
|
//
|
|
|
|
|
// @Success 200 {object} string
|
|
|
|
|
// @Failure 500 {object} dto.ErrorDto
|
|
|
|
|
// @Router /api/v1/simulation/ckm/operation [put]
|
|
|
|
|
func ckmOperation(c *gin.Context) {
|
|
|
|
|
req := &request_proto.CkmOperationReq{}
|
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
|
|
|
panic(dto.ErrorDto{Code: dto.ArgumentParseError, Message: err.Error()})
|
|
|
|
|
}
|
|
|
|
|
simulation := checkDeviceDataAndReturn(req.SimulationId)
|
|
|
|
|
var err *sys_error.BusinessError = memory.CkmOperation(simulation, req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
c.JSON(http.StatusOK, "ok")
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-31 17:27:05 +08:00
|
|
|
|
// 获取仿真设备数据并返回
|
2023-08-01 14:54:11 +08:00
|
|
|
|
func checkDeviceDataAndReturn(simId string) *memory.VerifySimulation {
|
2023-10-26 17:16:07 +08:00
|
|
|
|
deviceMemory := ts.FindSimulation(simId)
|
2023-07-31 17:27:05 +08:00
|
|
|
|
if deviceMemory == nil {
|
2023-10-20 18:08:06 +08:00
|
|
|
|
panic(sys_error.New(fmt.Sprintf("仿真[%s]不存在", simId)))
|
2023-07-28 15:49:44 +08:00
|
|
|
|
}
|
2023-07-31 17:27:05 +08:00
|
|
|
|
return deviceMemory
|
2023-07-28 15:49:44 +08:00
|
|
|
|
}
|
2023-08-22 16:44:34 +08:00
|
|
|
|
|
|
|
|
|
// 获取列车主键
|
|
|
|
|
func getAddTrainPrimaryKey(simulation *memory.VerifySimulation) int {
|
|
|
|
|
trainMap := &simulation.Memory.Status.TrainStateMap
|
|
|
|
|
// 获取列车ID
|
|
|
|
|
i := 1
|
|
|
|
|
for {
|
2023-10-17 14:35:56 +08:00
|
|
|
|
_, ok := trainMap.Load(strconv.Itoa(i))
|
2023-08-31 16:16:18 +08:00
|
|
|
|
if !ok {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
i++
|
2023-08-22 16:44:34 +08:00
|
|
|
|
}
|
|
|
|
|
return i
|
|
|
|
|
}
|