diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_generate.go b/ats/verify/simulation/wayside/memory/wayside_memory_generate.go index 563710d..3f21914 100644 --- a/ats/verify/simulation/wayside/memory/wayside_memory_generate.go +++ b/ats/verify/simulation/wayside/memory/wayside_memory_generate.go @@ -186,57 +186,6 @@ func getGraphicSectionPointRef(section *buildCalcSectionStruct, b bool, defaultR } } -// 获取link的路径信息 -func getGraphicLinkPath(gm *buildCalcStruct, startPointQueue *list.List) map[int][]*graphicData.RelatedRef { - handleMap := make(map[string]bool) - resultMap := make(map[int][]*graphicData.RelatedRef) - id := 1 - for i := startPointQueue.Front(); i != nil; i = i.Next() { - relatedRef := i.Value.(*graphicData.RelatedRef) - // 起始连接点 - var refInfo *graphicData.RelatedRef - var axleInfo *graphicData.AxleCounting - if relatedRef.DeviceType == graphicData.RelatedRef_Section { - refInfo, axleInfo = getRelatePointInfo(reflect.ValueOf(gm.SectionMap[relatedRef.Id]).Elem(), relatedRef.DevicePort) - } else { - refInfo, axleInfo = getRelatePointInfo(reflect.ValueOf(gm.TurnoutMap[relatedRef.Id]).Elem(), relatedRef.DevicePort) - } - // 查看是否已经被处理过的ID - var handleId string - if axleInfo == nil { - ids := []string{relatedRef.Id, refInfo.Id} - sort.Strings(ids) - handleId = strings.Join(ids, "_") - } else { - handleId = axleInfo.Common.Id - } - if handleMap[handleId] { - continue - } - handleMap[handleId] = true - pathRefArr := []*graphicData.RelatedRef{refInfo} - appendFunc := getRelateAppendMethod(gm, refInfo, relatedRef) - loopRelateRef := relatedRef - for loopRelateRef != nil { - pathRefArr = appendFunc(loopRelateRef, pathRefArr) - switch loopRelateRef.DeviceType { - case graphicData.RelatedRef_Section: - section := gm.SectionMap[loopRelateRef.Id] - if loopRelateRef.DevicePort == graphicData.RelatedRef_A { - loopRelateRef = section.Data.PbRef - } else { - loopRelateRef = section.Data.PaRef - } - case graphicData.RelatedRef_Turnout: - loopRelateRef = nil - } - } - resultMap[id] = pathRefArr - id++ // ID自增 - } - return resultMap -} - // 获取link的起始点和包装数据结构方便查找,以道岔的各分支的连接点为起点 func getGraphicDataDeviceMap(gd *graphicData.RtssGraphicStorage) (*buildCalcStruct, *list.List) { gm := &buildCalcStruct{ @@ -293,6 +242,62 @@ func getGraphicDataDeviceMap(gd *graphicData.RtssGraphicStorage) (*buildCalcStru return gm, startPoints } +// 获取link的路径信息 +func getGraphicLinkPath(gm *buildCalcStruct, startPointQueue *list.List) map[int][]*graphicData.RelatedRef { + handleMap := make(map[string]bool) + resultMap := make(map[int][]*graphicData.RelatedRef) + id := 1 + for i := startPointQueue.Front(); i != nil; i = i.Next() { + relatedRef := i.Value.(*graphicData.RelatedRef) + // 起始连接点,判断选择走向 + var refInfo *graphicData.RelatedRef + var axleInfo *graphicData.AxleCounting + if relatedRef.DeviceType == graphicData.RelatedRef_Section { + refInfo, axleInfo = getRelatePointInfo(reflect.ValueOf(gm.SectionMap[relatedRef.Id]).Elem(), relatedRef.DevicePort) + } else { + refInfo, axleInfo = getRelatePointInfo(reflect.ValueOf(gm.TurnoutMap[relatedRef.Id]).Elem(), relatedRef.DevicePort) + } + // 查看是否已经被处理过的ID,计轴信息为空时表示道岔,将ID排序后存入 + var handleId string + if axleInfo == nil { + ids := []string{relatedRef.Id, refInfo.Id} + sort.Strings(ids) + handleId = strings.Join(ids, "_") + } else { + handleId = axleInfo.Common.Id + } + if handleMap[handleId] { + continue + } + handleMap[handleId] = true + // 追加函数存在问题,表示数据存在问题 + appendFunc := getRelateAppendMethod(gm, refInfo, relatedRef) + if appendFunc == nil { + continue + } + pathRefArr := []*graphicData.RelatedRef{refInfo} + // 循环查找结束点 + loopRelateRef := relatedRef + for loopRelateRef != nil { + pathRefArr = appendFunc(loopRelateRef, pathRefArr) + switch loopRelateRef.DeviceType { + case graphicData.RelatedRef_Section: + section := gm.SectionMap[loopRelateRef.Id] + if loopRelateRef.DevicePort == graphicData.RelatedRef_A { + loopRelateRef = section.Data.PbRef + } else { + loopRelateRef = section.Data.PaRef + } + case graphicData.RelatedRef_Turnout: + loopRelateRef = nil + } + } + resultMap[id] = pathRefArr + id++ // ID自增 + } + return resultMap +} + // 获取本连接点上一个连接信息以及计轴信息 func getRelatePointInfo(v reflect.Value, p graphicData.RelatedRef_DevicePort) (*graphicData.RelatedRef, *graphicData.AxleCounting) { var relateInfo reflect.Value @@ -312,33 +317,15 @@ func getRelatePointInfo(v reflect.Value, p graphicData.RelatedRef_DevicePort) (* return relateInfo.Interface().(*graphicData.RelatedRef), axlePoint.Interface().(*graphicData.AxleCounting) } -// 确定接点追加放肆 +// 确定接点追加方法 func getRelateAppendMethod(gm *buildCalcStruct, sRef, eRef *graphicData.RelatedRef) func(*graphicData.RelatedRef, []*graphicData.RelatedRef) []*graphicData.RelatedRef { - start := 0 - switch sRef.DeviceType { - case graphicData.RelatedRef_Section: - section := gm.SectionMap[sRef.Id] - if sRef.DevicePort == graphicData.RelatedRef_A { - start = int(section.APoint.KilometerSystem.Kilometer) - } else { - start = int(section.BPoint.KilometerSystem.Kilometer) - } - case graphicData.RelatedRef_Turnout: - turnout := gm.TurnoutMap[sRef.Id] - start = int(turnout.CrossKilometerSystem.Kilometer) + start, sOK := handleFunc(gm, sRef) + if !sOK { + return nil } - end := 0 - switch eRef.DeviceType { - case graphicData.RelatedRef_Section: - section := gm.SectionMap[eRef.Id] - if eRef.DevicePort == graphicData.RelatedRef_A { - end = int(section.APoint.KilometerSystem.Kilometer) - } else { - end = int(section.BPoint.KilometerSystem.Kilometer) - } - case graphicData.RelatedRef_Turnout: - turnout := gm.TurnoutMap[eRef.Id] - end = int(turnout.CrossKilometerSystem.Kilometer) + end, eOk := handleFunc(gm, eRef) + if !eOk { + return nil } if start > end { return func(refInfo *graphicData.RelatedRef, linkArr []*graphicData.RelatedRef) []*graphicData.RelatedRef { @@ -350,3 +337,32 @@ func getRelateAppendMethod(gm *buildCalcStruct, sRef, eRef *graphicData.RelatedR } } } + +// 处理函数 +func handleFunc(gm *buildCalcStruct, ref *graphicData.RelatedRef) (int, bool) { + switch ref.DeviceType { + case graphicData.RelatedRef_Section: + section := gm.SectionMap[ref.Id] + if ref.DevicePort == graphicData.RelatedRef_A { + if section.APoint == nil || section.APoint.KilometerSystem == nil { + zap.S().Warnf("区段【%s】A端缺少关联计轴信息", ref.Id) + } else { + return int(section.APoint.KilometerSystem.Kilometer), true + } + } else { + if section.BPoint == nil || section.BPoint.KilometerSystem == nil { + zap.S().Warnf("区段【%s】B端缺少关联计轴信息", ref.Id) + } else { + return int(section.BPoint.KilometerSystem.Kilometer), true + } + } + case graphicData.RelatedRef_Turnout: + turnout := gm.TurnoutMap[ref.Id] + if turnout.CrossKilometerSystem == nil { + zap.S().Warnf("道岔【%s】缺少岔心公里标数据", ref.Id) + } else { + return int(turnout.CrossKilometerSystem.Kilometer), true + } + } + return 0, false +}