diff --git a/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go b/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go index a0c8a50..5628556 100644 --- a/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go +++ b/ats/verify/simulation/wayside/memory/wayside_memory_map_init.go @@ -30,7 +30,7 @@ type stationUidStructure struct { CurvatureIds map[string]*elementIdStructure ButtonIds map[string]*elementIdStructure StationIds map[string]*elementIdStructure - IBPIds map[string]*elementIdStructure + IBPIds map[string]map[string]*elementIdStructure } type relayUidStructure struct { @@ -75,7 +75,7 @@ func initStationUid(data *graphicData.RtssGraphicStorage) *stationUidStructure { CurvatureIds: make(map[string]*elementIdStructure, len(data.Curvatures)), ButtonIds: make(map[string]*elementIdStructure, len(data.EsbButtons)), StationIds: make(map[string]*elementIdStructure, len(data.Stations)), - IBPIds: make(map[string]*elementIdStructure, len(data.Stations)), + IBPIds: make(map[string]map[string]*elementIdStructure, len(data.Stations)), } city, lineId, _ := getUIdPrefix(data.UniqueIdPrefix) // 初始化计轴信息 @@ -192,30 +192,32 @@ func initIBPUid(gus *stationUidStructure, city, lineId string, station *graphicD } return p + "_" + code } + uidMap := make(map[string]*elementIdStructure, len(data.IbpButtons)+len(data.IbpKeys)+len(data.IbpAlarms)+len(data.IbpLights)) for _, d := range data.IbpButtons { // ibp按钮 - gus.IBPIds[d.Common.Id] = &elementIdStructure{ + uidMap[d.Common.Id] = &elementIdStructure{ CommonId: d.Common.Id, Uid: GenerateElementUid(city, lineId, []string{station.Code}, getCode(d.Common.Id, d.Code)), } } for _, d := range data.IbpKeys { // ibp钥匙 - gus.IBPIds[d.Common.Id] = &elementIdStructure{ + uidMap[d.Common.Id] = &elementIdStructure{ CommonId: d.Common.Id, Uid: GenerateElementUid(city, lineId, []string{station.Code}, getCode(d.Common.Id, d.Code)), } } for _, d := range data.IbpAlarms { // ibp报警器 - gus.IBPIds[d.Common.Id] = &elementIdStructure{ + uidMap[d.Common.Id] = &elementIdStructure{ CommonId: d.Common.Id, Uid: GenerateElementUid(city, lineId, []string{station.Code}, getCode(d.Common.Id, d.Code)), } } for _, d := range data.IbpLights { // ibp指示灯 - gus.IBPIds[d.Common.Id] = &elementIdStructure{ + uidMap[d.Common.Id] = &elementIdStructure{ CommonId: d.Common.Id, Uid: GenerateElementUid(city, lineId, []string{station.Code}, getCode(d.Common.Id, d.Code)), } } + gus.IBPIds[station.Code] = uidMap } // 初始化继电器柜 UID @@ -305,7 +307,9 @@ func buildRepositoryAllUidsMap(mapIds []int32, repo *repository.Repository) map[ saveToAllUidMap(u.SlopeIds) saveToAllUidMap(u.CurvatureIds) saveToAllUidMap(u.ButtonIds) - saveToAllUidMap(u.IBPIds) + for _, ids := range u.IBPIds { + saveToAllUidMap(ids) + } continue } } @@ -344,9 +348,6 @@ func getUidMapByType(uidData any, m interface{}) map[string]*elementIdStructure return (uidData.(*relayUidStructure)).RelayIds case *graphicData.EsbButton: return (uidData.(*stationUidStructure)).ButtonIds - // Ibp相关 - case *graphicData.IBPButton, *graphicData.IbpAlarm, *graphicData.IbpKey, *graphicData.IbpLight: - return (uidData.(*stationUidStructure)).IBPIds default: panic(&dto.ErrorDto{Code: dto.ArgumentParseError, Message: "类型未映射字段"}) } @@ -369,3 +370,27 @@ func QueryUidByMidAndComId(mapId int32, comId string, m interface{}) string { } panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("地图【id:%d】不存在【comId:%s】缓存", mapId, comId)}) } + +// 根据地图、车站CODE、设备类型获取UID集合 +func QueryIBPUidMapByType(mapId int32, stationCode string, m interface{}) map[string]*elementIdStructure { + uidData, ok := giUidMap.Load(mapId) + if !ok { + panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("地图【id:%d】不存在uid缓存", mapId)}) + } + switch m.(type) { + // Ibp相关 + case *graphicData.IBPButton, *graphicData.IbpAlarm, *graphicData.IbpKey, *graphicData.IbpLight: + return (uidData.(*stationUidStructure)).IBPIds[stationCode] + default: + panic(&dto.ErrorDto{Code: dto.ArgumentParseError, Message: "类型未映射字段"}) + } +} + +// 根据地图的comId获取UID +func QueryIBPUidByMidAndComId(mapId int32, comId, stationCode string, m interface{}) string { + uidMap := QueryIBPUidMapByType(mapId, stationCode, m) + if uidMap[comId] != nil { + return uidMap[comId].Uid + } + panic(&dto.ErrorDto{Code: dto.DataNotExist, Message: fmt.Sprintf("地图【id:%d】不存在【comId:%s】缓存", mapId, comId)}) +}