【修改IBP设备组合逻辑】(消息未修改)
This commit is contained in:
parent
745fb55110
commit
7cb868dcfc
@ -2,6 +2,7 @@ package memory
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"joylink.club/bj-rtsts-server/dto"
|
||||
@ -73,6 +74,41 @@ func filterOtherLineDevice(data *graphicData.RtssGraphicStorage) {
|
||||
otherDeviceIdMap[id] = true
|
||||
}
|
||||
}
|
||||
for _, d := range data.Section {
|
||||
if otherDeviceIdMap[d.Common.Id] {
|
||||
continue
|
||||
}
|
||||
otherDeviceIdMap[d.Common.Id] = (strings.TrimSpace(d.Code) == "" || d.Code == "G000")
|
||||
}
|
||||
// 处理物理区段
|
||||
var sections []*graphicData.Section
|
||||
for _, d := range data.Section {
|
||||
if otherDeviceIdMap[d.Common.Id] {
|
||||
continue
|
||||
}
|
||||
if d.PaRef != nil && otherDeviceIdMap[d.PaRef.Id] {
|
||||
d.PaRef = nil
|
||||
}
|
||||
if d.PbRef != nil && otherDeviceIdMap[d.PbRef.Id] {
|
||||
d.PbRef = nil
|
||||
}
|
||||
var acs []string
|
||||
for _, id := range d.AxleCountings {
|
||||
if otherDeviceIdMap[id] {
|
||||
continue
|
||||
}
|
||||
acs = append(acs, id)
|
||||
}
|
||||
if len(d.AxleCountings) > 1 && len(acs) == 0 {
|
||||
continue
|
||||
}
|
||||
d.AxleCountings = acs
|
||||
if otherDeviceIdMap[d.TrackSectionId] {
|
||||
d.TrackSectionId = ""
|
||||
}
|
||||
sections = append(sections, d)
|
||||
}
|
||||
data.Section = sections
|
||||
// 处理计轴
|
||||
var axleCounts []*graphicData.AxleCounting
|
||||
for _, d := range data.AxleCountings {
|
||||
@ -117,32 +153,6 @@ func filterOtherLineDevice(data *graphicData.RtssGraphicStorage) {
|
||||
turnouts = append(turnouts, d)
|
||||
}
|
||||
data.Turnouts = turnouts
|
||||
// 处理物理区段
|
||||
var sections []*graphicData.Section
|
||||
for _, d := range data.Section {
|
||||
if otherDeviceIdMap[d.Common.Id] {
|
||||
continue
|
||||
}
|
||||
if d.PaRef != nil && otherDeviceIdMap[d.PaRef.Id] {
|
||||
d.PaRef = nil
|
||||
}
|
||||
if d.PbRef != nil && otherDeviceIdMap[d.PbRef.Id] {
|
||||
d.PbRef = nil
|
||||
}
|
||||
var acs []string
|
||||
for _, id := range d.AxleCountings {
|
||||
if otherDeviceIdMap[id] {
|
||||
continue
|
||||
}
|
||||
acs = append(acs, id)
|
||||
}
|
||||
d.AxleCountings = acs
|
||||
if otherDeviceIdMap[d.TrackSectionId] {
|
||||
d.TrackSectionId = ""
|
||||
}
|
||||
sections = append(sections, d)
|
||||
}
|
||||
data.Section = sections
|
||||
// 处理信号机
|
||||
var signals []*graphicData.Signal
|
||||
for _, d := range data.Signals {
|
||||
|
@ -1260,48 +1260,32 @@ func handlerIBPDeviceToStation(station *proto.Station, repo *proto.Repository, i
|
||||
}
|
||||
repo.Alarms = append(repo.Alarms, b)
|
||||
}
|
||||
empGroup := &proto.ElectronicGroup{Code: "EMP"}
|
||||
spksGroup := &proto.ElectronicGroup{Code: "SPKS"}
|
||||
for _, data := range storage.IbpLights { // 指示灯,
|
||||
b := &proto.Light{
|
||||
Id: station.Id + "_light_" + data.Code,
|
||||
Code: data.Code,
|
||||
}
|
||||
repo.Lights = append(repo.Lights, b)
|
||||
// 存入组合类型的
|
||||
c := &proto.ElectronicComponent{
|
||||
deviceMap[data.Common.Id] = &proto.ElectronicComponent{
|
||||
Id: b.Id,
|
||||
DeviceType: proto.DeviceType_DeviceType_Light,
|
||||
}
|
||||
switch data.Code {
|
||||
case "XEMPD", "SEMPD":
|
||||
empGroup.Components = append(empGroup.Components, c)
|
||||
case "SPKSX1D", "SPKSX3D", "SPKSS2D", "SPKSS4D":
|
||||
spksGroup.Components = append(spksGroup.Components, c)
|
||||
}
|
||||
repo.Lights = append(repo.Lights, b)
|
||||
}
|
||||
for _, data := range storage.IbpRelatedDevices { // 组信息
|
||||
for _, c := range data.Combinationtypes {
|
||||
var group *proto.ElectronicGroup
|
||||
switch c.Code {
|
||||
case "EMP":
|
||||
group = empGroup
|
||||
case "SPKS":
|
||||
group = spksGroup
|
||||
default:
|
||||
continue
|
||||
}
|
||||
group := &proto.ElectronicGroup{Code: c.Code}
|
||||
for _, d := range c.RefDevices {
|
||||
deviceType, ok := deviceMap[d]
|
||||
if !ok {
|
||||
slog.Debug("IBP组合类型类型不确定id:%s", d)
|
||||
slog.Debug("IBP组合类型类型不存在设备id:%s", d)
|
||||
continue
|
||||
}
|
||||
group.Components = append(group.Components, deviceType)
|
||||
}
|
||||
station.ElectronicGroup = append(station.ElectronicGroup, group)
|
||||
}
|
||||
}
|
||||
station.ElectronicGroup = append(station.ElectronicGroup, empGroup, spksGroup)
|
||||
}
|
||||
|
||||
func converCheckPointUid(data *proto.CheckPoint, uidsMap *StationUidStructure) *proto.CheckPoint {
|
||||
@ -1394,6 +1378,9 @@ func converRefUid(id string, d proto.DeviceType, uidsMap *StationUidStructure) s
|
||||
default:
|
||||
panic(&dto.ErrorDto{Code: dto.ArgumentParseError, Message: "异常的设备类型-" + d.String()})
|
||||
}
|
||||
if elementId == nil {
|
||||
return ""
|
||||
}
|
||||
return elementId.Uid
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user