From 60f58060ad353d020954eaf729e9eb568412ee9a Mon Sep 17 00:00:00 2001 From: weizhihong Date: Wed, 15 Nov 2023 15:03:37 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wayside/memory/wayside_memory_map.go | 65 ------------------- 1 file changed, 65 deletions(-) diff --git a/ts/simulation/wayside/memory/wayside_memory_map.go b/ts/simulation/wayside/memory/wayside_memory_map.go index aa62c8b..99bccf3 100644 --- a/ts/simulation/wayside/memory/wayside_memory_map.go +++ b/ts/simulation/wayside/memory/wayside_memory_map.go @@ -556,68 +556,3 @@ func turnoutOffsetToKilometer(repo *repository.Repository, uid string, runDirect } 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 -}