列车pc仿真调整 上下行方向,紧急停车

This commit is contained in:
tiger_zhou 2024-05-07 15:00:59 +08:00
parent 398d1f1658
commit 4f8eab5a7a
2 changed files with 18 additions and 18 deletions

View File

@ -98,12 +98,8 @@ func AddTrainStateNew(vs *VerifySimulation, status *state_proto.TrainState, conf
if tl <= 0 { if tl <= 0 {
tl = DEFULAT_TRAIN_LOAD tl = DEFULAT_TRAIN_LOAD
} }
status.VobcState = &state_proto.TrainVobcState{Tc1Active: true, TrainLoad: int64(tl), BrakingStatus: true, BrakeForce: DEFAULT_BRAKE_FORCE} status.VobcState = &state_proto.TrainVobcState{Tc1Active: true, TrainLoad: int64(tl), BrakingStatus: true, BrakeForce: DEFAULT_BRAKE_FORCE, DirectionForward: true}
if status.RunDirection {
status.VobcState.DirectionForward = true
} else {
status.VobcState.DirectionBackward = true
}
status.Tcc = initTrainTcc(vs, status.RunDirection) status.Tcc = initTrainTcc(vs, status.RunDirection)
slog.Debug("列车初始化", "trainIndex", trainIndex, "linkId", linkId, "loffset", loffset) slog.Debug("列车初始化", "trainIndex", trainIndex, "linkId", linkId, "loffset", loffset)

View File

@ -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 { 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) _, find := findTrainTccGraphicDataButton(tccGraphic, deviceId)
if !find { if !find {
slog.Error("未找到对应的紧急停车摁钮,deviceId:", deviceId) slog.Error("未找到对应的紧急停车摁钮,deviceId:", deviceId)
return nil return nil
} }
trainState.VobcState.EmergencyBrakingStatus = request.Active
if trainState.Tcc.Ebutton == nil { if trainState.Tcc.Ebutton == nil {
trainState.Tcc.Ebutton = &state_proto.TrainControlState_EmergentButton{Id: deviceId, Passed: request.Active} 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 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.BrakeForce = 0
trainState.VobcState.MaintainBrakeStatus = false trainState.VobcState.MaintainBrakeStatus = false
tce := make([]train_pc_sim.TrainControlEvent, 0) 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}) tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_TO_ZERO, Status: 0})
if request.Val > 0 { if request.Val > 0 {
trainState.VobcState.TractionStatus = true trainState.VobcState.TractionStatus = true
trainState.VobcState.TractionForce = int64(request.Val * 180) 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}) tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.TRAIN_BRAKE_STATE, Status: 0})
} else if request.Val < 0 { } else if request.Val < 0 {
trainState.VobcState.BrakingStatus = true trainState.VobcState.BrakingStatus = true
trainState.VobcState.BrakeForce = int64(-request.Val * 180) 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}) tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.TRAIN_BRAKE_STATE, Status: 1})
} else { } else {
tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_TO_ZERO, Status: 1}) tce = append(tce, train_pc_sim.TrainControlEvent{Command: message.HANDLE_TO_ZERO, Status: 1})
} }
if trainState.Tcc.PushHandler == nil { if trainState.Tcc.PushHandler == nil {
trainState.Tcc.PushHandler = &state_proto.TrainControlState_PushHandler{Id: deviceId, Val: request.Val} 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 return tce
} }