2023-12-07 16:28:29 +08:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
)
|
|
|
|
|
2023-12-20 15:22:36 +08:00
|
|
|
//
|
|
|
|
|
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 {
|
2023-12-26 14:45:41 +08:00
|
|
|
e = w.Entry(w.Create(component.UidType, component.CircuitBreakerType, component.DeviceExceptionType))
|
2023-12-19 13:25:18 +08:00
|
|
|
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 {
|
2023-12-12 13:23:51 +08:00
|
|
|
wd := GetWorldData(w)
|
|
|
|
e, ok := wd.EntityMap[id]
|
|
|
|
if !ok {
|
2023-12-26 14:45:41 +08:00
|
|
|
e = w.Entry(w.Create(component.UidType, component.ThreePositionSwitchType, component.DeviceExceptionType))
|
2023-12-12 13:23:51 +08:00
|
|
|
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 {
|
2023-12-12 13:23:51 +08:00
|
|
|
wd := GetWorldData(w)
|
|
|
|
e, ok := wd.EntityMap[id]
|
|
|
|
if !ok {
|
2023-12-26 14:45:41 +08:00
|
|
|
e = w.Entry(w.Create(component.UidType, component.HandcartSwitchType, component.DeviceExceptionType))
|
2023-12-12 13:23:51 +08:00
|
|
|
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 {
|
2023-12-26 14:45:41 +08:00
|
|
|
e = w.Entry(w.Create(component.UidType, component.RectifierType, component.DeviceExceptionType))
|
2023-12-19 13:25:18 +08:00
|
|
|
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 {
|
2023-12-26 14:45:41 +08:00
|
|
|
e = w.Entry(w.Create(component.UidType, component.DisconnectorType, component.DeviceExceptionType))
|
2023-12-19 13:25:18 +08:00
|
|
|
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 {
|
2023-12-26 14:45:41 +08:00
|
|
|
e = w.Entry(w.Create(component.UidType, component.LightningArresterType))
|
2023-12-19 13:25:18 +08:00
|
|
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
2023-12-22 10:57:43 +08:00
|
|
|
component.LightningArresterType.Set(e, &component.LightningArrester{Normal: true})
|
2023-12-19 13:25:18 +08:00
|
|
|
wd.EntityMap[id] = e
|
|
|
|
}
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2023-12-22 13:20:06 +08:00
|
|
|
// NewEarthingDeviceEntity 创建接地装置实体
|
|
|
|
func NewEarthingDeviceEntity(w ecs.World, id string) *ecs.Entry {
|
|
|
|
wd := GetWorldData(w)
|
|
|
|
e, ok := wd.EntityMap[id]
|
|
|
|
if !ok {
|
2023-12-26 14:45:41 +08:00
|
|
|
e = w.Entry(w.Create(component.UidType, component.EarthingDeviceType))
|
2023-12-22 13:20:06 +08:00
|
|
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
|
|
|
component.EarthingDeviceType.Set(e, &component.EarthingDevice{Voltage: 0})
|
|
|
|
wd.EntityMap[id] = e
|
|
|
|
}
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2023-12-19 13:25:18 +08:00
|
|
|
// NewVoltageTransformerEntity 创建变压器实体
|
|
|
|
func NewVoltageTransformerEntity(w ecs.World, id string) *ecs.Entry {
|
|
|
|
wd := GetWorldData(w)
|
|
|
|
e, ok := wd.EntityMap[id]
|
|
|
|
if !ok {
|
2023-12-26 14:45:41 +08:00
|
|
|
e = w.Entry(w.Create(component.UidType, component.VoltageTransformerType, component.DeviceExceptionType))
|
2023-12-19 13:25:18 +08:00
|
|
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
|
|
|
wd.EntityMap[id] = e
|
|
|
|
}
|
|
|
|
return e
|
|
|
|
}
|
2023-12-19 17:10:30 +08:00
|
|
|
|
2024-01-05 11:30:39 +08:00
|
|
|
func NewPipeEntity(w ecs.World, id string) *ecs.Entry {
|
2023-12-19 17:10:30 +08:00
|
|
|
wd := GetWorldData(w)
|
|
|
|
e, ok := wd.EntityMap[id]
|
|
|
|
if !ok {
|
2024-01-05 11:30:39 +08:00
|
|
|
e = w.Entry(w.Create(component.UidType, component.PipeType))
|
2023-12-19 17:10:30 +08:00
|
|
|
wd.EntityMap[id] = e
|
|
|
|
}
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewPowerSourceEntity 创建PSCADA电源实体
|
2024-01-05 11:30:39 +08:00
|
|
|
func NewPowerSourceEntity(w ecs.World, id string) *ecs.Entry {
|
2023-12-19 17:10:30 +08:00
|
|
|
wd := GetWorldData(w)
|
|
|
|
e, ok := wd.EntityMap[id]
|
|
|
|
if !ok {
|
2024-01-05 11:30:39 +08:00
|
|
|
e = w.Entry(w.Create(component.UidType, component.ElectricitySourceType))
|
2023-12-19 17:10:30 +08:00
|
|
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
|
|
|
wd.EntityMap[id] = e
|
|
|
|
}
|
|
|
|
return e
|
|
|
|
}
|