应答器修改
This commit is contained in:
parent
4044b7f4c2
commit
06a4331135
@ -48,13 +48,13 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
|
||||
authed.GET("/:id/getMapKilometerRange", getMapKilometerRange)
|
||||
authed.POST("/psl/operation", pslBtnOperation) //1
|
||||
authed.POST("/psd/operation", psdOperation)
|
||||
authed.PUT("/balisecodec/position/modify", balisePositionModify)
|
||||
authed.PUT("/balisecodec/position/reset", balisePositionReset)
|
||||
authed.PUT("/balisecodec/telegram/modify", baliseTelegramModify)
|
||||
authed.PUT("/balisecodec/telegram/reset", baliseTelegramReset)
|
||||
authed.PUT("/balisecodec/telegram/stop", baliseTelegramStop)
|
||||
authed.PUT("/balisecodec/telegram/send", baliseTelegramSend)
|
||||
authed.PUT("/balisecodec/reset", baliseReset)
|
||||
authed.PUT("/balise/position/modify", balisePositionModify)
|
||||
authed.PUT("/balise/position/reset", balisePositionReset)
|
||||
authed.PUT("/balise/telegram/modify", baliseTelegramModify)
|
||||
authed.PUT("/balise/telegram/reset", baliseTelegramReset)
|
||||
authed.PUT("/balise/telegram/stop", baliseTelegramStop)
|
||||
authed.PUT("/balise/telegram/send", baliseTelegramSend)
|
||||
authed.PUT("/balise/reset", baliseReset)
|
||||
authed.PUT("/ckm/operation", ckmOperation)
|
||||
authed.PUT("/xcj/operation", xcjOperation)
|
||||
//authed.POST("/bypass/operation", bypassBtnOrKeyOperation)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
||||
Subproject commit 74bea4e9955524f7254876c90af08d963f666585
|
||||
Subproject commit 61b489dcf80d992891e3266d0224fbe05fd49d0f
|
4
third_party/can_btm/balise_btm.go
vendored
4
third_party/can_btm/balise_btm.go
vendored
@ -127,7 +127,9 @@ type BtmCanetClient interface {
|
||||
Stop()
|
||||
//HandleTrainHeadPositionInfo 处理收到列车位置信息
|
||||
HandleTrainHeadPositionInfo(w ecs.World, vobcBtm *state_proto.VobcBtmState, h *TrainHeadPositionInfo)
|
||||
//获取BTM显示状态 + btm最新的状态
|
||||
// GetState 获取BTM显示状态 + btm最新的状态
|
||||
//
|
||||
// Deprecated 请从列车的btmBaliseCache中获取
|
||||
GetState() state_proto.BTMState
|
||||
//GetAllData()
|
||||
FindNotSendState() (state_proto.BTMState, bool)
|
||||
|
132
third_party/can_btm/balise_detection.go
vendored
132
third_party/can_btm/balise_detection.go
vendored
@ -8,6 +8,7 @@ import (
|
||||
"joylink.club/rtsssimulation/fi"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/repository/model/proto"
|
||||
"log/slog"
|
||||
"math"
|
||||
"sort"
|
||||
"sync"
|
||||
@ -85,17 +86,9 @@ func (t *BaliseDetector) detect2(wd *component.WorldData, repo *repository.Repos
|
||||
curAntennaRi := t.createBtmAntennaRunningInfo(wd, repo, th) //目前车头
|
||||
curAntennaRi2 := t.createBtmAntennaRunningInfo(wd, repo, th2) //上次车头
|
||||
var startBalises []*repository.Transponder
|
||||
var endBalises []*repository.Transponder
|
||||
|
||||
//startBalises = t.searchBalisesFromBetweenLinkPosition(repo, th.Up, curAntennaRi2.LinkId, th2.LinkOffset, th.LinkOffset)
|
||||
startBalises = t.searchBalisesFromBetweenLinkPosition(repo, th.Up, curAntennaRi2.LinkId, curAntennaRi2.LinkOffset, curAntennaRi.LinkOffset)
|
||||
//endBalises = t.searchBalisesFromBetweenLinkPosition(repo, !th.Up, curAntennaRi.LinkId, curAntennaRi.LinkOffset, curAntennaRi2.LinkOffset)
|
||||
/* if th.Up {
|
||||
startBalises = t.searchBalisesFromBetweenLinkPosition(repo, th.Up, curAntennaRi2.LinkId, curAntennaRi2.LinkOffset, curAntennaRi.LinkOffset)
|
||||
endBalises = t.searchBalisesFromBetweenLinkPosition(repo, !th.Up, curAntennaRi.LinkId, curAntennaRi.LinkOffset, curAntennaRi2.LinkOffset)
|
||||
} else {
|
||||
startBalises = t.searchBalisesFromBetweenLinkPosition(repo, th.Up, curAntennaRi2.LinkId, curAntennaRi.LinkOffset, curAntennaRi2.LinkOffset)
|
||||
endBalises = t.searchBalisesFromBetweenLinkPosition(repo, !th.Up, curAntennaRi.LinkId, curAntennaRi2.LinkOffset, curAntennaRi.LinkOffset)
|
||||
}*/
|
||||
startBalises = t.searchBalisesFromBetweenLinkPosition(repo, th2.Up, curAntennaRi2.LinkId, curAntennaRi2.LinkOffset, curAntennaRi.LinkOffset)
|
||||
|
||||
balises := make([]*repository.Transponder, 0)
|
||||
for _, balise := range startBalises {
|
||||
@ -108,31 +101,15 @@ func (t *BaliseDetector) detect2(wd *component.WorldData, repo *repository.Repos
|
||||
}
|
||||
if !find {
|
||||
balises = append(balises, balise)
|
||||
//slog.Info(fmt.Sprintf("start baliseId:%v,Distance:%v,up:%v", balisecodec.Id(), balisecodec.LinkPosition(), curAntennaRi.Up))
|
||||
}
|
||||
}
|
||||
for _, balise := range endBalises {
|
||||
find := false
|
||||
for _, transponder := range balises {
|
||||
if transponder.Id() == balise.Id() {
|
||||
find = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !find {
|
||||
//slog.Info(fmt.Sprintf("end baliseId:%v,Distance:%v,up:%v", balisecodec.Id(), balisecodec.LinkPosition(), curAntennaRi.Up))
|
||||
balises = append(balises, balise)
|
||||
}
|
||||
}
|
||||
if len(balises) > 0 {
|
||||
balise := balises[0]
|
||||
baliseInfo := &BtmAntennaScanningBaliseInfo{BaliseId: balise.Id(), BaliseType: balise.BaliseType()}
|
||||
/*uuid := uuid2.NewString()
|
||||
for _, transponder := range balises {
|
||||
slog.Info(fmt.Sprintf("uid :%v,baliseId:%v,Distance:%v,up:%v", uuid, transponder.Id(), baliseInfo.Distance, curAntennaRi.Up))
|
||||
}*/
|
||||
//uuid := uuid2.NewString()
|
||||
//slog.Info(fmt.Sprintf("uid :%v,baliseId:%v,Distance:%v,up:%v", uuid, balise.Id(), baliseInfo.Distance, curAntennaRi.Up))
|
||||
|
||||
telegram, utel := t.rcvTelegram2(wd, balise.Id())
|
||||
telegram, utel := t.rcvTelegram(wd, balise.Id())
|
||||
if utel != nil && t.addExpectedBalise(baliseInfo) {
|
||||
t.baliseCounterAdd1() //应答器计数器
|
||||
if len(telegram) > 0 {
|
||||
@ -222,41 +199,28 @@ func (t *BaliseDetector) baliseMessageCounterAdd1() {
|
||||
}
|
||||
|
||||
// BTM天线接收应答器报文(线程不安全)
|
||||
func (t *BaliseDetector) rcvTelegram2(wd *component.WorldData, baliseId string) ([]byte, []byte) {
|
||||
func (t *BaliseDetector) rcvTelegram(wd *component.WorldData, baliseId string) ([]byte, []byte) {
|
||||
|
||||
if entry, ok := wd.EntityMap[baliseId]; ok {
|
||||
workedState := component.BaliseWorkStateType.Get(entry)
|
||||
if !workedState.Work {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
//hasVar := entry.HasComponent(component.BaliseVariableTelegramType)
|
||||
//hexFix := entry.HasComponent(component.BaliseFixedTelegramType)
|
||||
|
||||
fixBalise := component.BaliseFixedTelegramType.Get(entry)
|
||||
if entry.HasComponent(component.BaliseVariableTelegramType) {
|
||||
baliseVar := component.BaliseVariableTelegramType.Get(entry)
|
||||
//slog.Info(fmt.Sprintf("find_baliseId:%v ,work:%v,var:%v,fix:%v,tel:%v,usertel:%v", baliseId, workedState.Work, hasVar, hexFix, hex.EncodeToString(baliseVar.Telegram), hex.EncodeToString(baliseVar.UserTelegram)))
|
||||
return baliseVar.Telegram, baliseVar.UserTelegram
|
||||
} else if entry.HasComponent(component.BaliseFixedTelegramType) {
|
||||
fixBalise := component.BaliseFixedTelegramType.Get(entry)
|
||||
//slog.Info(fmt.Sprintf("find_baliseId:%v ,work:%v,var:%v,fix:%v,tel:%v,usertel:%v", baliseId, workedState.Work, hasVar, hexFix, hex.EncodeToString(tel), hex.EncodeToString(utel)))
|
||||
if !workedState.Work {
|
||||
return fixBalise.Telegram, fixBalise.UserTelegram
|
||||
} else if baliseVar.UserTelegram == nil || len(baliseVar.UserTelegram) == 0 {
|
||||
slog.Warn(fmt.Sprintf("BTM天线未接受到应答器可变报文,即将使用对应的固定报文, baliseId: %v", baliseId))
|
||||
return fixBalise.Telegram, fixBalise.UserTelegram
|
||||
} else {
|
||||
return baliseVar.Telegram, baliseVar.UserTelegram
|
||||
}
|
||||
} else if workedState.Work {
|
||||
return fixBalise.Telegram, fixBalise.UserTelegram
|
||||
} else {
|
||||
slog.Warn(fmt.Sprintf("BTM天线未接受到应答器报文,应答器未工作 baliseId: %v", baliseId))
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// BTM天线接收应答器报文(线程不安全)
|
||||
func (t *BaliseDetector) rcvTelegram(wd *component.WorldData, baliseId string) ([]byte, []byte) {
|
||||
entry, ok := wd.EntityMap[baliseId]
|
||||
if ok {
|
||||
if component.BaliseWorkStateType.Get(entry).Work {
|
||||
tel := component.BaliseFixedTelegramType.Get(entry).Telegram
|
||||
utel := component.BaliseFixedTelegramType.Get(entry).UserTelegram
|
||||
return tel, utel
|
||||
//return component.BaliseFixedTelegramType.Get(entry).Telegram
|
||||
}
|
||||
} else {
|
||||
slog.Warn(fmt.Sprintf("BTM天线接收应答器报文,未找到 baliseId: %v", baliseId))
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@ -351,6 +315,57 @@ func (t *BaliseDetector) calculateBtmAntennaScanNextBaliseTime(curTime time.Time
|
||||
return curTime, false
|
||||
}
|
||||
|
||||
// 获取车载BTM天线中心点运行方向最近的1个应答器
|
||||
func (t *BaliseDetector) findBaliseWillScanByBtmAntenna2(wd *component.WorldData, repo *repository.Repository, ba *BtmAntennaRunningInfo) *BtmAntennaToBaliseInfo {
|
||||
//BTM天线中心点所在轨道
|
||||
baLink := repo.FindLink(ba.LinkId)
|
||||
rs1 := t.searchBalisesFromLinkPosition(repo, ba.LinkId, ba.Up, ba.LinkOffset)
|
||||
if ba.Up {
|
||||
if len(rs1) > 0 {
|
||||
rs := rs1[0]
|
||||
return &BtmAntennaToBaliseInfo{BaliseId: rs.Id(), Distance: rs.LinkPosition().Offset() - ba.LinkOffset, BaliseType: rs.BaliseType()}
|
||||
} else {
|
||||
nextLinkPort := t.getNextLink(wd, repo, ba.LinkId, ba.Up)
|
||||
if nextLinkPort != nil {
|
||||
if nextLinkPort.IsPortA() {
|
||||
rs2 := t.searchBalisesFromLinkPosition(repo, nextLinkPort.Link().Id(), true, 0)
|
||||
if len(rs2) > 0 {
|
||||
rs := rs2[0]
|
||||
|
||||
return &BtmAntennaToBaliseInfo{BaliseId: rs.Id(), Distance: baLink.Length() - ba.LinkOffset + rs.LinkPosition().Offset(), BaliseType: rs.BaliseType()}
|
||||
}
|
||||
} else {
|
||||
rs2 := t.searchBalisesFromLinkPosition(repo, nextLinkPort.Link().Id(), false, nextLinkPort.Link().Length())
|
||||
if len(rs2) > 0 {
|
||||
rs := rs2[0]
|
||||
return &BtmAntennaToBaliseInfo{BaliseId: rs.Id(), Distance: baLink.Length() - ba.LinkOffset + nextLinkPort.Link().Length() - rs.LinkPosition().Offset(), BaliseType: rs.BaliseType()}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(rs1) > 0 {
|
||||
return &BtmAntennaToBaliseInfo{BaliseId: rs1[0].Id(), Distance: ba.LinkOffset - rs1[0].LinkPosition().Offset()}
|
||||
} else {
|
||||
nextLinkPort := t.getNextLink(wd, repo, ba.LinkId, ba.Up)
|
||||
if nextLinkPort != nil {
|
||||
if nextLinkPort.IsPortA() {
|
||||
rs2 := t.searchBalisesFromLinkPosition(repo, nextLinkPort.Link().Id(), true, 0)
|
||||
if len(rs2) > 0 {
|
||||
return &BtmAntennaToBaliseInfo{BaliseId: rs2[0].Id(), Distance: ba.LinkOffset + rs2[0].LinkPosition().Offset()}
|
||||
}
|
||||
} else {
|
||||
rs2 := t.searchBalisesFromLinkPosition(repo, nextLinkPort.Link().Id(), false, nextLinkPort.Link().Length())
|
||||
if len(rs2) > 0 {
|
||||
return &BtmAntennaToBaliseInfo{BaliseId: rs2[0].Id(), Distance: ba.LinkOffset + nextLinkPort.Link().Length() - rs2[0].LinkPosition().Offset()}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取车载BTM天线中心点运行方向最近的1个应答器
|
||||
func (t *BaliseDetector) findBaliseWillScanByBtmAntenna(wd *component.WorldData, repo *repository.Repository, ba *BtmAntennaRunningInfo) *BtmAntennaToBaliseInfo {
|
||||
//BTM天线中心点所在轨道
|
||||
@ -421,7 +436,7 @@ func (t *BaliseDetector) searchBalisesFromBetweenLinkPosition(repo *repository.R
|
||||
return rs[j].LinkPosition().Offset() < rs[i].LinkPosition().Offset()
|
||||
})
|
||||
for _, r := range rs {
|
||||
|
||||
//slog.Info(fmt.Sprintf("down id:%v,offset:%v,from:%v,to:%v", r.Id(), r.LinkPosition().Offset(), fromOffset, toOffset))
|
||||
if r.LinkPosition().Offset() <= toOffset {
|
||||
cha := int64(math.Abs(float64(toOffset - fromOffset)))
|
||||
cha2 := int64(math.Abs(float64(toOffset - r.LinkPosition().Offset())))
|
||||
@ -453,7 +468,6 @@ func (t *BaliseDetector) searchBalisesFromLinkPosition(repo *repository.Reposito
|
||||
return rs[j].LinkPosition().Offset() < rs[i].LinkPosition().Offset()
|
||||
})
|
||||
for i, r := range rs {
|
||||
//slog.Info(fmt.Sprintf("id:%v,offset:%v,from:%v", r.Id(), r.LinkPosition().Offset(), fromOffset))
|
||||
if r.LinkPosition().Offset() <= fromOffset {
|
||||
return rs[i:]
|
||||
}
|
||||
|
5
third_party/train_pc_sim/train_pc_sim.go
vendored
5
third_party/train_pc_sim/train_pc_sim.go
vendored
@ -218,6 +218,7 @@ func (d *trainPcSimService) newCloseConn(clientKey string) {
|
||||
rd.train = nil
|
||||
rd.speedPlace = nil
|
||||
rd.trainInit = false
|
||||
//d.cancleContextFun()
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,6 +380,10 @@ func (d *trainPcSimService) sendTrainLocationAndSpeedTask(ctx context.Context) {
|
||||
slog.Error(fmt.Sprintf("pc仿真速度位置未找到对应的列车 id:%v", train.Id))
|
||||
continue
|
||||
}
|
||||
if trainClient.speedPlace == nil {
|
||||
slog.Error(fmt.Sprintf("pc仿真速度位置脉冲对象为空 列车id:%v", train.Id))
|
||||
continue
|
||||
}
|
||||
|
||||
connState := tpapi.ThirdPartyState_Normal
|
||||
if train.Tcc.Line12ConnErr {
|
||||
|
@ -343,6 +343,9 @@ func UpdateTrainStateByDynamics(vs *VerifySimulation, trainId string, info *mess
|
||||
sta.OldLinkOffset = outLinkOffset
|
||||
sta.OldLink = outLinkId
|
||||
}
|
||||
if sta.BtmBaliseCache == nil {
|
||||
sta.BtmBaliseCache = make([]*state_proto.BTMState, 0)
|
||||
}
|
||||
updateTrainBtmPosition(vs, info, sta, outLinkId, outLinkOffset)
|
||||
//slog.Info(fmt.Sprintf("动力学,当前速度(米/秒):%v,加速度:%v,位移距离:%v", info.Speed, info.Acceleration, info.Displacement))
|
||||
if sta.OldLink != outLinkId {
|
||||
@ -466,19 +469,14 @@ func removeTrain(vs *VerifySimulation, trainId string, train *state_proto.TrainS
|
||||
TrainIndex: uint16(trainIndex),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
slog.Warn("列车移除失败,动力学请求失败", err)
|
||||
}
|
||||
thirdConn := train.ConnState
|
||||
if thirdConn.Conn {
|
||||
thirdConn.Conn = false
|
||||
err = TrainPcSimConnOrRemoveHandle(train, false)
|
||||
if err != nil {
|
||||
train.ConnState.Conn = true
|
||||
return err
|
||||
} else {
|
||||
thirdConn.ConnType = state_proto.TrainConnState_NONE
|
||||
thirdConn.TypeName = ""
|
||||
}
|
||||
thirdConn.ConnType = state_proto.TrainConnState_NONE
|
||||
thirdConn.TypeName = ""
|
||||
}
|
||||
if train.VobcState != nil {
|
||||
vobc := train.VobcState
|
||||
|
Loading…
Reference in New Issue
Block a user