diff --git a/api/simulation.go b/api/simulation.go index 9f26759..3eff0cf 100644 --- a/api/simulation.go +++ b/api/simulation.go @@ -235,37 +235,6 @@ 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.AddTrainStateNew(simulation, rsp, req.ConfigTrain, req.TrainEndsA, req.TrainEndsB, req.MapId) c.JSON(http.StatusOK, &rsp) diff --git a/service/trainManage.go b/service/trainManage.go index 49e9741..d5eace2 100644 --- a/service/trainManage.go +++ b/service/trainManage.go @@ -69,17 +69,10 @@ func TrainConfigToProtoConvert(t *dto.ConfigTrainData) *common_proto.TrainDynami return nil } return &common_proto.TrainDynamicConfig{ - BaseResistanceParamA: t.BaseResistanceParamA, - BaseResistanceParamB: t.BaseResistanceParamB, - BaseResistanceParamC: t.BaseResistanceParamC, - CurveResistanceParamR1: t.CurveResistanceParamR1, - CurveResistanceParamR2: t.CurveResistanceParamR2, - CurveResistanceParamR3: t.CurveResistanceParamR3, - CurveResistanceParamR4: t.CurveResistanceParamR4, - Jump: t.Jump, - Slip: t.Slip, - Slide: t.Slide, - StopSign: t.StopSign, + BaseResistanceParamA: t.BaseResistanceParamA, BaseResistanceParamB: t.BaseResistanceParamB, BaseResistanceParamC: t.BaseResistanceParamC, + CurveResistanceParamR1: t.CurveResistanceParamR1, CurveResistanceParamR2: t.CurveResistanceParamR2, CurveResistanceParamR3: t.CurveResistanceParamR3, CurveResistanceParamR4: t.CurveResistanceParamR4, + Jump: t.Jump, Slip: t.Slip, + Slide: t.Slide, StopSign: t.StopSign, } } diff --git a/ts/simulation/wayside/memory/wayside_memory_train.go b/ts/simulation/wayside/memory/wayside_memory_train.go index b8430d1..f22bb9c 100644 --- a/ts/simulation/wayside/memory/wayside_memory_train.go +++ b/ts/simulation/wayside/memory/wayside_memory_train.go @@ -78,15 +78,6 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf 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, trainEndsA, trainEndsB) 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, trainEndsB dto.ConfigTrainEnds) { trainState.TrainDynamicConfig = service.TrainConfigToProtoConvert(&configTrainData) - - /*if trainState.TrainDynamicConfig == nil { - trainState.TrainDynamicConfig = &common_proto.TrainDynamicConfig{} + if trainState.TrainDynamicConfig == nil { + slog.Error("") + } 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) { @@ -221,7 +201,7 @@ func copyTrainEnds(trainState *state_proto.TrainState, fieldName string, configD fieldVal.Set(reflect.ValueOf(endsVal)) } endsVal.SpeedSensorEnableA = configData.SpeedSensorEnableA - endsVal.SpeedSensorEnableA = configData.SpeedSensorEnableB + endsVal.SpeedSensorEnableB = configData.SpeedSensorEnableB endsVal.RadarEnable = configData.RadarEnable endsVal.RadarCheckSpeed = configData.RadarCheckSpeed endsVal.RadarCheckTime = configData.RadarCheckTime