【link映射公里标】

This commit is contained in:
weizhihong 2023-09-28 15:43:20 +08:00
parent deda54551d
commit 0f3422de0f
2 changed files with 12 additions and 6 deletions

View File

@ -140,6 +140,7 @@ func turnoutMapToEcsLink(repo *repository.Repository, id string, port string, of
}
// 岔心公里标
crossKm = turnout.GetTurnoutKm(proto2.Port_None)
portKm = repo.ConvertKilometer(portKm, crossKm.CoordinateSystem)
// 关联link
link := portPosition.Link()
isStart := link.ARelation().Device().Id() == id
@ -173,7 +174,7 @@ func QueryDeviceByCalcLink(repo *repository.Repository, id string, offset int64,
// 判断是否在道岔上
onTurnout, isA := isOnLinkTurnout(link, offset)
if onTurnout {
return ecsLinkMapToTurnout(isA, offset, up, link)
return ecsLinkMapToTurnout(repo, isA, offset, up, link)
} else {
return ecsLinkMapToSection(offset, up, link)
}
@ -198,7 +199,7 @@ func isOnLinkTurnout(link *repository.Link, offset int64) (bool, bool) {
}
// 处理在道岔上link映射
func ecsLinkMapToTurnout(isA bool, offset int64, up bool, link *repository.Link) (
func ecsLinkMapToTurnout(repo *repository.Repository, isA bool, offset int64, up bool, link *repository.Link) (
deviceId, port string, deviceOffset int64, runDirection, pointTo bool, km int64) {
tp := link.ARelation()
if !isA {
@ -206,7 +207,9 @@ func ecsLinkMapToTurnout(isA bool, offset int64, up bool, link *repository.Link)
}
deviceId = tp.Turnout().Id()
tpOffset := tp.Turnout().FindLinkPositionByPort(tp.Port()).Offset()
crossKm, portKm := tp.Turnout().GetTurnoutKm(proto2.Port_None).Value, tp.Turnout().GetTurnoutKm(tp.Port()).Value
crossKmInfo, portKmInfo := tp.Turnout().GetTurnoutKm(proto2.Port_None), tp.Turnout().GetTurnoutKm(tp.Port())
portKmInfo = repo.ConvertKilometer(portKmInfo, crossKmInfo.CoordinateSystem)
crossKm, portKm := crossKmInfo.Value, portKmInfo.Value
if isA {
deviceOffset = tpOffset - (tpOffset - offset)
pointTo = !up
@ -217,10 +220,13 @@ func ecsLinkMapToTurnout(isA bool, offset int64, up bool, link *repository.Link)
// 查询公里标大于端口公里标
if crossKm > portKm {
km = crossKm - deviceOffset
runDirection = pointTo
} else {
km = crossKm + deviceOffset
runDirection = !pointTo
}
if up {
runDirection = (crossKm > portKm) == !isA
} else {
runDirection = (crossKm < portKm) == !isA
}
switch tp.Port() {
case proto2.Port_A:

@ -1 +1 @@
Subproject commit d36ba6fc7dfe5235ace72be522566e55aadd34e1
Subproject commit b8db4336fb78c17fe179b7927929808a5793f0dc