From c06743297f4cf9e862aa06ffe6dfa49b1a457804 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Tue, 12 Dec 2023 13:23:51 +0800 Subject: [PATCH] =?UTF-8?q?ISCS=E7=8E=AF=E5=A2=83=E4=B8=8E=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=9B=91=E6=8E=A7=E7=B3=BB=E7=BB=9Fecs=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entity/iscs_bas.go | 18 ++++++++--- entity/iscs_pscada.go | 72 +++++++++++++++++++++++++------------------ 2 files changed, 56 insertions(+), 34 deletions(-) diff --git a/entity/iscs_bas.go b/entity/iscs_bas.go index 44e9def..db7e7e5 100644 --- a/entity/iscs_bas.go +++ b/entity/iscs_bas.go @@ -7,8 +7,13 @@ import ( // NewIscsFanEntity 创建风机实体 func NewIscsFanEntity(w ecs.World, id string) *ecs.Entry { - e := w.Entry(w.Create(component.UidType, component.FanType, component.FanStateType)) - component.UidType.SetValue(e, component.Uid{Id: id}) + wd := GetWorldData(w) + e, ok := wd.EntityMap[id] + if !ok { + e := w.Entry(w.Create(component.UidType, component.FanType, component.FanStateType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + wd.EntityMap[id] = e + } return e } @@ -38,8 +43,13 @@ func NewCombinedAirConditioner(w ecs.World, id string) *ecs.Entry { // NewElectricControlValve 创建电动调节阀实体 func NewElectricControlValve(w ecs.World, id string) *ecs.Entry { - e := w.Entry(w.Create(component.UidType, component.ElectricControlValveType, component.TwoPositionTransformType)) - component.UidType.SetValue(e, component.Uid{Id: id}) + wd := GetWorldData(w) + e, ok := wd.EntityMap[id] + if !ok { + e := w.Entry(w.Create(component.UidType, component.ElectricControlValveType, component.TwoPositionTransformType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + wd.EntityMap[id] = e + } return e } diff --git a/entity/iscs_pscada.go b/entity/iscs_pscada.go index c92c6cf..9f119f3 100644 --- a/entity/iscs_pscada.go +++ b/entity/iscs_pscada.go @@ -53,17 +53,17 @@ func NewIscsThreePositionSwitchEntity(w ecs.World, id string) *ecs.Entry { return entry } -// NewIscsTransBusbarEntity ISCS创建输电母线 -func NewIscsTransBusbarEntity(w ecs.World, id string, haveBackupZiTou bool) *ecs.Entry { - entry := w.Entry(w.Create(component.UidType, component.TransBusbarType)) - component.UidType.SetValue(entry, component.Uid{Id: id}) - component.TransBusbarType.Set(entry, &component.TransBusbar{Vl: component.VlNon, Elec: component.EywLossing}) - // - if haveBackupZiTou { - entry.AddComponent(component.IscsTransBackupZiTouStateType) +// NewIscsTransBusbarEntity 创建输电母线实体 +func NewIscsTransBusbarEntity(w ecs.World, id string) *ecs.Entry { + wd := GetWorldData(w) + e, ok := wd.EntityMap[id] + if !ok { + e := w.Entry(w.Create(component.UidType, component.TransBusbarType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + component.TransBusbarType.Set(e, &component.TransBusbar{Vl: component.VlNon, Elec: component.EywLossing}) + wd.EntityMap[id] = e } - // - return entry + return e } ///////////////////////////////////////////通用///////////////////////////////////////////////////////// @@ -72,17 +72,27 @@ func NewIscsTransBusbarEntity(w ecs.World, id string, haveBackupZiTou bool) *ecs // 如断路器 // 如PT、负极柜隔离开关、轨电位、上网隔离开关、隔离开关 func NewTwoPositionSwitchEntity(w ecs.World, id string) *ecs.Entry { - e := w.Entry(w.Create(component.UidType, component.TwoPositionSwitchType)) - component.UidType.SetValue(e, component.Uid{Id: id}) - component.TwoPositionSwitchType.Set(e, &component.TwoPositionSwitch{Closed: false}) + wd := GetWorldData(w) + e, ok := wd.EntityMap[id] + if !ok { + e := w.Entry(w.Create(component.UidType, component.TwoPositionSwitchType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + component.TwoPositionSwitchType.Set(e, &component.TwoPositionSwitch{Closed: false}) + wd.EntityMap[id] = e + } return e } // NewThreePositionSwitchEntity 创建三工位隔离开关实体 func NewThreePositionSwitchEntity(w ecs.World, id string) *ecs.Entry { - e := w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType)) - component.UidType.SetValue(e, component.Uid{Id: id}) - component.ThreePositionSwitchType.Set(e, &component.ThreePositionSwitch{Position: component.StpOpened}) + wd := GetWorldData(w) + e, ok := wd.EntityMap[id] + if !ok { + e := w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + component.ThreePositionSwitchType.Set(e, &component.ThreePositionSwitch{Position: component.StpOpened}) + wd.EntityMap[id] = e + } return e } @@ -91,24 +101,26 @@ func NewThreePositionSwitchEntity(w ecs.World, id string) *ecs.Entry { // Epu所有状态如:35kV进线柜、35kV出线柜、1500V直流进线柜、配电变馈线柜、整流变馈线柜、35kV母联柜、500V直流馈线柜、1500V直流馈线柜、1500V直流负极柜 // Epu状态中除去报警,如:400V进线柜、400V母联柜、三级负荷总开关、上网隔离开关柜、接口柜 func NewElectricPowerDeviceEntity(w ecs.World, id string) *ecs.Entry { - e := w.Entry(w.Create(component.UidType, component.ElecDeviceType)) - component.UidType.SetValue(e, component.Uid{Id: id}) - component.ElecDeviceType.Set(e, &component.ElecDevice{Normal: true}) + wd := GetWorldData(w) + e, ok := wd.EntityMap[id] + if !ok { + e := w.Entry(w.Create(component.UidType, component.ElecDeviceType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + component.ElecDeviceType.Set(e, &component.ElecDevice{Normal: true}) + wd.EntityMap[id] = e + } return e } // NewHandcartSwitchEntity 创建手车实体 func NewHandcartSwitchEntity(w ecs.World, id string) *ecs.Entry { - e := w.Entry(w.Create(component.UidType, component.HandcartSwitchType)) - component.UidType.SetValue(e, component.Uid{Id: id}) - component.HandcartSwitchType.Set(e, &component.HandcartSwitch{Position: component.HpOpened}) - return e -} - -// NewTransBusbarEntity 创建输电母线实体 -func NewTransBusbarEntity(w ecs.World, id string) *ecs.Entry { - e := w.Entry(w.Create(component.UidType, component.TransBusbarType)) - component.UidType.SetValue(e, component.Uid{Id: id}) - component.TransBusbarType.Set(e, &component.TransBusbar{Vl: component.VlNon, Elec: component.EywLossing}) + wd := GetWorldData(w) + e, ok := wd.EntityMap[id] + if !ok { + e := w.Entry(w.Create(component.UidType, component.HandcartSwitchType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + component.HandcartSwitchType.Set(e, &component.HandcartSwitch{Position: component.HpOpened}) + wd.EntityMap[id] = e + } return e }