rts-sim-module/entity/iscs_pscada.go

135 lines
4.2 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-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 {
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))
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-26 14:45:41 +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 {
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})
component.LightningArresterType.Set(e, &component.LightningArrester{Normal: true})
2023-12-19 13:25:18 +08:00
wd.EntityMap[id] = e
}
return e
}
// 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))
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
// NewPowerPipeEntity 创建PSCADA电力母线实体
func NewPowerPipeEntity(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.PowerPipeType))
2023-12-19 17:10:30 +08:00
component.UidType.SetValue(e, component.Uid{Id: id})
component.PowerPipeType.Set(e, &component.PowerPipe{Sources: make(map[string]*component.ElePower)})
2023-12-19 17:10:30 +08:00
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 {
2023-12-26 14:45:41 +08:00
e = w.Entry(w.Create(component.UidType, component.PowerSourceType))
2023-12-19 17:10:30 +08:00
component.UidType.SetValue(e, component.Uid{Id: id})
component.PowerSourceType.Set(e, &component.PowerSource{Ac: ac, Voltage: voltage})
wd.EntityMap[id] = e
}
return e
}