动力学列车数据配置

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": { "dto.ConfigTrainData": {
"type": "object", "type": "object",
"properties": { "properties": {
"TrainEndsA": {
"description": "车辆A端",
"allOf": [
{
"$ref": "#/definitions/dto.ConfigTrainEnds"
}
]
},
"TrainEndsB": {
"description": "车辆B端",
"allOf": [
{
"$ref": "#/definitions/dto.ConfigTrainEnds"
}
]
},
"baseResistanceParamA": { "baseResistanceParamA": {
"description": "基本阻力参数A", "description": "基本阻力参数A",
"type": "number" "type": "number"
@ -5255,18 +5271,6 @@ const docTemplate = `{
"description": "列车的质量100=1ton", "description": "列车的质量100=1ton",
"type": "integer" "type": "integer"
}, },
"radarCheckSpeed": {
"description": "雷达测速数值",
"type": "number"
},
"radarCheckTime": {
"description": "雷达检测时间(秒)",
"type": "integer"
},
"radarEnable": {
"description": "雷达是否有效",
"type": "boolean"
},
"revolvingMassParam": { "revolvingMassParam": {
"description": "旋转质量参数", "description": "旋转质量参数",
"type": "number" "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": { "dto.ConfigTrainReqDto": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

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

View File

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

View File

@ -63,27 +63,31 @@ type ConfigTrainReqDto struct {
TrainId int `json:"TrainId" form:"TrainId"` TrainId int `json:"TrainId" form:"TrainId"`
ConfigData ConfigTrainData 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 { type ConfigTrainData struct {
// //
Mass int32 `json:"mass" form:"mass"` // 列车的质量100=1ton Mass int32 `json:"mass" form:"mass"` // 列车的质量100=1ton
Length int64 `json:"length"` // 列车的长度cm Length int64 `json:"length"` // 列车的长度cm
BaseResistanceParamA float32 `json:"baseResistanceParamA"` // 基本阻力参数A BaseResistanceParamA float32 `json:"baseResistanceParamA"` // 基本阻力参数A
BaseResistanceParamB float32 `json:"baseResistanceParamB"` // 基本阻力参数B BaseResistanceParamB float32 `json:"baseResistanceParamB"` // 基本阻力参数B
BaseResistanceParamC float32 `json:"baseResistanceParamC"` // 基本阻力参数C BaseResistanceParamC float32 `json:"baseResistanceParamC"` // 基本阻力参数C
CurveResistanceParamR1 float32 `json:"curveResistanceParamR1"` // 曲线阻力参数R1 CurveResistanceParamR1 float32 `json:"curveResistanceParamR1"` // 曲线阻力参数R1
CurveResistanceParamR2 float32 `json:"curveResistanceParamR2"` // 曲线阻力参数R2 CurveResistanceParamR2 float32 `json:"curveResistanceParamR2"` // 曲线阻力参数R2
CurveResistanceParamR3 float32 `json:"curveResistanceParamR3"` // 曲线阻力参数R3 CurveResistanceParamR3 float32 `json:"curveResistanceParamR3"` // 曲线阻力参数R3
CurveResistanceParamR4 float32 `json:"curveResistanceParamR4"` // 曲线阻力参数R4 CurveResistanceParamR4 float32 `json:"curveResistanceParamR4"` // 曲线阻力参数R4
RevolvingMassParam float32 `json:"revolvingMassParam"` // 旋转质量参数 RevolvingMassParam float32 `json:"revolvingMassParam"` // 旋转质量参数
Jump bool `json:"jump"` // 是否跳跃 Jump bool `json:"jump"` // 是否跳跃
Slip float32 `json:"slip"` // 打滑(% Slip float32 `json:"slip"` // 打滑(%
Slide int32 `json:"slide"` // 前溜/后溜mm正数前溜负数后溜 Slide int32 `json:"slide"` // 前溜/后溜mm正数前溜负数后溜
StopSign int32 `json:"stopSign"` // 过标/欠标mm正数过标负数欠标 StopSign int32 `json:"stopSign"` // 过标/欠标mm正数过标负数欠标
WheelDiameter int32 `json:"wheelDiameter"` // 轮径mm WheelDiameter int32 `json:"wheelDiameter"` // 轮径mm
RadarEnable bool `json:"radarEnable"` // 雷达是否有效 TrainEndsA ConfigTrainEnds `json:"TrainEndsA"` // 车辆A端
RadarCheckSpeed float32 `json:"radarCheckSpeed"` // 雷达测速数值 TrainEndsB ConfigTrainEnds `json:"TrainEndsB"` // 车辆B端
RadarCheckTime int32 `json:"radarCheckTime"` // 雷达检测时间(秒)
} }
// 为仿真添加测试车请求 // 为仿真添加测试车请求

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 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= 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/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.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.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/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" "joylink.club/bj-rtsts-server/third_party/can_btm"
"log/slog" "log/slog"
"math" "math"
"reflect"
"strconv" "strconv"
"time" "time"
@ -92,7 +93,7 @@ func AddTrainState(vs *VerifySimulation, status *state_proto.TrainState, mapId i
func UpdateConfigTrain(vs *VerifySimulation, ct *dto.ConfigTrainReqDto) { func UpdateConfigTrain(vs *VerifySimulation, ct *dto.ConfigTrainReqDto) {
allTrainMap := &vs.Memory.Status.TrainStateMap allTrainMap := &vs.Memory.Status.TrainStateMap
data, ok := allTrainMap.Load(ct.TrainId) data, ok := allTrainMap.Load(strconv.Itoa(ct.TrainId))
if !ok { if !ok {
panic(sys_error.New(fmt.Sprintf("列车【%s】不存在", ct.TrainId))) 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.Slip = ct.ConfigData.Slip
trainState.DynamicState.TrainDynamicConfig.Slide = ct.ConfigData.Slide trainState.DynamicState.TrainDynamicConfig.Slide = ct.ConfigData.Slide
trainState.DynamicState.TrainDynamicConfig.StopSign = ct.ConfigData.StopSign 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 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 cd := ct.ConfigData
msg := &message.TrainOperationConfig{TrainIndex: ct.TrainId, Mass: int(cd.Mass), Length: int(cd.Length), msg := &message.TrainOperationConfig{TrainIndex: ct.TrainId, Mass: int(cd.Mass), Length: int(cd.Length),
BaseResistanceParamA: cd.BaseResistanceParamA, BaseResistanceParamB: cd.BaseResistanceParamB, BaseResistanceParamA: cd.BaseResistanceParamA, BaseResistanceParamB: cd.BaseResistanceParamB,
@ -132,7 +147,8 @@ func requestDynamic(ct *dto.ConfigTrainReqDto) {
CurveResistanceParamR4: cd.CurveResistanceParamR4, RevolvingMassParam: cd.RevolvingMassParam, CurveResistanceParamR4: cd.CurveResistanceParamR4, RevolvingMassParam: cd.RevolvingMassParam,
Jump: cd.Jump, Slip: cd.Slip, Slide: int(cd.Slide), Jump: cd.Jump, Slip: cd.Slip, Slide: int(cd.Slide),
StopSign: int(cd.StopSign), WheelDiameter: int(cd.WheelDiameter)} StopSign: int(cd.StopSign), WheelDiameter: int(cd.WheelDiameter)}
err := dynamics.Default().TrainOperationConfig(msg) err2 := dynamics.Default().TrainOperationConfig(msg)
err := err2
if err != nil { if err != nil {
slog.Error("列车参数变更请求动力学失败", err) slog.Error("列车参数变更请求动力学失败", err)
panic(sys_error.New(fmt.Sprintf("列车参数变更请求动力学失败"))) panic(sys_error.New(fmt.Sprintf("列车参数变更请求动力学失败")))