This commit is contained in:
parent
9a5e8be378
commit
9809df4b27
File diff suppressed because it is too large
Load Diff
|
@ -1 +1 @@
|
|||
Subproject commit 259b99e6102d79dc3f78e29e742f18fb8b7d1a7a
|
||||
Subproject commit 0a0de33fd10ea2ddca55ca9d3cc8acad971e4449
|
|
@ -41,7 +41,7 @@ type TrainPcSim interface {
|
|||
//发布列车控制的相关事件
|
||||
//PublishTrainControlEvent(train *state_proto.TrainState, events []TrainControlEvent)
|
||||
|
||||
SendTrainControlMsg(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage)
|
||||
SendTrainControlMsg(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage, aport bool)
|
||||
// CreateOrRemoveSpeedPLace 创建或删除速度位置信息
|
||||
//CreateOrRemoveSpeedPLace(train *state_proto.TrainState)
|
||||
// CreateOrRemoveTrain 创建或删除列车
|
||||
|
@ -116,7 +116,18 @@ func (d *trainPcSimService) ServiceDesc() string {
|
|||
func FindTrainPcSimClientKey2(t *state_proto.TrainState) string {
|
||||
return t.ConnState.TypeName
|
||||
}
|
||||
|
||||
func (d *trainPcSimService) findTrainConnForPort(sta *state_proto.TrainState, aport bool) (*TrainPcReciverData, error) {
|
||||
rds := d.newPcSimclientMap3[sta.ConnState.TypeName]
|
||||
if rds == nil {
|
||||
return nil, fmt.Errorf("")
|
||||
}
|
||||
for _, rd := range rds {
|
||||
if rd.aPort == aport {
|
||||
return rd, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("")
|
||||
}
|
||||
func (d *trainPcSimService) findTrainConn(sta *state_proto.TrainState) (*TrainPcReciverData, error) {
|
||||
rds := d.newPcSimclientMap3[sta.ConnState.TypeName]
|
||||
if rds == nil {
|
||||
|
@ -177,12 +188,11 @@ func (d *trainPcSimService) TrainPluseCount(sta *state_proto.TrainState, h1, h2,
|
|||
default:
|
||||
}
|
||||
|
||||
/*if sd, err := d.findTrainConn(sta); err == nil {
|
||||
sd.speedPlace.PulseCount1 += sta.DynamicState.Displacement
|
||||
//sd.speedPlace.PulseCount2 = sd.speedPlace.PulseCount1
|
||||
}*/
|
||||
for _, sd := range d.findTrainAllConn(sta) {
|
||||
sd.speedPlace.PulseCount1 += sta.DynamicState.Displacement
|
||||
if sd.speedPlace != nil {
|
||||
|
||||
sd.speedPlace.PulseCount1 += sta.DynamicState.Displacement
|
||||
}
|
||||
}
|
||||
if sta.TrainRunUp {
|
||||
if sta.TrainEndsA.SpeedSensorEnableA {
|
||||
|
@ -434,7 +444,7 @@ func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
|
|||
trainClients := d.newPcSimclientMap3[train.ConnState.TypeName]
|
||||
for _, trainClient := range trainClients {
|
||||
if trainClient.success {
|
||||
if trainClient.speedPlace == nil {
|
||||
if trainClient.speedPlace == nil || trainClient.tcpClient == nil {
|
||||
slog.Error(fmt.Sprintf("pc仿真速度位置脉冲对象为空 列车id:%v", train.Id))
|
||||
continue
|
||||
}
|
||||
|
@ -492,10 +502,16 @@ func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) {
|
|||
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
||||
}
|
||||
}*/
|
||||
if vobc.Tc1Active || vobc.Tc2Active {
|
||||
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
||||
if trainClient.aPort {
|
||||
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
||||
if vobc.Tc1Active {
|
||||
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
||||
}
|
||||
} else {
|
||||
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
|
||||
if vobc.Tc2Active {
|
||||
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
|
||||
}
|
||||
}
|
||||
msgs := make([]byte, 0)
|
||||
if msg.Type == message.SENDER_TRAIN_TC_ACTIVE {
|
||||
|
@ -507,7 +523,7 @@ func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) {
|
|||
}
|
||||
msgs = append(msgs, msg.Encode()...)
|
||||
hexData := hex.EncodeToString(msgs)
|
||||
//slog.Info(fmt.Sprintf("发送驾驶激活列车id:%v,数据:%v", train.Id, hexData))
|
||||
slog.Info(fmt.Sprintf("发送驾驶激活列车id:%v,数据:%v", train.Id, hexData), trainClient.aPort)
|
||||
err := trainClient.tcpClient.Send(msgs)
|
||||
|
||||
if err != nil {
|
||||
|
@ -601,11 +617,12 @@ func (d *trainPcSimService) SendBaliseData(train *state_proto.TrainState, msgTyp
|
|||
}
|
||||
}
|
||||
|
||||
func (d *trainPcSimService) SendTrainControlMsg(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage) {
|
||||
func (d *trainPcSimService) SendTrainControlMsg(train *state_proto.TrainState, baseMessage []message.TrainPcSimBaseMessage, aport bool) {
|
||||
if len(baseMessage) <= 0 {
|
||||
return
|
||||
}
|
||||
trainClient, trainDataErr := d.findTrainConn(train)
|
||||
//trainClient, trainDataErr := d.findTrainConn(train)
|
||||
trainClient, trainDataErr := d.findTrainConnForPort(train, aport)
|
||||
if trainDataErr != nil {
|
||||
slog.Error(fmt.Sprintf("发送列车控制信息失败,无连接,列车Id:%v", train.Id))
|
||||
return
|
||||
|
@ -613,7 +630,7 @@ func (d *trainPcSimService) SendTrainControlMsg(train *state_proto.TrainState, b
|
|||
|
||||
for _, msg := range baseMessage {
|
||||
dd := msg.Encode()
|
||||
//slog.Info(fmt.Sprintf("发送列车控制信息:%x", dd))
|
||||
slog.Info(fmt.Sprintf("发送操控列车控制信息:%x", dd), aport)
|
||||
d.sendData(trainClient.tcpClient, dd)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,8 +265,10 @@ func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainIn
|
|||
// 更新列车状态
|
||||
trainState := UpdateTrainStateByDynamics(s, trainId, info)
|
||||
vs := train.VobcState
|
||||
|
||||
if vs.Ato {
|
||||
trainAtoControlTractionAndBrake(train)
|
||||
|
||||
trainAtoControlTractionAndBrake(train, true)
|
||||
var msgs []message.TrainPcSimBaseMessage
|
||||
if vs.AtoOpenRightDoor || vs.AtoOpenLeftDoor {
|
||||
btn := train.Tcc.Buttons[KZM]
|
||||
|
@ -281,7 +283,7 @@ func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainIn
|
|||
}
|
||||
msgs = controlDoorCloseBtn(train.VobcState, true, btn, vs.AtoOpenLeftDoor, false)
|
||||
}
|
||||
train_pc_sim.Default().SendTrainControlMsg(train, msgs)
|
||||
train_pc_sim.Default().SendTrainControlMsg(train, msgs, false)
|
||||
|
||||
} else if vs.TractionStatus {
|
||||
f := trainTractionPower(train.TrainLoad, train.Tcc.PushHandler.Val, trainState.DynamicState.Speed, train.TrainMaxAcc, train.TrainMaxSpeed)
|
||||
|
|
|
@ -39,6 +39,9 @@ func ControlTrainUpdate(s *VerifySimulation, ct *request_proto.TrainControl) {
|
|||
sta := data.(*state_proto.TrainState)
|
||||
vobc := sta.VobcState
|
||||
tcc := sta.Tcc
|
||||
if ct.ControlType != request_proto.TrainControl_DRIVER_KEY_SWITCH && vobc.Tc1Active == false && vobc.Tc2Active == false {
|
||||
panic(sys_error.New("请先上驾驶端钥匙"))
|
||||
}
|
||||
|
||||
var baseMsg []message.TrainPcSimBaseMessage = nil
|
||||
if ct.ControlType == request_proto.TrainControl_EMERGENT_BUTTON {
|
||||
|
@ -78,7 +81,16 @@ func ControlTrainUpdate(s *VerifySimulation, ct *request_proto.TrainControl) {
|
|||
vobc.TractionForce = 0
|
||||
}
|
||||
if sta.ConnState.Conn && (sta.ConnState.ConnType == state_proto.TrainConnState_PC_SIM) && baseMsg != nil {
|
||||
train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg)
|
||||
if sta.TrainPort == state_proto.TrainState_PORT_A {
|
||||
train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg, true)
|
||||
} else if sta.TrainPort == state_proto.TrainState_PORT_B {
|
||||
train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg, false)
|
||||
}
|
||||
if vobc.Tc1Active == false && vobc.Tc2Active == false {
|
||||
sta.TrainPort = state_proto.TrainState_PORT_NONE
|
||||
}
|
||||
//train_pc_sim.Default().SendTrainControlMsg(sta, baseMsg, aPort)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,8 +399,10 @@ func trainControlDriverKey(train *state_proto.TrainState, request *request_proto
|
|||
tcc := train.Tcc
|
||||
if obj.Code == SKQYS1 {
|
||||
vobc.Tc1Active = request.Val
|
||||
train.TrainPort = state_proto.TrainState_PORT_A
|
||||
} else if obj.Code == SKQYS2 {
|
||||
vobc.Tc2Active = request.Val
|
||||
train.TrainPort = state_proto.TrainState_PORT_B
|
||||
}
|
||||
if vobc.Tc1Active && vobc.Tc2Active {
|
||||
if obj.Code == SKQYS1 {
|
||||
|
@ -412,11 +426,12 @@ func trainControlDriverKey(train *state_proto.TrainState, request *request_proto
|
|||
}
|
||||
tce := make([]message.TrainPcSimBaseMessage, 0)
|
||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.KEY_STATE, message.IsTrue(request.Val)}})
|
||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, message.IsTrue(request.Val)}})
|
||||
if request.Val == false {
|
||||
|
||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{0x2d, 0}})
|
||||
if request.Val {
|
||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_TC_ACTIVE})
|
||||
} else {
|
||||
tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_TC_NOT_ACTIVE})
|
||||
}
|
||||
//tce = append(tce, message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.DRIVER_ACTIVE_REPORT, message.IsTrue(request.Val)}})
|
||||
|
||||
return tce
|
||||
|
||||
|
@ -489,7 +504,7 @@ func trainTractionPowerAtoStepLevel(trainLoad int32, speedKM int32, stepLevel in
|
|||
f := float64(m) * (acc * (1 - speedM/sp))
|
||||
return int64(f)
|
||||
}
|
||||
func trainAtoControlTractionAndBrake(train *state_proto.TrainState) {
|
||||
func trainAtoControlTractionAndBrake(train *state_proto.TrainState, aport bool) {
|
||||
vs := train.VobcState
|
||||
vs.TractionStatus = false
|
||||
vs.TractionForce = 0
|
||||
|
@ -520,7 +535,7 @@ func trainAtoControlTractionAndBrake(train *state_proto.TrainState) {
|
|||
{Type: message.SENDER_TRAIN_OUTR_INFO, Data: []byte{message.NOT_BREAK, notBreak}},
|
||||
}
|
||||
slog.Info(fmt.Sprintf("列车 id:%v,ato:%v,AtoLevle:%v,牵引:%v,制动:%v,牵引力:%v,制动力%v", train.Id, vs.Ato, vs.AtoStepLevel, vs.AtoTractionCommandOut, vs.AtoBrakeCommand, vs.TractionForce, vs.BrakeForce))
|
||||
train_pc_sim.Default().SendTrainControlMsg(train, msg)
|
||||
train_pc_sim.Default().SendTrainControlMsg(train, msg, aport)
|
||||
}
|
||||
|
||||
// 列车牵引控制
|
||||
|
@ -699,7 +714,7 @@ func (s *VerifySimulation) reportTrainMockInitMsg(aport bool, client *tcp.TcpCli
|
|||
|
||||
}
|
||||
|
||||
train_pc_sim.Default().SendTrainControlMsg(train, tce)
|
||||
//train_pc_sim.Default().SendTrainControlMsg(train, tce)
|
||||
//return initResult
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue