Merge remote-tracking branch 'origin/master'

This commit is contained in:
joylink_zhangsai 2024-01-17 17:02:46 +08:00
commit 886e6d46f6
18 changed files with 1827 additions and 690 deletions

View File

@ -28,6 +28,7 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
authed.GET("/list", findAllSimulations)
authed.POST("/check/data", checkSimMapData)
authed.POST("/train/add", addTrain)
authed.POST("/train/config", configTrain)
authed.POST("/train/remove", removeTrain)
authed.POST("/train/update", updateTrain)
authed.POST("/switch/operation", turnoutOperation)
@ -174,6 +175,32 @@ func checkSimMapData(c *gin.Context) {
c.JSON(http.StatusOK, &dto.CheckMapDataRspDto{Success: true})
}
// 列车动力学参数配置修改
//
// @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")
}
// ATS测试仿真-添加列车
//
// @Summary ATS测试仿真-添加列车
@ -185,12 +212,13 @@ func checkSimMapData(c *gin.Context) {
// @Accept json
// @Produce json
// @Param Authorization header string true "JWT Token"
// @Param AddTrainReqDto body dto.AddTrainReqDto true "ATS测试仿真-添加列车"
// @Param AddTrainReqDto body dto.AddTrainReqDtoNew true "ATS测试仿真-添加列车"
// @Success 200 {object} dto.AddTrainRspDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/train/add [post]
func addTrain(c *gin.Context) {
req := dto.AddTrainReqDto{}
//req := dto.AddTrainReqDto{}
req := dto.AddTrainReqDtoNew{}
if err := c.ShouldBind(&req); err != nil {
panic(sys_error.New("添加列车失败,请求参数异常", err))
}
@ -207,8 +235,39 @@ func addTrain(c *gin.Context) {
RunDirection: req.RunDirection,
TrainLength: req.TrainLength,
WheelDiameter: req.WheelDiameter,
/*TrainDynamicConfig: &state_proto.TrainDynamicConfig{
//int32 mass=1;
//基本阻力参数A
BaseResistanceParamA: req.ConfigTrain.BaseResistanceParamA,
// 基本阻力参数B
BaseResistanceParamB: req.ConfigTrain.BaseResistanceParamB,
// 基本阻力参数C
BaseResistanceParamC: req.ConfigTrain.BaseResistanceParamC,
//曲线阻力参数R1
CurveResistanceParamR1: req.ConfigTrain.CurveResistanceParamR1,
// 曲线阻力参数R2
CurveResistanceParamR2: req.ConfigTrain.CurveResistanceParamR2,
// 曲线阻力参数R3
CurveResistanceParamR3: req.ConfigTrain.CurveResistanceParamR3,
// 曲线阻力参数R4
CurveResistanceParamR4: req.ConfigTrain.CurveResistanceParamR4,
//旋转质量参数
RevolvingMassParam: req.ConfigTrain.RevolvingMassParam,
//是否跳跃
Jump: req.ConfigTrain.Jump,
//打滑(%
Slip: req.ConfigTrain.Slip,
//前溜/后溜mm正数前溜负数后溜
Slide: req.ConfigTrain.Slide,
//过标/欠标mm正数过标负数欠标
StopSign: req.ConfigTrain.StopSign,
//车径
//WheelDiameter: req.ConfigTrain.WheelDiameter,
TrainEndsA: memory.DtoTrainEndsToStateProto(req.ConfigTrain.TrainEndsA),
TrainEndsB: memory.DtoTrainEndsToStateProto(req.ConfigTrain.TrainEndsB),
},*/
}
memory.AddTrainState(simulation, rsp, req.MapId)
memory.AddTrainStateNew(simulation, rsp, req.ConfigTrain, req.MapId)
c.JSON(http.StatusOK, &rsp)
}

@ -1 +1 @@
Subproject commit 411729dc6a357f8bab7df24d66ea93cb5ba77c0a
Subproject commit 923e04f548ef2d5c6571912468ae16829b1594d8

View File

@ -1,5 +1,4 @@
// Code generated by swaggo/swag. DO NOT EDIT.
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
@ -4166,7 +4165,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AddTrainReqDto"
"$ref": "#/definitions/dto.AddTrainReqDtoNew"
}
}
],
@ -4186,6 +4185,58 @@ const docTemplate = `{
}
}
},
"/api/v1/simulation/train/config": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "地图数据校验",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "列车动力学参数配置修改",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "动力学参数配置",
"name": "RemoveTrainDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.ConfigTrainReqDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/train/remove": {
"post": {
"security": [
@ -4903,9 +4954,66 @@ const docTemplate = `{
}
},
"definitions": {
"dto.AddTrainReqDto": {
"data_proto.KilometerSystem": {
"type": "object",
"properties": {
"coordinateSystem": {
"description": "坐标系",
"type": "string"
},
"direction": {
"description": "左右行",
"allOf": [
{
"$ref": "#/definitions/data_proto.KilometerSystem_Direction"
}
]
},
"kilometer": {
"description": "公里标mm",
"type": "integer"
}
}
},
"data_proto.KilometerSystem_Direction": {
"type": "integer",
"enum": [
0,
1
],
"x-enum-varnames": [
"KilometerSystem_LEFT",
"KilometerSystem_RIGHT"
]
},
"data_proto.PictureType": {
"type": "integer",
"enum": [
0,
1,
2,
3,
4
],
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl",
"PictureType_RelayCabinetLayout",
"PictureType_IBP",
"PictureType_TrainData"
]
},
"dto.AddTrainReqDtoNew": {
"type": "object",
"properties": {
"ConfigTrain": {
"description": "列车数据配置",
"allOf": [
{
"$ref": "#/definitions/dto.ConfigTrainData"
}
]
},
"devicePort": {
"description": "道岔端口",
"type": "string"
@ -4943,7 +5051,6 @@ const docTemplate = `{
"type": "boolean"
},
"wheelDiameter": {
"description": "列车轮径",
"type": "integer"
}
}
@ -5037,10 +5144,8 @@ const docTemplate = `{
"type": "string"
},
"telegram": {
"type": "array",
"items": {
"type": "integer"
}
"description": "报文16进制字符串",
"type": "string"
}
}
},
@ -5055,7 +5160,7 @@ const docTemplate = `{
"description": "公里标",
"allOf": [
{
"$ref": "#/definitions/graphicData.KilometerSystem"
"$ref": "#/definitions/data_proto.KilometerSystem"
}
]
},
@ -5114,6 +5219,123 @@ const docTemplate = `{
}
}
},
"dto.ConfigTrainData": {
"type": "object",
"properties": {
"TrainEndsA": {
"description": "车辆A端",
"allOf": [
{
"$ref": "#/definitions/dto.ConfigTrainEnds"
}
]
},
"TrainEndsB": {
"description": "车辆B端",
"allOf": [
{
"$ref": "#/definitions/dto.ConfigTrainEnds"
}
]
},
"baseResistanceParamA": {
"description": "Mass int32 ` + "`" + `json:\"mass\" form:\"mass\"` + "`" + ` // 列车的质量100=1ton",
"type": "number"
},
"baseResistanceParamB": {
"description": "基本阻力参数B",
"type": "number"
},
"baseResistanceParamC": {
"description": "基本阻力参数C",
"type": "number"
},
"curveResistanceParamR1": {
"description": "曲线阻力参数R1",
"type": "number"
},
"curveResistanceParamR2": {
"description": "曲线阻力参数R2",
"type": "number"
},
"curveResistanceParamR3": {
"description": "曲线阻力参数R3",
"type": "number"
},
"curveResistanceParamR4": {
"description": "曲线阻力参数R4",
"type": "number"
},
"jump": {
"description": "是否跳跃",
"type": "boolean"
},
"revolvingMassParam": {
"description": "旋转质量参数",
"type": "number"
},
"slide": {
"description": "前溜/后溜mm正数前溜负数后溜",
"type": "integer"
},
"slip": {
"description": "打滑(%",
"type": "number"
},
"stopSign": {
"description": "过标/欠标mm正数过标负数欠标",
"type": "integer"
}
}
},
"dto.ConfigTrainEnds": {
"type": "object",
"properties": {
"radarCheckSpeed": {
"description": "雷达测速数值",
"type": "number"
},
"radarCheckTime": {
"description": "雷达检测时间(秒)",
"type": "integer"
},
"radarEnable": {
"description": "雷达是否有效",
"type": "boolean"
},
"speedSensorEnableA": {
"description": "2端速度传感器是否有效",
"type": "boolean"
},
"speedSensorEnableB": {
"description": "2端速度传感器是否有效",
"type": "boolean"
}
}
},
"dto.ConfigTrainReqDto": {
"type": "object",
"properties": {
"TrainId": {
"description": "列车Id",
"type": "integer"
},
"configData": {
"$ref": "#/definitions/dto.ConfigTrainData"
},
"length": {
"description": "列车的长度cm",
"type": "integer"
},
"simulationId": {
"type": "string"
},
"wheelDiameter": {
"description": "轮径mm",
"type": "integer"
}
}
},
"dto.ErrorDto": {
"type": "object",
"properties": {
@ -5487,7 +5709,7 @@ const docTemplate = `{
"description": "当操作为Operation.Display时有效表示显示的信号",
"allOf": [
{
"$ref": "#/definitions/state.Signal_Aspect"
"$ref": "#/definitions/state_proto.Signal_Aspect"
}
]
},
@ -5680,55 +5902,6 @@ const docTemplate = `{
}
}
},
"graphicData.KilometerSystem": {
"type": "object",
"properties": {
"coordinateSystem": {
"description": "坐标系",
"type": "string"
},
"direction": {
"description": "左右行",
"allOf": [
{
"$ref": "#/definitions/graphicData.KilometerSystem_Direction"
}
]
},
"kilometer": {
"description": "公里标mm",
"type": "integer"
}
}
},
"graphicData.KilometerSystem_Direction": {
"type": "integer",
"enum": [
0,
1
],
"x-enum-varnames": [
"KilometerSystem_LEFT",
"KilometerSystem_RIGHT"
]
},
"graphicData.PictureType": {
"type": "integer",
"enum": [
0,
1,
2,
3,
4
],
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl",
"PictureType_RelayCabinetLayout",
"PictureType_IBP",
"PictureType_TrainData"
]
},
"model.AuthAPIPath": {
"type": "object",
"properties": {
@ -6107,7 +6280,7 @@ const docTemplate = `{
"Turnout_CancelForce"
]
},
"state.Signal_Aspect": {
"state_proto.Signal_Aspect": {
"type": "integer",
"enum": [
0,

View File

@ -4159,7 +4159,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AddTrainReqDto"
"$ref": "#/definitions/dto.AddTrainReqDtoNew"
}
}
],
@ -4179,6 +4179,58 @@
}
}
},
"/api/v1/simulation/train/config": {
"post": {
"security": [
{
"JwtAuth": []
}
],
"description": "地图数据校验",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"ATS测试仿真Api"
],
"summary": "列车动力学参数配置修改",
"parameters": [
{
"type": "string",
"description": "JWT Token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "动力学参数配置",
"name": "RemoveTrainDto",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.ConfigTrainReqDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorDto"
}
}
}
}
},
"/api/v1/simulation/train/remove": {
"post": {
"security": [
@ -4896,9 +4948,66 @@
}
},
"definitions": {
"dto.AddTrainReqDto": {
"data_proto.KilometerSystem": {
"type": "object",
"properties": {
"coordinateSystem": {
"description": "坐标系",
"type": "string"
},
"direction": {
"description": "左右行",
"allOf": [
{
"$ref": "#/definitions/data_proto.KilometerSystem_Direction"
}
]
},
"kilometer": {
"description": "公里标mm",
"type": "integer"
}
}
},
"data_proto.KilometerSystem_Direction": {
"type": "integer",
"enum": [
0,
1
],
"x-enum-varnames": [
"KilometerSystem_LEFT",
"KilometerSystem_RIGHT"
]
},
"data_proto.PictureType": {
"type": "integer",
"enum": [
0,
1,
2,
3,
4
],
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl",
"PictureType_RelayCabinetLayout",
"PictureType_IBP",
"PictureType_TrainData"
]
},
"dto.AddTrainReqDtoNew": {
"type": "object",
"properties": {
"ConfigTrain": {
"description": "列车数据配置",
"allOf": [
{
"$ref": "#/definitions/dto.ConfigTrainData"
}
]
},
"devicePort": {
"description": "道岔端口",
"type": "string"
@ -4936,7 +5045,6 @@
"type": "boolean"
},
"wheelDiameter": {
"description": "列车轮径",
"type": "integer"
}
}
@ -5030,10 +5138,8 @@
"type": "string"
},
"telegram": {
"type": "array",
"items": {
"type": "integer"
}
"description": "报文16进制字符串",
"type": "string"
}
}
},
@ -5048,7 +5154,7 @@
"description": "公里标",
"allOf": [
{
"$ref": "#/definitions/graphicData.KilometerSystem"
"$ref": "#/definitions/data_proto.KilometerSystem"
}
]
},
@ -5107,6 +5213,123 @@
}
}
},
"dto.ConfigTrainData": {
"type": "object",
"properties": {
"TrainEndsA": {
"description": "车辆A端",
"allOf": [
{
"$ref": "#/definitions/dto.ConfigTrainEnds"
}
]
},
"TrainEndsB": {
"description": "车辆B端",
"allOf": [
{
"$ref": "#/definitions/dto.ConfigTrainEnds"
}
]
},
"baseResistanceParamA": {
"description": "Mass int32 `json:\"mass\" form:\"mass\"` // 列车的质量100=1ton",
"type": "number"
},
"baseResistanceParamB": {
"description": "基本阻力参数B",
"type": "number"
},
"baseResistanceParamC": {
"description": "基本阻力参数C",
"type": "number"
},
"curveResistanceParamR1": {
"description": "曲线阻力参数R1",
"type": "number"
},
"curveResistanceParamR2": {
"description": "曲线阻力参数R2",
"type": "number"
},
"curveResistanceParamR3": {
"description": "曲线阻力参数R3",
"type": "number"
},
"curveResistanceParamR4": {
"description": "曲线阻力参数R4",
"type": "number"
},
"jump": {
"description": "是否跳跃",
"type": "boolean"
},
"revolvingMassParam": {
"description": "旋转质量参数",
"type": "number"
},
"slide": {
"description": "前溜/后溜mm正数前溜负数后溜",
"type": "integer"
},
"slip": {
"description": "打滑(%",
"type": "number"
},
"stopSign": {
"description": "过标/欠标mm正数过标负数欠标",
"type": "integer"
}
}
},
"dto.ConfigTrainEnds": {
"type": "object",
"properties": {
"radarCheckSpeed": {
"description": "雷达测速数值",
"type": "number"
},
"radarCheckTime": {
"description": "雷达检测时间(秒)",
"type": "integer"
},
"radarEnable": {
"description": "雷达是否有效",
"type": "boolean"
},
"speedSensorEnableA": {
"description": "2端速度传感器是否有效",
"type": "boolean"
},
"speedSensorEnableB": {
"description": "2端速度传感器是否有效",
"type": "boolean"
}
}
},
"dto.ConfigTrainReqDto": {
"type": "object",
"properties": {
"TrainId": {
"description": "列车Id",
"type": "integer"
},
"configData": {
"$ref": "#/definitions/dto.ConfigTrainData"
},
"length": {
"description": "列车的长度cm",
"type": "integer"
},
"simulationId": {
"type": "string"
},
"wheelDiameter": {
"description": "轮径mm",
"type": "integer"
}
}
},
"dto.ErrorDto": {
"type": "object",
"properties": {
@ -5480,7 +5703,7 @@
"description": "当操作为Operation.Display时有效表示显示的信号",
"allOf": [
{
"$ref": "#/definitions/state.Signal_Aspect"
"$ref": "#/definitions/state_proto.Signal_Aspect"
}
]
},
@ -5673,55 +5896,6 @@
}
}
},
"graphicData.KilometerSystem": {
"type": "object",
"properties": {
"coordinateSystem": {
"description": "坐标系",
"type": "string"
},
"direction": {
"description": "左右行",
"allOf": [
{
"$ref": "#/definitions/graphicData.KilometerSystem_Direction"
}
]
},
"kilometer": {
"description": "公里标mm",
"type": "integer"
}
}
},
"graphicData.KilometerSystem_Direction": {
"type": "integer",
"enum": [
0,
1
],
"x-enum-varnames": [
"KilometerSystem_LEFT",
"KilometerSystem_RIGHT"
]
},
"graphicData.PictureType": {
"type": "integer",
"enum": [
0,
1,
2,
3,
4
],
"x-enum-varnames": [
"PictureType_StationLayout",
"PictureType_Psl",
"PictureType_RelayCabinetLayout",
"PictureType_IBP",
"PictureType_TrainData"
]
},
"model.AuthAPIPath": {
"type": "object",
"properties": {
@ -6100,7 +6274,7 @@
"Turnout_CancelForce"
]
},
"state.Signal_Aspect": {
"state_proto.Signal_Aspect": {
"type": "integer",
"enum": [
0,

View File

@ -1,7 +1,46 @@
basePath: /
definitions:
dto.AddTrainReqDto:
data_proto.KilometerSystem:
properties:
coordinateSystem:
description: 坐标系
type: string
direction:
allOf:
- $ref: '#/definitions/data_proto.KilometerSystem_Direction'
description: 左右行
kilometer:
description: 公里标mm
type: integer
type: object
data_proto.KilometerSystem_Direction:
enum:
- 0
- 1
type: integer
x-enum-varnames:
- KilometerSystem_LEFT
- KilometerSystem_RIGHT
data_proto.PictureType:
enum:
- 0
- 1
- 2
- 3
- 4
type: integer
x-enum-varnames:
- PictureType_StationLayout
- PictureType_Psl
- PictureType_RelayCabinetLayout
- PictureType_IBP
- PictureType_TrainData
dto.AddTrainReqDtoNew:
properties:
ConfigTrain:
allOf:
- $ref: '#/definitions/dto.ConfigTrainData'
description: 列车数据配置
devicePort:
description: 道岔端口
type: string
@ -30,7 +69,6 @@ definitions:
description: 列车方向,true-上行false-下行
type: boolean
wheelDiameter:
description: 列车轮径
type: integer
type: object
dto.AddTrainRspDto:
@ -94,9 +132,8 @@ definitions:
description: 仿真ID
type: string
telegram:
items:
type: integer
type: array
description: 报文16进制字符串
type: string
type: object
dto.BaliseMoveReqDto:
properties:
@ -105,7 +142,7 @@ definitions:
type: integer
km:
allOf:
- $ref: '#/definitions/graphicData.KilometerSystem'
- $ref: '#/definitions/data_proto.KilometerSystem'
description: 公里标
mapId:
description: 地图ID
@ -144,6 +181,88 @@ definitions:
success:
type: boolean
type: object
dto.ConfigTrainData:
properties:
TrainEndsA:
allOf:
- $ref: '#/definitions/dto.ConfigTrainEnds'
description: 车辆A端
TrainEndsB:
allOf:
- $ref: '#/definitions/dto.ConfigTrainEnds'
description: 车辆B端
baseResistanceParamA:
description: Mass int32 `json:"mass" form:"mass"` //
列车的质量100=1ton
type: number
baseResistanceParamB:
description: 基本阻力参数B
type: number
baseResistanceParamC:
description: 基本阻力参数C
type: number
curveResistanceParamR1:
description: 曲线阻力参数R1
type: number
curveResistanceParamR2:
description: 曲线阻力参数R2
type: number
curveResistanceParamR3:
description: 曲线阻力参数R3
type: number
curveResistanceParamR4:
description: 曲线阻力参数R4
type: number
jump:
description: 是否跳跃
type: boolean
revolvingMassParam:
description: 旋转质量参数
type: number
slide:
description: 前溜/后溜mm正数前溜负数后溜
type: integer
slip:
description: 打滑(%
type: number
stopSign:
description: 过标/欠标mm正数过标负数欠标
type: integer
type: object
dto.ConfigTrainEnds:
properties:
radarCheckSpeed:
description: 雷达测速数值
type: number
radarCheckTime:
description: 雷达检测时间(秒)
type: integer
radarEnable:
description: 雷达是否有效
type: boolean
speedSensorEnableA:
description: 2端速度传感器是否有效
type: boolean
speedSensorEnableB:
description: 2端速度传感器是否有效
type: boolean
type: object
dto.ConfigTrainReqDto:
properties:
TrainId:
description: 列车Id
type: integer
configData:
$ref: '#/definitions/dto.ConfigTrainData'
length:
description: 列车的长度cm
type: integer
simulationId:
type: string
wheelDiameter:
description: 轮径mm
type: integer
type: object
dto.ErrorDto:
properties:
code:
@ -392,7 +511,7 @@ definitions:
properties:
aspect:
allOf:
- $ref: '#/definitions/state.Signal_Aspect'
- $ref: '#/definitions/state_proto.Signal_Aspect'
description: 当操作为Operation.Display时有效表示显示的信号
id:
type: integer
@ -528,41 +647,6 @@ definitions:
$ref: '#/definitions/dto.AuthRoleRspDto'
type: array
type: object
graphicData.KilometerSystem:
properties:
coordinateSystem:
description: 坐标系
type: string
direction:
allOf:
- $ref: '#/definitions/graphicData.KilometerSystem_Direction'
description: 左右行
kilometer:
description: 公里标mm
type: integer
type: object
graphicData.KilometerSystem_Direction:
enum:
- 0
- 1
type: integer
x-enum-varnames:
- KilometerSystem_LEFT
- KilometerSystem_RIGHT
graphicData.PictureType:
enum:
- 0
- 1
- 2
- 3
- 4
type: integer
x-enum-varnames:
- PictureType_StationLayout
- PictureType_Psl
- PictureType_RelayCabinetLayout
- PictureType_IBP
- PictureType_TrainData
model.AuthAPIPath:
properties:
id:
@ -864,7 +948,7 @@ definitions:
description: 仿真id
type: string
type: object
state.Signal_Aspect:
state_proto.Signal_Aspect:
enum:
- 0
- 1
@ -3525,7 +3609,7 @@ paths:
name: AddTrainReqDto
required: true
schema:
$ref: '#/definitions/dto.AddTrainReqDto'
$ref: '#/definitions/dto.AddTrainReqDtoNew'
produces:
- application/json
responses:
@ -3542,6 +3626,39 @@ paths:
summary: ATS测试仿真-添加列车
tags:
- ATS测试仿真Api
/api/v1/simulation/train/config:
post:
consumes:
- application/json
description: 地图数据校验
parameters:
- description: JWT Token
in: header
name: Authorization
required: true
type: string
- description: 动力学参数配置
in: body
name: RemoveTrainDto
required: true
schema:
$ref: '#/definitions/dto.ConfigTrainReqDto'
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.ErrorDto'
security:
- JwtAuth: []
summary: 列车动力学参数配置修改
tags:
- ATS测试仿真Api
/api/v1/simulation/train/remove:
post:
consumes:

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: ibpGraphics.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: picture.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: pslGraphics.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: relayCabinetLayoutGraphics.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: stationLayoutGraphics.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc-gen-go v1.32.0
// protoc v4.23.1
// source: request.proto

View File

@ -55,6 +55,63 @@ type AddTrainReqDto struct {
// 列车轮径
WheelDiameter int32 `json:"wheelDiameter" from:"wheelDiameter"`
}
type AddTrainReqDtoNew struct {
//仿真id
SimulationId string `json:"simulationId" form:"simulationId"`
//列车方向,true-上行false-下行
RunDirection bool `json:"up" form:"up"`
//车头所在link的索引
HeadLinkId string `json:"headLinkId" form:"headLinkId"`
//车头所在link内的偏移量单位为mm
HeadLinkOffset int64 `json:"headLinkOffset" form:"headLinkOffset"`
//物理区段、道岔ID
Id uint32 `json:"id" form:"id"`
//道岔端口
DevicePort string `json:"devicePort" form:"devicePort"`
//车头所在link内的偏移量单位为mm
HeadOffset int64 `json:"headOffset" form:"headOffset"`
//列车长度
TrainLength int64 `json:"trainLength" from:"trainLength"`
// 场景ID
MapId int32 `json:"mapId" from:"mapId"`
WheelDiameter int32 `json:"wheelDiameter" from:"wheelDiameter"`
// 列车数据配置
ConfigTrain ConfigTrainData `json:"ConfigTrain" from:"mapId"`
}
// 为反正列车修改对应的测试配置
type ConfigTrainReqDto struct {
SimulationId string `json:"simulationId" form:"simulationId"`
// 列车Id
TrainId int `json:"TrainId" form:"TrainId"`
Length int64 `json:"length"` // 列车的长度cm
ConfigData ConfigTrainData
WheelDiameter int32 `json:"wheelDiameter"` // 轮径mm
}
type ConfigTrainEnds struct {
SpeedSensorEnableA bool `json:"speedSensorEnableA"` // 2端速度传感器是否有效
SpeedSensorEnableB bool `json:"speedSensorEnableB"` // 2端速度传感器是否有效
RadarEnable bool `json:"radarEnable"` // 雷达是否有效
RadarCheckSpeed float32 `json:"radarCheckSpeed"` // 雷达测速数值
RadarCheckTime int32 `json:"radarCheckTime"` // 雷达检测时间(秒)
}
type ConfigTrainData struct {
//Mass int32 `json:"mass" form:"mass"` // 列车的质量100=1ton
BaseResistanceParamA float32 `json:"baseResistanceParamA"` // 基本阻力参数A
BaseResistanceParamB float32 `json:"baseResistanceParamB"` // 基本阻力参数B
BaseResistanceParamC float32 `json:"baseResistanceParamC"` // 基本阻力参数C
CurveResistanceParamR1 float32 `json:"curveResistanceParamR1"` // 曲线阻力参数R1
CurveResistanceParamR2 float32 `json:"curveResistanceParamR2"` // 曲线阻力参数R2
CurveResistanceParamR3 float32 `json:"curveResistanceParamR3"` // 曲线阻力参数R3
CurveResistanceParamR4 float32 `json:"curveResistanceParamR4"` // 曲线阻力参数R4
RevolvingMassParam float32 `json:"revolvingMassParam"` // 旋转质量参数
Jump bool `json:"jump"` // 是否跳跃
Slip float32 `json:"slip"` // 打滑(%
Slide int32 `json:"slide"` // 前溜/后溜mm正数前溜负数后溜
StopSign int32 `json:"stopSign"` // 过标/欠标mm正数过标负数欠标
TrainEndsA ConfigTrainEnds `json:"TrainEndsA"` // 车辆A端
TrainEndsB ConfigTrainEnds `json:"TrainEndsB"` // 车辆B端
}
// 为仿真添加测试车请求
type UpdateTrainReqDto struct {

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit 655a0712af53b18d1eeb73eee309af12b2142b5a
Subproject commit 79484bea97a47b76e8f0f0deb42d64286ddf0af7

View File

@ -30,7 +30,8 @@ type Dynamics interface {
RequestAddTrain(info *message.InitTrainInfo) error
// 请求移除列车
RequestRemoveTrain(req *message.RemoveTrainReq) error
//请求变更列车参数
TrainOperationConfig(req *message.TrainOperationConfig) error
// 启动动力学消息功能
Start(manager DynamicsMessageManager) error
// 停止动力学消息功能
@ -167,6 +168,25 @@ func (d *dynamics) RequestRemoveTrain(req *message.RemoveTrainReq) error {
return nil
}
// 动力学数据设置
func (d *dynamics) TrainOperationConfig(req *message.TrainOperationConfig) error {
if !d.runConfig.Open {
return nil
}
data, _ := json.Marshal(req)
url := d.buildUrl("/api/config")
resp, err := d.httpClient.Post(url, "application/json", bytes.NewBuffer(data))
defer resp.Body.Close()
if err != nil {
return fmt.Errorf("动力学移除列车请求异常: %v", err)
}
var bodyData []byte
_, err = resp.Body.Read(bodyData)
if err != nil {
return fmt.Errorf("动力学移除列车响应读取异常: %v", err)
}
return nil
}
func (d *dynamics) Start(manager DynamicsMessageManager) error {
if manager == nil {
panic("启动动力学消息服务错误: DynamicsMessageManager不能为nil")

View File

@ -5,9 +5,10 @@ type InitTrainInfo struct {
LinkIndex uint16 `json:"linkIndex"`
LinkOffset uint32 `json:"linkOffset"`
//单位0.1km/h
Speed uint16 `json:"speed"`
Up bool `json:"up"`
TrainLength uint32 `json:"trainLength"`
Speed uint16 `json:"speed"`
Up bool `json:"up"`
//TrainLength uint32 `json:"trainLength"`
TrainOperationConfig *TrainOperationConfig `json:"TrainOperationConfig"`
}
// 移除列车请求参数
@ -50,3 +51,24 @@ type Curve struct {
EndLinkOffset int32 `json:"endLinkOffset"`
Curvature int32 `json:"curvature"`
}
type TrainOperationConfig struct {
TrainIndex int `json:"trainIndex"`
//Mass int `json:"mass" form:"mass"` //列车的质量100=1ton
Length int `json:"列车的长度cm"`
BaseResistanceParamA float32 `json:"基本阻力参数A"`
BaseResistanceParamB float32 `json:"基本阻力参数B"`
BaseResistanceParamC float32 `json:"基本阻力参数C"`
CurveResistanceParamR1 float32 `json:"曲线阻力参数R1"`
CurveResistanceParamR2 float32 `json:"曲线阻力参数R2"`
CurveResistanceParamR3 float32 `json:"曲线阻力参数R3"`
CurveResistanceParamR4 float32 `json:"曲线阻力参数R4"`
RevolvingMassParam float32 `json:"旋转质量参数"`
Jump bool `json:"是否跳跃"`
Slip float32 `json:"打滑(%"`
Slide int `json:"前溜/后溜mm正数前溜负数后溜"`
StopSign int `json:"过标/欠标mm正数过标负数欠标"`
//WheelDiameter int `json:"轮径mm"`
//RadarSpeed float32 `json:"雷达速度差值m/s"`
//RadarDuration int `json:"雷达速度差值持续时间ms"`
//RadarIsValid bool `json:"雷达是否失效"`
}

View File

@ -8,16 +8,6 @@ import (
"joylink.club/rtsssimulation/fi"
)
// 继电器操作方法
func ChangeRelayState(sim *VerifySimulation, mapId int32, id uint32, td bool) error {
uid := QueryUidByMidAndComId(mapId, id, &data_proto.Relay{})
if td {
return fi.DriveRelayUp(sim.World, uid)
} else {
return fi.DriveRelayDown(sim.World, uid)
}
}
// 处理继电器操作
func HandleRelayOperation(simulation *VerifySimulation, req *request_proto.RelayOperationReq) error {
uid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &data_proto.Relay{})

View File

@ -5,6 +5,7 @@ import (
"joylink.club/bj-rtsts-server/third_party/can_btm"
"log/slog"
"math"
"reflect"
"strconv"
"time"
@ -18,8 +19,105 @@ import (
"joylink.club/bj-rtsts-server/dto/state_proto"
)
func DtoTrainEndsToStateProto(ends dto.ConfigTrainEnds) *state_proto.TrainEndsState {
return &state_proto.TrainEndsState{SpeedSensorEnableA: ends.SpeedSensorEnableA, SpeedSensorEnableB: ends.SpeedSensorEnableB,
RadarEnable: ends.RadarEnable, RadarCheckSpeed: ends.RadarCheckSpeed, RadarCheckTime: ends.RadarCheckTime}
}
func CreateMsgTrainConfig(trainId int, trainLen int64, configTrainData dto.ConfigTrainData) *message.TrainOperationConfig {
return &message.TrainOperationConfig{TrainIndex: trainId, Length: int(trainLen),
BaseResistanceParamA: configTrainData.BaseResistanceParamA, BaseResistanceParamB: configTrainData.BaseResistanceParamB,
BaseResistanceParamC: configTrainData.BaseResistanceParamC, CurveResistanceParamR1: configTrainData.CurveResistanceParamR1,
CurveResistanceParamR2: configTrainData.CurveResistanceParamR2, CurveResistanceParamR3: configTrainData.CurveResistanceParamR3,
CurveResistanceParamR4: configTrainData.CurveResistanceParamR4, RevolvingMassParam: configTrainData.RevolvingMassParam,
Jump: configTrainData.Jump, Slip: configTrainData.Slip, Slide: int(configTrainData.Slide),
StopSign: int(configTrainData.StopSign)}
}
// 增加列车状态
func AddTrainState(vs *VerifySimulation, status *state_proto.TrainState, mapId int32) *state_proto.TrainState {
func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, configTrainData dto.ConfigTrainData, mapId int32) *state_proto.TrainState {
allTrainMap := &vs.Memory.Status.TrainStateMap
_, ok := allTrainMap.Load(status.Id)
if ok {
panic(fmt.Sprintf("列车【%s】已存在", status.Id))
}
// 显示状态
status.Show = true
//向动力学发送初始化请求
trainIndex, _ := strconv.ParseUint(status.Id, 10, 16)
slog.Debug("添加列车", "trainIndex", trainIndex, "HeadDeviceId", status.HeadDeviceId, "HeadOffset", status.HeadOffset)
// 映射link、偏移量、运行方向
var uid string
if status.DevicePort == "" {
uid = QueryUidByMidAndComId(mapId, status.HeadDeviceId, &data_proto.Section{})
} else {
uid = QueryUidByMidAndComId(mapId, status.HeadDeviceId, &data_proto.Turnout{})
}
// 车头所在link、link上的偏移
linkId, loffset := QueryLinkAndOffsetByDevice(vs.Repo, uid, status.DevicePort, status.HeadOffset)
// link上的运行方向、设备上的运行方向
up, pointTo := QueryUpAndABByDevice(vs.Repo, uid, status.DevicePort, status.RunDirection)
// 车头所在公里标
kilometer := CalcTrainKilometer(vs.Repo, uid, status.DevicePort, status.RunDirection, status.HeadOffset)
// 车尾相对车头link的偏移量
calctailOffset := calcTrailTailOffset(loffset, status.TrainLength, up)
// 车尾位置
tailLink, _, _, tailLOffset, _, _, e1 := CalcInitializeLink(vs, linkId, calctailOffset, up)
if e1 != nil {
panic(sys_error.New("添加列车失败,列车车尾占用位置计算出错", e1))
}
status.Up = up
status.PointTo = pointTo
status.TrainKilometer = kilometer.Value
status.DynamicState = &state_proto.TrainDynamicState{
HeadLinkId: linkId,
HeadLinkOffset: loffset,
TailLinkId: tailLink,
TailLinkOffset: tailLOffset,
RunningUp: up,
}
/* status.TrainDynamicConfig = &state_proto.TrainDynamicConfig{
BaseResistanceParamA: configTrainData.BaseResistanceParamA, BaseResistanceParamB: configTrainData.BaseResistanceParamB,
BaseResistanceParamC: configTrainData.BaseResistanceParamC, CurveResistanceParamR1: configTrainData.CurveResistanceParamR1,
CurveResistanceParamR2: configTrainData.CurveResistanceParamR2, CurveResistanceParamR3: configTrainData.CurveResistanceParamR3,
CurveResistanceParamR4: configTrainData.CurveResistanceParamR4, RevolvingMassParam: configTrainData.RevolvingMassParam,
Jump: configTrainData.Jump, Slip: configTrainData.Slip,
Slide: configTrainData.Slide, StopSign: configTrainData.StopSign,
TrainEndsA: DtoTrainEndsToStateProto(configTrainData.TrainEndsA),
TrainEndsB: DtoTrainEndsToStateProto(configTrainData.TrainEndsB)}*/
//初始化列车参数状态
createOrUpdateStateDynamicConfig(status, configTrainData)
status.VobcState = &state_proto.TrainVobcState{}
slog.Debug("列车初始化", "trainIndex", trainIndex, "linkId", linkId, "loffset", loffset)
linkIdInt, _ := strconv.Atoi(linkId)
err := dynamics.Default().RequestAddTrain(&message.InitTrainInfo{
TrainIndex: uint16(trainIndex),
LinkIndex: uint16(linkIdInt),
LinkOffset: uint32(loffset),
Speed: uint16(math.Round(float64(status.Speed * 10))),
Up: status.Up,
TrainOperationConfig: CreateMsgTrainConfig(int(trainIndex), status.TrainLength, configTrainData),
})
if err != nil {
panic(dto.ErrorDto{Code: dto.DynamicsError, Message: err.Error()})
}
// world中加车
fi.AddTrainToWorld(vs.World, status.Id)
fi.UpdateTrainPositionFromDynamics(vs.World, fi.TrainPositionInfo{
TrainId: status.Id,
Up: status.Up,
Len: uint32(status.TrainLength),
HeadLink: linkId,
HeadLinkOffset: uint32(loffset),
TailLink: tailLink,
TailLinkOffset: uint32(tailLOffset),
})
// 将信息合并到当前设备状态中
allTrainMap.Store(status.Id, status)
return status
}
// 增加列车状态
/*func AddTrainState(vs *VerifySimulation, status *state_proto.TrainState, mapId int32) *state_proto.TrainState {
allTrainMap := &vs.Memory.Status.TrainStateMap
_, ok := allTrainMap.Load(status.Id)
if ok {
@ -88,6 +186,81 @@ func AddTrainState(vs *VerifySimulation, status *state_proto.TrainState, mapId i
// 将信息合并到当前设备状态中
allTrainMap.Store(status.Id, status)
return status
}*/
func createOrUpdateStateDynamicConfig(trainState *state_proto.TrainState, configTrainData dto.ConfigTrainData) {
if trainState.TrainDynamicConfig == nil {
trainState.TrainDynamicConfig = &state_proto.TrainDynamicConfig{}
}
trainState.TrainDynamicConfig.BaseResistanceParamA = configTrainData.BaseResistanceParamA
trainState.TrainDynamicConfig.BaseResistanceParamB = configTrainData.BaseResistanceParamB
trainState.TrainDynamicConfig.BaseResistanceParamC = configTrainData.BaseResistanceParamC
trainState.TrainDynamicConfig.CurveResistanceParamR1 = configTrainData.CurveResistanceParamR1
trainState.TrainDynamicConfig.CurveResistanceParamR2 = configTrainData.CurveResistanceParamR2
trainState.TrainDynamicConfig.CurveResistanceParamR3 = configTrainData.CurveResistanceParamR3
trainState.TrainDynamicConfig.CurveResistanceParamR4 = configTrainData.CurveResistanceParamR4
trainState.TrainDynamicConfig.Jump = configTrainData.Jump
trainState.TrainDynamicConfig.Slip = configTrainData.Slip
trainState.TrainDynamicConfig.Slide = configTrainData.Slide
trainState.TrainDynamicConfig.StopSign = configTrainData.StopSign
copyTrainEnds(trainState.TrainDynamicConfig, "TrainEndsA", configTrainData.TrainEndsA)
copyTrainEnds(trainState.TrainDynamicConfig, "TrainEndsB", configTrainData.TrainEndsB)
}
func copyTrainEnds(trainState *state_proto.TrainDynamicConfig, fieldName string, configData dto.ConfigTrainEnds) {
fieldVal := reflect.ValueOf(trainState).Elem().FieldByName(fieldName)
endsVal := fieldVal.Interface().(*state_proto.TrainEndsState)
if endsVal == nil {
endsVal = &state_proto.TrainEndsState{}
fieldVal.Set(reflect.ValueOf(endsVal))
}
endsVal.SpeedSensorEnableA = configData.SpeedSensorEnableA
endsVal.SpeedSensorEnableA = configData.SpeedSensorEnableB
endsVal.RadarEnable = configData.RadarEnable
endsVal.RadarCheckSpeed = configData.RadarCheckSpeed
endsVal.RadarCheckTime = configData.RadarCheckTime
}
func UpdateConfigTrain(vs *VerifySimulation, ct *dto.ConfigTrainReqDto) {
allTrainMap := &vs.Memory.Status.TrainStateMap
data, ok := allTrainMap.Load(strconv.Itoa(ct.TrainId))
if !ok {
panic(sys_error.New(fmt.Sprintf("列车【%s】不存在", ct.TrainId)))
}
trainState, ok := data.(*state_proto.TrainState)
if !ok {
panic(sys_error.New(fmt.Sprintf("列车参数修改断言:列车【%s】不存在", ct.TrainId)))
}
createOrUpdateStateDynamicConfig(trainState, ct.ConfigData)
/* if trainState.TrainDynamicConfig == nil {
trainState.TrainDynamicConfig = &state_proto.TrainDynamicConfig{}
}*/
/*trainState.TrainDynamicConfig.BaseResistanceParamA = ct.ConfigData.BaseResistanceParamA
trainState.TrainDynamicConfig.BaseResistanceParamB = ct.ConfigData.BaseResistanceParamB
trainState.TrainDynamicConfig.BaseResistanceParamC = ct.ConfigData.BaseResistanceParamC
trainState.TrainDynamicConfig.CurveResistanceParamR1 = ct.ConfigData.CurveResistanceParamR1
trainState.TrainDynamicConfig.CurveResistanceParamR2 = ct.ConfigData.CurveResistanceParamR2
trainState.TrainDynamicConfig.CurveResistanceParamR3 = ct.ConfigData.CurveResistanceParamR3
trainState.TrainDynamicConfig.CurveResistanceParamR4 = ct.ConfigData.CurveResistanceParamR4
trainState.TrainDynamicConfig.Jump = ct.ConfigData.Jump
trainState.TrainDynamicConfig.Slip = ct.ConfigData.Slip
trainState.TrainDynamicConfig.Slide = ct.ConfigData.Slide
trainState.TrainDynamicConfig.StopSign = ct.ConfigData.StopSign*/
trainState.TrainLength = ct.Length
trainState.WheelDiameter = ct.WheelDiameter
//copyTrainEnds(trainState.TrainDynamicConfig, "TrainEndsA", ct.ConfigData.TrainEndsA)
//copyTrainEnds(trainState.TrainDynamicConfig, "TrainEndsB", ct.ConfigData.TrainEndsB)
//requestDynamicConfig(ct)
}
func requestDynamicConfig(ct *dto.ConfigTrainReqDto) {
msg := CreateMsgTrainConfig(ct.TrainId, ct.Length, ct.ConfigData)
err2 := dynamics.Default().TrainOperationConfig(msg)
err := err2
if err != nil {
slog.Error("列车参数变更请求动力学失败", err)
panic(sys_error.New(fmt.Sprintf("列车参数变更请求动力学失败")))
}
}
// 修改列车信息