From 1fb8a5b7eb80244c809a453065f1c0f4ae9d6e06 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Fri, 22 Sep 2023 10:53:51 +0800 Subject: [PATCH] =?UTF-8?q?umi=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entities/common_entity.go | 3 +- entities/psd_entity.go | 5 ++- examples/test1/sjzdj9/main.go | 5 ++- examples/test1/tmodel/device_model.go | 6 ++-- examples/test1/tmodel/switch_model.go | 6 ++-- examples/test1/tstorages/model_storage.go | 13 ++++---- examples/test1/tstorages/storage_manager.go | 7 ++--- jl-ecs-go | 2 +- repository/model.go | 18 +++++++++++ simulation/config.go | 4 +-- {umi => system}/model_umi.go | 35 +++++++-------------- system/signal_2xh1_system.go | 3 +- system/signal_3xh1_system.go | 3 +- system/signal_3xh2_system.go | 3 +- system/signal_3xh3_system.go | 3 +- system/signal_3xh4_system.go | 3 +- system/signal_dcxh_system.go | 3 +- system/signal_jckxh_system.go | 3 +- system/signal_jdxh_system.go | 3 +- system/switch_2jzdj9_system.go | 7 ++--- system/system.go | 13 ++++---- 21 files changed, 69 insertions(+), 79 deletions(-) rename {umi => system}/model_umi.go (64%) diff --git a/entities/common_entity.go b/entities/common_entity.go index 5f040f9..5095124 100644 --- a/entities/common_entity.go +++ b/entities/common_entity.go @@ -5,11 +5,10 @@ import ( "joylink.club/ecs" "joylink.club/rtsssimulation/system" - "joylink.club/rtsssimulation/umi" ) // CreateModelStorageEntity 创建模型仓库实体 -func CreateModelStorageEntity(w ecs.World, modelManager umi.IModelManager) *ecs.Entry { +func CreateModelStorageEntity(w ecs.World, modelManager system.IModelManager) *ecs.Entry { e := w.Create(system.ModelStorageComponent) system.ModelStorageComponent.Set(e, &system.ModelStorageRef{ModelManager: modelManager}) return e diff --git a/entities/psd_entity.go b/entities/psd_entity.go index b013940..f58eead 100644 --- a/entities/psd_entity.go +++ b/entities/psd_entity.go @@ -4,11 +4,10 @@ import ( "github.com/yohamta/donburi" "joylink.club/ecs" "joylink.club/rtsssimulation/system" - "joylink.club/rtsssimulation/umi" ) // CreateStationPsdsCircuitEntity 创建车站屏蔽门电路实体 -func CreateStationPsdsCircuitEntity(w ecs.World, stationId string, psds []umi.IPsdModel) *ecs.Entry { +func CreateStationPsdsCircuitEntity(w ecs.World, stationId string, psds []system.IPsdModel) *ecs.Entry { circuit := w.Create(system.EntityIdentityComponent, system.StationPsdsCircuitStateComponent, system.PsdTagHandlerComponent) system.EntityIdentityComponent.Set(circuit, &system.EntityIdentity{Id: stationId}) system.StationPsdsCircuitStateComponent.Set(circuit, system.NewStationPsdsCircuitState()) @@ -40,7 +39,7 @@ func CreateStationPsdsCircuitEntity(w ecs.World, stationId string, psds []umi.IP } psdEntry := w.Create(cc...) // - psdId := psd.(umi.IDeviceModel).Id() + psdId := psd.(system.IDeviceModel).Id() system.EntityIdentityComponent.Set(psdEntry, &system.EntityIdentity{Id: psdId}) system.PsdStateComponent.Set(psdEntry, system.NewPsdState()) system.PercentageDeviceStateComponent.Set(psdEntry, system.NewPercentageDeviceStateL()) diff --git a/examples/test1/sjzdj9/main.go b/examples/test1/sjzdj9/main.go index 44a663a..a1a6261 100644 --- a/examples/test1/sjzdj9/main.go +++ b/examples/test1/sjzdj9/main.go @@ -12,7 +12,6 @@ import ( "joylink.club/rtsssimulation/examples/test1/tstorages" "joylink.club/rtsssimulation/simulation" "joylink.club/rtsssimulation/system" - "joylink.club/rtsssimulation/umi" ) // Test 测试双机ZDJ9道岔 @@ -90,7 +89,7 @@ func addRelays(modelStorage *tstorages.ModelStorage) { modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-dbj")) modelStorage.AddModel(tmodel.NewRelayModel("sw1-sjzdj9-j2-fbj")) } -func findRelayModel(modelStorage *tstorages.ModelStorage, id string) umi.IDeviceModel { +func findRelayModel(modelStorage *tstorages.ModelStorage, id string) system.IDeviceModel { return modelStorage.FindModelById(id) } func addSwitchs(modelStorage *tstorages.ModelStorage) { @@ -129,7 +128,7 @@ func initComponents(w ecs.World) { swState := system.Switch2jZdj9StateComponent.Get(e) swMd := system.FindModelStorage(w).FindById(swId).(*tmodel.SwitchModel) for _, relay := range swMd.Relays { - relayId := relay.Relay.(umi.IDeviceModel).Id() + relayId := relay.Relay.(system.IDeviceModel).Id() relayEntry := system.FindEntityById(w, relayId) relayState := system.RelayStateComponent.Get(relayEntry) relayGroup := relay.RelayGroup diff --git a/examples/test1/tmodel/device_model.go b/examples/test1/tmodel/device_model.go index 70f1878..f6a26c8 100644 --- a/examples/test1/tmodel/device_model.go +++ b/examples/test1/tmodel/device_model.go @@ -1,7 +1,7 @@ package tmodel import ( - "joylink.club/rtsssimulation/umi" + "joylink.club/rtsssimulation/system" ) // 设备模型基础信息 @@ -9,12 +9,12 @@ type DeviceModel struct { // 设备id DevId string // 设备类型 - DevType umi.DeviceType + DevType system.DeviceType } func (me *DeviceModel) Id() string { return me.DevId } -func (me *DeviceModel) Type() umi.DeviceType { +func (me *DeviceModel) Type() system.DeviceType { return me.DevType } diff --git a/examples/test1/tmodel/switch_model.go b/examples/test1/tmodel/switch_model.go index fc8d3a5..1c26d88 100644 --- a/examples/test1/tmodel/switch_model.go +++ b/examples/test1/tmodel/switch_model.go @@ -2,13 +2,13 @@ package tmodel import ( "joylink.club/rtsssimulation/repository/model/proto" - "joylink.club/rtsssimulation/umi" + "joylink.club/rtsssimulation/system" ) // 道岔电路系统中的继电器 type SwitchRelay struct { //继电器模型 - Relay umi.IDeviceModel + Relay system.IDeviceModel //该继电器在该道岔电路系统中的组合类型 RelayGroup string //该继电器在该道岔电路系统中的功能名称 @@ -47,7 +47,7 @@ func (me *SwitchModel) FindCircuitRoleById(relayId string) (relayGroup string, r // FindRelayModelByCRole 根据继电器具体电路角色来获取继电器设备模型 // relayGroup-继电器组合类型 // relayName-继电器在电路中的名称 -func (me *SwitchModel) FindRelayModelByCRole(relayGroup string, relayName string) umi.IDeviceModel { +func (me *SwitchModel) FindRelayModelByCRole(relayGroup string, relayName string) system.IDeviceModel { for _, sr := range me.Relays { if sr.RelayGroup == relayGroup && sr.RelayName == relayName { return sr.Relay diff --git a/examples/test1/tstorages/model_storage.go b/examples/test1/tstorages/model_storage.go index 1bc0606..71274e1 100644 --- a/examples/test1/tstorages/model_storage.go +++ b/examples/test1/tstorages/model_storage.go @@ -2,23 +2,22 @@ package tstorages import ( "fmt" - - "joylink.club/rtsssimulation/umi" + "joylink.club/rtsssimulation/system" ) // 仿真模型数据定义 -type ModelData = umi.IDeviceModel +type ModelData = system.IDeviceModel // 模型存储、管理仓库 type ModelStorage struct { //key-模型id,value-模型指针 idModelMap map[string]ModelData //key-设备类型,value-对应设备类型的所有模型数据的指针列表 - typeModelMap map[umi.DeviceType][]ModelData + typeModelMap map[system.DeviceType][]ModelData } func NewModelStorage() *ModelStorage { - return &ModelStorage{idModelMap: make(map[string]ModelData, 2048), typeModelMap: make(map[umi.DeviceType][]ModelData, 128)} + return &ModelStorage{idModelMap: make(map[string]ModelData, 2048), typeModelMap: make(map[system.DeviceType][]ModelData, 128)} } // 添加模型数据 @@ -41,7 +40,7 @@ func (me *ModelStorage) AddModel(m ModelData) error { } // 根据设备类型获取该类型的所有设备数据 -func (me *ModelStorage) FindModelsByType(deviceType umi.DeviceType) []ModelData { +func (me *ModelStorage) FindModelsByType(deviceType system.DeviceType) []ModelData { models, ok := me.typeModelMap[deviceType] if ok { return models @@ -62,7 +61,7 @@ func (me *ModelStorage) FindModelById(id string) ModelData { } // 遍历某个类型的所有设备 -func (me *ModelStorage) ForEachModelsByType(deviceType umi.DeviceType, callback func(md ModelData)) { +func (me *ModelStorage) ForEachModelsByType(deviceType system.DeviceType, callback func(md ModelData)) { mds := me.FindModelsByType(deviceType) for _, modelData := range mds { callback(modelData) diff --git a/examples/test1/tstorages/storage_manager.go b/examples/test1/tstorages/storage_manager.go index 60b8ade..69c36ca 100644 --- a/examples/test1/tstorages/storage_manager.go +++ b/examples/test1/tstorages/storage_manager.go @@ -3,8 +3,7 @@ package tstorages import ( "fmt" "joylink.club/rtsssimulation/repository/model/proto" - - "joylink.club/rtsssimulation/umi" + "joylink.club/rtsssimulation/system" ) // 共享仓库映射 @@ -52,7 +51,7 @@ type WorldModelStorage struct { } // 根据模型的复合id获取模型数据 -func (me *WorldModelStorage) FindById(id string) umi.IDeviceModel { +func (me *WorldModelStorage) FindById(id string) system.IDeviceModel { md := me.Links.FindModelById(id) if md != nil { return md @@ -65,7 +64,7 @@ func (me *WorldModelStorage) FindById(id string) umi.IDeviceModel { } // 获取某类型设备的所有模型数据 -func (me *WorldModelStorage) FindByType(deviceType umi.DeviceType) []umi.IDeviceModel { +func (me *WorldModelStorage) FindByType(deviceType system.DeviceType) []system.IDeviceModel { if proto.DeviceType_DeviceType_Link == deviceType { return me.Links.FindModelsByType(deviceType) } else { diff --git a/jl-ecs-go b/jl-ecs-go index 2949aa5..4997760 160000 --- a/jl-ecs-go +++ b/jl-ecs-go @@ -1 +1 @@ -Subproject commit 2949aa52e18d5d7eb8281cbba968b4bb22b6e741 +Subproject commit 4997760ffb1284a7898ab84164671d5e21ec9248 diff --git a/repository/model.go b/repository/model.go index c8fb5d8..aec1ca2 100644 --- a/repository/model.go +++ b/repository/model.go @@ -21,3 +21,21 @@ func (m identity) Id() string { func (m identity) Type() proto.DeviceType { return m.deviceType } + +///////////////////////////////////////////////////////////// + +// IRelayCRole 获取继电器在具体电路中的角色(组合类型、功能名称) +// 如信号机3XH-1电路中点灯继电器:组合类型-"3XH-1" 功能名称-"DDJ" +// 对应设备电路中有继电器的设备模型须实现该接口 +type IRelayCRole interface { + //FindCircuitRoleById 根据继电器id获取在具体电路中的电路角色 + //relayId-继电器id + //relayGroup-继电器组合类型 + //relayName-继电器在电路中的名称 + //find-true找到,false未找到 + FindCircuitRoleById(relayId string) (relayGroup string, relayName string, find bool) + //FindRelayModelByCRole 根据继电器具体电路角色来获取继电器设备模型 + //relayGroup-继电器组合类型 + //relayName-继电器在电路中的名称 + FindRelayModelByCRole(relayGroup string, relayName string) Identity +} diff --git a/simulation/config.go b/simulation/config.go index 9233a05..69a036f 100644 --- a/simulation/config.go +++ b/simulation/config.go @@ -1,16 +1,16 @@ package simulation import ( + "joylink.club/rtsssimulation/system" "time" "joylink.club/ecs" - "joylink.club/rtsssimulation/umi" ) // WorldConfig 仿真world配置 type WorldConfig struct { //模型管理器,接收模型仓库管理器实例的指针 - ModelManager umi.IModelManager + ModelManager system.IModelManager //world 系统 Systems []ecs.ISystem //world tick diff --git a/umi/model_umi.go b/system/model_umi.go similarity index 64% rename from umi/model_umi.go rename to system/model_umi.go index 03e8c83..a5c239d 100644 --- a/umi/model_umi.go +++ b/system/model_umi.go @@ -1,14 +1,23 @@ -package umi +package system import ( "joylink.club/rtsssimulation/repository" "joylink.club/rtsssimulation/repository/model/proto" ) -// 用户设备模型与仿真底层设备交互定义 +// system 视角的模型定义 type DeviceType = proto.DeviceType +// IDeviceModel 仿真底层设备模型定义 +// 用户所有设备模型定义须实现该接口 +type IDeviceModel = repository.Identity + +// IRelayCRole 获取继电器在具体电路中的角色(组合类型、功能名称) +// 如信号机3XH-1电路中点灯继电器:组合类型-"3XH-1" 功能名称-"DDJ" +// 对应设备电路中有继电器的设备模型须实现该接口 +type IRelayCRole = repository.IRelayCRole + // IModelManager 模型管理接口 type IModelManager interface { //FindById 根据模型的复合id获取模型数据 @@ -21,10 +30,6 @@ type IModelManager interface { /////////////////////////////////////////////////////////// -// IDeviceModel 仿真底层设备模型定义 -// 用户所有设备模型定义须实现该接口 -type IDeviceModel = repository.Identity - // IPsdModel 仿真底层屏蔽门模型 // 用户所有屏蔽门模型定义须实现该接口 type IPsdModel interface { @@ -41,21 +46,3 @@ type IPsdModel interface { //IsX8 true-下行8编组 IsX8() bool } - -// ////////////////////////////////////////////////////////// - -// IRelayCRole 获取继电器在具体电路中的角色(组合类型、功能名称) -// 如信号机3XH-1电路中点灯继电器:组合类型-"3XH-1" 功能名称-"DDJ" -// 对应设备电路中有继电器的设备模型须实现该接口 -type IRelayCRole interface { - //FindCircuitRoleById 根据继电器id获取在具体电路中的电路角色 - //relayId-继电器id - //relayGroup-继电器组合类型 - //relayName-继电器在电路中的名称 - //find-true找到,false未找到 - FindCircuitRoleById(relayId string) (relayGroup string, relayName string, find bool) - //FindRelayModelByCRole 根据继电器具体电路角色来获取继电器设备模型 - //relayGroup-继电器组合类型 - //relayName-继电器在电路中的名称 - FindRelayModelByCRole(relayGroup string, relayName string) IDeviceModel -} diff --git a/system/signal_2xh1_system.go b/system/signal_2xh1_system.go index 687b34c..e3ea4ff 100644 --- a/system/signal_2xh1_system.go +++ b/system/signal_2xh1_system.go @@ -5,7 +5,6 @@ import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" sysEvent "joylink.club/rtsssimulation/system/event" - "joylink.club/rtsssimulation/umi" ) // Signal2XH1State 电路状态:**信号机2XH-1(红-绿) 出段(场)信号机 或 **出站区间阻挡信号机 @@ -72,7 +71,7 @@ var Signal2XH1RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay //根据event来更新Signal2XH1State中对应继电器的状态 signal2XH1Query.Each(w, func(e *ecs.Entry) { signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) - roler, ok := signalModel.(umi.IRelayCRole) + roler, ok := signalModel.(IRelayCRole) if ok { if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find { if relayGroup == SIGNAL_2XH1 { diff --git a/system/signal_3xh1_system.go b/system/signal_3xh1_system.go index 3ebb32b..80f22b6 100644 --- a/system/signal_3xh1_system.go +++ b/system/signal_3xh1_system.go @@ -6,7 +6,6 @@ import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" sysEvent "joylink.club/rtsssimulation/system/event" - "joylink.club/rtsssimulation/umi" ) // 信号机电路继电器组合类型和功能名称常量 @@ -98,7 +97,7 @@ var Signal3XH1RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay //根据event来更新Signal3XH1State中对应继电器的状态 signal3XH1Query.Each(w, func(e *ecs.Entry) { signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) - roler, ok := signalModel.(umi.IRelayCRole) + roler, ok := signalModel.(IRelayCRole) if ok { if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find { if relayGroup == SIGNAL_3XH1 { diff --git a/system/signal_3xh2_system.go b/system/signal_3xh2_system.go index 230d2b9..86ae0e0 100644 --- a/system/signal_3xh2_system.go +++ b/system/signal_3xh2_system.go @@ -5,7 +5,6 @@ import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" sysEvent "joylink.club/rtsssimulation/system/event" - "joylink.club/rtsssimulation/umi" ) // Signal3XH2State 电路状态:信号机3XH-2(红-绿-黄) 道岔防护信号机(三显示不封灯、无单黄显示、带引导) @@ -76,7 +75,7 @@ var Signal3XH2RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay //根据event来更新Signal3XH1State中对应继电器的状态 signal3XH2Query.Each(w, func(e *ecs.Entry) { signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) - roler, ok := signalModel.(umi.IRelayCRole) + roler, ok := signalModel.(IRelayCRole) if ok { if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find { if relayGroup == SIGNAL_3XH2 { diff --git a/system/signal_3xh3_system.go b/system/signal_3xh3_system.go index 262692a..e417f59 100644 --- a/system/signal_3xh3_system.go +++ b/system/signal_3xh3_system.go @@ -5,7 +5,6 @@ import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" sysEvent "joylink.club/rtsssimulation/system/event" - "joylink.club/rtsssimulation/umi" ) // Signal3XH3State 电路状态:信号机3XH-3(红-绿-黄) 道岔防护信号机(三显示封绿灯、有单黄显示、带引导) @@ -72,7 +71,7 @@ var Signal3XH3RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay //根据event来更新Signal3XH3State中对应继电器的状态 signal3XH3Query.Each(w, func(e *ecs.Entry) { signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) - roler, ok := signalModel.(umi.IRelayCRole) + roler, ok := signalModel.(IRelayCRole) if ok { if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find { if relayGroup == SIGNAL_3XH3 { diff --git a/system/signal_3xh4_system.go b/system/signal_3xh4_system.go index 88485d6..7e00ea9 100644 --- a/system/signal_3xh4_system.go +++ b/system/signal_3xh4_system.go @@ -5,7 +5,6 @@ import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" sysEvent "joylink.club/rtsssimulation/system/event" - "joylink.club/rtsssimulation/umi" ) // Signal3XH4State 电路状态:信号机3XH-4(红-绿-黄) 出站兼道岔防护信号机(三显示不封灯、有单黄显示、无引导) @@ -72,7 +71,7 @@ var Signal3XH4RelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay //根据event来更新Signal3XH4State中对应继电器的状态 signal3XH4Query.Each(w, func(e *ecs.Entry) { signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) - roler, ok := signalModel.(umi.IRelayCRole) + roler, ok := signalModel.(IRelayCRole) if ok { if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find { if relayGroup == SIGNAL_3XH4 { diff --git a/system/signal_dcxh_system.go b/system/signal_dcxh_system.go index 381a2db..c906fb4 100644 --- a/system/signal_dcxh_system.go +++ b/system/signal_dcxh_system.go @@ -5,7 +5,6 @@ import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" sysEvent "joylink.club/rtsssimulation/system/event" - "joylink.club/rtsssimulation/umi" ) // SignalDCXHState 电路状态:信号机DCXH(蓝-白) 调车信号机 @@ -62,7 +61,7 @@ var SignalDCXHRelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay //根据event来更新SignalDCXHState中对应继电器的状态 signalDCXHQuery.Each(w, func(e *ecs.Entry) { signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) - roler, ok := signalModel.(umi.IRelayCRole) + roler, ok := signalModel.(IRelayCRole) if ok { if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find { if relayGroup == SIGNAL_DCXH { diff --git a/system/signal_jckxh_system.go b/system/signal_jckxh_system.go index 9b238b0..1ff2c20 100644 --- a/system/signal_jckxh_system.go +++ b/system/signal_jckxh_system.go @@ -5,7 +5,6 @@ import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" sysEvent "joylink.club/rtsssimulation/system/event" - "joylink.club/rtsssimulation/umi" ) // SignalJCKXHState 电路状态:信号机JCKXH(红-白-黄) 进/出库列车兼调车信号机(三显示不封灯、有单黄显示、无引导) @@ -69,7 +68,7 @@ var SignalJCKXHRelayActionEventProcessor = func(w ecs.World, event sysEvent.Rela //根据event来更新SignalJCKXHState中对应继电器的状态 signalJCKXHQuery.Each(w, func(e *ecs.Entry) { signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) - roler, ok := signalModel.(umi.IRelayCRole) + roler, ok := signalModel.(IRelayCRole) if ok { if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find { if relayGroup == SIGNAL_JCKXH { diff --git a/system/signal_jdxh_system.go b/system/signal_jdxh_system.go index 6ca2b53..f7cfee1 100644 --- a/system/signal_jdxh_system.go +++ b/system/signal_jdxh_system.go @@ -5,7 +5,6 @@ import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" sysEvent "joylink.club/rtsssimulation/system/event" - "joylink.club/rtsssimulation/umi" ) // SignalJDXHState 电路状态:信号机JDXH(红-绿-黄) 进段信号机(三显示不封灯、无单黄显示、带引导) @@ -71,7 +70,7 @@ var SignalJDXHRelayActionEventProcessor = func(w ecs.World, event sysEvent.Relay //根据event来更新SignalJDXHState中对应继电器的状态 signalJDXHQuery.Each(w, func(e *ecs.Entry) { signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) - roler, ok := signalModel.(umi.IRelayCRole) + roler, ok := signalModel.(IRelayCRole) if ok { if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find { if relayGroup == SIGNAL_JDXH { diff --git a/system/switch_2jzdj9_system.go b/system/switch_2jzdj9_system.go index 136ecd8..79e18d7 100644 --- a/system/switch_2jzdj9_system.go +++ b/system/switch_2jzdj9_system.go @@ -7,7 +7,6 @@ import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" sysEvent "joylink.club/rtsssimulation/system/event" - "joylink.club/rtsssimulation/umi" ) // --------联锁驱动----------------- @@ -298,7 +297,7 @@ var Switch2jzdj9RelayActionEventProcessor = func(w ecs.World, event sysEvent.Rel log.Println("==>>收到继电器动作事件:id = ", event.Id, " xh = ", event.Xh) zdj9Query.Each(w, func(e *ecs.Entry) { switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) - roler, ok := switchModel.(umi.IRelayCRole) + roler, ok := switchModel.(IRelayCRole) if ok { if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find { state := Switch2jZdj9StateComponent.Get(e) @@ -384,9 +383,9 @@ var Switch2jzdj9RelayActionEventProcessor = func(w ecs.World, event sysEvent.Rel // 发送继电器需要改变事件 func (me *Switch2jZdj9System) publishRelayNeedChangeEvent(w ecs.World, switchEntry *ecs.Entry, relayGroup string, relayName string, needXh bool) { switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(switchEntry).Id) - relayRole, _ := switchModel.(umi.IRelayCRole) + relayRole, _ := switchModel.(IRelayCRole) relayModel := relayRole.FindRelayModelByCRole(relayGroup, relayName) - sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.(umi.IDeviceModel).Id(), Xh: needXh}) + sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.(IDeviceModel).Id(), Xh: needXh}) } // 断相保护电路运算 diff --git a/system/system.go b/system/system.go index 83f2111..7ff282d 100644 --- a/system/system.go +++ b/system/system.go @@ -7,7 +7,6 @@ import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" sysEvent "joylink.club/rtsssimulation/system/event" - "joylink.club/rtsssimulation/umi" ) // EntityIdentity 实体身份定义 @@ -40,7 +39,7 @@ func QueryEntityById(world ecs.World, q *ecs.Query, id string) *ecs.Entry { var modelStorageQuery = ecs.NewQuery(filter.Contains(ModelStorageComponent)) // FindModelStorage 获取模型仓库 -func FindModelStorage(world ecs.World) umi.IModelManager { +func FindModelStorage(world ecs.World) IModelManager { e, _ := modelStorageQuery.First(world) return ModelStorageComponent.Get(e).ModelManager } @@ -74,7 +73,7 @@ var EntityTagHandlerComponent = ecs.NewComponentType[EntityTagHandler]() // ModelStorageRef 模型仓库引用 // 用于world内使用,查询模型 type ModelStorageRef struct { - ModelManager umi.IModelManager + ModelManager IModelManager } // ModelStorageComponent 模型仓库组件 @@ -89,9 +88,9 @@ var ModelStorageComponent = ecs.NewComponentType[ModelStorageRef]() // xh-true:吸合,false:落下 func DriveRelay(w ecs.World, circuitModelId string, relayGroup string, relayName string, xh bool) bool { if swModel := FindModelStorage(w).FindById(circuitModelId); swModel != nil { - if roler, isCr := swModel.(umi.IRelayCRole); isCr { + if roler, isCr := swModel.(IRelayCRole); isCr { if relayModel := roler.FindRelayModelByCRole(relayGroup, relayName); relayModel != nil { - if deviceModel, isDm := relayModel.(umi.IDeviceModel); isDm { + if deviceModel, isDm := relayModel.(IDeviceModel); isDm { relayId := deviceModel.Id() sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayId, Xh: xh}) return true @@ -105,9 +104,9 @@ func DriveRelay(w ecs.World, circuitModelId string, relayGroup string, relayName func createRelayNeedChangeEvent(w ecs.World, circuitModelId string, relayGroup string, relayName string, xh bool) (*sysEvent.RelayNeedChangeEvent, bool) { if swModel := FindModelStorage(w).FindById(circuitModelId); swModel != nil { - if roler, isCr := swModel.(umi.IRelayCRole); isCr { + if roler, isCr := swModel.(IRelayCRole); isCr { if relayModel := roler.FindRelayModelByCRole(relayGroup, relayName); relayModel != nil { - if deviceModel, isDm := relayModel.(umi.IDeviceModel); isDm { + if deviceModel, isDm := relayModel.(IDeviceModel); isDm { relayId := deviceModel.Id() return &sysEvent.RelayNeedChangeEvent{Id: relayId, Xh: xh}, true }