From 46507159c54691430dcec9f0ae9cb09ea66e2e7d Mon Sep 17 00:00:00 2001 From: walker Date: Mon, 6 Nov 2023 17:32:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E9=9B=B6=E6=95=A3=E7=BB=84=E5=90=88?= =?UTF-8?q?=E7=9A=84=E7=BB=A7=E7=94=B5=E5=99=A8=E5=8A=A0=E8=BD=BD=E8=BF=9B?= =?UTF-8?q?=E4=BB=BF=E7=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entity/ci_qc.go | 1 + entity/init.go | 1 + entity/station.go | 9 +++++++++ fi/ci_qc.go | 5 +++++ repository/repository_manager.go | 18 +++++++++++++++++- repository/station.go | 9 +++++++-- sys/bind.go | 1 + 7 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 fi/ci_qc.go diff --git a/entity/ci_qc.go b/entity/ci_qc.go index 027e04d..608cee6 100644 --- a/entity/ci_qc.go +++ b/entity/ci_qc.go @@ -23,6 +23,7 @@ func LoadCiQC(w ecs.World) error { // if len(csr.QdList) == 0 { // return fmt.Errorf("加载联锁驱采卡实体失败,车站'%s'无驱动码表数据", csr.StationId) // } + // 加载联锁驱采卡实体 if len(csr.CjList) == 0 || len(csr.QdList) == 0 { slog.Warn("加载联锁驱采卡实体失败,无驱动/采集码表数据", "车站", csr.StationId) continue diff --git a/entity/init.go b/entity/init.go index fa8aa36..6be3570 100644 --- a/entity/init.go +++ b/entity/init.go @@ -9,6 +9,7 @@ import ( func Load(w ecs.World, repo *repository.Repository) error { // 初始化世界数据单例组件 LoadWorldData(w, repo) + // 加载联锁驱采卡相关实体 err := LoadCiQC(w) if err != nil { return err diff --git a/entity/station.go b/entity/station.go index 5e357d2..d62adc6 100644 --- a/entity/station.go +++ b/entity/station.go @@ -3,12 +3,21 @@ package entity import ( "joylink.club/ecs" "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/repository" ) func LoadStations(w ecs.World) error { data := GetWorldData(w) stations := data.Repo.StationList() + // 加载零散组合继电器 for _, station := range stations { + for _, ecg := range station.ComponentGroups() { + if ecg.Code() == "LS" { + for _, ele := range ecg.Components() { + NewRelayEntity(w, ele.(*repository.Relay), data.EntityMap) + } + } + } entry := NewStationEntity(w, station.Id(), data) if station.GetIbpSpk() != nil { // 人员防护 LoadSPKEntity(w, entry, station.GetIbpSpk(), data) diff --git a/fi/ci_qc.go b/fi/ci_qc.go new file mode 100644 index 0000000..6750648 --- /dev/null +++ b/fi/ci_qc.go @@ -0,0 +1,5 @@ +package fi + +func GetCiQcState() { + +} diff --git a/repository/repository_manager.go b/repository/repository_manager.go index fc15136..bd81334 100644 --- a/repository/repository_manager.go +++ b/repository/repository_manager.go @@ -862,8 +862,24 @@ func buildStationRelationShip(source *proto.Repository, repo *Repository) error bindIbpDevice(repo, ref.Components, station.GetIbpEmp()) case "SPKS": bindIbpDevice(repo, ref.Components, station.GetIbpSpk()) + case "LS": + { + var components []IGroupedElectronicComponent + for _, cmp := range ref.Components { + switch cmp.DeviceType { + case proto.DeviceType_DeviceType_Relay: + components = append(components, repo.relayMap[cmp.Id]) + default: + return fmt.Errorf("集中站'%s'的LS组合数据异常,包含非继电器设备: type=%s, id=%s", station.Id(), cmp.DeviceType, cmp.Id) + } + } + station.componentGroups = append(station.componentGroups, &ElectronicComponentGroup{ + code: ref.Code, + components: components, + }) + } default: - slog.Warn("车站实体未实现【%s】绑定逻辑", ref.Code) + slog.Warn("未知的车站组合", "组合code", ref.Code) } } } diff --git a/repository/station.go b/repository/station.go index 1b5fd87..fcfa22f 100644 --- a/repository/station.go +++ b/repository/station.go @@ -4,8 +4,9 @@ import "joylink.club/rtsssimulation/repository/model/proto" type Station struct { Identity - code string - ibp *IBP + code string + ibp *IBP + componentGroups []*ElectronicComponentGroup } func NewStation(id, code string) *Station { @@ -27,3 +28,7 @@ func (s *Station) GetIbpEmp() *IBPRefMap { func (s *Station) GetIbpSpk() *IBPRefMap { return s.ibp.Spk } + +func (s *Station) ComponentGroups() []*ElectronicComponentGroup { + return s.componentGroups +} diff --git a/sys/bind.go b/sys/bind.go index cd6a8d9..9985c31 100644 --- a/sys/bind.go +++ b/sys/bind.go @@ -17,6 +17,7 @@ func BindSystem(w ecs.World) { device_sys.NewDBQSys(), device_sys.NewZzjSys(), device_sys.NewTurnoutSys(), + device_sys.NewCiQcSys(), circuit_sys.NewZdj9TwoDragSys(), circuit_sys.NewSignal2XH1System(), circuit_sys.NewSignal3XH1System(),