将link数据放入内存中

This commit is contained in:
weizhihong 2023-08-08 10:51:05 +08:00
parent 2cf801a4b2
commit cd31225af2
1 changed files with 14 additions and 2 deletions

View File

@ -46,6 +46,7 @@ type GraphicInfoMapStructure struct {
PhysicalSectionMap map[string]*graphicData.Section
LogicSectionMap map[string]*graphicData.LogicSection
SignalMap map[string]*graphicData.Signal
CalcLinkMap map[string]*graphicData.CalculateLink
}
// 将发布的地图数据放入内存中
@ -69,13 +70,14 @@ func PublishMapVerifyStructure(graphic *model.PublishedGi) *VerifyStructure {
PhysicalSectionMap: make(map[string]*graphicData.Section),
LogicSectionMap: make(map[string]*graphicData.LogicSection),
SignalMap: make(map[string]*graphicData.Signal),
CalcLinkMap: make(map[string]*graphicData.CalculateLink),
}
graphicStorage := &graphicData.RtssGraphicStorage{}
proto.Unmarshal(graphic.Proto, graphicStorage)
// 初始化地图结构
initGraphicStructure(graphicStorage, verifyStructure, graphicInfoMap)
// 构建设备间的关联关系
buildDeviceRef(graphicInfoMap, verifyStructure)
// 构建设备间的关联关系(8.8 注释掉构建逻辑)
// buildDeviceRef(graphicInfoMap, verifyStructure)
graphicDataMap.Store(graphic.ID, verifyStructure)
return verifyStructure
}
@ -110,6 +112,8 @@ func initGraphicStructure(graphicData *graphicData.RtssGraphicStorage, verifyStr
initGraphicLogicSections(graphicData.LogicSections, verifyStructure, graphicDataMap)
// 初始化信号机信息
initGraphicSignal(graphicData.Signals, verifyStructure, graphicDataMap)
// 初始化计算link数据
initCalcLink(graphicData.CalculateLink, verifyStructure, graphicDataMap)
}
// 初始化计轴信息
@ -226,6 +230,14 @@ func initGraphicSignal(signals []*graphicData.Signal, data *VerifyStructure, gra
}
}
// 初始化计算link数据
func initCalcLink(calculateLinks []*graphicData.CalculateLink, verifyStructure *VerifyStructure, graphicDataMap *GraphicInfoMapStructure) {
for _, l := range calculateLinks {
id := strconv.Itoa(int(l.Index))
graphicDataMap.CalcLinkMap[id] = l
}
}
// 构建设备间的关系
func buildDeviceRef(graphicData *GraphicInfoMapStructure, verifyStructure *VerifyStructure) {
// 构建link的关联关系