动力学列车数据配置
This commit is contained in:
parent
c9ff61abba
commit
21d04e9e4c
|
@ -235,37 +235,6 @@ func addTrain(c *gin.Context) {
|
||||||
RunDirection: req.RunDirection,
|
RunDirection: req.RunDirection,
|
||||||
TrainLength: req.TrainLength,
|
TrainLength: req.TrainLength,
|
||||||
WheelDiameter: req.WheelDiameter,
|
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.AddTrainStateNew(simulation, rsp, req.ConfigTrain, req.TrainEndsA, req.TrainEndsB, req.MapId)
|
memory.AddTrainStateNew(simulation, rsp, req.ConfigTrain, req.TrainEndsA, req.TrainEndsB, req.MapId)
|
||||||
c.JSON(http.StatusOK, &rsp)
|
c.JSON(http.StatusOK, &rsp)
|
||||||
|
|
|
@ -69,17 +69,10 @@ func TrainConfigToProtoConvert(t *dto.ConfigTrainData) *common_proto.TrainDynami
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &common_proto.TrainDynamicConfig{
|
return &common_proto.TrainDynamicConfig{
|
||||||
BaseResistanceParamA: t.BaseResistanceParamA,
|
BaseResistanceParamA: t.BaseResistanceParamA, BaseResistanceParamB: t.BaseResistanceParamB, BaseResistanceParamC: t.BaseResistanceParamC,
|
||||||
BaseResistanceParamB: t.BaseResistanceParamB,
|
CurveResistanceParamR1: t.CurveResistanceParamR1, CurveResistanceParamR2: t.CurveResistanceParamR2, CurveResistanceParamR3: t.CurveResistanceParamR3, CurveResistanceParamR4: t.CurveResistanceParamR4,
|
||||||
BaseResistanceParamC: t.BaseResistanceParamC,
|
Jump: t.Jump, Slip: t.Slip,
|
||||||
CurveResistanceParamR1: t.CurveResistanceParamR1,
|
Slide: t.Slide, StopSign: t.StopSign,
|
||||||
CurveResistanceParamR2: t.CurveResistanceParamR2,
|
|
||||||
CurveResistanceParamR3: t.CurveResistanceParamR3,
|
|
||||||
CurveResistanceParamR4: t.CurveResistanceParamR4,
|
|
||||||
Jump: t.Jump,
|
|
||||||
Slip: t.Slip,
|
|
||||||
Slide: t.Slide,
|
|
||||||
StopSign: t.StopSign,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,15 +78,6 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
||||||
TailLinkOffset: tailLOffset,
|
TailLinkOffset: tailLOffset,
|
||||||
RunningUp: up,
|
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, trainEndsA, trainEndsB)
|
createOrUpdateStateDynamicConfig(status, configTrainData, trainEndsA, trainEndsB)
|
||||||
status.VobcState = &state_proto.TrainVobcState{}
|
status.VobcState = &state_proto.TrainVobcState{}
|
||||||
|
@ -194,23 +185,12 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
|
||||||
func createOrUpdateStateDynamicConfig(trainState *state_proto.TrainState, configTrainData dto.ConfigTrainData, trainEndsA dto.ConfigTrainEnds,
|
func createOrUpdateStateDynamicConfig(trainState *state_proto.TrainState, configTrainData dto.ConfigTrainData, trainEndsA dto.ConfigTrainEnds,
|
||||||
trainEndsB dto.ConfigTrainEnds) {
|
trainEndsB dto.ConfigTrainEnds) {
|
||||||
trainState.TrainDynamicConfig = service.TrainConfigToProtoConvert(&configTrainData)
|
trainState.TrainDynamicConfig = service.TrainConfigToProtoConvert(&configTrainData)
|
||||||
|
if trainState.TrainDynamicConfig == nil {
|
||||||
/*if trainState.TrainDynamicConfig == nil {
|
slog.Error("")
|
||||||
trainState.TrainDynamicConfig = &common_proto.TrainDynamicConfig{}
|
} else {
|
||||||
|
copyTrainEnds(trainState, "TrainEndsA", trainEndsA)
|
||||||
|
copyTrainEnds(trainState, "TrainEndsB", trainEndsB)
|
||||||
}
|
}
|
||||||
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, "TrainEndsA", trainEndsA)
|
|
||||||
copyTrainEnds(trainState, "TrainEndsB", trainEndsB)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyTrainEnds(trainState *state_proto.TrainState, fieldName string, configData dto.ConfigTrainEnds) {
|
func copyTrainEnds(trainState *state_proto.TrainState, fieldName string, configData dto.ConfigTrainEnds) {
|
||||||
|
@ -221,7 +201,7 @@ func copyTrainEnds(trainState *state_proto.TrainState, fieldName string, configD
|
||||||
fieldVal.Set(reflect.ValueOf(endsVal))
|
fieldVal.Set(reflect.ValueOf(endsVal))
|
||||||
}
|
}
|
||||||
endsVal.SpeedSensorEnableA = configData.SpeedSensorEnableA
|
endsVal.SpeedSensorEnableA = configData.SpeedSensorEnableA
|
||||||
endsVal.SpeedSensorEnableA = configData.SpeedSensorEnableB
|
endsVal.SpeedSensorEnableB = configData.SpeedSensorEnableB
|
||||||
endsVal.RadarEnable = configData.RadarEnable
|
endsVal.RadarEnable = configData.RadarEnable
|
||||||
endsVal.RadarCheckSpeed = configData.RadarCheckSpeed
|
endsVal.RadarCheckSpeed = configData.RadarCheckSpeed
|
||||||
endsVal.RadarCheckTime = configData.RadarCheckTime
|
endsVal.RadarCheckTime = configData.RadarCheckTime
|
||||||
|
|
Loading…
Reference in New Issue