列车换端计算,里程ato调整

This commit is contained in:
tiger_zhou 2024-09-10 18:55:15 +08:00
parent 903fd14a61
commit 8b5ef2e597
4 changed files with 28 additions and 35 deletions

View File

@ -76,7 +76,7 @@ func (rd *TrainPcReciverData) receiverDataHandle(n int, data []byte) {
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR_BACK:
rd.pcSimManage.TrainPcSimDigitalReportHandle(train, baseMsg.Data)
case message.RECIVE_TRAIN_QUERY_STATUS:
rd.pcSimManage.TrainBtmQuery2(train, baseMsg.Data)
rd.pcSimManage.TrainBtmQuery2(train, baseMsg.Data, rd.aPort)
case message.RECIVE_TRAIN_MOCK_DATA:
rd.pcSimManage.TrainPcSimMockInfo(train, baseMsg.Data)

View File

@ -29,14 +29,14 @@ type TrainPcSim interface {
Stop()
// SendDriverActive Deprecated 发送驾驶端激活
SendDriverActive(train *state_proto.TrainState)
//SendDriverActive(train *state_proto.TrainState)
// SendHandleSwitch 发送牵引制动手柄
SendHandleSwitch(oldTraction, oldBrakeForce int64, tractionState bool, train *state_proto.TrainState)
// SendTrainDirection 列车运行方向
//因文档说明不清楚,在调用的时候目前是注释状态,现场调试可能会用到
SendTrainDirection(train *state_proto.TrainState, trainForward, trainBackward bool)
//发送应答器信息数据
SendBaliseData(train *state_proto.TrainState, msgType byte, data []byte)
SendBaliseData(train *state_proto.TrainState, trainPort bool, msgType byte, data []byte)
//发布列车控制的相关事件
//PublishTrainControlEvent(train *state_proto.TrainState, events []TrainControlEvent)
@ -67,7 +67,7 @@ type TrainPcSimManage interface {
TrainPcSimMockInfo(train *state_proto.TrainState, data []byte)
// TrainBtmQuery 处理列车btm查询
TrainBtmQuery2(train *state_proto.TrainState, data []byte)
TrainBtmQuery2(train *state_proto.TrainState, data []byte, trainPort bool)
}
type trainPcSimService struct {
state tpapi.ThirdPartyApiServiceState
@ -481,7 +481,7 @@ func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
}
// SendDriverActive Deprecated 发送驾驶激活
func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) {
/*func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) {
trainClient, trainDataErr := d.findTrainConn(train)
if trainDataErr != nil {
slog.Error(fmt.Sprintf("发送驾驶激活未找到对应的列车连接列车id%v", train.Id))
@ -489,19 +489,7 @@ func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) {
}
vobc := train.VobcState
msg := &message.TrainPcSimBaseMessage{}
/*if train.TrainRunUp {
if vobc.Tc1Active {
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
} else if vobc.Tc1Active == false {
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
}
} else if !train.TrainRunUp {
if vobc.Tc1Active {
msg.Type = message.SENDER_TRAIN_TC_ACTIVE
} else if vobc.Tc1Active == false {
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
}
}*/
if trainClient.aPort {
msg.Type = message.SENDER_TRAIN_TC_NOT_ACTIVE
if vobc.Tc1Active {
@ -529,7 +517,7 @@ func (d *trainPcSimService) SendDriverActive(train *state_proto.TrainState) {
if err != nil {
slog.Error(fmt.Sprintf("发送驾驶激活失败列车id:%v,数据:%v,err:%v", train.Id, hexData, err.Error()))
}
}
}*/
func (d *trainPcSimService) SendHandleSwitch(oldTraction, oldBrakeForce int64, tractionState bool, train *state_proto.TrainState) {
trainClient, trainDataErr := d.findTrainConn(train)
if trainDataErr != nil {
@ -599,8 +587,9 @@ func (d *trainPcSimService) SendTrainDirection(train *state_proto.TrainState, tr
}
}
func (d *trainPcSimService) SendBaliseData(train *state_proto.TrainState, msgType byte, data []byte) {
trainClient, trainDataErr := d.findTrainConn(train)
func (d *trainPcSimService) SendBaliseData(train *state_proto.TrainState, trainPort bool, msgType byte, data []byte) {
//trainClient, trainDataErr := d.findTrainConn(train)
trainClient, trainDataErr := d.findTrainConnForPort(train, trainPort)
if trainDataErr != nil {
slog.Error(fmt.Sprintf("发送列车PC仿真应答器信息失败未找到列车连接trainId%v", train.Id))
return

View File

@ -265,10 +265,21 @@ func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainIn
// 更新列车状态
trainState := UpdateTrainStateByDynamics(s, trainId, info)
vs := train.VobcState
if train.ConnState.Conn && train.ConnState.ConnType == state_proto.TrainConnState_VOBC {
semi_physical_train.Default().SendTrainControlMessage(info)
electrical_machinery.Default().SendElectricMachineryMessage2(info, trainState)
radar.Default().TrainSpeedSender(info, trainState)
acc.Default().TrainAccSender(info, trainState)
}
if vs.Ato {
trainAtoControlTractionAndBrake(train, true)
trainPort := true
if train.TrainPort == state_proto.TrainState_PORT_B {
trainPort = false
} else if train.TrainPort == state_proto.TrainState_PORT_NONE {
slog.Info("")
return
}
trainAtoControlTractionAndBrake(train, trainPort)
var msgs []message.TrainPcSimBaseMessage
if vs.AtoOpenRightDoor || vs.AtoOpenLeftDoor {
btn := train.Tcc.Buttons[KZM]
@ -283,19 +294,12 @@ func (s *VerifySimulation) HandleDynamicsTrainInfo(info *message.DynamicsTrainIn
}
msgs = controlDoorCloseBtn(train.VobcState, true, btn, vs.AtoOpenLeftDoor, false)
}
train_pc_sim.Default().SendTrainControlMsg(train, msgs, false)
train_pc_sim.Default().SendTrainControlMsg(train, msgs, trainPort)
} else if vs.TractionStatus {
f := trainTractionPower(train.TrainLoad, train.Tcc.PushHandler.Val, trainState.DynamicState.Speed, train.TrainMaxAcc, train.TrainMaxSpeed)
vs.TractionForce = f / 1000 * 100
}
if train.ConnState.Conn && train.ConnState.ConnType == state_proto.TrainConnState_VOBC {
semi_physical_train.Default().SendTrainControlMessage(info)
electrical_machinery.Default().SendElectricMachineryMessage2(info, trainState)
radar.Default().TrainSpeedSender(info, trainState)
acc.Default().TrainAccSender(info, trainState)
}
}
// 获取动力学配置信息

View File

@ -1015,7 +1015,7 @@ func (s *VerifySimulation) TrainPcSimMockInfo(train *state_proto.TrainState, dat
}
// 4.4.4. 车载输出BTM查询同步帧报文内容0x04
func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []byte) {
func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []byte, trainPort bool) {
ts := time.Now().UnixMilli()
if len(data) < 12 {
@ -1049,7 +1049,7 @@ func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []
queryData := make([]byte, 0)
queryData = append(queryData, btmRepFrame.EncodeBtmAtp().Encode()...)
queryData = append(queryData, timeSyncF.EncodeBtmAtp().Encode()...)
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_NOT_DATA, queryData)
train_pc_sim.Default().SendBaliseData(train, trainPort, message.RECIVE_TRAIN_BTM_NOT_DATA, queryData)
//slog.Info(fmt.Sprintf("接受应答器查询:%x发送无应答器数据,id:%v,数据:%X", data, trainAtm.CanId.ID4, queryData))
} else {
logstr := ""
@ -1074,7 +1074,7 @@ func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []
queryData = append(queryData, timeSyncF.EncodeBtmAtp().Encode()...)
queryData = append(queryData, statusDataCf...) //数据帧包含结束帧
balise.BaliseTelegramForPcSimResend = fmt.Sprintf("%X", statusDataCf)
train_pc_sim.Default().SendBaliseData(train, message.RECIVE_TRAIN_BTM_HAS_DATA, queryData)
train_pc_sim.Default().SendBaliseData(train, trainPort, message.RECIVE_TRAIN_BTM_HAS_DATA, queryData)
} else {
slog.Error("列车pc仿真 BtmCanetClient应答帧、数据帧编码失败")
}