rts-sim-module/entity/iscs_pscada.go

130 lines
3.9 KiB
Go
Raw Normal View History

2023-12-07 16:28:29 +08:00
package entity
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
)
2023-12-19 13:25:18 +08:00
// 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
}
2023-12-07 16:28:29 +08:00
// NewThreePositionSwitchEntity 创建三工位隔离开关实体
func NewThreePositionSwitchEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
2023-12-19 13:25:18 +08:00
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
}
2023-12-07 16:28:29 +08:00
return e
}
// NewHandcartSwitchEntity 创建手车实体
func NewHandcartSwitchEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
2023-12-19 13:25:18 +08:00
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
}
2023-12-07 16:28:29 +08:00
return e
}
2023-12-19 13:25:18 +08:00
// 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
}
2023-12-19 17:10:30 +08:00
// NewPowerPipeEntity 创建PSCADA电力母线实体
func NewPowerPipeEntity(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.PowerPipeType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewPowerSourceEntity 创建PSCADA电源实体
func NewPowerSourceEntity(w ecs.World, id string, ac bool, voltage uint32) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.PowerSourceType))
component.UidType.SetValue(e, component.Uid{Id: id})
component.PowerSourceType.Set(e, &component.PowerSource{Ac: ac, Voltage: voltage})
wd.EntityMap[id] = e
}
return e
}