From 4f8eab5a7a83d1e3c84c1ea7a7c734b6fc93311d Mon Sep 17 00:00:00 2001 From: tiger_zhou Date: Tue, 7 May 2024 15:00:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BD=A6pc=E4=BB=BF=E7=9C=9F=E8=B0=83?= =?UTF-8?q?=E6=95=B4=20=E4=B8=8A=E4=B8=8B=E8=A1=8C=E6=96=B9=E5=90=91?= =?UTF-8?q?=EF=BC=8C=E7=B4=A7=E6=80=A5=E5=81=9C=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wayside/memory/wayside_memory_train.go | 8 ++---- .../memory/wayside_simulation_train_pc.go | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ts/simulation/wayside/memory/wayside_memory_train.go b/ts/simulation/wayside/memory/wayside_memory_train.go index 86f6d27..4ed43e9 100644 --- a/ts/simulation/wayside/memory/wayside_memory_train.go +++ b/ts/simulation/wayside/memory/wayside_memory_train.go @@ -98,12 +98,8 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf if tl <= 0 { tl = DEFULAT_TRAIN_LOAD } - status.VobcState = &state_proto.TrainVobcState{Tc1Active: true, TrainLoad: int64(tl), BrakingStatus: true, BrakeForce: DEFAULT_BRAKE_FORCE} - if status.RunDirection { - status.VobcState.DirectionForward = true - } else { - status.VobcState.DirectionBackward = true - } + status.VobcState = &state_proto.TrainVobcState{Tc1Active: true, TrainLoad: int64(tl), BrakingStatus: true, BrakeForce: DEFAULT_BRAKE_FORCE, DirectionForward: true} + status.Tcc = initTrainTcc(vs, status.RunDirection) slog.Debug("列车初始化", "trainIndex", trainIndex, "linkId", linkId, "loffset", loffset) diff --git a/ts/simulation/wayside/memory/wayside_simulation_train_pc.go b/ts/simulation/wayside/memory/wayside_simulation_train_pc.go index 68528e9..49bfc27 100644 --- a/ts/simulation/wayside/memory/wayside_simulation_train_pc.go +++ b/ts/simulation/wayside/memory/wayside_simulation_train_pc.go @@ -59,20 +59,26 @@ func ControlTrainUpdate(s *VerifySimulation, ct *request_proto.TrainControl) { } func trainControlEB(trainState *state_proto.TrainState, request *request_proto.TrainControl_EmergentButton, deviceId uint32, tccGraphic *data_proto.TccGraphicStorage) []train_pc_sim.TrainControlEvent { - + if !request.Active { + return nil + } + if trainState.Tcc.Ebutton != nil && trainState.Tcc.Ebutton.Passed { + return nil + } _, find := findTrainTccGraphicDataButton(tccGraphic, deviceId) if !find { slog.Error("未找到对应的紧急停车摁钮,deviceId:", deviceId) return nil } - trainState.VobcState.EmergencyBrakingStatus = request.Active if trainState.Tcc.Ebutton == nil { trainState.Tcc.Ebutton = &state_proto.TrainControlState_EmergentButton{Id: deviceId, Passed: request.Active} - } else { - trainState.Tcc.Ebutton.Passed = request.Active } + trainState.VobcState.EmergencyBrakingStatus = true + trainState.Tcc.Ebutton.Passed = request.Active + trainState.VobcState.TractionForce = 0 + trainState.VobcState.BrakeForce = DEFAULT_BRAKE_FORCE + return nil - //return []train_pc_sim.TrainControlEvent{{Command: message.KEY_STATE, Status: message.IsTrue(request.Val)}} } // 列车方向 @@ -153,28 +159,26 @@ func trainControlHandle(trainState *state_proto.TrainState, request *request_pro trainState.VobcState.BrakeForce = 0 trainState.VobcState.MaintainBrakeStatus = false tce := make([]train_pc_sim.TrainControlEvent, 0) - //tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_FORWORD, Status: 0}) - //tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_BACKWORD, Status: 0}) tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_TO_ZERO, Status: 0}) if request.Val > 0 { trainState.VobcState.TractionStatus = true trainState.VobcState.TractionForce = int64(request.Val * 180) - //tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_FORWORD, Status: 1}) tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.TRAIN_BRAKE_STATE, Status: 0}) } else if request.Val < 0 { trainState.VobcState.BrakingStatus = true trainState.VobcState.BrakeForce = int64(-request.Val * 180) - //tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_BACKWORD, Status: 1}) + trainState.VobcState.EmergencyBrakingStatus = false + if trainState.Tcc.Ebutton != nil { + trainState.Tcc.Ebutton.Passed = false + } tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.TRAIN_BRAKE_STATE, Status: 1}) } else { - tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_TO_ZERO, Status: 1}) } if trainState.Tcc.PushHandler == nil { trainState.Tcc.PushHandler = &state_proto.TrainControlState_PushHandler{Id: deviceId, Val: request.Val} - } else { - trainState.Tcc.PushHandler.Val = request.Val } + trainState.Tcc.PushHandler.Val = request.Val return tce }