From 91dcac0c29c421ec6a29772cd02b117fa4278fb2 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Wed, 13 Sep 2023 11:28:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=9C=BA3XH-1=E7=94=B5?= =?UTF-8?q?=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jl-ecs-go | 2 +- system/signal_3xh1_system.go | 14 ++++++++++---- umi/model_umi.go | 9 +++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/jl-ecs-go b/jl-ecs-go index 8ffea35..c3b9d96 160000 --- a/jl-ecs-go +++ b/jl-ecs-go @@ -1 +1 @@ -Subproject commit 8ffea356da60f2811eed5735c5733c0a24b0fbea +Subproject commit c3b9d965c607a2f29e0bdc586aba6851d4f29f13 diff --git a/system/signal_3xh1_system.go b/system/signal_3xh1_system.go index dd32522..1272080 100644 --- a/system/signal_3xh1_system.go +++ b/system/signal_3xh1_system.go @@ -62,9 +62,9 @@ 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.IRelayCRoler) + roler, ok := signalModel.(umi.IRelayCRole) if ok { - if _, relayName, find := roler.FindCircuitRole(event.Id); find { + if _, relayName, find := roler.FindCircuitRoleById(event.Id); find { state := Signal3XH1StateComponent.Get(e) switch relayName { case "DDJ": @@ -148,7 +148,10 @@ func (me *Signal3XH1System) calculateDJ(w ecs.World, e *ecs.Entry, state *Signal isDj := !state.DDJ //通知继电器进行动作 if _DJ != isDj { - sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: "123", Xh: isDj}) + signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) + relayRole, _ := signalModel.(umi.IRelayCRole) + relayModel := relayRole.FindRelayModelByCRole("3XH-1", "DJ") + sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.GetId(), Xh: isDj}) } } @@ -159,6 +162,9 @@ func (me *Signal3XH1System) calculate2DJ(w ecs.World, e *ecs.Entry, state *Signa is2DJ := state.U //通知继电器进行动作 if _2DJ != is2DJ { - sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: "123", Xh: is2DJ}) + signalModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id) + relayRole, _ := signalModel.(umi.IRelayCRole) + relayModel := relayRole.FindRelayModelByCRole("3XH-1", "2DJ") + sysEvent.RelayNeedChangeEventBus.Publish(w, &sysEvent.RelayNeedChangeEvent{Id: relayModel.GetId(), Xh: is2DJ}) } } diff --git a/umi/model_umi.go b/umi/model_umi.go index 951784c..7b1b3d0 100644 --- a/umi/model_umi.go +++ b/umi/model_umi.go @@ -144,10 +144,15 @@ type IRelayModel interface { // 获取继电器在具体电路中的角色(组合类型、功能名称) // 如信号机3XH-1电路中点灯继电器:组合类型-"3XH-1" 功能名称-"DDJ" // 对应设备电路中有继电器的设备模型须实现该接口 -type IRelayCRoler interface { +type IRelayCRole interface { + //根据继电器id获取在具体电路中的电路角色 //relayId-继电器id //relayGroup-继电器组合类型 //relayName-继电器在电路中的名称 //find-true找到,false未找到 - FindCircuitRole(relayId string) (relayGroup string, relayName string, find bool) + FindCircuitRoleById(relayId string) (relayGroup string, relayName string, find bool) + //根据继电器具体电路角色来获取继电器设备模型 + //relayGroup-继电器组合类型 + //relayName-继电器在电路中的名称 + FindRelayModelByCRole(relayGroup string, relayName string) IDeviceModel }