Merge remote-tracking branch 'origin/master'

This commit is contained in:
joylink_zhangsai 2023-08-08 16:46:56 +08:00
commit 85a5baa1e9

View File

@ -13,6 +13,7 @@ import (
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/device"
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/ref"
"joylink.club/bj-rtsts-server/ats/verify/simulation/wayside/model/section"
"joylink.club/bj-rtsts-server/db/dbquery"
"joylink.club/bj-rtsts-server/db/model"
)
@ -46,6 +47,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 +71,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
}
@ -91,7 +94,12 @@ func QueryMapVerifyStructure(mapId int32) *VerifyStructure {
if ok {
return d.(*VerifyStructure)
}
panic(fmt.Sprintf("地图【id:%d】不存在", mapId))
mapData, _ := dbquery.PublishedGi.Where(dbquery.PublishedGi.ID.Eq(mapId), dbquery.PublishedGi.Status.Eq(1)).First()
if mapData != nil {
return PublishMapVerifyStructure(mapData)
} else {
panic(fmt.Sprintf("地图【id:%d】不存在", mapId))
}
}
// 初始化地图结构
@ -110,6 +118,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 +236,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的关联关系