修改模型数据构建bug;屏蔽门所有继电器都会构建为实体
This commit is contained in:
parent
13af2d6ff9
commit
a6dfa6fffb
@ -19,6 +19,8 @@ type PsdCircuit struct {
|
||||
//屏蔽门表示继电器
|
||||
MGJ *ecs.Entry
|
||||
MPLJ *ecs.Entry
|
||||
//一些不知道如何使用的继电器,为了使得采集、驱动逻辑正常,先构建出来
|
||||
UnusedJ []*ecs.Entry
|
||||
}
|
||||
|
||||
var PsdInterlockDriveCircuitType = ecs.NewComponentType[PsdInterlockDriveCircuit]()
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user