折返速度调整
This commit is contained in:
parent
8b5ef2e597
commit
449162856b
File diff suppressed because it is too large
Load Diff
|
@ -1 +1 @@
|
|||
Subproject commit 15470e0e4aa2c5839be5c009d5a4239c9238b4ba
|
||||
Subproject commit 35c2c8e7748a4a30230ef4fcaedbfd7d2466299d
|
|
@ -70,15 +70,13 @@ func (rd *TrainPcReciverData) receiverDataHandle(n int, data []byte) {
|
|||
//case RECIVE_TRAIN_CREATE_REMOVE:
|
||||
// pc.trainPcSimManage.TrainPcSimConnOrRemoveHandle(baseMsg.Data[0])
|
||||
case message.RECIVE_TRAIN_INTERFACE_CABINET_OUTR:
|
||||
|
||||
rd.pcSimManage.TrainPcSimDigitalOutInfoHandle(rd.aPort, rd.tcpClient, train, baseMsg.Data)
|
||||
|
||||
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.aPort)
|
||||
case message.RECIVE_TRAIN_MOCK_DATA:
|
||||
rd.pcSimManage.TrainPcSimMockInfo(train, baseMsg.Data)
|
||||
//case message.RECIVE_TRAIN_MOCK_DATA:
|
||||
// rd.pcSimManage.TrainPcSimMockInfo(train, baseMsg.Data)
|
||||
|
||||
//case RECIVE_TRAIN_DOOR_MODE:
|
||||
// pc.trainPcSimManage.TrainDoorModeHandle(baseMsg.Data[0])
|
||||
|
|
|
@ -162,22 +162,23 @@ func pluseCountSpeed(wheelDiameter int32, speedMeter float32) uint32 {
|
|||
return uint32(pluseCountData)
|
||||
}
|
||||
|
||||
func (d *trainPcSimService) pluseSpeed(sta *state_proto.TrainState) (uint32, float32) {
|
||||
func (d *trainPcSimService) pluseSpeed(pc *state_proto.SensorSpeedPulseCount, wheelDiameter int32) (uint32, float32) {
|
||||
defer initLock.Unlock()
|
||||
initLock.Lock()
|
||||
|
||||
var sum float32 = 0
|
||||
pcLen := len(sta.PluseCount.PulseCount3)
|
||||
pcLen := len(pc.PulseCount3)
|
||||
if pcLen == 0 {
|
||||
return 0, 0
|
||||
}
|
||||
for _, f := range sta.PluseCount.PulseCount3 {
|
||||
for _, f := range pc.PulseCount3 {
|
||||
sum += f
|
||||
}
|
||||
d.TrainPluseCountReset(sta)
|
||||
d.trainPluseCountReset(pc)
|
||||
speed := sum / float32(pcLen)
|
||||
return pluseCountSpeed(sta.WheelDiameter, speed*1000), speed
|
||||
|
||||
return pluseCountSpeed(wheelDiameter, speed*1000), speed
|
||||
}
|
||||
|
||||
func (d *trainPcSimService) TrainPluseCount(sta *state_proto.TrainState, h1, h2, t1, t2 float32) {
|
||||
defer initLock.Unlock()
|
||||
initLock.Lock()
|
||||
|
@ -190,36 +191,29 @@ func (d *trainPcSimService) TrainPluseCount(sta *state_proto.TrainState, h1, h2,
|
|||
|
||||
for _, sd := range d.findTrainAllConn(sta) {
|
||||
if sd.speedPlace != nil {
|
||||
|
||||
sd.speedPlace.PulseCount1 += sta.DynamicState.Displacement
|
||||
}
|
||||
}
|
||||
if sta.TrainRunUp {
|
||||
if sta.TrainEndsA.SpeedSensorEnableA {
|
||||
sta.PluseCount.PulseCount1 = pluseCountSpeed(sta.WheelDiameter, h1)
|
||||
sta.PluseCount.PulseCount3 = append(sta.PluseCount.PulseCount3, h1)
|
||||
}
|
||||
if sta.TrainEndsA.SpeedSensorEnableB {
|
||||
sta.PluseCount.PulseCount2 = pluseCountSpeed(sta.WheelDiameter, h2)
|
||||
sta.PluseCount.PulseCount4 = append(sta.PluseCount.PulseCount3, h2)
|
||||
}
|
||||
} else {
|
||||
if sta.TrainEndsB.SpeedSensorEnableA {
|
||||
sta.PluseCount.PulseCount1 = pluseCountSpeed(sta.WheelDiameter, t1)
|
||||
sta.PluseCount.PulseCount3 = append(sta.PluseCount.PulseCount3, t1)
|
||||
}
|
||||
if sta.TrainEndsB.SpeedSensorEnableB {
|
||||
sta.PluseCount.PulseCount2 = pluseCountSpeed(sta.WheelDiameter, t2)
|
||||
sta.PluseCount.PulseCount4 = append(sta.PluseCount.PulseCount3, t2)
|
||||
for _, pc := range sta.PulseCountMap {
|
||||
|
||||
if sta.TrainRunUp {
|
||||
if sta.TrainEndsA.SpeedSensorEnableA || sta.TrainEndsA.SpeedSensorEnableB {
|
||||
pc.PulseCount1 = pluseCountSpeed(sta.WheelDiameter, h1)
|
||||
pc.PulseCount3 = append(pc.PulseCount3, h1)
|
||||
}
|
||||
} else {
|
||||
if sta.TrainEndsB.SpeedSensorEnableA || sta.TrainEndsB.SpeedSensorEnableB {
|
||||
pc.PulseCount1 = pluseCountSpeed(sta.WheelDiameter, t1)
|
||||
pc.PulseCount3 = append(pc.PulseCount3, t1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (d *trainPcSimService) TrainPluseCountReset(sta *state_proto.TrainState) {
|
||||
sta.PluseCount.PulseCount1 = 0
|
||||
sta.PluseCount.PulseCount2 = 0
|
||||
sta.PluseCount.PulseCount3 = make([]float32, 0)
|
||||
sta.PluseCount.PulseCount4 = make([]float32, 0)
|
||||
func (d *trainPcSimService) trainPluseCountReset(pc *state_proto.SensorSpeedPulseCount) {
|
||||
pc.PulseCount1 = 0
|
||||
pc.PulseCount3 = make([]float32, 0)
|
||||
}
|
||||
|
||||
func (d *trainPcSimService) newCloseAllConn() {
|
||||
|
@ -239,13 +233,7 @@ func (d *trainPcSimService) newCloseConn(clientKey string) {
|
|||
rd.speedPlace = nil
|
||||
}
|
||||
}
|
||||
/*rd := d.newPcSimclientMap[clientKey]
|
||||
if rd != nil {
|
||||
rd.tcpClient.Close()
|
||||
rd.tcpClient = nil
|
||||
rd.train = nil
|
||||
rd.speedPlace = nil
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
func (d *trainPcSimService) findConfig(configName string) (*config.VehiclePCSimConfig, error) {
|
||||
|
@ -393,7 +381,9 @@ func (d *trainPcSimService) initTrain(rd *TrainPcReciverData, train *state_proto
|
|||
msgs := make([]message.TrainPcSimBaseMessage, 0)
|
||||
sendMsg := make([]byte, 0)
|
||||
rd.speedPlace = &message.TrainSpeedPlaceReportMsg{}
|
||||
train.PluseCount = &state_proto.SensorSpeedPulseCount{}
|
||||
train.PulseCountMap = make(map[int32]*state_proto.SensorSpeedPulseCount)
|
||||
train.PulseCountMap[int32(state_proto.TrainState_PORT_A.Number())] = &state_proto.SensorSpeedPulseCount{}
|
||||
train.PulseCountMap[int32(state_proto.TrainState_PORT_B.Number())] = &state_proto.SensorSpeedPulseCount{}
|
||||
rd.train = train
|
||||
tcc := train.Tcc
|
||||
tcc.LineInitTimeStamp12PortA = 0
|
||||
|
@ -440,9 +430,14 @@ func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
|
|||
|
||||
trains := d.trainPcSimManage.GetConnTrain2()
|
||||
for _, train := range trains {
|
||||
if train.ConnState.Conn && train.PluseCount != nil {
|
||||
trainClients := d.newPcSimclientMap3[train.ConnState.TypeName]
|
||||
for _, trainClient := range trainClients {
|
||||
if train.ConnState.Conn {
|
||||
for numKey, pc := range train.PulseCountMap {
|
||||
trainPort := state_proto.TrainState_TrainPort(numKey)
|
||||
aPort := true
|
||||
if trainPort == state_proto.TrainState_PORT_B {
|
||||
aPort = false
|
||||
}
|
||||
trainClient, _ := d.findTrainConnForPort(train, aPort)
|
||||
if trainClient.success {
|
||||
if trainClient.speedPlace == nil || trainClient.tcpClient == nil {
|
||||
slog.Error(fmt.Sprintf("pc仿真速度位置脉冲对象为空 列车id:%v", train.Id))
|
||||
|
@ -454,27 +449,25 @@ func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
|
|||
} else if trainClient.aPort == false && train.Tcc.Line12ConnErrPortB {
|
||||
connState = tpapi.ThirdPartyState_Broken
|
||||
}
|
||||
/*if train.Tcc.Line12ConnErr {
|
||||
connState = tpapi.ThirdPartyState_Broken
|
||||
}*/
|
||||
trainClient.updateState(connState)
|
||||
s1, speed := d.pluseSpeed(train)
|
||||
s1, _ := d.pluseSpeed(pc, train.WheelDiameter)
|
||||
runDir := uint16(2)
|
||||
if train.VobcState.DirectionForward {
|
||||
runDir = 1
|
||||
} else if train.VobcState.DirectionBackward {
|
||||
runDir = 0
|
||||
}
|
||||
disPluse := pluseCountSpeed(train.WheelDiameter, trainClient.speedPlace.PulseCount1)
|
||||
data := trainClient.speedPlace.Encode(runDir, s1, disPluse)
|
||||
bm := &message.TrainPcSimBaseMessage{Type: message.SENDER_TRAIN_LOCATION_INFO, Data: data}
|
||||
dataCode := bm.Encode()
|
||||
slog.Info(fmt.Sprintf("发送列车速度位置,列车:%v,A端:%v,列车速度:%v,计数脉冲: %v,累计里程: %v ,发送数据:%v", train.Id, trainClient.aPort, speed, s1, trainClient.speedPlace.PulseCount1, hex.EncodeToString(dataCode)), trainClient.aPort)
|
||||
//slog.Info(fmt.Sprintf("发送列车速度位置,列车:%v,A端:%v,列车速度:%v,计数脉冲: %v,累计里程: %v ,发送数据:%v", train.Id, trainClient.aPort, speed, s1, trainClient.speedPlace.PulseCount1, hex.EncodeToString(dataCode)), trainClient.aPort)
|
||||
err := trainClient.tcpClient.Send(dataCode)
|
||||
if err != nil {
|
||||
slog.Error(fmt.Sprintf("发送列车速度位置失败,列车:%v,发送数据:%v", train.Id, hex.EncodeToString(dataCode)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -446,7 +446,7 @@ func handleTrainPositionFromDynamic(vs *VerifySimulation, info *message.Dynamics
|
|||
}
|
||||
|
||||
func pluseCount(sta *state_proto.TrainState, h1, h2, t1, t2 float32) {
|
||||
if sta.PluseCount == nil {
|
||||
if sta.PulseCountMap == nil {
|
||||
return
|
||||
}
|
||||
train_pc_sim.Default().TrainPluseCount(sta, h1, h2, t1, t2)
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
train_pc_sim "joylink.club/bj-rtsts-server/third_party/train_pc_sim"
|
||||
"log/slog"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -745,12 +744,12 @@ func (s *VerifySimulation) reportTrainMockInitMsg2(aport, act, initConn bool, in
|
|||
connErr = true
|
||||
}
|
||||
if state == 0 {
|
||||
slog.Info("列车紧急制动%v", aport)
|
||||
//slog.Info("列车紧急制动%v", aport)
|
||||
jjzdBtn := tcc.Buttons[JJZD]
|
||||
ebTce := controlEBBtn(train, true, jjzdBtn)
|
||||
tce = append(tce, ebTce...)
|
||||
} else if message.GetBit(data1, 0) == 0 {
|
||||
slog.Info(fmt.Sprintf("列车紧切牵引%v ,state :%v", aport, state))
|
||||
//slog.Info(fmt.Sprintf("列车紧切牵引%v ,state :%v", aport, state))
|
||||
jjzdBtn := tcc.Buttons[JJZD]
|
||||
ebTce := controlEBBtn(train, true, jjzdBtn)
|
||||
tce = append(tce, ebTce...)
|
||||
|
@ -801,7 +800,7 @@ func trainAtoLevel(at3, at2, at1 bool) state_proto.TrainVobcState_AtoStepLevel {
|
|||
func (s *VerifySimulation) shuziliang(aport bool, client *tcp.TcpClient, baseMessage []message.TrainPcSimBaseMessage) {
|
||||
for _, msg := range baseMessage {
|
||||
dd := msg.Encode()
|
||||
slog.Info(fmt.Sprintf("发送列车控制信息:%x", dd), aport)
|
||||
//slog.Info(fmt.Sprintf("发送列车控制信息:%x", dd), aport)
|
||||
client.Send(dd)
|
||||
|
||||
}
|
||||
|
@ -810,18 +809,15 @@ func (s *VerifySimulation) shuziliang(aport bool, client *tcp.TcpClient, baseMes
|
|||
// 4.4.1. 车载输出数字量信息报文内容
|
||||
func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(aport bool, client *tcp.TcpClient, train *state_proto.TrainState, data []byte) bool {
|
||||
|
||||
dd := &strings.Builder{}
|
||||
//slog.Info("开始接受atp输出模拟量==============%v", aport)
|
||||
/* for i, d := range data {
|
||||
for j := 0; j < 8; j++ {
|
||||
dd.WriteString(fmt.Sprintf(" bit%v val:%v , ", j, message.GetBit(d, uint(j))))
|
||||
}
|
||||
slog.Info(fmt.Sprintf("接受atp模拟量id:%v,data:%b,bits:%v", i, d, dd.String()))
|
||||
}*/
|
||||
d := data[4]
|
||||
for j := 0; j < 8; j++ {
|
||||
dd.WriteString(fmt.Sprintf(" bit%v val:%v , ", j, message.GetBit(d, uint(j))))
|
||||
}
|
||||
dd := &strings.Builder{}
|
||||
for j := 0; j < 8; j++ {
|
||||
dd.WriteString(fmt.Sprintf(" bit%v val:%v , ", j, message.GetBit(d, uint(j))))
|
||||
}
|
||||
slog.Info(fmt.Sprintf("接受atp模拟量id:%v,data:%b,bits:%v", i, d, dd.String()))
|
||||
}*/
|
||||
|
||||
//slog.Info(fmt.Sprintf("%v", dd.String()), aport)
|
||||
//slog.Info("结束接受atp输出模拟量eeeeeeeeeeeeeeeeee", aport)
|
||||
|
||||
|
@ -834,17 +830,9 @@ func (s *VerifySimulation) TrainPcSimDigitalOutInfoHandle(aport bool, client *tc
|
|||
train.Tcc.LineInitTimeStamp12PortA = ts
|
||||
train.Tcc.TrainConnInitComplatePortA = initConn
|
||||
train.Tcc.Line12ConnErrPortA = connErr
|
||||
//slog.Info("发送数字量")
|
||||
s.shuziliang(aport, client, tce)
|
||||
}
|
||||
/* if initConn {
|
||||
train.Tcc.TrainConnInitComplatePortB = initConn
|
||||
train.Tcc.LineInitTimeStamp12PortB = ts
|
||||
}
|
||||
if train.Tcc.ActiveTrainA {
|
||||
train.Tcc.ActiveTrainB = train.Tcc.ActiveTrainA
|
||||
}
|
||||
*/
|
||||
|
||||
if train.VobcState.Tc1Active {
|
||||
trainPcSimDigitalOutInfoHandleCode7_0(data[4], vobc)
|
||||
trainPcSimDigitalOutInfoHandleCode15_8(data[3], vobc)
|
||||
|
@ -1060,9 +1048,13 @@ func (s *VerifySimulation) TrainBtmQuery2(train *state_proto.TrainState, data []
|
|||
balise.IsSend = true
|
||||
logstr = fmt.Sprintf("准备发送应答id:%v,接受时间:%v,发送时间:%v , 数据:%v 经过:%v,解报文:%v,接受应答器报文:%X", balise.BaliseId, ts, time.Now().UnixMilli(), balise.Telegram, bc, mc, data)
|
||||
} else {
|
||||
queryData := make([]byte, 0)
|
||||
queryData = append(queryData, btmRepFrame.EncodeBtmAtp().Encode()...)
|
||||
queryData = append(queryData, timeSyncF.EncodeBtmAtp().Encode()...)
|
||||
train_pc_sim.Default().SendBaliseData(train, trainPort, message.RECIVE_TRAIN_BTM_NOT_DATA, queryData)
|
||||
return
|
||||
}
|
||||
slog.Info(logstr)
|
||||
slog.Info(logstr, trainPort)
|
||||
aliseData, _ := hex.DecodeString(balise.Telegram)
|
||||
stateRepFrame := btmRepFrame.EncodeBtmAtp()
|
||||
statusDataCf, statusDataCfOk := message.CreateBtmAtpDataRspFramesData(stateRepFrame, aliseData, false, balise.HasData, cl.BtmTk, cl.BtmTk, cl.BtmTk)
|
||||
|
|
Loading…
Reference in New Issue