【仿真修改轮径接口】

This commit is contained in:
weizhihong 2023-11-13 15:57:32 +08:00
parent f7db9ebb13
commit 7893db2b5c
6 changed files with 249 additions and 0 deletions

View File

@ -29,6 +29,7 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
authed.POST("/check/data", checkSimMapData) authed.POST("/check/data", checkSimMapData)
authed.POST("/train/add", addTrain) authed.POST("/train/add", addTrain)
authed.POST("/train/remove", removeTrain) authed.POST("/train/remove", removeTrain)
authed.POST("/train/update", updateTrain)
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)
@ -206,6 +207,36 @@ func addTrain(c *gin.Context) {
c.JSON(http.StatusOK, &rsp) c.JSON(http.StatusOK, &rsp)
} }
// 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)
rsp := &state.TrainState{
Id: req.Id,
TrainLength: req.TrainLength,
WheelDiameter: req.WheelDiameter,
}
memory.UpdateTrainInfo(simulation, rsp)
c.JSON(http.StatusOK, &rsp)
}
// ATS测试仿真-移除列车 // ATS测试仿真-移除列车
// //
// @Summary ATS测试仿真-移除列车 // @Summary ATS测试仿真-移除列车

View File

@ -3946,6 +3946,58 @@ const docTemplate = `{
} }
} }
}, },
"/api/v1/simulation/train/update": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-修改列车基础信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "ATS测试仿真-修改列车基础信息",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "ATS测试仿真-修改列车基础信息",
"name": "UpdateTrainReqDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.UpdateTrainReqDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.AddTrainRspDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/trainManage/model": { "/api/v1/trainManage/model": {
"post": { "post": {
"security": [ "security": [
@ -5805,6 +5857,27 @@ const docTemplate = `{
} }
} }
}, },
"dto.UpdateTrainReqDto": {
"type": "object",
"properties": {
"id": {
"description": "列车Id",
"type": "string"
},
"simulationId": {
"description": "仿真id",
"type": "string"
},
"trainLength": {
"description": "列车长度",
"type": "integer"
},
"wheelDiameter": {
"description": "列车轮径",
"type": "integer"
}
}
},
"dto.UserRspDto": { "dto.UserRspDto": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -3939,6 +3939,58 @@
} }
} }
}, },
"/api/v1/simulation/train/update": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "ATS测试仿真-修改列车基础信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "ATS测试仿真-修改列车基础信息",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "ATS测试仿真-修改列车基础信息",
"name": "UpdateTrainReqDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.UpdateTrainReqDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.AddTrainRspDto"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/trainManage/model": { "/api/v1/trainManage/model": {
"post": { "post": {
"security": [ "security": [
@ -5798,6 +5850,27 @@
} }
} }
}, },
"dto.UpdateTrainReqDto": {
"type": "object",
"properties": {
"id": {
"description": "列车Id",
"type": "string"
},
"simulationId": {
"description": "仿真id",
"type": "string"
},
"trainLength": {
"description": "列车长度",
"type": "integer"
},
"wheelDiameter": {
"description": "列车轮径",
"type": "integer"
}
}
},
"dto.UserRspDto": { "dto.UserRspDto": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -399,6 +399,21 @@ definitions:
total_length: total_length:
type: integer type: integer
type: object type: object
dto.UpdateTrainReqDto:
properties:
id:
description: 列车Id
type: string
simulationId:
description: 仿真id
type: string
trainLength:
description: 列车长度
type: integer
wheelDiameter:
description: 列车轮径
type: integer
type: object
dto.UserRspDto: dto.UserRspDto:
properties: properties:
id: id:
@ -3325,6 +3340,39 @@ paths:
summary: ATS测试仿真-移除列车 summary: ATS测试仿真-移除列车
tags: tags:
- ATS测试仿真Api - ATS测试仿真Api
/api/v1/simulation/train/update:
post:
consumes:
- application/json
description: ATS测试仿真-修改列车基础信息
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- description: ATS测试仿真-修改列车基础信息
in: body
name: UpdateTrainReqDto
required: true
schema:
$ref: '#/definitions/dto.UpdateTrainReqDto'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.AddTrainRspDto'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: ATS测试仿真-修改列车基础信息
tags:
- ATS测试仿真Api
/api/v1/trainManage/model: /api/v1/trainManage/model:
post: post:
consumes: consumes:

View File

@ -55,6 +55,18 @@ type AddTrainReqDto struct {
WheelDiameter int32 `json:"wheelDiameter" from:"wheelDiameter"` WheelDiameter int32 `json:"wheelDiameter" from:"wheelDiameter"`
} }
// 为仿真添加测试车请求
type UpdateTrainReqDto struct {
// 仿真id
SimulationId string `json:"simulationId" form:"simulationId"`
// 列车Id
Id string `json:"id" form:"id"`
//列车长度
TrainLength int64 `json:"trainLength" from:"trainLength"`
// 列车轮径
WheelDiameter int32 `json:"wheelDiameter" from:"wheelDiameter"`
}
// 为仿真添加测试车请求 // 为仿真添加测试车请求
type AddTrainRspDto struct { type AddTrainRspDto struct {
//仿真id //仿真id

View File

@ -88,6 +88,18 @@ func AddTrainState(vs *VerifySimulation, status *state.TrainState, mapId int32)
allTrainMap.Store(status.Id, status) allTrainMap.Store(status.Id, status)
} }
// 修改列车信息
func UpdateTrainInfo(vs *VerifySimulation, status *state.TrainState) {
allTrainMap := &vs.Memory.Status.TrainStateMap
data, ok := allTrainMap.Load(status.Id)
if !ok {
panic(sys_error.New(fmt.Sprintf("列车【%s】不存在", status.Id)))
}
sta := data.(*state.TrainState)
sta.TrainLength = status.TrainLength
sta.WheelDiameter = status.WheelDiameter
}
// 根据动力学发来的信息修改列车状态 // 根据动力学发来的信息修改列车状态
func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *message.DynamicsTrainInfo) { func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *message.DynamicsTrainInfo) {
data, ok := vs.Memory.Status.TrainStateMap.Load(trainId) data, ok := vs.Memory.Status.TrainStateMap.Load(trainId)