增加断相保护器模型及相关构建逻辑

This commit is contained in:
joylink_zhangsai 2023-09-28 14:10:20 +08:00
parent e8a3f635b9
commit 88ea4862b4
2 changed files with 50 additions and 17 deletions

View File

@ -176,18 +176,18 @@ func buildProtoRepository(mapIds []int32) (*proto.Repository, error) {
exceptStationGiMapIds = append(exceptStationGiMapIds, mapId)
}
}
//将继电器与设备关联
//构建并关联电子元件
for _, mapId := range exceptStationGiMapIds {
giType := QueryGiType(mapId)
if giType == graphicData.PictureType_RelayCabinetLayout {
relayGi := QueryGiData[*graphicData.RelayCabinetGraphicStorage](mapId)
relateRelay(repo, relayGi, mapId)
buildAndRelateElectronicComponent(repo, relayGi, mapId)
}
}
return repo, nil
}
func relateRelay(repo *proto.Repository, relayGi *graphicData.RelayCabinetGraphicStorage, mapId int32) {
func buildAndRelateElectronicComponent(repo *proto.Repository, relayGi *graphicData.RelayCabinetGraphicStorage, mapId int32) {
uidsMap := queryUidStructure[*relayUidStructure](mapId)
city := relayGi.UniqueIdPrefix.City
lineId := relayGi.UniqueIdPrefix.LineId
@ -196,7 +196,13 @@ func relateRelay(repo *proto.Repository, relayGi *graphicData.RelayCabinetGraphi
repo.Relays = append(repo.Relays, &proto.Relay{
Id: uidsMap.RelayIds[relay.Common.Id].Uid,
Code: relay.Code,
Model: relay.NewModel.String(),
Model: convertRelayModel(relay.NewModel),
})
}
for _, pfp := range relayGi.PhaseFailureProtectors {
repo.PhaseFailureProtectors = append(repo.PhaseFailureProtectors, &proto.PhaseFailureProtector{
Id: uidsMap.RelayIds[pfp.Common.Id].Uid,
Code: pfp.Code,
})
}
turnoutMap := make(map[string]*proto.Turnout)
@ -215,16 +221,17 @@ func relateRelay(repo *proto.Repository, relayGi *graphicData.RelayCabinetGraphi
continue
}
for _, group := range relationship.Combinationtypes {
var relayUIds []string
var componentIds []string
for _, relayId := range group.RefRelays {
if uidsMap.RelayIds[relayId] == nil {
continue
}
relayUIds = append(relayUIds, uidsMap.RelayIds[relayId].Uid)
componentIds = append(componentIds, uidsMap.RelayIds[relayId].Uid)
}
turnout.RelayGroups = append(turnout.RelayGroups, &proto.RelayGroup{
turnout.ElectronicComponentGroups = append(turnout.ElectronicComponentGroups,
&proto.ElectronicComponentGroup{
Code: group.Code,
RelayIds: relayUIds,
ComponentIds: componentIds,
})
}
case graphicData.RelatedRef_signal:
@ -233,22 +240,48 @@ func relateRelay(repo *proto.Repository, relayGi *graphicData.RelayCabinetGraphi
continue
}
for _, group := range relationship.Combinationtypes {
var relayUIds []string
var componentIds []string
for _, relayId := range group.RefRelays {
if uidsMap.RelayIds[relayId] == nil {
continue
}
relayUIds = append(relayUIds, uidsMap.RelayIds[relayId].Uid)
componentIds = append(componentIds, uidsMap.RelayIds[relayId].Uid)
}
signal.RelayGroups = append(signal.RelayGroups, &proto.RelayGroup{
signal.ElectronicComponentGroups = append(signal.ElectronicComponentGroups,
&proto.ElectronicComponentGroup{
Code: group.Code,
RelayIds: relayUIds,
ComponentIds: componentIds,
})
}
}
}
}
func convertRelayModel(modelType graphicData.Relay_ModelType) proto.Relay_Model {
switch modelType {
case graphicData.Relay_Unknown:
return proto.Relay_Unknown
case graphicData.Relay_JPXC_1000:
return proto.Relay_JPXC_1000
case graphicData.Relay_JPXC_1700:
return proto.Relay_JPXC_1700
case graphicData.Relay_JWJXC_480:
return proto.Relay_JWJXC_480
case graphicData.Relay_JWJXC_H125_80:
return proto.Relay_JWJXC_H125_80
case graphicData.Relay_JWXC_1700:
return proto.Relay_JWXC_1700
case graphicData.Relay_JWXC_H340:
return proto.Relay_JWXC_H340
case graphicData.Relay_JYJXC_160_260:
return proto.Relay_JYJXC_160_260
case graphicData.Relay_JZXC_H18:
return proto.Relay_JZXC_H18
default:
panic(fmt.Sprintf("意料之外的继电器型号:%s", modelType))
}
}
func fillProtoRepository(repo *proto.Repository, storage *graphicData.RtssGraphicStorage, mapId int32) {
axleCountingMap := make(map[string]*graphicData.AxleCounting)
uidsMap := queryUidStructure[*stationUidStructure](mapId)

@ -1 +1 @@
Subproject commit d743f0be7c203172884bc07fa76e0c61e550386e
Subproject commit d36ba6fc7dfe5235ace72be522566e55aadd34e1