动力学列车数据配置

This commit is contained in:
tiger_zhou 2024-01-17 13:09:45 +08:00
parent cc2b2e6715
commit 72374630de
8 changed files with 713 additions and 527 deletions

View File

@ -5215,6 +5215,22 @@ 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": "基本阻力参数A",
"type": "number"
@ -5255,18 +5271,6 @@ const docTemplate = `{
"description": "列车的质量100=1ton",
"type": "integer"
},
"radarCheckSpeed": {
"description": "雷达测速数值",
"type": "number"
},
"radarCheckTime": {
"description": "雷达检测时间(秒)",
"type": "integer"
},
"radarEnable": {
"description": "雷达是否有效",
"type": "boolean"
},
"revolvingMassParam": {
"description": "旋转质量参数",
"type": "number"
@ -5289,6 +5293,30 @@ const docTemplate = `{
}
}
},
"dto.ConfigTrainEnds": {
"type": "object",
"properties": {
"radarCheckSpeed": {
"description": "雷达测速数值",
"type": "number"
},
"radarCheckTime": {
"description": "雷达检测时间(秒)",
"type": "integer"
},
"radarEnable": {
"description": "雷达是否有效",
"type": "boolean"
},
"speedSensorEnable": {
"description": "2端速度传感器是否有效",
"type": "array",
"items": {
"type": "boolean"
}
}
}
},
"dto.ConfigTrainReqDto": {
"type": "object",
"properties": {

View File

@ -5209,6 +5209,22 @@
"dto.ConfigTrainData": {
"type": "object",
"properties": {
"TrainEndsA": {
"description": "车辆A端",
"allOf": [
{
"$ref": "#/definitions/dto.ConfigTrainEnds"
}
]
},
"TrainEndsB": {
"description": "车辆B端",
"allOf": [
{
"$ref": "#/definitions/dto.ConfigTrainEnds"
}
]
},
"baseResistanceParamA": {
"description": "基本阻力参数A",
"type": "number"
@ -5249,18 +5265,6 @@
"description": "列车的质量100=1ton",
"type": "integer"
},
"radarCheckSpeed": {
"description": "雷达测速数值",
"type": "number"
},
"radarCheckTime": {
"description": "雷达检测时间(秒)",
"type": "integer"
},
"radarEnable": {
"description": "雷达是否有效",
"type": "boolean"
},
"revolvingMassParam": {
"description": "旋转质量参数",
"type": "number"
@ -5283,6 +5287,30 @@
}
}
},
"dto.ConfigTrainEnds": {
"type": "object",
"properties": {
"radarCheckSpeed": {
"description": "雷达测速数值",
"type": "number"
},
"radarCheckTime": {
"description": "雷达检测时间(秒)",
"type": "integer"
},
"radarEnable": {
"description": "雷达是否有效",
"type": "boolean"
},
"speedSensorEnable": {
"description": "2端速度传感器是否有效",
"type": "array",
"items": {
"type": "boolean"
}
}
}
},
"dto.ConfigTrainReqDto": {
"type": "object",
"properties": {

View File

@ -180,6 +180,14 @@ definitions:
type: object
dto.ConfigTrainData:
properties:
TrainEndsA:
allOf:
- $ref: '#/definitions/dto.ConfigTrainEnds'
description: 车辆A端
TrainEndsB:
allOf:
- $ref: '#/definitions/dto.ConfigTrainEnds'
description: 车辆B端
baseResistanceParamA:
description: 基本阻力参数A
type: number
@ -210,15 +218,6 @@ definitions:
mass:
description: 列车的质量100=1ton
type: integer
radarCheckSpeed:
description: 雷达测速数值
type: number
radarCheckTime:
description: 雷达检测时间(秒)
type: integer
radarEnable:
description: 雷达是否有效
type: boolean
revolvingMassParam:
description: 旋转质量参数
type: number
@ -235,6 +234,23 @@ definitions:
description: 轮径mm
type: integer
type: object
dto.ConfigTrainEnds:
properties:
radarCheckSpeed:
description: 雷达测速数值
type: number
radarCheckTime:
description: 雷达检测时间(秒)
type: integer
radarEnable:
description: 雷达是否有效
type: boolean
speedSensorEnable:
description: 2端速度传感器是否有效
items:
type: boolean
type: array
type: object
dto.ConfigTrainReqDto:
properties:
TrainId:

View File

@ -63,7 +63,12 @@ type ConfigTrainReqDto struct {
TrainId int `json:"TrainId" form:"TrainId"`
ConfigData ConfigTrainData
}
type ConfigTrainEnds struct {
SpeedSensorEnable []bool `json:"speedSensorEnable"` // 2端速度传感器是否有效
RadarEnable bool `json:"radarEnable"` // 雷达是否有效
RadarCheckSpeed float32 `json:"radarCheckSpeed"` // 雷达测速数值
RadarCheckTime int32 `json:"radarCheckTime"` // 雷达检测时间(秒)
}
type ConfigTrainData struct {
//
Mass int32 `json:"mass" form:"mass"` // 列车的质量100=1ton
@ -81,9 +86,8 @@ type ConfigTrainData struct {
Slide int32 `json:"slide"` // 前溜/后溜mm正数前溜负数后溜
StopSign int32 `json:"stopSign"` // 过标/欠标mm正数过标负数欠标
WheelDiameter int32 `json:"wheelDiameter"` // 轮径mm
RadarEnable bool `json:"radarEnable"` // 雷达是否有效
RadarCheckSpeed float32 `json:"radarCheckSpeed"` // 雷达测速数值
RadarCheckTime int32 `json:"radarCheckTime"` // 雷达检测时间(秒)
TrainEndsA ConfigTrainEnds `json:"TrainEndsA"` // 车辆A端
TrainEndsB ConfigTrainEnds `json:"TrainEndsB"` // 车辆B端
}
// 为仿真添加测试车请求

File diff suppressed because it is too large Load Diff

View File

@ -384,6 +384,7 @@ google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

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

View File

@ -5,6 +5,7 @@ import (
"joylink.club/bj-rtsts-server/third_party/can_btm"
"log/slog"
"math"
"reflect"
"strconv"
"time"
@ -92,7 +93,7 @@ func AddTrainState(vs *VerifySimulation, status *state_proto.TrainState, mapId i
func UpdateConfigTrain(vs *VerifySimulation, ct *dto.ConfigTrainReqDto) {
allTrainMap := &vs.Memory.Status.TrainStateMap
data, ok := allTrainMap.Load(ct.TrainId)
data, ok := allTrainMap.Load(strconv.Itoa(ct.TrainId))
if !ok {
panic(sys_error.New(fmt.Sprintf("列车【%s】不存在", ct.TrainId)))
}
@ -116,14 +117,28 @@ func UpdateConfigTrain(vs *VerifySimulation, ct *dto.ConfigTrainReqDto) {
trainState.DynamicState.TrainDynamicConfig.Slip = ct.ConfigData.Slip
trainState.DynamicState.TrainDynamicConfig.Slide = ct.ConfigData.Slide
trainState.DynamicState.TrainDynamicConfig.StopSign = ct.ConfigData.StopSign
trainState.DynamicState.TrainDynamicConfig.RadarEnable = ct.ConfigData.RadarEnable
trainState.DynamicState.TrainDynamicConfig.RadarCheckSpeed = ct.ConfigData.RadarCheckSpeed
trainState.DynamicState.TrainDynamicConfig.RadarCheckTime = ct.ConfigData.RadarCheckTime
trainState.WheelDiameter = ct.ConfigData.WheelDiameter
requestDynamic(ct)
copyTrainEnds(trainState.DynamicState.TrainDynamicConfig, "TrainEndsA", ct.ConfigData.TrainEndsA)
copyTrainEnds(trainState.DynamicState.TrainDynamicConfig, "TrainEndsB", ct.ConfigData.TrainEndsB)
//requestDynamicConfig(ct)
}
func requestDynamic(ct *dto.ConfigTrainReqDto) {
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 := fieldVal.Interface().(*state_proto.TrainEndsState)
}
endsVal.SpeedSensorEnable = configData.SpeedSensorEnable
endsVal.RadarEnable = configData.RadarEnable
endsVal.RadarCheckSpeed = configData.RadarCheckSpeed
endsVal.RadarCheckTime = configData.RadarCheckTime
}
func requestDynamicConfig(ct *dto.ConfigTrainReqDto) {
cd := ct.ConfigData
msg := &message.TrainOperationConfig{TrainIndex: ct.TrainId, Mass: int(cd.Mass), Length: int(cd.Length),
BaseResistanceParamA: cd.BaseResistanceParamA, BaseResistanceParamB: cd.BaseResistanceParamB,
@ -132,7 +147,8 @@ func requestDynamic(ct *dto.ConfigTrainReqDto) {
CurveResistanceParamR4: cd.CurveResistanceParamR4, RevolvingMassParam: cd.RevolvingMassParam,
Jump: cd.Jump, Slip: cd.Slip, Slide: int(cd.Slide),
StopSign: int(cd.StopSign), WheelDiameter: int(cd.WheelDiameter)}
err := dynamics.Default().TrainOperationConfig(msg)
err2 := dynamics.Default().TrainOperationConfig(msg)
err := err2
if err != nil {
slog.Error("列车参数变更请求动力学失败", err)
panic(sys_error.New(fmt.Sprintf("列车参数变更请求动力学失败")))