【删除多余方法】

This commit is contained in:
weizhihong 2023-11-15 15:03:37 +08:00
parent bef31c4dbb
commit 60f58060ad

View File

@ -556,68 +556,3 @@ func turnoutOffsetToKilometer(repo *repository.Repository, uid string, runDirect
} }
return return
} }
// 根据起始与末尾端查找经过的设备ID列表
// 入参起始设备uid、起始设备端口、终点设备uid、在区段a->b或道岔->岔心)上的找寻方向
// 输出占用物理区段的ID
func QueryDeviceRoutePath(sim *VerifySimulation, startUid, endUid, startPort string, pointTo bool) (paths []string, err error) {
suid, port, direction := startUid, startPort, pointTo
pathMap := make(map[string]bool)
for {
device := sim.Repo.FindById(suid)
var nextRelation repository.DevicePort
switch device.Type() {
case proto2.DeviceType_DeviceType_PhysicalSection: // 区段
d := device.(*repository.PhysicalSection)
pathMap[d.Id()] = true
nextRelation = d.ARelation()
if direction {
nextRelation = d.BRelation()
}
case proto2.DeviceType_DeviceType_Turnout: // 道岔
d := device.(*repository.Turnout)
physicalSection := d.GetPhysicalSection()
if physicalSection == nil {
err = sys_error.New(fmt.Sprintf("道岔%s没有绑定物理区段", device.Id()))
break
}
pathMap[physicalSection.Id()] = true
var nextPort proto2.Port
switch port {
case "A":
nextPort = proto2.Port_A
case "B":
nextPort = proto2.Port_B
case "C":
nextPort = proto2.Port_C
}
if direction { // -> 岔心
nextPort, err = getTurnoutNextPort(sim, d.Id(), port)
}
nextRelation = d.GindDevicePortByPort(nextPort)
default:
err = sys_error.New(fmt.Sprintf("查找路径设备类型%s无处理处理", device.Type().String()))
}
if err != nil {
break
}
if suid == endUid {
break
}
if nextRelation == nil {
break
}
suid = nextRelation.Device().Id() // 下一个设备ID
port = nextRelation.Port().String() // 下一个道岔端
switch nextRelation.Device().Type() { // 查找方向
case proto2.DeviceType_DeviceType_PhysicalSection:
direction = nextRelation.Port() == proto2.Port_A
case proto2.DeviceType_DeviceType_Turnout:
direction = true
}
}
for k := range pathMap {
paths = append(paths, k)
}
return
}