From b5467e0139b286c0e3191433edd6c45503592b2c Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Tue, 19 Dec 2023 13:25:18 +0800 Subject: [PATCH] iscs ecs pscada --- component/iscs_pscada.go | 17 ++------- entity/iscs_pscada.go | 76 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 17 deletions(-) diff --git a/component/iscs_pscada.go b/component/iscs_pscada.go index b3a80f1..f0be8bf 100644 --- a/component/iscs_pscada.go +++ b/component/iscs_pscada.go @@ -71,12 +71,6 @@ type LightningArrester struct { Normal bool //true-正常 } -// AbcVoltageSource 三相电压源 -// -// 35KV 1#和2#进线连接的国家电网可以视作电压源,为整个一次图中最终电的来源 -type AbcVoltageSource struct { -} - // VoltageTransformer 变压器 // 具体异常-故障、报警、通信中断 type VoltageTransformer struct { @@ -85,14 +79,6 @@ type VoltageTransformer struct { OutputV uint32 //输出电压值,单位V } -// VoltageABTransmission 电压传递,从A传递到B,如断路器闭合时,电压会从断路器一端传递到另一端 -type VoltageABTransmission struct { -} - -// VoltageANTransmission 电压传递,电源从A点传递到N个点 -type VoltageANTransmission struct { -} - var ( CircuitBreakerType = ecs.NewComponentType[CircuitBreaker]() //断路器 ThreePositionSwitchType = ecs.NewComponentType[ThreePositionSwitch]() //三工位隔离开关 @@ -100,7 +86,8 @@ var ( DisconnectorType = ecs.NewComponentType[Disconnector]() //隔离开关 WireCabinetType = ecs.NewComponentType[WireCabinet]() //线柜 LightningArresterType = ecs.NewComponentType[LightningArrester]() //避雷器 - AbcVoltageSourceType = ecs.NewComponentType[AbcVoltageSource]() //三相电压源 + RectifierType = ecs.NewComponentType[Rectifier]() //整流器 + VoltageTransformerType = ecs.NewComponentType[VoltageTransformer]() //变压器 ) // BackupZiTouInputTag 备自投投入、退出标签 diff --git a/entity/iscs_pscada.go b/entity/iscs_pscada.go index c4c5dbe..90430af 100644 --- a/entity/iscs_pscada.go +++ b/entity/iscs_pscada.go @@ -5,12 +5,24 @@ import ( "joylink.club/rtsssimulation/component" ) +// NewCircuitBreakerEntity 创建断路器 +func NewCircuitBreakerEntity(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.CircuitBreakerType, component.DeviceExceptionType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + wd.EntityMap[id] = e + } + return e +} + // NewThreePositionSwitchEntity 创建三工位隔离开关实体 func NewThreePositionSwitchEntity(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.ThreePositionSwitchType)) + e := w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType, component.DeviceExceptionType)) component.UidType.SetValue(e, component.Uid{Id: id}) component.ThreePositionSwitchType.Set(e, &component.ThreePositionSwitch{Position: component.StpOpened}) wd.EntityMap[id] = e @@ -23,10 +35,70 @@ func NewHandcartSwitchEntity(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.HandcartSwitchType)) + e := w.Entry(w.Create(component.UidType, component.HandcartSwitchType, component.DeviceExceptionType)) component.UidType.SetValue(e, component.Uid{Id: id}) component.HandcartSwitchType.Set(e, &component.HandcartSwitch{Position: component.HpOpened}) wd.EntityMap[id] = e } return e } + +// NewRectifierEntity 创建整流器实体 +func NewRectifierEntity(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.RectifierType, component.DeviceExceptionType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + wd.EntityMap[id] = e + } + return e +} + +// NewDisconnectorEntity 创建隔离开关实体 +func NewDisconnectorEntity(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.DisconnectorType, component.DeviceExceptionType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + wd.EntityMap[id] = e + } + return e +} + +// NewWireCabinetEntity 创建线柜实体 +func NewWireCabinetEntity(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.WireCabinetType, component.DeviceExceptionType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + wd.EntityMap[id] = e + } + return e +} + +// NewLightningArresterEntity 创建避雷器实体 +func NewLightningArresterEntity(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.LightningArresterType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + wd.EntityMap[id] = e + } + return e +} + +// NewVoltageTransformerEntity 创建变压器实体 +func NewVoltageTransformerEntity(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.VoltageTransformerType, component.DeviceExceptionType)) + component.UidType.SetValue(e, component.Uid{Id: id}) + wd.EntityMap[id] = e + } + return e +}