From a6dfa6fffb7ecfe6630280a838092d208c0e3c1a Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 7 Nov 2023 14:30:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=A1=E5=9E=8B=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9E=84=E5=BB=BAbug=EF=BC=9B=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E9=97=A8=E6=89=80=E6=9C=89=E7=BB=A7=E7=94=B5=E5=99=A8=E9=83=BD?= =?UTF-8?q?=E4=BC=9A=E6=9E=84=E5=BB=BA=E4=B8=BA=E5=AE=9E=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/psd.go | 2 ++ entity/psd.go | 2 ++ repository/platform.go | 13 ++++++++----- repository/repository_manager.go | 32 +++++++++++++++++++++++++++----- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/component/psd.go b/component/psd.go index a443862..17a6918 100644 --- a/component/psd.go +++ b/component/psd.go @@ -19,6 +19,8 @@ type PsdCircuit struct { //屏蔽门表示继电器 MGJ *ecs.Entry MPLJ *ecs.Entry + //一些不知道如何使用的继电器,为了使得采集、驱动逻辑正常,先构建出来 + UnusedJ []*ecs.Entry } var PsdInterlockDriveCircuitType = ecs.NewComponentType[PsdInterlockDriveCircuit]() diff --git a/entity/psd.go b/entity/psd.go index f963913..2f0db61 100644 --- a/entity/psd.go +++ b/entity/psd.go @@ -59,6 +59,8 @@ func loadPsdCircuit(world ecs.World, entry *ecs.Entry, psd *repository.Psd, entr circuit.MGJ = NewRelayEntity(world, relay, entryMap) case "XMPLJ", "SMPLJ": circuit.MPLJ = NewRelayEntity(world, relay, entryMap) + default: + circuit.UnusedJ = append(circuit.UnusedJ, NewRelayEntity(world, relay, entryMap)) } } } diff --git a/repository/platform.go b/repository/platform.go index 0c30117..a34c152 100644 --- a/repository/platform.go +++ b/repository/platform.go @@ -8,11 +8,14 @@ type Platform struct { station *Station } -func NewPlatform(id string) *Platform { - return &Platform{Identity: identity{ - id: id, - deviceType: proto.DeviceType_DeviceType_Platform, - }} +func NewPlatform(id string, code string) *Platform { + return &Platform{ + Identity: identity{ + id: id, + deviceType: proto.DeviceType_DeviceType_Platform, + }, + code: code, + } } func (p *Platform) Code() string { diff --git a/repository/repository_manager.go b/repository/repository_manager.go index bd81334..a043a18 100644 --- a/repository/repository_manager.go +++ b/repository/repository_manager.go @@ -3,12 +3,11 @@ package repository import ( "errors" "fmt" + "joylink.club/rtsssimulation/repository/model/proto" + "joylink.club/rtsssimulation/util/number" "log/slog" "math" "strconv" - - "joylink.club/rtsssimulation/repository/model/proto" - "joylink.club/rtsssimulation/util/number" ) var repositoryMap = make(map[string]*Repository) @@ -112,7 +111,6 @@ func buildModels(source *proto.Repository, repository *Repository) error { m := newPsd(protoData.Id, protoData.AsdAmount, protoData.AsdGroups) repository.psdMap[m.Id()] = m } - for _, protoData := range source.Lights { m := NewLight(protoData.Id, protoData.Code) repository.lightMap[m.Id()] = m @@ -121,7 +119,6 @@ func buildModels(source *proto.Repository, repository *Repository) error { m := NewAlarm(protoData.Id, protoData.Code) repository.alarmMap[m.Id()] = m } - for _, protoData := range source.Mkxs { m := NewMkx(protoData.Id) repository.mkxMap[m.Id()] = m @@ -130,6 +127,10 @@ func buildModels(source *proto.Repository, repository *Repository) error { m := NewKey(protoData.Id, protoData.Code, protoData.Gear) repository.keyMap[m.Id()] = m } + for _, protoData := range source.Platforms { + m := NewPlatform(protoData.Id, protoData.Code) + repository.platformMap[m.Id()] = m + } err := repository.generateCoordinateInfo(source.MainCoordinateSystem) for _, protoData := range source.CentralizedStationRefs { repository.centralizedMap[protoData.StationId] = protoData @@ -174,9 +175,25 @@ func buildModelRelationship(source *proto.Repository, repository *Repository) er if err != nil { return err } + err = buildPlatformRelationShip(source, repository) + if err != nil { + return err + } return err } +func buildPlatformRelationShip(source *proto.Repository, repo *Repository) error { + for _, protoData := range source.Platforms { + platform := repo.platformMap[protoData.Id] + station := repo.stationMap[protoData.StationId] + if station == nil { + return fmt.Errorf("站台[id:%s]关联的车站[id:%s]不存在", platform.Id(), protoData.StationId) + } + platform.station = station + } + return nil +} + func buildMkxRelationShip(source *proto.Repository, repo *Repository) error { for _, protoData := range source.Mkxs { mkx := repo.mkxMap[protoData.Id] @@ -194,6 +211,11 @@ func buildMkxRelationShip(source *proto.Repository, repo *Repository) error { func buildPsdRelationShip(source *proto.Repository, repo *Repository) error { for _, protoData := range source.Psds { psd := repo.psdMap[protoData.Id] + platform := repo.platformMap[protoData.PlatformId] + if platform == nil { + return fmt.Errorf("屏蔽门[id:%s]关联的站台[id:%s]不存在", psd.Id(), protoData.PlatformId) + } + psd.platform = platform for _, group := range protoData.ElectronicComponentGroups { var components []IGroupedElectronicComponent for _, id := range group.GetComponentIds() {